main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v4; // rdi
__int64 v5; // rdx
int v6; // ebx
int v7; // ebp
char *v8; // rax
__int64 v9; // rbx
int v10; // eax
__int64 v12; // rsi
__int64 v13; // rdx
__int64 v14; // rsi
char v15; // r12
__int64 v16; // rsi
__int64 v17; // rsi
__int64 v18; // rsi
int v19; // eax
int v20; // eax
int v21; // eax
int v22; // [rsp+8h] [rbp-420h] BYREF
unsigned int v23; // [rsp+Ch] [rbp-41Ch] BYREF
char s[2]; // [rsp+10h] [rbp-418h] BYREF
char v25; // [rsp+12h] [rbp-416h]
char v26[2]; // [rsp+15h] [rbp-413h] BYREF
char v27; // [rsp+17h] [rbp-411h] BYREF
char v28[1040]; // [rsp+18h] [rbp-410h] BYREF

if ( argc <= 1 )
{
interactive = 0;
reset_labels(argc, argv, envp);
output_magic();
output_version();
LABEL_29:
output_header(0);
goto LABEL_4;
}
v4 = argv[1];
if ( strncmp(v4, "-i", 2uLL) )
{
interactive = 0;
v9 = 2LL;
reset_labels(v4, "-i", v5);
output_magic();
output_version();
do
{
output_until_space((char *)argv[v9 - 1], 1);
output_header(32);
v10 = v9++;
}
while ( v10 <= 15 && argc > v10 );
goto LABEL_29;
}
interactive = 1;
reset_labels(v4, "-i", v5);
LABEL_4:
v6 = interactive;
v7 = 0;
while ( 1 )
{
if ( v6 )
{
printf(">>> ");
fflush(stdout);
}
v8 = fgets(s, 1024, stdin);
v6 = interactive;
if ( !v8 && !interactive )
return 0;
if ( s[0] == 58 )
{
if ( (unsigned __int8)(s[1] - 97) <= 0x19u )
labels[(char)(s[1] - 97)] = current_addr;
}
else if ( *(_WORD *)s == 17473 && v25 == 68 )
{
output(32);
v6 = interactive;
}
else if ( *(_WORD *)s == 21843 && v25 == 66 )
{
output(33);
v6 = interactive;
}
else if ( *(_WORD *)s == 21837 && v25 == 76 )
{
output(34);
v6 = interactive;
}
else if ( *(_WORD *)s == 18756 && v25 == 86 )
{
output(35);
v6 = interactive;
}
else
{
switch ( *(_WORD *)s )
{
case 0x544C:
output(36);
v6 = interactive;
break;
case 0x454C:
output(37);
v6 = interactive;
break;
case 0x5145:
output(38);
v6 = interactive;
break;
default:
if ( *(_WORD *)s == 21828 && v25 == 80 )
{
output(64);
v6 = interactive;
}
else if ( !strncmp(s, "DROP", 4uLL) )
{
output(65);
v6 = interactive;
}
else if ( !strncmp(s, "NOP", 3uLL) )
{
output(66);
v6 = interactive;
}
else if ( !strncmp(s, "SWAP", 4uLL) )
{
output(67);
v6 = interactive;
}
else if ( !strncmp(s, "NEW", 3uLL) )
{
output(71);
v6 = interactive;
}
else if ( !strncmp(s, "RSTORE", 6uLL) )
{
output(72);
v6 = interactive;
}
else if ( !strncmp(s, "RLOAD", 4uLL) )
{
output(73);
v6 = interactive;
}
else if ( !strncmp(s, "END_THUNK", 9uLL) )
{
output(83);
v6 = interactive;
}
else
{
if ( (unsigned int)output_offset(s, "BR", 51)
|| (unsigned int)output_offset(s, "BRNZ", 52)
|| (unsigned int)output_offset(s, "THUNK", 82) )
{
goto LABEL_54;
}
if ( !strncmp(s, "FUNCALL ", 8uLL) )
{
v14 = getnum(v28, &v23);
if ( v23 )
{
output_num(50, v14);
goto LABEL_54;
}
goto LABEL_65;
}
if ( !strncmp(s, "FUNPCALL", 8uLL) )
{
output(80);
v6 = interactive;
}
else if ( !strncmp(s, "FUNDEF ", 7uLL) )
{
if ( !v7 )
{
v7 = get_two_nums(&v27, &v22, &v23);
if ( v7 )
{
v12 = v23;
v7 = 1;
output_nums(48, v23, v22);
reset_labels(48LL, v12, v13);
goto LABEL_54;
}
LABEL_65:
fwrite("?\n", 1uLL, 2uLL, stderr);
goto LABEL_54;
}
LABEL_72:
fwrite("?\n", 1uLL, 2uLL, stderr);
v6 = interactive;
}
else if ( !strncmp(s, "FUNEND", 6uLL) )
{
v21 = funend(49, v7);
v6 = interactive;
v7 = v21;
}
else if ( !strncmp(s, "RET0", 4uLL) )
{
v20 = funend(69, v7);
v6 = interactive;
v7 = v20;
}
else if ( !strncmp(s, "RET1", 4uLL) )
{
v19 = funend(70, v7);
v6 = interactive;
v7 = v19;
}
else
{
if ( !strncmp(s, "LOAD ", 5uLL) )
{
v18 = getnum(v26, &v23);
if ( !v23 )
goto LABEL_65;
output_num(68, v18);
goto LABEL_54;
}
if ( !strncmp(s, "FFIDEF ", 7uLL) )
{
if ( v7 )
goto LABEL_72;
if ( !(unsigned int)handle_ffidef(&v27) )
{
fwrite("FFIDEF?\n", 1uLL, 8uLL, stderr);
goto LABEL_4;
}
LABEL_54:
v6 = interactive;
}
else
{
v15 = s[0];
if ( s[0] == 102 )
{
v17 = getnum(&s[1], &v23);
if ( !v23 )
goto LABEL_65;
output_num(81, v17);
goto LABEL_54;
}
if ( s[0] == 45 || ((*_ctype_b_loc())[v15] & 0x800) != 0 )
{
v16 = getnum(s, &v23);
if ( !v23 )
goto LABEL_65;
output_num(31, v16);
goto LABEL_54;
}
v6 = interactive;
if ( interactive && !strncmp(s, "run", 3uLL) )
{
parse_buffer(interactive_buffer, (unsigned int)interactive_bufferpos);
goto LABEL_54;
}
if ( v15 )
goto LABEL_72;
}
}
}
break;
}
}
}
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v4; // rdi
__int64 v5; // rdx
int v6; // ebx
int v7; // ebp
char *v8; // rax
__int64 v9; // rbx
int v10; // eax
__int64 v12; // rsi
__int64 v13; // rdx
__int64 v14; // rsi
char v15; // r12
__int64 v16; // rsi
__int64 v17; // rsi
__int64 v18; // rsi
int v19; // eax
int v20; // eax
int v21; // eax
int v22; // [rsp+8h] [rbp-420h] BYREF
unsigned int v23; // [rsp+Ch] [rbp-41Ch] BYREF
char s[2]; // [rsp+10h] [rbp-418h] BYREF
char v25; // [rsp+12h] [rbp-416h]
char v26[2]; // [rsp+15h] [rbp-413h] BYREF
char v27; // [rsp+17h] [rbp-411h] BYREF
char v28[1040]; // [rsp+18h] [rbp-410h] BYREF

if ( argc <= 1 )
{
interactive = 0;
func16(argc, argv, envp);
func8();
func7();
LABEL_29:
func5(0);
goto LABEL_4;
}
v4 = argv[1];
if ( strncmp(v4, "-i", 2uLL) )
{
interactive = 0;
v9 = 2LL;
func16(v4, "-i", v5);
func8();
func7();
do
{
func6((char *)argv[v9 - 1], 1);
func5(32);
v10 = v9++;
}
while ( v10 <= 15 && argc > v10 );
goto LABEL_29;
}
interactive = 1;
func16(v4, "-i", v5);
LABEL_4:
v6 = interactive;
v7 = 0;
while ( 1 )
{
if ( v6 )
{
printf(">>> ");
fflush(stdout);
}
v8 = fgets(s, 1024, stdin);
v6 = interactive;
if ( !v8 && !interactive )
return 0;
if ( s[0] == 58 )
{
if ( (unsigned __int8)(s[1] - 97) <= 0x19u )
labels[(char)(s[1] - 97)] = current_addr;
}
else if ( *(_WORD *)s == 17473 && v25 == 68 )
{
func13(32);
v6 = interactive;
}
else if ( *(_WORD *)s == 21843 && v25 == 66 )
{
func13(33);
v6 = interactive;
}
else if ( *(_WORD *)s == 21837 && v25 == 76 )
{
func13(34);
v6 = interactive;
}
else if ( *(_WORD *)s == 18756 && v25 == 86 )
{
func13(35);
v6 = interactive;
}
else
{
switch ( *(_WORD *)s )
{
case 0x544C:
func13(36);
v6 = interactive;
break;
case 0x454C:
func13(37);
v6 = interactive;
break;
case 0x5145:
func13(38);
v6 = interactive;
break;
default:
if ( *(_WORD *)s == 21828 && v25 == 80 )
{
func13(64);
v6 = interactive;
}
else if ( !strncmp(s, "DROP", 4uLL) )
{
func13(65);
v6 = interactive;
}
else if ( !strncmp(s, "NOP", 3uLL) )
{
func13(66);
v6 = interactive;
}
else if ( !strncmp(s, "SWAP", 4uLL) )
{
func13(67);
v6 = interactive;
}
else if ( !strncmp(s, "NEW", 3uLL) )
{
func13(71);
v6 = interactive;
}
else if ( !strncmp(s, "RSTORE", 6uLL) )
{
func13(72);
v6 = interactive;
}
else if ( !strncmp(s, "RLOAD", 4uLL) )
{
func13(73);
v6 = interactive;
}
else if ( !strncmp(s, "END_THUNK", 9uLL) )
{
func13(83);
v6 = interactive;
}
else
{
if ( (unsigned int)func17(s, "BR", 51)
|| (unsigned int)func17(s, "BRNZ", 52)
|| (unsigned int)func17(s, "THUNK", 82) )
{
goto LABEL_54;
}
if ( !strncmp(s, "FUNCALL ", 8uLL) )
{
v14 = func1(v28, &v23);
if ( v23 )
{
func11(50, v14);
goto LABEL_54;
}
goto LABEL_65;
}
if ( !strncmp(s, "FUNPCALL", 8uLL) )
{
func13(80);
v6 = interactive;
}
else if ( !strncmp(s, "FUNDEF ", 7uLL) )
{
if ( !v7 )
{
v7 = func0(&v27, &v22, &v23);
if ( v7 )
{
v12 = v23;
v7 = 1;
func9(48, v23, v22);
func16(48LL, v12, v13);
goto LABEL_54;
}
LABEL_65:
fwrite("?\n", 1uLL, 2uLL, stderr);
goto LABEL_54;
}
LABEL_72:
fwrite("?\n", 1uLL, 2uLL, stderr);
v6 = interactive;
}
else if ( !strncmp(s, "FUNEND", 6uLL) )
{
v21 = func15(49, v7);
v6 = interactive;
v7 = v21;
}
else if ( !strncmp(s, "RET0", 4uLL) )
{
v20 = func15(69, v7);
v6 = interactive;
v7 = v20;
}
else if ( !strncmp(s, "RET1", 4uLL) )
{
v19 = func15(70, v7);
v6 = interactive;
v7 = v19;
}
else
{
if ( !strncmp(s, "LOAD ", 5uLL) )
{
v18 = func1(v26, &v23);
if ( !v23 )
goto LABEL_65;
func11(68, v18);
goto LABEL_54;
}
if ( !strncmp(s, "FFIDEF ", 7uLL) )
{
if ( v7 )
goto LABEL_72;
if ( !(unsigned int)func18(&v27) )
{
fwrite("FFIDEF?\n", 1uLL, 8uLL, stderr);
goto LABEL_4;
}
LABEL_54:
v6 = interactive;
}
else
{
v15 = s[0];
if ( s[0] == 102 )
{
v17 = func1(&s[1], &v23);
if ( !v23 )
goto LABEL_65;
func11(81, v17);
goto LABEL_54;
}
if ( s[0] == 45 || ((*_ctype_b_loc())[v15] & 0x800) != 0 )
{
v16 = func1(s, &v23);
if ( !v23 )
goto LABEL_65;
func11(31, v16);
goto LABEL_54;
}
v6 = interactive;
if ( interactive && !strncmp(s, "run", 3uLL) )
{
parse_buffer(interactive_buffer, (unsigned int)interactive_bufferpos);
goto LABEL_54;
}
if ( v15 )
goto LABEL_72;
}
}
}
break;
}
}
}
}

