decompiled_code:
__int64 __fastcall parse_credentials(__int64 a1)
{
__int64 result; // rax
int v2; // er8
const char *v3; // rbx
unsigned int v4; // eax
struct _IO_FILE *v5; // rdi
__int64 v6; // [rsp-1Ch] [rbp-28h]
unsigned int v7; // [rsp+0h] [rbp-Ch]

result = 0LL;
if ( !*(_QWORD *)(a1 + 48) )
{
if ( (int)new_credentials(a1) < 0 )
{
v2 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v2 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v3 = (const char *)*((_QWORD *)&log_level_info + 8);
v4 = my_pid();
v5 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_credentials(): Can't create new credentials\n",
process_no,
v4,
v3,
"<core> [parser/digest/digest.c:76]: ",
"parse_credentials");
if ( log_color )
dprint_color_reset(v5, "%2d(%d) %s: %s%s(): parse_credentials(): Can't create new credentials\n", v6);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_credentials(): Can't create new credentials\n",
*((const char **)&log_level_info + 8),
"<core> [parser/digest/digest.c:76]: ",
"parse_credentials");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
else
{
result = parse_digest_cred(a1 + 24, *(_QWORD *)(a1 + 48) + 8LL);
if ( (_DWORD)result )
{
v7 = result;
free_credentials((_QWORD *)(a1 + 48));
result = v7;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 result; // rax
int v2; // er8
const char *v3; // rbx
unsigned int v4; // eax
struct _IO_FILE *v5; // rdi
__int64 v6; // [rsp-1Ch] [rbp-28h]
unsigned int v7; // [rsp+0h] [rbp-Ch]

result = 0LL;
if ( !*(_QWORD *)(a1 + 48) )
{
if ( (int)func0(a1) < 0 )
{
v2 = get_debug_level("core", 4LL);
result = 0xFFFFFFFFLL;
if ( v2 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v3 = (const char *)*((_QWORD *)&log_level_info + 8);
v4 = my_pid();
v5 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): parse_credentials(): Can't create new credentials\n",
process_no,
v4,
v3,
"<core> [parser/digest/digest.c:76]: ",
"parse_credentials");
if ( log_color )
dprint_color_reset(v5, "%2d(%d) %s: %s%s(): parse_credentials(): Can't create new credentials\n", v6);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): parse_credentials(): Can't create new credentials\n",
*((const char **)&log_level_info + 8),
"<core> [parser/digest/digest.c:76]: ",
"parse_credentials");
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
else
{
result = parse_digest_cred(a1 + 24, *(_QWORD *)(a1 + 48) + 8LL);
if ( (_DWORD)result )
{
v7 = result;
func1((_QWORD *)(a1 + 48));
result = v7;
}
}
}
return result;
}

