original_code:
static void parse_uri(const str_t *uri, str_t *user, str_t *domain)
{
 char *a;
 char *d;
 str_t s;
 do { if (user != ((void *)0)) { (user)->len = 0; (user)->s = 0; } } while (0);
 do { if (domain != ((void *)0)) { (domain)->len = 0; (domain)->s = 0; } } while (0);
 if (uri->len > 0) {
  d = str_strchr(uri, ':');
  if (d) {
   s.s = d + 1;
   s.len = uri->len - (s.s - uri->s);
  }
  else s = *uri;
  a = str_strchr(&s, '@');
  if (a) {
   user->s = s.s;
   user->len = a - s.s;
  }
  domain->s = s.s + user->len;
  if (a) domain->s++;
  domain->len = uri->len - (domain->s - uri->s);
 }
}

canonical_original_code:
static void parse_uri(struct _str *uri, struct _str *user, struct _str *domain)
{
 char *a;
 char *d;
 struct _str s;
 do { if (user != ((void *)0)) { (user)->len = 0; (user)->s = 0; } } while (0);
 do { if (domain != ((void *)0)) { (domain)->len = 0; (domain)->s = 0; } } while (0);
 if (uri->len > 0) {
  d = str_strchr(uri, ':');
  if (d) {
   s.s = d + 1;
   s.len = uri->len - (s.s - uri->s);
  }
  else s = *uri;
  a = str_strchr(&s, '@');
  if (a) {
   user->s = s.s;
   user->len = a - s.s;
  }
  domain->s = s.s + user->len;
  if (a) domain->s++;
  domain->len = uri->len - (domain->s - uri->s);
 }
}

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

variable_types:
user
struct _str *

variable_types:
domain
struct _str *

variable_types:
a
char *

variable_types:
d
char *

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


repo: virtualolson/who

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

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:
lock
struct atomic_t { int val; } *

variable_types: v int

variable_types: i int

