decompiled_code:
__int64 __fastcall cst_args(const char **a1, int a2, const char *a3, __int64 a4)
{
__int64 v4; // rbx
__int64 v5; // r15
int v6; // ebx
const char *v7; // rax
__int64 v8; // rbp
const char **v9; // r12
__int64 v10; // rax
unsigned int v11; // eax
float v12; // xmm0_4
__int64 v14; // [rsp+8h] [rbp-50h]

v4 = (__int64)a3;
v5 = new_features();
parse_description(v4, v5);
if ( a2 <= 1 )
{
v14 = 0LL;
}
else
{
v6 = 1;
v14 = 0LL;
do
{
v8 = v6;
v9 = &a1[v8];
if ( *a1[v8] == 45 )
{
if ( !(unsigned int)feat_present(v5, a1[v6])
|| !strcmp("-h", *v9)
|| !strcmp("-?", *v9)
|| !strcmp("-help", *v9) )
{
parse_usage(stdout, *a1, (const char *)&unk_35D, (const char *)&unk_35D, a3);
}
v7 = (const char *)feat_string(v5, *v9);
if ( !strcmp("<binary>", v7) )
{
feat_set_string(a4, *v9, "true");
}
else
{
if ( ++v6 == a2 )
parse_usage(stderr, *a1, "missing argument for ", *v9, a3);
if ( !strcmp("<int>", v7) )
{
v11 = atoi(a1[v8 + 1]);
feat_set_int(a4, *v9, v11);
}
else if ( !strcmp("<float>", v7) )
{
v12 = atof(a1[v8 + 1]);
feat_set_float(a4, *v9, v12);
}
else
{
if ( strcmp("<string>", v7) )
parse_usage(stderr, *a1, "unknown arg type ", v7, a3);
feat_set_string(a4, *v9, a1[v8 + 1]);
}
}
}
else
{
v10 = string_val();
v14 = cons_val(v10, v14);
}
++v6;
}
while ( a2 > v6 );
}
delete_features(v5);
return val_reverse(v14);
}

canonical_decompiled_code:
__int64 __fastcall func2(const char **a1, int a2, const char *a3, __int64 a4)
{
__int64 v4; // rbx
__int64 v5; // r15
int v6; // ebx
const char *v7; // rax
__int64 v8; // rbp
const char **v9; // r12
__int64 v10; // rax
unsigned int v11; // eax
float v12; // xmm0_4
__int64 v14; // [rsp+8h] [rbp-50h]

v4 = (__int64)a3;
v5 = new_features();
func0(v4, v5);
if ( a2 <= 1 )
{
v14 = 0LL;
}
else
{
v6 = 1;
v14 = 0LL;
do
{
v8 = v6;
v9 = &a1[v8];
if ( *a1[v8] == 45 )
{
if ( !(unsigned int)feat_present(v5, a1[v6])
|| !strcmp("-h", *v9)
|| !strcmp("-?", *v9)
|| !strcmp("-help", *v9) )
{
func1(stdout, *a1, (const char *)&unk_35D, (const char *)&unk_35D, a3);
}
v7 = (const char *)feat_string(v5, *v9);
if ( !strcmp("<binary>", v7) )
{
feat_set_string(a4, *v9, "true");
}
else
{
if ( ++v6 == a2 )
func1(stderr, *a1, "missing argument for ", *v9, a3);
if ( !strcmp("<int>", v7) )
{
v11 = atoi(a1[v8 + 1]);
feat_set_int(a4, *v9, v11);
}
else if ( !strcmp("<float>", v7) )
{
v12 = atof(a1[v8 + 1]);
feat_set_float(a4, *v9, v12);
}
else
{
if ( strcmp("<string>", v7) )
func1(stderr, *a1, "unknown arg type ", v7, a3);
feat_set_string(a4, *v9, a1[v8 + 1]);
}
}
}
else
{
v10 = string_val();
v14 = cons_val(v10, v14);
}
++v6;
}
while ( a2 > v6 );
}
delete_features(v5);
return val_reverse(v14);
}

original_code:
cst_val *cst_args(char **argv, int argc,
    const char *description,
    cst_features *args)
{
    cst_features *op_types = new_features();
    cst_val *files = ((void *)0);
    int i;
    const char *type;
    parse_description(description,op_types);
    for (i=1; i<argc; i++)
    {
 if (argv[i][0] == '-')
 {
     if ((!feat_present(op_types,argv[i])) ||
  ((strcmp("-h",argv[i]) == 0)) ||
  ((strcmp("-?",argv[i]) == 0)) ||
  ((strcmp("-help",argv[i]) == 0)))
  parse_usage(stdout,argv[0],"","",description);
     else
     {
  type = feat_string(op_types,argv[i]);
  if ((strcmp("<binary>",type) == 0))
      feat_set_string(args,argv[i],"true");
  else
  {
      if (i+1 == argc)
   parse_usage(stderr,argv[0],
        "missing argument for ",argv[i],
        description);
      if ((strcmp("<int>",type) == 0))
   feat_set_int(args,argv[i],atoi(argv[i+1]));
      else if ((strcmp("<float>",type) == 0))
   feat_set_float(args,argv[i],atof(argv[i+1]));
      else if ((strcmp("<string>",type) == 0))
   feat_set_string(args,argv[i],argv[i+1]);
      else
   parse_usage(stderr,argv[0],
        "unknown arg type ",type,
        description);
      i++;
  }
     }
 }
 else
     files = cons_val(string_val(argv[i]),files);
    }
    delete_features(op_types);
    return val_reverse(files);
}

canonical_original_code:
struct cst_val_struct *cst_args(char **argv, int argc, char *description, struct cst_features_struct *args)
{
    struct cst_features_struct *op_types = new_features();
    struct cst_val_struct *files = ((void *)0);
    int i;
    char *type;
    parse_description(description,op_types);
    for (i=1; i<argc; i++)
    {
 if (argv[i][0] == '-')
 {
     if ((!feat_present(op_types,argv[i])) ||
  ((strcmp("-h",argv[i]) == 0)) ||
  ((strcmp("-?",argv[i]) == 0)) ||
  ((strcmp("-help",argv[i]) == 0)))
  parse_usage(stdout,argv[0],"","",description);
     else
     {
  type = feat_string(op_types,argv[i]);
  if ((strcmp("<binary>",type) == 0))
      feat_set_string(args,argv[i],"true");
  else
  {
      if (i+1 == argc)
   parse_usage(stderr,argv[0],
        "missing argument for ",argv[i],
        description);
      if ((strcmp("<int>",type) == 0))
   feat_set_int(args,argv[i],atoi(argv[i+1]));
      else if ((strcmp("<float>",type) == 0))
   feat_set_float(args,argv[i],atof(argv[i+1]));
      else if ((strcmp("<string>",type) == 0))
   feat_set_string(args,argv[i],argv[i+1]);
      else
   parse_usage(stderr,argv[0],
        "unknown arg type ",type,
        description);
      i++;
  }
     }
 }
 else
     files = cons_val(string_val(argv[i]),files);
    }
    delete_features(op_types);
    return val_reverse(files);
}

variable_types:
argv
char **

variable_types: argc int

variable_types:
description
char *

variable_types: struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *

variable_types: struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *

variable_types: i int

variable_types:
type
char *


repo: deardaniel/PizzaTest

decompiled_code:
int __fastcall lex_match_entry(__int64 a1, __int64 a2)
{
return strcmp((const char *)(a1 + 1), (const char *)(a2 + 1));
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1, __int64 a2)
{
return strcmp((const char *)(a1 + 1), (const char *)(a2 + 1));
}

original_code:
static int lex_match_entry(const char *a, const char *b)
{
    int c;
    c = strcmp(a+1,b+1);
    return c;
}

canonical_original_code:
static int lex_match_entry(char *a, char *b)
{
    int c;
    c = strcmp(a+1,b+1);
    return c;
}

variable_types:
a
char *

variable_types:
b
char *

variable_types: c int

return_type: int


decompiled_code:
__int64 __fastcall find_full_match(__int64 a1, int a2, const char *a3)
{
unsigned int v3; // er12
const char **v5; // rbp
const char *v6; // r14
const char *v7; // rbx
__int64 v8; // rbx
const char *v9; // rbp

v3 = a2;
if ( *a3 != 48 )
{
if ( a2 < 0 )
{
v3 = a2;
}
else
{
v5 = (const char **)(a1 + 16LL * a2);
v6 = a3 + 1;
do
{
v7 = *v5;
if ( strcmp(v6, *v5 + 1) )
break;
if ( !strcmp(a3, v7) || *v7 == 48 )
return v3;
--v3;
v5 -= 2;
}
while ( v3 != -1 );
}
++v3;
v8 = a2;
v9 = *(const char **)(a1 + 16LL * a2);
if ( v9 )
{
while ( !strcmp(a3 + 1, v9 + 1) )
{
if ( !strcmp(a3, v9) )
return (unsigned int)v8;
if ( *v9 == 48 )
return (unsigned int)v8;
++v8;
v9 = *(const char **)(a1 + 16 * v8);
if ( !v9 )
return v3;
}
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2, const char *a3)
{
unsigned int v3; // er12
const char **v5; // rbp
const char *v6; // r14
const char *v7; // rbx
__int64 v8; // rbx
const char *v9; // rbp

v3 = a2;
if ( *a3 != 48 )
{
if ( a2 < 0 )
{
v3 = a2;
}
else
{
v5 = (const char **)(a1 + 16LL * a2);
v6 = a3 + 1;
do
{
v7 = *v5;
if ( strcmp(v6, *v5 + 1) )
break;
if ( !strcmp(a3, v7) || *v7 == 48 )
return v3;
--v3;
v5 -= 2;
}
while ( v3 != -1 );
}
++v3;
v8 = a2;
v9 = *(const char **)(a1 + 16LL * a2);
if ( v9 )
{
while ( !strcmp(a3 + 1, v9 + 1) )
{
if ( !strcmp(a3, v9) )
return (unsigned int)v8;
if ( *v9 == 48 )
return (unsigned int)v8;
++v8;
v9 = *(const char **)(a1 + 16 * v8);
if ( !v9 )
return v3;
}
}
}
return v3;
}

original_code:
static int find_full_match(const lexicon_entry *entries, int i,const char *word)
{
    int w, match;
    if (word[0] == '0')
 return i;
    for (w=i; w >=0; w--)
    {
 if (!(strcmp(word+1,entries[w].word_pos+1) == 0))
     break;
 else if (((strcmp(word,entries[w].word_pos) == 0)) ||
   (entries[w].word_pos[0] == '0'))
     return w;
    }
    match = w+1;
    for (w=i; entries[w].word_pos; w++)
    {
 if (!(strcmp(word+1,entries[w].word_pos+1) == 0))
     break;
 else if (((strcmp(word,entries[w].word_pos) == 0)) ||
   (entries[w].word_pos[0] == '0'))
     return w;
    }
    return match;
}

canonical_original_code:
static int find_full_match(struct lexicon_entry_struct *entries, int i, char *word)
{
    int w; int match;
    if (word[0] == '0')
 return i;
    for (w=i; w >=0; w--)
    {
 if (!(strcmp(word+1,entries[w].word_pos+1) == 0))
     break;
 else if (((strcmp(word,entries[w].word_pos) == 0)) ||
   (entries[w].word_pos[0] == '0'))
     return w;
    }
    match = w+1;
    for (w=i; entries[w].word_pos; w++)
    {
 if (!(strcmp(word+1,entries[w].word_pos+1) == 0))
     break;
 else if (((strcmp(word,entries[w].word_pos) == 0)) ||
   (entries[w].word_pos[0] == '0'))
     return w;
    }
    return match;
}

variable_types: struct lexicon_entry_struct { char *word_pos; int phone_index; } *

variable_types:
word
char *

variable_types: w int

variable_types: match int


decompiled_code:
void *__fastcall val_int_n(int a1)
{
void *result; // rax

result = &val_int_19;
if ( a1 <= 19 )
result = *(&val_int_const + a1);
return result;
}

canonical_decompiled_code:
void *__fastcall func0(int a1)
{
void *result; // rax

result = &val_int_19;
if ( a1 <= 19 )
result = *(&val_int_const + a1);
return result;
}

original_code:
const cst_val *val_int_n(int n)
{
    if (n < val_int_const_max)
 return val_int_const[n];
    else
 return val_int_const[val_int_const_max-1];
}

canonical_original_code:
struct cst_val_struct *val_int_n(int n)
{
    if (n < val_int_const_max)
 return val_int_const[n];
    else
 return val_int_const[val_int_const_max-1];
}

variable_types: n int

return_type: struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *

user_defined_types: struct cst_val_struct { union { struct cst_val_cons_struct cc; struct cst_val_atom_struct a; } c; }


decompiled_code:
void *__fastcall val_string_n(int a1)
{
void *result; // rax

result = &val_string_19;
if ( a1 <= 19 )
result = *(&val_string_const + a1);
return result;
}

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

result = &val_string_19;
if ( a1 <= 19 )
result = *(&val_string_const + a1);
return result;
}

original_code:
const cst_val *val_string_n(int n)
{
    if (n < val_int_const_max)
 return val_string_const[n];
    else
 return val_string_const[val_int_const_max-1];
}

canonical_original_code:
struct cst_val_struct *val_string_n(int n)
{
    if (n < val_int_const_max)
 return val_string_const[n];
    else
 return val_string_const[val_int_const_max-1];
}

user_defined_types: struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; }

user_defined_types: struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; }


decompiled_code:
__int64 __fastcall en_exp_digits(_BYTE *a1)
{
char v1; // al
_BYTE *v2; // rbp
__int64 v3; // rbx
__int64 v4; // rax

v1 = *a1;
if ( *a1 )
{
v2 = a1;
v3 = 0LL;
do
{
if ( (unsigned __int8)(v1 - 48) > 9u )
v4 = string_val("umpty");
else
v4 = string_val(digit2num[v1 - 48]);
v3 = cons_val(v4, v3);
v1 = *++v2;
}
while ( *v2 );
}
else
{
v3 = 0LL;
}
return val_reverse(v3);
}

canonical_decompiled_code:
__int64 __fastcall func0(_BYTE *a1)
{
char v1; // al
_BYTE *v2; // rbp
__int64 v3; // rbx
__int64 v4; // rax

v1 = *a1;
if ( *a1 )
{
v2 = a1;
v3 = 0LL;
do
{
if ( (unsigned __int8)(v1 - 48) > 9u )
v4 = string_val("umpty");
else
v4 = string_val(digit2num[v1 - 48]);
v3 = cons_val(v4, v3);
v1 = *++v2;
}
while ( *v2 );
}
else
{
v3 = 0LL;
}
return val_reverse(v3);
}