original_code:
int parse_credentials(struct hdr_field* _h)
{
 int res;
 void** ph_parsed;
 if (_h->parsed) {
  return 0;
 }
 if (new_credentials(_h) < 0) {
  do { if (get_debug_level("core", (sizeof("core")-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(): " "parse_credentials(): Can't create new credentials\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/digest/digest.c" ":" "76" "]: ") , __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(): " "parse_credentials(): Can't create new credentials\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/digest/digest.c" ":" "76" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_credentials(): Can't create new credentials\n", process_no, my_pid(), ("<core> [" "parser/digest/digest.c" ":" "76" "]: ") , __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(): " "parse_credentials(): Can't create new credentials\n", ("<core> [" "parser/digest/digest.c" ":" "76" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_credentials(): Can't create new credentials\n", ("<core> [" "parser/digest/digest.c" ":" "76" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 res = parse_digest_cred(&(_h->body), &(((auth_body_t*)(_h->parsed))->digest));
 if (res != 0) {
  ph_parsed=&_h->parsed;
  free_credentials((auth_body_t**)ph_parsed);
 }
 return res;
}

canonical_original_code:
int parse_credentials(struct hdr_field *_h)
{
 int res;
 void **ph_parsed;
 if (_h->parsed) {
  return 0;
 }
 if (new_credentials(_h) < 0) {
  do { if (get_debug_level("core", (sizeof("core")-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(): " "parse_credentials(): Can't create new credentials\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/digest/digest.c" ":" "76" "]: ") , __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(): " "parse_credentials(): Can't create new credentials\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/digest/digest.c" ":" "76" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "parse_credentials(): Can't create new credentials\n", process_no, my_pid(), ("<core> [" "parser/digest/digest.c" ":" "76" "]: ") , __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(): " "parse_credentials(): Can't create new credentials\n", ("<core> [" "parser/digest/digest.c" ":" "76" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "parse_credentials(): Can't create new credentials\n", ("<core> [" "parser/digest/digest.c" ":" "76" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 res = parse_digest_cred(&(_h->body), &(((struct auth_body *)(_h->parsed))->digest));
 if (res != 0) {
  ph_parsed=&_h->parsed;
  free_credentials((struct auth_body **)ph_parsed);
 }
 return res;
}

variable_types: struct hdr_field { enum _hdr_types_t { HDR_ERROR_T=-1, HDR_OTHER_T=0, HDR_VIA_T=1, HDR_VIA1_T=1, HDR_VIA2_T=2, HDR_TO_T=3, HDR_FROM_T=4, HDR_CSEQ_T=5, HDR_CALLID_T=6, HDR_CONTACT_T=7, HDR_MAXFORWARDS_T=8, HDR_ROUTE_T=9, HDR_RECORDROUTE_T=10, HDR_CONTENTTYPE_T=11, HDR_CONTENTLENGTH_T=12, HDR_AUTHORIZATION_T=13, HDR_EXPIRES_T=14, HDR_PROXYAUTH_T=15, HDR_SUPPORTED_T=16, HDR_REQUIRE_T=17, HDR_PROXYREQUIRE_T=18, HDR_UNSUPPORTED_T=19, HDR_ALLOW_T=20, HDR_EVENT_T=21, HDR_ACCEPT_T=22, HDR_ACCEPTLANGUAGE_T=23, HDR_ORGANIZATION_T=24, HDR_PRIORITY_T=25, HDR_SUBJECT_T=26, HDR_USERAGENT_T=27, HDR_SERVER_T=28, HDR_CONTENTDISPOSITION_T=29, HDR_DIVERSION_T=30, HDR_RPID_T=31, HDR_REFER_TO_T=32, HDR_SIPIFMATCH_T=33, HDR_SESSIONEXPIRES_T=34, HDR_MIN_SE_T=35, HDR_SUBSCRIPTION_STATE_T=36, HDR_ACCEPTCONTACT_T=37, HDR_ALLOWEVENTS_T=38, HDR_CONTENTENCODING_T=39, HDR_REFERREDBY_T=40, HDR_REJECTCONTACT_T=41, HDR_REQUESTDISPOSITION_T=42, HDR_WWW_AUTHENTICATE_T=43, HDR_PROXY_AUTHENTICATE_T=44, HDR_DATE_T=45, HDR_IDENTITY_T=46, HDR_IDENTITY_INFO_T=47, HDR_RETRY_AFTER_T=48, HDR_PPI_T=49, HDR_PAI_T=50, HDR_PATH_T=51, HDR_PRIVACY_T=52, HDR_REASON_T=53, HDR_EOH_T=54 } type; struct _str { char *s; int len; } name; struct _str body; int len; void *parsed; struct hdr_field *next; } *

user_defined_types: struct username { struct _str whole; struct _str user; struct _str domain; }

user_defined_types: enum alg { ALG_UNSPEC=0, ALG_MD5=1, ALG_MD5SESS=2, ALG_OTHER=4 }

user_defined_types: enum qop_type { QOP_UNSPEC=0, QOP_AUTH=1, QOP_AUTHINT=2, QOP_OTHER=4 }


repo: virtualolson/who

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

result = *(_QWORD *)(a1 + 16) == 0LL;
if ( !*(_QWORD *)(a1 + 48) )
result = (unsigned int)result | 2;
if ( !*(_QWORD *)(a1 + 64) )
result = (unsigned int)result | 4;
if ( !*(_QWORD *)(a1 + 80) )
result = (unsigned int)result | 8;
if ( !*(_QWORD *)(a1 + 96) )
result = (unsigned int)result | 0x10;
if ( (unsigned int)(*(_DWORD *)(a1 + 184) - 1) <= 1 )
{
if ( !*(_QWORD *)(a1 + 136) )
result = (unsigned int)result | 0x20;
if ( !*(_QWORD *)(a1 + 192) )
result = (unsigned int)result | 0x40;
}
return result;
}

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

result = *(_QWORD *)(a1 + 16) == 0LL;
if ( !*(_QWORD *)(a1 + 48) )
result = (unsigned int)result | 2;
if ( !*(_QWORD *)(a1 + 64) )
result = (unsigned int)result | 4;
if ( !*(_QWORD *)(a1 + 80) )
result = (unsigned int)result | 8;
if ( !*(_QWORD *)(a1 + 96) )
result = (unsigned int)result | 0x10;
if ( (unsigned int)(*(_DWORD *)(a1 + 184) - 1) <= 1 )
{
if ( !*(_QWORD *)(a1 + 136) )
result = (unsigned int)result | 0x20;
if ( !*(_QWORD *)(a1 + 192) )
result = (unsigned int)result | 0x40;
}
return result;
}

original_code:
dig_err_t check_dig_cred(dig_cred_t* _c)
{
 dig_err_t res = E_DIG_OK;
 if (_c->username.user.s == 0) res |= E_DIG_USERNAME;
 if (_c->realm.s == 0) res |= E_DIG_REALM;
 if (_c->nonce.s == 0) res |= E_DIG_NONCE;
 if (_c->uri.s == 0) res |= E_DIG_URI;
 if (_c->response.s == 0) res |= E_DIG_RESPONSE;
 if ((_c->qop.qop_parsed == QOP_AUTH) || (_c->qop.qop_parsed == QOP_AUTHINT)) {
  if (_c->cnonce.s == 0) res |= E_DIG_CNONCE;
  if (_c->nc.s == 0) res |= E_DIG_NC;
 }
 return res;
}

canonical_original_code:
enum dig_err check_dig_cred(struct dig_cred *_c)
{
 enum dig_err res = E_DIG_OK;
 if (_c->username.user.s == 0) res |= E_DIG_USERNAME;
 if (_c->realm.s == 0) res |= E_DIG_REALM;
 if (_c->nonce.s == 0) res |= E_DIG_NONCE;
 if (_c->uri.s == 0) res |= E_DIG_URI;
 if (_c->response.s == 0) res |= E_DIG_RESPONSE;
 if ((_c->qop.qop_parsed == QOP_AUTH) || (_c->qop.qop_parsed == QOP_AUTHINT)) {
  if (_c->cnonce.s == 0) res |= E_DIG_CNONCE;
  if (_c->nc.s == 0) res |= E_DIG_NC;
 }
 return res;
}

variable_types: struct dig_cred { struct username { struct _str { char *s; int len; } whole; struct _str user; struct _str domain; } username; struct _str realm; struct _str nonce; struct _str uri; struct _str response; struct algorithm { struct _str alg_str; enum alg { ALG_UNSPEC=0, ALG_MD5=1, ALG_MD5SESS=2, ALG_OTHER=4 } alg_parsed; } alg; struct _str cnonce; struct _str opaque; struct qp { struct _str qop_str; enum qop_type { QOP_UNSPEC=0, QOP_AUTH=1, QOP_AUTHINT=2, QOP_OTHER=4 } qop_parsed; } qop; struct _str nc; } *

variable_types: enum dig_err { E_DIG_OK=0, E_DIG_USERNAME=1, E_DIG_REALM=2, E_DIG_NONCE=4, E_DIG_URI=8, E_DIG_RESPONSE=16, E_DIG_CNONCE=32, E_DIG_NC=64, E_DIG_DOMAIN=128 }

user_defined_types: struct dig_cred { struct username username; struct _str realm; struct _str nonce; struct _str uri; struct _str response; struct algorithm alg; struct _str cnonce; struct _str opaque; struct qp qop; struct _str nc; }

user_defined_types: struct algorithm { struct _str alg_str; enum alg alg_parsed; }

user_defined_types: struct qp { struct _str qop_str; enum qop_type qop_parsed; }


original_code:
void print_cred(dig_cred_t* _c)
{
 printf("===Digest credentials===\n");
 if (_c) {
  printf("Username\n");
  printf("+--whole  = \'%.*s\'\n", _c->username.whole.len, _c->username.whole.s);
  printf("+--user   = \'%.*s\'\n", _c->username.user.len, _c->username.user.s);
  printf("\\--domain = \'%.*s\'\n", _c->username.domain.len, _c->username.domain.s);
  printf("Realm     = \'%.*s\'\n", _c->realm.len, _c->realm.s);
  printf("Nonce     = \'%.*s\'\n", _c->nonce.len, _c->nonce.s);
  printf("URI       = \'%.*s\'\n", _c->uri.len, _c->uri.s);
  printf("Response  = \'%.*s\'\n", _c->response.len, _c->response.s);
  printf("Algorithm = \'%.*s\'\n", _c->alg.alg_str.len, _c->alg.alg_str.s);
  printf("\\--parsed = ");
  switch(_c->alg.alg_parsed) {
  case ALG_UNSPEC: printf("ALG_UNSPEC\n"); break;
  case ALG_MD5: printf("ALG_MD5\n"); break;
  case ALG_MD5SESS: printf("ALG_MD5SESS\n"); break;
  case ALG_OTHER: printf("ALG_OTHER\n"); break;
  }
  printf("Cnonce    = \'%.*s\'\n", _c->cnonce.len, _c->cnonce.s);
  printf("Opaque    = \'%.*s\'\n", _c->opaque.len, _c->opaque.s);
  printf("QOP       = \'%.*s\'\n", _c->qop.qop_str.len, _c->qop.qop_str.s);
  printf("\\--parsed = ");
  switch(_c->qop.qop_parsed) {
  case QOP_UNSPEC: printf("QOP_UNSPEC\n"); break;
  case QOP_AUTH: printf("QOP_AUTH\n"); break;
  case QOP_AUTHINT: printf("QOP_AUTHINT\n"); break;
  case QOP_OTHER: printf("QOP_OTHER\n"); break;
  }
  printf("NC        = \'%.*s\'\n", _c->nc.len, _c->nc.s);
 }
 printf("===/Digest credentials===\n");
}

canonical_original_code:
void print_cred(struct dig_cred *_c)
{
 printf("===Digest credentials===\n");
 if (_c) {
  printf("Username\n");
  printf("+--whole  = \'%.*s\'\n", _c->username.whole.len, _c->username.whole.s);
  printf("+--user   = \'%.*s\'\n", _c->username.user.len, _c->username.user.s);
  printf("\\--domain = \'%.*s\'\n", _c->username.domain.len, _c->username.domain.s);
  printf("Realm     = \'%.*s\'\n", _c->realm.len, _c->realm.s);
  printf("Nonce     = \'%.*s\'\n", _c->nonce.len, _c->nonce.s);
  printf("URI       = \'%.*s\'\n", _c->uri.len, _c->uri.s);
  printf("Response  = \'%.*s\'\n", _c->response.len, _c->response.s);
  printf("Algorithm = \'%.*s\'\n", _c->alg.alg_str.len, _c->alg.alg_str.s);
  printf("\\--parsed = ");
  switch(_c->alg.alg_parsed) {
  case ALG_UNSPEC: printf("ALG_UNSPEC\n"); break;
  case ALG_MD5: printf("ALG_MD5\n"); break;
  case ALG_MD5SESS: printf("ALG_MD5SESS\n"); break;
  case ALG_OTHER: printf("ALG_OTHER\n"); break;
  }
  printf("Cnonce    = \'%.*s\'\n", _c->cnonce.len, _c->cnonce.s);
  printf("Opaque    = \'%.*s\'\n", _c->opaque.len, _c->opaque.s);
  printf("QOP       = \'%.*s\'\n", _c->qop.qop_str.len, _c->qop.qop_str.s);
  printf("\\--parsed = ");
  switch(_c->qop.qop_parsed) {
  case QOP_UNSPEC: printf("QOP_UNSPEC\n"); break;
  case QOP_AUTH: printf("QOP_AUTH\n"); break;
  case QOP_AUTHINT: printf("QOP_AUTHINT\n"); break;
  case QOP_OTHER: printf("QOP_OTHER\n"); break;
  }
  printf("NC        = \'%.*s\'\n", _c->nc.len, _c->nc.s);
 }
 printf("===/Digest credentials===\n");
}

return_type: void


decompiled_code:
__int64 __fastcall get_authorized_cred(_QWORD *a1, _QWORD *a2)
{
if ( a1 )
{
a1 = (_QWORD *)a1[6];
if ( a1 )
a1 = (_QWORD *)*a1;
}
*a2 = a1;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1, _QWORD *a2)
{
if ( a1 )
{
a1 = (_QWORD *)a1[6];
if ( a1 )
a1 = (_QWORD *)*a1;
}
*a2 = a1;
return 0LL;
}

original_code:
int get_authorized_cred(struct hdr_field* _f, struct hdr_field** _h)
{
 if (_f && _f->parsed) {
  *_h = ((auth_body_t*)(_f->parsed))->authorized;
 } else {
  *_h = 0;
 }
 return 0;
}

canonical_original_code:
int get_authorized_cred(struct hdr_field *_f, struct hdr_field **_h)
{
 if (_f && _f->parsed) {
  *_h = ((struct auth_body *)(_f->parsed))->authorized;
 } else {
  *_h = 0;
 }
 return 0;
}

return_type: int

user_defined_types: struct hdr_field { enum _hdr_types_t type; struct _str name; struct _str body; int len; void *parsed; struct hdr_field *next; }

user_defined_types: struct auth_body { struct hdr_field *authorized; struct dig_cred digest; unsigned char stale; }

user_defined_types: enum _hdr_types_t { HDR_ERROR_T=-1, HDR_OTHER_T=0, HDR_VIA_T=1, HDR_VIA1_T=1, HDR_VIA2_T=2, HDR_TO_T=3, HDR_FROM_T=4, HDR_CSEQ_T=5, HDR_CALLID_T=6, HDR_CONTACT_T=7, HDR_MAXFORWARDS_T=8, HDR_ROUTE_T=9, HDR_RECORDROUTE_T=10, HDR_CONTENTTYPE_T=11, HDR_CONTENTLENGTH_T=12, HDR_AUTHORIZATION_T=13, HDR_EXPIRES_T=14, HDR_PROXYAUTH_T=15, HDR_SUPPORTED_T=16, HDR_REQUIRE_T=17, HDR_PROXYREQUIRE_T=18, HDR_UNSUPPORTED_T=19, HDR_ALLOW_T=20, HDR_EVENT_T=21, HDR_ACCEPT_T=22, HDR_ACCEPTLANGUAGE_T=23, HDR_ORGANIZATION_T=24, HDR_PRIORITY_T=25, HDR_SUBJECT_T=26, HDR_USERAGENT_T=27, HDR_SERVER_T=28, HDR_CONTENTDISPOSITION_T=29, HDR_DIVERSION_T=30, HDR_RPID_T=31, HDR_REFER_TO_T=32, HDR_SIPIFMATCH_T=33, HDR_SESSIONEXPIRES_T=34, HDR_MIN_SE_T=35, HDR_SUBSCRIPTION_STATE_T=36, HDR_ACCEPTCONTACT_T=37, HDR_ALLOWEVENTS_T=38, HDR_CONTENTENCODING_T=39, HDR_REFERREDBY_T=40, HDR_REJECTCONTACT_T=41, HDR_REQUESTDISPOSITION_T=42, HDR_WWW_AUTHENTICATE_T=43, HDR_PROXY_AUTHENTICATE_T=44, HDR_DATE_T=45, HDR_IDENTITY_T=46, HDR_IDENTITY_INFO_T=47, HDR_RETRY_AFTER_T=48, HDR_PPI_T=49, HDR_PAI_T=50, HDR_PATH_T=51, HDR_PRIVACY_T=52, HDR_REASON_T=53, HDR_EOH_T=54 }


decompiled_code:
__int64 *msrp_get_env()
{
return &msrp_env;
}

canonical_decompiled_code:
__int64 *func1()
{
return &msrp_env;
}

original_code:
msrp_env_t *msrp_get_env(void)
{
 return &_msrp_env;
}

canonical_original_code:
struct msrp_env *msrp_get_env()
{
 return &_msrp_env;
}

return_type: struct msrp_env { struct msrp_frame { struct _str { char *s; int len; } buf; struct msrp_fline { struct _str buf; int msgtypeid; struct _str protocol; struct _str transaction; struct _str rtype; int rtypeid; struct _str rtext; } fline; struct _str hbody; struct _str mbody; struct _str endline; struct msrp_hdr { struct _str buf; int htype; struct _str name; struct _str body; struct msrp_data { void (*free_fn)(void *); int flags; void *data; } parsed; struct msrp_hdr *next; } *headers; struct tcp_event_info { int type; char *buf; unsigned int len; struct receive_info { struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; } src_ip; struct ip_addr dst_ip; unsigned short src_port; unsigned short dst_port; int proto_reserved1; int proto_reserved2; union sockaddr_union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } s; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } src_su; struct socket_info { int socket; struct _str name; struct ip_addr address; struct _str address_str; struct _str port_no_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; } *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; } useinfo; } *bind_address; char proto; } *rcv; struct tcp_connection { int s; int fd; struct atomic_t { int val; } write_lock; int id; int reader_pid; struct receive_info rcv; struct tcp_req { struct tcp_req *next; char *buf; char *start; char *pos; char *parsed; char *body; unsigned int b_size; int content_len; int chunk_size; unsigned short flags; int bytes_to_go; enum tcp_req_errors { TCP_REQ_INIT=0, TCP_REQ_OK=1, TCP_READ_ERROR=2, TCP_REQ_OVERRUN=3, TCP_REQ_BAD_LEN=4 } error; enum tcp_req_states { H_SKIP_EMPTY=0, H_SKIP_EMPTY_CR_FOUND=1, H_SKIP_EMPTY_CRLF_FOUND=2, H_SKIP_EMPTY_CRLFCR_FOUND=3, H_SKIP=4, H_LF=5, H_LFCR=6, H_BODY=7, H_STARTWS=8, H_CONT_LEN1=9, H_CONT_LEN2=10, H_CONT_LEN3=11, H_CONT_LEN4=12, H_CONT_LEN5=13, H_CONT_LEN6=14, H_CONT_LEN7=15, H_CONT_LEN8=16, H_CONT_LEN9=17, H_CONT_LEN10=18, H_CONT_LEN11=19, H_CONT_LEN12=20, H_CONT_LEN13=21, H_L_COLON=22, H_CONT_LEN_BODY=23, H_CONT_LEN_BODY_PARSE=24, H_STUN_MSG=25, H_STUN_READ_BODY=26, H_STUN_FP=27, H_STUN_END=28, H_PING_CRLF=29, H_HTTP11_CHUNK_START=30, H_HTTP11_CHUNK_SIZE=31, H_HTTP11_CHUNK_BODY=32, H_HTTP11_CHUNK_END=33, H_HTTP11_CHUNK_FINISH=34, H_MSRP_BODY=35, H_MSRP_BODY_LF=36, H_MSRP_BODY_END=37, H_MSRP_FINISH=38 } state; } req; struct atomic_t refcnt; enum sip_protos { PROTO_NONE=0, PROTO_UDP=1, PROTO_TCP=2, PROTO_TLS=3, PROTO_SCTP=4, PROTO_WS=5, PROTO_WSS=6, PROTO_OTHER=7 } type; unsigned short flags; struct snd_flags { unsigned char f; unsigned char blst_imask; } send_flags; enum tcp_conn_states { S_CONN_ERROR=-2, S_CONN_BAD=-1, S_CONN_OK=0, S_CONN_INIT=1, S_CONN_EOF=2, S_CONN_ACCEPT=3, S_CONN_CONNECT=4 } state; void *extra_data; struct timer_ln { struct timer_ln *next; struct timer_ln *prev; unsigned int expire; unsigned int initial_timeout; void *data; unsigned int (*f)(unsigned int t, struct timer_ln *tl, void *data); unsigned short flags; unsigned short slow_idx; } timer; unsigned int timeout; unsigned int id_hash; struct tcp_connection *id_next; struct tcp_connection *id_prev; struct tcp_connection *c_next; struct tcp_connection *c_prev; struct tcp_conn_alias { struct tcp_connection *parent; struct tcp_conn_alias *next; struct tcp_conn_alias *prev; unsigned short port; unsigned short hash; } con_aliases[-1]; int aliases; struct tcp_wbuffer_queue { struct tcp_wbuffer { struct tcp_wbuffer *next; unsigned int b_size; char buf[1]; } *first; struct tcp_wbuffer *last; unsigned int wr_timeout; unsigned int queued; unsigned int offset; unsigned int last_used; } wbuf_q; } *con; } *tcpinfo; } *msrp; struct dest_info { struct socket_info *send_sock; union sockaddr_union to; int id; char proto; struct snd_flags send_flags; } srcinfo; struct dest_info dstinfo; int envflags; int sndflags; int rplflags; } *

user_defined_types: struct msrp_env { struct msrp_frame *msrp; struct dest_info srcinfo; struct dest_info dstinfo; int envflags; int sndflags; int rplflags; }

user_defined_types: struct msrp_frame { struct _str buf; struct msrp_fline fline; struct _str hbody; struct _str mbody; struct _str endline; struct msrp_hdr *headers; struct tcp_event_info *tcpinfo; }

user_defined_types: struct msrp_hdr { struct _str buf; int htype; struct _str name; struct _str body; struct msrp_data parsed; struct msrp_hdr *next; }

user_defined_types: struct tcp_event_info { int type; char *buf; unsigned int len; struct receive_info *rcv; struct tcp_connection *con; }

user_defined_types: struct receive_info { struct ip_addr src_ip; struct ip_addr dst_ip; unsigned short src_port; unsigned short dst_port; int proto_reserved1; int proto_reserved2; union sockaddr_union src_su; struct socket_info *bind_address; char proto; }

user_defined_types: struct tcp_connection { int s; int fd; struct atomic_t write_lock; int id; int reader_pid; struct receive_info rcv; struct tcp_req req; struct atomic_t refcnt; enum sip_protos type; unsigned short flags; struct snd_flags send_flags; enum tcp_conn_states state; void *extra_data; struct timer_ln timer; unsigned int timeout; unsigned int id_hash; struct tcp_connection *id_next; struct tcp_connection *id_prev; struct tcp_connection *c_next; struct tcp_connection *c_prev; struct tcp_conn_alias con_aliases[-1]; int aliases; struct tcp_wbuffer_queue wbuf_q; }

user_defined_types: union sockaddr_union { struct sockaddr s; struct sockaddr_in sin; struct sockaddr_in6 sin6; }

user_defined_types: struct tcp_req { struct tcp_req *next; char *buf; char *start; char *pos; char *parsed; char *body; unsigned int b_size; int content_len; int chunk_size; unsigned short flags; int bytes_to_go; enum tcp_req_errors error; enum tcp_req_states state; }

user_defined_types: struct tcp_wbuffer_queue { struct tcp_wbuffer *first; struct tcp_wbuffer *last; unsigned int wr_timeout; unsigned int queued; unsigned int offset; unsigned int last_used; }

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr sin6_addr; unsigned int sin6_scope_id; }

user_defined_types: struct socket_info { int socket; struct _str name; struct ip_addr address; struct _str address_str; struct _str port_no_str; enum si_flags flags; union sockaddr_union su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info useinfo; }

user_defined_types: struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; }


decompiled_code:
__int64 msrp_reset_env()
{
__int64 result; // rax

result = 0LL;
memset(&msrp_env, 0, 0x78uLL);
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax

result = 0LL;
memset(&msrp_env, 0, 0x78uLL);
return result;
}

original_code:
void msrp_reset_env(void)
{
 memset(&_msrp_env, 0, sizeof(struct msrp_env));
}

canonical_original_code:
void msrp_reset_env()
{
 memset(&_msrp_env, 0, sizeof(struct msrp_env));
}

user_defined_types: struct dest_info { struct socket_info *send_sock; union sockaddr_union to; int id; char proto; struct snd_flags send_flags; }

user_defined_types: struct msrp_fline { struct _str buf; int msgtypeid; struct _str protocol; struct _str transaction; struct _str rtype; int rtypeid; struct _str rtext; }

user_defined_types: struct msrp_data { void (*free_fn)(void *); int flags; void *data; }

user_defined_types: struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; }

user_defined_types: enum sip_protos { PROTO_NONE=0, PROTO_UDP=1, PROTO_TCP=2, PROTO_TLS=3, PROTO_SCTP=4, PROTO_WS=5, PROTO_WSS=6, PROTO_OTHER=7 }

user_defined_types: struct snd_flags { unsigned char f; unsigned char blst_imask; }

user_defined_types: enum tcp_conn_states { S_CONN_ERROR=-2, S_CONN_BAD=-1, S_CONN_OK=0, S_CONN_INIT=1, S_CONN_EOF=2, S_CONN_ACCEPT=3, S_CONN_CONNECT=4 }

user_defined_types: struct timer_ln { struct timer_ln *next; struct timer_ln *prev; unsigned int expire; unsigned int initial_timeout; void *data; unsigned int (*f)(unsigned int t, struct timer_ln *tl, void *data); unsigned short flags; unsigned short slow_idx; }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }

user_defined_types: enum tcp_req_errors { TCP_REQ_INIT=0, TCP_REQ_OK=1, TCP_READ_ERROR=2, TCP_REQ_OVERRUN=3, TCP_REQ_BAD_LEN=4 }

user_defined_types: enum tcp_req_states { H_SKIP_EMPTY=0, H_SKIP_EMPTY_CR_FOUND=1, H_SKIP_EMPTY_CRLF_FOUND=2, H_SKIP_EMPTY_CRLFCR_FOUND=3, H_SKIP=4, H_LF=5, H_LFCR=6, H_BODY=7, H_STARTWS=8, H_CONT_LEN1=9, H_CONT_LEN2=10, H_CONT_LEN3=11, H_CONT_LEN4=12, H_CONT_LEN5=13, H_CONT_LEN6=14, H_CONT_LEN7=15, H_CONT_LEN8=16, H_CONT_LEN9=17, H_CONT_LEN10=18, H_CONT_LEN11=19, H_CONT_LEN12=20, H_CONT_LEN13=21, H_L_COLON=22, H_CONT_LEN_BODY=23, H_CONT_LEN_BODY_PARSE=24, H_STUN_MSG=25, H_STUN_READ_BODY=26, H_STUN_FP=27, H_STUN_END=28, H_PING_CRLF=29, H_HTTP11_CHUNK_START=30, H_HTTP11_CHUNK_SIZE=31, H_HTTP11_CHUNK_BODY=32, H_HTTP11_CHUNK_END=33, H_HTTP11_CHUNK_FINISH=34, H_MSRP_BODY=35, H_MSRP_BODY_LF=36, H_MSRP_BODY_END=37, H_MSRP_FINISH=38 }

user_defined_types: struct tcp_conn_alias { struct tcp_connection *parent; struct tcp_conn_alias *next; struct tcp_conn_alias *prev; unsigned short port; unsigned short hash; }

user_defined_types: struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; }