return_type: void


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 func5(unsigned int a1)
{
__int64 v1; // r12

func4(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_conditions(_QWORD *a1)
{
__int64 v2; // rdi
int *v3; // rbx
int *v4; // rbp
volatile signed __int32 *v5; // rdi
__int64 result; // rax

if ( a1 )
{
if ( *a1 )
{
futex_get(mem_lock);
qm_free(shm_block, *a1);
futex_release(mem_lock);
}
v2 = a1[1];
if ( v2 )
free_identity(v2);
v3 = (int *)a1[2];
while ( v3 )
{
v4 = v3;
v3 = *(int **)v3;
if ( v4[4] > 0 )
{
if ( *((_QWORD *)v4 + 1) )
{
futex_get(mem_lock);
qm_free(shm_block, *((_QWORD *)v4 + 1));
futex_release(mem_lock);
}
}
v4[4] = 0;
v5 = mem_lock;
*((_QWORD *)v4 + 1) = 0LL;
futex_get(v5);
qm_free(shm_block, v4);
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 func7(_QWORD *a1)
{
__int64 v2; // rdi
int *v3; // rbx
int *v4; // rbp
volatile signed __int32 *v5; // rdi
__int64 result; // rax

if ( a1 )
{
if ( *a1 )
{
func4(mem_lock);
qm_free(shm_block, *a1);
func1(mem_lock);
}
v2 = a1[1];
if ( v2 )
func6(v2);
v3 = (int *)a1[2];
while ( v3 )
{
v4 = v3;
v3 = *(int **)v3;
if ( v4[4] > 0 )
{
if ( *((_QWORD *)v4 + 1) )
{
func4(mem_lock);
qm_free(shm_block, *((_QWORD *)v4 + 1));
func1(mem_lock);
}
}
v4[4] = 0;
v5 = mem_lock;
*((_QWORD *)v4 + 1) = 0LL;
func4(v5);
qm_free(shm_block, v4);
func1(mem_lock);
}
func4(mem_lock);
qm_free(shm_block, a1);
result = func1(mem_lock);
}
return result;
}

original_code:
static void free_conditions(cp_conditions_t *c)
{
 cp_sphere_t *s, *n;
 if (!c) return;
 if (c->validity) do { futex_get(mem_lock); qm_free(shm_block, (c->validity)); futex_release(mem_lock); }while(0);
 if (c->identity) free_identity(c->identity);
 s = c->spheres;
 while (s) {
  n = s->next;
  do { if (&s->value != ((void *)0)) { if (((&s->value)->len > 0) && ((&s->value)->s)) do { futex_get(mem_lock); qm_free(shm_block, ((&s->value)->s)); futex_release(mem_lock); }while(0); (&s->value)->len = 0; (&s->value)->s = 0; } } while (0);
  do { futex_get(mem_lock); qm_free(shm_block, (s)); futex_release(mem_lock); }while(0);
  s = n;
 }
 do { futex_get(mem_lock); qm_free(shm_block, (c)); futex_release(mem_lock); }while(0);
}

canonical_original_code:
static void free_conditions(struct cp_conditions_t *c)
{
 struct _cp_sphere_t *s; struct _cp_sphere_t *n;
 if (!c) return;
 if (c->validity) do { futex_get(mem_lock); qm_free(shm_block, (c->validity)); futex_release(mem_lock); }while(0);
 if (c->identity) free_identity(c->identity);
 s = c->spheres;
 while (s) {
  n = s->next;
  do { if (&s->value != ((void *)0)) { if (((&s->value)->len > 0) && ((&s->value)->s)) do { futex_get(mem_lock); qm_free(shm_block, ((&s->value)->s)); futex_release(mem_lock); }while(0); (&s->value)->len = 0; (&s->value)->s = 0; } } while (0);
  do { futex_get(mem_lock); qm_free(shm_block, (s)); futex_release(mem_lock); }while(0);
  s = n;
 }
 do { futex_get(mem_lock); qm_free(shm_block, (c)); futex_release(mem_lock); }while(0);
}

variable_types: struct cp_conditions_t { struct cp_validity_t { long from; long to; } *validity; struct cp_identity_t { struct _cp_id_t { struct _cp_id_t *next; struct _str { char *s; int len; } entity; } *ids; struct _cp_domain_t { struct _cp_domain_t *next; struct _str domain; } *domains; struct _cp_except_t { struct _cp_except_t *next; struct _str entity; } *excepts; struct cp_any_identity_t { struct _cp_domain_t *domains; struct _cp_except_domain_t { struct _cp_except_domain_t *next; struct _str domain; } *except_domains; } *any_identity; } *identity; struct _cp_sphere_t { struct _cp_sphere_t *next; struct _str value; } *spheres; } *

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

user_defined_types: struct cp_conditions_t { struct cp_validity_t *validity; struct cp_identity_t *identity; struct _cp_sphere_t *spheres; }

user_defined_types: struct cp_identity_t { struct _cp_id_t *ids; struct _cp_domain_t *domains; struct _cp_except_t *excepts; struct cp_any_identity_t *any_identity; }

user_defined_types: struct _cp_id_t { struct _cp_id_t *next; struct _str entity; }

user_defined_types: struct cp_any_identity_t { struct _cp_domain_t *domains; struct _cp_except_domain_t *except_domains; }


decompiled_code:
__int64 __fastcall free_transformations(_QWORD **a1)
{
_QWORD *v1; // rbx
_QWORD *v2; // r12
__int64 result; // rax

if ( a1 )
{
v1 = *a1;
while ( v1 )
{
v2 = v1;
v1 = (_QWORD *)*v1;
futex_get(mem_lock);
qm_free(shm_block, v2);
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 func8(_QWORD **a1)
{
_QWORD *v1; // rbx
_QWORD *v2; // r12
__int64 result; // rax

if ( a1 )
{
v1 = *a1;
while ( v1 )
{
v2 = v1;
v1 = (_QWORD *)*v1;
func4(mem_lock);
qm_free(shm_block, v2);
func1(mem_lock);
}
func4(mem_lock);
qm_free(shm_block, a1);
result = func1(mem_lock);
}
return result;
}

original_code:
static void free_transformations(cp_transformations_t *t)
{
 cp_unknown_t *u, *nu;
 if (!t) return;
 u = t->unknown;
 while (u) {
  nu = u->next;
  do { futex_get(mem_lock); qm_free(shm_block, (u)); futex_release(mem_lock); }while(0);
  u = nu;
 }
 do { futex_get(mem_lock); qm_free(shm_block, (t)); futex_release(mem_lock); }while(0);
}

canonical_original_code:
static void free_transformations(struct cp_transformations_t *t)
{
 struct _cp_unknown_t *u; struct _cp_unknown_t *nu;
 if (!t) return;
 u = t->unknown;
 while (u) {
  nu = u->next;
  do { futex_get(mem_lock); qm_free(shm_block, (u)); futex_release(mem_lock); }while(0);
  u = nu;
 }
 do { futex_get(mem_lock); qm_free(shm_block, (t)); futex_release(mem_lock); }while(0);
}

variable_types: struct cp_transformations_t { struct _cp_unknown_t { struct _cp_unknown_t *next; char data[1]; } *unknown; } *

user_defined_types: struct cp_transformations_t { struct _cp_unknown_t *unknown; }


decompiled_code:
__int64 __fastcall free_cp_rule(__int64 a1, void (*a2)(void))
{
_QWORD *v3; // rdi
_QWORD **v4; // rdi
volatile signed __int32 *v5; // rdi
__int64 result; // rax

if ( a1 )
{
v3 = *(_QWORD **)(a1 + 8);
if ( v3 )
free_conditions(v3);
if ( *(_QWORD *)(a1 + 16) )
a2();
v4 = *(_QWORD ***)(a1 + 24);
if ( v4 )
free_transformations(v4);
if ( *(int *)(a1 + 40) > 0 )
{
if ( *(_QWORD *)(a1 + 32) )
{
futex_get(mem_lock);
qm_free(shm_block, *(_QWORD *)(a1 + 32));
futex_release(mem_lock);
}
}
*(_DWORD *)(a1 + 40) = 0;
v5 = mem_lock;
*(_QWORD *)(a1 + 32) = 0LL;
futex_get(v5);
qm_free(shm_block, a1);
result = futex_release(mem_lock);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, void (*a2)(void))
{
_QWORD *v3; // rdi
_QWORD **v4; // rdi
volatile signed __int32 *v5; // rdi
__int64 result; // rax

if ( a1 )
{
v3 = *(_QWORD **)(a1 + 8);
if ( v3 )
func7(v3);
if ( *(_QWORD *)(a1 + 16) )
a2();
v4 = *(_QWORD ***)(a1 + 24);
if ( v4 )
func8(v4);
if ( *(int *)(a1 + 40) > 0 )
{
if ( *(_QWORD *)(a1 + 32) )
{
func4(mem_lock);
qm_free(shm_block, *(_QWORD *)(a1 + 32));
func1(mem_lock);
}
}
*(_DWORD *)(a1 + 40) = 0;
v5 = mem_lock;
*(_QWORD *)(a1 + 32) = 0LL;
func4(v5);
qm_free(shm_block, a1);
result = func1(mem_lock);
}
return result;
}

original_code:
void free_cp_rule(cp_rule_t *r, cp_free_actions_func free_actions)
{
 if (!r) return;
 if (r->conditions) free_conditions(r->conditions);
 if (r->actions) free_actions(r->actions);
 if (r->transformations) free_transformations(r->transformations);
 do { if (&r->id != ((void *)0)) { if (((&r->id)->len > 0) && ((&r->id)->s)) do { futex_get(mem_lock); qm_free(shm_block, ((&r->id)->s)); futex_release(mem_lock); }while(0); (&r->id)->len = 0; (&r->id)->s = 0; } } while (0);
 do { futex_get(mem_lock); qm_free(shm_block, (r)); futex_release(mem_lock); }while(0);
}

canonical_original_code:
void free_cp_rule(struct _cp_rule_t *r, void free_actions(struct cp_actions_t *a))
{
 if (!r) return;
 if (r->conditions) free_conditions(r->conditions);
 if (r->actions) free_actions(r->actions);
 if (r->transformations) free_transformations(r->transformations);
 do { if (&r->id != ((void *)0)) { if (((&r->id)->len > 0) && ((&r->id)->s)) do { futex_get(mem_lock); qm_free(shm_block, ((&r->id)->s)); futex_release(mem_lock); }while(0); (&r->id)->len = 0; (&r->id)->s = 0; } } while (0);
 do { futex_get(mem_lock); qm_free(shm_block, (r)); futex_release(mem_lock); }while(0);
}

variable_types: struct _cp_rule_t { struct _cp_rule_t *next; struct cp_conditions_t { struct cp_validity_t { long from; long to; } *validity; struct cp_identity_t { struct _cp_id_t { struct _cp_id_t *next; struct _str { char *s; int len; } entity; } *ids; struct _cp_domain_t { struct _cp_domain_t *next; struct _str domain; } *domains; struct _cp_except_t { struct _cp_except_t *next; struct _str entity; } *excepts; struct cp_any_identity_t { struct _cp_domain_t *domains; struct _cp_except_domain_t { struct _cp_except_domain_t *next; struct _str domain; } *except_domains; } *any_identity; } *identity; struct _cp_sphere_t { struct _cp_sphere_t *next; struct _str value; } *spheres; } *conditions; struct cp_actions_t { struct _cp_unknown_t { struct _cp_unknown_t *next; char data[1]; } *unknown; } *actions; struct cp_transformations_t { struct _cp_unknown_t *unknown; } *transformations; struct _str id; } *

user_defined_types: struct _cp_rule_t { struct _cp_rule_t *next; struct cp_conditions_t *conditions; struct cp_actions_t *actions; struct cp_transformations_t *transformations; struct _str id; }

user_defined_types: struct cp_actions_t { struct _cp_unknown_t *unknown; }


decompiled_code:
__int64 __fastcall free_common_rules(_QWORD **a1, void (*a2)(void))
{
_QWORD *v3; // rbx
__int64 v4; // rdi
__int64 result; // rax

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

canonical_decompiled_code:
__int64 __fastcall func10(_QWORD **a1, void (*a2)(void))
{
_QWORD *v3; // rbx
__int64 v4; // rdi
__int64 result; // rax

if ( a1 )
{
v3 = *a1;
while ( v3 )
{
v4 = (__int64)v3;
v3 = (_QWORD *)*v3;
func9(v4, a2);
}
func4(mem_lock);
qm_free(shm_block, a1);
result = func1(mem_lock);
}
return result;
}

original_code:
void free_common_rules(cp_ruleset_t *r, cp_free_actions_func free_actions)
{
 cp_rule_t *rule, *n;
 if (!r) return;
 rule = r->rules;
 while (rule) {
  n = rule->next;
  free_cp_rule(rule, free_actions);
  rule = n;
 }
 do { futex_get(mem_lock); qm_free(shm_block, (r)); futex_release(mem_lock); }while(0);
}

canonical_original_code:
void free_common_rules(struct cp_ruleset_t *r, void free_actions(struct cp_actions_t *a))
{
 struct _cp_rule_t *rule; struct _cp_rule_t *n;
 if (!r) return;
 rule = r->rules;
 while (rule) {
  n = rule->next;
  free_cp_rule(rule, free_actions);
  rule = n;
 }
 do { futex_get(mem_lock); qm_free(shm_block, (r)); futex_release(mem_lock); }while(0);
}

variable_types: struct cp_ruleset_t { struct _cp_rule_t { struct _cp_rule_t *next; struct cp_conditions_t { struct cp_validity_t { long from; long to; } *validity; struct cp_identity_t { struct _cp_id_t { struct _cp_id_t *next; struct _str { char *s; int len; } entity; } *ids; struct _cp_domain_t { struct _cp_domain_t *next; struct _str domain; } *domains; struct _cp_except_t { struct _cp_except_t *next; struct _str entity; } *excepts; struct cp_any_identity_t { struct _cp_domain_t *domains; struct _cp_except_domain_t { struct _cp_except_domain_t *next; struct _str domain; } *except_domains; } *any_identity; } *identity; struct _cp_sphere_t { struct _cp_sphere_t *next; struct _str value; } *spheres; } *conditions; struct cp_actions_t { struct _cp_unknown_t { struct _cp_unknown_t *next; char data[1]; } *unknown; } *actions; struct cp_transformations_t { struct _cp_unknown_t *unknown; } *transformations; struct _str id; } *rules; } *

user_defined_types: struct cp_ruleset_t { struct _cp_rule_t *rules; }


decompiled_code:
__int64 __fastcall is_rule_for_uri(__int64 a1, const __m128i *a2)
{
__int64 v2; // rax
__int64 **v3; // r14
__int64 *i; // rbx
__int64 *v6; // rbx
int v7; // ebp
int v8; // eax
__int64 *v9; // r13
__int64 *v10; // rdx
_QWORD *v11; // r12
_QWORD *j; // r14
_BYTE v13[16]; // [rsp-10h] [rbp-78h] BYREF
char v14[16]; // [rsp+0h] [rbp-68h] BYREF
char v15[16]; // [rsp+10h] [rbp-58h] BYREF
char v16[72]; // [rsp+20h] [rbp-48h] BYREF

if ( !a1 )
return 0LL;
v2 = *(_QWORD *)(a1 + 8);
if ( !v2 )
return 1LL;
v3 = *(__int64 ***)(v2 + 8);
if ( v3 )
{
parse_uri(a2, (__int64)v14, (__int64)v13);
for ( i = *v3; i; i = (__int64 *)*i )
{
parse_uri((const __m128i *)(i + 1), (__int64)v16, (__int64)v15);
if ( !(unsigned int)str_case_equals(v14, v16) && !(unsigned int)str_nocase_equals(v13, v15) )
return 1LL;
}
v6 = v3[1];
v7 = 0;
if ( !v6 )
goto LABEL_20;
do
{
v8 = str_nocase_equals(v13, v6 + 1);
v6 = (__int64 *)*v6;
if ( !v8 )
v7 = 1;
}
while ( v6 );
if ( v7 )
{
v9 = v3[2];
if ( !v9 )
return 1LL;
while ( (unsigned int)str_case_equals(v14, v9 + 1) )
{
v9 = (__int64 *)*v9;
if ( !v9 )
return 1LL;
}
}
else
{
LABEL_20:
v10 = v3[3];
if ( v10 )
{
v11 = (_QWORD *)*v10;
if ( *v10 )
{
while ( (unsigned int)str_nocase_equals(v13, v11 + 1) )
{
v11 = (_QWORD *)*v11;
if ( !v11 )
{
v10 = v3[3];
goto LABEL_29;
}
}
return 1LL;
}
LABEL_29:
for ( j = (_QWORD *)v10[1]; j; j = (_QWORD *)*j )
{
if ( !(unsigned int)str_nocase_equals(v13, 8LL) )
break;
}
}
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, const __m128i *a2)
{
__int64 v2; // rax
__int64 **v3; // r14
__int64 *i; // rbx
__int64 *v6; // rbx
int v7; // ebp
int v8; // eax
__int64 *v9; // r13
__int64 *v10; // rdx
_QWORD *v11; // r12
_QWORD *j; // r14
_BYTE v13[16]; // [rsp-10h] [rbp-78h] BYREF
char v14[16]; // [rsp+0h] [rbp-68h] BYREF
char v15[16]; // [rsp+10h] [rbp-58h] BYREF
char v16[72]; // [rsp+20h] [rbp-48h] BYREF

if ( !a1 )
return 0LL;
v2 = *(_QWORD *)(a1 + 8);
if ( !v2 )
return 1LL;
v3 = *(__int64 ***)(v2 + 8);
if ( v3 )
{
func2(a2, (__int64)v14, (__int64)v13);
for ( i = *v3; i; i = (__int64 *)*i )
{
func2((const __m128i *)(i + 1), (__int64)v16, (__int64)v15);
if ( !(unsigned int)str_case_equals(v14, v16) && !(unsigned int)str_nocase_equals(v13, v15) )
return 1LL;
}
v6 = v3[1];
v7 = 0;
if ( !v6 )
goto LABEL_20;
do
{
v8 = str_nocase_equals(v13, v6 + 1);
v6 = (__int64 *)*v6;
if ( !v8 )
v7 = 1;
}
while ( v6 );
if ( v7 )
{
v9 = v3[2];
if ( !v9 )
return 1LL;
while ( (unsigned int)str_case_equals(v14, v9 + 1) )
{
v9 = (__int64 *)*v9;
if ( !v9 )
return 1LL;
}
}
else
{
LABEL_20:
v10 = v3[3];
if ( v10 )
{
v11 = (_QWORD *)*v10;
if ( *v10 )
{
while ( (unsigned int)str_nocase_equals(v13, v11 + 1) )
{
v11 = (_QWORD *)*v11;
if ( !v11 )
{
v10 = v3[3];
goto LABEL_29;
}
}
return 1LL;
}
LABEL_29:
for ( j = (_QWORD *)v10[1]; j; j = (_QWORD *)*j )
{
if ( !(unsigned int)str_nocase_equals(v13, 8LL) )
break;
}
}
}
}
return 0LL;
}

original_code:
int is_rule_for_uri(cp_rule_t *rule, const str_t *uri)
{
 cp_identity_t *id;
 int ok = 0;
 str_t domain, user;
 str_t d_, u_;
 cp_domain_t *d;
 cp_id_t *i;
 cp_except_t *e;
 cp_except_domain_t *ed;
 if (!rule) return 0;
 if (!rule->conditions) return 1;
 id = rule->conditions->identity;
 if (!id) return 0;
 parse_uri(uri, &user, &domain);
 i = id->ids;
 while (i) {
  parse_uri(&i->entity, &u_, &d_);
  if (str_case_equals(&user, &u_) == 0) {
   if (str_nocase_equals(&domain, &d_) == 0) {
    return 1;
   }
  }
  i = i->next;
 }
 d = id->domains;
 while (d) {
  if (str_nocase_equals(&domain, &d->domain) == 0) ok = 1;
  d = d->next;
 }
 if (ok) {
  e = id->excepts;
  while (e) {
   if (str_case_equals(&user, &e->entity) == 0)
    return 0;
   e = e->next;
  }
  return 1;
 }
 if (id->any_identity) {
  d = id->any_identity->domains;
  while (d) {
   if (str_nocase_equals(&domain, &d->domain) == 0) {
    return 1;
   }
   d = d->next;
  }
  ed = id->any_identity->except_domains;
  while (ed) {
   if (str_nocase_equals(&domain, &d->domain) == 0) return 0;
   ed = ed->next;
  }
 }
 return 0;
}

canonical_original_code:
int is_rule_for_uri(struct _cp_rule_t *rule, struct _str *uri)
{
 struct cp_identity_t *id;
 int ok = 0;
 struct _str domain; struct _str user;
 struct _str d_; struct _str u_;
 struct _cp_domain_t *d;
 struct _cp_id_t *i;
 struct _cp_except_t *e;
 struct _cp_except_domain_t *ed;
 if (!rule) return 0;
 if (!rule->conditions) return 1;
 id = rule->conditions->identity;
 if (!id) return 0;
 parse_uri(uri, &user, &domain);
 i = id->ids;
 while (i) {
  parse_uri(&i->entity, &u_, &d_);
  if (str_case_equals(&user, &u_) == 0) {
   if (str_nocase_equals(&domain, &d_) == 0) {
    return 1;
   }
  }
  i = i->next;
 }
 d = id->domains;
 while (d) {
  if (str_nocase_equals(&domain, &d->domain) == 0) ok = 1;
  d = d->next;
 }
 if (ok) {
  e = id->excepts;
  while (e) {
   if (str_case_equals(&user, &e->entity) == 0)
    return 0;
   e = e->next;
  }
  return 1;
 }
 if (id->any_identity) {
  d = id->any_identity->domains;
  while (d) {
   if (str_nocase_equals(&domain, &d->domain) == 0) {
    return 1;
   }
   d = d->next;
  }
  ed = id->any_identity->except_domains;
  while (ed) {
   if (str_nocase_equals(&domain, &d->domain) == 0) return 0;
   ed = ed->next;
  }
 }
 return 0;
}

variable_types:
uri
struct _str *

variable_types: struct cp_identity_t { struct _cp_id_t { struct _cp_id_t *next; struct _str { char *s; int len; } entity; } *ids; struct _cp_domain_t { struct _cp_domain_t *next; struct _str domain; } *domains; struct _cp_except_t { struct _cp_except_t *next; struct _str entity; } *excepts; struct cp_any_identity_t { struct _cp_domain_t *domains; struct _cp_except_domain_t { struct _cp_except_domain_t *next; struct _str domain; } *except_domains; } *any_identity; } *

variable_types: ok int

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

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

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

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

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

return_type: int

user_defined_types: struct cp_validity_t { long from; long to; }

user_defined_types: struct _cp_sphere_t { struct _cp_sphere_t *next; struct _str value; }

user_defined_types: struct _cp_unknown_t { struct _cp_unknown_t *next; char data[1]; }


decompiled_code:
__int64 __fastcall parse_pai_ppi_body(const char *a1, unsigned int a2, __int64 *a3)
{
_BYTE *v4; // rax
__int64 *v5; // r15
__int64 v6; // r14
__int64 v7; // rbp
__int64 v8; // rax
__int64 v9; // rbp
__int64 v10; // r15
__int64 v11; // rax
_QWORD *v12; // rcx
__int64 v13; // r14
__int64 *v14; // rsi
__int64 *v15; // rcx
_QWORD *v16; // rcx
__int64 v17; // r8
unsigned int v18; // ebx
const char *v20; // r15
unsigned int v21; // eax
const char *v22; // r14
unsigned int v23; // eax
const char *v24; // r15
unsigned int v25; // eax
int v26; // eax
const char *v27; // rbx
unsigned int v28; // eax
struct _IO_FILE *v29; // rdi
const char *v30; // r15
unsigned int v31; // eax
__int64 v32; // [rsp-10h] [rbp-58h]
int v33; // [rsp+Ch] [rbp-3Ch]
int v34; // [rsp+Ch] [rbp-3Ch]

memset(uri_b_3, 0, 0x1270uLL);
v4 = (_BYTE *)parse_addr_spec(a1, &a1[a2], uri_b_3, 1LL);
if ( LODWORD(uri_b_3[0]) == -1 )
{
v33 = uri_b_3[0];
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
v26 = v33;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Error parsing PAI/PPI body %u '%.*s'\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_ppi_pai.c:62]: ",
"parse_pai_ppi_body",
0LL,
a2,
a1);
LABEL_29:
v18 = v33;
goto LABEL_30;
}
if ( log_color )
{
dprint_color(0xFFFFFFFFLL);
v26 = v33;
}
v34 = v26;
v30 = (const char *)*((_QWORD *)&log_level_info + 8);
v31 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Error parsing PAI/PPI body %u '%.*s'\n",
process_no,
v31,
v30,
"<core> [parser/parse_ppi_pai.c:62]: ",
"parse_pai_ppi_body",
0LL,
a2,
a1);
LABEL_36:
v18 = v34;
if ( log_color )
{
((void (*)(void))dprint_color_reset)();
v18 = v34;
}
LABEL_30:
--dprint_crit;
return v18;
}
return (unsigned int)-1;
}
v5 = qword_EF8;
v6 = 1LL;
if ( *v4 == 44 )
{
while ( 1 )
{
v4 = (_BYTE *)parse_addr_spec(v4 + 1, &a1[a2], v5, 1LL);
if ( *(_DWORD *)v5 == -1 )
break;
v6 = (unsigned int)(v6 + 1);
if ( *v4 != 44 )
{
v7 = 472LL * (int)v6 + 24;
if ( (_DWORD)v6 != 10 )
goto LABEL_18;
goto LABEL_7;
}
v5 += 59;
if ( (_DWORD)v6 == 10 )
{
v7 = 4744LL;
LABEL_7:
if ( (int)get_debug_level("core", 4LL) >= 0 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0LL);
v24 = (const char *)*((_QWORD *)&log_level_info + 10);
v25 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Too many bodies in PAI/PPI header '%.*s'\n",
process_no,
v25,
v24,
"<core> [parser/parse_ppi_pai.c:79]: ",
"parse_pai_ppi_body",
a2,
a1);
if ( log_color )
((void (*)(void))dprint_color_reset)();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 22) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Too many bodies in PAI/PPI header '%.*s'\n",
*((_QWORD *)&log_level_info + 10),
"<core> [parser/parse_ppi_pai.c:79]: ",
"parse_pai_ppi_body",
a2);
}
--dprint_crit;
}
LODWORD(v6) = 10;
if ( (int)get_debug_level("core", 4LL) >= 0 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0LL);
v22 = (const char *)*((_QWORD *)&log_level_info + 10);
v23 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Ignoring bodies beyond %u\n",
process_no,
v23,
v22,
"<core> [parser/parse_ppi_pai.c:80]: ",
"parse_pai_ppi_body",
10LL);
if ( log_color )
dprint_color_reset(v32);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 22) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Ignoring bodies beyond %u\n",
*((const char **)&log_level_info + 10),
"<core> [parser/parse_ppi_pai.c:80]: ",
"parse_pai_ppi_body",
10LL);
}
LODWORD(v6) = 10;
--dprint_crit;
}
goto LABEL_18;
}
}
if ( (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
return (unsigned int)-1;
++dprint_crit;
if ( !log_stderr )
{
v33 = -1;
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Error parsing PAI/PPI body %u '%.*s'\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_ppi_pai.c:72]: ",
"parse_pai_ppi_body",
(unsigned int)v6,
a2,
a1);
goto LABEL_29;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v34 = -1;
v20 = (const char *)*((_QWORD *)&log_level_info + 8);
v21 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Error parsing PAI/PPI body %u '%.*s'\n",
process_no,
v21,
v20,
"<core> [parser/parse_ppi_pai.c:72]: ",
"parse_pai_ppi_body",
v6,
a2,
a1);
goto LABEL_36;
}
v7 = 496LL;
LABEL_18:
v8 = qm_malloc(mem_block, v7);
*a3 = v8;
if ( v8 )
{
*(_QWORD *)(v8 + 16) = 0LL;
*(_OWORD *)v8 = 0LL;
v9 = *a3;
v10 = 472LL * (int)v6;
v11 = 0LL;
v12 = (_QWORD *)(*a3 + 24);
*(_DWORD *)(v9 + 8) = v6;
*(_QWORD *)v9 = v12;
if ( (v6 & 1) == 0 )
{
v11 = 59LL;
*v12 = uri_b_3[0];
*(_QWORD *)(v9 + 488) = qword_EF0[0];
qmemcpy(
(void *)((v9 + 32) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)uri_b_3 - ((char *)v12 - ((v9 + 32) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v12 - (((_DWORD)v9 + 32) & 0xFFFFFFF8) + 472) >> 3));
v12 = *(_QWORD **)*a3;
}
while ( 1 )
{
v16 = &v12[v11];
v17 = v11 * 8 + 472;
*v16 = uri_b_3[v11];
v16[58] = qword_EF0[v11];
qmemcpy(
(void *)((unsigned __int64)(v16 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)&uri_b_3[v11] - ((char *)v16 - ((unsigned __int64)(v16 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v16 - (((_DWORD)v16 + 8) & 0xFFFFFFF8) + 472) >> 3));
if ( v10 == v11 * 8 + 472 )
break;
v13 = qword_EF8[v11];
v14 = &qword_EF8[v11];
v11 += 118LL;
v15 = (__int64 *)(v17 + *(_QWORD *)*a3);
*v15 = v13;
v15[58] = *(_QWORD *)(v11 * 8 + 3352);
qmemcpy(
(void *)((unsigned __int64)(v15 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)v14 - ((char *)v15 - ((unsigned __int64)(v15 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v15 - (((_DWORD)v15 + 8) & 0xFFFFFFF8) + 472) >> 3));
v12 = *(_QWORD **)*a3;
}
return 0;
}
if ( (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
return (unsigned int)-1;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v27 = (const char *)*((_QWORD *)&log_level_info + 8);
v28 = my_pid();
v29 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): No pkg memory for pai/ppi body\n",
process_no,
v28,
v27,
"<core> [parser/parse_ppi_pai.c:85]: ",
"parse_pai_ppi_body");
if ( log_color )
dprint_color_reset(v29);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): No pkg memory for pai/ppi body\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_ppi_pai.c:85]: ",
"parse_pai_ppi_body");
}
v18 = -1;
--dprint_crit;
return v18;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, unsigned int a2, __int64 *a3)
{
_BYTE *v4; // rax
__int64 *v5; // r15
__int64 v6; // r14
__int64 v7; // rbp
__int64 v8; // rax
__int64 v9; // rbp
__int64 v10; // r15
__int64 v11; // rax
_QWORD *v12; // rcx
__int64 v13; // r14
__int64 *v14; // rsi
__int64 *v15; // rcx
_QWORD *v16; // rcx
__int64 v17; // r8
unsigned int v18; // ebx
const char *v20; // r15
unsigned int v21; // eax
const char *v22; // r14
unsigned int v23; // eax
const char *v24; // r15
unsigned int v25; // eax
int v26; // eax
const char *v27; // rbx
unsigned int v28; // eax
struct _IO_FILE *v29; // rdi
const char *v30; // r15
unsigned int v31; // eax
__int64 v32; // [rsp-10h] [rbp-58h]
int v33; // [rsp+Ch] [rbp-3Ch]
int v34; // [rsp+Ch] [rbp-3Ch]

memset(uri_b_3, 0, 0x1270uLL);
v4 = (_BYTE *)parse_addr_spec(a1, &a1[a2], uri_b_3, 1LL);
if ( LODWORD(uri_b_3[0]) == -1 )
{
v33 = uri_b_3[0];
if ( (int)get_debug_level("core", 4LL) >= -1 && !dprint_crit )
{
v26 = v33;
++dprint_crit;
if ( !log_stderr )
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Error parsing PAI/PPI body %u '%.*s'\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_ppi_pai.c:62]: ",
"parse_pai_ppi_body",
0LL,
a2,
a1);
LABEL_29:
v18 = v33;
goto LABEL_30;
}
if ( log_color )
{
dprint_color(0xFFFFFFFFLL);
v26 = v33;
}
v34 = v26;
v30 = (const char *)*((_QWORD *)&log_level_info + 8);
v31 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Error parsing PAI/PPI body %u '%.*s'\n",
process_no,
v31,
v30,
"<core> [parser/parse_ppi_pai.c:62]: ",
"parse_pai_ppi_body",
0LL,
a2,
a1);
LABEL_36:
v18 = v34;
if ( log_color )
{
((void (*)(void))dprint_color_reset)();
v18 = v34;
}
LABEL_30:
--dprint_crit;
return v18;
}
return (unsigned int)-1;
}
v5 = qword_EF8;
v6 = 1LL;
if ( *v4 == 44 )
{
while ( 1 )
{
v4 = (_BYTE *)parse_addr_spec(v4 + 1, &a1[a2], v5, 1LL);
if ( *(_DWORD *)v5 == -1 )
break;
v6 = (unsigned int)(v6 + 1);
if ( *v4 != 44 )
{
v7 = 472LL * (int)v6 + 24;
if ( (_DWORD)v6 != 10 )
goto LABEL_18;
goto LABEL_7;
}
v5 += 59;
if ( (_DWORD)v6 == 10 )
{
v7 = 4744LL;
LABEL_7:
if ( (int)get_debug_level("core", 4LL) >= 0 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0LL);
v24 = (const char *)*((_QWORD *)&log_level_info + 10);
v25 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Too many bodies in PAI/PPI header '%.*s'\n",
process_no,
v25,
v24,
"<core> [parser/parse_ppi_pai.c:79]: ",
"parse_pai_ppi_body",
a2,
a1);
if ( log_color )
((void (*)(void))dprint_color_reset)();
}
else
{
syslog(
*((_DWORD *)&log_level_info + 22) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Too many bodies in PAI/PPI header '%.*s'\n",
*((_QWORD *)&log_level_info + 10),
"<core> [parser/parse_ppi_pai.c:79]: ",
"parse_pai_ppi_body",
a2);
}
--dprint_crit;
}
LODWORD(v6) = 10;
if ( (int)get_debug_level("core", 4LL) >= 0 && !dprint_crit )
{
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0LL);
v22 = (const char *)*((_QWORD *)&log_level_info + 10);
v23 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Ignoring bodies beyond %u\n",
process_no,
v23,
v22,
"<core> [parser/parse_ppi_pai.c:80]: ",
"parse_pai_ppi_body",
10LL);
if ( log_color )
dprint_color_reset(v32);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 22) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Ignoring bodies beyond %u\n",
*((const char **)&log_level_info + 10),
"<core> [parser/parse_ppi_pai.c:80]: ",
"parse_pai_ppi_body",
10LL);
}
LODWORD(v6) = 10;
--dprint_crit;
}
goto LABEL_18;
}
}
if ( (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
return (unsigned int)-1;
++dprint_crit;
if ( !log_stderr )
{
v33 = -1;
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): Error parsing PAI/PPI body %u '%.*s'\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_ppi_pai.c:72]: ",
"parse_pai_ppi_body",
(unsigned int)v6,
a2,
a1);
goto LABEL_29;
}
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v34 = -1;
v20 = (const char *)*((_QWORD *)&log_level_info + 8);
v21 = my_pid();
fprintf(
stderr,
"%2d(%d) %s: %s%s(): Error parsing PAI/PPI body %u '%.*s'\n",
process_no,
v21,
v20,
"<core> [parser/parse_ppi_pai.c:72]: ",
"parse_pai_ppi_body",
v6,
a2,
a1);
goto LABEL_36;
}
v7 = 496LL;
LABEL_18:
v8 = qm_malloc(mem_block, v7);
*a3 = v8;
if ( v8 )
{
*(_QWORD *)(v8 + 16) = 0LL;
*(_OWORD *)v8 = 0LL;
v9 = *a3;
v10 = 472LL * (int)v6;
v11 = 0LL;
v12 = (_QWORD *)(*a3 + 24);
*(_DWORD *)(v9 + 8) = v6;
*(_QWORD *)v9 = v12;
if ( (v6 & 1) == 0 )
{
v11 = 59LL;
*v12 = uri_b_3[0];
*(_QWORD *)(v9 + 488) = qword_EF0[0];
qmemcpy(
(void *)((v9 + 32) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)uri_b_3 - ((char *)v12 - ((v9 + 32) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v12 - (((_DWORD)v9 + 32) & 0xFFFFFFF8) + 472) >> 3));
v12 = *(_QWORD **)*a3;
}
while ( 1 )
{
v16 = &v12[v11];
v17 = v11 * 8 + 472;
*v16 = uri_b_3[v11];
v16[58] = qword_EF0[v11];
qmemcpy(
(void *)((unsigned __int64)(v16 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)&uri_b_3[v11] - ((char *)v16 - ((unsigned __int64)(v16 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v16 - (((_DWORD)v16 + 8) & 0xFFFFFFF8) + 472) >> 3));
if ( v10 == v11 * 8 + 472 )
break;
v13 = qword_EF8[v11];
v14 = &qword_EF8[v11];
v11 += 118LL;
v15 = (__int64 *)(v17 + *(_QWORD *)*a3);
*v15 = v13;
v15[58] = *(_QWORD *)(v11 * 8 + 3352);
qmemcpy(
(void *)((unsigned __int64)(v15 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)v14 - ((char *)v15 - ((unsigned __int64)(v15 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v15 - (((_DWORD)v15 + 8) & 0xFFFFFFF8) + 472) >> 3));
v12 = *(_QWORD **)*a3;
}
return 0;
}
if ( (int)get_debug_level("core", 4LL) < -1 || dprint_crit )
return (unsigned int)-1;
++dprint_crit;
if ( log_stderr )
{
if ( log_color )
dprint_color(0xFFFFFFFFLL);
v27 = (const char *)*((_QWORD *)&log_level_info + 8);
v28 = my_pid();
v29 = stderr;
fprintf(
stderr,
"%2d(%d) %s: %s%s(): No pkg memory for pai/ppi body\n",
process_no,
v28,
v27,
"<core> [parser/parse_ppi_pai.c:85]: ",
"parse_pai_ppi_body");
if ( log_color )
dprint_color_reset(v29);
}
else
{
syslog(
*((_DWORD *)&log_level_info + 18) | *(_DWORD *)(core_cfg + 4LL),
"%s: %s%s(): No pkg memory for pai/ppi body\n",
*((const char **)&log_level_info + 8),
"<core> [parser/parse_ppi_pai.c:85]: ",
"parse_pai_ppi_body");
}
v18 = -1;
--dprint_crit;
return v18;
}

original_code:
int parse_pai_ppi_body(char *buf, int len, p_id_body_t **body)
{
 static to_body_t uri_b[10];
 int num_uri = 0;
 char *tmp;
 int i;
 memset(uri_b, 0, 10 * sizeof(to_body_t));
 tmp = parse_addr_spec(buf, buf+len, &uri_b[num_uri], 1);
 if (uri_b[num_uri].error == -1)
 {
  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(): " "Error parsing PAI/PPI body %u '%.*s'\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "62" "]: ") , __func__, num_uri, len, buf); 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(): " "Error parsing PAI/PPI body %u '%.*s'\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "62" "]: ") , __func__, num_uri, len, buf); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Error parsing PAI/PPI body %u '%.*s'\n", process_no, my_pid(), ("<core> [" "parser/parse_ppi_pai.c" ":" "62" "]: ") , __func__, num_uri, len, buf); 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(): " "Error parsing PAI/PPI body %u '%.*s'\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "62" "]: ") , __func__, num_uri, len, buf); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Error parsing PAI/PPI body %u '%.*s'\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "62" "]: ") , __func__, num_uri, len, buf); } } (dprint_crit--); } } while(0);
  return -1;
 }
 num_uri++;
 while ((*tmp == ',') && (num_uri < 10))
 {
  tmp++;
  tmp = parse_addr_spec(tmp, buf+len, &uri_b[num_uri], 1);
  if (uri_b[num_uri].error == -1)
  {
   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(): " "Error parsing PAI/PPI body %u '%.*s'\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "72" "]: ") , __func__, num_uri, len, buf); 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(): " "Error parsing PAI/PPI body %u '%.*s'\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "72" "]: ") , __func__, num_uri, len, buf); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Error parsing PAI/PPI body %u '%.*s'\n", process_no, my_pid(), ("<core> [" "parser/parse_ppi_pai.c" ":" "72" "]: ") , __func__, num_uri, len, buf); 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(): " "Error parsing PAI/PPI body %u '%.*s'\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "72" "]: ") , __func__, num_uri, len, buf); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Error parsing PAI/PPI body %u '%.*s'\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "72" "]: ") , __func__, num_uri, len, buf); } } (dprint_crit--); } } while(0);
   return -1;
  }
  num_uri++;
 }
 if (num_uri >= 10)
 {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((0)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((0)) >= -5) && (((0)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Too many bodies in PAI/PPI header '%.*s'\n", process_no, my_pid(), (log_level_info[((0)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "79" "]: ") , __func__, len, buf); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((0)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Too many bodies in PAI/PPI header '%.*s'\n", (log_level_info[((0)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "79" "]: ") , __func__, len, buf); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Too many bodies in PAI/PPI header '%.*s'\n", process_no, my_pid(), ("<core> [" "parser/parse_ppi_pai.c" ":" "79" "]: ") , __func__, len, buf); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((0))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Too many bodies in PAI/PPI header '%.*s'\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "79" "]: ") , __func__, len, buf); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Too many bodies in PAI/PPI header '%.*s'\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "79" "]: ") , __func__, len, buf); } } (dprint_crit--); } } while(0);
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((0)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((0)) >= -5) && (((0)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Ignoring bodies beyond %u\n", process_no, my_pid(), (log_level_info[((0)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "80" "]: ") , __func__, 10); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((0)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Ignoring bodies beyond %u\n", (log_level_info[((0)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "80" "]: ") , __func__, 10); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Ignoring bodies beyond %u\n", process_no, my_pid(), ("<core> [" "parser/parse_ppi_pai.c" ":" "80" "]: ") , __func__, 10); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((0))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Ignoring bodies beyond %u\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "80" "]: ") , __func__, 10); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Ignoring bodies beyond %u\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "80" "]: ") , __func__, 10); } } (dprint_crit--); } } while(0);
 }
 *body = qm_malloc(mem_block, (sizeof(p_id_body_t) + num_uri * sizeof(to_body_t)));
 if (*body == ((void *)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(): " "No pkg memory for pai/ppi body\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "85" "]: ") , __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(): " "No pkg memory for pai/ppi body\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "85" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "No pkg memory for pai/ppi body\n", process_no, my_pid(), ("<core> [" "parser/parse_ppi_pai.c" ":" "85" "]: ") , __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(): " "No pkg memory for pai/ppi body\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "85" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "No pkg memory for pai/ppi body\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "85" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(*body, 0, sizeof(p_id_body_t));
 (*body)->id = (to_body_t*)((char*)(*body) + sizeof(p_id_body_t));
 (*body)->num_ids = num_uri;
 for (i=0; i< num_uri; i++)
 {
  memcpy(&(*body)->id[i], &uri_b[i], sizeof(to_body_t));
 }
 return 0;
}