original_code:
int main(int argc, char **argv)
{
 char buf[1024];
 int fundef = 0;
 interactive = argc > 1 && !strncmp(argv[1], "-i", 2);
 reset_labels();
 if(!interactive) {
  int lib_index = 1;
  output_magic();
  output_version();
  for(lib_index = 1; lib_index < 16 && lib_index < argc;
    lib_index++) {
   output_until_space(argv[lib_index], 1);
   output_header(' ');
  }
  output_header('\0');
 }
 while(1) {
  int emptyline;
  if(interactive) {
   printf(">>> ");
   fflush(stdout);
  }
  emptyline = (fgets(buf, 1024, stdin) == ((void *)0));
  if(!interactive && emptyline)
   break;
  if(buf[0] == ':') {
   if(buf[1] >= 'a' && buf[1] <= 'z') {
    labels[buf[1] - 'a'] = current_addr;
   }
  }
  else if(!strncmp(buf, "ADD", 3)) {
   output(0x20);
  }
  else if(!strncmp(buf, "SUB", 3)) {
   output(0x21);
  }
  else if(!strncmp(buf, "MUL", 3)) {
   output(0x22);
  }
  else if(!strncmp(buf, "DIV", 3)) {
   output(0x23);
  }
  else if(!strncmp(buf, "LT", 2)) {
   output(0x24);
  }
  else if(!strncmp(buf, "LE", 2)) {
   output(0x25);
  }
  else if(!strncmp(buf, "EQ", 2)) {
   output(0x26);
  }
  else if(!strncmp(buf, "DUP", 3)) {
   output(0x40);
  }
  else if(!strncmp(buf, "DROP", 4)) {
   output(0x41);
  }
  else if(!strncmp(buf, "NOP", 3)) {
   output(0x42);
  }
  else if(!strncmp(buf, "SWAP", 4)) {
   output(0x43);
  }
  else if(!strncmp(buf, "NEW", 3)) {
   output(0x47);
  }
  else if(!strncmp(buf, "RSTORE", 6)) {
   output(0x48);
  }
  else if(!strncmp(buf, "RLOAD", 4)) {
   output(0x49);
  }
  else if(!strncmp(buf, "END_THUNK", 9)) {
   output(0x53);
  }
  else if(output_offset(buf, "BR", 0x33));
  else if(output_offset(buf, "BRNZ", 0x34));
  else if(output_offset(buf, "THUNK", 0x52));
  else if(!strncmp(buf, "FUNCALL ", 8)) {
   int succ;
   long int parsed_num = getnum(buf + 8, &succ);
   if(!succ)
    fprintf(stderr, "?\n");
   else {
    output_num(0x32, parsed_num);
   }
  }
  else if(!strncmp(buf, "FUNPCALL", 8)) {
   output(0x50);
  }
  else if(!strncmp(buf, "FUNDEF ", 7)) {
   if(fundef) {
    fprintf(stderr, "?\n");
   }
   else {
    int parsed_funnum, parsed_params;
    int succ = get_two_nums(buf + 7, &parsed_funnum, &parsed_params);
    if(!succ)
     fprintf(stderr, "?\n");
    else {
     output_nums(0x30, parsed_params, parsed_funnum);
     fundef = 1;
     reset_labels();
    }
   }
  }
  else if(!strncmp(buf, "FUNEND", 6)) {
   fundef = funend(0x31, fundef);
  }
  else if(!strncmp(buf, "RET0", 4)) {
   fundef = funend(0x45, fundef);
  }
  else if(!strncmp(buf, "RET1", 4)) {
   fundef = funend(0x46, fundef);
  }
  else if(!strncmp(buf, "LOAD ", 5)) {
   int succ;
   long int parsed_num = getnum(buf + 5, &succ);
   if(!succ)
    fprintf(stderr, "?\n");
   else
    output_num(0x44, parsed_num);
  }
  else if(!strncmp(buf, "FFIDEF ", 7)) {
   if(fundef) {
    fprintf(stderr, "?\n");
   }
   else {
    int succ = handle_ffidef(buf + 7);
    if(!succ) {
     fprintf(stderr, "FFIDEF?\n");
    }
   }
  }
  else if(buf[0] == 'f') {
   int succ;
   long int parsed_num = getnum(buf + 1, &succ);
   if(!succ)
    fprintf(stderr, "?\n");
   else
    output_num(0x51, parsed_num);
  }
  else if(buf[0] == '-' || ((*__ctype_b_loc ())[(int) ((buf[0]))] & (unsigned short int) _ISdigit)) {
   int succ;
   long int parsed_num = getnum(buf, &succ);
   if(!succ)
    fprintf(stderr, "?\n");
   else
    output_num(0x1f, parsed_num);
  }
  else if(interactive && !strncmp(buf, "run", 3)) {
   parse_buffer(interactive_buffer,
     interactive_bufferpos);
  }
  else if(buf[0]) {
   fprintf(stderr, "?\n");
  }
 }
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 char buf[1024];
 int fundef = 0;
 interactive = argc > 1 && !strncmp(argv[1], "-i", 2);
 reset_labels();
 if(!interactive) {
  int lib_index = 1;
  output_magic();
  output_version();
  for(lib_index = 1; lib_index < 16 && lib_index < argc;
    lib_index++) {
   output_until_space(argv[lib_index], 1);
   output_header(' ');
  }
  output_header('\0');
 }
 while(1) {
  int emptyline;
  if(interactive) {
   printf(">>> ");
   fflush(stdout);
  }
  emptyline = (fgets(buf, 1024, stdin) == ((void *)0));
  if(!interactive && emptyline)
   break;
  if(buf[0] == ':') {
   if(buf[1] >= 'a' && buf[1] <= 'z') {
    labels[buf[1] - 'a'] = current_addr;
   }
  }
  else if(!strncmp(buf, "ADD", 3)) {
   output(0x20);
  }
  else if(!strncmp(buf, "SUB", 3)) {
   output(0x21);
  }
  else if(!strncmp(buf, "MUL", 3)) {
   output(0x22);
  }
  else if(!strncmp(buf, "DIV", 3)) {
   output(0x23);
  }
  else if(!strncmp(buf, "LT", 2)) {
   output(0x24);
  }
  else if(!strncmp(buf, "LE", 2)) {
   output(0x25);
  }
  else if(!strncmp(buf, "EQ", 2)) {
   output(0x26);
  }
  else if(!strncmp(buf, "DUP", 3)) {
   output(0x40);
  }
  else if(!strncmp(buf, "DROP", 4)) {
   output(0x41);
  }
  else if(!strncmp(buf, "NOP", 3)) {
   output(0x42);
  }
  else if(!strncmp(buf, "SWAP", 4)) {
   output(0x43);
  }
  else if(!strncmp(buf, "NEW", 3)) {
   output(0x47);
  }
  else if(!strncmp(buf, "RSTORE", 6)) {
   output(0x48);
  }
  else if(!strncmp(buf, "RLOAD", 4)) {
   output(0x49);
  }
  else if(!strncmp(buf, "END_THUNK", 9)) {
   output(0x53);
  }
  else if(output_offset(buf, "BR", 0x33));
  else if(output_offset(buf, "BRNZ", 0x34));
  else if(output_offset(buf, "THUNK", 0x52));
  else if(!strncmp(buf, "FUNCALL ", 8)) {
   int succ;
   long parsed_num = getnum(buf + 8, &succ);
   if(!succ)
    fprintf(stderr, "?\n");
   else {
    output_num(0x32, parsed_num);
   }
  }
  else if(!strncmp(buf, "FUNPCALL", 8)) {
   output(0x50);
  }
  else if(!strncmp(buf, "FUNDEF ", 7)) {
   if(fundef) {
    fprintf(stderr, "?\n");
   }
   else {
    int parsed_funnum; int parsed_params;
    int succ = get_two_nums(buf + 7, &parsed_funnum, &parsed_params);
    if(!succ)
     fprintf(stderr, "?\n");
    else {
     output_nums(0x30, parsed_params, parsed_funnum);
     fundef = 1;
     reset_labels();
    }
   }
  }
  else if(!strncmp(buf, "FUNEND", 6)) {
   fundef = funend(0x31, fundef);
  }
  else if(!strncmp(buf, "RET0", 4)) {
   fundef = funend(0x45, fundef);
  }
  else if(!strncmp(buf, "RET1", 4)) {
   fundef = funend(0x46, fundef);
  }
  else if(!strncmp(buf, "LOAD ", 5)) {
   int succ;
   long parsed_num = getnum(buf + 5, &succ);
   if(!succ)
    fprintf(stderr, "?\n");
   else
    output_num(0x44, parsed_num);
  }
  else if(!strncmp(buf, "FFIDEF ", 7)) {
   if(fundef) {
    fprintf(stderr, "?\n");
   }
   else {
    int succ = handle_ffidef(buf + 7);
    if(!succ) {
     fprintf(stderr, "FFIDEF?\n");
    }
   }
  }
  else if(buf[0] == 'f') {
   int succ;
   long parsed_num = getnum(buf + 1, &succ);
   if(!succ)
    fprintf(stderr, "?\n");
   else
    output_num(0x51, parsed_num);
  }
  else if(buf[0] == '-' || ((*__ctype_b_loc ())[(int) ((buf[0]))] & (unsigned short) _ISdigit)) {
   int succ;
   long parsed_num = getnum(buf, &succ);
   if(!succ)
    fprintf(stderr, "?\n");
   else
    output_num(0x1f, parsed_num);
  }
  else if(interactive && !strncmp(buf, "run", 3)) {
   parse_buffer(interactive_buffer,
     interactive_bufferpos);
  }
  else if(buf[0]) {
   fprintf(stderr, "?\n");
  }
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
buf
char [1024]

variable_types: emptyline int


usage

repo: anttisalonen/lvm

decompiled_code:
size_t __fastcall usage(const char *a1)
{
fprintf(stderr, "Usage: %s <filename>\n", a1);
return fwrite("\tsimple stack machine\n", 1uLL, 0x16uLL, stderr);
}

canonical_decompiled_code:
size_t __fastcall func0(const char *a1)
{
fprintf(stderr, "Usage: %s <filename>\n", a1);
return fwrite("\tsimple stack machine\n", 1uLL, 0x16uLL, stderr);
}

original_code:
void usage(const char *pn)
{
 fprintf(stderr, "Usage: %s <filename>\n",
   pn);
 fprintf(stderr, "\tsimple stack machine\n");
}

canonical_original_code:
void usage(char *pn)
{
 fprintf(stderr, "Usage: %s <filename>\n",
   pn);
 fprintf(stderr, "\tsimple stack machine\n");
}

variable_types:
pn
char *

return_type: void


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
if ( argc == 2 )
return parse_file(argv[1]);
usage(*argv);
return 1;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
if ( argc == 2 )
return parse_file(argv[1]);
func0(*argv);
return 1;
}

original_code:
int main(int argc, char **argv)
{
 if(argc != 2) {
  usage(argv[0]);
  return 1;
 }
 return parse_file(argv[1]);
}

return_type: int


repo: anyc/pmtools

decompiled_code:
int __fastcall acpi_table_print(__int64 a1, const void *a2)
{
int result; // eax

if ( a1 )
result = printf(
"ACPI: %.4s (v%3.3d %6.6s %8.8s 0x%08x %.4s 0x%08x) @ 0x%p\n",
(const char *)a1,
*(unsigned __int8 *)(a1 + 8),
(const char *)(a1 + 10),
(const char *)(a1 + 16),
*(unsigned int *)(a1 + 24),
(const char *)(a1 + 28),
*(unsigned int *)(a1 + 32),
a2);
return result;
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1, const void *a2)
{
int result; // eax

if ( a1 )
result = printf(
"ACPI: %.4s (v%3.3d %6.6s %8.8s 0x%08x %.4s 0x%08x) @ 0x%p\n",
(const char *)a1,
*(unsigned __int8 *)(a1 + 8),
(const char *)(a1 + 10),
(const char *)(a1 + 16),
*(unsigned int *)(a1 + 24),
(const char *)(a1 + 28),
*(unsigned int *)(a1 + 32),
a2);
return result;
}

original_code:
void
acpi_table_print (
 struct acpi_table_header *header,
 unsigned long phys_addr)
{
 char *name = ((void *)0);
 if (!header)
  return;
  name = header->signature;
 printf("" "ACPI: " "%.4s (v%3.3d %6.6s %8.8s 0x%08x %.4s 0x%08x) @ 0x%p\n",
  name, header->revision, header->oem_id,
  header->oem_table_id, header->oem_revision,
  header->asl_compiler_id, header->asl_compiler_revision,
  (void *) phys_addr);
}

canonical_original_code:
void acpi_table_print(struct acpi_table_header *header, unsigned long phys_addr)
{
 char *name = ((void *)0);
 if (!header)
  return;
  name = header->signature;
 printf("" "ACPI: " "%.4s (v%3.3d %6.6s %8.8s 0x%08x %.4s 0x%08x) @ 0x%p\n",
  name, header->revision, header->oem_id,
  header->oem_table_id, header->oem_revision,
  header->asl_compiler_id, header->asl_compiler_revision,
  (void *) phys_addr);
}

variable_types: struct acpi_table_header { char signature[4]; unsigned int length; unsigned char revision; unsigned char checksum; char oem_id[6]; char oem_table_id[8]; unsigned int oem_revision; char asl_compiler_id[4]; unsigned int asl_compiler_revision; } *

variable_types:
name
char *


repo: aodinokov/expos

decompiled_code:
__int64 __fastcall elf_hash(unsigned __int8 *a1)
{
__int64 result; // rax
unsigned __int8 *v2; // rdi
__int64 v3; // rdx

result = *a1;
v2 = a1 + 1;
if ( !(_BYTE)result )
return 0LL;
while ( 1 )
{
v3 = *v2;
if ( !(_BYTE)v3 )
break;
while ( 1 )
{
++v2;
result = v3 + 16 * result;
if ( (result & 0xF0000000) == 0 )
break;
result ^= (unsigned int)result & 0xF0000000 | ((unsigned __int64)((unsigned int)result & 0xF0000000) >> 24);
v3 = *v2;
if ( !(_BYTE)v3 )
return result;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 *a1)
{
__int64 result; // rax
unsigned __int8 *v2; // rdi
__int64 v3; // rdx

result = *a1;
v2 = a1 + 1;
if ( !(_BYTE)result )
return 0LL;
while ( 1 )
{
v3 = *v2;
if ( !(_BYTE)v3 )
break;
while ( 1 )
{
++v2;
result = v3 + 16 * result;
if ( (result & 0xF0000000) == 0 )
break;
result ^= (unsigned int)result & 0xF0000000 | ((unsigned __int64)((unsigned int)result & 0xF0000000) >> 24);
v3 = *v2;
if ( !(_BYTE)v3 )
return result;
}
}
return result;
}

original_code:
unsigned long
elf_hash(const unsigned char *name) {
    unsigned long hash = 0;
    unsigned long tmp;
    while (*name) {
 hash = (hash << 4) + (unsigned char)*name++;
 if ((tmp = hash & 0xf0000000)) {
     hash ^= tmp | (tmp >> 24);
 }
    }
    return hash;
}

canonical_original_code:
unsigned long elf_hash(unsigned char *name) {
    unsigned long hash = 0;
    unsigned long tmp;
    while (*name) {
 hash = (hash << 4) + (unsigned char)*name++;
 if ((tmp = hash & 0xf0000000)) {
     hash ^= tmp | (tmp >> 24);
 }
    }
    return hash;
}

variable_types:
name
unsigned char *

variable_types:
hash
unsigned long

variable_types:
tmp
unsigned long

return_type: unsigned long


original_code:
int
gelf_update_shdr(Elf_Scn *scn, GElf_Shdr *src) {
    if (!scn || !src) {
 return 0;
    }
    do{}while(0);
    do{}while(0);
    do{}while(0);
    if (scn->s_elf->e_class == 2) {
 scn->s_uhdr.u_shdr64 = *src;
    }
    else if (scn->s_elf->e_class == 1) {
 Elf32_Shdr *dst = &scn->s_uhdr.u_shdr32;
 do { if (sizeof((dst)->sh_name) < sizeof((src)->sh_name) && (Elf32_Word)(src)->sh_name != (src)->sh_name) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_name = (Elf32_Word)(src)->sh_name; } while (0);
 do { if (sizeof((dst)->sh_type) < sizeof((src)->sh_type) && (Elf32_Word)(src)->sh_type != (src)->sh_type) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_type = (Elf32_Word)(src)->sh_type; } while (0);
 do { if (sizeof((dst)->sh_flags) < sizeof((src)->sh_flags) && (Elf32_Word)(src)->sh_flags != (src)->sh_flags) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_flags = (Elf32_Word)(src)->sh_flags; } while (0);
 do { if (sizeof((dst)->sh_addr) < sizeof((src)->sh_addr) && (Elf32_Addr)(src)->sh_addr != (src)->sh_addr) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_addr = (Elf32_Addr)(src)->sh_addr; } while (0);
 do { if (sizeof((dst)->sh_offset) < sizeof((src)->sh_offset) && (Elf32_Off)(src)->sh_offset != (src)->sh_offset) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_offset = (Elf32_Off)(src)->sh_offset; } while (0);
 do { if (sizeof((dst)->sh_size) < sizeof((src)->sh_size) && (Elf32_Word)(src)->sh_size != (src)->sh_size) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_size = (Elf32_Word)(src)->sh_size; } while (0);
 do { if (sizeof((dst)->sh_link) < sizeof((src)->sh_link) && (Elf32_Word)(src)->sh_link != (src)->sh_link) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_link = (Elf32_Word)(src)->sh_link; } while (0);
 do { if (sizeof((dst)->sh_info) < sizeof((src)->sh_info) && (Elf32_Word)(src)->sh_info != (src)->sh_info) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_info = (Elf32_Word)(src)->sh_info; } while (0);
 do { if (sizeof((dst)->sh_addralign) < sizeof((src)->sh_addralign) && (Elf32_Word)(src)->sh_addralign != (src)->sh_addralign) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_addralign = (Elf32_Word)(src)->sh_addralign; } while (0);
 do { if (sizeof((dst)->sh_entsize) < sizeof((src)->sh_entsize) && (Elf32_Word)(src)->sh_entsize != (src)->sh_entsize) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_entsize = (Elf32_Word)(src)->sh_entsize; } while (0);
    }
    else {
 if (((scn->s_elf->e_class) >= 1 && (scn->s_elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNIMPLEMENTED));
 }
 else {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 return 0;
    }
    return 1;
}

canonical_original_code:
int gelf_update_shdr(struct Elf_Scn *scn, struct Elf64_Shdr *src) {
    if (!scn || !src) {
 return 0;
    }
    do{}while(0);
    do{}while(0);
    do{}while(0);
    if (scn->s_elf->e_class == 2) {
 scn->s_uhdr.u_shdr64 = *src;
    }
    else if (scn->s_elf->e_class == 1) {
 struct Elf32_Shdr *dst = &scn->s_uhdr.u_shdr32;
 do { if (sizeof((dst)->sh_name) < sizeof((src)->sh_name) && (Elf32_Word)(src)->sh_name != (src)->sh_name) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_name = (Elf32_Word)(src)->sh_name; } while (0);
 do { if (sizeof((dst)->sh_type) < sizeof((src)->sh_type) && (Elf32_Word)(src)->sh_type != (src)->sh_type) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_type = (Elf32_Word)(src)->sh_type; } while (0);
 do { if (sizeof((dst)->sh_flags) < sizeof((src)->sh_flags) && (Elf32_Word)(src)->sh_flags != (src)->sh_flags) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_flags = (Elf32_Word)(src)->sh_flags; } while (0);
 do { if (sizeof((dst)->sh_addr) < sizeof((src)->sh_addr) && (Elf32_Addr)(src)->sh_addr != (src)->sh_addr) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_addr = (Elf32_Addr)(src)->sh_addr; } while (0);
 do { if (sizeof((dst)->sh_offset) < sizeof((src)->sh_offset) && (Elf32_Off)(src)->sh_offset != (src)->sh_offset) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_offset = (Elf32_Off)(src)->sh_offset; } while (0);
 do { if (sizeof((dst)->sh_size) < sizeof((src)->sh_size) && (Elf32_Word)(src)->sh_size != (src)->sh_size) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_size = (Elf32_Word)(src)->sh_size; } while (0);
 do { if (sizeof((dst)->sh_link) < sizeof((src)->sh_link) && (Elf32_Word)(src)->sh_link != (src)->sh_link) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_link = (Elf32_Word)(src)->sh_link; } while (0);
 do { if (sizeof((dst)->sh_info) < sizeof((src)->sh_info) && (Elf32_Word)(src)->sh_info != (src)->sh_info) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_info = (Elf32_Word)(src)->sh_info; } while (0);
 do { if (sizeof((dst)->sh_addralign) < sizeof((src)->sh_addralign) && (Elf32_Word)(src)->sh_addralign != (src)->sh_addralign) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_addralign = (Elf32_Word)(src)->sh_addralign; } while (0);
 do { if (sizeof((dst)->sh_entsize) < sizeof((src)->sh_entsize) && (Elf32_Word)(src)->sh_entsize != (src)->sh_entsize) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->sh_entsize = (Elf32_Word)(src)->sh_entsize; } while (0);
    }
    else {
 if (((scn->s_elf->e_class) >= 1 && (scn->s_elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNIMPLEMENTED));
 }
 else {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 return 0;
    }
    return 1;
}

variable_types: struct Elf_Scn { struct Elf_Scn *s_link; struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 } e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; } *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; } *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data { struct Elf_Data { void *d_buf; enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 } d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; } sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; } *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } u_shdr64; struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } u_shdr32; } s_uhdr; long s_magic; } *