user_defined_types: enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 }

user_defined_types: struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; }

user_defined_types: struct tcp_wbuffer { struct tcp_wbuffer *next; unsigned int b_size; char buf[1]; }


decompiled_code:
__int64 msrp_get_current_frame()
{
return msrp_env;
}

canonical_decompiled_code:
__int64 func3()
{
return msrp_env;
}

original_code:
msrp_frame_t *msrp_get_current_frame(void)
{
 return _msrp_env.msrp;
}

canonical_original_code:
struct msrp_frame *msrp_get_current_frame()
{
 return _msrp_env.msrp;
}

return_type: struct msrp_frame { struct _str { char *s; int len; } buf; struct msrp_fline { struct _str buf; int msgtypeid; struct _str protocol; struct _str transaction; struct _str rtype; int rtypeid; struct _str rtext; } fline; struct _str hbody; struct _str mbody; struct _str endline; struct msrp_hdr { struct _str buf; int htype; struct _str name; struct _str body; struct msrp_data { void (*free_fn)(void *); int flags; void *data; } parsed; struct msrp_hdr *next; } *headers; struct tcp_event_info { int type; char *buf; unsigned int len; struct receive_info { struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; } src_ip; struct ip_addr dst_ip; unsigned short src_port; unsigned short dst_port; int proto_reserved1; int proto_reserved2; union sockaddr_union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } s; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } src_su; struct socket_info { int socket; struct _str name; struct ip_addr address; struct _str address_str; struct _str port_no_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; } *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; } useinfo; } *bind_address; char proto; } *rcv; struct tcp_connection { int s; int fd; struct atomic_t { int val; } write_lock; int id; int reader_pid; struct receive_info rcv; struct tcp_req { struct tcp_req *next; char *buf; char *start; char *pos; char *parsed; char *body; unsigned int b_size; int content_len; int chunk_size; unsigned short flags; int bytes_to_go; enum tcp_req_errors { TCP_REQ_INIT=0, TCP_REQ_OK=1, TCP_READ_ERROR=2, TCP_REQ_OVERRUN=3, TCP_REQ_BAD_LEN=4 } error; enum tcp_req_states { H_SKIP_EMPTY=0, H_SKIP_EMPTY_CR_FOUND=1, H_SKIP_EMPTY_CRLF_FOUND=2, H_SKIP_EMPTY_CRLFCR_FOUND=3, H_SKIP=4, H_LF=5, H_LFCR=6, H_BODY=7, H_STARTWS=8, H_CONT_LEN1=9, H_CONT_LEN2=10, H_CONT_LEN3=11, H_CONT_LEN4=12, H_CONT_LEN5=13, H_CONT_LEN6=14, H_CONT_LEN7=15, H_CONT_LEN8=16, H_CONT_LEN9=17, H_CONT_LEN10=18, H_CONT_LEN11=19, H_CONT_LEN12=20, H_CONT_LEN13=21, H_L_COLON=22, H_CONT_LEN_BODY=23, H_CONT_LEN_BODY_PARSE=24, H_STUN_MSG=25, H_STUN_READ_BODY=26, H_STUN_FP=27, H_STUN_END=28, H_PING_CRLF=29, H_HTTP11_CHUNK_START=30, H_HTTP11_CHUNK_SIZE=31, H_HTTP11_CHUNK_BODY=32, H_HTTP11_CHUNK_END=33, H_HTTP11_CHUNK_FINISH=34, H_MSRP_BODY=35, H_MSRP_BODY_LF=36, H_MSRP_BODY_END=37, H_MSRP_FINISH=38 } state; } req; struct atomic_t refcnt; enum sip_protos { PROTO_NONE=0, PROTO_UDP=1, PROTO_TCP=2, PROTO_TLS=3, PROTO_SCTP=4, PROTO_WS=5, PROTO_WSS=6, PROTO_OTHER=7 } type; unsigned short flags; struct snd_flags { unsigned char f; unsigned char blst_imask; } send_flags; enum tcp_conn_states { S_CONN_ERROR=-2, S_CONN_BAD=-1, S_CONN_OK=0, S_CONN_INIT=1, S_CONN_EOF=2, S_CONN_ACCEPT=3, S_CONN_CONNECT=4 } state; void *extra_data; struct timer_ln { struct timer_ln *next; struct timer_ln *prev; unsigned int expire; unsigned int initial_timeout; void *data; unsigned int (*f)(unsigned int t, struct timer_ln *tl, void *data); unsigned short flags; unsigned short slow_idx; } timer; unsigned int timeout; unsigned int id_hash; struct tcp_connection *id_next; struct tcp_connection *id_prev; struct tcp_connection *c_next; struct tcp_connection *c_prev; struct tcp_conn_alias { struct tcp_connection *parent; struct tcp_conn_alias *next; struct tcp_conn_alias *prev; unsigned short port; unsigned short hash; } con_aliases[-1]; int aliases; struct tcp_wbuffer_queue { struct tcp_wbuffer { struct tcp_wbuffer *next; unsigned int b_size; char buf[1]; } *first; struct tcp_wbuffer *last; unsigned int wr_timeout; unsigned int queued; unsigned int offset; unsigned int last_used; } wbuf_q; } *con; } *tcpinfo; } *