canonical_original_code:
int parse_pai_ppi_body(char *buf, int len, struct p_id_body **body)
{
 static struct to_body uri_b[10];
 int num_uri = 0;
 char *tmp;
 int i;
 memset(uri_b, 0, 10 * sizeof(to_body_t));
 tmp = parse_addr_spec(buf, buf+len, &uri_b[num_uri], 1);
 if (uri_b[num_uri].error == -1)
 {
  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(): " "Error parsing PAI/PPI body %u '%.*s'\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "62" "]: ") , __func__, num_uri, len, buf); 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(): " "Error parsing PAI/PPI body %u '%.*s'\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "62" "]: ") , __func__, num_uri, len, buf); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Error parsing PAI/PPI body %u '%.*s'\n", process_no, my_pid(), ("<core> [" "parser/parse_ppi_pai.c" ":" "62" "]: ") , __func__, num_uri, len, buf); 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(): " "Error parsing PAI/PPI body %u '%.*s'\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "62" "]: ") , __func__, num_uri, len, buf); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Error parsing PAI/PPI body %u '%.*s'\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "62" "]: ") , __func__, num_uri, len, buf); } } (dprint_crit--); } } while(0);
  return -1;
 }
 num_uri++;
 while ((*tmp == ',') && (num_uri < 10))
 {
  tmp++;
  tmp = parse_addr_spec(tmp, buf+len, &uri_b[num_uri], 1);
  if (uri_b[num_uri].error == -1)
  {
   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(): " "Error parsing PAI/PPI body %u '%.*s'\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "72" "]: ") , __func__, num_uri, len, buf); 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(): " "Error parsing PAI/PPI body %u '%.*s'\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "72" "]: ") , __func__, num_uri, len, buf); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Error parsing PAI/PPI body %u '%.*s'\n", process_no, my_pid(), ("<core> [" "parser/parse_ppi_pai.c" ":" "72" "]: ") , __func__, num_uri, len, buf); 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(): " "Error parsing PAI/PPI body %u '%.*s'\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "72" "]: ") , __func__, num_uri, len, buf); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Error parsing PAI/PPI body %u '%.*s'\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "72" "]: ") , __func__, num_uri, len, buf); } } (dprint_crit--); } } while(0);
   return -1;
  }
  num_uri++;
 }
 if (num_uri >= 10)
 {
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((0)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((0)) >= -5) && (((0)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Too many bodies in PAI/PPI header '%.*s'\n", process_no, my_pid(), (log_level_info[((0)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "79" "]: ") , __func__, len, buf); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((0)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Too many bodies in PAI/PPI header '%.*s'\n", (log_level_info[((0)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "79" "]: ") , __func__, len, buf); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Too many bodies in PAI/PPI header '%.*s'\n", process_no, my_pid(), ("<core> [" "parser/parse_ppi_pai.c" ":" "79" "]: ") , __func__, len, buf); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((0))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Too many bodies in PAI/PPI header '%.*s'\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "79" "]: ") , __func__, len, buf); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Too many bodies in PAI/PPI header '%.*s'\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "79" "]: ") , __func__, len, buf); } } (dprint_crit--); } } while(0);
  do { if (get_debug_level("core", (sizeof("core")-1)) >= ((0)) && (dprint_crit==0)) { (dprint_crit++); if (__builtin_expect(!!((((0)) >= -5) && (((0)) <= 3)), 1)){ if (__builtin_expect(!!(log_stderr), 0)) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s: %s" "%s(): " "Ignoring bodies beyond %u\n", process_no, my_pid(), (log_level_info[((0)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "80" "]: ") , __func__, 10); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { syslog((log_level_info[((0)) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s: %s" "%s(): " "Ignoring bodies beyond %u\n", (log_level_info[((0)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "80" "]: ") , __func__, 10); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((0)); fprintf(stderr, "%2d(%d) %s" "%s(): " "Ignoring bodies beyond %u\n", process_no, my_pid(), ("<core> [" "parser/parse_ppi_pai.c" ":" "80" "]: ") , __func__, 10); if (__builtin_expect(!!(log_color), 0)) dprint_color_reset(); } else { if (((0))<-5) syslog((log_level_info[(-5) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Ignoring bodies beyond %u\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "80" "]: ") , __func__, 10); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "Ignoring bodies beyond %u\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "80" "]: ") , __func__, 10); } } (dprint_crit--); } } while(0);
 }
 *body = qm_malloc(mem_block, (sizeof(p_id_body_t) + num_uri * sizeof(to_body_t)));
 if (*body == ((void *)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(): " "No pkg memory for pai/ppi body\n", process_no, my_pid(), (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "85" "]: ") , __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(): " "No pkg memory for pai/ppi body\n", (log_level_info[((-1)) - (-5)].name), ("<core> [" "parser/parse_ppi_pai.c" ":" "85" "]: ") , __func__); } } else { if (log_stderr) { if (__builtin_expect(!!(log_color), 0)) dprint_color((-1)); fprintf(stderr, "%2d(%d) %s" "%s(): " "No pkg memory for pai/ppi body\n", process_no, my_pid(), ("<core> [" "parser/parse_ppi_pai.c" ":" "85" "]: ") , __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(): " "No pkg memory for pai/ppi body\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "85" "]: ") , __func__); else syslog((log_level_info[(3) - (-5)].syslog_level) | (((0) != 0) ? (0) : ((struct cfg_group_core *)core_cfg)->log_facility), "%s" "%s(): " "No pkg memory for pai/ppi body\n", ("<core> [" "parser/parse_ppi_pai.c" ":" "85" "]: ") , __func__); } } (dprint_crit--); } } while(0);
  return -1;
 }
 memset(*body, 0, sizeof(p_id_body_t));
 (*body)->id = (struct to_body *)((char *)(*body) + sizeof(p_id_body_t));
 (*body)->num_ids = num_uri;
 for (i=0; i< num_uri; i++)
 {
  memcpy(&(*body)->id[i], &uri_b[i], sizeof(to_body_t));
 }
 return 0;
}