variable_types:
src
struct Elf64_Shdr *

variable_types: struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } *

user_defined_types: struct Elf_Scn { struct Elf_Scn *s_link; struct Elf *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { struct Elf64_Shdr u_shdr64; struct Elf32_Shdr u_shdr32; } s_uhdr; long s_magic; }

user_defined_types: struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; }

user_defined_types: struct Scn_Data { struct Elf_Data sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; }

user_defined_types: struct Elf_Data { void *d_buf; enum Elf_Type d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; }


parse

decompiled_code:
__int64 __fastcall parse(int argc, char **argv)
{
int v3; // eax
__int64 result; // rax
const char *v5; // rsi
int longind; // [rsp+Ch] [rbp-10Ch] BYREF
struct option longopts; // [rsp+10h] [rbp-108h] BYREF
const char *v8; // [rsp+30h] [rbp-E8h]
int v9; // [rsp+38h] [rbp-E0h]
__int64 v10; // [rsp+40h] [rbp-D8h]
int v11; // [rsp+48h] [rbp-D0h]
const char *v12; // [rsp+50h] [rbp-C8h]
int v13; // [rsp+58h] [rbp-C0h]
__int64 v14; // [rsp+60h] [rbp-B8h]
int v15; // [rsp+68h] [rbp-B0h]
const char *v16; // [rsp+70h] [rbp-A8h]
int v17; // [rsp+78h] [rbp-A0h]
__int64 v18; // [rsp+80h] [rbp-98h]
int v19; // [rsp+88h] [rbp-90h]
const char *v20; // [rsp+90h] [rbp-88h]
int v21; // [rsp+98h] [rbp-80h]
__int64 v22; // [rsp+A0h] [rbp-78h]
int v23; // [rsp+A8h] [rbp-70h]
const char *v24; // [rsp+B0h] [rbp-68h]
int v25; // [rsp+B8h] [rbp-60h]
__int64 v26; // [rsp+C0h] [rbp-58h]
int v27; // [rsp+C8h] [rbp-50h]
__int64 v28; // [rsp+D0h] [rbp-48h]
int v29; // [rsp+D8h] [rbp-40h]
__int64 v30; // [rsp+E0h] [rbp-38h]
int v31; // [rsp+E8h] [rbp-30h]

longopts.name = "help";
v8 = "list";
v12 = "pid";
v16 = "module";
v20 = "group";
longopts.has_arg = 0;
longopts.flag = 0LL;
longopts.val = 104;
v9 = 0;
v10 = 0LL;
v11 = 108;
v13 = 1;
v14 = 0LL;
v15 = 112;
v17 = 1;
v18 = 0LL;
v19 = 100;
v21 = 1;
v22 = 0LL;
v23 = 103;
v24 = "mask";
v25 = 1;
v26 = 0LL;
v27 = 109;
v28 = 0LL;
v29 = 0;
v30 = 0LL;
v31 = 0;
while ( 2 )
{
v3 = getopt_long(argc, argv, "hlp:d:g:m:", &longopts, &longind);
if ( v3 == -1 )
{
result = 0LL;
if ( optind < argc )
{
printf("Unknown parameter: ");
while ( optind < argc )
{
v5 = argv[optind++];
printf("%s ", v5);
}
putchar(10);
result = 1LL;
}
}
else
{
switch ( v3 )
{
case 'd':
module = optarg;
continue;
case 'g':
group = optarg;
continue;
case 'l':
list = 1;
continue;
case 'm':
mask = (__int64)optarg;
continue;
case 'p':
pid = optarg;
continue;
default:
show_help((__int64)*argv);
result = 0xFFFFFFFFLL;
break;
}
}
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(int argc, char **argv)
{
int v3; // eax
__int64 result; // rax
const char *v5; // rsi
int longind; // [rsp+Ch] [rbp-10Ch] BYREF
struct option longopts; // [rsp+10h] [rbp-108h] BYREF
const char *v8; // [rsp+30h] [rbp-E8h]
int v9; // [rsp+38h] [rbp-E0h]
__int64 v10; // [rsp+40h] [rbp-D8h]
int v11; // [rsp+48h] [rbp-D0h]
const char *v12; // [rsp+50h] [rbp-C8h]
int v13; // [rsp+58h] [rbp-C0h]
__int64 v14; // [rsp+60h] [rbp-B8h]
int v15; // [rsp+68h] [rbp-B0h]
const char *v16; // [rsp+70h] [rbp-A8h]
int v17; // [rsp+78h] [rbp-A0h]
__int64 v18; // [rsp+80h] [rbp-98h]
int v19; // [rsp+88h] [rbp-90h]
const char *v20; // [rsp+90h] [rbp-88h]
int v21; // [rsp+98h] [rbp-80h]
__int64 v22; // [rsp+A0h] [rbp-78h]
int v23; // [rsp+A8h] [rbp-70h]
const char *v24; // [rsp+B0h] [rbp-68h]
int v25; // [rsp+B8h] [rbp-60h]
__int64 v26; // [rsp+C0h] [rbp-58h]
int v27; // [rsp+C8h] [rbp-50h]
__int64 v28; // [rsp+D0h] [rbp-48h]
int v29; // [rsp+D8h] [rbp-40h]
__int64 v30; // [rsp+E0h] [rbp-38h]
int v31; // [rsp+E8h] [rbp-30h]

longopts.name = "help";
v8 = "list";
v12 = "pid";
v16 = "module";
v20 = "group";
longopts.has_arg = 0;
longopts.flag = 0LL;
longopts.val = 104;
v9 = 0;
v10 = 0LL;
v11 = 108;
v13 = 1;
v14 = 0LL;
v15 = 112;
v17 = 1;
v18 = 0LL;
v19 = 100;
v21 = 1;
v22 = 0LL;
v23 = 103;
v24 = "mask";
v25 = 1;
v26 = 0LL;
v27 = 109;
v28 = 0LL;
v29 = 0;
v30 = 0LL;
v31 = 0;
while ( 2 )
{
v3 = getopt_long(argc, argv, "hlp:d:g:m:", &longopts, &longind);
if ( v3 == -1 )
{
result = 0LL;
if ( optind < argc )
{
printf("Unknown parameter: ");
while ( optind < argc )
{
v5 = argv[optind++];
printf("%s ", v5);
}
putchar(10);
result = 1LL;
}
}
else
{
switch ( v3 )
{
case 'd':
module = optarg;
continue;
case 'g':
group = optarg;
continue;
case 'l':
list = 1;
continue;
case 'm':
mask = (__int64)optarg;
continue;
case 'p':
pid = optarg;
continue;
default:
func7((__int64)*argv);
result = 0xFFFFFFFFLL;
break;
}
}
break;
}
return result;
}

original_code:
static int parse(int argc, char **argv) {
 int rez;
 int option_index;
 const char* short_options = "hlp:d:g:m:";
 const struct option long_options[] =
 {
  {"help",0,((void *)0),'h'},
  {"list",0,((void *)0),'l'},
  {"pid",1,((void *)0),'p'},
  {"module",1,((void *)0),'d'},
  {"group",1,((void *)0),'g'},
  {"mask",1,((void *)0),'m'},
  {((void *)0),0,((void *)0),0}
 };
 while ((rez=getopt_long(argc, argv, short_options,
   long_options,&option_index))!=-1){
  switch(rez){
   case 'l':{
    list = 1;
    break;
   }
   case 'p': pid = optarg; break;
   case 'd': module = optarg; break;
   case 'g': group = optarg; break;
   case 'm': mask = optarg; break;
   case 'h':
   default:
    _show_help(argv[0]);
    return -1;
  }
 }
 if (optind < argc) {
  printf("Unknown parameter: ");
  while (optind < argc)
   printf ("%s ", argv[optind++]);
  printf ("\n");
  return 1;
 }
 return 0;
}

canonical_original_code:
static int parse(int argc, char **argv) {
 int rez;
 int option_index;
 char *short_options = "hlp:d:g:m:";
 struct option long_options[] = {
  {"help",0,((void *)0),'h'},
  {"list",0,((void *)0),'l'},
  {"pid",1,((void *)0),'p'},
  {"module",1,((void *)0),'d'},
  {"group",1,((void *)0),'g'},
  {"mask",1,((void *)0),'m'},
  {((void *)0),0,((void *)0),0}
 };
 while ((rez=getopt_long(argc, argv, short_options,
   long_options,&option_index))!=-1){
  switch(rez){
   case 'l':{
    list = 1;
    break;
   }
   case 'p': pid = optarg; break;
   case 'd': module = optarg; break;
   case 'g': group = optarg; break;
   case 'm': mask = optarg; break;
   case 'h':
   default:
    _show_help(argv[0]);
    return -1;
  }
 }
 if (optind < argc) {
  printf("Unknown parameter: ");
  while (optind < argc)
   printf ("%s ", argv[optind++]);
  printf ("\n");
  return 1;
 }
 return 0;
}

variable_types: rez int

variable_types: struct option { char *name; int has_arg; int *flag; int val; } []


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax

if ( argc == 1 )
{
show_help(*argv);
return 1;
}
if ( (unsigned int)parse(argc, (char **)argv) )
return 1;
result = list;
if ( list )
{
if ( pid || module || group || mask )
{
puts("Invalid usage of --list");
return 1;
}
}
else if ( module || group )
{
if ( !pid )
{
puts("Invalid usage of --module or --group without --pid");
return 1;
}
if ( !mask )
return showPid();
return ((__int64 (__fastcall *)(int))setMask)(argc);
}
if ( mask )
return ((__int64 (__fastcall *)(int))setMask)(argc);
if ( pid )
return showPid();
if ( list )
result = ((__int64 (__fastcall *)(int, const char **))showlist)(argc, argv);
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax

if ( argc == 1 )
{
func7(*argv);
return 1;
}
if ( (unsigned int)func8(argc, (char **)argv) )
return 1;
result = list;
if ( list )
{
if ( pid || module || group || mask )
{
puts("Invalid usage of --list");
return 1;
}
}
else if ( module || group )
{
if ( !pid )
{
puts("Invalid usage of --module or --group without --pid");
return 1;
}
if ( !mask )
return func10();
return ((__int64 (__fastcall *)(int))setMask)(argc);
}
if ( mask )
return ((__int64 (__fastcall *)(int))setMask)(argc);
if ( pid )
return func10();
if ( list )
result = ((__int64 (__fastcall *)(int, const char **))showlist)(argc, argv);
return result;
}

original_code:
int main(int argc, char **argv) {
 if (argc == 1) {
  _show_help(argv[0]);
  return 1;
 }
 if (parse(argc, argv)!=0)
  return 1;
 if(list && (pid || module || group || mask)) {
  printf("Invalid usage of --list\n");
  return 1;
 }
 if ((module || group) && !pid) {
  printf("Invalid usage of --module or --group without --pid\n");
  return 1;
 }
 if (mask)
  return _setMask();
 if (pid)
  return _showPid();
 if (list)
  return _showlist();
 return 0;
}


xread

decompiled_code:
__int64 __fastcall xread(int fd, __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v4; // rbx
int v5; // eax
int v6; // eax

if ( !a3 )
return 0LL;
v4 = 0LL;
do
{
v5 = read(fd, (void *)(a2 + v4), a3 - v4);
if ( !v5 )
return 0xFFFFFFFFLL;
if ( v5 == -1LL )
{
v6 = *_errno_location();
if ( v6 != 11 && v6 != 4 )
return 0xFFFFFFFFLL;
}
else
{
v4 += v5;
}
}
while ( a3 > v4 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(int fd, __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v4; // rbx
int v5; // eax
int v6; // eax

if ( !a3 )
return 0LL;
v4 = 0LL;
do
{
v5 = read(fd, (void *)(a2 + v4), a3 - v4);
if ( !v5 )
return 0xFFFFFFFFLL;
if ( v5 == -1LL )
{
v6 = *_errno_location();
if ( v6 != 11 && v6 != 4 )
return 0xFFFFFFFFLL;
}
else
{
v4 += v5;
}
}
while ( a3 > v4 );
return 0LL;
}

original_code:
static int
xread(int fd, char *buffer, size_t len) {
    size_t done = 0;
    size_t n;
    while (done < len) {
 n = read(fd, buffer + done, len - done);
 if (n == 0) {
     return -1;
 }
 else if (n != (size_t)-1) {
     done += n;
 }
 else if ((*__errno_location ()) != 11 && (*__errno_location ()) != 4) {
     return -1;
 }
    }
    return 0;
}

canonical_original_code:
static int xread(int fd, char *buffer, unsigned long len) {
    unsigned long done = 0;
    unsigned long n;
    while (done < len) {
 n = read(fd, buffer + done, len - done);
 if (n == 0) {
     return -1;
 }
 else if (n != (unsigned long)-1) {
     done += n;
 }
 else if ((*__errno_location ()) != 11 && (*__errno_location ()) != 4) {
     return -1;
 }
    }
    return 0;
}

variable_types: fd int

variable_types:
buffer
char *

variable_types:
len
unsigned long

variable_types:
done
unsigned long

variable_types:
n
unsigned long


decompiled_code:
__int64 __fastcall elf_getphdrnum(__int64 a1, _QWORD *a2)
{
if ( !a1 )
return 0xFFFFFFFFLL;
if ( *(_DWORD *)(a1 + 16) != 3 )
{
elf_errno = 13;
return 0xFFFFFFFFLL;
}
if ( !*(_QWORD *)(a1 + 160) && !(unsigned int)elf_cook() )
return 0xFFFFFFFFLL;
if ( a2 )
*a2 = *(_QWORD *)(a1 + 176);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, _QWORD *a2)
{
if ( !a1 )
return 0xFFFFFFFFLL;
if ( *(_DWORD *)(a1 + 16) != 3 )
{
elf_errno = 13;
return 0xFFFFFFFFLL;
}
if ( !*(_QWORD *)(a1 + 160) && !(unsigned int)elf_cook() )
return 0xFFFFFFFFLL;
if ( a2 )
*a2 = *(_QWORD *)(a1 + 176);
return 0LL;
}

original_code:
int
elf_getphdrnum(Elf *elf, size_t *resultp) {
    if (!elf) {
 return -1;
    }
    do{}while(0);
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return -1;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
 return -1;
    }
    if (resultp) {
 *resultp = elf->e_phnum;
    }
    return 0;
}

canonical_original_code:
int elf_getphdrnum(struct Elf *elf, unsigned long *resultp) {
    if (!elf) {
 return -1;
    }
    do{}while(0);
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return -1;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
 return -1;
    }
    if (resultp) {
 *resultp = elf->e_phnum;
    }
    return 0;
}

variable_types: struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 } e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; } *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn { struct Elf_Scn *s_link; struct Elf *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data { struct Elf_Data { void *d_buf; enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 } d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; } sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; } *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } u_shdr64; struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } u_shdr32; } s_uhdr; long s_magic; } *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; } *