user_defined_types: struct msrp_frame { struct _str buf; struct msrp_fline fline; struct _str hbody; struct _str mbody; struct _str endline; struct msrp_hdr *headers; struct tcp_event_info *tcpinfo; }

user_defined_types: struct msrp_hdr { struct _str buf; int htype; struct _str name; struct _str body; struct msrp_data parsed; struct msrp_hdr *next; }

user_defined_types: struct tcp_event_info { int type; char *buf; unsigned int len; struct receive_info *rcv; struct tcp_connection *con; }

user_defined_types: struct receive_info { struct ip_addr src_ip; struct ip_addr dst_ip; unsigned short src_port; unsigned short dst_port; int proto_reserved1; int proto_reserved2; union sockaddr_union src_su; struct socket_info *bind_address; char proto; }

user_defined_types: struct tcp_connection { int s; int fd; struct atomic_t write_lock; int id; int reader_pid; struct receive_info rcv; struct tcp_req req; struct atomic_t refcnt; enum sip_protos type; unsigned short flags; struct snd_flags send_flags; enum tcp_conn_states state; void *extra_data; struct timer_ln timer; unsigned int timeout; unsigned int id_hash; struct tcp_connection *id_next; struct tcp_connection *id_prev; struct tcp_connection *c_next; struct tcp_connection *c_prev; struct tcp_conn_alias con_aliases[-1]; int aliases; struct tcp_wbuffer_queue wbuf_q; }

user_defined_types: union sockaddr_union { struct sockaddr s; struct sockaddr_in sin; struct sockaddr_in6 sin6; }

user_defined_types: struct tcp_req { struct tcp_req *next; char *buf; char *start; char *pos; char *parsed; char *body; unsigned int b_size; int content_len; int chunk_size; unsigned short flags; int bytes_to_go; enum tcp_req_errors error; enum tcp_req_states state; }

user_defined_types: struct tcp_wbuffer_queue { struct tcp_wbuffer *first; struct tcp_wbuffer *last; unsigned int wr_timeout; unsigned int queued; unsigned int offset; unsigned int last_used; }

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr sin6_addr; unsigned int sin6_scope_id; }

user_defined_types: struct socket_info { int socket; struct _str name; struct ip_addr address; struct _str address_str; struct _str port_no_str; enum si_flags flags; union sockaddr_union su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info useinfo; }

user_defined_types: struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; }


decompiled_code:
__int64 __fastcall msrp_set_current_frame(__int64 a1)
{
__int64 v1; // rax

v1 = *(_QWORD *)(a1 + 168);
msrp_env = a1;
init_dst_from_rcv_constprop_0(*(_QWORD *)(v1 + 24));
dword_3B48 |= 1u;
return 0LL;
}

original_code:
int msrp_set_current_frame(msrp_frame_t *mf)
{
 _msrp_env.msrp = mf;
 init_dst_from_rcv(&_msrp_env.srcinfo, mf->tcpinfo->rcv);
 _msrp_env.envflags |= (1<<0);
 return 0;
}

canonical_original_code:
int msrp_set_current_frame(struct msrp_frame *mf)
{
 _msrp_env.msrp = mf;
 init_dst_from_rcv(&_msrp_env.srcinfo, mf->tcpinfo->rcv);
 _msrp_env.envflags |= (1<<0);
 return 0;
}

