decompiled_code:
_BOOL8 __fastcall rfc1918_parser_execute(_BYTE *a1, __int64 a2)
{
_BYTE *v2; // rsi
_BOOL8 result; // rax
char v4; // cl
_BYTE *v5; // r11
char v6; // al
_BYTE *v7; // r9
char v8; // r11
_BYTE *v9; // rdx
char v10; // cl
_BYTE *v11; // r10
char v12; // r11
char v13; // si
char v14; // r11
char v15; // r8
char v16; // r10
char v17; // di
char v18; // r8
char v19; // r9
char v20; // al
unsigned __int8 v21; // di

v2 = &a1[a2];
result = 0LL;
if ( a1 == v2 || *a1 != 49 || v2 == a1 + 1 )
return result;
v4 = a1[1];
if ( v4 == 55 )
{
if ( v2 == a1 + 2 || a1[2] != 50 || v2 == a1 + 3 || a1[3] != 46 || v2 == a1 + 4 )
return result;
v14 = a1[4];
if ( v14 == 50 )
{
v5 = a1 + 5;
if ( v2 == a1 + 5 || (unsigned __int8)(a1[5] - 48) > 9u )
return 0LL;
}
else if ( v14 == 51 )
{
v5 = a1 + 5;
if ( v2 == a1 + 5 || (unsigned __int8)(a1[5] - 48) > 1u )
return 0LL;
}
else
{
result = 0LL;
if ( v14 != 49 )
return result;
v5 = a1 + 5;
if ( v2 == a1 + 5 || (unsigned __int8)(a1[5] - 54) > 3u )
return result;
}
goto LABEL_29;
}
if ( v4 == 57 )
{
if ( v2 == a1 + 2 )
return result;
if ( a1[2] != 50 )
return result;
if ( v2 == a1 + 3 )
return result;
if ( a1[3] != 46 )
return result;
result = 0LL;
if ( v2 == a1 + 4 )
return result;
if ( a1[4] != 49 )
return result;
if ( v2 == a1 + 5 )
return result;
if ( a1[5] != 54 )
return result;
v5 = a1 + 6;
if ( v2 == a1 + 6 || a1[6] != 56 )
return result;
goto LABEL_29;
}
if ( v4 != 48 )
return result;
if ( v2 == a1 + 2 )
return result;
if ( a1[2] != 46 )
return result;
v5 = a1 + 3;
if ( v2 == a1 + 3 )
return result;
v6 = a1[3];
switch ( v6 )
{
case '1':
v5 = a1 + 4;
if ( v2 == a1 + 4 )
return 0LL;
v17 = a1[4];
if ( v17 == 46 )
{
v7 = v5;
goto LABEL_31;
}
result = 0LL;
if ( (unsigned __int8)(v17 - 48) > 9u )
return result;
break;
case '2':
v7 = a1 + 4;
if ( v2 == a1 + 4 )
return 0LL;
v15 = a1[4];
if ( v15 == 46 )
goto LABEL_31;
if ( v15 == 53 )
{
v7 = a1 + 5;
if ( v2 == a1 + 5 )
return 0LL;
v16 = a1[5];
if ( v16 == 46 )
goto LABEL_31;
if ( (unsigned __int8)(v16 - 48) > 5u )
return 0LL;
}
else
{
if ( v15 <= 52 )
{
if ( v15 <= 47 )
return 0LL;
v5 = a1 + 4;
break;
}
if ( (unsigned __int8)(v15 - 54) > 3u )
return 0LL;
}
LABEL_18:
v5 = v7;
goto LABEL_29;
case '0':
LABEL_29:
v7 = v5 + 1;
result = 0LL;
if ( v2 == v5 + 1 || v5[1] != 46 )
return result;
goto LABEL_31;
default:
if ( (unsigned __int8)(v6 - 51) > 6u )
return 0LL;
break;
}
v7 = v5 + 1;
if ( v2 == v5 + 1 )
return 0LL;
v8 = v5[1];
if ( v8 != 46 )
{
if ( (unsigned __int8)(v8 - 48) > 9u )
return 0LL;
goto LABEL_18;
}
LABEL_31:
v9 = v7 + 1;
if ( v2 == v7 + 1 )
return 0LL;
v10 = v7[1];
if ( v10 == 49 )
{
v9 = v7 + 2;
if ( v2 == v7 + 2 )
return 0LL;
v20 = v7[2];
if ( v20 == 46 )
goto LABEL_42;
v21 = v20 - 48;
result = 0LL;
if ( v21 > 9u )
return result;
goto LABEL_36;
}
if ( v10 != 50 )
{
if ( v10 != 48 )
{
if ( (unsigned __int8)(v10 - 51) > 6u )
return 0LL;
goto LABEL_36;
}
LABEL_39:
result = 0LL;
if ( v2 == v9 + 1 || v9[1] != 46 )
return result;
++v9;
goto LABEL_42;
}
v9 = v7 + 2;
if ( v2 == v7 + 2 )
return 0LL;
v18 = v7[2];
if ( v18 != 46 )
{
if ( v18 == 53 )
{
v9 = v7 + 3;
if ( v2 == v7 + 3 )
return 0LL;
v19 = v7[3];
if ( v19 != 46 )
{
if ( (unsigned __int8)(v19 - 48) > 5u )
return 0LL;
goto LABEL_39;
}
goto LABEL_42;
}
if ( v18 > 52 )
{
if ( (unsigned __int8)(v18 - 54) > 3u )
return 0LL;
goto LABEL_39;
}
if ( v18 <= 47 )
return 0LL;
LABEL_36:
v11 = v9++;
if ( v2 != v9 )
{
v12 = v11[1];
if ( v12 == 46 )
goto LABEL_42;
if ( (unsigned __int8)(v12 - 48) <= 9u )
goto LABEL_39;
}
return 0LL;
}
LABEL_42:
if ( v2 == v9 + 1 )
return 0LL;
v13 = v9[1];
if ( v13 == 49 || v13 == 50 || v13 == 48 )
result = 1LL;
else
result = (unsigned __int8)(v13 - 51) <= 6u;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(_BYTE *a1, __int64 a2)
{
_BYTE *v2; // rsi
_BOOL8 result; // rax
char v4; // cl
_BYTE *v5; // r11
char v6; // al
_BYTE *v7; // r9
char v8; // r11
_BYTE *v9; // rdx
char v10; // cl
_BYTE *v11; // r10
char v12; // r11
char v13; // si
char v14; // r11
char v15; // r8
char v16; // r10
char v17; // di
char v18; // r8
char v19; // r9
char v20; // al
unsigned __int8 v21; // di

v2 = &a1[a2];
result = 0LL;
if ( a1 == v2 || *a1 != 49 || v2 == a1 + 1 )
return result;
v4 = a1[1];
if ( v4 == 55 )
{
if ( v2 == a1 + 2 || a1[2] != 50 || v2 == a1 + 3 || a1[3] != 46 || v2 == a1 + 4 )
return result;
v14 = a1[4];
if ( v14 == 50 )
{
v5 = a1 + 5;
if ( v2 == a1 + 5 || (unsigned __int8)(a1[5] - 48) > 9u )
return 0LL;
}
else if ( v14 == 51 )
{
v5 = a1 + 5;
if ( v2 == a1 + 5 || (unsigned __int8)(a1[5] - 48) > 1u )
return 0LL;
}
else
{
result = 0LL;
if ( v14 != 49 )
return result;
v5 = a1 + 5;
if ( v2 == a1 + 5 || (unsigned __int8)(a1[5] - 54) > 3u )
return result;
}
goto LABEL_29;
}
if ( v4 == 57 )
{
if ( v2 == a1 + 2 )
return result;
if ( a1[2] != 50 )
return result;
if ( v2 == a1 + 3 )
return result;
if ( a1[3] != 46 )
return result;
result = 0LL;
if ( v2 == a1 + 4 )
return result;
if ( a1[4] != 49 )
return result;
if ( v2 == a1 + 5 )
return result;
if ( a1[5] != 54 )
return result;
v5 = a1 + 6;
if ( v2 == a1 + 6 || a1[6] != 56 )
return result;
goto LABEL_29;
}
if ( v4 != 48 )
return result;
if ( v2 == a1 + 2 )
return result;
if ( a1[2] != 46 )
return result;
v5 = a1 + 3;
if ( v2 == a1 + 3 )
return result;
v6 = a1[3];
switch ( v6 )
{
case '1':
v5 = a1 + 4;
if ( v2 == a1 + 4 )
return 0LL;
v17 = a1[4];
if ( v17 == 46 )
{
v7 = v5;
goto LABEL_31;
}
result = 0LL;
if ( (unsigned __int8)(v17 - 48) > 9u )
return result;
break;
case '2':
v7 = a1 + 4;
if ( v2 == a1 + 4 )
return 0LL;
v15 = a1[4];
if ( v15 == 46 )
goto LABEL_31;
if ( v15 == 53 )
{
v7 = a1 + 5;
if ( v2 == a1 + 5 )
return 0LL;
v16 = a1[5];
if ( v16 == 46 )
goto LABEL_31;
if ( (unsigned __int8)(v16 - 48) > 5u )
return 0LL;
}
else
{
if ( v15 <= 52 )
{
if ( v15 <= 47 )
return 0LL;
v5 = a1 + 4;
break;
}
if ( (unsigned __int8)(v15 - 54) > 3u )
return 0LL;
}
LABEL_18:
v5 = v7;
goto LABEL_29;
case '0':
LABEL_29:
v7 = v5 + 1;
result = 0LL;
if ( v2 == v5 + 1 || v5[1] != 46 )
return result;
goto LABEL_31;
default:
if ( (unsigned __int8)(v6 - 51) > 6u )
return 0LL;
break;
}
v7 = v5 + 1;
if ( v2 == v5 + 1 )
return 0LL;
v8 = v5[1];
if ( v8 != 46 )
{
if ( (unsigned __int8)(v8 - 48) > 9u )
return 0LL;
goto LABEL_18;
}
LABEL_31:
v9 = v7 + 1;
if ( v2 == v7 + 1 )
return 0LL;
v10 = v7[1];
if ( v10 == 49 )
{
v9 = v7 + 2;
if ( v2 == v7 + 2 )
return 0LL;
v20 = v7[2];
if ( v20 == 46 )
goto LABEL_42;
v21 = v20 - 48;
result = 0LL;
if ( v21 > 9u )
return result;
goto LABEL_36;
}
if ( v10 != 50 )
{
if ( v10 != 48 )
{
if ( (unsigned __int8)(v10 - 51) > 6u )
return 0LL;
goto LABEL_36;
}
LABEL_39:
result = 0LL;
if ( v2 == v9 + 1 || v9[1] != 46 )
return result;
++v9;
goto LABEL_42;
}
v9 = v7 + 2;
if ( v2 == v7 + 2 )
return 0LL;
v18 = v7[2];
if ( v18 != 46 )
{
if ( v18 == 53 )
{
v9 = v7 + 3;
if ( v2 == v7 + 3 )
return 0LL;
v19 = v7[3];
if ( v19 != 46 )
{
if ( (unsigned __int8)(v19 - 48) > 5u )
return 0LL;
goto LABEL_39;
}
goto LABEL_42;
}
if ( v18 > 52 )
{
if ( (unsigned __int8)(v18 - 54) > 3u )
return 0LL;
goto LABEL_39;
}
if ( v18 <= 47 )
return 0LL;
LABEL_36:
v11 = v9++;
if ( v2 != v9 )
{
v12 = v11[1];
if ( v12 == 46 )
goto LABEL_42;
if ( (unsigned __int8)(v12 - 48) <= 9u )
goto LABEL_39;
}
return 0LL;
}
LABEL_42:
if ( v2 == v9 + 1 )
return 0LL;
v13 = v9[1];
if ( v13 == 49 || v13 == 50 || v13 == 48 )
result = 1LL;
else
result = (unsigned __int8)(v13 - 51) <= 6u;
return result;
}

original_code:
unsigned int rfc1918_parser_execute(const char *str, size_t len)
{
  int cs = 0;
  const char *p, *pe;
  unsigned int is_ip_rfc1918 = 0;
  p = str;
  pe = str+len;
 {
 cs = rfc1918_parser_start;
 }
 {
 if ( p == pe )
  goto _test_eof;
 switch ( cs )
 {
case 1:
 if ( (*p) == 49 )
  goto st2;
 goto st0;
st0:
cs = 0;
 goto _out;
st2:
 if ( ++p == pe )
  goto _test_eof2;
case 2:
 switch( (*p) ) {
  case 48: goto st3;
  case 55: goto st17;
  case 57: goto st23;
 }
 goto st0;
st3:
 if ( ++p == pe )
  goto _test_eof3;
case 3:
 if ( (*p) == 46 )
  goto st4;
 goto st0;
st4:
 if ( ++p == pe )
  goto _test_eof4;
case 4:
 switch( (*p) ) {
  case 48: goto st5;
  case 49: goto st13;
  case 50: goto st15;
 }
 if ( 51 <= (*p) && (*p) <= 57 )
  goto st14;
 goto st0;
st5:
 if ( ++p == pe )
  goto _test_eof5;
case 5:
 if ( (*p) == 46 )
  goto st6;
 goto st0;
st6:
 if ( ++p == pe )
  goto _test_eof6;
case 6:
 switch( (*p) ) {
  case 48: goto st7;
  case 49: goto st9;
  case 50: goto st11;
 }
 if ( 51 <= (*p) && (*p) <= 57 )
  goto st10;
 goto st0;
st7:
 if ( ++p == pe )
  goto _test_eof7;
case 7:
 if ( (*p) == 46 )
  goto st8;
 goto st0;
st8:
 if ( ++p == pe )
  goto _test_eof8;
case 8:
 switch( (*p) ) {
  case 48: goto tr16;
  case 49: goto tr17;
  case 50: goto tr18;
 }
 if ( 51 <= (*p) && (*p) <= 57 )
  goto tr19;
 goto st0;
tr16:
 {
    is_ip_rfc1918 = 1;
  }
 goto st28;
st28:
 if ( ++p == pe )
  goto _test_eof28;
case 28:
 goto st0;
tr17:
 {
    is_ip_rfc1918 = 1;
  }
 goto st29;
st29:
 if ( ++p == pe )
  goto _test_eof29;
case 29:
 if ( 48 <= (*p) && (*p) <= 57 )
  goto tr19;
 goto st0;
tr19:
 {
    is_ip_rfc1918 = 1;
  }
 goto st30;
st30:
 if ( ++p == pe )
  goto _test_eof30;
case 30:
 if ( 48 <= (*p) && (*p) <= 57 )
  goto tr16;
 goto st0;
tr18:
 {
    is_ip_rfc1918 = 1;
  }
 goto st31;
st31:
 if ( ++p == pe )
  goto _test_eof31;
case 31:
 if ( (*p) == 53 )
  goto tr31;
 if ( (*p) > 52 ) {
  if ( 54 <= (*p) && (*p) <= 57 )
   goto tr16;
 } else if ( (*p) >= 48 )
  goto tr19;
 goto st0;
tr31:
 {
    is_ip_rfc1918 = 1;
  }
 goto st32;
st32:
 if ( ++p == pe )
  goto _test_eof32;
case 32:
 if ( 48 <= (*p) && (*p) <= 53 )
  goto tr16;
 goto st0;
st9:
 if ( ++p == pe )
  goto _test_eof9;
case 9:
 if ( (*p) == 46 )
  goto st8;
 if ( 48 <= (*p) && (*p) <= 57 )
  goto st10;
 goto st0;
st10:
 if ( ++p == pe )
  goto _test_eof10;
case 10:
 if ( (*p) == 46 )
  goto st8;
 if ( 48 <= (*p) && (*p) <= 57 )
  goto st7;
 goto st0;
st11:
 if ( ++p == pe )
  goto _test_eof11;
case 11:
 switch( (*p) ) {
  case 46: goto st8;
  case 53: goto st12;
 }
 if ( (*p) > 52 ) {
  if ( 54 <= (*p) && (*p) <= 57 )
   goto st7;
 } else if ( (*p) >= 48 )
  goto st10;
 goto st0;
st12:
 if ( ++p == pe )
  goto _test_eof12;
case 12:
 if ( (*p) == 46 )
  goto st8;
 if ( 48 <= (*p) && (*p) <= 53 )
  goto st7;
 goto st0;
st13:
 if ( ++p == pe )
  goto _test_eof13;
case 13:
 if ( (*p) == 46 )
  goto st6;
 if ( 48 <= (*p) && (*p) <= 57 )
  goto st14;
 goto st0;
st14:
 if ( ++p == pe )
  goto _test_eof14;
case 14:
 if ( (*p) == 46 )
  goto st6;
 if ( 48 <= (*p) && (*p) <= 57 )
  goto st5;
 goto st0;
st15:
 if ( ++p == pe )
  goto _test_eof15;
case 15:
 switch( (*p) ) {
  case 46: goto st6;
  case 53: goto st16;
 }
 if ( (*p) > 52 ) {
  if ( 54 <= (*p) && (*p) <= 57 )
   goto st5;
 } else if ( (*p) >= 48 )
  goto st14;
 goto st0;
st16:
 if ( ++p == pe )
  goto _test_eof16;
case 16:
 if ( (*p) == 46 )
  goto st6;
 if ( 48 <= (*p) && (*p) <= 53 )
  goto st5;
 goto st0;
st17:
 if ( ++p == pe )
  goto _test_eof17;
case 17:
 if ( (*p) == 50 )
  goto st18;
 goto st0;
st18:
 if ( ++p == pe )
  goto _test_eof18;
case 18:
 if ( (*p) == 46 )
  goto st19;
 goto st0;
st19:
 if ( ++p == pe )
  goto _test_eof19;
case 19:
 switch( (*p) ) {
  case 49: goto st20;
  case 50: goto st21;
  case 51: goto st22;
 }
 goto st0;
st20:
 if ( ++p == pe )
  goto _test_eof20;
case 20:
 if ( 54 <= (*p) && (*p) <= 57 )
  goto st5;
 goto st0;
st21:
 if ( ++p == pe )
  goto _test_eof21;
case 21:
 if ( 48 <= (*p) && (*p) <= 57 )
  goto st5;
 goto st0;
st22:
 if ( ++p == pe )
  goto _test_eof22;
case 22:
 if ( 48 <= (*p) && (*p) <= 49 )
  goto st5;
 goto st0;
st23:
 if ( ++p == pe )
  goto _test_eof23;
case 23:
 if ( (*p) == 50 )
  goto st24;
 goto st0;
st24:
 if ( ++p == pe )
  goto _test_eof24;
case 24:
 if ( (*p) == 46 )
  goto st25;
 goto st0;
st25:
 if ( ++p == pe )
  goto _test_eof25;
case 25:
 if ( (*p) == 49 )
  goto st26;
 goto st0;
st26:
 if ( ++p == pe )
  goto _test_eof26;
case 26:
 if ( (*p) == 54 )
  goto st27;
 goto st0;
st27:
 if ( ++p == pe )
  goto _test_eof27;
case 27:
 if ( (*p) == 56 )
  goto st5;
 goto st0;
 }
 _test_eof2: cs = 2; goto _test_eof;
 _test_eof3: cs = 3; goto _test_eof;
 _test_eof4: cs = 4; goto _test_eof;
 _test_eof5: cs = 5; goto _test_eof;
 _test_eof6: cs = 6; goto _test_eof;
 _test_eof7: cs = 7; goto _test_eof;
 _test_eof8: cs = 8; goto _test_eof;
 _test_eof28: cs = 28; goto _test_eof;
 _test_eof29: cs = 29; goto _test_eof;
 _test_eof30: cs = 30; goto _test_eof;
 _test_eof31: cs = 31; goto _test_eof;
 _test_eof32: cs = 32; goto _test_eof;
 _test_eof9: cs = 9; goto _test_eof;
 _test_eof10: cs = 10; goto _test_eof;
 _test_eof11: cs = 11; goto _test_eof;
 _test_eof12: cs = 12; goto _test_eof;
 _test_eof13: cs = 13; goto _test_eof;
 _test_eof14: cs = 14; goto _test_eof;
 _test_eof15: cs = 15; goto _test_eof;
 _test_eof16: cs = 16; goto _test_eof;
 _test_eof17: cs = 17; goto _test_eof;
 _test_eof18: cs = 18; goto _test_eof;
 _test_eof19: cs = 19; goto _test_eof;
 _test_eof20: cs = 20; goto _test_eof;
 _test_eof21: cs = 21; goto _test_eof;
 _test_eof22: cs = 22; goto _test_eof;
 _test_eof23: cs = 23; goto _test_eof;
 _test_eof24: cs = 24; goto _test_eof;
 _test_eof25: cs = 25; goto _test_eof;
 _test_eof26: cs = 26; goto _test_eof;
 _test_eof27: cs = 27; goto _test_eof;
 _test_eof: {}
 _out: {}
 }
  return is_ip_rfc1918;
}

canonical_original_code:
unsigned int rfc1918_parser_execute(char *str, unsigned long len)
{
  int cs = 0;
  char *p; char *pe;
  unsigned int is_ip_rfc1918 = 0;
  p = str;
  pe = str+len;
 {
 cs = rfc1918_parser_start;
 }
 {
 if ( p == pe )
  goto _test_eof;
 switch ( cs )
 {
case 1:
 if ( (*p) == 49 )
  goto st2;
 goto st0;
st0:
cs = 0;
 goto _out;
st2:
 if ( ++p == pe )
  goto _test_eof2;
case 2:
 switch( (*p) ) {
  case 48: goto st3;
  case 55: goto st17;
  case 57: goto st23;
 }
 goto st0;
st3:
 if ( ++p == pe )
  goto _test_eof3;
case 3:
 if ( (*p) == 46 )
  goto st4;
 goto st0;
st4:
 if ( ++p == pe )
  goto _test_eof4;
case 4:
 switch( (*p) ) {
  case 48: goto st5;
  case 49: goto st13;
  case 50: goto st15;
 }
 if ( 51 <= (*p) && (*p) <= 57 )
  goto st14;
 goto st0;
st5:
 if ( ++p == pe )
  goto _test_eof5;
case 5:
 if ( (*p) == 46 )
  goto st6;
 goto st0;
st6:
 if ( ++p == pe )
  goto _test_eof6;
case 6:
 switch( (*p) ) {
  case 48: goto st7;
  case 49: goto st9;
  case 50: goto st11;
 }
 if ( 51 <= (*p) && (*p) <= 57 )
  goto st10;
 goto st0;
st7:
 if ( ++p == pe )
  goto _test_eof7;
case 7:
 if ( (*p) == 46 )
  goto st8;
 goto st0;
st8:
 if ( ++p == pe )
  goto _test_eof8;
case 8:
 switch( (*p) ) {
  case 48: goto tr16;
  case 49: goto tr17;
  case 50: goto tr18;
 }
 if ( 51 <= (*p) && (*p) <= 57 )
  goto tr19;
 goto st0;
tr16:
 {
    is_ip_rfc1918 = 1;
  }
 goto st28;
st28:
 if ( ++p == pe )
  goto _test_eof28;
case 28:
 goto st0;
tr17:
 {
    is_ip_rfc1918 = 1;
  }
 goto st29;
st29:
 if ( ++p == pe )
  goto _test_eof29;
case 29:
 if ( 48 <= (*p) && (*p) <= 57 )
  goto tr19;
 goto st0;
tr19:
 {
    is_ip_rfc1918 = 1;
  }
 goto st30;
st30:
 if ( ++p == pe )
  goto _test_eof30;
case 30:
 if ( 48 <= (*p) && (*p) <= 57 )
  goto tr16;
 goto st0;
tr18:
 {
    is_ip_rfc1918 = 1;
  }
 goto st31;
st31:
 if ( ++p == pe )
  goto _test_eof31;
case 31:
 if ( (*p) == 53 )
  goto tr31;
 if ( (*p) > 52 ) {
  if ( 54 <= (*p) && (*p) <= 57 )
   goto tr16;
 } else if ( (*p) >= 48 )
  goto tr19;
 goto st0;
tr31:
 {
    is_ip_rfc1918 = 1;
  }
 goto st32;
st32:
 if ( ++p == pe )
  goto _test_eof32;
case 32:
 if ( 48 <= (*p) && (*p) <= 53 )
  goto tr16;
 goto st0;
st9:
 if ( ++p == pe )
  goto _test_eof9;
case 9:
 if ( (*p) == 46 )
  goto st8;
 if ( 48 <= (*p) && (*p) <= 57 )
  goto st10;
 goto st0;
st10:
 if ( ++p == pe )
  goto _test_eof10;
case 10:
 if ( (*p) == 46 )
  goto st8;
 if ( 48 <= (*p) && (*p) <= 57 )
  goto st7;
 goto st0;
st11:
 if ( ++p == pe )
  goto _test_eof11;
case 11:
 switch( (*p) ) {
  case 46: goto st8;
  case 53: goto st12;
 }
 if ( (*p) > 52 ) {
  if ( 54 <= (*p) && (*p) <= 57 )
   goto st7;
 } else if ( (*p) >= 48 )
  goto st10;
 goto st0;
st12:
 if ( ++p == pe )
  goto _test_eof12;
case 12:
 if ( (*p) == 46 )
  goto st8;
 if ( 48 <= (*p) && (*p) <= 53 )
  goto st7;
 goto st0;
st13:
 if ( ++p == pe )
  goto _test_eof13;
case 13:
 if ( (*p) == 46 )
  goto st6;
 if ( 48 <= (*p) && (*p) <= 57 )
  goto st14;
 goto st0;
st14:
 if ( ++p == pe )
  goto _test_eof14;
case 14:
 if ( (*p) == 46 )
  goto st6;
 if ( 48 <= (*p) && (*p) <= 57 )
  goto st5;
 goto st0;
st15:
 if ( ++p == pe )
  goto _test_eof15;
case 15:
 switch( (*p) ) {
  case 46: goto st6;
  case 53: goto st16;
 }
 if ( (*p) > 52 ) {
  if ( 54 <= (*p) && (*p) <= 57 )
   goto st5;
 } else if ( (*p) >= 48 )
  goto st14;
 goto st0;
st16:
 if ( ++p == pe )
  goto _test_eof16;
case 16:
 if ( (*p) == 46 )
  goto st6;
 if ( 48 <= (*p) && (*p) <= 53 )
  goto st5;
 goto st0;
st17:
 if ( ++p == pe )
  goto _test_eof17;
case 17:
 if ( (*p) == 50 )
  goto st18;
 goto st0;
st18:
 if ( ++p == pe )
  goto _test_eof18;
case 18:
 if ( (*p) == 46 )
  goto st19;
 goto st0;
st19:
 if ( ++p == pe )
  goto _test_eof19;
case 19:
 switch( (*p) ) {
  case 49: goto st20;
  case 50: goto st21;
  case 51: goto st22;
 }
 goto st0;
st20:
 if ( ++p == pe )
  goto _test_eof20;
case 20:
 if ( 54 <= (*p) && (*p) <= 57 )
  goto st5;
 goto st0;
st21:
 if ( ++p == pe )
  goto _test_eof21;
case 21:
 if ( 48 <= (*p) && (*p) <= 57 )
  goto st5;
 goto st0;
st22:
 if ( ++p == pe )
  goto _test_eof22;
case 22:
 if ( 48 <= (*p) && (*p) <= 49 )
  goto st5;
 goto st0;
st23:
 if ( ++p == pe )
  goto _test_eof23;
case 23:
 if ( (*p) == 50 )
  goto st24;
 goto st0;
st24:
 if ( ++p == pe )
  goto _test_eof24;
case 24:
 if ( (*p) == 46 )
  goto st25;
 goto st0;
st25:
 if ( ++p == pe )
  goto _test_eof25;
case 25:
 if ( (*p) == 49 )
  goto st26;
 goto st0;
st26:
 if ( ++p == pe )
  goto _test_eof26;
case 26:
 if ( (*p) == 54 )
  goto st27;
 goto st0;
st27:
 if ( ++p == pe )
  goto _test_eof27;
case 27:
 if ( (*p) == 56 )
  goto st5;
 goto st0;
 }
 _test_eof2: cs = 2; goto _test_eof;
 _test_eof3: cs = 3; goto _test_eof;
 _test_eof4: cs = 4; goto _test_eof;
 _test_eof5: cs = 5; goto _test_eof;
 _test_eof6: cs = 6; goto _test_eof;
 _test_eof7: cs = 7; goto _test_eof;
 _test_eof8: cs = 8; goto _test_eof;
 _test_eof28: cs = 28; goto _test_eof;
 _test_eof29: cs = 29; goto _test_eof;
 _test_eof30: cs = 30; goto _test_eof;
 _test_eof31: cs = 31; goto _test_eof;
 _test_eof32: cs = 32; goto _test_eof;
 _test_eof9: cs = 9; goto _test_eof;
 _test_eof10: cs = 10; goto _test_eof;
 _test_eof11: cs = 11; goto _test_eof;
 _test_eof12: cs = 12; goto _test_eof;
 _test_eof13: cs = 13; goto _test_eof;
 _test_eof14: cs = 14; goto _test_eof;
 _test_eof15: cs = 15; goto _test_eof;
 _test_eof16: cs = 16; goto _test_eof;
 _test_eof17: cs = 17; goto _test_eof;
 _test_eof18: cs = 18; goto _test_eof;
 _test_eof19: cs = 19; goto _test_eof;
 _test_eof20: cs = 20; goto _test_eof;
 _test_eof21: cs = 21; goto _test_eof;
 _test_eof22: cs = 22; goto _test_eof;
 _test_eof23: cs = 23; goto _test_eof;
 _test_eof24: cs = 24; goto _test_eof;
 _test_eof25: cs = 25; goto _test_eof;
 _test_eof26: cs = 26; goto _test_eof;
 _test_eof27: cs = 27; goto _test_eof;
 _test_eof: {}
 _out: {}
 }
  return is_ip_rfc1918;
}

variable_types:
str
char *

variable_types:
len
unsigned long

variable_types: cs int

variable_types:
p
char *

variable_types:
pe
char *

return_type: unsigned int


repo: virtualolson/who

decompiled_code:
__int64 __fastcall atomic_get_and_set_int(volatile __int32 *a1, __int32 a2)
{
return (unsigned int)_InterlockedExchange(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(volatile __int32 *a1, __int32 a2)
{
return (unsigned int)_InterlockedExchange(a1, a2);
}

original_code: inline static int atomic_get_and_set_int(volatile int* var, int v) { asm volatile( "xchgl %1, %0" " \n\t" : "+q"(v), "=m"(*var) : "m"(*var) : "memory" ); return v; }

canonical_original_code: inline static int atomic_get_and_set_int(int *var, int v) { asm volatile( "xchgl %1, %0" " \n\t" : "+q"(v), "=m"(*var) : "m"(*var) : "memory" ); return v; }

variable_types:
var
int *

variable_types: v int

return_type: int


decompiled_code:
__int64 __fastcall futex_release(volatile __int32 *a1)
{
__int64 result; // rax
__int64 v2; // [rsp-10h] [rbp-18h]

result = atomic_get_and_set_int(a1, 0);
if ( (_DWORD)result == 2 )
{
syscall(202LL, a1, 1LL, 1LL, 0LL, 0LL, 0LL);
result = v2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(volatile __int32 *a1)
{
__int64 result; // rax
__int64 v2; // [rsp-10h] [rbp-18h]

result = func0(a1, 0);
if ( (_DWORD)result == 2 )
{
syscall(202LL, a1, 1LL, 1LL, 0LL, 0LL, 0LL);
result = v2;
}
return result;
}

original_code:
inline static void futex_release(futex_lock_t* lock)
{
 int v;
 do {} while(0);
 v=atomic_get_and_set_int(&(lock)->val, 0);
 if (__builtin_expect(!!(v==2), 0)){
  syscall(202 , (&(lock)->val), (1), (1), (0), (0), (0));
 }
}

canonical_original_code:
inline static void futex_release(struct atomic_t *lock)
{
 int v;
 do {} while(0);
 v=atomic_get_and_set_int(&(lock)->val, 0);
 if (__builtin_expect(!!(v==2), 0)){
  syscall(202 , (&(lock)->val), (1), (1), (0), (0), (0));
 }
}

variable_types:
lock
struct atomic_t { int val; } *

return_type: void


decompiled_code:
__int64 __fastcall futex_get(volatile signed __int32 *a1)
{
__int64 result; // rax
int v2; // ecx

result = atomic_cmpxchg_int_constprop_0(a1);
if ( (_DWORD)result )
{
if ( (_DWORD)result == 2 )
{
do
{
LABEL_24:
syscall(202LL, a1, 0LL, 2LL, 0LL, 0LL, 0LL);
result = atomic_get_and_set_int(a1, 2);
}
while ( (_DWORD)result );
}
else
{
while ( 1 )
{
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = atomic_cmpxchg_int_constprop_0(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
if ( v2 == 7 )
{
for ( result = atomic_get_and_set_int(a1, 2); (_DWORD)result; result = atomic_get_and_set_int(a1, 2) )
syscall(202LL, a1, 0LL, 2LL, 0LL, 0LL, 0LL);
return result;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(volatile signed __int32 *a1)
{
__int64 result; // rax
int v2; // ecx

result = func2(a1);
if ( (_DWORD)result )
{
if ( (_DWORD)result == 2 )
{
do
{
LABEL_24:
syscall(202LL, a1, 0LL, 2LL, 0LL, 0LL, 0LL);
result = func0(a1, 2);
}
while ( (_DWORD)result );
}
else
{
while ( 1 )
{
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func2(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
if ( v2 == 7 )
{
for ( result = func0(a1, 2); (_DWORD)result; result = func0(a1, 2) )
syscall(202LL, a1, 0LL, 2LL, 0LL, 0LL, 0LL);
return result;
}
}
}
}
return result;
}

original_code:
inline static void futex_get(futex_lock_t* lock)
{
 int v;
 register int i=1024;
retry:
 v=atomic_cmpxchg_int(&(lock)->val, 0, 1);
 if (__builtin_expect(!!(v==0), 1)){
  do {} while(0);
  return;
 }else if (__builtin_expect(!!(v==2), 0)){
  do{
   syscall(202 , (&(lock)->val), (0), (2), (0), (0), (0));
   v=atomic_get_and_set_int(&(lock)->val, 2);
  }while(v);
 }else{
  if (i>0){
   i--;
   goto retry;
  }
  v=atomic_get_and_set_int(&(lock)->val, 2);
  while(v){
   syscall(202 , (&(lock)->val), (0), (2), (0), (0), (0));
   v=atomic_get_and_set_int(&(lock)->val, 2);
  }
 }
 do {} while(0);
}

canonical_original_code:
inline static void futex_get(struct atomic_t *lock)
{
 int v;
 register int i = 1024;
retry:
 v=atomic_cmpxchg_int(&(lock)->val, 0, 1);
 if (__builtin_expect(!!(v==0), 1)){
  do {} while(0);
  return;
 }else if (__builtin_expect(!!(v==2), 0)){
  do{
   syscall(202 , (&(lock)->val), (0), (2), (0), (0), (0));
   v=atomic_get_and_set_int(&(lock)->val, 2);
  }while(v);
 }else{
  if (i>0){
   i--;
   goto retry;
  }
  v=atomic_get_and_set_int(&(lock)->val, 2);
  while(v){
   syscall(202 , (&(lock)->val), (0), (2), (0), (0), (0));
   v=atomic_get_and_set_int(&(lock)->val, 2);
  }
 }
 do {} while(0);
}

variable_types: i int


decompiled_code:
__int64 __fastcall shm_malloc(unsigned int a1)
{
__int64 v1; // r12

futex_get(mem_lock);
v1 = qm_malloc(shm_block, a1);
futex_release(mem_lock);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1)
{
__int64 v1; // r12

func3(mem_lock);
v1 = qm_malloc(shm_block, a1);
func1(mem_lock);
return v1;
}

original_code:
inline static void* shm_malloc(unsigned int size)
{
 void *p;
 futex_get(mem_lock);
 p=qm_malloc(shm_block, (size));
 futex_release(mem_lock);
  return p;
}

canonical_original_code:
inline static void *shm_malloc(unsigned int size)
{
 void *p;
 futex_get(mem_lock);
 p=qm_malloc(shm_block, (size));
 futex_release(mem_lock);
  return p;
}

variable_types:
size
unsigned int

variable_types:
p
void *

return_type: void *


decompiled_code:
__int64 __fastcall free_package(__int64 a1)
{
__int64 result; // rax

if ( a1 )
{
if ( *(_QWORD *)(a1 + 8) )
{
futex_get(mem_lock);
qm_free(shm_block, *(_QWORD *)(a1 + 8));
futex_release(mem_lock);
}
futex_get(mem_lock);
qm_free(shm_block, a1);
result = futex_release(mem_lock);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
__int64 result; // rax

if ( a1 )
{
if ( *(_QWORD *)(a1 + 8) )
{
func3(mem_lock);
qm_free(shm_block, *(_QWORD *)(a1 + 8));
func1(mem_lock);
}
func3(mem_lock);
qm_free(shm_block, a1);
result = func1(mem_lock);
}
return result;
}

original_code:
static void free_package(package_t *p)
{
 if (!p) return;
 if (p->name) do { futex_get(mem_lock); qm_free(shm_block, (p->name)); futex_release(mem_lock); }while(0);
 do { futex_get(mem_lock); qm_free(shm_block, (p)); futex_release(mem_lock); }while(0);
}

canonical_original_code:
static void free_package(struct _package_t *p)
{
 if (!p) return;
 if (p->name) do { futex_get(mem_lock); qm_free(shm_block, (p->name)); futex_release(mem_lock); }while(0);
 do { futex_get(mem_lock); qm_free(shm_block, (p)); futex_release(mem_lock); }while(0);
}

variable_types: struct _package_t { struct _package_t *__next; char *name; } *


decompiled_code:
__int64 __fastcall free_packages(_QWORD **a1)
{
_QWORD *v2; // rbx
__int64 v3; // rdi
__int64 result; // rax

if ( a1 )
{
v2 = *a1;
while ( v2 )
{
v3 = (__int64)v2;
v2 = (_QWORD *)*v2;
free_package(v3);
}
futex_get(mem_lock);
qm_free(shm_block, a1);
result = futex_release(mem_lock);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(_QWORD **a1)
{
_QWORD *v2; // rbx
__int64 v3; // rdi
__int64 result; // rax

if ( a1 )
{
v2 = *a1;
while ( v2 )
{
v3 = (__int64)v2;
v2 = (_QWORD *)*v2;
func6(v3);
}
func3(mem_lock);
qm_free(shm_block, a1);
result = func1(mem_lock);
}
return result;
}

original_code:
static void free_packages(packages_t *p)
{
 package_t *e, *f;
 if (!p) return;
 e = p->package;
 while (e) {
  f = (e)->__next;
  free_package(e);
  e = f;
 }
 do { futex_get(mem_lock); qm_free(shm_block, (p)); futex_release(mem_lock); }while(0);
}

canonical_original_code:
static void free_packages(struct _packages_t *p)
{
 struct _package_t *e; struct _package_t *f;
 if (!p) return;
 e = p->package;
 while (e) {
  f = (e)->__next;
  free_package(e);
  e = f;
 }
 do { futex_get(mem_lock); qm_free(shm_block, (p)); futex_release(mem_lock); }while(0);
}

variable_types: struct _packages_t { struct _package_t { struct _package_t *__next; char *name; } *package; } *

user_defined_types: struct _packages_t { struct _package_t *package; }


decompiled_code:
void __fastcall free_service(__int64 a1)
{
int v1; // eax

if ( a1 )
{
if ( *(_QWORD *)(a1 + 32) )
{
futex_get(mem_lock);
qm_free(shm_block, *(_QWORD *)(a1 + 32));
futex_release(mem_lock);
v1 = *(_DWORD *)(a1 + 16);
if ( v1 )
goto LABEL_4;
}
else
{
v1 = *(_DWORD *)(a1 + 16);
if ( v1 )
{
LABEL_4:
if ( v1 == 1 )
{
futex_get(mem_lock);
qm_free(shm_block, *(_QWORD *)(a1 + 24));
futex_release(mem_lock);
}
goto LABEL_6;
}
}
free_list(*(_QWORD *)(a1 + 24));
LABEL_6:
free_packages(*(_QWORD ***)(a1 + 8));
futex_get(mem_lock);
qm_free(shm_block, a1);
futex_release(mem_lock);
}
}

canonical_decompiled_code:
void __fastcall func12(__int64 a1)
{
int v1; // eax

if ( a1 )
{
if ( *(_QWORD *)(a1 + 32) )
{
func3(mem_lock);
qm_free(shm_block, *(_QWORD *)(a1 + 32));
func1(mem_lock);
v1 = *(_DWORD *)(a1 + 16);
if ( v1 )
goto LABEL_4;
}
else
{
v1 = *(_DWORD *)(a1 + 16);
if ( v1 )
{
LABEL_4:
if ( v1 == 1 )
{
func3(mem_lock);
qm_free(shm_block, *(_QWORD *)(a1 + 24));
func1(mem_lock);
}
goto LABEL_6;
}
}
free_list(*(_QWORD *)(a1 + 24));
LABEL_6:
func7(*(_QWORD ***)(a1 + 8));
func3(mem_lock);
qm_free(shm_block, a1);
func1(mem_lock);
}
}

original_code:
void free_service(service_t *s)
{
 if (!s) return;
 if (s->uri) do { futex_get(mem_lock); qm_free(shm_block, (s->uri)); futex_release(mem_lock); }while(0);
 switch (s->content_type) {
  case stc_list: free_list(s->content.list); break;
  case stc_resource_list: do { futex_get(mem_lock); qm_free(shm_block, (s->content.resource_list)); futex_release(mem_lock); }while(0); break;
 }
 free_packages(s->packages);
 do { futex_get(mem_lock); qm_free(shm_block, (s)); futex_release(mem_lock); }while(0);
}

canonical_original_code:
void free_service(struct _service_t *s)
{
 if (!s) return;
 if (s->uri) do { futex_get(mem_lock); qm_free(shm_block, (s->uri)); futex_release(mem_lock); }while(0);
 switch (s->content_type) {
  case stc_list: free_list(s->content.list); break;
  case stc_resource_list: do { futex_get(mem_lock); qm_free(shm_block, (s->content.resource_list)); futex_release(mem_lock); }while(0); break;
 }
 free_packages(s->packages);
 do { futex_get(mem_lock); qm_free(shm_block, (s)); futex_release(mem_lock); }while(0);
}

variable_types: struct _service_t { struct _service_t *__next; struct _packages_t { struct _package_t { struct _package_t *__next; char *name; } *package; } *packages; enum service_content_type_t { stc_list=0, stc_resource_list=1 } content_type; union { struct _list_t { struct _list_t *__next; char *display_name; struct _list_content_t { struct _list_content_t *__next; enum list_content_type_t { lct_list=0, lct_entry=1, lct_entry_ref=2, lct_external=3 } type; union { struct _list_t *list; struct entry_t { char *uri; struct _display_name_t { struct _display_name_t *__next; char *name; char *lang; } *display_names; } *entry; struct entry_ref_t { char *ref; } *entry_ref; struct external_t { char *anchor; } *external; } u; } *content; char *name; } *list; char *resource_list; } content; char *uri; } *

user_defined_types: struct _service_t { struct _service_t *__next; struct _packages_t *packages; enum service_content_type_t content_type; union { struct _list_t *list; char *resource_list; } content; char *uri; }

user_defined_types: struct _list_t { struct _list_t *__next; char *display_name; struct _list_content_t *content; char *name; }

user_defined_types: struct _list_content_t { struct _list_content_t *__next; enum list_content_type_t type; union { struct _list_t *list; struct entry_t *entry; struct entry_ref_t *entry_ref; struct external_t *external; } u; }

user_defined_types: struct entry_t { char *uri; struct _display_name_t *display_names; }


decompiled_code:
__int64 __fastcall free_rls_services(_QWORD **a1)
{
_QWORD *v2; // rbx
__int64 v3; // rdi
__int64 result; // rax

if ( a1 )
{
v2 = *a1;
while ( v2 )
{
v3 = (__int64)v2;
v2 = (_QWORD *)*v2;
free_service(v3);
}
futex_get(mem_lock);
qm_free(shm_block, a1);
result = futex_release(mem_lock);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(_QWORD **a1)
{
_QWORD *v2; // rbx
__int64 v3; // rdi
__int64 result; // rax

if ( a1 )
{
v2 = *a1;
while ( v2 )
{
v3 = (__int64)v2;
v2 = (_QWORD *)*v2;
func12(v3);
}
func3(mem_lock);
qm_free(shm_block, a1);
result = func1(mem_lock);
}
return result;
}

original_code:
void free_rls_services(rls_services_t *rls)
{
 service_t *e, *f;
 if (!rls) return;
 e = rls->rls_services;
 while (e) {
  f = (e)->__next;
  free_service(e);
  e = f;
 }
 do { futex_get(mem_lock); qm_free(shm_block, (rls)); futex_release(mem_lock); }while(0);
}

canonical_original_code:
void free_rls_services(struct rls_services_t *rls)
{
 struct _service_t *e; struct _service_t *f;
 if (!rls) return;
 e = rls->rls_services;
 while (e) {
  f = (e)->__next;
  free_service(e);
  e = f;
 }
 do { futex_get(mem_lock); qm_free(shm_block, (rls)); futex_release(mem_lock); }while(0);
}

variable_types: struct rls_services_t { struct _service_t { struct _service_t *__next; struct _packages_t { struct _package_t { struct _package_t *__next; char *name; } *package; } *packages; enum service_content_type_t { stc_list=0, stc_resource_list=1 } content_type; union { struct _list_t { struct _list_t *__next; char *display_name; struct _list_content_t { struct _list_content_t *__next; enum list_content_type_t { lct_list=0, lct_entry=1, lct_entry_ref=2, lct_external=3 } type; union { struct _list_t *list; struct entry_t { char *uri; struct _display_name_t { struct _display_name_t *__next; char *name; char *lang; } *display_names; } *entry; struct entry_ref_t { char *ref; } *entry_ref; struct external_t { char *anchor; } *external; } u; } *content; char *name; } *list; char *resource_list; } content; char *uri; } *rls_services; } *

user_defined_types: struct rls_services_t { struct _service_t *rls_services; }


decompiled_code:
char *__fastcall binrpc_error(int a1)
{
int v1; // edi

v1 = abs32(a1);
if ( v1 > 10 )
v1 = 10;
return binrpc_str_errors[v1];
}

canonical_decompiled_code:
char *__fastcall func0(int a1)
{
int v1; // edi

v1 = abs32(a1);
if ( v1 > 10 )
v1 = 10;
return binrpc_str_errors[v1];
}

original_code:
const char* binrpc_error(int err)
{
 if (err<0) err=-err;
 if (err>(- -10)) err=- -10;
 return binrpc_str_errors[err];
}

canonical_original_code:
char *binrpc_error(int err)
{
 if (err<0) err=-err;
 if (err>(- -10)) err=- -10;
 return binrpc_str_errors[err];
}

variable_types: err int

return_type: char *


decompiled_code:
__int64 __fastcall fixup_replace_from1(const char **a1)
{
const char **v2; // rax
const char *v3; // rdi
const char **v4; // rbx
int v5; // eax
__int64 result; // rax
int v7; // er8
__int64 v8; // rdi
int v9; // ebx
const char *v10; // r12
struct _IO_FILE *v11; // rdi
const char *v12; // r8
const char *v13; // r9
const char *v14; // r12
unsigned int v15; // eax
struct _IO_FILE *v16; // rdi
__int64 v17; // rdx
__int64 v18; // rcx
__int64 v19; // [rsp-10h] [rbp-28h]
const char *v20; // [rsp-10h] [rbp-28h]
__int64 v21; // [rsp-8h] [rbp-20h]
const char *v22; // [rsp-8h] [rbp-20h]
const char *v23; // [rsp+0h] [rbp-18h]

v2 = (const char **)qm_malloc(mem_block, 16LL);
if ( v2 )
{
v3 = *a1;
v4 = v2;
*v2 = *a1;
v5 = strlen(v3);
*((_DWORD *)v4 + 2) = v5;
if ( v5 )
{
*a1 = (const char *)v4;
result = 0LL;
}
else
{
v7 = get_debug_level(&LC0, 3LL);
result = 0xFFFFFFFFLL;
if ( v7 >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v10 = (const char *)*((_QWORD *)&log_level_info + 6);
v21 = my_pid();
v11 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from1: empty parameter not accepted\n",
process_no,
(unsigned int)v21,
v10,
"uac [uac.c:180]: ",
"fixup_replace_from1");
if ( log_color )
dprint_color_reset(
v11,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from1: empty parameter not accepted\n",
v19,
v21,
v12,
v13,
v23);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:uac:fixup_replace_from1: empty parameter not accepted\n",
*((const char **)&log_level_info + 6),
"uac [uac.c:180]: ",
"fixup_replace_from1");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
}
else
{
v8 = (__int64)&LC0;
v9 = get_debug_level(&LC0, 3LL);
result = 4294967294LL;
if ( v9 >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
{
v8 = 4294967294LL;
dprint_color(4294967294LL);
}
v14 = (const char *)*((_QWORD *)&log_level_info + 6);
v15 = my_pid();
v22 = (const char *)v8;
v16 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from1: no more pkg mem\n",
process_no,
v15,
v14,
"uac [uac.c:173]: ",
"fixup_replace_from1");
if ( log_color )
dprint_color_reset(
v16,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from1: no more pkg mem\n",
v17,
v18,
v20,
v22,
v23);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:uac:fixup_replace_from1: no more pkg mem\n",
*((const char **)&log_level_info + 6),
"uac [uac.c:173]: ",
"fixup_replace_from1");
}
result = 4294967294LL;
--dprint_crit;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char **a1)
{
const char **v2; // rax
const char *v3; // rdi
const char **v4; // rbx
int v5; // eax
__int64 result; // rax
int v7; // er8
__int64 v8; // rdi
int v9; // ebx
const char *v10; // r12
struct _IO_FILE *v11; // rdi
const char *v12; // r8
const char *v13; // r9
const char *v14; // r12
unsigned int v15; // eax
struct _IO_FILE *v16; // rdi
__int64 v17; // rdx
__int64 v18; // rcx
__int64 v19; // [rsp-10h] [rbp-28h]
const char *v20; // [rsp-10h] [rbp-28h]
__int64 v21; // [rsp-8h] [rbp-20h]
const char *v22; // [rsp-8h] [rbp-20h]
const char *v23; // [rsp+0h] [rbp-18h]

v2 = (const char **)qm_malloc(mem_block, 16LL);
if ( v2 )
{
v3 = *a1;
v4 = v2;
*v2 = *a1;
v5 = strlen(v3);
*((_DWORD *)v4 + 2) = v5;
if ( v5 )
{
*a1 = (const char *)v4;
result = 0LL;
}
else
{
v7 = get_debug_level(&LC0, 3LL);
result = 0xFFFFFFFFLL;
if ( v7 >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v10 = (const char *)*((_QWORD *)&log_level_info + 6);
v21 = my_pid();
v11 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from1: empty parameter not accepted\n",
process_no,
(unsigned int)v21,
v10,
"uac [uac.c:180]: ",
"fixup_replace_from1");
if ( log_color )
dprint_color_reset(
v11,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from1: empty parameter not accepted\n",
v19,
v21,
v12,
v13,
v23);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:uac:fixup_replace_from1: empty parameter not accepted\n",
*((const char **)&log_level_info + 6),
"uac [uac.c:180]: ",
"fixup_replace_from1");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
}
else
{
v8 = (__int64)&LC0;
v9 = get_debug_level(&LC0, 3LL);
result = 4294967294LL;
if ( v9 >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
{
v8 = 4294967294LL;
dprint_color(4294967294LL);
}
v14 = (const char *)*((_QWORD *)&log_level_info + 6);
v15 = my_pid();
v22 = (const char *)v8;
v16 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from1: no more pkg mem\n",
process_no,
v15,
v14,
"uac [uac.c:173]: ",
"fixup_replace_from1");
if ( log_color )
dprint_color_reset(
v16,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from1: no more pkg mem\n",
v17,
v18,
v20,
v22,
v23);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:uac:fixup_replace_from1: no more pkg mem\n",
*((const char **)&log_level_info + 6),
"uac [uac.c:173]: ",
"fixup_replace_from1");
}
result = 4294967294LL;
--dprint_crit;
}
}
return result;
}

original_code:
static int fixup_replace_from1(void** param, int param_no)
{
 str *s;
 s = (str*)qm_malloc(mem_block, (sizeof(str)));
 if (s==0)
 {
  do { if (get_debug_level("uac", (sizeof("uac")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR:uac:fixup_replace_from1: no more pkg mem\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "173" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR:uac:fixup_replace_from1: no more pkg mem\n", (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "173" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR:uac:fixup_replace_from1: no more pkg mem\n", process_no, my_pid(), ("uac" " [" "uac.c" ":" "173" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from1: no more pkg mem\n", ("uac" " [" "uac.c" ":" "173" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from1: no more pkg mem\n", ("uac" " [" "uac.c" ":" "173" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -2;
 }
 s->s = (char*)*param;
 s->len = strlen(s->s);
 if (s->len==0)
 {
  do { if (get_debug_level("uac", (sizeof("uac")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR:uac:fixup_replace_from1: empty parameter " "not accepted\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "180" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR:uac:fixup_replace_from1: empty parameter " "not accepted\n", (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "180" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR:uac:fixup_replace_from1: empty parameter " "not accepted\n", process_no, my_pid(), ("uac" " [" "uac.c" ":" "180" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from1: empty parameter " "not accepted\n", ("uac" " [" "uac.c" ":" "180" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from1: empty parameter " "not accepted\n", ("uac" " [" "uac.c" ":" "180" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 *param=(void*)s;
 return 0;
}

canonical_original_code:
static int fixup_replace_from1(void **param, int param_no)
{
 struct _str *s;
 s = (struct _str *)qm_malloc(mem_block, (sizeof(str)));
 if (s==0)
 {
  do { if (get_debug_level("uac", (sizeof("uac")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR:uac:fixup_replace_from1: no more pkg mem\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "173" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR:uac:fixup_replace_from1: no more pkg mem\n", (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "173" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR:uac:fixup_replace_from1: no more pkg mem\n", process_no, my_pid(), ("uac" " [" "uac.c" ":" "173" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from1: no more pkg mem\n", ("uac" " [" "uac.c" ":" "173" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from1: no more pkg mem\n", ("uac" " [" "uac.c" ":" "173" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -2;
 }
 s->s = (char *)*param;
 s->len = strlen(s->s);
 if (s->len==0)
 {
  do { if (get_debug_level("uac", (sizeof("uac")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR:uac:fixup_replace_from1: empty parameter " "not accepted\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "180" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR:uac:fixup_replace_from1: empty parameter " "not accepted\n", (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "180" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR:uac:fixup_replace_from1: empty parameter " "not accepted\n", process_no, my_pid(), ("uac" " [" "uac.c" ":" "180" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from1: empty parameter " "not accepted\n", ("uac" " [" "uac.c" ":" "180" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from1: empty parameter " "not accepted\n", ("uac" " [" "uac.c" ":" "180" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 *param=(void *)s;
 return 0;
}

variable_types:
param
void **

variable_types:
s
struct _str { char *s; int len; } *

user_defined_types: struct cfg_group_core { int debug; int log_facility; int memdbg; int use_dst_blacklist; unsigned int blst_timeout; unsigned int blst_max_mem; unsigned int blst_udp_imask; unsigned int blst_tcp_imask; unsigned int blst_tls_imask; unsigned int blst_sctp_imask; int dns_try_ipv6; int dns_try_naptr; int dns_udp_pref; int dns_tcp_pref; int dns_tls_pref; int dns_sctp_pref; int dns_retr_time; int dns_retr_no; int dns_servers_no; int dns_search_list; int dns_search_fmatch; int dns_reinit; int use_dns_cache; int dns_cache_flags; int use_dns_failover; int dns_srv_lb; unsigned int dns_neg_cache_ttl; unsigned int dns_cache_min_ttl; unsigned int dns_cache_max_ttl; unsigned int dns_cache_max_mem; int dns_cache_del_nonexp; int dns_cache_rec_pref; int mem_dump_pkg; int mem_dump_shm; int max_while_loops; int udp_mtu; int udp_mtu_try_proto; int udp4_raw; int udp4_raw_mtu; int udp4_raw_ttl; int force_rport; int memlog; int mem_summary; int mem_safety; int mem_join; int corelog; int latency_log; int latency_limit_db; int latency_limit_action; }


decompiled_code:
__int64 __fastcall fixup_replace_from2(const char **a1, int a2)
{
const char **v3; // rax
const char *v4; // r14
const char **v5; // rbx
int v6; // eax
int v7; // esi
__int64 result; // rax
char *v9; // rax
const char *v10; // r14
int v11; // er8
const char *v12; // rbp
unsigned int v13; // eax
__int64 v14; // r9
__int64 v15; // rcx
const char *v16; // r9
const char *v17; // rbx
struct _IO_FILE *v18; // rdi
const char *v19; // r8
const char *v20; // r9
unsigned int v21; // eax
__int64 v22; // r8
const char *v23; // [rsp-10h] [rbp-38h]
__int64 v24; // [rsp-10h] [rbp-38h]
__int64 v25; // [rsp-8h] [rbp-30h]
__int64 v26; // [rsp-8h] [rbp-30h]
const char *v27; // [rsp+0h] [rbp-28h]

v3 = (const char **)qm_malloc(mem_block, 16LL);
if ( !v3 )
{
if ( (int)get_debug_level(&LC0, 3LL) < -2 || dprint_crit )
return 4294967294LL;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:uac:fixup_replace_from2: no more pkg mem\n",
*((const char **)&log_level_info + 6),
"uac [uac.c:199]: ",
"fixup_replace_from2");
LABEL_21:
--dprint_crit;
return 4294967294LL;
}
if ( log_color )
dprint_color(4294967294LL);
v12 = (const char *)*((_QWORD *)&log_level_info + 6);
v13 = my_pid();
v25 = v14;
v15 = v13;
v16 = "uac [uac.c:199]: ";
LABEL_30:
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from2: no more pkg mem\n",
process_no,
v15,
v12,
v16,
"fixup_replace_from2");
if ( log_color )
dprint_color_reset(v25, v23);
goto LABEL_21;
}
v4 = *a1;
v5 = v3;
*v3 = *a1;
v6 = strlen(v4);
*((_DWORD *)v5 + 2) = v6;
v7 = v6;
if ( v6 )
{
if ( a2 != 1 )
{
LABEL_4:
*a1 = (const char *)v5;
return 0LL;
}
goto LABEL_8;
}
qm_free(mem_block, v4);
*v5 = 0LL;
if ( a2 == 1 )
{
v7 = *((_DWORD *)v5 + 2);
if ( !v7 )
goto LABEL_4;
LABEL_8:
v9 = (char *)qm_malloc(mem_block, v7 + 2);
v10 = v9;
if ( v9 )
{
*v9 = 34;
memcpy(v9 + 1, *v5, *((int *)v5 + 2));
v10[*((int *)v5 + 2) + 1] = 34;
qm_free(mem_block, *v5);
*((_DWORD *)v5 + 2) += 2;
*v5 = v10;
goto LABEL_4;
}
if ( (int)get_debug_level(&LC0, 3LL) < -2 || dprint_crit )
return 4294967294LL;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:uac:fixup_replace_from2: no more pkg mem\n",
*((const char **)&log_level_info + 6),
"uac [uac.c:218]: ",
"fixup_replace_from2");
goto LABEL_21;
}
if ( log_color )
dprint_color(4294967294LL);
v12 = (const char *)*((_QWORD *)&log_level_info + 6);
v21 = my_pid();
v16 = "uac [uac.c:218]: ";
v15 = v21;
v25 = v22;
goto LABEL_30;
}
if ( a2 != 2 || *(_QWORD *)*(a1 - 1) )
goto LABEL_4;
v11 = get_debug_level(&LC0, 3LL);
result = 0xFFFFFFFFLL;
if ( v11 >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v17 = (const char *)*((_QWORD *)&log_level_info + 6);
v26 = my_pid();
v18 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from2: both parameter are empty\n",
process_no,
(unsigned int)v26,
v17,
"uac [uac.c:233]: ",
"fixup_replace_from2");
if ( log_color )
dprint_color_reset(
v18,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from2: both parameter are empty\n",
v24,
v26,
v19,
v20,
v27);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:uac:fixup_replace_from2: both parameter are empty\n",
*((const char **)&log_level_info + 6),
"uac [uac.c:233]: ",
"fixup_replace_from2");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char **a1, int a2)
{
const char **v3; // rax
const char *v4; // r14
const char **v5; // rbx
int v6; // eax
int v7; // esi
__int64 result; // rax
char *v9; // rax
const char *v10; // r14
int v11; // er8
const char *v12; // rbp
unsigned int v13; // eax
__int64 v14; // r9
__int64 v15; // rcx
const char *v16; // r9
const char *v17; // rbx
struct _IO_FILE *v18; // rdi
const char *v19; // r8
const char *v20; // r9
unsigned int v21; // eax
__int64 v22; // r8
const char *v23; // [rsp-10h] [rbp-38h]
__int64 v24; // [rsp-10h] [rbp-38h]
__int64 v25; // [rsp-8h] [rbp-30h]
__int64 v26; // [rsp-8h] [rbp-30h]
const char *v27; // [rsp+0h] [rbp-28h]

v3 = (const char **)qm_malloc(mem_block, 16LL);
if ( !v3 )
{
if ( (int)get_debug_level(&LC0, 3LL) < -2 || dprint_crit )
return 4294967294LL;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:uac:fixup_replace_from2: no more pkg mem\n",
*((const char **)&log_level_info + 6),
"uac [uac.c:199]: ",
"fixup_replace_from2");
LABEL_21:
--dprint_crit;
return 4294967294LL;
}
if ( log_color )
dprint_color(4294967294LL);
v12 = (const char *)*((_QWORD *)&log_level_info + 6);
v13 = my_pid();
v25 = v14;
v15 = v13;
v16 = "uac [uac.c:199]: ";
LABEL_30:
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from2: no more pkg mem\n",
process_no,
v15,
v12,
v16,
"fixup_replace_from2");
if ( log_color )
dprint_color_reset(v25, v23);
goto LABEL_21;
}
v4 = *a1;
v5 = v3;
*v3 = *a1;
v6 = strlen(v4);
*((_DWORD *)v5 + 2) = v6;
v7 = v6;
if ( v6 )
{
if ( a2 != 1 )
{
LABEL_4:
*a1 = (const char *)v5;
return 0LL;
}
goto LABEL_8;
}
qm_free(mem_block, v4);
*v5 = 0LL;
if ( a2 == 1 )
{
v7 = *((_DWORD *)v5 + 2);
if ( !v7 )
goto LABEL_4;
LABEL_8:
v9 = (char *)qm_malloc(mem_block, v7 + 2);
v10 = v9;
if ( v9 )
{
*v9 = 34;
memcpy(v9 + 1, *v5, *((int *)v5 + 2));
v10[*((int *)v5 + 2) + 1] = 34;
qm_free(mem_block, *v5);
*((_DWORD *)v5 + 2) += 2;
*v5 = v10;
goto LABEL_4;
}
if ( (int)get_debug_level(&LC0, 3LL) < -2 || dprint_crit )
return 4294967294LL;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:uac:fixup_replace_from2: no more pkg mem\n",
*((const char **)&log_level_info + 6),
"uac [uac.c:218]: ",
"fixup_replace_from2");
goto LABEL_21;
}
if ( log_color )
dprint_color(4294967294LL);
v12 = (const char *)*((_QWORD *)&log_level_info + 6);
v21 = my_pid();
v16 = "uac [uac.c:218]: ";
v15 = v21;
v25 = v22;
goto LABEL_30;
}
if ( a2 != 2 || *(_QWORD *)*(a1 - 1) )
goto LABEL_4;
v11 = get_debug_level(&LC0, 3LL);
result = 0xFFFFFFFFLL;
if ( v11 >= -2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(4294967294LL);
v17 = (const char *)*((_QWORD *)&log_level_info + 6);
v26 = my_pid();
v18 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from2: both parameter are empty\n",
process_no,
(unsigned int)v26,
v17,
"uac [uac.c:233]: ",
"fixup_replace_from2");
if ( log_color )
dprint_color_reset(
v18,
"%2d(%d) %s: %s%s(): ERROR:uac:fixup_replace_from2: both parameter are empty\n",
v24,
v26,
v19,
v20,
v27);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 14) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): ERROR:uac:fixup_replace_from2: both parameter are empty\n",
*((const char **)&log_level_info + 6),
"uac [uac.c:233]: ",
"fixup_replace_from2");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
return result;
}

original_code:
static int fixup_replace_from2(void** param, int param_no)
{
 char *p;
 str *s;
 s = (str*)qm_malloc(mem_block, (sizeof(str)));
 if (s==0)
 {
  do { if (get_debug_level("uac", (sizeof("uac")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", process_no, my_pid(), ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -2;
 }
 s->s = (char*)*param;
 s->len = strlen(s->s);
 if (s->len==0)
 {
  qm_free(mem_block, (s->s));
  s->s = 0;
 }
 if (param_no==1)
 {
  if (s->len)
  {
   p = (char*)qm_malloc(mem_block, (s->len+2));
   if (p==0)
   {
    do { if (get_debug_level("uac", (sizeof("uac")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", process_no, my_pid(), ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); } } (dprint_crit--); } } while(0);
    return -2;
   }
   p[0] = '\"';
   memcpy( p+1, s->s, s->len);
   p[s->len+1] = '\"';
   qm_free(mem_block, (s->s));
   s->s = p;
   s->len += 2;
  }
 } else if (param_no==2)
 {
  if (s->s==0 && ((str*)(*(param-1)))->s==0 )
  {
   do { if (get_debug_level("uac", (sizeof("uac")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", process_no, my_pid(), ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -1;
  }
 }
 *param=(void*)s;
 return 0;
}

canonical_original_code:
static int fixup_replace_from2(void **param, int param_no)
{
 char *p;
 struct _str *s;
 s = (struct _str *)qm_malloc(mem_block, (sizeof(str)));
 if (s==0)
 {
  do { if (get_debug_level("uac", (sizeof("uac")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", process_no, my_pid(), ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", ("uac" " [" "uac.c" ":" "199" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -2;
 }
 s->s = (char *)*param;
 s->len = strlen(s->s);
 if (s->len==0)
 {
  qm_free(mem_block, (s->s));
  s->s = 0;
 }
 if (param_no==1)
 {
  if (s->len)
  {
   p = (char *)qm_malloc(mem_block, (s->len+2));
   if (p==0)
   {
    do { if (get_debug_level("uac", (sizeof("uac")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", process_no, my_pid(), ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: no more pkg mem\n", ("uac" " [" "uac.c" ":" "218" "]: ") , __func__); } } (dprint_crit--); } } while(0);
    return -2;
   }
   p[0] = '\"';
   memcpy( p+1, s->s, s->len);
   p[s->len+1] = '\"';
   qm_free(mem_block, (s->s));
   s->s = p;
   s->len += 2;
  }
 } else if (param_no==2)
 {
  if (s->s==0 && ((struct _str *)(*(param-1)))->s==0 )
  {
   do { if (get_debug_level("uac", (sizeof("uac")-1)) >= ((-2)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-2)) >= -5) && (((-2)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", process_no, my_pid(), (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-2)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", (log_level_info[((-2)) - (-5)].name), ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-2)); fprintf(stderr, "%2d(%d) %s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", process_no, my_pid(), ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-2))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "ERROR:uac:fixup_replace_from2: both parameter " "are empty\n", ("uac" " [" "uac.c" ":" "233" "]: ") , __func__); } } (dprint_crit--); } } while(0);
   return -1;
  }
 }
 *param=(void *)s;
 return 0;
}


decompiled_code:
__int64 mod_destroy()
{
return destroy_credentials();
}

canonical_decompiled_code:
__int64 func0()
{
return destroy_credentials();
}

original_code:
static void mod_destroy()
{
 destroy_credentials();
}


decompiled_code:
int __fastcall err2reason_phrase(int a1, _DWORD *a2, char *a3, int a4, const char *a5)
{
const char *v5; // r11

if ( a1 > 0 )
goto LABEL_13;
if ( a1 < -18 )
{
if ( a1 == -478 )
{
*a2 = 478;
v5 = "Unresolvable destination";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
if ( a1 < -477 )
{
if ( a1 == -487 )
{
*a2 = 487;
v5 = "transaction canceled";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
if ( a1 == -479 )
{
*a2 = 479;
v5 = "Regretfully, we were not able to process the URI";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
}
else
{
if ( a1 == -477 )
{
*a2 = 477;
v5 = "Unfortunately error on sending to next hop occurred";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
if ( a1 == -400 )
{
*a2 = 400;
v5 = "Bad Request";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
}
LABEL_13:
*a2 = 500;
v5 = "I'm terribly sorry, server error occurred";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
switch ( a1 )
{
case -18:
*a2 = 400;
v5 = "Decimal part missing in q";
break;
case -17:
*a2 = 400;
v5 = "q parameter too big";
break;
case -16:
*a2 = 400;
v5 = "Empty q parameter";
break;
case -15:
*a2 = 400;
v5 = "Invalid character in q parameter";
break;
case -13:
*a2 = 400;
v5 = "Bad To";
break;
case -12:
*a2 = 500;
v5 = "Forking capacity exceeded";
break;
case -11:
*a2 = 500;
v5 = "Error in external logic";
break;
case -9:
*a2 = 400;
v5 = "Transaction tuple incomplete";
break;
case -2:
case 0:
*a2 = 500;
v5 = "No error";
break;
default:
goto LABEL_13;
}
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}

canonical_decompiled_code:
int __fastcall func0(int a1, _DWORD *a2, char *a3, int a4, const char *a5)
{
const char *v5; // r11

if ( a1 > 0 )
goto LABEL_13;
if ( a1 < -18 )
{
if ( a1 == -478 )
{
*a2 = 478;
v5 = "Unresolvable destination";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
if ( a1 < -477 )
{
if ( a1 == -487 )
{
*a2 = 487;
v5 = "transaction canceled";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
if ( a1 == -479 )
{
*a2 = 479;
v5 = "Regretfully, we were not able to process the URI";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
}
else
{
if ( a1 == -477 )
{
*a2 = 477;
v5 = "Unfortunately error on sending to next hop occurred";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
if ( a1 == -400 )
{
*a2 = 400;
v5 = "Bad Request";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
}
LABEL_13:
*a2 = 500;
v5 = "I'm terribly sorry, server error occurred";
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}
switch ( a1 )
{
case -18:
*a2 = 400;
v5 = "Decimal part missing in q";
break;
case -17:
*a2 = 400;
v5 = "q parameter too big";
break;
case -16:
*a2 = 400;
v5 = "Empty q parameter";
break;
case -15:
*a2 = 400;
v5 = "Invalid character in q parameter";
break;
case -13:
*a2 = 400;
v5 = "Bad To";
break;
case -12:
*a2 = 500;
v5 = "Forking capacity exceeded";
break;
case -11:
*a2 = 500;
v5 = "Error in external logic";
break;
case -9:
*a2 = 400;
v5 = "Transaction tuple incomplete";
break;
case -2:
case 0:
*a2 = 500;
v5 = "No error";
break;
default:
goto LABEL_13;
}
return snprintf(a3, a4, "%s (%d/%s)", v5, (unsigned int)-a1, a5);
}

original_code:
int err2reason_phrase(
 int ser_error,
 int *sip_error,
 char *phrase,
 int etl,
 char *signature )
{
 char *error_txt;
 switch( ser_error ) {
  case -477:
   error_txt="Unfortunately error on sending to next hop occurred";
   *sip_error=-ser_error;
   break;
  case -478:
   error_txt="Unresolvable destination";
   *sip_error=-ser_error;
   break;
  case -400:
   error_txt="Bad Request";
   *sip_error=-ser_error;
   break;
  case -479:
   error_txt="Regretfully, we were not able to process the URI";
   *sip_error=-ser_error;
   break;
  case -9:
   error_txt="Transaction tuple incomplete";
   *sip_error=- -400;
   break;
  case -13:
   error_txt="Bad To";
   *sip_error=- -400;
   break;
  case -11:
   error_txt="Error in external logic";
   *sip_error=- -500;
   break;
  case -12:
   error_txt="Forking capacity exceeded";
   *sip_error=- -500;
   break;
         case -15:
   error_txt="Invalid character in q parameter";
   *sip_error=- -400;
   break;
         case -16:
   error_txt="Empty q parameter";
   *sip_error=- -400;
   break;;
         case -17:
   error_txt="q parameter too big";
   *sip_error=- -400;
   break;
         case -18:
   error_txt="Decimal part missing in q";
   *sip_error=- -400;
   break;
  case -487:
   error_txt="transaction canceled";
   *sip_error=-ser_error;
   break;
  case -2:
  case 0:
   error_txt="No error";
   *sip_error=500;
   break;
  default:
   error_txt="I'm terribly sorry, server error occurred";
   *sip_error=500;
   break;
 }
 return snprintf( phrase, etl, "%s (%d/%s)", error_txt,
  -ser_error, signature );
}

canonical_original_code:
int err2reason_phrase(int ser_error, int *sip_error, char *phrase, int etl, char *signature)
{
 char *error_txt;
 switch( ser_error ) {
  case -477:
   error_txt="Unfortunately error on sending to next hop occurred";
   *sip_error=-ser_error;
   break;
  case -478:
   error_txt="Unresolvable destination";
   *sip_error=-ser_error;
   break;
  case -400:
   error_txt="Bad Request";
   *sip_error=-ser_error;
   break;
  case -479:
   error_txt="Regretfully, we were not able to process the URI";
   *sip_error=-ser_error;
   break;
  case -9:
   error_txt="Transaction tuple incomplete";
   *sip_error=- -400;
   break;
  case -13:
   error_txt="Bad To";
   *sip_error=- -400;
   break;
  case -11:
   error_txt="Error in external logic";
   *sip_error=- -500;
   break;
  case -12:
   error_txt="Forking capacity exceeded";
   *sip_error=- -500;
   break;
         case -15:
   error_txt="Invalid character in q parameter";
   *sip_error=- -400;
   break;
         case -16:
   error_txt="Empty q parameter";
   *sip_error=- -400;
   break;;
         case -17:
   error_txt="q parameter too big";
   *sip_error=- -400;
   break;
         case -18:
   error_txt="Decimal part missing in q";
   *sip_error=- -400;
   break;
  case -487:
   error_txt="transaction canceled";
   *sip_error=-ser_error;
   break;
  case -2:
  case 0:
   error_txt="No error";
   *sip_error=500;
   break;
  default:
   error_txt="I'm terribly sorry, server error occurred";
   *sip_error=500;
   break;
 }
 return snprintf( phrase, etl, "%s (%d/%s)", error_txt,
  -ser_error, signature );
}

variable_types:
phrase
char *

variable_types: etl int

variable_types:
signature
char *


decompiled_code:
const char *__fastcall error_text(int a1)
{
const char *result; // rax

if ( a1 > 606 )
return "Global Failure";
if ( a1 <= 299 )
{
if ( a1 == 100 )
{
result = "Trying";
}
else
{
switch ( a1 )
{
case 180:
result = "Ringing";
break;
case 181:
result = "Call is Being Forwarded";
break;
case 182:
result = "Queued";
break;
case 183:
result = "Session Progress";
break;
case 184:
case 185:
case 186:
case 187:
case 188:
case 189:
case 190:
case 191:
case 192:
case 193:
case 194:
case 195:
case 196:
case 197:
case 198:
case 199:
LABEL_8:
if ( a1 > 599 )
return "Global Failure";
result = "Server Failure";
if ( a1 <= 499 )
{
result = "Request Failure";
if ( a1 <= 399 )
{
if ( a1 <= 299 )
goto LABEL_61;
result = "Redirection";
}
}
break;
case 200:
result = "OK";
break;
default:
LABEL_61:
result = "Successful";
if ( a1 <= 199 )
{
result = "Provisional";
if ( a1 <= 99 )
result = "Unspecified";
}
break;
}
}
}
else
{
switch ( a1 )
{
case 300:
result = "Multiple Choices";
break;
case 301:
result = "Moved Permanently";
break;
case 302:
result = "Moved Temporarily";
break;
case 305:
result = "Use Proxy";
break;
case 380:
result = "Alternative Service";
break;
case 400:
result = "Bad Request";
break;
case 401:
result = "Unauthorized";
break;
case 402:
result = "Payment Required";
break;
case 403:
result = "Forbidden";
break;
case 404:
result = "Not Found";
break;
case 405:
result = "Method not Allowed";
break;
case 406:
case 606:
result = "Not Acceptable";
break;
case 407:
result = "Proxy authentication Required";
break;
case 408:
result = "Request Timeout";
break;
case 410:
result = "Gone";
break;
case 413:
result = "Request Entity Too Large";
break;
case 414:
result = "Request-URI Too Long";
break;
case 415:
result = "Unsupported Media Type";
break;
case 416:
result = "Unsupported URI Scheme";
break;
case 417:
result = "Bad Extension";
break;
case 421:
result = "Extension Required";
break;
case 423:
result = "Interval Too Brief";
break;
case 480:
result = "Temporarily Unavailable";
break;
case 481:
result = "Call/Transaction Does not Exist";
break;
case 482:
result = "Loop Detected";
break;
case 483:
result = "Too Many Hops";
break;
case 484:
result = "Address Incomplete";
break;
case 485:
result = "Ambiguous";
break;
case 486:
result = "Busy Here";
break;
case 487:
result = "Request Terminated";
break;
case 488:
result = "Not Acceptable Here";
break;
case 491:
result = "Request Pending";
break;
case 500:
result = "Server Internal Error";
break;
case 501:
result = "Not Implemented";
break;
case 502:
result = "Bad Gateway";
break;
case 503:
result = "Service Unavailable";
break;
case 504:
result = "Server Time-out";
break;
case 505:
result = "Version not Supported";
break;
case 513:
result = "Message Too Large";
break;
case 600:
result = "Busy Everywhere";
break;
case 603:
result = "Decline";
break;
case 604:
result = "Does not Exist Anywhere";
break;
default:
goto LABEL_8;
}
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func1(int a1)
{
const char *result; // rax

if ( a1 > 606 )
return "Global Failure";
if ( a1 <= 299 )
{
if ( a1 == 100 )
{
result = "Trying";
}
else
{
switch ( a1 )
{
case 180:
result = "Ringing";
break;
case 181:
result = "Call is Being Forwarded";
break;
case 182:
result = "Queued";
break;
case 183:
result = "Session Progress";
break;
case 184:
case 185:
case 186:
case 187:
case 188:
case 189:
case 190:
case 191:
case 192:
case 193:
case 194:
case 195:
case 196:
case 197:
case 198:
case 199:
LABEL_8:
if ( a1 > 599 )
return "Global Failure";
result = "Server Failure";
if ( a1 <= 499 )
{
result = "Request Failure";
if ( a1 <= 399 )
{
if ( a1 <= 299 )
goto LABEL_61;
result = "Redirection";
}
}
break;
case 200:
result = "OK";
break;
default:
LABEL_61:
result = "Successful";
if ( a1 <= 199 )
{
result = "Provisional";
if ( a1 <= 99 )
result = "Unspecified";
}
break;
}
}
}
else
{
switch ( a1 )
{
case 300:
result = "Multiple Choices";
break;
case 301:
result = "Moved Permanently";
break;
case 302:
result = "Moved Temporarily";
break;
case 305:
result = "Use Proxy";
break;
case 380:
result = "Alternative Service";
break;
case 400:
result = "Bad Request";
break;
case 401:
result = "Unauthorized";
break;
case 402:
result = "Payment Required";
break;
case 403:
result = "Forbidden";
break;
case 404:
result = "Not Found";
break;
case 405:
result = "Method not Allowed";
break;
case 406:
case 606:
result = "Not Acceptable";
break;
case 407:
result = "Proxy authentication Required";
break;
case 408:
result = "Request Timeout";
break;
case 410:
result = "Gone";
break;
case 413:
result = "Request Entity Too Large";
break;
case 414:
result = "Request-URI Too Long";
break;
case 415:
result = "Unsupported Media Type";
break;
case 416:
result = "Unsupported URI Scheme";
break;
case 417:
result = "Bad Extension";
break;
case 421:
result = "Extension Required";
break;
case 423:
result = "Interval Too Brief";
break;
case 480:
result = "Temporarily Unavailable";
break;
case 481:
result = "Call/Transaction Does not Exist";
break;
case 482:
result = "Loop Detected";
break;
case 483:
result = "Too Many Hops";
break;
case 484:
result = "Address Incomplete";
break;
case 485:
result = "Ambiguous";
break;
case 486:
result = "Busy Here";
break;
case 487:
result = "Request Terminated";
break;
case 488:
result = "Not Acceptable Here";
break;
case 491:
result = "Request Pending";
break;
case 500:
result = "Server Internal Error";
break;
case 501:
result = "Not Implemented";
break;
case 502:
result = "Bad Gateway";
break;
case 503:
result = "Service Unavailable";
break;
case 504:
result = "Server Time-out";
break;
case 505:
result = "Version not Supported";
break;
case 513:
result = "Message Too Large";
break;
case 600:
result = "Busy Everywhere";
break;
case 603:
result = "Decline";
break;
case 604:
result = "Does not Exist Anywhere";
break;
default:
goto LABEL_8;
}
}
return result;
}

original_code:
char *error_text( int code )
{
 switch(code) {
  case 100: return "Trying";
  case 180: return "Ringing";
  case 181: return "Call is Being Forwarded";
  case 182: return "Queued";
  case 183: return "Session Progress";
  case 200: return "OK";
  case 300: return "Multiple Choices";
  case 301: return "Moved Permanently";
  case 302: return "Moved Temporarily";
  case 305: return "Use Proxy";
  case 380: return "Alternative Service";
  case 400: return "Bad Request";
  case 401: return "Unauthorized";
  case 402: return "Payment Required";
  case 403: return "Forbidden";
  case 404: return "Not Found";
  case 405: return "Method not Allowed";
  case 406: return "Not Acceptable";
  case 407: return "Proxy authentication Required";
  case 408: return "Request Timeout";
  case 410: return "Gone";
  case 413: return "Request Entity Too Large";
  case 414: return "Request-URI Too Long";
  case 415: return "Unsupported Media Type";
  case 416: return "Unsupported URI Scheme";
  case 417: return "Bad Extension";
  case 421: return "Extension Required";
  case 423: return "Interval Too Brief";
  case 480: return "Temporarily Unavailable";
  case 481: return "Call/Transaction Does not Exist";
  case 482: return "Loop Detected";
  case 483: return "Too Many Hops";
  case 484: return "Address Incomplete";
  case 485: return "Ambiguous";
  case 486: return "Busy Here";
  case 487: return "Request Terminated";
  case 488: return "Not Acceptable Here";
  case 491: return "Request Pending";
  case 500: return "Server Internal Error";
  case 501: return "Not Implemented";
  case 502: return "Bad Gateway";
  case 503: return "Service Unavailable";
  case 504: return "Server Time-out";
  case 505: return "Version not Supported";
  case 513: return "Message Too Large";
  case 600: return "Busy Everywhere";
  case 603: return "Decline";
  case 604: return "Does not Exist Anywhere";
  case 606: return "Not Acceptable";
 }
 if (code>=600) return "Global Failure";
 else if (code>=500) return "Server Failure";
 else if (code>=400) return "Request Failure";
 else if (code>=300) return "Redirection";
 else if (code>=200) return "Successful";
 else if (code>=100) return "Provisional";
 else return "Unspecified";
}

canonical_original_code:
char *error_text(int code)
{
 switch(code) {
  case 100: return "Trying";
  case 180: return "Ringing";
  case 181: return "Call is Being Forwarded";
  case 182: return "Queued";
  case 183: return "Session Progress";
  case 200: return "OK";
  case 300: return "Multiple Choices";
  case 301: return "Moved Permanently";
  case 302: return "Moved Temporarily";
  case 305: return "Use Proxy";
  case 380: return "Alternative Service";
  case 400: return "Bad Request";
  case 401: return "Unauthorized";
  case 402: return "Payment Required";
  case 403: return "Forbidden";
  case 404: return "Not Found";
  case 405: return "Method not Allowed";
  case 406: return "Not Acceptable";
  case 407: return "Proxy authentication Required";
  case 408: return "Request Timeout";
  case 410: return "Gone";
  case 413: return "Request Entity Too Large";
  case 414: return "Request-URI Too Long";
  case 415: return "Unsupported Media Type";
  case 416: return "Unsupported URI Scheme";
  case 417: return "Bad Extension";
  case 421: return "Extension Required";
  case 423: return "Interval Too Brief";
  case 480: return "Temporarily Unavailable";
  case 481: return "Call/Transaction Does not Exist";
  case 482: return "Loop Detected";
  case 483: return "Too Many Hops";
  case 484: return "Address Incomplete";
  case 485: return "Ambiguous";
  case 486: return "Busy Here";
  case 487: return "Request Terminated";
  case 488: return "Not Acceptable Here";
  case 491: return "Request Pending";
  case 500: return "Server Internal Error";
  case 501: return "Not Implemented";
  case 502: return "Bad Gateway";
  case 503: return "Service Unavailable";
  case 504: return "Server Time-out";
  case 505: return "Version not Supported";
  case 513: return "Message Too Large";
  case 600: return "Busy Everywhere";
  case 603: return "Decline";
  case 604: return "Does not Exist Anywhere";
  case 606: return "Not Acceptable";
 }
 if (code>=600) return "Global Failure";
 else if (code>=500) return "Server Failure";
 else if (code>=400) return "Request Failure";
 else if (code>=300) return "Redirection";
 else if (code>=200) return "Successful";
 else if (code>=100) return "Provisional";
 else return "Unspecified";
}

variable_types: code int


decompiled_code:
__int64 __fastcall defunct_gw(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // [rsp+4h] [rbp-24h] BYREF
unsigned int v4; // [rsp+8h] [rbp-20h] BYREF
unsigned int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( (*(int (__fastcall **)(__int64, const char *, unsigned int *, unsigned int *, unsigned int *))(a1 + 24))(
a2,
"ddd",
&v3,
&v4,
v5) <= 2 )
return (*(__int64 (__fastcall **)(__int64, __int64, const char *))a1)(
a2,
400LL,
"lcr_id, gw_id, and timestamp parameters required");
result = rpc_defunct_gw(v3, v4, v5[0]);
if ( !(_DWORD)result )
result = (*(__int64 (__fastcall **)(__int64, __int64, const char *))a1)(
a2,
400LL,
"parameter value error (see syslog)");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // [rsp+4h] [rbp-24h] BYREF
unsigned int v4; // [rsp+8h] [rbp-20h] BYREF
unsigned int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( (*(int (__fastcall **)(__int64, const char *, unsigned int *, unsigned int *, unsigned int *))(a1 + 24))(
a2,
"ddd",
&v3,
&v4,
v5) <= 2 )
return (*(__int64 (__fastcall **)(__int64, __int64, const char *))a1)(
a2,
400LL,
"lcr_id, gw_id, and timestamp parameters required");
result = rpc_defunct_gw(v3, v4, v5[0]);
if ( !(_DWORD)result )
result = (*(__int64 (__fastcall **)(__int64, __int64, const char *))a1)(
a2,
400LL,
"parameter value error (see syslog)");
return result;
}

original_code:
static void defunct_gw(rpc_t* rpc, void* c)
{
    unsigned int lcr_id, gw_id, until;
    if (rpc->scan(c, "ddd", &lcr_id, &gw_id, &until) < 3) {
 rpc->fault(c, 400, "lcr_id, gw_id, and timestamp parameters required");
 return;
    }
    if (rpc_defunct_gw(lcr_id, gw_id, until) == 0) {
 rpc->fault(c, 400, "parameter value error (see syslog)");
    }
    return;
}

canonical_original_code:
static void defunct_gw(struct rpc *rpc, void *c)
{
    unsigned int lcr_id; unsigned int gw_id; unsigned int until;
    if (rpc->scan(c, "ddd", &lcr_id, &gw_id, &until) < 3) {
 rpc->fault(c, 400, "lcr_id, gw_id, and timestamp parameters required");
 return;
    }
    if (rpc_defunct_gw(lcr_id, gw_id, until) == 0) {
 rpc->fault(c, 400, "parameter value error (see syslog)");
    }
    return;
}

variable_types: struct rpc { void (*fault)(void *ctx, int code, char *fmt, ...); int (*send)(void *ctx); int (*add)(void *ctx, char *fmt, ...); int (*scan)(void *ctx, char *fmt, ...); int (*printf)(void *ctx, char *fmt, ...); int (*struct_add)(void *ctx, char *fmt, ...); int (*struct_scan)(void *ctx, char *fmt, ...); int (*struct_printf)(void *ctx, char *name, char *fmt, ...); enum rpc_capabilities { RPC_DELAYED_REPLY=expr } (*capabilities)(void *ctx); struct rpc_delayed_ctx { struct rpc rpc; void *reply_ctx; } *(*delayed_ctx_new)(void *ctx); void (*delayed_ctx_close)(struct rpc_delayed_ctx *dctx); } *

variable_types:
c
void *

variable_types:
until
unsigned int

user_defined_types: struct rpc { void (*fault)(void *ctx, int code, char *fmt, ...); int (*send)(void *ctx); int (*add)(void *ctx, char *fmt, ...); int (*scan)(void *ctx, char *fmt, ...); int (*printf)(void *ctx, char *fmt, ...); int (*struct_add)(void *ctx, char *fmt, ...); int (*struct_scan)(void *ctx, char *fmt, ...); int (*struct_printf)(void *ctx, char *name, char *fmt, ...); enum rpc_capabilities (*capabilities)(void *ctx); struct rpc_delayed_ctx *(*delayed_ctx_new)(void *ctx); void (*delayed_ctx_close)(struct rpc_delayed_ctx *dctx); }


canonical_decompiled_code:
__int64 __fastcall func2(volatile __int32 *a1)
{
__int64 result; // rax
__int64 v2; // [rsp-10h] [rbp-18h]

result = func0(a1, 0);
if ( (_DWORD)result == 2 )
{
syscall(202LL, a1, 1LL, 1LL, 0LL, 0LL, 0LL);
result = v2;
}
return result;
}

variable_types:
lock
struct atomic_t { int val; } *

variable_types: v int


canonical_decompiled_code:
__int64 __fastcall func4(volatile signed __int32 *a1)
{
__int64 result; // rax
int v2; // ecx

result = func3(a1);
if ( (_DWORD)result )
{
if ( (_DWORD)result == 2 )
{
do
{
LABEL_24:
syscall(202LL, a1, 0LL, 2LL, 0LL, 0LL, 0LL);
result = func0(a1, 2);
}
while ( (_DWORD)result );
}
else
{
while ( 1 )
{
result = func3(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func3(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func3(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func3(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func3(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func3(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func3(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
result = func3(a1);
if ( !(_DWORD)result )
break;
if ( (_DWORD)result == 2 )
goto LABEL_24;
if ( v2 == 7 )
{
for ( result = func0(a1, 2); (_DWORD)result; result = func0(a1, 2) )
syscall(202LL, a1, 0LL, 2LL, 0LL, 0LL, 0LL);
return result;
}
}
}
}
return result;
}

variable_types: i int


reload

decompiled_code:
__int64 __fastcall reload(void (__fastcall **a1)(__int64, __int64, const char *), __int64 a2)
{
futex_get(reload_lock);
if ( (unsigned int)reload_tables() != 1 )
(*a1)(a2, 500LL, "LCR Module Reload Failed");
return futex_release(reload_lock);
}

canonical_decompiled_code:
__int64 __fastcall func5(void (__fastcall **a1)(__int64, __int64, const char *), __int64 a2)
{
func4(reload_lock);
if ( (unsigned int)reload_tables() != 1 )
(*a1)(a2, 500LL, "LCR Module Reload Failed");
return func2(reload_lock);
}

original_code:
static void reload(rpc_t* rpc, void* c)
{
    futex_get(reload_lock);
    if (reload_tables() != 1)
 rpc->fault(c, 500, "LCR Module Reload Failed");
    futex_release(reload_lock);
}

canonical_original_code:
static void reload(struct rpc *rpc, void *c)
{
    futex_get(reload_lock);
    if (reload_tables() != 1)
 rpc->fault(c, 500, "LCR Module Reload Failed");
    futex_release(reload_lock);
}

user_defined_types: enum rpc_capabilities { RPC_DELAYED_REPLY=expr }

user_defined_types: struct rpc_delayed_ctx { struct rpc rpc; void *reply_ctx; }


decompiled_code:
__int64 __fastcall db_gen_init(_QWORD *a1)
{
__int64 result; // rax

*a1 = 0LL;
result = 0LL;
a1[16] = 0LL;
memset(
(void *)((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 136) >> 3));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1)
{
__int64 result; // rax

*a1 = 0LL;
result = 0LL;
a1[16] = 0LL;
memset(
(void *)((unsigned __int64)(a1 + 1) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 136) >> 3));
return result;
}

original_code:
int db_gen_init(db_gen_t* gen)
{
 memset(gen, '\0', sizeof(db_gen_t));
 return 0;
}

canonical_original_code:
int db_gen_init(struct db_gen *gen)
{
 memset(gen, '\0', sizeof(db_gen_t));
 return 0;
}

variable_types: struct db_gen { struct { struct db_gen *stqe_next; } next; struct db_drv { void (*free)(struct db_gen *db_struct, struct db_drv *payload); } *data[16]; } *

user_defined_types: struct db_gen { struct { struct db_gen *stqe_next; } next; struct db_drv *data[16]; }


decompiled_code:
__int64 __fastcall tcp_info(__int64 a1, int a2)
{
_DWORD v3[14]; // [rsp+0h] [rbp-38h] BYREF

if ( tcp_disable )
return 0LL;
tcp_get_info(v3);
if ( a2 == 1 )
return v3[3];
if ( a2 != 2 )
return 0LL;
return v3[5];
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2)
{
_DWORD v3[14]; // [rsp+0h] [rbp-38h] BYREF

if ( tcp_disable )
return 0LL;
tcp_get_info(v3);
if ( a2 == 1 )
return v3[3];
if ( a2 != 2 )
return 0LL;
return v3[5];
}

original_code:
static counter_val_t tcp_info(counter_handle_t h, void* what)
{
 enum tcp_info_req w;
 struct tcp_gen_info ti;
 if (tcp_disable)
  return 0;
 w = (int)(long)what;
 tcp_get_info(&ti);
 switch(w) {
  case TCP_INFO_CONN_NO:
   return ti.tcp_connections_no;
  case TCP_INFO_WR_QUEUE_SZ:
   return ti.tcp_write_queued;
  case TCP_INFO_NONE:
   break;
 };
 return 0;
}

canonical_original_code:
static long tcp_info(struct counter_handle_s h, void *what)
{
 enum tcp_info_req w;
 struct tcp_gen_info ti;
 if (tcp_disable)
  return 0;
 w = (int)(long)what;
 tcp_get_info(&ti);
 switch(w) {
  case TCP_INFO_CONN_NO:
   return ti.tcp_connections_no;
  case TCP_INFO_WR_QUEUE_SZ:
   return ti.tcp_write_queued;
  case TCP_INFO_NONE:
   break;
 };
 return 0;
}

variable_types: struct counter_handle_s { unsigned short id; }

variable_types:
what
void *

variable_types: enum tcp_info_req { TCP_INFO_NONE=0, TCP_INFO_CONN_NO=1, TCP_INFO_WR_QUEUE_SZ=2 }

variable_types: struct tcp_gen_info { int tcp_readers; int tcp_max_connections; int tls_max_connections; int tcp_connections_no; int tls_connections_no; int tcp_write_queued; }

return_type: long


decompiled_code:
__int64 tcp_stats_init()
{
return (unsigned int)((int)counter_register_array(&unk_2F2, &tcp_cnt_defs) >> 31);
}

canonical_decompiled_code:
__int64 func1()
{
return (unsigned int)((int)counter_register_array(&unk_2F2, &tcp_cnt_defs) >> 31);
}

original_code:
int tcp_stats_init()
{
 if (counter_register_array("tcp", tcp_cnt_defs) < 0)
  goto error;
 return 0;
error:
 return -1;
}


decompiled_code:
void tcp_stats_destroy()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void tcp_stats_destroy()
{
}

canonical_original_code:
void tcp_stats_destroy()
{
}


original_code:
int netstring_read_fd(int fd, char **netstring) {
  int i, bytes;
 size_t len = 0;
  *netstring = ((void *)0);
 char buffer[10]={0};
 bytes = recv(fd,buffer,10,MSG_PEEK);
 if (bytes<3) return -3;
  if (buffer[0] == '0' && ((*__ctype_b_loc ())[(int) ((buffer[1]))] & (unsigned short int) _ISdigit))
    return -5;
  if (!((*__ctype_b_loc ())[(int) ((buffer[0]))] & (unsigned short int) _ISdigit)) return -6;
  for (i = 0; i < bytes && ((*__ctype_b_loc ())[(int) ((buffer[i]))] & (unsigned short int) _ISdigit); i++) {
    if (i >= 9) return -1;
    len = len*10 + (buffer[i] - '0');
  }
  if (buffer[i++] != ':') return -2;
 size_t read_len = i+len+1;
 char *buffer2 = qm_malloc(mem_block, (read_len));
 if (!buffer2) {
  do { if (get_debug_level("jsonrpc-c", (sizeof("jsonrpc-c")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Out of memory!", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("jsonrpc-c" " [" "netstring.c" ":" "71" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Out of memory!", (log_level_info[((-1)) - (-5)].name), ("jsonrpc-c" " [" "netstring.c" ":" "71" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Out of memory!", process_no, my_pid(), ("jsonrpc-c" " [" "netstring.c" ":" "71" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Out of memory!", ("jsonrpc-c" " [" "netstring.c" ":" "71" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Out of memory!", ("jsonrpc-c" " [" "netstring.c" ":" "71" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 bytes = recv(fd,buffer2,read_len,0);
  if (read_len > bytes) return -3;
  if (buffer2[read_len-1] != ',') return -4;
 buffer2[read_len-1] = '\0';
 int x;
 for(x=0;x<=read_len-i-1;x++) {
  buffer2[x]=buffer2[x+i];
 }
 *netstring = buffer2;
  return 0;
}

canonical_original_code:
int netstring_read_fd(int fd, char **netstring) {
  int i; int bytes;
 unsigned long len = 0;
  *netstring = ((void *)0);
 char buffer[10] = {0};
 bytes = recv(fd,buffer,10,MSG_PEEK);
 if (bytes<3) return -3;
  if (buffer[0] == '0' && ((*__ctype_b_loc ())[(int) ((buffer[1]))] & (unsigned short) _ISdigit))
    return -5;
  if (!((*__ctype_b_loc ())[(int) ((buffer[0]))] & (unsigned short) _ISdigit)) return -6;
  for (i = 0; i < bytes && ((*__ctype_b_loc ())[(int) ((buffer[i]))] & (unsigned short) _ISdigit); i++) {
    if (i >= 9) return -1;
    len = len*10 + (buffer[i] - '0');
  }
  if (buffer[i++] != ':') return -2;
 unsigned long read_len = i+len+1;
 char *buffer2 = qm_malloc(mem_block, (read_len));
 if (!buffer2) {
  do { if (get_debug_level("jsonrpc-c", (sizeof("jsonrpc-c")-1)) >= ((-1)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((-1)) >= -5) && (((-1)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Out of memory!", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("jsonrpc-c" " [" "netstring.c" ":" "71" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((-1)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Out of memory!", (log_level_info[((-1)) - (-5)].name), ("jsonrpc-c" " [" "netstring.c" ":" "71" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Out of memory!", process_no, my_pid(), ("jsonrpc-c" " [" "netstring.c" ":" "71" "]: ") , __func__); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((-1))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Out of memory!", ("jsonrpc-c" " [" "netstring.c" ":" "71" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Out of memory!", ("jsonrpc-c" " [" "netstring.c" ":" "71" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 bytes = recv(fd,buffer2,read_len,0);
  if (read_len > bytes) return -3;
  if (buffer2[read_len-1] != ',') return -4;
 buffer2[read_len-1] = '\0';
 int x;
 for(x=0;x<=read_len-i-1;x++) {
  buffer2[x]=buffer2[x+i];
 }
 *netstring = buffer2;
  return 0;
}

variable_types: fd int

variable_types:
netstring
char **

variable_types: bytes int

variable_types:
len
unsigned long

variable_types:
buffer
char [10]

variable_types: x int