variable_types:
buf
char *

variable_types: len int

variable_types: struct p_id_body { struct to_body { int error; struct _str { char *s; int len; } body; struct _str uri; struct _str display; struct _str tag_value; struct sip_uri { struct _str user; struct _str passwd; struct _str host; struct _str port; struct _str params; struct _str sip_params; struct _str headers; unsigned short port_no; unsigned short proto; enum _uri_type { ERROR_URI_T=0, SIP_URI_T=1, SIPS_URI_T=2, TEL_URI_T=3, TELS_URI_T=4, URN_URI_T=5 } type; enum _uri_flags { URI_USER_NORMALIZE=1, URI_SIP_USER_PHONE=2 } flags; struct _str transport; struct _str ttl; struct _str user_param; struct _str maddr; struct _str method; struct _str lr; struct _str r2; struct _str gr; struct _str transport_val; struct _str ttl_val; struct _str user_param_val; struct _str maddr_val; struct _str method_val; struct _str lr_val; struct _str r2_val; struct _str gr_val; } parsed_uri; struct to_param { int type; struct _str name; struct _str value; struct to_param *next; } *param_lst; struct to_param *last_param; } *id; int num_ids; struct p_id_body *next; } **

variable_types: struct to_body { int error; struct _str { char *s; int len; } body; struct _str uri; struct _str display; struct _str tag_value; struct sip_uri { struct _str user; struct _str passwd; struct _str host; struct _str port; struct _str params; struct _str sip_params; struct _str headers; unsigned short port_no; unsigned short proto; enum _uri_type { ERROR_URI_T=0, SIP_URI_T=1, SIPS_URI_T=2, TEL_URI_T=3, TELS_URI_T=4, URN_URI_T=5 } type; enum _uri_flags { URI_USER_NORMALIZE=1, URI_SIP_USER_PHONE=2 } flags; struct _str transport; struct _str ttl; struct _str user_param; struct _str maddr; struct _str method; struct _str lr; struct _str r2; struct _str gr; struct _str transport_val; struct _str ttl_val; struct _str user_param_val; struct _str maddr_val; struct _str method_val; struct _str lr_val; struct _str r2_val; struct _str gr_val; } parsed_uri; struct to_param { int type; struct _str name; struct _str value; struct to_param *next; } *param_lst; struct to_param *last_param; } [10]