original_code:
cst_val *en_exp_digits(const char *numstring)
{
    cst_val *d = 0;
    const char *p;
    for (p=numstring; *p; p++)
    {
 if ((*p >= '0') && (*p <= '9'))
     d = cons_val(string_val(digit2num[*p-'0']),d);
 else
     d = cons_val(string_val("umpty"),d);
    }
    return val_reverse(d);
}

canonical_original_code:
struct cst_val_struct *en_exp_digits(char *numstring)
{
    struct cst_val_struct *d = 0;
    char *p;
    for (p=numstring; *p; p++)
    {
 if ((*p >= '0') && (*p <= '9'))
     d = cons_val(string_val(digit2num[*p-'0']),d);
 else
     d = cons_val(string_val("umpty"),d);
    }
    return val_reverse(d);
}

variable_types:
numstring
char *

variable_types: struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *

variable_types:
p
char *


decompiled_code:
__int64 __fastcall en_exp_number(char *a1)
{
int v1; // eax
int v2; // ebx
__int64 v3; // rdx
__int64 v4; // r12
__int64 v5; // rbx
__int64 v6; // rax
__int64 v7; // rax
__int64 result; // rax
char v9; // al
char v10; // dl
__int64 v11; // rbx
__int64 v12; // rax
char v13; // dl
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rax
__int64 v17; // rbx
__int64 v18; // rax
__int64 v19; // rbx
__int64 v20; // rax
__int64 v21; // rdx
__int64 v22; // r12
__int64 v23; // rbx
__int64 v24; // rax
__int64 v25; // rax
__int64 v26; // rdx
__int64 v27; // r12
__int64 v28; // rbx
__int64 v29; // rax
__int64 v30; // rax
char s[28]; // [rsp+Ch] [rbp-1Ch] BYREF

v1 = strlen(a1);
switch ( v1 )
{
case 0:
return 0LL;
case 1:
return en_exp_digits(a1);
case 2:
v9 = *a1;
if ( *a1 == 48 )
{
v13 = a1[1];
result = 0LL;
if ( v13 != 48 )
{
v14 = string_val(digit2num[v13 - 48]);
result = cons_val(v14, 0LL);
}
}
else
{
v10 = a1[1];
if ( v10 == 48 )
{
v15 = string_val(digit2enty[v9 - 48]);
result = cons_val(v15, 0LL);
}
else if ( v9 == 49 )
{
v16 = string_val(digit2teen[v10 - 48]);
result = cons_val(v16, 0LL);
}
else
{
v11 = en_exp_digits(a1 + 1);
v12 = string_val(digit2enty[*a1 - 48]);
result = cons_val(v12, v11);
}
}
break;
case 3:
if ( *a1 == 48 )
{
result = en_exp_number(a1 + 1);
}
else
{
v17 = en_exp_number(a1 + 1);
v18 = string_val("hundred");
v19 = cons_val(v18, v17);
v20 = string_val(digit2num[*a1 - 48]);
result = cons_val(v20, v19);
}
break;
default:
if ( v1 <= 6 )
{
v2 = 0;
if ( v1 - 3 > 0 )
{
v3 = 0LL;
do
{
s[v3] = a1[v3];
++v3;
}
while ( v1 - 3 > (int)v3 );
v2 = v1 - 3;
}
s[v2] = 0;
v4 = en_exp_number(s);
if ( v4 )
{
v5 = en_exp_number(&a1[v2]);
v6 = string_val("thousand");
v7 = cons_val(v6, v5);
return val_append(v4, v7);
}
return en_exp_number(&a1[v2]);
}
if ( v1 <= 9 )
{
v21 = 0LL;
do
{
s[v21] = a1[v21];
++v21;
}
while ( v1 - 6 > (int)v21 );
v2 = v1 - 6;
s[v1 - 6] = 0;
v22 = en_exp_number(s);
if ( v22 )
{
v23 = en_exp_number(&a1[v2]);
v24 = string_val("million");
v25 = cons_val(v24, v23);
return val_append(v22, v25);
}
return en_exp_number(&a1[v2]);
}
if ( v1 <= 12 )
{
v26 = 0LL;
do
{
s[v26] = a1[v26];
++v26;
}
while ( v1 - 9 > (int)v26 );
v2 = v1 - 9;
s[v1 - 9] = 0;
v27 = en_exp_number(s);
if ( v27 )
{
v28 = en_exp_number(&a1[v2]);
v29 = string_val("billion");
v30 = cons_val(v29, v28);
return val_append(v27, v30);
}
return en_exp_number(&a1[v2]);
}
return en_exp_digits(a1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *a1)
{
int v1; // eax
int v2; // ebx
__int64 v3; // rdx
__int64 v4; // r12
__int64 v5; // rbx
__int64 v6; // rax
__int64 v7; // rax
__int64 result; // rax
char v9; // al
char v10; // dl
__int64 v11; // rbx
__int64 v12; // rax
char v13; // dl
__int64 v14; // rax
__int64 v15; // rax
__int64 v16; // rax
__int64 v17; // rbx
__int64 v18; // rax
__int64 v19; // rbx
__int64 v20; // rax
__int64 v21; // rdx
__int64 v22; // r12
__int64 v23; // rbx
__int64 v24; // rax
__int64 v25; // rax
__int64 v26; // rdx
__int64 v27; // r12
__int64 v28; // rbx
__int64 v29; // rax
__int64 v30; // rax
char s[28]; // [rsp+Ch] [rbp-1Ch] BYREF

v1 = strlen(a1);
switch ( v1 )
{
case 0:
return 0LL;
case 1:
return func0(a1);
case 2:
v9 = *a1;
if ( *a1 == 48 )
{
v13 = a1[1];
result = 0LL;
if ( v13 != 48 )
{
v14 = string_val(digit2num[v13 - 48]);
result = cons_val(v14, 0LL);
}
}
else
{
v10 = a1[1];
if ( v10 == 48 )
{
v15 = string_val(digit2enty[v9 - 48]);
result = cons_val(v15, 0LL);
}
else if ( v9 == 49 )
{
v16 = string_val(digit2teen[v10 - 48]);
result = cons_val(v16, 0LL);
}
else
{
v11 = func0(a1 + 1);
v12 = string_val(digit2enty[*a1 - 48]);
result = cons_val(v12, v11);
}
}
break;
case 3:
if ( *a1 == 48 )
{
result = func1(a1 + 1);
}
else
{
v17 = func1(a1 + 1);
v18 = string_val("hundred");
v19 = cons_val(v18, v17);
v20 = string_val(digit2num[*a1 - 48]);
result = cons_val(v20, v19);
}
break;
default:
if ( v1 <= 6 )
{
v2 = 0;
if ( v1 - 3 > 0 )
{
v3 = 0LL;
do
{
s[v3] = a1[v3];
++v3;
}
while ( v1 - 3 > (int)v3 );
v2 = v1 - 3;
}
s[v2] = 0;
v4 = func1(s);
if ( v4 )
{
v5 = func1(&a1[v2]);
v6 = string_val("thousand");
v7 = cons_val(v6, v5);
return val_append(v4, v7);
}
return func1(&a1[v2]);
}
if ( v1 <= 9 )
{
v21 = 0LL;
do
{
s[v21] = a1[v21];
++v21;
}
while ( v1 - 6 > (int)v21 );
v2 = v1 - 6;
s[v1 - 6] = 0;
v22 = func1(s);
if ( v22 )
{
v23 = func1(&a1[v2]);
v24 = string_val("million");
v25 = cons_val(v24, v23);
return val_append(v22, v25);
}
return func1(&a1[v2]);
}
if ( v1 <= 12 )
{
v26 = 0LL;
do
{
s[v26] = a1[v26];
++v26;
}
while ( v1 - 9 > (int)v26 );
v2 = v1 - 9;
s[v1 - 9] = 0;
v27 = func1(s);
if ( v27 )
{
v28 = func1(&a1[v2]);
v29 = string_val("billion");
v30 = cons_val(v29, v28);
return val_append(v27, v30);
}
return func1(&a1[v2]);
}
return func0(a1);
}
return result;
}

original_code:
cst_val *en_exp_number(const char *numstring)
{
    int num_digits = strlen(numstring);
    char part[4];
    cst_val *p;
    int i;
    if (num_digits == 0)
 return ((void *)0);
    else if (num_digits == 1)
 return en_exp_digits(numstring);
    else if (num_digits == 2)
    {
 if (numstring[0] == '0')
 {
     if (numstring[1] == '0')
  return 0;
     else
  return cons_val(string_val(digit2num[numstring[1]-'0']),0);
 }
 else if (numstring[1] == '0')
     return cons_val(string_val(digit2enty[numstring[0]-'0']),0);
 else if (numstring[0] == '1')
     return cons_val(string_val(digit2teen[numstring[1]-'0']),0);
 else
     return cons_val(string_val(digit2enty[numstring[0]-'0']),
       en_exp_digits(numstring+1));
    }
    else if (num_digits == 3)
    {
 if (numstring[0] == '0')
     return en_exp_number(numstring+1);
 else
     return cons_val(string_val(digit2num[numstring[0]-'0']),
    cons_val(string_val("hundred"),
          en_exp_number(numstring+1)));
    }
    else if (num_digits < 7)
    {
 for (i=0; i < num_digits-3; i++)
     part[i] = numstring[i];
 part[i]='\0';
 p = en_exp_number(part);
 if (p == 0)
     return en_exp_number(numstring+i);
 else
     return val_append(p,cons_val(string_val("thousand"),
      en_exp_number(numstring+i)));
    }
    else if (num_digits < 10)
    {
 for (i=0; i < num_digits-6; i++)
     part[i] = numstring[i];
 part[i]='\0';
 p = en_exp_number(part);
 if (p == 0)
     return en_exp_number(numstring+i);
 else
     return val_append(p,cons_val(string_val("million"),
      en_exp_number(numstring+i)));
    }
    else if (num_digits < 13)
    {
 for (i=0; i < num_digits-9; i++)
     part[i] = numstring[i];
 part[i]='\0';
 p = en_exp_number(part);
 if (p == 0)
     return en_exp_number(numstring+i);
 else
     return val_append(p,cons_val(string_val("billion"),
      en_exp_number(numstring+i)));
    }
    else
    {
 return en_exp_digits(numstring);
    }
}

canonical_original_code:
struct cst_val_struct *en_exp_number(char *numstring)
{
    int num_digits = strlen(numstring);
    char part[4];
    struct cst_val_struct *p;
    int i;
    if (num_digits == 0)
 return ((void *)0);
    else if (num_digits == 1)
 return en_exp_digits(numstring);
    else if (num_digits == 2)
    {
 if (numstring[0] == '0')
 {
     if (numstring[1] == '0')
  return 0;
     else
  return cons_val(string_val(digit2num[numstring[1]-'0']),0);
 }
 else if (numstring[1] == '0')
     return cons_val(string_val(digit2enty[numstring[0]-'0']),0);
 else if (numstring[0] == '1')
     return cons_val(string_val(digit2teen[numstring[1]-'0']),0);
 else
     return cons_val(string_val(digit2enty[numstring[0]-'0']),
       en_exp_digits(numstring+1));
    }
    else if (num_digits == 3)
    {
 if (numstring[0] == '0')
     return en_exp_number(numstring+1);
 else
     return cons_val(string_val(digit2num[numstring[0]-'0']),
    cons_val(string_val("hundred"),
          en_exp_number(numstring+1)));
    }
    else if (num_digits < 7)
    {
 for (i=0; i < num_digits-3; i++)
     part[i] = numstring[i];
 part[i]='\0';
 p = en_exp_number(part);
 if (p == 0)
     return en_exp_number(numstring+i);
 else
     return val_append(p,cons_val(string_val("thousand"),
      en_exp_number(numstring+i)));
    }
    else if (num_digits < 10)
    {
 for (i=0; i < num_digits-6; i++)
     part[i] = numstring[i];
 part[i]='\0';
 p = en_exp_number(part);
 if (p == 0)
     return en_exp_number(numstring+i);
 else
     return val_append(p,cons_val(string_val("million"),
      en_exp_number(numstring+i)));
    }
    else if (num_digits < 13)
    {
 for (i=0; i < num_digits-9; i++)
     part[i] = numstring[i];
 part[i]='\0';
 p = en_exp_number(part);
 if (p == 0)
     return en_exp_number(numstring+i);
 else
     return val_append(p,cons_val(string_val("billion"),
      en_exp_number(numstring+i)));
    }
    else
    {
 return en_exp_digits(numstring);
    }
}

variable_types:
part
char [4]


decompiled_code:
__int64 __fastcall en_exp_ordinal(char *s)
{
char *v1; // r13
size_t v2; // rbx
int v3; // er12
char v4; // al
__int64 v5; // rax
__int64 v6; // r12
__int64 v7; // rax
const char *v8; // rbp
__int64 v9; // rbx
const char *v10; // r13
__int64 v11; // rbp
__int64 i; // rbx
__int64 j; // rbx
__int64 v14; // rax
__int64 k; // rbx
__int64 v16; // rax

v1 = (char *)cst_strdup();
v2 = 0LL;
v3 = 0;
while ( strlen(s) > v2 )
{
v4 = s[v2];
if ( v4 != 44 )
v1[v3++] = v4;
++v2;
}
v1[v3] = 0;
v5 = en_exp_number(v1);
v6 = val_reverse(v5);
cst_free(v1);
v7 = val_car(v6);
v8 = (const char *)val_string(v7);
v9 = 0LL;
v10 = 0LL;
do
{
if ( !strcmp(v8, digit2num[v9]) )
v10 = ord2num[v9];
++v9;
}
while ( v9 != 10 );
if ( !v10 )
{
for ( i = 0LL; i != 10; ++i )
{
if ( !strcmp(v8, digit2teen[i]) )
v10 = ord2teen[i];
}
if ( !v10 )
{
for ( j = 0LL; j != 10; ++j )
{
if ( !strcmp(v8, digit2enty[j]) )
v10 = ord2enty[j];
}
}
}
if ( !strcmp(v8, "hundred") )
v10 = "hundredth";
if ( !strcmp(v8, "thousand") )
v10 = "thousandth";
if ( !strcmp(v8, "billion") )
{
v10 = "billtionth";
}
else
{
v11 = v6;
if ( !v10 )
return v11;
}
v14 = string_val(v10);
v11 = cons_val(v14, 0LL);
for ( k = val_cdr(v6); k; k = val_cdr(k) )
{
v16 = val_car(k);
v11 = cons_val(v16, v11);
}
delete_val(v6);
return v11;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *s)
{
char *v1; // r13
size_t v2; // rbx
int v3; // er12
char v4; // al
__int64 v5; // rax
__int64 v6; // r12
__int64 v7; // rax
const char *v8; // rbp
__int64 v9; // rbx
const char *v10; // r13
__int64 v11; // rbp
__int64 i; // rbx
__int64 j; // rbx
__int64 v14; // rax
__int64 k; // rbx
__int64 v16; // rax

v1 = (char *)cst_strdup();
v2 = 0LL;
v3 = 0;
while ( strlen(s) > v2 )
{
v4 = s[v2];
if ( v4 != 44 )
v1[v3++] = v4;
++v2;
}
v1[v3] = 0;
v5 = func1(v1);
v6 = val_reverse(v5);
cst_free(v1);
v7 = val_car(v6);
v8 = (const char *)val_string(v7);
v9 = 0LL;
v10 = 0LL;
do
{
if ( !strcmp(v8, digit2num[v9]) )
v10 = ord2num[v9];
++v9;
}
while ( v9 != 10 );
if ( !v10 )
{
for ( i = 0LL; i != 10; ++i )
{
if ( !strcmp(v8, digit2teen[i]) )
v10 = ord2teen[i];
}
if ( !v10 )
{
for ( j = 0LL; j != 10; ++j )
{
if ( !strcmp(v8, digit2enty[j]) )
v10 = ord2enty[j];
}
}
}
if ( !strcmp(v8, "hundred") )
v10 = "hundredth";
if ( !strcmp(v8, "thousand") )
v10 = "thousandth";
if ( !strcmp(v8, "billion") )
{
v10 = "billtionth";
}
else
{
v11 = v6;
if ( !v10 )
return v11;
}
v14 = string_val(v10);
v11 = cons_val(v14, 0LL);
for ( k = val_cdr(v6); k; k = val_cdr(k) )
{
v16 = val_car(k);
v11 = cons_val(v16, v11);
}
delete_val(v6);
return v11;
}

original_code:
cst_val *en_exp_ordinal(const char *rawnumstring)
{
    cst_val *card, *o;
    const cst_val *t;
    const char *l;
    const char *ord;
    char *numstring;
    int i,j;
    numstring = cst_strdup(rawnumstring);
    for (j=i=0; i < strlen(rawnumstring); i++)
 if (rawnumstring[i] != ',')
 {
     numstring[j] = rawnumstring[i];
     j++;
 }
    numstring[j] = '\0';
    card = val_reverse(en_exp_number(numstring));
    cst_free(numstring);
    l = val_string(val_car(card));
    ord = 0;
    for (i=0; i<10; i++)
 if ((strcmp(l,digit2num[i]) == 0))
     ord = ord2num[i];
    if (!ord)
 for (i=0; i<10; i++)
     if ((strcmp(l,digit2teen[i]) == 0))
  ord = ord2teen[i];
    if (!ord)
 for (i=0; i<10; i++)
     if ((strcmp(l,digit2enty[i]) == 0))
  ord = ord2enty[i];
    if ((strcmp(l,"hundred") == 0))
 ord = "hundredth";
    if ((strcmp(l,"thousand") == 0))
 ord = "thousandth";
    if ((strcmp(l,"billion") == 0))
 ord = "billtionth";
    if (!ord)
 return card;
    o = cons_val(string_val(ord),0);
    for (t=val_cdr(card); t; t=val_cdr(t))
 o = cons_val(val_car(t),o);
    delete_val(card);
    return o;
}

canonical_original_code:
struct cst_val_struct *en_exp_ordinal(char *rawnumstring)
{
    struct cst_val_struct *card; struct cst_val_struct *o;
    struct cst_val_struct *t;
    char *l;
    char *ord;
    char *numstring;
    int i; int j;
    numstring = cst_strdup(rawnumstring);
    for (j=i=0; i < strlen(rawnumstring); i++)
 if (rawnumstring[i] != ',')
 {
     numstring[j] = rawnumstring[i];
     j++;
 }
    numstring[j] = '\0';
    card = val_reverse(en_exp_number(numstring));
    cst_free(numstring);
    l = val_string(val_car(card));
    ord = 0;
    for (i=0; i<10; i++)
 if ((strcmp(l,digit2num[i]) == 0))
     ord = ord2num[i];
    if (!ord)
 for (i=0; i<10; i++)
     if ((strcmp(l,digit2teen[i]) == 0))
  ord = ord2teen[i];
    if (!ord)
 for (i=0; i<10; i++)
     if ((strcmp(l,digit2enty[i]) == 0))
  ord = ord2enty[i];
    if ((strcmp(l,"hundred") == 0))
 ord = "hundredth";
    if ((strcmp(l,"thousand") == 0))
 ord = "thousandth";
    if ((strcmp(l,"billion") == 0))
 ord = "billtionth";
    if (!ord)
 return card;
    o = cons_val(string_val(ord),0);
    for (t=val_cdr(card); t; t=val_cdr(t))
 o = cons_val(val_car(t),o);
    delete_val(card);
    return o;
}

variable_types:
rawnumstring
char *

variable_types:
l
char *

variable_types:
ord
char *

variable_types: j int


decompiled_code:
__int64 __fastcall en_exp_id(char *a1)
{
size_t v1; // rax
__int64 v3; // rbx
__int64 v4; // rax
char v5; // al
__int64 v6; // rax
__int64 v7; // rbx
__int64 v8; // rax
__int64 v9; // rbx
__int64 v10; // rax
__int64 v11; // rbp
__int64 v12; // rax
char v13; // [rsp+Dh] [rbp-1Bh] BYREF
char v14; // [rsp+Eh] [rbp-1Ah]
char v15; // [rsp+Fh] [rbp-19h]

v1 = strlen(a1);
if ( v1 == 4 )
{
if ( a1[2] == 48 && a1[3] == 48 )
{
v5 = a1[1];
if ( v5 == 48 )
return en_exp_number(a1);
v13 = *a1;
v14 = v5;
v15 = 0;
v6 = string_val("hundred");
v7 = cons_val(v6, 0LL);
v8 = en_exp_number(&v13);
return val_append(v8, v7);
}
if ( a1[1] == 48 )
return en_exp_number(a1);
LABEL_7:
v13 = *a1;
v14 = a1[1];
v15 = 0;
v3 = en_exp_id(a1 + 2);
v4 = en_exp_number(&v13);
return val_append(v4, v3);
}
if ( v1 != 2 )
{
if ( v1 <= 2 )
return en_exp_number(a1);
if ( (v1 & 1) != 0 )
{
v11 = en_exp_id(a1 + 1);
v12 = string_val(digit2num[*a1 - 48]);
return cons_val(v12, v11);
}
goto LABEL_7;
}
if ( *a1 != 48 )
return en_exp_number(a1);
v9 = en_exp_digits(a1 + 1);
v10 = string_val("oh");
return cons_val(v10, v9);
}

original_code:
cst_val *en_exp_id(const char *numstring)
{
    char aaa[3];
    if ((strlen(numstring) == 4) &&
 (numstring[2] == '0') &&
 (numstring[3] == '0'))
    {
 if (numstring[1] == '0')
     return en_exp_number(numstring);
 else
 {
     aaa[0] = numstring[0];
     aaa[1] = numstring[1];
     aaa[2] = '\0';
     return val_append(en_exp_number(aaa),
         cons_val(string_val("hundred"),0));
 }
    }
    else if ((strlen(numstring) == 2) && (numstring[0] == '0'))
 return cons_val(string_val("oh"),
   en_exp_digits(&numstring[1]));
    else if (((strlen(numstring) == 4) &&
  ((numstring[1] == '0'))) ||
 (strlen(numstring) < 3))
 return en_exp_number(numstring);
    else if (strlen(numstring)%2 == 1)
    {
 return cons_val(string_val(digit2num[numstring[0]-'0']),
   en_exp_id(&numstring[1]));
    }
    else
    {
 aaa[0] = numstring[0];
 aaa[1] = numstring[1];
 aaa[2] = '\0';
 return val_append(en_exp_number(aaa),en_exp_id(&numstring[2]));
    }
}

canonical_original_code:
struct cst_val_struct *en_exp_id(char *numstring)
{
    char aaa[3];
    if ((strlen(numstring) == 4) &&
 (numstring[2] == '0') &&
 (numstring[3] == '0'))
    {
 if (numstring[1] == '0')
     return en_exp_number(numstring);
 else
 {
     aaa[0] = numstring[0];
     aaa[1] = numstring[1];
     aaa[2] = '\0';
     return val_append(en_exp_number(aaa),
         cons_val(string_val("hundred"),0));
 }
    }
    else if ((strlen(numstring) == 2) && (numstring[0] == '0'))
 return cons_val(string_val("oh"),
   en_exp_digits(&numstring[1]));
    else if (((strlen(numstring) == 4) &&
  ((numstring[1] == '0'))) ||
 (strlen(numstring) < 3))
 return en_exp_number(numstring);
    else if (strlen(numstring)%2 == 1)
    {
 return cons_val(string_val(digit2num[numstring[0]-'0']),
   en_exp_id(&numstring[1]));
    }
    else
    {
 aaa[0] = numstring[0];
 aaa[1] = numstring[1];
 aaa[2] = '\0';
 return val_append(en_exp_number(aaa),en_exp_id(&numstring[2]));
    }
}

variable_types:
aaa
char [3]


decompiled_code:
__int64 __fastcall en_exp_real(char *a1)
{
char *v1; // r12
__int64 v2; // rbp
size_t v3; // rbx
__int64 v4; // rbx
__int64 v5; // rax
__int64 v6; // rbx
__int64 v7; // rax
__int64 v8; // rbx
__int64 v10; // rbx
__int64 v11; // rax
__int64 v12; // rbx
__int64 v13; // rax
char *v14; // rbp
char *v15; // r12
size_t v16; // rbx
__int64 v17; // rbx
__int64 v18; // rax
__int64 v19; // rbx
__int64 v20; // rax

if ( a1 )
{
if ( *a1 == 45 )
{
v10 = en_exp_real(a1 + 1);
v11 = string_val("minus");
return cons_val(v11, v10);
}
if ( *a1 == 43 )
{
v12 = en_exp_real(a1 + 1);
v13 = string_val("plus");
return cons_val(v13, v12);
}
}
v1 = strchr(a1, 101);
if ( v1 || (v1 = strchr(a1, 69)) != 0LL )
{
v2 = cst_strdup(a1);
v3 = strlen(a1);
*(_BYTE *)(v2 + v3 - strlen(v1)) = 0;
v4 = en_exp_real(v1 + 1);
v5 = string_val("e");
v6 = cons_val(v5, v4);
v7 = en_exp_real(v2);
v8 = val_append(v7, v6);
cst_free(v2);
}
else
{
v14 = strchr(a1, 46);
if ( v14 )
{
v15 = (char *)cst_strdup(a1);
v16 = strlen(a1);
v15[v16 - strlen(v14)] = 0;
v17 = en_exp_digits(v14 + 1);
v18 = string_val("point");
v19 = cons_val(v18, v17);
v20 = en_exp_number(v15);
v8 = val_append(v20, v19);
cst_free(v15);
}
else
{
v8 = en_exp_number(a1);
}
}
return v8;
}

original_code:
cst_val *en_exp_real(const char *numstring)
{
    char *aaa, *p;
    cst_val *r;
    if (numstring && (numstring[0] == '-'))
 r = cons_val(string_val("minus"),
       en_exp_real(&numstring[1]));
    else if (numstring && (numstring[0] == '+'))
 r = cons_val(string_val("plus"),
       en_exp_real(&numstring[1]));
    else if (((p=strchr(numstring,'e')) != 0) ||
      ((p=strchr(numstring,'E')) != 0))
    {
 aaa = cst_strdup(numstring);
 aaa[strlen(numstring)-strlen(p)] = '\0';
 r = val_append(en_exp_real(aaa),
         cons_val(string_val("e"),
    en_exp_real(p+1)));
 cst_free(aaa);
    }
    else if ((p=strchr(numstring,'.')) != 0)
    {
 aaa = cst_strdup(numstring);
 aaa[strlen(numstring)-strlen(p)] = '\0';
 r = val_append(en_exp_number(aaa),
         cons_val(string_val("point"),
    en_exp_digits(p+1)));
 cst_free(aaa);
    }
    else
 r = en_exp_number(numstring);
    return r;
}

canonical_original_code:
struct cst_val_struct *en_exp_real(char *numstring)
{
    char *aaa; char *p;
    struct cst_val_struct *r;
    if (numstring && (numstring[0] == '-'))
 r = cons_val(string_val("minus"),
       en_exp_real(&numstring[1]));
    else if (numstring && (numstring[0] == '+'))
 r = cons_val(string_val("plus"),
       en_exp_real(&numstring[1]));
    else if (((p=strchr(numstring,'e')) != 0) ||
      ((p=strchr(numstring,'E')) != 0))
    {
 aaa = cst_strdup(numstring);
 aaa[strlen(numstring)-strlen(p)] = '\0';
 r = val_append(en_exp_real(aaa),
         cons_val(string_val("e"),
    en_exp_real(p+1)));
 cst_free(aaa);
    }
    else if ((p=strchr(numstring,'.')) != 0)
    {
 aaa = cst_strdup(numstring);
 aaa[strlen(numstring)-strlen(p)] = '\0';
 r = val_append(en_exp_number(aaa),
         cons_val(string_val("point"),
    en_exp_digits(p+1)));
 cst_free(aaa);
    }
    else
 r = en_exp_number(numstring);
    return r;
}

variable_types:
aaa
char *


decompiled_code:
__int64 __fastcall en_exp_letters(char *a1)
{
char *v1; // r12
char v2; // bl
const unsigned __int16 **v3; // r14
char *v4; // r13
__int64 v5; // rbp
int v6; // ebx
__int64 v7; // rax
__int64 v8; // rax

v1 = (char *)cst_safe_alloc(2LL);
v1[1] = 0;
v2 = *a1;
if ( *a1 )
{
v3 = _ctype_b_loc();
v4 = a1 + 1;
v5 = 0LL;
do
{
*v1 = v2;
if ( ((*v3)[v2] & 0x100) != 0 )
*v1 = tolower(v2);
v6 = *v1;
if ( strchr("0123456789", v6) )
{
v7 = string_val(digit2num[v6 - 48]);
v5 = cons_val(v7, v5);
}
else
{
if ( !strcmp(v1, "a") )
v8 = string_val("_a");
else
v8 = string_val(v1);
v5 = cons_val(v8, v5);
}
v2 = *v4++;
}
while ( v2 );
}
else
{
v5 = 0LL;
}
cst_free(v1);
return val_reverse(v5);
}

canonical_decompiled_code:
__int64 __fastcall func5(char *a1)
{
char *v1; // r12
char v2; // bl
const unsigned __int16 **v3; // r14
char *v4; // r13
__int64 v5; // rbp
int v6; // ebx
__int64 v7; // rax
__int64 v8; // rax

v1 = (char *)cst_safe_alloc(2LL);
v1[1] = 0;
v2 = *a1;
if ( *a1 )
{
v3 = _ctype_b_loc();
v4 = a1 + 1;
v5 = 0LL;
do
{
*v1 = v2;
if ( ((*v3)[v2] & 0x100) != 0 )
*v1 = tolower(v2);
v6 = *v1;
if ( strchr("0123456789", v6) )
{
v7 = string_val(digit2num[v6 - 48]);
v5 = cons_val(v7, v5);
}
else
{
if ( !strcmp(v1, "a") )
v8 = string_val("_a");
else
v8 = string_val(v1);
v5 = cons_val(v8, v5);
}
v2 = *v4++;
}
while ( v2 );
}
else
{
v5 = 0LL;
}
cst_free(v1);
return val_reverse(v5);
}

original_code:
cst_val *en_exp_letters(const char *lets)
{
    char *aaa;
    cst_val *r;
    int i;
    aaa = ((char *)cst_safe_alloc(sizeof(char)*(2)));
    aaa[1] = '\0';
    for (r=0,i=0; lets[i] != '\0'; i++)
    {
 aaa[0] = lets[i];
 if (((*__ctype_b_loc ())[(int) (((int)aaa[0]))] & (unsigned short int) _ISupper))
     aaa[0] = tolower((int)aaa[0]);
 if (strchr("0123456789",aaa[0]))
     r = cons_val(string_val(digit2num[aaa[0]-'0']),r);
 else if ((strcmp(aaa,"a") == 0))
     r = cons_val(string_val("_a"),r);
 else
     r = cons_val(string_val(aaa),r);
    }
    cst_free(aaa);
    return val_reverse(r);
}

canonical_original_code:
struct cst_val_struct *en_exp_letters(char *lets)
{
    char *aaa;
    struct cst_val_struct *r;
    int i;
    aaa = ((char *)cst_safe_alloc(sizeof(char)*(2)));
    aaa[1] = '\0';
    for (r=0,i=0; lets[i] != '\0'; i++)
    {
 aaa[0] = lets[i];
 if (((*__ctype_b_loc ())[(int) (((int)aaa[0]))] & (unsigned short) _ISupper))
     aaa[0] = tolower((int)aaa[0]);
 if (strchr("0123456789",aaa[0]))
     r = cons_val(string_val(digit2num[aaa[0]-'0']),r);
 else if ((strcmp(aaa,"a") == 0))
     r = cons_val(string_val("_a"),r);
 else
     r = cons_val(string_val(aaa),r);
    }
    cst_free(aaa);
    return val_reverse(r);
}

variable_types:
lets
char *

variable_types: i int


original_code:
int en_exp_roman(const char *roman)
{
    int val;
    const char *p;
    val = 0;
    for (p=roman; *p != 0; p++)
    {
 if (*p == 'X')
     val += 10;
 else if (*p == 'V')
     val += 5;
 else if (*p == 'I')
 {
     if (p[1] == 'V')
     {
  val += 4;
  p++;
     }
     else if (p[1] == 'X')
     {
  val += 9;
  p++;
     }
     else
  val += 1;
 }
    }
    return val;
}

canonical_original_code:
int en_exp_roman(char *roman)
{
    int val;
    char *p;
    val = 0;
    for (p=roman; *p != 0; p++)
    {
 if (*p == 'X')
     val += 10;
 else if (*p == 'V')
     val += 5;
 else if (*p == 'I')
 {
     if (p[1] == 'V')
     {
  val += 4;
  p++;
     }
     else if (p[1] == 'X')
     {
  val += 9;
  p++;
     }
     else
  val += 1;
 }
    }
    return val;
}

variable_types:
roman
char *

variable_types: val int


decompiled_code:
__int64 __fastcall usenglish_init(_QWORD *a1)
{
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax

us_text_init();
v1 = phoneset_val(us_phoneset);
feat_set(*a1, "phoneset", v1);
feat_set_string(*a1, "silence", us_phoneset[4]);
feat_set_string(*a1, "text_whitespace", us_english_whitespace);
feat_set_string(*a1, "text_postpunctuation", us_english_punctuation);
feat_set_string(*a1, "text_prepunctuation", us_english_prepunctuation);
feat_set_string(*a1, "text_singlecharsymbols", us_english_singlecharsymbols);
v2 = itemfunc_val(&us_tokentowords);
feat_set(*a1, "tokentowords_func", v2);
v3 = cart_val(&us_phrasing_cart);
feat_set(*a1, "phrasing_cart", v3);
v4 = cart_val(&us_int_accent_cart);
feat_set(*a1, "int_cart_accents", v4);
v5 = cart_val(&us_int_tone_cart);
feat_set(*a1, "int_cart_tones", v5);
v6 = cart_val(&us_durz_cart);
feat_set(*a1, "dur_cart", v6);
v7 = dur_stats_val(&us_dur_stats);
feat_set(*a1, "dur_stats", v7);
v8 = uttfunc_val(&us_f0_model);
feat_set(*a1, "f0_model_func", v8);
v9 = uttfunc_val(&us_postlex);
feat_set(*a1, "postlex_func", v9);
return us_ff_register(a1[1]);
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1)
{
__int64 v1; // rax
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax

us_text_init();
v1 = phoneset_val(us_phoneset);
feat_set(*a1, "phoneset", v1);
feat_set_string(*a1, "silence", us_phoneset[4]);
feat_set_string(*a1, "text_whitespace", us_english_whitespace);
feat_set_string(*a1, "text_postpunctuation", us_english_punctuation);
feat_set_string(*a1, "text_prepunctuation", us_english_prepunctuation);
feat_set_string(*a1, "text_singlecharsymbols", us_english_singlecharsymbols);
v2 = itemfunc_val(&us_tokentowords);
feat_set(*a1, "tokentowords_func", v2);
v3 = cart_val(&us_phrasing_cart);
feat_set(*a1, "phrasing_cart", v3);
v4 = cart_val(&us_int_accent_cart);
feat_set(*a1, "int_cart_accents", v4);
v5 = cart_val(&us_int_tone_cart);
feat_set(*a1, "int_cart_tones", v5);
v6 = cart_val(&us_durz_cart);
feat_set(*a1, "dur_cart", v6);
v7 = dur_stats_val(&us_dur_stats);
feat_set(*a1, "dur_stats", v7);
v8 = uttfunc_val(&us_f0_model);
feat_set(*a1, "f0_model_func", v8);
v9 = uttfunc_val(&us_postlex);
feat_set(*a1, "postlex_func", v9);
return us_ff_register(a1[1]);
}

original_code:
void usenglish_init(cst_voice *v)
{
    us_text_init();
    feat_set(v->features,"phoneset",phoneset_val(&us_phoneset));
    feat_set_string(v->features,"silence",us_phoneset.silence);
    feat_set_string(v->features,"text_whitespace",us_english_whitespace);
    feat_set_string(v->features,"text_postpunctuation",us_english_punctuation);
    feat_set_string(v->features,"text_prepunctuation",
      us_english_prepunctuation);
    feat_set_string(v->features,"text_singlecharsymbols",
      us_english_singlecharsymbols);
    feat_set(v->features,"tokentowords_func",itemfunc_val(&us_tokentowords));
    feat_set(v->features,"phrasing_cart",cart_val(&us_phrasing_cart));
    feat_set(v->features,"int_cart_accents",cart_val(&us_int_accent_cart));
    feat_set(v->features,"int_cart_tones",cart_val(&us_int_tone_cart));
    feat_set(v->features,"dur_cart",cart_val(&us_durz_cart));
    feat_set(v->features,"dur_stats",dur_stats_val((dur_stats *)us_dur_stats));
    feat_set(v->features,"f0_model_func",uttfunc_val(&us_f0_model));
    feat_set(v->features,"postlex_func",uttfunc_val(&us_postlex));
    us_ff_register(v->ffunctions);
}

canonical_original_code:
void usenglish_init(struct cst_voice_struct *v)
{
    us_text_init();
    feat_set(v->features,"phoneset",phoneset_val(&us_phoneset));
    feat_set_string(v->features,"silence",us_phoneset.silence);
    feat_set_string(v->features,"text_whitespace",us_english_whitespace);
    feat_set_string(v->features,"text_postpunctuation",us_english_punctuation);
    feat_set_string(v->features,"text_prepunctuation",
      us_english_prepunctuation);
    feat_set_string(v->features,"text_singlecharsymbols",
      us_english_singlecharsymbols);
    feat_set(v->features,"tokentowords_func",itemfunc_val(&us_tokentowords));
    feat_set(v->features,"phrasing_cart",cart_val(&us_phrasing_cart));
    feat_set(v->features,"int_cart_accents",cart_val(&us_int_accent_cart));
    feat_set(v->features,"int_cart_tones",cart_val(&us_int_tone_cart));
    feat_set(v->features,"dur_cart",cart_val(&us_durz_cart));
    feat_set(v->features,"dur_stats",dur_stats_val((struct cst_dur_stats_struct **)us_dur_stats));
    feat_set(v->features,"f0_model_func",uttfunc_val(&us_f0_model));
    feat_set(v->features,"postlex_func",uttfunc_val(&us_postlex));
    us_ff_register(v->ffunctions);
}

variable_types: struct cst_voice_struct { struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *features; struct cst_features_struct *ffunctions; struct cst_utterance_struct { struct cst_features_struct *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; } *(*utt_init)(struct cst_utterance_struct *u, struct cst_voice_struct *v); } *

return_type: void

user_defined_types: struct cst_voice_struct { struct cst_features_struct *features; struct cst_features_struct *ffunctions; struct cst_utterance_struct *(*utt_init)(struct cst_utterance_struct *u, struct cst_voice_struct *v); }

user_defined_types: struct cst_dur_stats_struct { char *phone; float mean; float stddev; }

user_defined_types: struct cst_features_struct { struct cst_featvalpair_struct *head; void *ctx; }

user_defined_types: struct cst_featvalpair_struct { char *name; struct cst_val_struct *val; struct cst_featvalpair_struct *next; }


decompiled_code:
__int64 cst_errmsg(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
HRError(7999LL, a1, va);
return 0LL;
}

canonical_decompiled_code:
__int64 func0(__int64 a1, ...)
{
gcc_va_list va; // [rsp+8h] [rbp-D0h] BYREF

va_start(va, a1);
HRError(7999LL, a1, va);
return 0LL;
}

original_code:
int cst_errmsg(char *fmt, ...)
{
 va_list args;
 __builtin_va_start(args,fmt);
 HRError(7999, fmt, args);
 __builtin_va_end(args);
 return 0;
}

canonical_original_code:
int cst_errmsg(char *fmt, ...)
{
 __builtin_va_list args;
 __builtin_va_start(args,fmt);
 HRError(7999, fmt, args);
 __builtin_va_end(args);
 return 0;
}

variable_types:
fmt
char *


decompiled_code:
_BOOL8 __fastcall post_break(__int64 a1)
{
__int64 v1; // rdx
_BOOL8 result; // rax

v1 = item_prev();
result = 1LL;
if ( v1 )
result = strcmp("pau", (const char *)ffeature_string(a1, "R:SylStructure.daughter.R:Segment.p.name")) == 0;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(__int64 a1)
{
__int64 v1; // rdx
_BOOL8 result; // rax

v1 = item_prev();
result = 1LL;
if ( v1 )
result = strcmp("pau", (const char *)ffeature_string(a1, "R:SylStructure.daughter.R:Segment.p.name")) == 0;
return result;
}

original_code:
static int post_break(cst_item *syl)
{
    if ((item_prev(syl) == 0) ||
 ((strcmp("pau",ffeature_string(syl, "R:SylStructure.daughter.R:Segment.p.name")) == 0)))
 return TRUE;
    else
 return FALSE;
}

canonical_original_code:
static int post_break(struct cst_item_struct *syl)
{
    if ((item_prev(syl) == 0) ||
 ((strcmp("pau",ffeature_string(syl, "R:SylStructure.daughter.R:Segment.p.name")) == 0)))
 return TRUE;
    else
 return FALSE;
}

variable_types: struct cst_item_struct { struct cst_item_contents_struct { struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *features; struct cst_features_struct *relations; } *contents; struct cst_relation_struct { char *name; struct cst_features_struct *features; struct cst_utterance_struct { struct cst_features_struct *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; } *utterance; struct cst_item_struct *head; struct cst_item_struct *tail; } *relation; struct cst_item_struct *n; struct cst_item_struct *p; struct cst_item_struct *u; struct cst_item_struct *d; } *

user_defined_types: struct cst_item_struct { struct cst_item_contents_struct *contents; struct cst_relation_struct *relation; struct cst_item_struct *n; struct cst_item_struct *p; struct cst_item_struct *u; struct cst_item_struct *d; }

user_defined_types: struct cst_item_contents_struct { struct cst_features_struct *features; struct cst_features_struct *relations; }

user_defined_types: struct cst_relation_struct { char *name; struct cst_features_struct *features; struct cst_utterance_struct *utterance; struct cst_item_struct *head; struct cst_item_struct *tail; }


decompiled_code:
_BOOL8 __fastcall pre_break(__int64 a1)
{
__int64 v1; // rdx
_BOOL8 result; // rax

v1 = item_next();
result = 1LL;
if ( v1 )
result = strcmp("pau", (const char *)ffeature_string(a1, "R:SylStructure.daughtern.R:Segment.n.name")) == 0;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1)
{
__int64 v1; // rdx
_BOOL8 result; // rax

v1 = item_next();
result = 1LL;
if ( v1 )
result = strcmp("pau", (const char *)ffeature_string(a1, "R:SylStructure.daughtern.R:Segment.n.name")) == 0;
return result;
}

original_code:
static int pre_break(cst_item *syl)
{
    if ((item_next(syl) == 0) ||
 ((strcmp("pau",ffeature_string(syl, "R:SylStructure.daughtern.R:Segment.n.name")) == 0)))
 return TRUE;
    else
 return FALSE;
}

canonical_original_code:
static int pre_break(struct cst_item_struct *syl)
{
    if ((item_next(syl) == 0) ||
 ((strcmp("pau",ffeature_string(syl, "R:SylStructure.daughtern.R:Segment.n.name")) == 0)))
 return TRUE;
    else
 return FALSE;
}

user_defined_types: struct cst_utterance_struct { struct cst_features_struct *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; }


decompiled_code:
double __fastcall vowel_mid(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // r12
__int64 v5; // rbx
__int64 v6; // rax
bool v7; // cf
bool v8; // zf
const char *v9; // rdi
const char *v10; // rsi
__int64 v11; // rcx
double result; // xmm0_8
float v13; // [rsp+Ch] [rbp-1Ch]
float v14; // [rsp+Ch] [rbp-1Ch]

v1 = item_phoneset();
v2 = item_as(a1, "SylStructure");
v3 = item_daughter(v2);
if ( !v3 )
return 0.0;
v4 = v3;
v5 = v3;
while ( 1 )
{
v6 = item_feat_string(v5, "name");
v9 = (const char *)phone_feature_string(v1, v6, "vc");
v10 = "+";
v11 = 2LL;
do
{
if ( !v11 )
break;
v7 = *v10 < (unsigned int)*v9;
v8 = *v10++ == *v9++;
--v11;
}
while ( v8 );
if ( (!v7 && !v8) == v7 )
break;
v5 = item_next(v5, v10);
if ( !v5 )
{
v13 = item_feat_float(v4, "end");
*(float *)&result = (float)(ffeature_float(v4, "R:Segment.p.end") + v13) * 0.5;
return result;
}
}
v14 = item_feat_float(v5, "end");
*(float *)&result = (float)(ffeature_float(v5, "R:Segment.p.end") + v14) * 0.5;
return result;
}

canonical_decompiled_code:
double __fastcall func3(__int64 a1)
{
__int64 v1; // rbp
__int64 v2; // rax
__int64 v3; // rax
__int64 v4; // r12
__int64 v5; // rbx
__int64 v6; // rax
bool v7; // cf
bool v8; // zf
const char *v9; // rdi
const char *v10; // rsi
__int64 v11; // rcx
double result; // xmm0_8
float v13; // [rsp+Ch] [rbp-1Ch]
float v14; // [rsp+Ch] [rbp-1Ch]

v1 = item_phoneset();
v2 = item_as(a1, "SylStructure");
v3 = item_daughter(v2);
if ( !v3 )
return 0.0;
v4 = v3;
v5 = v3;
while ( 1 )
{
v6 = item_feat_string(v5, "name");
v9 = (const char *)phone_feature_string(v1, v6, "vc");
v10 = "+";
v11 = 2LL;
do
{
if ( !v11 )
break;
v7 = *v10 < (unsigned int)*v9;
v8 = *v10++ == *v9++;
--v11;
}
while ( v8 );
if ( (!v7 && !v8) == v7 )
break;
v5 = item_next(v5, v10);
if ( !v5 )
{
v13 = item_feat_float(v4, "end");
*(float *)&result = (float)(ffeature_float(v4, "R:Segment.p.end") + v13) * 0.5;
return result;
}
}
v14 = item_feat_float(v5, "end");
*(float *)&result = (float)(ffeature_float(v5, "R:Segment.p.end") + v14) * 0.5;
return result;
}

original_code:
static float vowel_mid(cst_item *syl)
{
    cst_item *s;
    cst_item *ts;
    const cst_phoneset *ps = item_phoneset(syl);
    ts = item_daughter(item_as(syl,"SylStructure"));
    for (s=ts; s; s = item_next(s))
    {
 if ((strcmp("+",phone_feature_string(ps,item_feat_string(s,"name"), "vc")) == 0))
 {
     return (item_feat_float(s,"end")+
      ffeature_float(s,"R:Segment.p.end"))/2.0;
 }
    }
    if (ts == 0)
 return 0;
    return (item_feat_float(ts,"end")+
     ffeature_float(ts,"R:Segment.p.end"))/2.0;
}

canonical_original_code:
static float vowel_mid(struct cst_item_struct *syl)
{
    struct cst_item_struct *s;
    struct cst_item_struct *ts;
    struct cst_phoneset_struct *ps = item_phoneset(syl);
    ts = item_daughter(item_as(syl,"SylStructure"));
    for (s=ts; s; s = item_next(s))
    {
 if ((strcmp("+",phone_feature_string(ps,item_feat_string(s,"name"), "vc")) == 0))
 {
     return (item_feat_float(s,"end")+
      ffeature_float(s,"R:Segment.p.end"))/2.0;
 }
    }
    if (ts == 0)
 return 0;
    return (item_feat_float(ts,"end")+
     ffeature_float(ts,"R:Segment.p.end"))/2.0;
}

variable_types: struct cst_phoneset_struct { char *name; char **featnames; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } **featvals; char **phonenames; char *silence; int num_phones; int **fvtable; } *

return_type: float

user_defined_types: struct cst_phoneset_struct { char *name; char **featnames; struct cst_val_struct **featvals; char **phonenames; char *silence; int num_phones; int **fvtable; }


decompiled_code:
__int64 __fastcall add_target_point(__int64 a1, float a2, float a3)
{
__int64 v3; // rbx

v3 = relation_append(a1, 0LL);
item_set_float(v3, "pos", a2);
if ( a3 > 500.0 )
return item_set_float(v3, "f0", 500.0);
if ( a3 >= 50.0 )
return item_set_float(v3, "f0", a3);
return item_set_float(v3, "f0", 50.0);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, float a2, float a3)
{
__int64 v3; // rbx

v3 = relation_append(a1, 0LL);
item_set_float(v3, "pos", a2);
if ( a3 > 500.0 )
return item_set_float(v3, "f0", 500.0);
if ( a3 >= 50.0 )
return item_set_float(v3, "f0", a3);
return item_set_float(v3, "f0", 50.0);
}

original_code:
static void add_target_point(cst_relation *targ,float pos, float f0)
{
    cst_item *t;
    t = relation_append(targ,((void *)0));
    item_set_float(t,"pos",pos);
    if (f0 > 500.0)
 item_set_float(t,"f0",500.0);
    else if (f0 < 50.0)
 item_set_float(t,"f0",50.0);
    else
 item_set_float(t,"f0",f0);
}

canonical_original_code:
static void add_target_point(struct cst_relation_struct *targ, float pos, float f0)
{
    struct cst_item_struct *t;
    t = relation_append(targ,((void *)0));
    item_set_float(t,"pos",pos);
    if (f0 > 500.0)
 item_set_float(t,"f0",500.0);
    else if (f0 < 50.0)
 item_set_float(t,"f0",50.0);
    else
 item_set_float(t,"f0",f0);
}

variable_types: struct cst_relation_struct { char *name; struct cst_features_struct { struct cst_featvalpair_struct { char *name; struct cst_val_struct { union { struct cst_val_cons_struct { struct cst_val_struct *car; struct cst_val_struct *cdr; } cc; struct cst_val_atom_struct { short type; short ref_count; union { float fval; int ival; void *vval; } v; } a; } c; } *val; struct cst_featvalpair_struct *next; } *head; void *ctx; } *features; struct cst_utterance_struct { struct cst_features_struct *features; struct cst_features_struct *ffunctions; struct cst_features_struct *relations; void *ctx; } *utterance; struct cst_item_struct { struct cst_item_contents_struct { struct cst_features_struct *features; struct cst_features_struct *relations; } *contents; struct cst_relation_struct *relation; struct cst_item_struct *n; struct cst_item_struct *p; struct cst_item_struct *u; struct cst_item_struct *d; } *head; struct cst_item_struct *tail; } *

variable_types: pos float


main

canonical_name: main

repo: deaz/sntp-server

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx

if ( (int)daemon_init((char *)*argv, 0) < 0 )
exit(-1);
v3 = (unsigned int)server();
syslog(7, "exited with %d", v3);
return v3;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx

if ( (int)func7((char *)*argv, 0) < 0 )
exit(-1);
v3 = (unsigned int)func13();
syslog(7, "exited with %d", v3);
return v3;
}

original_code:
int main(int argc, char *argv[]) {
    if (daemon_init(argv[0], 0) < 0) {
        exit(-1);
    }
    int status;
    status = server();
    syslog(7, "exited with %d", status);
    return status;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: status int


decompiled_code:
__int64 __fastcall daemon_init(char *ident, int facility)
{
__pid_t v2; // eax
unsigned int v3; // er12

v2 = fork();
if ( v2 < 0 )
return (unsigned int)-1;
v3 = v2;
if ( v2 )
exit(0);
umask(0);
if ( setsid() < 0 )
return (unsigned int)-1;
if ( chdir("/") < 0 )
return (unsigned int)-1;
close(0);
close(1);
close(2);
openlog(ident, 1, facility);
syslog(7, "started");
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func7(char *ident, int facility)
{
__pid_t v2; // eax
unsigned int v3; // er12

v2 = fork();
if ( v2 < 0 )
return (unsigned int)-1;
v3 = v2;
if ( v2 )
exit(0);
umask(0);
if ( setsid() < 0 )
return (unsigned int)-1;
if ( chdir("/") < 0 )
return (unsigned int)-1;
close(0);
close(1);
close(2);
openlog(ident, 1, facility);
syslog(7, "started");
return v3;
}

original_code:
int daemon_init(const char *pname, int facility) {
    pid_t pid;
    pid = fork();
    if (pid < 0) {
        return -1;
    } else if (pid != 0) {
        exit(0);
    }
    umask(0);
    if (setsid() < 0) {
        return -1;
    }
    if (chdir("/") < 0) {
        return -1;
    }
    close(0);
    close(1);
    close(2);
    openlog(pname, 0x01, facility);
    syslog(7, "started");
    return 0;
}

canonical_original_code:
int daemon_init(char *pname, int facility) {
    int pid;
    pid = fork();
    if (pid < 0) {
        return -1;
    } else if (pid != 0) {
        exit(0);
    }
    umask(0);
    if (setsid() < 0) {
        return -1;
    }
    if (chdir("/") < 0) {
        return -1;
    }
    close(0);
    close(1);
    close(2);
    openlog(pname, 0x01, facility);
    syslog(7, "started");
    return 0;
}

variable_types:
pname
char *

variable_types: facility int

variable_types: pid int


decompiled_code:
__int64 ntp_time()
{
unsigned int v0; // ebx
struct timeval v2; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v2, 0LL);
v0 = _bswap_32(LODWORD(v2.tv_sec) - 2085978496);
return (_bswap_32((int)((double)SLODWORD(v2.tv_usec) / 1000000.0 * 4294967296.0)) << 32) | v0;
}

canonical_decompiled_code:
__int64 func10()
{
unsigned int v0; // ebx
struct timeval v2; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v2, 0LL);
v0 = func8(LODWORD(v2.tv_sec) - 2085978496);
return (func8((int)((double)SLODWORD(v2.tv_usec) / 1000000.0 * 4294967296.0)) << 32) | v0;
}

original_code:
fixedpt64 ntp_time() {
    struct timeval tv;
    gettimeofday(&tv, ((void *)0));
    double usecf = (double)tv.tv_usec / 1000000;
    uint32_t useci = (uint32_t)(usecf * 4294967296);
    fixedpt64 res = {htonl(tv.tv_sec + 2208988800UL), htonl(useci)};
    return res;
}

canonical_original_code:
struct fixedpt64 ntp_time() {
    struct timeval tv;
    gettimeofday(&tv, ((void *)0));
    double usecf = (double)tv.tv_usec / 1000000;
    unsigned int useci = (uint32_t)(usecf * 4294967296);
    struct fixedpt64 res = {htonl(tv.tv_sec + 2208988800UL), htonl(useci)};
    return res;
}

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types: usecf double

variable_types:
useci
unsigned int

variable_types: struct fixedpt64 { unsigned int integer; unsigned int fraction; }


original_code:
void make_ntp_msg(ntpmsg *msg) {
    msg->status = (msg->status & ~0xC0);
    msg->status = (msg->status & ~0x07) | 4;
    msg->stratum = 1;
    msg->precision = -6;
    memset(&(msg->delay), 0, sizeof(msg->delay));
    memset(&(msg->dispersion), 0, sizeof(msg->dispersion));
    strncpy(msg->refid, "LOCL", 4);
    memset(&(msg->reftime), 0, sizeof(msg->reftime));
    msg->origintime = msg->transtime;
    msg->recvtime = ntp_time();
    msg->transtime = ntp_time();
}

canonical_original_code:
void make_ntp_msg(struct ntpmsg *msg) {
    msg->status = (msg->status & ~0xC0);
    msg->status = (msg->status & ~0x07) | 4;
    msg->stratum = 1;
    msg->precision = -6;
    memset(&(msg->delay), 0, sizeof(msg->delay));
    memset(&(msg->dispersion), 0, sizeof(msg->dispersion));
    strncpy(msg->refid, "LOCL", 4);
    memset(&(msg->reftime), 0, sizeof(msg->reftime));
    msg->origintime = msg->transtime;
    msg->recvtime = ntp_time();
    msg->transtime = ntp_time();
}

variable_types: struct ntpmsg { unsigned char status; unsigned char stratum; unsigned char poll; char precision; struct fixedpt32 { unsigned short integer; unsigned short fraction; } delay; struct fixedpt32 dispersion; char refid[4]; struct fixedpt64 { unsigned int integer; unsigned int fraction; } reftime; struct fixedpt64 origintime; struct fixedpt64 recvtime; struct fixedpt64 transtime; } *

user_defined_types: struct ntpmsg { unsigned char status; unsigned char stratum; unsigned char poll; char precision; struct fixedpt32 delay; struct fixedpt32 dispersion; char refid[4]; struct fixedpt64 reftime; struct fixedpt64 origintime; struct fixedpt64 recvtime; struct fixedpt64 transtime; }


decompiled_code:
int __fastcall init_server(int *a1, __int64 a2)
{
int v2; // eax
int result; // eax
int *v4; // rax
char *v5; // rax
int *v6; // rax
char *v7; // rax
int optval[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v2 = socket(2, 2, 0);
*a1 = v2;
if ( v2 < 0 )
{
v4 = __errno_location();
v5 = strerror(*v4);
syslog(7, "opening socket: %s", v5);
result = -1;
}
else
{
optval[0] = 1;
setsockopt(v2, 1, 2, optval, 4u);
*(_QWORD *)(a2 + 8) = 0LL;
*(_WORD *)a2 = 2;
*(_WORD *)(a2 + 2) = _bswap_16(123);
*(_DWORD *)(a2 + 4) = _bswap_32(0);
result = bind(*a1, (const struct sockaddr *)a2, 0x10u);
if ( result )
{
v6 = __errno_location();
v7 = strerror(*v6);
syslog(7, "binding: %s", v7);
result = -1;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func12(int *a1, __int64 a2)
{
int v2; // eax
int result; // eax
int *v4; // rax
char *v5; // rax
int *v6; // rax
char *v7; // rax
int optval[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v2 = socket(2, 2, 0);
*a1 = v2;
if ( v2 < 0 )
{
v4 = __errno_location();
v5 = strerror(*v4);
syslog(7, "opening socket: %s", v5);
result = -1;
}
else
{
optval[0] = 1;
setsockopt(v2, 1, 2, optval, 4u);
*(_QWORD *)(a2 + 8) = 0LL;
*(_WORD *)a2 = 2;
*(_WORD *)(a2 + 2) = func9(123);
*(_DWORD *)(a2 + 4) = func8(0);
result = bind(*a1, (const struct sockaddr *)a2, 0x10u);
if ( result )
{
v6 = __errno_location();
v7 = strerror(*v6);
syslog(7, "binding: %s", v7);
result = -1;
}
}
return result;
}

original_code:
int init_server(int *sockfd, sockaddr_in *servaddr) {
    *sockfd = socket(2, SOCK_DGRAM, 0);
    if (*sockfd < 0) {
        syslog(7, "opening socket: %s", strerror((*__errno_location ())));
        return -1;
    }
    int tr = 1;
    setsockopt(*sockfd, 1, 2, &tr, sizeof(tr));
    memset(servaddr, 0, sizeof(*servaddr));
    (*servaddr).sin_family = 2;
    (*servaddr).sin_port = htons(123);
    (*servaddr).sin_addr.s_addr = htonl(((in_addr_t) 0x00000000));
    if (bind(*sockfd, (sockaddr*)servaddr, sizeof(*servaddr))) {
        syslog(7, "binding: %s", strerror((*__errno_location ())));
        return -1;
    }
    return 0;
}

canonical_original_code:
int init_server(int *sockfd, struct sockaddr_in *servaddr) {
    *sockfd = socket(2, SOCK_DGRAM, 0);
    if (*sockfd < 0) {
        syslog(7, "opening socket: %s", strerror((*__errno_location ())));
        return -1;
    }
    int tr = 1;
    setsockopt(*sockfd, 1, 2, &tr, sizeof(tr));
    memset(servaddr, 0, sizeof(*servaddr));
    (*servaddr).sin_family = 2;
    (*servaddr).sin_port = htons(123);
    (*servaddr).sin_addr.s_addr = htonl(((unsigned int) 0x00000000));
    if (bind(*sockfd, (struct sockaddr *)servaddr, sizeof(*servaddr))) {
        syslog(7, "binding: %s", strerror((*__errno_location ())));
        return -1;
    }
    return 0;
}

variable_types:
sockfd
int *

variable_types: 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]; } *

variable_types: tr int

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 { unsigned short sa_family; char sa_data[14]; }


server

decompiled_code:
__int64 server()
{
int *v1; // rax
char *v2; // rax
int v3; // eax
int *v4; // rax
char *v5; // rax
_BYTE v6[60]; // [rsp+0h] [rbp-78h] BYREF
socklen_t addr_len; // [rsp+3Ch] [rbp-3Ch] BYREF
struct sockaddr addr; // [rsp+40h] [rbp-38h] BYREF
char v9[28]; // [rsp+50h] [rbp-28h] BYREF
int fd[3]; // [rsp+6Ch] [rbp-Ch] BYREF

if ( init_server(fd, (__int64)v9) >= 0 )
{
while ( 1 )
{
addr_len = 16;
v3 = recvfrom(fd[0], v6, 0x30uLL, 0, &addr, &addr_len);
if ( v3 < 0 )
{
v1 = __errno_location();
v2 = strerror(*v1);
syslog(7, "receiving: %s", v2);
}
else if ( (unsigned int)v3 <= 0x2F )
{
syslog(7, "message too small");
}
else
{
make_ntp_msg((__int64)v6);
if ( sendto(fd[0], v6, 0x30uLL, 0, &addr, 0x10u) < 0 )
{
v4 = __errno_location();
v5 = strerror(*v4);
syslog(7, "sending: %s", v5);
}
else
{
syslog(7, "client synced");
}
}
}
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func13()
{
int *v1; // rax
char *v2; // rax
int v3; // eax
int *v4; // rax
char *v5; // rax
_BYTE v6[60]; // [rsp+0h] [rbp-78h] BYREF
socklen_t addr_len; // [rsp+3Ch] [rbp-3Ch] BYREF
struct sockaddr addr; // [rsp+40h] [rbp-38h] BYREF
char v9[28]; // [rsp+50h] [rbp-28h] BYREF
int fd[3]; // [rsp+6Ch] [rbp-Ch] BYREF

if ( func12(fd, (__int64)v9) >= 0 )
{
while ( 1 )
{
addr_len = 16;
v3 = recvfrom(fd[0], v6, 0x30uLL, 0, &addr, &addr_len);
if ( v3 < 0 )
{
v1 = __errno_location();
v2 = strerror(*v1);
syslog(7, "receiving: %s", v2);
}
else if ( (unsigned int)v3 <= 0x2F )
{
syslog(7, "message too small");
}
else
{
func11((__int64)v6);
if ( sendto(fd[0], v6, 0x30uLL, 0, &addr, 0x10u) < 0 )
{
v4 = __errno_location();
v5 = strerror(*v4);
syslog(7, "sending: %s", v5);
}
else
{
syslog(7, "client synced");
}
}
}
}
return 0xFFFFFFFFLL;
}

original_code:
int server() {
    int sockfd;
    sockaddr_in servaddr;
    if (init_server(&sockfd, &servaddr) < 0) {
        return -1;
    }
    sockaddr_in cliaddr;
    socklen_t cliaddr_size;
    int recvbytes;
    char buf[sizeof(ntpmsg)];
    while (1) {
        cliaddr_size = sizeof(cliaddr);
        recvbytes = recvfrom(sockfd, buf, sizeof(ntpmsg), 0, (sockaddr*)&cliaddr, &cliaddr_size);
        if (recvbytes < 0) {
            syslog(7, "receiving: %s", strerror((*__errno_location ())));
            continue;
        }
        if (recvbytes < sizeof(ntpmsg)) {
            syslog(7, "message too small");
            continue;
        }
        make_ntp_msg((ntpmsg*)buf);
        if (sendto(sockfd, buf, sizeof(ntpmsg), 0, (sockaddr*)&cliaddr, sizeof(cliaddr)) < 0) {
            syslog(7, "sending: %s", strerror((*__errno_location ())));
            continue;
        }
        syslog(7, "client synced");
    }
    return 0;
}

canonical_original_code:
int server() {
    int sockfd;
    struct sockaddr_in servaddr;
    if (init_server(&sockfd, &servaddr) < 0) {
        return -1;
    }
    struct sockaddr_in cliaddr;
    unsigned int cliaddr_size;
    int recvbytes;
    char buf[-1];
    while (1) {
        cliaddr_size = sizeof(cliaddr);
        recvbytes = recvfrom(sockfd, buf, sizeof(ntpmsg), 0, (struct sockaddr *)&cliaddr, &cliaddr_size);
        if (recvbytes < 0) {
            syslog(7, "receiving: %s", strerror((*__errno_location ())));
            continue;
        }
        if (recvbytes < sizeof(ntpmsg)) {
            syslog(7, "message too small");
            continue;
        }
        make_ntp_msg((struct ntpmsg *)buf);
        if (sendto(sockfd, buf, sizeof(ntpmsg), 0, (struct sockaddr *)&cliaddr, sizeof(cliaddr)) < 0) {
            syslog(7, "sending: %s", strerror((*__errno_location ())));
            continue;
        }
        syslog(7, "client synced");
    }
    return 0;
}

variable_types: sockfd int

variable_types: 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]; }

variable_types: recvbytes int

variable_types:
buf
char [-1]

user_defined_types: struct fixedpt32 { unsigned short integer; unsigned short fraction; }

user_defined_types: struct fixedpt64 { unsigned int integer; unsigned int fraction; }


inserirClientes

repo: debymf/msgserver

decompiled_code:
void inserirClientes()
{
int i; // ebx
_DWORD v1[6]; // [rsp+0h] [rbp-18h] BYREF

for ( i = 1; ; ++i )
{
if ( msgrcv(filaE1, v1, 8uLL, 0LL, 0) < 0 )
{
puts("Erro ao receber cliente para cadastro.");
perror("msgrcv");
exit(1);
}
if ( i - 1 > 4 )
break;
clientes_cadastrados[v1[2]] = 1;
if ( msgsnd(filaE2, v1, 8uLL, 0) < 0 )
goto LABEL_9;
LABEL_5:
;
}
v1[3] = 0;
if ( msgsnd(filaE2, v1, 8uLL, 0) >= 0 )
goto LABEL_4;
LABEL_9:
puts("Erro ao enviar resposta de cadastro ao cliente.");
perror("msgsnd");
LABEL_4:
if ( i <= 8 )
goto LABEL_5;
}

canonical_decompiled_code:
void func7()
{
int i; // ebx
_DWORD v1[6]; // [rsp+0h] [rbp-18h] BYREF

for ( i = 1; ; ++i )
{
if ( msgrcv(filaE1, v1, 8uLL, 0LL, 0) < 0 )
{
puts("Erro ao receber cliente para cadastro.");
perror("msgrcv");
exit(1);
}
if ( i - 1 > 4 )
break;
clientes_cadastrados[v1[2]] = 1;
if ( msgsnd(filaE2, v1, 8uLL, 0) < 0 )
goto LABEL_9;
LABEL_5:
;
}
v1[3] = 0;
if ( msgsnd(filaE2, v1, 8uLL, 0) >= 0 )
goto LABEL_4;
LABEL_9:
puts("Erro ao enviar resposta de cadastro ao cliente.");
perror("msgsnd");
LABEL_4:
if ( i <= 8 )
goto LABEL_5;
}

original_code:
void inserirClientes(){
 struct inServer msg1_recv;
 int i;
 for(i=0;i<9;i++){
  if(msgrcv(filaE1, &msg1_recv, sizeof(struct inServer) - sizeof(long), 0, 0)<0){
   printf("Erro ao receber cliente para cadastro.\n");
   perror("msgrcv");
   exit(1);
  }
  if (i>4){
   msg1_recv.auth=0;
  }
  else{
   clientes_cadastrados[msg1_recv.pid]=1;
  }
;
  if(msgsnd(filaE2,&msg1_recv, sizeof(struct inServer) - sizeof(long), 0)<0){
   printf("Erro ao enviar resposta de cadastro ao cliente.\n");
   perror("msgsnd");
  }
 }
}

variable_types: struct inServer { long type; int pid; int auth; }

variable_types: i int


imprimirMsgs

decompiled_code:
int imprimirMsgs()
{
int v0; // ebx
int result; // eax
__int64 v2; // [rsp+0h] [rbp-58h] BYREF
int v3; // [rsp+8h] [rbp-50h]
char v4[72]; // [rsp+10h] [rbp-48h] BYREF

v0 = 5;
do
{
if ( msgrcv(filaM, &v2, 0x40uLL, 0LL, 0) < 0 )
{
puts(" Erro ao receber cliente para imprimir msg.");
perror("msgrcv");
exit(1);
}
result = v3;
if ( clientes_cadastrados[v3] == 1 )
result = printf("Mensagem: %s\n", v4);
--v0;
}
while ( v0 );
return result;
}

canonical_decompiled_code:
int func8()
{
int v0; // ebx
int result; // eax
__int64 v2; // [rsp+0h] [rbp-58h] BYREF
int v3; // [rsp+8h] [rbp-50h]
char v4[72]; // [rsp+10h] [rbp-48h] BYREF

v0 = 5;
do
{
if ( msgrcv(filaM, &v2, 0x40uLL, 0LL, 0) < 0 )
{
puts(" Erro ao receber cliente para imprimir msg.");
perror("msgrcv");
exit(1);
}
result = v3;
if ( clientes_cadastrados[v3] == 1 )
result = printf("Mensagem: %s\n", v4);
--v0;
}
while ( v0 );
return result;
}

original_code:
void imprimirMsgs(){
 struct msgServer msg1_recv;
 int i;
 for(i=0;i<5;i++){
  if(msgrcv(filaM, &msg1_recv, sizeof(struct msgServer) - sizeof(long), 0, 0)<0){
   printf(" Erro ao receber cliente para imprimir msg.\n");
   perror("msgrcv");
   exit(1);
  }
  if (clientes_cadastrados[msg1_recv.pid]==1){
   printf("Mensagem: %s\n", msg1_recv.buf);
  }
 }
}

variable_types: struct msgServer { long type; int pid; int auth; char buf[50]; }


removerClientes

decompiled_code:
void removerClientes()
{
int v0; // ebx
_DWORD v1[6]; // [rsp+0h] [rbp-18h] BYREF

v0 = 5;
do
{
if ( msgrcv(filaE1, v1, 8uLL, 0LL, 0) < 0 )
{
puts("Erro ao receber cliente para retirada.");
perror("msgrcv");
exit(1);
}
clientes_cadastrados[v1[2]] = 0;
v1[3] = 2;
if ( msgsnd(filaE2, v1, 8uLL, 0) < 0 )
{
puts("Erro ao enviar resposta de remocao ao cliente.");
perror("msgsnd");
}
--v0;
}
while ( v0 );
}

canonical_decompiled_code:
void func9()
{
int v0; // ebx
_DWORD v1[6]; // [rsp+0h] [rbp-18h] BYREF

v0 = 5;
do
{
if ( msgrcv(filaE1, v1, 8uLL, 0LL, 0) < 0 )
{
puts("Erro ao receber cliente para retirada.");
perror("msgrcv");
exit(1);
}
clientes_cadastrados[v1[2]] = 0;
v1[3] = 2;
if ( msgsnd(filaE2, v1, 8uLL, 0) < 0 )
{
puts("Erro ao enviar resposta de remocao ao cliente.");
perror("msgsnd");
}
--v0;
}
while ( v0 );
}

original_code:
void removerClientes(){
 struct inServer msg1_recv;
 int i;
 for(i=0;i<5;i++){
  if(msgrcv(filaE1, &msg1_recv, sizeof(struct inServer) - sizeof(long), 0, 0)<0){
   printf("Erro ao receber cliente para retirada.\n");
   perror("msgrcv");
   exit(1);
  }
  clientes_cadastrados[msg1_recv.pid]=0;
  msg1_recv.auth=2;
  if(msgsnd(filaE2,&msg1_recv, sizeof(struct inServer) - sizeof(long), 0)<0){
   printf("Erro ao enviar resposta de remocao ao cliente.\n");
   perror("msgsnd");
  }
 }
}

user_defined_types: struct inServer { long type; int pid; int auth; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
key_t v3; // eax
key_t v4; // eax
key_t v5; // eax

v3 = ftok("main.c", 1);
filaE1 = msgget(v3, 950);
if ( filaE1 < 0 )
{
puts("Erro na criacao da fila de entrada.");
exit(1);
}
v4 = ftok("main.c", 2);
filaE2 = msgget(v4, 950);
if ( filaE2 < 0 )
{
puts("Erro na criacao da fila de entrada.");
exit(1);
}
v5 = ftok("main.c", 3);
filaM = msgget(v5, 950);
if ( filaM < 0 )
{
puts("Erro na criacao da fila de entrada.");
exit(1);
}
puts("Inicia servidor de impressao");
inserirClientes();
imprimirMsgs();
removerClientes();
sleep(0xAu);
msgctl(filaE1, 0, 0LL);
msgctl(filaE2, 0, 0LL);
msgctl(filaM, 0, 0LL);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
key_t v3; // eax
key_t v4; // eax
key_t v5; // eax

v3 = ftok("main.c", 1);
filaE1 = msgget(v3, 950);
if ( filaE1 < 0 )
{
puts("Erro na criacao da fila de entrada.");
exit(1);
}
v4 = ftok("main.c", 2);
filaE2 = msgget(v4, 950);
if ( filaE2 < 0 )
{
puts("Erro na criacao da fila de entrada.");
exit(1);
}
v5 = ftok("main.c", 3);
filaM = msgget(v5, 950);
if ( filaM < 0 )
{
puts("Erro na criacao da fila de entrada.");
exit(1);
}
puts("Inicia servidor de impressao");
func7();
func8();
func9();
sleep(0xAu);
msgctl(filaE1, 0, 0LL);
msgctl(filaE2, 0, 0LL);
msgctl(filaM, 0, 0LL);
return 0;
}

original_code:
int main(){
 int key1;
 if ((filaE1 = msgget(ftok("main.c", 1), 01000|0x1B6)) < 0)
 {
  printf("Erro na criacao da fila de entrada.\n");
  exit(1);
 }
 if ((filaE2 = msgget(ftok("main.c", 2), 01000|0x1B6)) < 0)
 {
  printf("Erro na criacao da fila de entrada.\n");
  exit(1);
 }
 if ((filaM = msgget(ftok("main.c", 3), 01000|0x1B6)) < 0)
 {
  printf("Erro na criacao da fila de entrada.\n");
  exit(1);
 }
 printf("Inicia servidor de impressao\n");
 inserirClientes();
 imprimirMsgs();
 removerClientes();
 sleep(10);
 msgctl(filaE1, 0, ((void *)0));
 msgctl(filaE2, 0, ((void *)0));
 msgctl(filaM, 0, ((void *)0));
 return 0;
}


repo: dedesite/piscine

decompiled_code:
__int64 __fastcall get_char(int a1)
{
unsigned int v1; // edx

if ( len_2 || (len_2 = read(a1, &buff_1, 0x40uLL), ptr_buff_0 = (__int64)&buff_1, v1 = 0, len_2) )
{
v1 = *(unsigned __int8 *)ptr_buff_0++;
--len_2;
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
unsigned int v1; // edx

if ( len_2 || (len_2 = read(a1, &buff_1, 0x40uLL), ptr_buff_0 = (__int64)&buff_1, v1 = 0, len_2) )
{
v1 = *(unsigned __int8 *)ptr_buff_0++;
--len_2;
}
return v1;
}

original_code:
char get_char(const int fd)
{
    static char buff[64];
    static char* ptr_buff;
    static int len = 0;
    char c;
    if(len == 0)
    {
        len = read(fd, buff, 64);
        ptr_buff = (char*)&buff;
        if(len == 0)
            return (0);
    }
    c = *ptr_buff;
    ptr_buff++;
    len--;
    return c;
}

canonical_original_code:
char get_char(int fd)
{
    static char buff[64];
    static char *ptr_buff;
    static int len = 0;
    char c;
    if(len == 0)
    {
        len = read(fd, buff, 64);
        ptr_buff = (char *)&buff;
        if(len == 0)
            return (0);
    }
    c = *ptr_buff;
    ptr_buff++;
    len--;
    return c;
}

variable_types: fd int

variable_types:
buff
char [64]

variable_types: len int

variable_types: c char

return_type: char


eq

decompiled_code:
_BOOL8 __fastcall eq(int a1, int a2)
{
return ((a2 - a1) | (a1 - a2)) >= 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(int a1, int a2)
{
return ((a2 - a1) | (a1 - a2)) >= 0;
}

original_code:
int eq(int x, int y)
{
  return (unsigned int)(~((x-y) | (y-x))) >> 31;
}

variable_types: x int

variable_types: y int


ne

decompiled_code:
__int64 __fastcall ne(int a1, int a2)
{
return ((a1 - a2) | (unsigned int)(a2 - a1)) >> 31;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, int a2)
{
return ((a1 - a2) | (unsigned int)(a2 - a1)) >> 31;
}

original_code:
int ne(int x, int y)
{
  return (unsigned int)((x-y) | (y-x)) >> 31;
}


lt

decompiled_code:
__int64 __fastcall lt(unsigned int a1, int a2)
{
return ((a1 - a2) ^ (a1 ^ a2) & ((a1 - a2) ^ a1)) >> 31;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int a1, int a2)
{
return ((a1 - a2) ^ (a1 ^ a2) & ((a1 - a2) ^ a1)) >> 31;
}

original_code:
int lt(int x, int y)
{
  return (unsigned int)((x-y) ^ ((x^y)&((x-y)^x))) >> 31;
}


le

decompiled_code:
__int64 __fastcall le(int a1, int a2)
{
return ((a1 | ~a2) & (a1 ^ a2 | (unsigned int)~(a2 - a1))) >> 31;
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1, int a2)
{
return ((a1 | ~a2) & (a1 ^ a2 | (unsigned int)~(a2 - a1))) >> 31;
}

original_code:
int le(int x, int y)
{
  return (unsigned int)((x|~y) & ((x^y) | ~(y-x))) >> 31;
}


decompiled_code:
__int64 __fastcall lt_unsigned(int a1, int a2)
{
return (~a1 & a2 | (a1 - a2) & (a2 | (unsigned int)~a1)) >> 31;
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1, int a2)
{
return (~a1 & a2 | (a1 - a2) & (a2 | (unsigned int)~a1)) >> 31;
}

original_code:
int lt_unsigned(int x, int y)
{
  return (unsigned int)((~x&y) | ((~x|y)&(x-y))) >> 31;
}


decompiled_code:
__int64 __fastcall le_unsigned(int a1, int a2)
{
return ((a2 | ~a1) & (a2 ^ a1 | (unsigned int)~(a2 - a1))) >> 31;
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1, int a2)
{
return ((a2 | ~a1) & (a2 ^ a1 | (unsigned int)~(a2 - a1))) >> 31;
}

original_code:
int le_unsigned(int x, int y)
{
  return (unsigned int)((~x|y) & ((x^y) | ~(y-x))) >> 31;
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebp
__int64 v4; // rbx
_BOOL4 v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int v10; // eax

if ( argc != 3 )
exit(0);
v3 = atoi(argv[1]);
v4 = (unsigned int)atoi(argv[2]);
printf("x:%d, y:%d\n", v3, v4);
v5 = eq(v3, v4);
printf("x = y :%d\n", v5);
v6 = ne(v3, v4);
printf("x != y :%d\n", v6);
v7 = lt(v3, v4);
printf("x < y :%d\n", v7);
v8 = le(v3, v4);
printf("x <= y :%d\n", v8);
v9 = lt_unsigned(v3, v4);
printf("x u< y :%d\n", v9);
v10 = le_unsigned(v3, v4);
printf("x u<= y:%d\n", v10);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebp
__int64 v4; // rbx
_BOOL4 v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int v10; // eax

if ( argc != 3 )
exit(0);
v3 = atoi(argv[1]);
v4 = (unsigned int)atoi(argv[2]);
printf("x:%d, y:%d\n", v3, v4);
v5 = func7(v3, v4);
printf("x = y :%d\n", v5);
v6 = func8(v3, v4);
printf("x != y :%d\n", v6);
v7 = func9(v3, v4);
printf("x < y :%d\n", v7);
v8 = func10(v3, v4);
printf("x <= y :%d\n", v8);
v9 = func11(v3, v4);
printf("x u< y :%d\n", v9);
v10 = func12(v3, v4);
printf("x u<= y:%d\n", v10);
return 0;
}

original_code:
int main(int argc, char** argv)
{
  if(argc != 3)
    exit(0);
  int x = atoi(argv[1]);
  int y = atoi(argv[2]);
  printf("x:%d, y:%d\n", x, y);
  printf("x = y  :%d\n", eq(x, y));
  printf("x != y :%d\n", ne(x, y));
  printf("x < y  :%d\n", lt(x, y));
  printf("x <= y :%d\n", le(x, y));
  printf("x u< y :%d\n", lt_unsigned(x, y));
  printf("x u<= y:%d\n", le_unsigned(x, y));
}

canonical_original_code:
int main(int argc, char **argv)
{
  if(argc != 3)
    exit(0);
  int x = atoi(argv[1]);
  int y = atoi(argv[2]);
  printf("x:%d, y:%d\n", x, y);
  printf("x = y  :%d\n", eq(x, y));
  printf("x != y :%d\n", ne(x, y));
  printf("x < y  :%d\n", lt(x, y));
  printf("x <= y :%d\n", le(x, y));
  printf("x u< y :%d\n", lt_unsigned(x, y));
  printf("x u<= y:%d\n", le_unsigned(x, y));
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
__int64 __fastcall zbytel1(unsigned int a1)
{
__int64 result; // rax

result = 0LL;
if ( HIBYTE(a1) )
{
result = 1LL;
if ( (a1 & 0xFF0000) != 0 )
{
result = 2LL;
if ( (a1 & 0xFF00) != 0 )
result = 3 - ((unsigned int)((_BYTE)a1 == 0) - 1);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int a1)
{
__int64 result; // rax

result = 0LL;
if ( HIBYTE(a1) )
{
result = 1LL;
if ( (a1 & 0xFF0000) != 0 )
{
result = 2LL;
if ( (a1 & 0xFF00) != 0 )
result = 3 - ((unsigned int)((_BYTE)a1 == 0) - 1);
}
}
return result;
}

original_code:
int zbytel1(unsigned int x)
{
  if((x>>24) == 0)
    return 0;
  else if((x&0x00FF0000) == 0)
    return 1;
  else if((x&0x0000FF00) == 0)
    return 2;
  else if((x&0x000000FF) == 0)
    return 3;
  else
    return 4;
}

variable_types:
x
unsigned int


decompiled_code:
__int64 __fastcall zbytel2(int a1)
{
return (unsigned int)((int)nlz(~(a1 | ((a1 & 0x7F7F7F7F) + 2139062143) | 0x7F7F7F7Fu)) >> 3);
}

original_code:
int zbytel2(unsigned int x)
{
  unsigned int y;
  int n;
  y = (x & 0x7F7F7F7F) + 0x7F7F7F7F;
  y = ~(y | x | 0x7F7F7F7F);
  n = nlz(y) >> 3;
  return n;
}

variable_types:
y
unsigned int

variable_types: n int


decompiled_code:
__int64 __fastcall search_word(int a1, int a2)
{
printf("temp hex:0x%x\n", (unsigned int)(16843009 * a2));
return zbytel2(a1 ^ (unsigned int)(16843009 * a2));
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1, int a2)
{
printf("temp hex:0x%x\n", (unsigned int)(16843009 * a2));
return func10(a1 ^ (unsigned int)(16843009 * a2));
}

original_code:
int search_word(unsigned int x, int word){
  int temp = 0;
  temp += word<<24;
  temp += word<<16;
  temp += word<<8;
  temp += word;
  printf("temp hex:0x%x\n", temp);
  return zbytel2(x^temp);
}

variable_types: word int

variable_types: temp int


decompiled_code:
__int64 __fastcall rightmost_bit_1_to_0(int a1)
{
return a1 & (unsigned int)(a1 - 1);
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
return a1 & (unsigned int)(a1 - 1);
}

original_code:
int rightmost_bit_1_to_0(int x)
{
  return x & (x-1);
}


decompiled_code:
__int64 __fastcall rightmost_bit_0_to_1(int a1)
{
return a1 | (unsigned int)(a1 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1)
{
return a1 | (unsigned int)(a1 + 1);
}

original_code:
int rightmost_bit_0_to_1(int x)
{
  return x | (x+1);
}


decompiled_code:
__int64 __fastcall get_rightmost_bit_1(int a1)
{
return a1 & (unsigned int)-a1;
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1)
{
return a1 & (unsigned int)-a1;
}

original_code:
int get_rightmost_bit_1(int x)
{
  return x & (-x);
}


decompiled_code:
__int64 __fastcall get_rightmost_bit_0(int a1)
{
return ~a1 & (unsigned int)(a1 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1)
{
return ~a1 & (unsigned int)(a1 + 1);
}

original_code:
int get_rightmost_bit_0(int x)
{
  return (~x) & (x+1);
}


decompiled_code:
__int64 __fastcall get_mask_last_line_0(int a1)
{
return ~a1 & (unsigned int)(a1 - 1);
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1)
{
return ~a1 & (unsigned int)(a1 - 1);
}

original_code:
int get_mask_last_line_0(int x)
{
  return (~x) & (x-1);
}


decompiled_code:
__int64 __fastcall rightmost_bit_1_propagate(int a1)
{
return a1 | (unsigned int)(a1 - 1);
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1)
{
return a1 | (unsigned int)(a1 - 1);
}

original_code:
int rightmost_bit_1_propagate(int x)
{
  return x | (x-1);
}


decompiled_code:
__int64 __fastcall rightmost_line_1_to_0(int a1)
{
return a1 & ((a1 | (unsigned int)(a1 - 1)) + 1);
}

canonical_decompiled_code:
__int64 __fastcall func13(int a1)
{
return a1 & ((a1 | (unsigned int)(a1 - 1)) + 1);
}

original_code:
int rightmost_line_1_to_0(int x)
{
  return ((x | (x-1)) + 1) & x;
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int v10; // eax
char v12[16]; // [rsp+8h] [rbp-10h] BYREF

if ( argc != 2 )
exit(0);
v3 = (unsigned int)atoi(argv[1]);
int2binary(v3, v12);
printf("argument :%.8s\n", v12);
v4 = rightmost_bit_1_to_0(v3);
int2binary(v4, v12);
printf("rightmost_bit_1_to_0 :%.8s\n", v12);
v5 = rightmost_bit_0_to_1(v3);
int2binary(v5, v12);
printf("rightmost_bit_0_to_1 :%.8s\n", v12);
v6 = get_rightmost_bit_1(v3);
int2binary(v6, v12);
printf("get_rightmost_bit_1 :%.8s\n", v12);
v7 = get_rightmost_bit_0(v3);
int2binary(v7, v12);
printf("get_rightmost_bit_0 :%.8s\n", v12);
v8 = get_mask_last_line_0(v3);
int2binary(v8, v12);
printf("get_mask_last_line_0 :%.8s\n", v12);
v9 = rightmost_bit_1_propagate(v3);
int2binary(v9, v12);
printf("rightmost_bit_1_propagate:%.8s\n", v12);
v10 = rightmost_line_1_to_0(v3);
int2binary(v10, v12);
printf("rightmost_line_1_to_0 :%.8s\n", v12);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int v10; // eax
char v12[16]; // [rsp+8h] [rbp-10h] BYREF

if ( argc != 2 )
exit(0);
v3 = (unsigned int)atoi(argv[1]);
int2binary(v3, v12);
printf("argument :%.8s\n", v12);
v4 = func7(v3);
int2binary(v4, v12);
printf("rightmost_bit_1_to_0 :%.8s\n", v12);
v5 = func8(v3);
int2binary(v5, v12);
printf("rightmost_bit_0_to_1 :%.8s\n", v12);
v6 = func9(v3);
int2binary(v6, v12);
printf("get_rightmost_bit_1 :%.8s\n", v12);
v7 = func10(v3);
int2binary(v7, v12);
printf("get_rightmost_bit_0 :%.8s\n", v12);
v8 = func11(v3);
int2binary(v8, v12);
printf("get_mask_last_line_0 :%.8s\n", v12);
v9 = func12(v3);
int2binary(v9, v12);
printf("rightmost_bit_1_propagate:%.8s\n", v12);
v10 = func13(v3);
int2binary(v10, v12);
printf("rightmost_line_1_to_0 :%.8s\n", v12);
return 0;
}

original_code:
int main(int argc, char** argv)
{
  if(argc != 2)
    exit(0);
  int x, y;
  char c[8];
  x = atoi(argv[1]);
  int2binary(x, c);
  printf("argument                 :%.8s\n", c);
  y = rightmost_bit_1_to_0(x);
  int2binary(y, c);
  printf("rightmost_bit_1_to_0     :%.8s\n", c);
  y = rightmost_bit_0_to_1(x);
  int2binary(y, c);
  printf("rightmost_bit_0_to_1     :%.8s\n", c);
  y = get_rightmost_bit_1(x);
  int2binary(y, c);
  printf("get_rightmost_bit_1      :%.8s\n", c);
  y = get_rightmost_bit_0(x);
  int2binary(y, c);
  printf("get_rightmost_bit_0      :%.8s\n", c);
  y = get_mask_last_line_0(x);
  int2binary(y, c);
  printf("get_mask_last_line_0     :%.8s\n", c);
  y = rightmost_bit_1_propagate(x);
  int2binary(y, c);
  printf("rightmost_bit_1_propagate:%.8s\n", c);
  y = rightmost_line_1_to_0(x);
  int2binary(y, c);
  printf("rightmost_line_1_to_0    :%.8s\n", c);
}

canonical_original_code:
int main(int argc, char **argv)
{
  if(argc != 2)
    exit(0);
  int x; int y;
  char c[8];
  x = atoi(argv[1]);
  int2binary(x, c);
  printf("argument                 :%.8s\n", c);
  y = rightmost_bit_1_to_0(x);
  int2binary(y, c);
  printf("rightmost_bit_1_to_0     :%.8s\n", c);
  y = rightmost_bit_0_to_1(x);
  int2binary(y, c);
  printf("rightmost_bit_0_to_1     :%.8s\n", c);
  y = get_rightmost_bit_1(x);
  int2binary(y, c);
  printf("get_rightmost_bit_1      :%.8s\n", c);
  y = get_rightmost_bit_0(x);
  int2binary(y, c);
  printf("get_rightmost_bit_0      :%.8s\n", c);
  y = get_mask_last_line_0(x);
  int2binary(y, c);
  printf("get_mask_last_line_0     :%.8s\n", c);
  y = rightmost_bit_1_propagate(x);
  int2binary(y, c);
  printf("rightmost_bit_1_propagate:%.8s\n", c);
  y = rightmost_line_1_to_0(x);
  int2binary(y, c);
  printf("rightmost_line_1_to_0    :%.8s\n", c);
}

variable_types:
c
char [8]


max

decompiled_code:
__int64 __fastcall max(int a1, int a2)
{
return a2 + (unsigned int)doz(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, int a2)
{
return a2 + (unsigned int)func7(a1, a2);
}

original_code:
int max(int x, int y)
{
  return y + doz(x, y);
}


min

decompiled_code:
__int64 __fastcall min(int a1, int a2)
{
return a1 - (unsigned int)doz(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1, int a2)
{
return a1 - (unsigned int)func7(a1, a2);
}

original_code:
int min(int x, int y)
{
  return x - doz(x, y);
}


dozu

decompiled_code:
__int64 __fastcall dozu(int a1, int a2)
{
return (a1 - a2) & (unsigned int)~((a2 & ~a1 | (a1 - a2) & ~(a2 ^ a1)) >> 31);
}

original_code:
unsigned int dozu(unsigned int x, unsigned int y)
{
  int d = x - y;
  return d & ~((int)(((~x&y) | (~(x^y) & d))) >> 31);
}

variable_types: d int

return_type: unsigned int


maxu

decompiled_code:
__int64 __fastcall maxu(int a1, int a2)
{
return a2 + (unsigned int)dozu(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func11(int a1, int a2)
{
return a2 + (unsigned int)func10(a1, a2);
}

original_code:
unsigned int maxu(unsigned int x, unsigned int y)
{
  return y + dozu(x, y);
}


minu

decompiled_code:
__int64 __fastcall minu(int a1, int a2)
{
return a1 - (unsigned int)dozu(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1, int a2)
{
return a1 - (unsigned int)func10(a1, a2);
}

original_code:
unsigned int minu(unsigned int x, unsigned int y)
{
  return x - dozu(x, y);
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebp
__int64 v4; // rbx
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int v10; // eax

if ( argc != 3 )
exit(0);
v3 = atoi(argv[1]);
v4 = (unsigned int)atoi(argv[2]);
printf("x:%d, y:%d\n", v3, v4);
v5 = doz(v3, v4);
printf("doz :%d\n", v5);
v6 = max(v3, v4);
printf("max :%d\n", v6);
v7 = min(v3, v4);
printf("min :%d\n", v7);
v8 = dozu(v3, v4);
printf("dozu:%u\n", v8);
v9 = maxu(v3, v4);
printf("maxu:%u\n", v9);
v10 = minu(v3, v4);
printf("minu:%u\n", v10);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebp
__int64 v4; // rbx
unsigned int v5; // eax
unsigned int v6; // eax
unsigned int v7; // eax
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int v10; // eax

if ( argc != 3 )
exit(0);
v3 = atoi(argv[1]);
v4 = (unsigned int)atoi(argv[2]);
printf("x:%d, y:%d\n", v3, v4);
v5 = func7(v3, v4);
printf("doz :%d\n", v5);
v6 = func8(v3, v4);
printf("max :%d\n", v6);
v7 = func9(v3, v4);
printf("min :%d\n", v7);
v8 = func10(v3, v4);
printf("dozu:%u\n", v8);
v9 = func11(v3, v4);
printf("maxu:%u\n", v9);
v10 = func12(v3, v4);
printf("minu:%u\n", v10);
return 0;
}

original_code:
int main(int argc, char** argv)
{
  if(argc != 3)
    exit(0);
  int x = atoi(argv[1]);
  int y = atoi(argv[2]);
  printf("x:%d, y:%d\n", x, y);
  printf("doz :%d\n", doz(x, y));
  printf("max :%d\n", max(x, y));
  printf("min :%d\n", min(x, y));
  printf("dozu:%u\n", dozu(x, y));
  printf("maxu:%u\n", maxu(x, y));
  printf("minu:%u\n", minu(x, y));
}

canonical_original_code:
int main(int argc, char **argv)
{
  if(argc != 3)
    exit(0);
  int x = atoi(argv[1]);
  int y = atoi(argv[2]);
  printf("x:%d, y:%d\n", x, y);
  printf("doz :%d\n", doz(x, y));
  printf("max :%d\n", max(x, y));
  printf("min :%d\n", min(x, y));
  printf("dozu:%u\n", dozu(x, y));
  printf("maxu:%u\n", maxu(x, y));
  printf("minu:%u\n", minu(x, y));
}


decompiled_code:
__int64 __fastcall cyclic_left_shift(int a1, char a2)
{
return (unsigned int)__ROL4__(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1, char a2)
{
return (unsigned int)__ROL4__(a1, a2);
}

original_code:
int cyclic_left_shift(int x, unsigned int n)
{
  return (x << n) | ((unsigned int)x >> (32-n));
}

variable_types:
n
unsigned int


decompiled_code:
__int64 __fastcall cyclic_right_shift(int a1, char a2)
{
return (unsigned int)__ROR4__(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, char a2)
{
return (unsigned int)__ROR4__(a1, a2);
}

original_code:
int cyclic_right_shift(int x, unsigned int n)
{
  return ((unsigned int)x >> n) | (x << (32-n));
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebp
__int64 v4; // rbx
unsigned int v5; // eax
unsigned int v6; // eax
char v8[56]; // [rsp+0h] [rbp-38h] BYREF

if ( argc != 3 )
exit(0);
v3 = atoi(argv[2]);
if ( v3 > 0x20 )
exit(0);
v4 = (unsigned int)atoi(argv[1]);
printf("x:%d, n:%d\n", v4, v3);
int2binary((unsigned int)v4, v8);
printf("before shift :%.32s\n", v8);
v5 = cyclic_left_shift(v4, v3);
int2binary(v5, v8);
printf("after left shift :%.32s\n", v8);
v6 = cyclic_right_shift(v4, v3);
int2binary(v6, v8);
printf("after right shift :%.32s\n", v8);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebp
__int64 v4; // rbx
unsigned int v5; // eax
unsigned int v6; // eax
char v8[56]; // [rsp+0h] [rbp-38h] BYREF

if ( argc != 3 )
exit(0);
v3 = atoi(argv[2]);
if ( v3 > 0x20 )
exit(0);
v4 = (unsigned int)atoi(argv[1]);
printf("x:%d, n:%d\n", v4, v3);
int2binary((unsigned int)v4, v8);
printf("before shift :%.32s\n", v8);
v5 = func7(v4, v3);
int2binary(v5, v8);
printf("after left shift :%.32s\n", v8);
v6 = func8(v4, v3);
int2binary(v6, v8);
printf("after right shift :%.32s\n", v8);
return 0;
}

original_code:
int main(int argc, char** argv)
{
  if(argc != 3)
    exit(0);
  int x = atoi(argv[1]);
  int y;
  int n = atoi(argv[2]);
  if(n > 32 || n < 0)
    exit(0);
  char c[32];
  printf("x:%d, n:%d\n", x, n);
  int2binary(x, c);
  printf("before shift      :%.32s\n", c);
  y = cyclic_left_shift(x, n);
  int2binary(y, c);
  printf("after left shift  :%.32s\n", c);
  y = cyclic_right_shift(x, n);
  int2binary(y, c);
  printf("after right shift :%.32s\n", c);
}

canonical_original_code:
int main(int argc, char **argv)
{
  if(argc != 3)
    exit(0);
  int x = atoi(argv[1]);
  int y;
  int n = atoi(argv[2]);
  if(n > 32 || n < 0)
    exit(0);
  char c[32];
  printf("x:%d, n:%d\n", x, n);
  int2binary(x, c);
  printf("before shift      :%.32s\n", c);
  y = cyclic_left_shift(x, n);
  int2binary(y, c);
  printf("after left shift  :%.32s\n", c);
  y = cyclic_right_shift(x, n);
  int2binary(y, c);
  printf("after right shift :%.32s\n", c);
}

variable_types:
c
char [32]


decompiled_code:
__int64 __fastcall detect_overflow_signed_add(int a1, int a2, int a3)
{
return (~(a2 ^ a1) & (a1 ^ (unsigned int)(a3 + a1 + a2))) >> 31;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1, int a2, int a3)
{
return (~(a2 ^ a1) & (a1 ^ (unsigned int)(a3 + a1 + a2))) >> 31;
}

original_code:
int detect_overflow_signed_add(int x, int y, int c)
{
  return (unsigned int)(~(x^y) & ((x+y+c)^x)) >> 31;
}

variable_types: c int


decompiled_code:
__int64 __fastcall detect_overflow_signed_sub(int a1, int a2, int a3)
{
return ((a2 ^ a1) & (a1 ^ (unsigned int)(a1 - a2 - a3))) >> 31;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, int a2, int a3)
{
return ((a2 ^ a1) & (a1 ^ (unsigned int)(a1 - a2 - a3))) >> 31;
}

original_code:
int detect_overflow_signed_sub(int x, int y, int c)
{
  return (unsigned int)((x^y) & ((x-y-c)^x)) >> 31;
}


decompiled_code:
__int64 __fastcall detect_overflow_unsigned_add(int a1, int a2, int a3)
{
return (a2 & a1 | (a2 | a1) & (unsigned int)~(a2 + a3 + a1)) >> 31;
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1, int a2, int a3)
{
return (a2 & a1 | (a2 | a1) & (unsigned int)~(a2 + a3 + a1)) >> 31;
}

original_code:
int detect_overflow_unsigned_add(unsigned int x, unsigned int y, unsigned int c)
{
   return (unsigned int)((x&y) | ((x|y) & ~(x+y+c))) >> 31;
}

variable_types:
c
unsigned int


decompiled_code:
__int64 __fastcall detect_overflow_unsigned_sub(int a1, int a2, int a3)
{
return ((a2 | ~a1) & (a1 - a2 - a3) | a2 & (unsigned int)~a1) >> 31;
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1, int a2, int a3)
{
return ((a2 | ~a1) & (a1 - a2 - a3) | a2 & (unsigned int)~a1) >> 31;
}

original_code:
int detect_overflow_unsigned_sub(unsigned int x, unsigned int y, unsigned int c)
{
  return (unsigned int)((~x&y) | ((~x|y) & (x-y-c))) >> 31;
}


decompiled_code:
__int64 __fastcall detect_overflow_signed_mul(__int64 a1, __int64 a2)
{
return ((unsigned int)(((unsigned __int64)(a2 * a1) >> 32) - (((int)a2 * (int)a1) >> 31)) | (unsigned int)((((int)a2 * (int)a1) >> 31) - ((unsigned __int64)(a2 * a1) >> 32))) >> 31;
}

original_code:
int detect_overflow_signed_mul(long x, long y)
{
  int hi = (x * y) >> 32;
  int lo = x * y;
  int sign_lo = lo >> 31;
  return (unsigned int)((hi - sign_lo) | (sign_lo - hi)) >> 31;
}

variable_types: x long

variable_types: y long

variable_types: hi int

variable_types: lo int


decompiled_code:
unsigned __int64 __fastcall detect_overflow_unsigned_mul(__int64 a1, __int64 a2)
{
return (-((unsigned __int64)(a2 * a1) >> 32) | ((unsigned __int64)(a2 * a1) >> 32)) >> 31;
}

original_code:
int detect_overflow_unsigned_mul(unsigned long x, unsigned long y)
{
  long hi = (x * y) >> 32;
  return (unsigned int)(hi | -hi) >> 31;
}

variable_types:
x
unsigned long

variable_types:
y
unsigned long

variable_types: hi long