variable_types:
resultp
unsigned long *


decompiled_code:
__int64 __fastcall elf_getshdrnum(__int64 a1, __int64 *a2)
{
__int64 v2; // rax
unsigned int v3; // er8

if ( a1 )
{
if ( *(_DWORD *)(a1 + 16) == 3 )
{
if ( *(_QWORD *)(a1 + 160) || (unsigned int)elf_cook() )
{
v2 = *(_QWORD *)(a1 + 192);
if ( v2 )
v2 = *(_QWORD *)(v2 + 16) + 1LL;
v3 = 0;
if ( a2 )
*a2 = v2;
return v3;
}
}
else
{
elf_errno = 13;
}
return (unsigned int)-1;
}
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 *a2)
{
__int64 v2; // rax
unsigned int v3; // er8

if ( a1 )
{
if ( *(_DWORD *)(a1 + 16) == 3 )
{
if ( *(_QWORD *)(a1 + 160) || (unsigned int)elf_cook() )
{
v2 = *(_QWORD *)(a1 + 192);
if ( v2 )
v2 = *(_QWORD *)(v2 + 16) + 1LL;
v3 = 0;
if ( a2 )
*a2 = v2;
return v3;
}
}
else
{
elf_errno = 13;
}
return (unsigned int)-1;
}
return 0xFFFFFFFFLL;
}

original_code:
int
elf_getshdrnum(Elf *elf, size_t *resultp) {
    size_t num = 0;
    Elf_Scn *scn;
    if (!elf) {
 return -1;
    }
    do{}while(0);
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return -1;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
 return -1;
    }
    if ((scn = elf->e_scn_n)) {
 num = scn->s_index + 1;
    }
    if (resultp) {
 *resultp = num;
    }
    return 0;
}

canonical_original_code:
int elf_getshdrnum(struct Elf *elf, unsigned long *resultp) {
    unsigned long num = 0;
    struct Elf_Scn *scn;
    if (!elf) {
 return -1;
    }
    do{}while(0);
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return -1;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
 return -1;
    }
    if ((scn = elf->e_scn_n)) {
 num = scn->s_index + 1;
    }
    if (resultp) {
 *resultp = num;
    }
    return 0;
}

variable_types:
num
unsigned long

user_defined_types: enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 }

user_defined_types: struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; }

user_defined_types: struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; }

user_defined_types: struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; }

user_defined_types: enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 }