variable_types:
tmp
char *

user_defined_types: struct to_body { int error; struct _str body; struct _str uri; struct _str display; struct _str tag_value; struct sip_uri parsed_uri; struct to_param *param_lst; struct to_param *last_param; }

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 p_id_body { struct to_body *id; int num_ids; struct p_id_body *next; }

user_defined_types: struct sip_uri { struct _str user; struct _str passwd; struct _str host; struct _str port; struct _str params; struct _str sip_params; struct _str headers; unsigned short port_no; unsigned short proto; enum _uri_type type; enum _uri_flags flags; struct _str transport; struct _str ttl; struct _str user_param; struct _str maddr; struct _str method; struct _str lr; struct _str r2; struct _str gr; struct _str transport_val; struct _str ttl_val; struct _str user_param_val; struct _str maddr_val; struct _str method_val; struct _str lr_val; struct _str r2_val; struct _str gr_val; }


decompiled_code:
__int64 __fastcall free_pai_ppi_body(__int64 a1)
{
if ( a1 )
qm_free(mem_block, a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
if ( a1 )
qm_free(mem_block, a1);
return 0LL;
}

original_code:
int free_pai_ppi_body(p_id_body_t *pid_b)
{
 if (pid_b != ((void *)0))
 {
  qm_free(mem_block, (pid_b));
 }
 return 0;
}

canonical_original_code:
int free_pai_ppi_body(struct p_id_body *pid_b)
{
 if (pid_b != ((void *)0))
 {
  qm_free(mem_block, (pid_b));
 }
 return 0;
}

variable_types: struct p_id_body { struct to_body { int error; struct _str { char *s; int len; } body; struct _str uri; struct _str display; struct _str tag_value; struct sip_uri { struct _str user; struct _str passwd; struct _str host; struct _str port; struct _str params; struct _str sip_params; struct _str headers; unsigned short port_no; unsigned short proto; enum _uri_type { ERROR_URI_T=0, SIP_URI_T=1, SIPS_URI_T=2, TEL_URI_T=3, TELS_URI_T=4, URN_URI_T=5 } type; enum _uri_flags { URI_USER_NORMALIZE=1, URI_SIP_USER_PHONE=2 } flags; struct _str transport; struct _str ttl; struct _str user_param; struct _str maddr; struct _str method; struct _str lr; struct _str r2; struct _str gr; struct _str transport_val; struct _str ttl_val; struct _str user_param_val; struct _str maddr_val; struct _str method_val; struct _str lr_val; struct _str r2_val; struct _str gr_val; } parsed_uri; struct to_param { int type; struct _str name; struct _str value; struct to_param *next; } *param_lst; struct to_param *last_param; } *id; int num_ids; struct p_id_body *next; } *


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


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


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

variable_types: i int


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

variable_types:
size
unsigned int

variable_types:
p
void *


decompiled_code:
__int64 __fastcall ht_init(__int64 a1, __int64 a2, __int64 a3, int a4)
{
__int64 v6; // r14
void *v7; // rax
__int64 result; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
if ( !a3 )
return 0xFFFFFFFFLL;
v6 = a4;
v7 = (void *)shm_malloc(24 * a4);
*(_QWORD *)(a1 + 16) = v7;
if ( !v7 )
return 0xFFFFFFFFLL;
memset(v7, 0, 24 * v6);
*(_DWORD *)(a1 + 24) = a4;
result = 0LL;
*(_QWORD *)a1 = a2;
*(_QWORD *)(a1 + 8) = a3;
*(_QWORD *)(a1 + 28) = 0LL;
*(_QWORD *)(a1 + 36) = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2, __int64 a3, int a4)
{
__int64 v6; // r14
void *v7; // rax
__int64 result; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
if ( !a3 )
return 0xFFFFFFFFLL;
v6 = a4;
v7 = (void *)func4(24 * a4);
*(_QWORD *)(a1 + 16) = v7;
if ( !v7 )
return 0xFFFFFFFFLL;
memset(v7, 0, 24 * v6);
*(_DWORD *)(a1 + 24) = a4;
result = 0LL;
*(_QWORD *)a1 = a2;
*(_QWORD *)(a1 + 8) = a3;
*(_QWORD *)(a1 + 28) = 0LL;
*(_QWORD *)(a1 + 36) = 0LL;
return result;
}

original_code:
int ht_init(hash_table_t *ht, hash_func_t hash_func, key_cmp_func_t cmp_keys, int size)
{
 if (!ht) return -1;
 if ((!hash_func) || (!cmp_keys)) return -1;
 ht->cslots = (ht_cslot_t*)shm_malloc(size * sizeof(ht_cslot_t));
 if (!ht->cslots) return -1;
 memset(ht->cslots, 0, size * sizeof(ht_cslot_t));
 ht->size = size;
 ht->hash = hash_func;
 ht->cmp = cmp_keys;
 ht->find_cnt = 0;
 ht->cmp_cnt = 0;
 ht->nocmp_cnt = 0;
 ht->missed_cnt = 0;
 return 0;
}

canonical_original_code:
int ht_init(struct hash_table *ht, unsigned int (*hash_func)(void *k), int (*cmp_keys)(void *a, void *b), int size)
{
 if (!ht) return -1;
 if ((!hash_func) || (!cmp_keys)) return -1;
 ht->cslots = (struct ht_cslot *)shm_malloc(size * sizeof(ht_cslot_t));
 if (!ht->cslots) return -1;
 memset(ht->cslots, 0, size * sizeof(ht_cslot_t));
 ht->size = size;
 ht->hash = hash_func;
 ht->cmp = cmp_keys;
 ht->find_cnt = 0;
 ht->cmp_cnt = 0;
 ht->nocmp_cnt = 0;
 ht->missed_cnt = 0;
 return 0;
}

variable_types: struct hash_table { unsigned int (*hash)(void *k); int (*cmp)(void *a, void *b); struct ht_cslot { struct ht_element { void *key; void *data; struct ht_element *next; } *first; struct ht_element *last; int cnt; } *cslots; int size; int find_cnt; int cmp_cnt; int nocmp_cnt; int missed_cnt; } *

variable_types: size int

user_defined_types: struct hash_table { unsigned int (*hash)(void *k); int (*cmp)(void *a, void *b); struct ht_cslot *cslots; int size; int find_cnt; int cmp_cnt; int nocmp_cnt; int missed_cnt; }

user_defined_types: struct ht_cslot { struct ht_element *first; struct ht_element *last; int cnt; }


decompiled_code:
void __fastcall ht_destroy(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // r14
__int64 v3; // rbx
__int64 v4; // r12

if ( a1 )
{
v1 = *(_QWORD *)(a1 + 16);
if ( v1 )
{
if ( *(int *)(a1 + 24) > 0 )
{
v2 = 0LL;
while ( 1 )
{
v3 = *(_QWORD *)(v1 + 24 * v2);
while ( v3 )
{
v4 = v3;
v3 = *(_QWORD *)(v3 + 16);
futex_get(mem_lock);
qm_free(shm_block, v4);
futex_release(mem_lock);
}
if ( *(_DWORD *)(a1 + 24) <= (int)++v2 )
break;
v1 = *(_QWORD *)(a1 + 16);
}
}
futex_get(mem_lock);
qm_free(shm_block, *(_QWORD *)(a1 + 16));
futex_release(mem_lock);
}
*(_QWORD *)(a1 + 16) = 0LL;
}
}

original_code:
void ht_destroy(hash_table_t *ht)
{
 ht_element_t *e, *n;
 int i;
 if (!ht) return;
 if (ht->cslots) {
  for (i = 0; i < ht->size; i++) {
   e = ht->cslots[i].first;
   while (e) {
    n = e->next;
    do { futex_get(mem_lock); qm_free(shm_block, (e)); futex_release(mem_lock); }while(0);
    e = n;
   }
  }
  do { futex_get(mem_lock); qm_free(shm_block, (ht->cslots)); futex_release(mem_lock); }while(0);
 }
 ht->cslots = ((void *)0);
}

canonical_original_code:
void ht_destroy(struct hash_table *ht)
{
 struct ht_element *e; struct ht_element *n;
 int i;
 if (!ht) return;
 if (ht->cslots) {
  for (i = 0; i < ht->size; i++) {
   e = ht->cslots[i].first;
   while (e) {
    n = e->next;
    do { futex_get(mem_lock); qm_free(shm_block, (e)); futex_release(mem_lock); }while(0);
    e = n;
   }
  }
  do { futex_get(mem_lock); qm_free(shm_block, (ht->cslots)); futex_release(mem_lock); }while(0);
 }
 ht->cslots = ((void *)0);
}

variable_types: struct ht_element { void *key; void *data; struct ht_element *next; } *


decompiled_code:
__int64 __fastcall ht_add(__int64 a1, __int64 a2, __int64 a3)
{
_QWORD *v4; // rax
_QWORD *v5; // rbx
__int64 v6; // r8
__int64 v7; // r9
__int64 result; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
v4 = (_QWORD *)shm_malloc(0x18u);
v5 = v4;
if ( !v4 )
return 0xFFFFFFFFLL;
v4[2] = 0LL;
*v4 = a2;
v4[1] = a3;
v6 = *(_QWORD *)(a1 + 16) + 24LL * (int)abs32((*(unsigned int (__fastcall **)(__int64))a1)(a2) % *(_DWORD *)(a1 + 24));
v7 = *(_QWORD *)(v6 + 8);
if ( v7 )
*(_QWORD *)(v7 + 16) = v5;
else
*(_QWORD *)v6 = v5;
++*(_DWORD *)(v6 + 16);
result = 0LL;
*(_QWORD *)(v6 + 8) = v5;
return result;
}

original_code:
int ht_add(hash_table_t *ht, ht_key_t key, ht_data_t data)
{
 int h;
 ht_element_t *new_e;
 if (!ht) return -1;
 new_e = (ht_element_t*)shm_malloc(sizeof(ht_element_t));
 if (!new_e) return -1;
 new_e->next = ((void *)0);
 new_e->key = key;
 new_e->data = data;
 h = ht->hash(key) % ht->size;
 if (h < 0) h = -h;
 if (!ht->cslots[h].last) {
  ht->cslots[h].first = new_e;
 }
 else {
  ht->cslots[h].last->next = new_e;
 }
 ht->cslots[h].cnt++;
 ht->cslots[h].last = new_e;
 return 0;
}

canonical_original_code:
int ht_add(struct hash_table *ht, void *key, void *data)
{
 int h;
 struct ht_element *new_e;
 if (!ht) return -1;
 new_e = (struct ht_element *)shm_malloc(sizeof(ht_element_t));
 if (!new_e) return -1;
 new_e->next = ((void *)0);
 new_e->key = key;
 new_e->data = data;
 h = ht->hash(key) % ht->size;
 if (h < 0) h = -h;
 if (!ht->cslots[h].last) {
  ht->cslots[h].first = new_e;
 }
 else {
  ht->cslots[h].last->next = new_e;
 }
 ht->cslots[h].cnt++;
 ht->cslots[h].last = new_e;
 return 0;
}

variable_types:
key
void *

variable_types:
data
void *

variable_types: h int

user_defined_types: struct ht_element { void *key; void *data; struct ht_element *next; }


original_code:
ht_data_t ht_find(hash_table_t *ht, ht_key_t key)
{
 int h;
 ht_element_t *e;
 if (!ht) return ((void *)0);
 ht->find_cnt++;
 h = ht->hash(key) % ht->size;
 if (h < 0) h = -h;
 e = ht->cslots[h].first;
 if (!e) ht->nocmp_cnt++;
 while (e) {
  ht->cmp_cnt++;
  if (ht->cmp(e->key, key) == 0) return e->data;
  e = e->next;
 }
 ht->missed_cnt++;
 return ((void *)0);
}

canonical_original_code:
void *ht_find(struct hash_table *ht, void *key)
{
 int h;
 struct ht_element *e;
 if (!ht) return ((void *)0);
 ht->find_cnt++;
 h = ht->hash(key) % ht->size;
 if (h < 0) h = -h;
 e = ht->cslots[h].first;
 if (!e) ht->nocmp_cnt++;
 while (e) {
  ht->cmp_cnt++;
  if (ht->cmp(e->key, key) == 0) return e->data;
  e = e->next;
 }
 ht->missed_cnt++;
 return ((void *)0);
}


original_code:
ht_data_t ht_remove(hash_table_t *ht, ht_key_t key)
{
 int h;
 ht_element_t *e,*p;
 ht_data_t data;
 if (!ht) return ((void *)0);
 h = ht->hash(key) % ht->size;
 if (h < 0) h = -h;
 e = ht->cslots[h].first;
 p = ((void *)0);
 while (e) {
  if (ht->cmp(e->key, key) == 0) {
   if (p) p->next = e->next;
   else ht->cslots[h].first = e->next;
   ht->cslots[h].cnt--;
   if (!e->next) ht->cslots[h].last = p;
   data = e->data;
   do { futex_get(mem_lock); qm_free(shm_block, (e)); futex_release(mem_lock); }while(0);
   return data;
  }
  p = e;
  e = e->next;
 }
 return ((void *)0);
}

canonical_original_code:
void *ht_remove(struct hash_table *ht, void *key)
{
 int h;
 struct ht_element *e; struct ht_element *p;
 void *data;
 if (!ht) return ((void *)0);
 h = ht->hash(key) % ht->size;
 if (h < 0) h = -h;
 e = ht->cslots[h].first;
 p = ((void *)0);
 while (e) {
  if (ht->cmp(e->key, key) == 0) {
   if (p) p->next = e->next;
   else ht->cslots[h].first = e->next;
   ht->cslots[h].cnt--;
   if (!e->next) ht->cslots[h].last = p;
   data = e->data;
   do { futex_get(mem_lock); qm_free(shm_block, (e)); futex_release(mem_lock); }while(0);
   return data;
  }
  p = e;
  e = e->next;
 }
 return ((void *)0);
}


decompiled_code:
__int64 __fastcall get_first_ht_element(__int64 a1, __int64 a2)
{
int v3; // edi
__int64 *v4; // rdx
int v5; // ecx
int v6; // er8
__int64 result; // rax
int v8; // er9

if ( a2 )
{
*(_QWORD *)a2 = a1;
v3 = *(_DWORD *)(a1 + 24);
*(_QWORD *)(a2 + 16) = 0LL;
if ( v3 <= 0 )
{
result = 0LL;
v3 = 0;
LABEL_33:
*(_DWORD *)(a2 + 8) = v3;
return result;
}
v4 = *(__int64 **)(a1 + 16);
v5 = 0;
v6 = v3 & 7;
if ( (v3 & 7) == 0 )
{
LABEL_24:
while ( 1 )
{
result = *v4;
if ( *v4 )
goto LABEL_34;
result = v4[3];
v8 = ++v5;
if ( result )
goto LABEL_34;
result = v4[6];
++v5;
if ( result )
goto LABEL_34;
result = v4[9];
v5 = v8 + 2;
if ( result )
goto LABEL_34;
result = v4[12];
v5 = v8 + 3;
if ( result )
goto LABEL_34;
result = v4[15];
v5 = v8 + 4;
if ( result )
goto LABEL_34;
result = v4[18];
v5 = v8 + 5;
if ( result )
goto LABEL_34;
result = v4[21];
v5 = v8 + 6;
if ( result )
goto LABEL_34;
v5 = v8 + 7;
v4 += 24;
if ( v3 == v8 + 7 )
goto LABEL_33;
}
}
if ( v6 == 1 )
goto LABEL_22;
if ( v6 != 2 )
{
if ( v6 != 3 )
{
if ( v6 != 4 )
{
if ( v6 != 5 )
{
if ( v6 != 6 )
{
result = *v4;
if ( *v4 )
goto LABEL_34;
v5 = 1;
v4 += 3;
}
result = *v4;
if ( *v4 )
goto LABEL_34;
++v5;
v4 += 3;
}
result = *v4;
if ( *v4 )
goto LABEL_34;
++v5;
v4 += 3;
}
result = *v4;
if ( *v4 )
goto LABEL_34;
++v5;
v4 += 3;
}
result = *v4;
if ( *v4 )
goto LABEL_34;
++v5;
v4 += 3;
}
result = *v4;
if ( !*v4 )
{
++v5;
v4 += 3;
LABEL_22:
result = *v4;
if ( !*v4 )
{
++v5;
v4 += 3;
if ( v3 != v5 )
goto LABEL_24;
goto LABEL_33;
}
}
LABEL_34:
*(_QWORD *)(a2 + 16) = result;
*(_DWORD *)(a2 + 8) = v5;
return result;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, __int64 a2)
{
int v3; // edi
__int64 *v4; // rdx
int v5; // ecx
int v6; // er8
__int64 result; // rax
int v8; // er9

if ( a2 )
{
*(_QWORD *)a2 = a1;
v3 = *(_DWORD *)(a1 + 24);
*(_QWORD *)(a2 + 16) = 0LL;
if ( v3 <= 0 )
{
result = 0LL;
v3 = 0;
LABEL_33:
*(_DWORD *)(a2 + 8) = v3;
return result;
}
v4 = *(__int64 **)(a1 + 16);
v5 = 0;
v6 = v3 & 7;
if ( (v3 & 7) == 0 )
{
LABEL_24:
while ( 1 )
{
result = *v4;
if ( *v4 )
goto LABEL_34;
result = v4[3];
v8 = ++v5;
if ( result )
goto LABEL_34;
result = v4[6];
++v5;
if ( result )
goto LABEL_34;
result = v4[9];
v5 = v8 + 2;
if ( result )
goto LABEL_34;
result = v4[12];
v5 = v8 + 3;
if ( result )
goto LABEL_34;
result = v4[15];
v5 = v8 + 4;
if ( result )
goto LABEL_34;
result = v4[18];
v5 = v8 + 5;
if ( result )
goto LABEL_34;
result = v4[21];
v5 = v8 + 6;
if ( result )
goto LABEL_34;
v5 = v8 + 7;
v4 += 24;
if ( v3 == v8 + 7 )
goto LABEL_33;
}
}
if ( v6 == 1 )
goto LABEL_22;
if ( v6 != 2 )
{
if ( v6 != 3 )
{
if ( v6 != 4 )
{
if ( v6 != 5 )
{
if ( v6 != 6 )
{
result = *v4;
if ( *v4 )
goto LABEL_34;
v5 = 1;
v4 += 3;
}
result = *v4;
if ( *v4 )
goto LABEL_34;
++v5;
v4 += 3;
}
result = *v4;
if ( *v4 )
goto LABEL_34;
++v5;
v4 += 3;
}
result = *v4;
if ( *v4 )
goto LABEL_34;
++v5;
v4 += 3;
}
result = *v4;
if ( *v4 )
goto LABEL_34;
++v5;
v4 += 3;
}
result = *v4;
if ( !*v4 )
{
++v5;
v4 += 3;
LABEL_22:
result = *v4;
if ( !*v4 )
{
++v5;
v4 += 3;
if ( v3 != v5 )
goto LABEL_24;
goto LABEL_33;
}
}
LABEL_34:
*(_QWORD *)(a2 + 16) = result;
*(_DWORD *)(a2 + 8) = v5;
return result;
}
return 0LL;
}

original_code:
ht_element_t *get_first_ht_element(hash_table_t *ht, ht_traversal_info_t *info)
{
 int i;
 if (!info) return ((void *)0);
 info->ht = ht;
 info->current = ((void *)0);
 for (i = 0; i < ht->size; i++) {
  if (ht->cslots[i].first) {
   info->current = ht->cslots[i].first;
   break;
  }
 }
 info->slot_pos = i;
 return info->current;
}

canonical_original_code:
struct ht_element *get_first_ht_element(struct hash_table *ht, struct ht_traversal_info_t *info)
{
 int i;
 if (!info) return ((void *)0);
 info->ht = ht;
 info->current = ((void *)0);
 for (i = 0; i < ht->size; i++) {
  if (ht->cslots[i].first) {
   info->current = ht->cslots[i].first;
   break;
  }
 }
 info->slot_pos = i;
 return info->current;
}

variable_types: struct hash_table { unsigned int (*hash)(void *k); int (*cmp)(void *a, void *b); struct ht_cslot { struct ht_element *first; struct ht_element *last; int cnt; } *cslots; int size; int find_cnt; int cmp_cnt; int nocmp_cnt; int missed_cnt; } *

variable_types: struct ht_traversal_info_t { struct hash_table *ht; int slot_pos; struct ht_element *current; } *

return_type: struct ht_element { void *key; void *data; struct ht_element *next; } *


original_code:
ht_element_t *get_next_ht_element(ht_traversal_info_t *info)
{
 int i;
 if (!info) return ((void *)0);
 if (info->current) info->current = info->current->next;
 if (info->current) return info->current;
 else {
  for (i = info->slot_pos + 1; i < info->ht->size; i++) {
   if (info->ht->cslots[i].first) {
    info->current = info->ht->cslots[i].first;
    break;
   }
  }
  info->slot_pos = i;
 }
 return info->current;
}

canonical_original_code:
struct ht_element *get_next_ht_element(struct ht_traversal_info_t *info)
{
 int i;
 if (!info) return ((void *)0);
 if (info->current) info->current = info->current->next;
 if (info->current) return info->current;
 else {
  for (i = info->slot_pos + 1; i < info->ht->size; i++) {
   if (info->ht->cslots[i].first) {
    info->current = info->ht->cslots[i].first;
    break;
   }
  }
  info->slot_pos = i;
 }
 return info->current;
}

variable_types: struct ht_traversal_info_t { struct hash_table { unsigned int (*hash)(void *k); int (*cmp)(void *a, void *b); struct ht_cslot { struct ht_element *first; struct ht_element *last; int cnt; } *cslots; int size; int find_cnt; int cmp_cnt; int nocmp_cnt; int missed_cnt; } *ht; int slot_pos; struct ht_element *current; } *

user_defined_types: struct ht_traversal_info_t { struct hash_table *ht; int slot_pos; struct ht_element *current; }


rshash

original_code:
unsigned int rshash(const char* str, unsigned int len)
{
 unsigned int b = 378551;
 unsigned int a = 63689;
 unsigned int hash = 0;
 unsigned int i = 0;
 for(i = 0; i < len; str++, i++) {
  hash = hash * a + (*str);
  a = a * b;
 }
 return (hash & 0x7FFFFFFF);
}

canonical_original_code:
unsigned int rshash(char *str, unsigned int len)
{
 unsigned int b = 378551;
 unsigned int a = 63689;
 unsigned int hash = 0;
 unsigned int i = 0;
 for(i = 0; i < len; str++, i++) {
  hash = hash * a + (*str);
  a = a * b;
 }
 return (hash & 0x7FFFFFFF);
}

variable_types:
str
char *

variable_types:
len
unsigned int

variable_types:
b
unsigned int

variable_types:
a
unsigned int

variable_types:
hash
unsigned int

variable_types:
i
unsigned int

return_type: unsigned int