variable_types: struct msrp_frame { struct _str { char *s; int len; } buf; struct msrp_fline { struct _str buf; int msgtypeid; struct _str protocol; struct _str transaction; struct _str rtype; int rtypeid; struct _str rtext; } fline; struct _str hbody; struct _str mbody; struct _str endline; struct msrp_hdr { struct _str buf; int htype; struct _str name; struct _str body; struct msrp_data { void (*free_fn)(void *); int flags; void *data; } parsed; struct msrp_hdr *next; } *headers; struct tcp_event_info { int type; char *buf; unsigned int len; struct receive_info { struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; } src_ip; struct ip_addr dst_ip; unsigned short src_port; unsigned short dst_port; int proto_reserved1; int proto_reserved2; union sockaddr_union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } s; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } src_su; struct socket_info { int socket; struct _str name; struct ip_addr address; struct _str address_str; struct _str port_no_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; } *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; } useinfo; } *bind_address; char proto; } *rcv; struct tcp_connection { int s; int fd; struct atomic_t { int val; } write_lock; int id; int reader_pid; struct receive_info rcv; struct tcp_req { struct tcp_req *next; char *buf; char *start; char *pos; char *parsed; char *body; unsigned int b_size; int content_len; int chunk_size; unsigned short flags; int bytes_to_go; enum tcp_req_errors { TCP_REQ_INIT=0, TCP_REQ_OK=1, TCP_READ_ERROR=2, TCP_REQ_OVERRUN=3, TCP_REQ_BAD_LEN=4 } error; enum tcp_req_states { H_SKIP_EMPTY=0, H_SKIP_EMPTY_CR_FOUND=1, H_SKIP_EMPTY_CRLF_FOUND=2, H_SKIP_EMPTY_CRLFCR_FOUND=3, H_SKIP=4, H_LF=5, H_LFCR=6, H_BODY=7, H_STARTWS=8, H_CONT_LEN1=9, H_CONT_LEN2=10, H_CONT_LEN3=11, H_CONT_LEN4=12, H_CONT_LEN5=13, H_CONT_LEN6=14, H_CONT_LEN7=15, H_CONT_LEN8=16, H_CONT_LEN9=17, H_CONT_LEN10=18, H_CONT_LEN11=19, H_CONT_LEN12=20, H_CONT_LEN13=21, H_L_COLON=22, H_CONT_LEN_BODY=23, H_CONT_LEN_BODY_PARSE=24, H_STUN_MSG=25, H_STUN_READ_BODY=26, H_STUN_FP=27, H_STUN_END=28, H_PING_CRLF=29, H_HTTP11_CHUNK_START=30, H_HTTP11_CHUNK_SIZE=31, H_HTTP11_CHUNK_BODY=32, H_HTTP11_CHUNK_END=33, H_HTTP11_CHUNK_FINISH=34, H_MSRP_BODY=35, H_MSRP_BODY_LF=36, H_MSRP_BODY_END=37, H_MSRP_FINISH=38 } state; } req; struct atomic_t refcnt; enum sip_protos { PROTO_NONE=0, PROTO_UDP=1, PROTO_TCP=2, PROTO_TLS=3, PROTO_SCTP=4, PROTO_WS=5, PROTO_WSS=6, PROTO_OTHER=7 } type; unsigned short flags; struct snd_flags { unsigned char f; unsigned char blst_imask; } send_flags; enum tcp_conn_states { S_CONN_ERROR=-2, S_CONN_BAD=-1, S_CONN_OK=0, S_CONN_INIT=1, S_CONN_EOF=2, S_CONN_ACCEPT=3, S_CONN_CONNECT=4 } state; void *extra_data; struct timer_ln { struct timer_ln *next; struct timer_ln *prev; unsigned int expire; unsigned int initial_timeout; void *data; unsigned int (*f)(unsigned int t, struct timer_ln *tl, void *data); unsigned short flags; unsigned short slow_idx; } timer; unsigned int timeout; unsigned int id_hash; struct tcp_connection *id_next; struct tcp_connection *id_prev; struct tcp_connection *c_next; struct tcp_connection *c_prev; struct tcp_conn_alias { struct tcp_connection *parent; struct tcp_conn_alias *next; struct tcp_conn_alias *prev; unsigned short port; unsigned short hash; } con_aliases[-1]; int aliases; struct tcp_wbuffer_queue { struct tcp_wbuffer { struct tcp_wbuffer *next; unsigned int b_size; char buf[1]; } *first; struct tcp_wbuffer *last; unsigned int wr_timeout; unsigned int queued; unsigned int offset; unsigned int last_used; } wbuf_q; } *con; } *tcpinfo; } *


decompiled_code:
__int64 __fastcall msrp_env_set_dstinfo(__int64 a1, const char **a2, int *a3, char a4)
{
unsigned int v4; // er13
__int64 v7; // rdx
char v8; // r14
__int64 result; // rax
int v10; // er12
int v11; // er15
const char *v12; // rbx
unsigned int v13; // eax
const char *v14; // r14
int v15; // er13
const char *v16; // rbx
unsigned int v17; // eax
const char *v18; // [rsp+8h] [rbp-40h]

v4 = 0;
if ( !a3 || a3[2] <= 0 )
{
LABEL_3:
v7 = 0LL;
v8 = a4 & 0xFB;
goto LABEL_4;
}
v8 = a4 | 4;
v7 = msrp_get_local_socket(a3);
if ( !v7 )
{
if ( (int)get_debug_level("msrp", 4LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v18 = *(const char **)a3;
v11 = a3[2];
v12 = (const char *)*((_QWORD *)&log_level_info + 16);
v13 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): local socket not found [%.*s] - trying to continue\n",
process_no,
v13,
v12,
"msrp [msrp_env.c:92]: ",
"msrp_env_set_dstinfo",
v11,
v18);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): local socket not found [%.*s] - trying to continue\n",
*((_QWORD *)&log_level_info + 16),
"msrp [msrp_env.c:92]: ",
"msrp_env_set_dstinfo",
(unsigned int)a3[2],
*(_QWORD *)a3);
}
--dprint_crit;
}
goto LABEL_3;
}
LABEL_4:
LOBYTE(v4) = dword_3B4C | v8;
xmmword_3B18 = 0LL;
xmmword_3B28 = 0LL;
xmmword_3B38 = 0LL;
if ( msrp_uri_to_dstinfo(0LL, &xmmword_3B18, v7, v4, a2) )
{
dword_3B48 |= 2u;
result = 0LL;
}
else
{
v10 = get_debug_level("msrp", 4LL);
result = 0xFFFFFFFFLL;
if ( v10 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v14 = *a2;
v15 = *((_DWORD *)a2 + 2);
v16 = (const char *)*((_QWORD *)&log_level_info + 8);
v17 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): failed to set destination address [%.*s]\n",
process_no,
v17,
v16,
"msrp [msrp_env.c:108]: ",
"msrp_env_set_dstinfo",
v15,
v14);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): failed to set destination address [%.*s]\n",
*((_QWORD *)&log_level_info + 8),
"msrp [msrp_env.c:108]: ",
"msrp_env_set_dstinfo",
*((unsigned int *)a2 + 2),
*a2,
&core_cfg);
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, const char **a2, int *a3, char a4)
{
unsigned int v4; // er13
__int64 v7; // rdx
char v8; // r14
__int64 result; // rax
int v10; // er12
int v11; // er15
const char *v12; // rbx
unsigned int v13; // eax
const char *v14; // r14
int v15; // er13
const char *v16; // rbx
unsigned int v17; // eax
const char *v18; // [rsp+8h] [rbp-40h]

v4 = 0;
if ( !a3 || a3[2] <= 0 )
{
LABEL_3:
v7 = 0LL;
v8 = a4 & 0xFB;
goto LABEL_4;
}
v8 = a4 | 4;
v7 = msrp_get_local_socket(a3);
if ( !v7 )
{
if ( (int)get_debug_level("msrp", 4LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v18 = *(const char **)a3;
v11 = a3[2];
v12 = (const char *)*((_QWORD *)&log_level_info + 16);
v13 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): local socket not found [%.*s] - trying to continue\n",
process_no,
v13,
v12,
"msrp [msrp_env.c:92]: ",
"msrp_env_set_dstinfo",
v11,
v18);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): local socket not found [%.*s] - trying to continue\n",
*((_QWORD *)&log_level_info + 16),
"msrp [msrp_env.c:92]: ",
"msrp_env_set_dstinfo",
(unsigned int)a3[2],
*(_QWORD *)a3);
}
--dprint_crit;
}
goto LABEL_3;
}
LABEL_4:
LOBYTE(v4) = dword_3B4C | v8;
xmmword_3B18 = 0LL;
xmmword_3B28 = 0LL;
xmmword_3B38 = 0LL;
if ( msrp_uri_to_dstinfo(0LL, &xmmword_3B18, v7, v4, a2) )
{
dword_3B48 |= 2u;
result = 0LL;
}
else
{
v10 = get_debug_level("msrp", 4LL);
result = 0xFFFFFFFFLL;
if ( v10 >= -1 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v14 = *a2;
v15 = *((_DWORD *)a2 + 2);
v16 = (const char *)*((_QWORD *)&log_level_info + 8);
v17 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): failed to set destination address [%.*s]\n",
process_no,
v17,
v16,
"msrp [msrp_env.c:108]: ",
"msrp_env_set_dstinfo",
v15,
v14);
if ( log_color )
dprint_color_reset();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): failed to set destination address [%.*s]\n",
*((_QWORD *)&log_level_info + 8),
"msrp [msrp_env.c:108]: ",
"msrp_env_set_dstinfo",
*((unsigned int *)a2 + 2),
*a2,
&core_cfg);
}
result = 0xFFFFFFFFLL;
--dprint_crit;
}
}
return result;
}