decompiled_code:
__int64 __fastcall elf_getshdrstrndx(__int64 a1, char *a2)
{
char *v2; // rbp
int v3; // eax
__int64 v4; // rdx
__int64 v5; // rdx
__int64 result; // rax
char v7; // [rsp+0h] [rbp-20h] BYREF

if ( !a1 )
return 0xFFFFFFFFLL;
v2 = a2;
if ( !a2 )
v2 = &v7;
if ( *(_DWORD *)(a1 + 16) != 3 )
{
elf_errno = 13;
return 0xFFFFFFFFLL;
}
if ( !*(_QWORD *)(a1 + 160) && !(unsigned int)elf_cook() )
return 0xFFFFFFFFLL;
v3 = *(_DWORD *)(a1 + 144);
if ( v3 == 1 )
{
v4 = *(unsigned __int16 *)(*(_QWORD *)(a1 + 160) + 50LL);
}
else
{
if ( v3 != 2 )
{
elf_errno = 19;
return 0xFFFFFFFFLL;
}
v4 = *(unsigned __int16 *)(*(_QWORD *)(a1 + 160) + 62LL);
}
if ( v4 != 0xFFFF )
{
*(_QWORD *)v2 = v4;
return 0LL;
}
v5 = *(_QWORD *)(a1 + 184);
if ( !v5 )
{
elf_errno = 21;
return 0xFFFFFFFFLL;
}
if ( v3 == 2 )
{
*(_QWORD *)v2 = *(unsigned int *)(v5 + 128);
result = 0LL;
}
else
{
*(_QWORD *)v2 = *(unsigned int *)(v5 + 112);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, char *a2)
{
char *v2; // rbp
int v3; // eax
__int64 v4; // rdx
__int64 v5; // rdx
__int64 result; // rax
char v7; // [rsp+0h] [rbp-20h] BYREF

if ( !a1 )
return 0xFFFFFFFFLL;
v2 = a2;
if ( !a2 )
v2 = &v7;
if ( *(_DWORD *)(a1 + 16) != 3 )
{
elf_errno = 13;
return 0xFFFFFFFFLL;
}
if ( !*(_QWORD *)(a1 + 160) && !(unsigned int)elf_cook() )
return 0xFFFFFFFFLL;
v3 = *(_DWORD *)(a1 + 144);
if ( v3 == 1 )
{
v4 = *(unsigned __int16 *)(*(_QWORD *)(a1 + 160) + 50LL);
}
else
{
if ( v3 != 2 )
{
elf_errno = 19;
return 0xFFFFFFFFLL;
}
v4 = *(unsigned __int16 *)(*(_QWORD *)(a1 + 160) + 62LL);
}
if ( v4 != 0xFFFF )
{
*(_QWORD *)v2 = v4;
return 0LL;
}
v5 = *(_QWORD *)(a1 + 184);
if ( !v5 )
{
elf_errno = 21;
return 0xFFFFFFFFLL;
}
if ( v3 == 2 )
{
*(_QWORD *)v2 = *(unsigned int *)(v5 + 128);
result = 0LL;
}
else
{
*(_QWORD *)v2 = *(unsigned int *)(v5 + 112);
result = 0LL;
}
return result;
}

original_code:
int
elf_getshdrstrndx(Elf *elf, size_t *resultp) {
    size_t num = 0;
    size_t dummy;
    Elf_Scn *scn;
    if (!elf) {
 return -1;
    }
    do{}while(0);
    if (resultp == ((void *)0)) {
 resultp = &dummy;
    }
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return -1;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
 return -1;
    }
    if (elf->e_class == 1) {
 num = ((Elf32_Ehdr*)elf->e_ehdr)->e_shstrndx;
    }
    else if (elf->e_class == 2) {
 num = ((Elf64_Ehdr*)elf->e_ehdr)->e_shstrndx;
    }
    else {
 if (((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNIMPLEMENTED));
 }
 else {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 return -1;
    }
    if (num != 0xffff) {
 *resultp = num;
 return 0;
    }
    if (!(scn = elf->e_scn_1)) {
 (_elf_errno = (ERROR_NOSUCHSCN));
 return -1;
    }
    do{}while(0);
    if (elf->e_class == 2) {
 *resultp = scn->s_uhdr.u_shdr64.sh_link;
 return 0;
    }
    *resultp = scn->s_uhdr.u_shdr32.sh_link;
    return 0;
}

canonical_original_code:
int elf_getshdrstrndx(struct Elf *elf, unsigned long *resultp) {
    unsigned long num = 0;
    unsigned long dummy;
    struct Elf_Scn *scn;
    if (!elf) {
 return -1;
    }
    do{}while(0);
    if (resultp == ((void *)0)) {
 resultp = &dummy;
    }
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return -1;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
 return -1;
    }
    if (elf->e_class == 1) {
 num = ((struct Elf32_Ehdr *)elf->e_ehdr)->e_shstrndx;
    }
    else if (elf->e_class == 2) {
 num = ((struct Elf64_Ehdr *)elf->e_ehdr)->e_shstrndx;
    }
    else {
 if (((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNIMPLEMENTED));
 }
 else {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 return -1;
    }
    if (num != 0xffff) {
 *resultp = num;
 return 0;
    }
    if (!(scn = elf->e_scn_1)) {
 (_elf_errno = (ERROR_NOSUCHSCN));
 return -1;
    }
    do{}while(0);
    if (elf->e_class == 2) {
 *resultp = scn->s_uhdr.u_shdr64.sh_link;
 return 0;
    }
    *resultp = scn->s_uhdr.u_shdr32.sh_link;
    return 0;
}

variable_types:
dummy
unsigned long

user_defined_types: struct Elf32_Ehdr { unsigned char e_ident[-1]; unsigned short e_type; unsigned short e_machine; unsigned int e_version; unsigned int e_entry; unsigned int e_phoff; unsigned int e_shoff; unsigned int e_flags; unsigned short e_ehsize; unsigned short e_phentsize; unsigned short e_phnum; unsigned short e_shentsize; unsigned short e_shnum; unsigned short e_shstrndx; }

user_defined_types: struct Elf64_Ehdr { unsigned char e_ident[-1]; unsigned short e_type; unsigned short e_machine; unsigned int e_version; unsigned long e_entry; unsigned long e_phoff; unsigned long e_shoff; unsigned int e_flags; unsigned short e_ehsize; unsigned short e_phentsize; unsigned short e_phnum; unsigned short e_shentsize; unsigned short e_shnum; unsigned short e_shstrndx; }


decompiled_code:
_BOOL8 __fastcall elf_getphnum(__int64 a1, _QWORD *a2)
{
return (unsigned int)elf_getphdrnum(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(__int64 a1, _QWORD *a2)
{
return (unsigned int)func0(a1, a2) == 0;
}

original_code:
int
elf_getphnum(Elf *elf, size_t *resultp) {
    return elf_getphdrnum(elf, resultp) ? 0 : 1;
}

canonical_original_code:
int elf_getphnum(struct Elf *elf, unsigned long *resultp) {
    return elf_getphdrnum(elf, resultp) ? 0 : 1;
}


decompiled_code:
_BOOL8 __fastcall elf_getshnum(__int64 a1, __int64 *a2)
{
return (unsigned int)elf_getshdrnum(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(__int64 a1, __int64 *a2)
{
return (unsigned int)func1(a1, a2) == 0;
}

original_code:
int
elf_getshnum(Elf *elf, size_t *resultp) {
    return elf_getshdrnum(elf, resultp) ? 0 : 1;
}

canonical_original_code:
int elf_getshnum(struct Elf *elf, unsigned long *resultp) {
    return elf_getshdrnum(elf, resultp) ? 0 : 1;
}


decompiled_code:
_BOOL8 __fastcall elf_getshstrndx(__int64 a1, char *a2)
{
return (unsigned int)elf_getshdrstrndx(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(__int64 a1, char *a2)
{
return (unsigned int)func2(a1, a2) == 0;
}

original_code:
int
elf_getshstrndx(Elf *elf, size_t *resultp) {
    return elf_getshdrstrndx(elf, resultp) ? 0 : 1;
}

canonical_original_code:
int elf_getshstrndx(struct Elf *elf, unsigned long *resultp) {
    return elf_getshdrstrndx(elf, resultp) ? 0 : 1;
}


original_code:
int
elfx_update_shstrndx(Elf *elf, size_t value) {
    size_t extvalue = 0;
    Elf_Scn *scn;
    if (!elf) {
 return 0;
    }
    do{}while(0);
    if (value >= 0xff00) {
 extvalue = value;
 value = 0xffff;
    }
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return 0;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
 return 0;
    }
    if (!(scn = _elf_first_scn(elf))) {
 return 0;
    }
    do{}while(0);
    if (elf->e_class == 1) {
 ((Elf32_Ehdr*)elf->e_ehdr)->e_shstrndx = value;
 scn->s_uhdr.u_shdr32.sh_link = extvalue;
    }
    else if (elf->e_class == 2) {
 ((Elf64_Ehdr*)elf->e_ehdr)->e_shstrndx = value;
 scn->s_uhdr.u_shdr64.sh_link = extvalue;
    }
    else {
 if (((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNIMPLEMENTED));
 }
 else {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 return 0;
    }
    elf->e_ehdr_flags |= 0x1;
    scn->s_shdr_flags |= 0x1;
    return 1;
}

canonical_original_code:
int elfx_update_shstrndx(struct Elf *elf, unsigned long value) {
    unsigned long extvalue = 0;
    struct Elf_Scn *scn;
    if (!elf) {
 return 0;
    }
    do{}while(0);
    if (value >= 0xff00) {
 extvalue = value;
 value = 0xffff;
    }
    if (elf->e_kind != ELF_K_ELF) {
 (_elf_errno = (ERROR_NOTELF));
 return 0;
    }
    if (!elf->e_ehdr && !_elf_cook(elf)) {
 return 0;
    }
    if (!(scn = _elf_first_scn(elf))) {
 return 0;
    }
    do{}while(0);
    if (elf->e_class == 1) {
 ((struct Elf32_Ehdr *)elf->e_ehdr)->e_shstrndx = value;
 scn->s_uhdr.u_shdr32.sh_link = extvalue;
    }
    else if (elf->e_class == 2) {
 ((struct Elf64_Ehdr *)elf->e_ehdr)->e_shstrndx = value;
 scn->s_uhdr.u_shdr64.sh_link = extvalue;
    }
    else {
 if (((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNIMPLEMENTED));
 }
 else {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 return 0;
    }
    elf->e_ehdr_flags |= 0x1;
    scn->s_shdr_flags |= 0x1;
    return 1;
}

variable_types:
value
unsigned long

variable_types:
extvalue
unsigned long


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

if ( a1 )
result = *(_QWORD *)(a1 + 72);
else
result = -1LL;
return result;
}

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

if ( a1 )
result = *(_QWORD *)(a1 + 72);
else
result = -1LL;
return result;
}

original_code:
off_t
elf_getbase(Elf *elf) {
    if (!elf) {
 return -1;
    }
    do{}while(0);
    return (off_t)elf->e_base;
}

canonical_original_code:
long elf_getbase(struct Elf *elf) {
    if (!elf) {
 return -1;
    }
    do{}while(0);
    return (long)elf->e_base;
}

return_type: long


decompiled_code:
__int64 __fastcall elf32_getshdr(__int64 a1)
{
if ( !a1 )
return 0LL;
if ( *(_DWORD *)(*(_QWORD *)(a1 + 8) + 144LL) == 1 )
return a1 + 88;
elf_errno = 14;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
if ( !a1 )
return 0LL;
if ( *(_DWORD *)(*(_QWORD *)(a1 + 8) + 144LL) == 1 )
return a1 + 88;
elf_errno = 14;
return 0LL;
}

original_code:
Elf32_Shdr*
elf32_getshdr(Elf_Scn *scn) {
    if (!scn) {
 return ((void *)0);
    }
    do{}while(0);
    do{}while(0);
    do{}while(0);
    if (scn->s_elf->e_class == 1) {
 return &scn->s_uhdr.u_shdr32;
    }
    (_elf_errno = (ERROR_CLASSMISMATCH));
    return ((void *)0);
}

canonical_original_code:
struct Elf32_Shdr *elf32_getshdr(struct Elf_Scn *scn) {
    if (!scn) {
 return ((void *)0);
    }
    do{}while(0);
    do{}while(0);
    do{}while(0);
    if (scn->s_elf->e_class == 1) {
 return &scn->s_uhdr.u_shdr32;
    }
    (_elf_errno = (ERROR_CLASSMISMATCH));
    return ((void *)0);
}

variable_types: struct Elf_Scn { struct Elf_Scn *s_link; struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 } e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; } *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; } *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data { struct Elf_Data { void *d_buf; enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 } d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; } sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; } *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } u_shdr64; struct Elf32_Shdr u_shdr32; } s_uhdr; long s_magic; } *

return_type: struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } *


decompiled_code:
__int64 __fastcall elf64_getshdr(__int64 a1)
{
if ( !a1 )
return 0LL;
if ( *(_DWORD *)(*(_QWORD *)(a1 + 8) + 144LL) == 2 )
return a1 + 88;
elf_errno = 14;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
if ( !a1 )
return 0LL;
if ( *(_DWORD *)(*(_QWORD *)(a1 + 8) + 144LL) == 2 )
return a1 + 88;
elf_errno = 14;
return 0LL;
}