original_code:
int msrp_env_set_dstinfo(msrp_frame_t *mf, str *addr, str *fsock, int flags)
{
 struct socket_info *si = ((void *)0);
 snd_flags_t sflags = {0};
 if(fsock!=((void *)0) && fsock->len>0)
 {
  si = msrp_get_local_socket(fsock);
  if(si==((void *)0))
  {
   do { if (get_debug_level("msrp", (sizeof("msrp")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "local socket not found [%.*s] - trying to continue\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("msrp" " [" "msrp_env.c" ":" "92" "]: ") , __func__, fsock->len, fsock->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "local socket not found [%.*s] - trying to continue\n", (log_level_info[((3)) - (-5)].name), ("msrp" " [" "msrp_env.c" ":" "92" "]: ") , __func__, fsock->len, fsock->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "local socket not found [%.*s] - trying to continue\n", process_no, my_pid(), ("msrp" " [" "msrp_env.c" ":" "92" "]: ") , __func__, fsock->len, fsock->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "local socket not found [%.*s] - trying to continue\n", ("msrp" " [" "msrp_env.c" ":" "92" "]: ") , __func__, fsock->len, fsock->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "local socket not found [%.*s] - trying to continue\n", ("msrp" " [" "msrp_env.c" ":" "92" "]: ") , __func__, fsock->len, fsock->s); } } (dprint_crit--); } } while(0);
  }
 }
 sflags.f = flags;
 if(si==((void *)0))
 {
  sflags.f &= ~4;
 } else {
  sflags.f |= 4;
 }
 sflags.f |= _msrp_env.sndflags;
 memset(&_msrp_env.dstinfo, 0, sizeof(struct dest_info));
 if(msrp_uri_to_dstinfo(((void *)0), &_msrp_env.dstinfo, si, sflags, addr)==((void *)0))
 {
  do { if (get_debug_level("msrp", (sizeof("msrp")-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(): " "failed to set destination address [%.*s]\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("msrp" " [" "msrp_env.c" ":" "108" "]: ") , __func__, addr->len, addr->s); 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(): " "failed to set destination address [%.*s]\n", (log_level_info[((-1)) - (-5)].name), ("msrp" " [" "msrp_env.c" ":" "108" "]: ") , __func__, addr->len, addr->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "failed to set destination address [%.*s]\n", process_no, my_pid(), ("msrp" " [" "msrp_env.c" ":" "108" "]: ") , __func__, addr->len, addr->s); 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(): " "failed to set destination address [%.*s]\n", ("msrp" " [" "msrp_env.c" ":" "108" "]: ") , __func__, addr->len, addr->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "failed to set destination address [%.*s]\n", ("msrp" " [" "msrp_env.c" ":" "108" "]: ") , __func__, addr->len, addr->s); } } (dprint_crit--); } } while(0);
  return -1;
 }
 _msrp_env.envflags |= (1<<1);
 return 0;
}

canonical_original_code:
int msrp_env_set_dstinfo(struct msrp_frame *mf, struct _str *addr, struct _str *fsock, int flags)
{
 struct socket_info *si = ((void *)0);
 struct snd_flags sflags = {0};
 if(fsock!=((void *)0) && fsock->len>0)
 {
  si = msrp_get_local_socket(fsock);
  if(si==((void *)0))
  {
   do { if (get_debug_level("msrp", (sizeof("msrp")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "local socket not found [%.*s] - trying to continue\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("msrp" " [" "msrp_env.c" ":" "92" "]: ") , __func__, fsock->len, fsock->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "local socket not found [%.*s] - trying to continue\n", (log_level_info[((3)) - (-5)].name), ("msrp" " [" "msrp_env.c" ":" "92" "]: ") , __func__, fsock->len, fsock->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "local socket not found [%.*s] - trying to continue\n", process_no, my_pid(), ("msrp" " [" "msrp_env.c" ":" "92" "]: ") , __func__, fsock->len, fsock->s); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "local socket not found [%.*s] - trying to continue\n", ("msrp" " [" "msrp_env.c" ":" "92" "]: ") , __func__, fsock->len, fsock->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "local socket not found [%.*s] - trying to continue\n", ("msrp" " [" "msrp_env.c" ":" "92" "]: ") , __func__, fsock->len, fsock->s); } } (dprint_crit--); } } while(0);
  }
 }
 sflags.f = flags;
 if(si==((void *)0))
 {
  sflags.f &= ~4;
 } else {
  sflags.f |= 4;
 }
 sflags.f |= _msrp_env.sndflags;
 memset(&_msrp_env.dstinfo, 0, sizeof(struct dest_info));
 if(msrp_uri_to_dstinfo(((void *)0), &_msrp_env.dstinfo, si, sflags, addr)==((void *)0))
 {
  do { if (get_debug_level("msrp", (sizeof("msrp")-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(): " "failed to set destination address [%.*s]\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("msrp" " [" "msrp_env.c" ":" "108" "]: ") , __func__, addr->len, addr->s); 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(): " "failed to set destination address [%.*s]\n", (log_level_info[((-1)) - (-5)].name), ("msrp" " [" "msrp_env.c" ":" "108" "]: ") , __func__, addr->len, addr->s); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "failed to set destination address [%.*s]\n", process_no, my_pid(), ("msrp" " [" "msrp_env.c" ":" "108" "]: ") , __func__, addr->len, addr->s); 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(): " "failed to set destination address [%.*s]\n", ("msrp" " [" "msrp_env.c" ":" "108" "]: ") , __func__, addr->len, addr->s); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "failed to set destination address [%.*s]\n", ("msrp" " [" "msrp_env.c" ":" "108" "]: ") , __func__, addr->len, addr->s); } } (dprint_crit--); } } while(0);
  return -1;
 }
 _msrp_env.envflags |= (1<<1);
 return 0;
}

variable_types:
addr
struct _str *

variable_types:
fsock
struct _str *

variable_types: flags int

variable_types: struct socket_info { int socket; struct _str { char *s; int len; } name; struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; } address; struct _str address_str; struct _str port_no_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } s; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; } *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; } useinfo; } *

variable_types: struct snd_flags { unsigned char f; unsigned char blst_imask; }

user_defined_types: struct dest_info { struct socket_info *send_sock; union sockaddr_union to; int id; char proto; struct snd_flags send_flags; }

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; }

user_defined_types: struct msrp_fline { struct _str buf; int msgtypeid; struct _str protocol; struct _str transaction; struct _str rtype; int rtypeid; struct _str rtext; }

user_defined_types: struct msrp_data { void (*free_fn)(void *); int flags; void *data; }

user_defined_types: enum sip_protos { PROTO_NONE=0, PROTO_UDP=1, PROTO_TCP=2, PROTO_TLS=3, PROTO_SCTP=4, PROTO_WS=5, PROTO_WSS=6, PROTO_OTHER=7 }

user_defined_types: enum tcp_conn_states { S_CONN_ERROR=-2, S_CONN_BAD=-1, S_CONN_OK=0, S_CONN_INIT=1, S_CONN_EOF=2, S_CONN_ACCEPT=3, S_CONN_CONNECT=4 }

user_defined_types: struct timer_ln { struct timer_ln *next; struct timer_ln *prev; unsigned int expire; unsigned int initial_timeout; void *data; unsigned int (*f)(unsigned int t, struct timer_ln *tl, void *data); unsigned short flags; unsigned short slow_idx; }

user_defined_types: enum tcp_req_errors { TCP_REQ_INIT=0, TCP_REQ_OK=1, TCP_READ_ERROR=2, TCP_REQ_OVERRUN=3, TCP_REQ_BAD_LEN=4 }

user_defined_types: enum tcp_req_states { H_SKIP_EMPTY=0, H_SKIP_EMPTY_CR_FOUND=1, H_SKIP_EMPTY_CRLF_FOUND=2, H_SKIP_EMPTY_CRLFCR_FOUND=3, H_SKIP=4, H_LF=5, H_LFCR=6, H_BODY=7, H_STARTWS=8, H_CONT_LEN1=9, H_CONT_LEN2=10, H_CONT_LEN3=11, H_CONT_LEN4=12, H_CONT_LEN5=13, H_CONT_LEN6=14, H_CONT_LEN7=15, H_CONT_LEN8=16, H_CONT_LEN9=17, H_CONT_LEN10=18, H_CONT_LEN11=19, H_CONT_LEN12=20, H_CONT_LEN13=21, H_L_COLON=22, H_CONT_LEN_BODY=23, H_CONT_LEN_BODY_PARSE=24, H_STUN_MSG=25, H_STUN_READ_BODY=26, H_STUN_FP=27, H_STUN_END=28, H_PING_CRLF=29, H_HTTP11_CHUNK_START=30, H_HTTP11_CHUNK_SIZE=31, H_HTTP11_CHUNK_BODY=32, H_HTTP11_CHUNK_END=33, H_HTTP11_CHUNK_FINISH=34, H_MSRP_BODY=35, H_MSRP_BODY_LF=36, H_MSRP_BODY_END=37, H_MSRP_FINISH=38 }

user_defined_types: struct tcp_conn_alias { struct tcp_connection *parent; struct tcp_conn_alias *next; struct tcp_conn_alias *prev; unsigned short port; unsigned short hash; }


decompiled_code:
__int64 __fastcall msrp_env_set_sndflags(__int64 a1, int a2)
{
unsigned int v2; // esi

v2 = dword_3B4C | a2 & 0xFFFFFFFB;
dword_3B4C = v2;
if ( (dword_3B48 & 2) != 0 )
BYTE9(xmmword_3B38) |= v2;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, int a2)
{
unsigned int v2; // esi

v2 = dword_3B4C | a2 & 0xFFFFFFFB;
dword_3B4C = v2;
if ( (dword_3B48 & 2) != 0 )
BYTE9(xmmword_3B38) |= v2;
return 0LL;
}

original_code:
int msrp_env_set_sndflags(msrp_frame_t *mf, int flags)
{
 _msrp_env.sndflags |= (flags & (~4));
 if(_msrp_env.envflags & (1<<1))
 {
  _msrp_env.dstinfo.send_flags.f |= _msrp_env.sndflags;
 }
 return 0;
}

canonical_original_code:
int msrp_env_set_sndflags(struct msrp_frame *mf, int flags)
{
 _msrp_env.sndflags |= (flags & (~4));
 if(_msrp_env.envflags & (1<<1))
 {
  _msrp_env.dstinfo.send_flags.f |= _msrp_env.sndflags;
 }
 return 0;
}

user_defined_types: struct msrp_frame { struct _str buf; struct msrp_fline fline; struct _str hbody; struct _str mbody; struct _str endline; struct msrp_hdr *headers; struct tcp_event_info *tcpinfo; }

user_defined_types: struct msrp_hdr { struct _str buf; int htype; struct _str name; struct _str body; struct msrp_data parsed; struct msrp_hdr *next; }

user_defined_types: struct tcp_event_info { int type; char *buf; unsigned int len; struct receive_info *rcv; struct tcp_connection *con; }

user_defined_types: struct receive_info { struct ip_addr src_ip; struct ip_addr dst_ip; unsigned short src_port; unsigned short dst_port; int proto_reserved1; int proto_reserved2; union sockaddr_union src_su; struct socket_info *bind_address; char proto; }

user_defined_types: struct tcp_connection { int s; int fd; struct atomic_t write_lock; int id; int reader_pid; struct receive_info rcv; struct tcp_req req; struct atomic_t refcnt; enum sip_protos type; unsigned short flags; struct snd_flags send_flags; enum tcp_conn_states state; void *extra_data; struct timer_ln timer; unsigned int timeout; unsigned int id_hash; struct tcp_connection *id_next; struct tcp_connection *id_prev; struct tcp_connection *c_next; struct tcp_connection *c_prev; struct tcp_conn_alias con_aliases[-1]; int aliases; struct tcp_wbuffer_queue wbuf_q; }

user_defined_types: struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; }

user_defined_types: union sockaddr_union { struct sockaddr s; struct sockaddr_in sin; struct sockaddr_in6 sin6; }

user_defined_types: struct snd_flags { unsigned char f; unsigned char blst_imask; }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }

user_defined_types: struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; }

user_defined_types: enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 }

user_defined_types: struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; }

user_defined_types: struct tcp_wbuffer { struct tcp_wbuffer *next; unsigned int b_size; char buf[1]; }


decompiled_code:
__int64 __fastcall msrp_env_set_rplflags(__int64 a1, int a2)
{
unsigned int v2; // esi

v2 = dword_3B50 | a2 & 0xFFFFFFFB;
dword_3B50 = v2;
if ( (dword_3B48 & 1) != 0 )
LOBYTE(word_3B11) = v2 | word_3B11;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2)
{
unsigned int v2; // esi

v2 = dword_3B50 | a2 & 0xFFFFFFFB;
dword_3B50 = v2;
if ( (dword_3B48 & 1) != 0 )
LOBYTE(word_3B11) = v2 | word_3B11;
return 0LL;
}

original_code:
int msrp_env_set_rplflags(msrp_frame_t *mf, int flags)
{
 _msrp_env.rplflags |= (flags & (~4));
 if(_msrp_env.envflags & (1<<0))
 {
  _msrp_env.srcinfo.send_flags.f |= _msrp_env.rplflags;
 }
 return 0;
}

canonical_original_code:
int msrp_env_set_rplflags(struct msrp_frame *mf, int flags)
{
 _msrp_env.rplflags |= (flags & (~4));
 if(_msrp_env.envflags & (1<<0))
 {
  _msrp_env.srcinfo.send_flags.f |= _msrp_env.rplflags;
 }
 return 0;
}