original_code:
Elf64_Shdr*
elf64_getshdr(Elf_Scn *scn) {
    if (!scn) {
 return ((void *)0);
    }
    do{}while(0);
    do{}while(0);
    do{}while(0);
    if (scn->s_elf->e_class == 2) {
 return &scn->s_uhdr.u_shdr64;
    }
    (_elf_errno = (ERROR_CLASSMISMATCH));
    return ((void *)0);
}

canonical_original_code:
struct Elf64_Shdr *elf64_getshdr(struct Elf_Scn *scn) {
    if (!scn) {
 return ((void *)0);
    }
    do{}while(0);
    do{}while(0);
    do{}while(0);
    if (scn->s_elf->e_class == 2) {
 return &scn->s_uhdr.u_shdr64;
    }
    (_elf_errno = (ERROR_CLASSMISMATCH));
    return ((void *)0);
}

variable_types: struct Elf_Scn { struct Elf_Scn *s_link; struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 } e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; } *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; } *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data { struct Elf_Data { void *d_buf; enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 } d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; } sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; } *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { struct Elf64_Shdr u_shdr64; struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } u_shdr32; } s_uhdr; long s_magic; } *

return_type: struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } *


original_code:
static inline void CMN_list_del(struct CMN_list_head *entry)
{
 __CMN_list_del(entry->prev, entry->next);
 entry->next = (pCMN_list_head_t)((void *) 0x00100100);
 entry->prev = (pCMN_list_head_t)((void *) 0x00200200);
}

variable_types: struct CMN_list_head { struct CMN_list_head *next; } *


decompiled_code:
__int64 __fastcall esyslog_unregisterBackend(__int64 a1)
{
void *v1; // r8

if ( !a1 )
return 0xFFFFFFFFLL;
ESyslogEngine_RemBacked_constprop_0(a1);
free(v1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1)
{
void *v1; // r8

if ( !a1 )
return 0xFFFFFFFFLL;
func9(a1);
free(v1);
return 0LL;
}

original_code:
int esyslog_unregisterBackend (void *pBackendHandle) {
 ESyslogEngine_Backend_t *pEngine_Backend = (ESyslogEngine_Backend_t *)pBackendHandle;
 if (!pBackendHandle)
  return -1;
 _ESyslogEngine_RemBacked(&st_ESyslogEngine, pEngine_Backend);
 free(pEngine_Backend);
 return 0;
}

canonical_original_code:
int esyslog_unregisterBackend(void *pBackendHandle) {
 struct tagESyslogEngine_Backend *pEngine_Backend = (ESyslogEngine_Backend_t *)pBackendHandle;
 if (!pBackendHandle)
  return -1;
 _ESyslogEngine_RemBacked(&st_ESyslogEngine, pEngine_Backend);
 free(pEngine_Backend);
 return 0;
}

variable_types:
pBackendHandle
void *

variable_types: struct tagESyslogEngine_Backend { struct tagESyslog_Backend { void (*onSyslog)(struct tagESyslog_Backend *pBackend, char *moduleName, struct tagESyslog_Group { char name[40]; struct tagESyslog_GroupConfig { unsigned int mask; } config; } *pGroup, enum enumESyslog_MsgImportance { esgiEmerg=0, esgiAlert=1, esgiCrit=2, esgiErr=3, esgiWarn=4, esgiNotice=5, esgiInfo=6, esgiDebug=7 } importance, char *format, __builtin_va_list ap); void (*onDestroy)(struct tagESyslog_Backend *pBackend); } *pBackend; struct CMN_list_head { struct CMN_list_head *next; } list; } *

user_defined_types: struct tagESyslogEngine_Backend { struct tagESyslog_Backend *pBackend; struct CMN_list_head list; }

user_defined_types: struct tagESyslog_Backend { void (*onSyslog)(struct tagESyslog_Backend *pBackend, char *moduleName, struct tagESyslog_Group *pGroup, enum enumESyslog_MsgImportance importance, char *format, __builtin_va_list ap); void (*onDestroy)(struct tagESyslog_Backend *pBackend); }

user_defined_types: struct tagESyslog_Group { char name[40]; struct tagESyslog_GroupConfig config; }


decompiled_code:
__int64 esyslog_getModuleCount()
{
return (unsigned int)st_ESyslogEngine;
}

canonical_decompiled_code:
__int64 func18()
{
return (unsigned int)st_ESyslogEngine;
}

original_code:
ESyslog_ModuleId_t esyslog_getModuleCount(void) {
 return st_ESyslogEngine.moduleCnt;
}

canonical_original_code:
int esyslog_getModuleCount() {
 return st_ESyslogEngine.moduleCnt;
}


decompiled_code:
__int64 __fastcall esyslog_getModuleName(int a1, __int64 a2)
{
const __m128i *v2; // rax
__m128i *v3; // r9

if ( !a2 )
return 0xFFFFFFFFLL;
v2 = (const __m128i *)ESyslogEngine_GetModuleImpl_constprop_0(a1);
if ( !v2 )
return 0xFFFFFFFFLL;
*v3 = _mm_loadu_si128(v2);
v3[1] = _mm_loadu_si128(v2 + 1);
v3[2].m128i_i64[0] = v2[2].m128i_i64[0];
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func19(int a1, __int64 a2)
{
const __m128i *v2; // rax
__m128i *v3; // r9

if ( !a2 )
return 0xFFFFFFFFLL;
v2 = (const __m128i *)func6(a1);
if ( !v2 )
return 0xFFFFFFFFLL;
*v3 = _mm_loadu_si128(v2);
v3[1] = _mm_loadu_si128(v2 + 1);
v3[2].m128i_i64[0] = v2[2].m128i_i64[0];
return 0LL;
}

original_code:
int esyslog_getModuleName(ESyslog_ModuleId_t moduleId, ESyslog_ModuleName_t *pName) {
 ESyslog_ModuleImpl_t * pModuleImpl;
 if (!pName)
  return -1;
 if (!(pModuleImpl = _ESyslogEngine_GetModuleImpl(&st_ESyslogEngine, moduleId)))
  return -1;
 memcpy(&((*pName)[0]), &(pModuleImpl->name[0]), sizeof(ESyslog_ModuleName_t));
 return 0;
}

canonical_original_code:
int esyslog_getModuleName(int moduleId, char (*pName)[40]) {
 struct tagESyslog_ModuleImpl *pModuleImpl;
 if (!pName)
  return -1;
 if (!(pModuleImpl = _ESyslogEngine_GetModuleImpl(&st_ESyslogEngine, moduleId)))
  return -1;
 memcpy(&((*pName)[0]), &(pModuleImpl->name[0]), sizeof(ESyslog_ModuleName_t));
 return 0;
}

variable_types: moduleId int

variable_types:
pName
char (*)[40]

variable_types: struct tagESyslog_ModuleImpl { char name[40]; int usageCounter; int grpCount; struct CMN_list_head { struct CMN_list_head *next; } grpList; struct CMN_list_head list; } *

user_defined_types: struct tagESyslog_ModuleImpl { char name[40]; int usageCounter; int grpCount; struct CMN_list_head grpList; struct CMN_list_head list; }


decompiled_code:
__int64 __fastcall esyslog_getGroupCount(int a1)
{
void **v1; // rax
__int64 result; // rax

v1 = ESyslogEngine_GetModuleImpl_constprop_0(a1);
if ( v1 )
result = *((unsigned int *)v1 + 11);
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func20(int a1)
{
void **v1; // rax
__int64 result; // rax

v1 = func6(a1);
if ( v1 )
result = *((unsigned int *)v1 + 11);
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
ESyslog_GroupId_t esyslog_getGroupCount(ESyslog_ModuleId_t moduleId) {
 ESyslog_ModuleImpl_t * pModuleImpl;
 if (!(pModuleImpl = _ESyslogEngine_GetModuleImpl(&st_ESyslogEngine, moduleId)))
  return -1;
 return pModuleImpl->grpCount;
}

canonical_original_code:
int esyslog_getGroupCount(int moduleId) {
 struct tagESyslog_ModuleImpl *pModuleImpl;
 if (!(pModuleImpl = _ESyslogEngine_GetModuleImpl(&st_ESyslogEngine, moduleId)))
  return -1;
 return pModuleImpl->grpCount;
}

user_defined_types: struct CMN_list_head { struct CMN_list_head *next; }


decompiled_code:
__int64 __fastcall esyslog_getGroup(int a1, __int64 a2, __int64 a3)
{
void **v3; // rdi
int v4; // er10
const __m128i *v5; // rax
__m128i *v6; // r9

if ( !a3 )
return 0xFFFFFFFFLL;
v3 = ESyslogEngine_GetModuleImpl_constprop_0(a1);
if ( !v3 )
return 0xFFFFFFFFLL;
v5 = (const __m128i *)ESyslogModuleImpl_GetGroupImpl((__int64)v3, v4);
if ( !v5 )
return 0xFFFFFFFFLL;
*v6 = _mm_loadu_si128(v5);
v6[1] = _mm_loadu_si128(v5 + 1);
v6[2].m128i_i64[0] = v5[2].m128i_i64[0];
v6[2].m128i_i32[2] = v5[2].m128i_i32[2];
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func21(int a1, __int64 a2, __int64 a3)
{
void **v3; // rdi
int v4; // er10
const __m128i *v5; // rax
__m128i *v6; // r9

if ( !a3 )
return 0xFFFFFFFFLL;
v3 = func6(a1);
if ( !v3 )
return 0xFFFFFFFFLL;
v5 = (const __m128i *)ESyslogModuleImpl_GetGroupImpl((__int64)v3, v4);
if ( !v5 )
return 0xFFFFFFFFLL;
*v6 = _mm_loadu_si128(v5);
v6[1] = _mm_loadu_si128(v5 + 1);
v6[2].m128i_i64[0] = v5[2].m128i_i64[0];
v6[2].m128i_i32[2] = v5[2].m128i_i32[2];
return 0LL;
}

original_code:
int esyslog_getGroup(ESyslog_ModuleId_t moduleId, ESyslog_GroupId_t groupId, ESyslog_Group_t *pGroup) {
 ESyslog_ModuleImpl_t * pModuleImpl;
 ESyslog_GroupImpl_t * pGroupImpl;
 if (!pGroup) {
  return -1;
 }
 if (!(pModuleImpl = _ESyslogEngine_GetModuleImpl(&st_ESyslogEngine, moduleId))) {
  return -1;
 }
 if (!(pGroupImpl = _ESyslogModuleImpl_GetGroupImpl(pModuleImpl, groupId))) {
  return -1;
 }
 memcpy(pGroup, &pGroupImpl->group, sizeof(ESyslog_Group_t));
 return 0;
}

canonical_original_code:
int esyslog_getGroup(int moduleId, int groupId, struct tagESyslog_Group *pGroup) {
 struct tagESyslog_ModuleImpl *pModuleImpl;
 struct tagESyslog_GroupImpl *pGroupImpl;
 if (!pGroup) {
  return -1;
 }
 if (!(pModuleImpl = _ESyslogEngine_GetModuleImpl(&st_ESyslogEngine, moduleId))) {
  return -1;
 }
 if (!(pGroupImpl = _ESyslogModuleImpl_GetGroupImpl(pModuleImpl, groupId))) {
  return -1;
 }
 memcpy(pGroup, &pGroupImpl->group, sizeof(ESyslog_Group_t));
 return 0;
}

variable_types: groupId int

variable_types: struct tagESyslog_Group { char name[40]; struct tagESyslog_GroupConfig { unsigned int mask; } config; } *

variable_types: struct tagESyslog_GroupImpl { struct tagESyslog_Group { char name[40]; struct tagESyslog_GroupConfig { unsigned int mask; } config; } group; struct tagESyslog_ModuleImpl { char name[40]; int usageCounter; int grpCount; struct CMN_list_head { struct CMN_list_head *next; } grpList; struct CMN_list_head list; } *pModule; struct CMN_list_head list; } *

user_defined_types: struct tagESyslog_GroupImpl { struct tagESyslog_Group group; struct tagESyslog_ModuleImpl *pModule; struct CMN_list_head list; }


decompiled_code:
__int64 __fastcall esyslog_setGroupConfig(int a1, __int64 a2, __int64 a3)
{
void **v3; // rdi
int v4; // er10
_QWORD *v5; // rax
_DWORD *v6; // r9

if ( !a3 )
return 0xFFFFFFFFLL;
v3 = ESyslogEngine_GetModuleImpl_constprop_0(a1);
if ( !v3 )
return 0xFFFFFFFFLL;
v5 = ESyslogModuleImpl_GetGroupImpl((__int64)v3, v4);
if ( !v5 )
return 0xFFFFFFFFLL;
*((_DWORD *)v5 + 10) = *v6;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func22(int a1, __int64 a2, __int64 a3)
{
void **v3; // rdi
int v4; // er10
_QWORD *v5; // rax
_DWORD *v6; // r9

if ( !a3 )
return 0xFFFFFFFFLL;
v3 = func6(a1);
if ( !v3 )
return 0xFFFFFFFFLL;
v5 = ESyslogModuleImpl_GetGroupImpl((__int64)v3, v4);
if ( !v5 )
return 0xFFFFFFFFLL;
*((_DWORD *)v5 + 10) = *v6;
return 0LL;
}

original_code:
int esyslog_setGroupConfig(ESyslog_ModuleId_t moduleId, ESyslog_GroupId_t groupId, ESyslog_GroupConfig_t *pGroupConfig) {
 ESyslog_ModuleImpl_t * pModuleImpl;
 ESyslog_GroupImpl_t * pGroupImpl;
 if (!pGroupConfig) {
  return -1;
 }
 if (!(pModuleImpl = _ESyslogEngine_GetModuleImpl(&st_ESyslogEngine, moduleId))) {
  return -1;
 }
 if (!(pGroupImpl = _ESyslogModuleImpl_GetGroupImpl(pModuleImpl, groupId))) {
  return -1;
 }
 memcpy(&pGroupImpl->group.config, pGroupConfig, sizeof(ESyslog_GroupConfig_t));
 return 0;
}

canonical_original_code:
int esyslog_setGroupConfig(int moduleId, int groupId, struct tagESyslog_GroupConfig *pGroupConfig) {
 struct tagESyslog_ModuleImpl *pModuleImpl;
 struct tagESyslog_GroupImpl *pGroupImpl;
 if (!pGroupConfig) {
  return -1;
 }
 if (!(pModuleImpl = _ESyslogEngine_GetModuleImpl(&st_ESyslogEngine, moduleId))) {
  return -1;
 }
 if (!(pGroupImpl = _ESyslogModuleImpl_GetGroupImpl(pModuleImpl, groupId))) {
  return -1;
 }
 memcpy(&pGroupImpl->group.config, pGroupConfig, sizeof(ESyslog_GroupConfig_t));
 return 0;
}

variable_types: struct tagESyslog_GroupConfig { unsigned int mask; } *


decompiled_code:
__int64 __fastcall add_bytes(unsigned __int8 *a1, __int64 a2)
{
unsigned __int8 *v2; // rsi
__int64 result; // rax
__int64 v4; // rdx

if ( !a2 )
return 0LL;
v2 = &a1[a2];
result = 0LL;
do
{
v4 = *a1++;
result += v4;
}
while ( v2 != a1 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int8 *a1, __int64 a2)
{
unsigned __int8 *v2; // rsi
__int64 result; // rax
__int64 v4; // rdx

if ( !a2 )
return 0LL;
v2 = &a1[a2];
result = 0LL;
do
{
v4 = *a1++;
result += v4;
}
while ( v2 != a1 );
return result;
}

original_code:
static long
add_bytes(unsigned char *ptr, size_t len) {
    long csum = 0;
    while (len--) {
 csum += *ptr++;
    }
    return csum;
}

canonical_original_code:
static long add_bytes(unsigned char *ptr, unsigned long len) {
    long csum = 0;
    while (len--) {
 csum += *ptr++;
    }
    return csum;
}

variable_types:
ptr
unsigned char *

variable_types:
len
unsigned long

variable_types: csum long


decompiled_code:
signed __int64 __fastcall elf32_checksum(__int64 a1)
{
if ( !a1 )
return 0LL;
if ( *(_DWORD *)(a1 + 16) != 3 )
{
elf_errno = 13;
return 0LL;
}
if ( *(_DWORD *)(a1 + 144) == 1 )
return elf_csum(a1);
elf_errno = 14;
return 0LL;
}

canonical_decompiled_code:
signed __int64 __fastcall func3(__int64 a1)
{
if ( !a1 )
return 0LL;
if ( *(_DWORD *)(a1 + 16) != 3 )
{
elf_errno = 13;
return 0LL;
}
if ( *(_DWORD *)(a1 + 144) == 1 )
return func2(a1);
elf_errno = 14;
return 0LL;
}

original_code:
long
elf32_checksum(Elf *elf) {
    if (elf) {
 if (elf->e_kind != ELF_K_ELF) {
     (_elf_errno = (ERROR_NOTELF));
 }
 else if (elf->e_class != 1) {
     (_elf_errno = (ERROR_CLASSMISMATCH));
 }
 else {
     return _elf_csum(elf);
 }
    }
    return 0L;
}

canonical_original_code:
long elf32_checksum(struct Elf *elf) {
    if (elf) {
 if (elf->e_kind != ELF_K_ELF) {
     (_elf_errno = (ERROR_NOTELF));
 }
 else if (elf->e_class != 1) {
     (_elf_errno = (ERROR_CLASSMISMATCH));
 }
 else {
     return _elf_csum(elf);
 }
    }
    return 0L;
}

variable_types: struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 } e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; } *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn { struct Elf_Scn *s_link; struct Elf *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data { struct Elf_Data { void *d_buf; enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 } d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; } sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; } *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } u_shdr64; struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } u_shdr32; } s_uhdr; long s_magic; } *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; } *

user_defined_types: struct Elf_Scn { struct Elf_Scn *s_link; struct Elf *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { struct Elf64_Shdr u_shdr64; struct Elf32_Shdr u_shdr32; } s_uhdr; long s_magic; }


decompiled_code:
signed __int64 __fastcall elf64_checksum(__int64 a1)
{
if ( !a1 )
return 0LL;
if ( *(_DWORD *)(a1 + 16) != 3 )
{
elf_errno = 13;
return 0LL;
}
if ( *(_DWORD *)(a1 + 144) == 2 )
return elf_csum(a1);
elf_errno = 14;
return 0LL;
}

canonical_decompiled_code:
signed __int64 __fastcall func4(__int64 a1)
{
if ( !a1 )
return 0LL;
if ( *(_DWORD *)(a1 + 16) != 3 )
{
elf_errno = 13;
return 0LL;
}
if ( *(_DWORD *)(a1 + 144) == 2 )
return func2(a1);
elf_errno = 14;
return 0LL;
}

original_code:
long
elf64_checksum(Elf *elf) {
    if (elf) {
 if (elf->e_kind != ELF_K_ELF) {
     (_elf_errno = (ERROR_NOTELF));
 }
 else if (elf->e_class != 2) {
     (_elf_errno = (ERROR_CLASSMISMATCH));
 }
 else {
     return _elf_csum(elf);
 }
    }
    return 0L;
}

canonical_original_code:
long elf64_checksum(struct Elf *elf) {
    if (elf) {
 if (elf->e_kind != ELF_K_ELF) {
     (_elf_errno = (ERROR_NOTELF));
 }
 else if (elf->e_class != 2) {
     (_elf_errno = (ERROR_CLASSMISMATCH));
 }
 else {
     return _elf_csum(elf);
 }
    }
    return 0L;
}

user_defined_types: struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; }


decompiled_code:
signed __int64 __fastcall gelf_checksum(__int64 a1)
{
if ( !a1 )
return 0LL;
if ( *(_DWORD *)(a1 + 16) != 3 )
{
elf_errno = 13;
return 0LL;
}
if ( (unsigned int)(*(_DWORD *)(a1 + 144) - 1) <= 1 )
return elf_csum(a1);
elf_errno = 19;
return 0LL;
}

canonical_decompiled_code:
signed __int64 __fastcall func5(__int64 a1)
{
if ( !a1 )
return 0LL;
if ( *(_DWORD *)(a1 + 16) != 3 )
{
elf_errno = 13;
return 0LL;
}
if ( (unsigned int)(*(_DWORD *)(a1 + 144) - 1) <= 1 )
return func2(a1);
elf_errno = 19;
return 0LL;
}

original_code:
long
gelf_checksum(Elf *elf) {
    if (elf) {
 if (elf->e_kind != ELF_K_ELF) {
     (_elf_errno = (ERROR_NOTELF));
 }
 else if (!((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 else {
     return _elf_csum(elf);
 }
    }
    return 0L;
}

canonical_original_code:
long gelf_checksum(struct Elf *elf) {
    if (elf) {
 if (elf->e_kind != ELF_K_ELF) {
     (_elf_errno = (ERROR_NOTELF));
 }
 else if (!((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 else {
     return _elf_csum(elf);
 }
    }
    return 0L;
}

user_defined_types: struct Scn_Data { struct Elf_Data sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; }


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

if ( !a1 )
return 0LL;
result = *(_QWORD *)(a1 + 88);
if ( !result )
elf_errno = 7;
return result;
}

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

if ( !a1 )
return 0LL;
result = *(_QWORD *)(a1 + 88);
if ( !result )
elf_errno = 7;
return result;
}

original_code:
Elf_Arhdr*
elf_getarhdr(Elf *elf) {
    if (!elf) {
 return ((void *)0);
    }
    do{}while(0);
    if (elf->e_arhdr) {
 return elf->e_arhdr;
    }
    (_elf_errno = (ERROR_NOTARCHIVE));
    return ((void *)0);
}

canonical_original_code:
struct Elf_Arhdr *elf_getarhdr(struct Elf *elf) {
    if (!elf) {
 return ((void *)0);
    }
    do{}while(0);
    if (elf->e_arhdr) {
 return elf->e_arhdr;
    }
    (_elf_errno = (ERROR_NOTARCHIVE));
    return ((void *)0);
}

variable_types: struct Elf { unsigned long e_size; unsigned long e_dsize; enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 } e_kind; char *e_data; char *e_rawdata; unsigned long e_idlen; int e_fd; unsigned int e_count; struct Elf *e_parent; unsigned long e_next; unsigned long e_base; struct Elf *e_link; struct Elf_Arhdr *e_arhdr; unsigned long e_off; struct Elf *e_members; char *e_symtab; unsigned long e_symlen; char *e_strtab; unsigned long e_strlen; unsigned int e_class; unsigned int e_encoding; unsigned int e_version; char *e_ehdr; char *e_phdr; unsigned long e_phnum; struct Elf_Scn { struct Elf_Scn *s_link; struct Elf *s_elf; unsigned long s_index; unsigned int s_scn_flags; unsigned int s_shdr_flags; struct Scn_Data { struct Elf_Data { void *d_buf; enum Elf_Type { ELF_T_BYTE=0, ELF_T_ADDR=1, ELF_T_DYN=2, ELF_T_EHDR=3, ELF_T_HALF=4, ELF_T_OFF=5, ELF_T_PHDR=6, ELF_T_RELA=7, ELF_T_REL=8, ELF_T_SHDR=9, ELF_T_SWORD=10, ELF_T_SYM=11, ELF_T_WORD=12, ELF_T_SXWORD=13, ELF_T_XWORD=14, ELF_T_VDEF=15, ELF_T_VNEED=16, ELF_T_NUM=17 } d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; } sd_data; struct Scn_Data *sd_link; struct Elf_Scn *sd_scn; char *sd_memdata; unsigned int sd_data_flags; unsigned int sd_freeme; unsigned int sd_free_data; long sd_magic; } *s_data_1; struct Scn_Data *s_data_n; struct Scn_Data *s_rawdata; unsigned int s_type; unsigned long s_offset; unsigned long s_size; unsigned int s_freeme; union { struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; } u_shdr64; struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; } u_shdr32; } s_uhdr; long s_magic; } *e_scn_1; struct Elf_Scn *e_scn_n; unsigned int e_elf_flags; unsigned int e_ehdr_flags; unsigned int e_phdr_flags; unsigned int e_readable; unsigned int e_writable; unsigned int e_disabled; unsigned int e_cooked; unsigned int e_free_syms; unsigned int e_unmap_data; unsigned int e_memory; long e_magic; } *

return_type: struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; } *

user_defined_types: struct Elf_Data { void *d_buf; enum Elf_Type d_type; unsigned long d_size; long d_off; unsigned long d_align; unsigned int d_version; }


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

if ( a1 )
{
if ( a1 == -1 )
{
a1 = elf_errno;
result = "unknown error";
if ( elf_errno > 0x4Bu )
return result;
goto LABEL_5;
}
}
else
{
a1 = elf_errno;
if ( !elf_errno )
return 0LL;
}
result = "unknown error";
if ( a1 > 0x4B )
return result;
LABEL_5:
result = messages[a1];
if ( !result )
result = "unknown error";
return result;
}

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

if ( a1 )
{
if ( a1 == -1 )
{
a1 = elf_errno;
result = "unknown error";
if ( elf_errno > 0x4Bu )
return result;
goto LABEL_5;
}
}
else
{
a1 = elf_errno;
if ( !elf_errno )
return 0LL;
}
result = "unknown error";
if ( a1 > 0x4B )
return result;
LABEL_5:
result = messages[a1];
if ( !result )
result = "unknown error";
return result;
}

original_code:
const char*
elf_errmsg(int err) {
    if (err == 0) {
 err = _elf_errno;
 if (err == 0) {
     return ((void *)0);
 }
    }
    else if (err == -1) {
 err = _elf_errno;
    }
    if (err < 0 || err >= ERROR_NUM || _messages[err] == ((void *)0)) {
 err = ERROR_UNKNOWN;
    }
    return _messages[err];
}