user_defined_types: struct msrp_fline { struct _str buf; int msgtypeid; struct _str protocol; struct _str transaction; struct _str rtype; int rtypeid; struct _str rtext; }

user_defined_types: struct msrp_data { void (*free_fn)(void *); int flags; void *data; }

user_defined_types: struct tcp_req { struct tcp_req *next; char *buf; char *start; char *pos; char *parsed; char *body; unsigned int b_size; int content_len; int chunk_size; unsigned short flags; int bytes_to_go; enum tcp_req_errors error; enum tcp_req_states state; }

user_defined_types: enum sip_protos { PROTO_NONE=0, PROTO_UDP=1, PROTO_TCP=2, PROTO_TLS=3, PROTO_SCTP=4, PROTO_WS=5, PROTO_WSS=6, PROTO_OTHER=7 }

user_defined_types: enum tcp_conn_states { S_CONN_ERROR=-2, S_CONN_BAD=-1, S_CONN_OK=0, S_CONN_INIT=1, S_CONN_EOF=2, S_CONN_ACCEPT=3, S_CONN_CONNECT=4 }

user_defined_types: struct timer_ln { struct timer_ln *next; struct timer_ln *prev; unsigned int expire; unsigned int initial_timeout; void *data; unsigned int (*f)(unsigned int t, struct timer_ln *tl, void *data); unsigned short flags; unsigned short slow_idx; }

user_defined_types: struct tcp_wbuffer_queue { struct tcp_wbuffer *first; struct tcp_wbuffer *last; unsigned int wr_timeout; unsigned int queued; unsigned int offset; unsigned int last_used; }

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr sin6_addr; unsigned int sin6_scope_id; }

user_defined_types: struct socket_info { int socket; struct _str name; struct ip_addr address; struct _str address_str; struct _str port_no_str; enum si_flags flags; union sockaddr_union su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info useinfo; }

user_defined_types: struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; }


decompiled_code:
__int64 __fastcall register_tls_hooks(const __m128i *a1)
{
__int64 result; // rax
__m128i v2; // xmm0

result = tls_disable;
if ( tls_disable )
return 0xFFFFFFFFLL;
v2 = _mm_loadu_si128(a1);
++tls_hooks_loaded;
tls_hook[0] = v2;
tls_hook[1] = _mm_loadu_si128(a1 + 1);
tls_hook[2] = _mm_loadu_si128(a1 + 2);
tls_hook[3] = _mm_loadu_si128(a1 + 3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const __m128i *a1)
{
__int64 result; // rax
__m128i v2; // xmm0

result = tls_disable;
if ( tls_disable )
return 0xFFFFFFFFLL;
v2 = _mm_loadu_si128(a1);
++tls_hooks_loaded;
tls_hook[0] = v2;
tls_hook[1] = _mm_loadu_si128(a1 + 1);
tls_hook[2] = _mm_loadu_si128(a1 + 2);
tls_hook[3] = _mm_loadu_si128(a1 + 3);
return result;
}

original_code:
int register_tls_hooks(struct tls_hooks* h)
{
 if (!tls_disable){
  tls_hook=*h;
  tls_hooks_loaded++;
  return 0;
 }
 return -1;
}

canonical_original_code:
int register_tls_hooks(struct tls_hooks *h)
{
 if (!tls_disable){
  tls_hook=*h;
  tls_hooks_loaded++;
  return 0;
 }
 return -1;
}

variable_types: struct tls_hooks { int (*read)(struct tcp_connection { int s; int fd; struct atomic_t { int val; } write_lock; int id; int reader_pid; struct receive_info { struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; } src_ip; struct ip_addr dst_ip; unsigned short src_port; unsigned short dst_port; int proto_reserved1; int proto_reserved2; union sockaddr_union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } s; struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } sin; struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; } sin6; } src_su; struct socket_info { int socket; struct _str { char *s; int len; } name; struct ip_addr address; struct _str address_str; struct _str port_no_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct socket_info *next; struct socket_info *prev; unsigned short port_no; char proto; struct _str sock_str; struct addr_info { struct _str name; struct ip_addr address; struct _str address_str; enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 } flags; union sockaddr_union su; struct addr_info *next; struct addr_info *prev; } *addr_info_lst; int workers; int workers_tcpidx; struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; } useinfo; } *bind_address; char proto; } rcv; struct tcp_req { struct tcp_req *next; char *buf; char *start; char *pos; char *parsed; char *body; unsigned int b_size; int content_len; int chunk_size; unsigned short flags; int bytes_to_go; enum tcp_req_errors { TCP_REQ_INIT=0, TCP_REQ_OK=1, TCP_READ_ERROR=2, TCP_REQ_OVERRUN=3, TCP_REQ_BAD_LEN=4 } error; enum tcp_req_states { H_SKIP_EMPTY=0, H_SKIP_EMPTY_CR_FOUND=1, H_SKIP_EMPTY_CRLF_FOUND=2, H_SKIP_EMPTY_CRLFCR_FOUND=3, H_SKIP=4, H_LF=5, H_LFCR=6, H_BODY=7, H_STARTWS=8, H_CONT_LEN1=9, H_CONT_LEN2=10, H_CONT_LEN3=11, H_CONT_LEN4=12, H_CONT_LEN5=13, H_CONT_LEN6=14, H_CONT_LEN7=15, H_CONT_LEN8=16, H_CONT_LEN9=17, H_CONT_LEN10=18, H_CONT_LEN11=19, H_CONT_LEN12=20, H_CONT_LEN13=21, H_L_COLON=22, H_CONT_LEN_BODY=23, H_CONT_LEN_BODY_PARSE=24, H_STUN_MSG=25, H_STUN_READ_BODY=26, H_STUN_FP=27, H_STUN_END=28, H_PING_CRLF=29, H_HTTP11_CHUNK_START=30, H_HTTP11_CHUNK_SIZE=31, H_HTTP11_CHUNK_BODY=32, H_HTTP11_CHUNK_END=33, H_HTTP11_CHUNK_FINISH=34, H_MSRP_BODY=35, H_MSRP_BODY_LF=36, H_MSRP_BODY_END=37, H_MSRP_FINISH=38 } state; } req; struct atomic_t refcnt; enum sip_protos { PROTO_NONE=0, PROTO_UDP=1, PROTO_TCP=2, PROTO_TLS=3, PROTO_SCTP=4, PROTO_WS=5, PROTO_WSS=6, PROTO_OTHER=7 } type; unsigned short flags; struct snd_flags { unsigned char f; unsigned char blst_imask; } send_flags; enum tcp_conn_states { S_CONN_ERROR=-2, S_CONN_BAD=-1, S_CONN_OK=0, S_CONN_INIT=1, S_CONN_EOF=2, S_CONN_ACCEPT=3, S_CONN_CONNECT=4 } state; void *extra_data; struct timer_ln { struct timer_ln *next; struct timer_ln *prev; unsigned int expire; unsigned int initial_timeout; void *data; unsigned int (*f)(unsigned int t, struct timer_ln *tl, void *data); unsigned short flags; unsigned short slow_idx; } timer; unsigned int timeout; unsigned int id_hash; struct tcp_connection *id_next; struct tcp_connection *id_prev; struct tcp_connection *c_next; struct tcp_connection *c_prev; struct tcp_conn_alias { struct tcp_connection *parent; struct tcp_conn_alias *next; struct tcp_conn_alias *prev; unsigned short port; unsigned short hash; } con_aliases[-1]; int aliases; struct tcp_wbuffer_queue { struct tcp_wbuffer { struct tcp_wbuffer *next; unsigned int b_size; char buf[1]; } *first; struct tcp_wbuffer *last; unsigned int wr_timeout; unsigned int queued; unsigned int offset; unsigned int last_used; } wbuf_q; } *c, int *flags); int (*encode)(struct tcp_connection *c, char **pbuf, unsigned int *plen, char **rest_buf, unsigned int *rest_len, struct snd_flags *send_flags); int (*on_tcpconn_init)(struct tcp_connection *c, int sock); void (*tcpconn_clean)(struct tcp_connection *c); void (*tcpconn_close)(struct tcp_connection *c, int fd); int (*init_si)(struct socket_info *si); int (*init)(); void (*destroy)(); } *

user_defined_types: struct tls_hooks { int (*read)(struct tcp_connection *c, int *flags); int (*encode)(struct tcp_connection *c, char **pbuf, unsigned int *plen, char **rest_buf, unsigned int *rest_len, struct snd_flags *send_flags); int (*on_tcpconn_init)(struct tcp_connection *c, int sock); void (*tcpconn_clean)(struct tcp_connection *c); void (*tcpconn_close)(struct tcp_connection *c, int fd); int (*init_si)(struct socket_info *si); int (*init)(); void (*destroy)(); }

user_defined_types: struct tcp_connection { int s; int fd; struct atomic_t write_lock; int id; int reader_pid; struct receive_info rcv; struct tcp_req req; struct atomic_t refcnt; enum sip_protos type; unsigned short flags; struct snd_flags send_flags; enum tcp_conn_states state; void *extra_data; struct timer_ln timer; unsigned int timeout; unsigned int id_hash; struct tcp_connection *id_next; struct tcp_connection *id_prev; struct tcp_connection *c_next; struct tcp_connection *c_prev; struct tcp_conn_alias con_aliases[-1]; int aliases; struct tcp_wbuffer_queue wbuf_q; }

user_defined_types: struct receive_info { struct ip_addr src_ip; struct ip_addr dst_ip; unsigned short src_port; unsigned short dst_port; int proto_reserved1; int proto_reserved2; union sockaddr_union src_su; struct socket_info *bind_address; char proto; }

user_defined_types: union sockaddr_union { struct sockaddr s; struct sockaddr_in sin; struct sockaddr_in6 sin6; }


decompiled_code:
__int64 tls_init()
{
__int64 (*v0)(void); // rax
__int64 result; // rax

v0 = (__int64 (*)(void))tls_hook[2].m128i_i64[1];
if ( v0 )
result = v0();
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 (*v0)(void); // rax
__int64 result; // rax

v0 = (__int64 (*)(void))tls_hook[2].m128i_i64[1];
if ( v0 )
result = v0();
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int tls_init(struct socket_info* si)
{
 if (tls_hook.init_si)
  return tls_hook.init_si(si);
  return -1;
}

canonical_original_code:
int tls_init(struct socket_info *si)
{
 if (tls_hook.init_si)
  return tls_hook.init_si(si);
  return -1;
}

user_defined_types: struct ip_addr { unsigned int af; unsigned int len; union { unsigned long addrl[-1]; unsigned int addr32[4]; unsigned short addr16[8]; unsigned char addr[16]; } u; }

user_defined_types: enum si_flags { SI_NONE=0, SI_IS_IP=1, SI_IS_LO=2, SI_IS_MCAST=4, SI_IS_ANY=8, SI_IS_MHOMED=16 }

user_defined_types: struct advertise_info { struct _str name; unsigned short port_no; struct _str port_no_str; struct _str address_str; struct ip_addr address; struct _str sock_str; }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }

user_defined_types: struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; }


decompiled_code:
_BOOL8 tls_has_init_si()
{
return tls_hook[2].m128i_i64[1] != 0;
}

original_code:
int tls_has_init_si()
{
 return (tls_hook.init_si!=0);
}


decompiled_code:
__int64 init_tls()
{
__int64 (*v0)(void); // rax
__int64 result; // rax

v0 = (__int64 (*)(void))tls_hook[3].m128i_i64[0];
if ( v0 )
result = v0();
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 (*v0)(void); // rax
__int64 result; // rax

v0 = (__int64 (*)(void))tls_hook[3].m128i_i64[0];
if ( v0 )
result = v0();
else
result = 0LL;
return result;
}

original_code:
int init_tls()
{
 if (tls_hook.init)
  return tls_hook.init();
 return 0;
}


decompiled_code:
__int64 tls_loaded()
{
return (unsigned int)tls_hooks_loaded;
}

canonical_decompiled_code:
__int64 func4()
{
return (unsigned int)tls_hooks_loaded;
}

original_code:
int tls_loaded()
{
 return tls_hooks_loaded;
}


decompiled_code:
__int64 destroy_nonsip_hooks()
{
__int64 v0; // rsi
__int64 v1; // rbx
void (*v2)(void); // rcx
__int64 result; // rax

v0 = nonsip_hooks;
if ( nonsip_hooks )
{
if ( last_hook_idx > 0 )
{
v1 = 0LL;
do
{
v2 = *(void (**)(void))(v0 + 24 * v1 + 16);
if ( v2 )
{
v2();
v0 = nonsip_hooks;
}
++v1;
}
while ( last_hook_idx > (int)v1 );
}
result = qm_free(mem_block);
nonsip_hooks = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rsi
__int64 v1; // rbx
void (*v2)(void); // rcx
__int64 result; // rax

v0 = nonsip_hooks;
if ( nonsip_hooks )
{
if ( last_hook_idx > 0 )
{
v1 = 0LL;
do
{
v2 = *(void (**)(void))(v0 + 24 * v1 + 16);
if ( v2 )
{
v2();
v0 = nonsip_hooks;
}
++v1;
}
while ( last_hook_idx > (int)v1 );
}
result = qm_free(mem_block);
nonsip_hooks = 0LL;
}
return result;
}

original_code:
void destroy_nonsip_hooks()
{
 int r;
 if (nonsip_hooks){
  for (r=0; r<last_hook_idx; r++){
   if (nonsip_hooks[r].destroy)
    nonsip_hooks[r].destroy();
  }
  qm_free(mem_block, (nonsip_hooks));
  nonsip_hooks=0;
 }
}

variable_types: r int


decompiled_code:
__int64 __fastcall print_fixup_f_2(const char **a1, unsigned int a2)
{
const char *v4; // r15
const char *v5; // r14
unsigned int v6; // eax
struct _IO_FILE *v7; // rdi

if ( (int)get_debug_level("print", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v4 = *a1;
v5 = (const char *)*((_QWORD *)&log_level_info + 16);
v6 = my_pid();
v7 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): print: print_fixup_f_2('%s')\n",
process_no,
v6,
v5,
"print [print.c:141]: ",
"print_fixup_f_2",
v4);
if ( log_color )
dprint_color_reset(v7, "%2d(%d) %s: %s%s(): print: print_fixup_f_2('%s')\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): print: print_fixup_f_2('%s')\n",
*((const char **)&log_level_info + 16),
"print [print.c:141]: ",
"print_fixup_f_2",
*a1);
}
--dprint_crit;
}
return print_fixup_f((__int64)a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func9(const char **a1, unsigned int a2)
{
const char *v4; // r15
const char *v5; // r14
unsigned int v6; // eax
struct _IO_FILE *v7; // rdi

if ( (int)get_debug_level("print", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v4 = *a1;
v5 = (const char *)*((_QWORD *)&log_level_info + 16);
v6 = my_pid();
v7 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): print: print_fixup_f_2('%s')\n",
process_no,
v6,
v5,
"print [print.c:141]: ",
"print_fixup_f_2",
v4);
if ( log_color )
dprint_color_reset(v7, "%2d(%d) %s: %s%s(): print: print_fixup_f_2('%s')\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): print: print_fixup_f_2('%s')\n",
*((const char **)&log_level_info + 16),
"print [print.c:141]: ",
"print_fixup_f_2",
*a1);
}
--dprint_crit;
}
return func8((__int64)a1, a2);
}

original_code:
static int print_fixup_f_2(void **param, int param_no) {
 do { if (get_debug_level("print", (sizeof("print")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "print: print_fixup_f_2('%s')\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "141" "]: ") , __func__, (char*)*param); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "print: print_fixup_f_2('%s')\n", (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "141" "]: ") , __func__, (char*)*param); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "print: print_fixup_f_2('%s')\n", process_no, my_pid(), ("print" " [" "print.c" ":" "141" "]: ") , __func__, (char*)*param); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "print: print_fixup_f_2('%s')\n", ("print" " [" "print.c" ":" "141" "]: ") , __func__, (char*)*param); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "print: print_fixup_f_2('%s')\n", ("print" " [" "print.c" ":" "141" "]: ") , __func__, (char*)*param); } } (dprint_crit--); } } while(0);
 return print_fixup_f(param, param_no);
}

canonical_original_code:
static int print_fixup_f_2(void **param, int param_no) {
 do { if (get_debug_level("print", (sizeof("print")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "print: print_fixup_f_2('%s')\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "141" "]: ") , __func__, (char *)*param); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "print: print_fixup_f_2('%s')\n", (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "141" "]: ") , __func__, (char *)*param); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "print: print_fixup_f_2('%s')\n", process_no, my_pid(), ("print" " [" "print.c" ":" "141" "]: ") , __func__, (char *)*param); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "print: print_fixup_f_2('%s')\n", ("print" " [" "print.c" ":" "141" "]: ") , __func__, (char *)*param); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "print: print_fixup_f_2('%s')\n", ("print" " [" "print.c" ":" "141" "]: ") , __func__, (char *)*param); } } (dprint_crit--); } } while(0);
 return print_fixup_f(param, param_no);
}

variable_types:
param
void **

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 print_fixup_f_1(const char **a1, unsigned int a2)
{
const char *v4; // r15
const char *v5; // r14
unsigned int v6; // eax
struct _IO_FILE *v7; // rdi

if ( (int)get_debug_level("print", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v4 = *a1;
v5 = (const char *)*((_QWORD *)&log_level_info + 16);
v6 = my_pid();
v7 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): print: print_fixup_f_1('%s')\n",
process_no,
v6,
v5,
"print [print.c:136]: ",
"print_fixup_f_1",
v4);
if ( log_color )
dprint_color_reset(v7, "%2d(%d) %s: %s%s(): print: print_fixup_f_1('%s')\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): print: print_fixup_f_1('%s')\n",
*((const char **)&log_level_info + 16),
"print [print.c:136]: ",
"print_fixup_f_1",
*a1);
}
--dprint_crit;
}
return print_fixup_f((__int64)a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func10(const char **a1, unsigned int a2)
{
const char *v4; // r15
const char *v5; // r14
unsigned int v6; // eax
struct _IO_FILE *v7; // rdi

if ( (int)get_debug_level("print", 5LL) > 2 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(3LL);
v4 = *a1;
v5 = (const char *)*((_QWORD *)&log_level_info + 16);
v6 = my_pid();
v7 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): print: print_fixup_f_1('%s')\n",
process_no,
v6,
v5,
"print [print.c:136]: ",
"print_fixup_f_1",
v4);
if ( log_color )
dprint_color_reset(v7, "%2d(%d) %s: %s%s(): print: print_fixup_f_1('%s')\n");
}
else
{
syslog(
*((_DWORD *)&log_level_info + 34) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): print: print_fixup_f_1('%s')\n",
*((const char **)&log_level_info + 16),
"print [print.c:136]: ",
"print_fixup_f_1",
*a1);
}
--dprint_crit;
}
return func8((__int64)a1, a2);
}

original_code:
static int print_fixup_f_1(void **param, int param_no) {
 do { if (get_debug_level("print", (sizeof("print")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "print: print_fixup_f_1('%s')\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "136" "]: ") , __func__, (char*)*param); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "print: print_fixup_f_1('%s')\n", (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "136" "]: ") , __func__, (char*)*param); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "print: print_fixup_f_1('%s')\n", process_no, my_pid(), ("print" " [" "print.c" ":" "136" "]: ") , __func__, (char*)*param); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "print: print_fixup_f_1('%s')\n", ("print" " [" "print.c" ":" "136" "]: ") , __func__, (char*)*param); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "print: print_fixup_f_1('%s')\n", ("print" " [" "print.c" ":" "136" "]: ") , __func__, (char*)*param); } } (dprint_crit--); } } while(0);
 return print_fixup_f(param, param_no);
}

canonical_original_code:
static int print_fixup_f_1(void **param, int param_no) {
 do { if (get_debug_level("print", (sizeof("print")-1)) >= ((3)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((3)) >= -5) && (((3)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "print: print_fixup_f_1('%s')\n", process_no, my_pid(), (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "136" "]: ") , __func__, (char *)*param); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((3)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "print: print_fixup_f_1('%s')\n", (log_level_info[((3)) - (-5)].name), ("print" " [" "print.c" ":" "136" "]: ") , __func__, (char *)*param); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((3)); fprintf(stderr, "%2d(%d) %s" "%s(): " "print: print_fixup_f_1('%s')\n", process_no, my_pid(), ("print" " [" "print.c" ":" "136" "]: ") , __func__, (char *)*param); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((3))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "print: print_fixup_f_1('%s')\n", ("print" " [" "print.c" ":" "136" "]: ") , __func__, (char *)*param); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "print: print_fixup_f_1('%s')\n", ("print" " [" "print.c" ":" "136" "]: ") , __func__, (char *)*param); } } (dprint_crit--); } } while(0);
 return print_fixup_f(param, param_no);
}