canonical_original_code:
char *elf_errmsg(int err) {
    if (err == 0) {
 err = _elf_errno;
 if (err == 0) {
     return ((void *)0);
 }
    }
    else if (err == -1) {
 err = _elf_errno;
    }
    if (err < 0 || err >= ERROR_NUM || _messages[err] == ((void *)0)) {
 err = ERROR_UNKNOWN;
    }
    return _messages[err];
}

variable_types: err int

return_type: char *


decompiled_code:
_BOOL8 __fastcall elf_next(__int64 a1)
{
_QWORD *v1; // rax
__int64 v2; // rdx
bool v3; // zf

if ( !a1 )
return 0LL;
v1 = *(_QWORD **)(a1 + 56);
if ( !v1 )
return 0LL;
v2 = *(_QWORD *)(a1 + 64);
v3 = *v1 == v2;
v1[12] = v2;
return !v3;
}

original_code:
Elf_Cmd
elf_next(Elf *elf) {
    if (!elf) {
 return ELF_C_NULL;
    }
    do{}while(0);
    if (!elf->e_parent) {
 return ELF_C_NULL;
    }
    do{}while(0);
    do{}while(0);
    elf->e_parent->e_off = elf->e_next;
    if (elf->e_next == elf->e_parent->e_size) {
 return ELF_C_NULL;
    }
    return ELF_C_READ;
}

canonical_original_code:
enum Elf_Cmd elf_next(struct Elf *elf) {
    if (!elf) {
 return ELF_C_NULL;
    }
    do{}while(0);
    if (!elf->e_parent) {
 return ELF_C_NULL;
    }
    do{}while(0);
    do{}while(0);
    elf->e_parent->e_off = elf->e_next;
    if (elf->e_next == elf->e_parent->e_size) {
 return ELF_C_NULL;
    }
    return ELF_C_READ;
}

return_type: enum Elf_Cmd { ELF_C_NULL=0, ELF_C_READ=1, ELF_C_WRITE=2, ELF_C_CLR=3, ELF_C_SET=4, ELF_C_FDDONE=5, ELF_C_FDREAD=6, ELF_C_RDWR=7, ELF_C_NUM=8 }

user_defined_types: enum Elf_Kind { ELF_K_NONE=0, ELF_K_AR=1, ELF_K_COFF=2, ELF_K_ELF=3, ELF_K_NUM=4 }


decompiled_code:
__int64 __fastcall elf32_getphdr(__int64 a1)
{
return elf_getphdr(a1, 1);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return func0(a1, 1);
}

original_code:
Elf32_Phdr*
elf32_getphdr(Elf *elf) {
    return (Elf32_Phdr*)_elf_getphdr(elf, 1);
}

canonical_original_code:
struct Elf32_Phdr *elf32_getphdr(struct Elf *elf) {
    return (struct Elf32_Phdr *)_elf_getphdr(elf, 1);
}

return_type: struct Elf32_Phdr { unsigned int p_type; unsigned int p_offset; unsigned int p_vaddr; unsigned int p_paddr; unsigned int p_filesz; unsigned int p_memsz; unsigned int p_flags; unsigned int p_align; } *

user_defined_types: struct Elf_Arhdr { char *ar_name; long ar_date; long ar_uid; long ar_gid; unsigned long ar_mode; long ar_size; char *ar_rawname; }


decompiled_code:
__int64 __fastcall elf64_getphdr(__int64 a1)
{
return elf_getphdr(a1, 2);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return func0(a1, 2);
}

original_code:
Elf64_Phdr*
elf64_getphdr(Elf *elf) {
    return (Elf64_Phdr*)_elf_getphdr(elf, 2);
}

canonical_original_code:
struct Elf64_Phdr *elf64_getphdr(struct Elf *elf) {
    return (struct Elf64_Phdr *)_elf_getphdr(elf, 2);
}

return_type: struct Elf64_Phdr { unsigned int p_type; unsigned int p_flags; unsigned long p_offset; unsigned long p_vaddr; unsigned long p_paddr; unsigned long p_filesz; unsigned long p_memsz; unsigned long p_align; } *

user_defined_types: struct Elf64_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned long sh_flags; unsigned long sh_addr; unsigned long sh_offset; unsigned long sh_size; unsigned int sh_link; unsigned int sh_info; unsigned long sh_addralign; unsigned long sh_entsize; }


original_code:
int
gelf_update_ehdr(Elf *elf, GElf_Ehdr *src) {
    char *tmp;
    if (!elf || !src) {
 return 0;
    }
    do{}while(0);
    tmp = _elf_getehdr(elf, elf->e_class);
    if (!tmp) {
 return 0;
    }
    if (elf->e_class == 2) {
 *(Elf64_Ehdr*)tmp = *src;
    }
    else if (elf->e_class == 1) {
 Elf32_Ehdr *dst = (Elf32_Ehdr*)tmp;
 bcopy(src->e_ident,dst->e_ident,(16));
 do { if (sizeof((dst)->e_type) < sizeof((src)->e_type) && (Elf32_Half)(src)->e_type != (src)->e_type) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_type = (Elf32_Half)(src)->e_type; } while (0);
 do { if (sizeof((dst)->e_machine) < sizeof((src)->e_machine) && (Elf32_Half)(src)->e_machine != (src)->e_machine) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_machine = (Elf32_Half)(src)->e_machine; } while (0);
 do { if (sizeof((dst)->e_version) < sizeof((src)->e_version) && (Elf32_Word)(src)->e_version != (src)->e_version) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_version = (Elf32_Word)(src)->e_version; } while (0);
 do { if (sizeof((dst)->e_entry) < sizeof((src)->e_entry) && (Elf32_Addr)(src)->e_entry != (src)->e_entry) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_entry = (Elf32_Addr)(src)->e_entry; } while (0);
 do { if (sizeof((dst)->e_phoff) < sizeof((src)->e_phoff) && (Elf32_Off)(src)->e_phoff != (src)->e_phoff) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_phoff = (Elf32_Off)(src)->e_phoff; } while (0);
 do { if (sizeof((dst)->e_shoff) < sizeof((src)->e_shoff) && (Elf32_Off)(src)->e_shoff != (src)->e_shoff) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_shoff = (Elf32_Off)(src)->e_shoff; } while (0);
 do { if (sizeof((dst)->e_flags) < sizeof((src)->e_flags) && (Elf32_Word)(src)->e_flags != (src)->e_flags) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_flags = (Elf32_Word)(src)->e_flags; } while (0);
 do { if (sizeof((dst)->e_ehsize) < sizeof((src)->e_ehsize) && (Elf32_Half)(src)->e_ehsize != (src)->e_ehsize) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_ehsize = (Elf32_Half)(src)->e_ehsize; } while (0);
 do { if (sizeof((dst)->e_phentsize) < sizeof((src)->e_phentsize) && (Elf32_Half)(src)->e_phentsize != (src)->e_phentsize) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_phentsize = (Elf32_Half)(src)->e_phentsize; } while (0);
 do { if (sizeof((dst)->e_phnum) < sizeof((src)->e_phnum) && (Elf32_Half)(src)->e_phnum != (src)->e_phnum) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_phnum = (Elf32_Half)(src)->e_phnum; } while (0);
 do { if (sizeof((dst)->e_shentsize) < sizeof((src)->e_shentsize) && (Elf32_Half)(src)->e_shentsize != (src)->e_shentsize) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_shentsize = (Elf32_Half)(src)->e_shentsize; } while (0);
 do { if (sizeof((dst)->e_shnum) < sizeof((src)->e_shnum) && (Elf32_Half)(src)->e_shnum != (src)->e_shnum) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_shnum = (Elf32_Half)(src)->e_shnum; } while (0);
 do { if (sizeof((dst)->e_shstrndx) < sizeof((src)->e_shstrndx) && (Elf32_Half)(src)->e_shstrndx != (src)->e_shstrndx) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_shstrndx = (Elf32_Half)(src)->e_shstrndx; } while (0);
    }
    else {
 if (((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNIMPLEMENTED));
 }
 else {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 return 0;
    }
    return 1;
}

canonical_original_code:
int gelf_update_ehdr(struct Elf *elf, struct Elf64_Ehdr *src) {
    char *tmp;
    if (!elf || !src) {
 return 0;
    }
    do{}while(0);
    tmp = _elf_getehdr(elf, elf->e_class);
    if (!tmp) {
 return 0;
    }
    if (elf->e_class == 2) {
 *(struct Elf64_Ehdr *)tmp = *src;
    }
    else if (elf->e_class == 1) {
 struct Elf32_Ehdr *dst = (Elf32_Ehdr*)tmp;
 bcopy(src->e_ident,dst->e_ident,(16));
 do { if (sizeof((dst)->e_type) < sizeof((src)->e_type) && (Elf32_Half)(src)->e_type != (src)->e_type) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_type = (Elf32_Half)(src)->e_type; } while (0);
 do { if (sizeof((dst)->e_machine) < sizeof((src)->e_machine) && (Elf32_Half)(src)->e_machine != (src)->e_machine) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_machine = (Elf32_Half)(src)->e_machine; } while (0);
 do { if (sizeof((dst)->e_version) < sizeof((src)->e_version) && (Elf32_Word)(src)->e_version != (src)->e_version) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_version = (Elf32_Word)(src)->e_version; } while (0);
 do { if (sizeof((dst)->e_entry) < sizeof((src)->e_entry) && (Elf32_Addr)(src)->e_entry != (src)->e_entry) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_entry = (Elf32_Addr)(src)->e_entry; } while (0);
 do { if (sizeof((dst)->e_phoff) < sizeof((src)->e_phoff) && (Elf32_Off)(src)->e_phoff != (src)->e_phoff) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_phoff = (Elf32_Off)(src)->e_phoff; } while (0);
 do { if (sizeof((dst)->e_shoff) < sizeof((src)->e_shoff) && (Elf32_Off)(src)->e_shoff != (src)->e_shoff) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_shoff = (Elf32_Off)(src)->e_shoff; } while (0);
 do { if (sizeof((dst)->e_flags) < sizeof((src)->e_flags) && (Elf32_Word)(src)->e_flags != (src)->e_flags) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_flags = (Elf32_Word)(src)->e_flags; } while (0);
 do { if (sizeof((dst)->e_ehsize) < sizeof((src)->e_ehsize) && (Elf32_Half)(src)->e_ehsize != (src)->e_ehsize) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_ehsize = (Elf32_Half)(src)->e_ehsize; } while (0);
 do { if (sizeof((dst)->e_phentsize) < sizeof((src)->e_phentsize) && (Elf32_Half)(src)->e_phentsize != (src)->e_phentsize) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_phentsize = (Elf32_Half)(src)->e_phentsize; } while (0);
 do { if (sizeof((dst)->e_phnum) < sizeof((src)->e_phnum) && (Elf32_Half)(src)->e_phnum != (src)->e_phnum) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_phnum = (Elf32_Half)(src)->e_phnum; } while (0);
 do { if (sizeof((dst)->e_shentsize) < sizeof((src)->e_shentsize) && (Elf32_Half)(src)->e_shentsize != (src)->e_shentsize) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_shentsize = (Elf32_Half)(src)->e_shentsize; } while (0);
 do { if (sizeof((dst)->e_shnum) < sizeof((src)->e_shnum) && (Elf32_Half)(src)->e_shnum != (src)->e_shnum) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_shnum = (Elf32_Half)(src)->e_shnum; } while (0);
 do { if (sizeof((dst)->e_shstrndx) < sizeof((src)->e_shstrndx) && (Elf32_Half)(src)->e_shstrndx != (src)->e_shstrndx) { (_elf_errno = (ERROR_BADVALUE)); return (0); } (dst)->e_shstrndx = (Elf32_Half)(src)->e_shstrndx; } while (0);
    }
    else {
 if (((elf->e_class) >= 1 && (elf->e_class) <= 2)) {
     (_elf_errno = (ERROR_UNIMPLEMENTED));
 }
 else {
     (_elf_errno = (ERROR_UNKNOWN_CLASS));
 }
 return 0;
    }
    return 1;
}

variable_types: struct Elf64_Ehdr { unsigned char e_ident[-1]; unsigned short e_type; unsigned short e_machine; unsigned int e_version; unsigned long e_entry; unsigned long e_phoff; unsigned long e_shoff; unsigned int e_flags; unsigned short e_ehsize; unsigned short e_phentsize; unsigned short e_phnum; unsigned short e_shentsize; unsigned short e_shnum; unsigned short e_shstrndx; } *

variable_types:
tmp
char *

variable_types: struct Elf32_Ehdr { unsigned char e_ident[-1]; unsigned short e_type; unsigned short e_machine; unsigned int e_version; unsigned int e_entry; unsigned int e_phoff; unsigned int e_shoff; unsigned int e_flags; unsigned short e_ehsize; unsigned short e_phentsize; unsigned short e_phnum; unsigned short e_shentsize; unsigned short e_shnum; unsigned short e_shstrndx; } *

user_defined_types: struct Elf32_Shdr { unsigned int sh_name; unsigned int sh_type; unsigned int sh_flags; unsigned int sh_addr; unsigned int sh_offset; unsigned int sh_size; unsigned int sh_link; unsigned int sh_info; unsigned int sh_addralign; unsigned int sh_entsize; }