decompiled_code:
__int64 __fastcall g_reverse_semaphore_destroy(__int64 a1)
{
g_mutex_lock(*(_QWORD *)(a1 + 8));
while ( *(_DWORD *)a1 )
g_cond_wait(*(_QWORD *)(a1 + 16), *(_QWORD *)(a1 + 8));
g_mutex_unlock(*(_QWORD *)(a1 + 8));
g_mutex_free(*(_QWORD *)(a1 + 8));
g_cond_free(*(_QWORD *)(a1 + 16));
return g_slice_free1(24LL, a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
g_mutex_lock(*(_QWORD *)(a1 + 8));
while ( *(_DWORD *)a1 )
g_cond_wait(*(_QWORD *)(a1 + 16), *(_QWORD *)(a1 + 8));
g_mutex_unlock(*(_QWORD *)(a1 + 8));
g_mutex_free(*(_QWORD *)(a1 + 8));
g_cond_free(*(_QWORD *)(a1 + 16));
return g_slice_free1(24LL, a1);
}

original_code:
void g_reverse_semaphore_destroy(GReverseSemaphore *sem)
{
 g_mutex_lock(sem->access);
 while (sem->value > 0)
  g_cond_wait(sem->cond, sem->access);
 g_mutex_unlock(sem->access);
 g_mutex_free(sem->access);
 g_cond_free(sem->cond);
 do { if (1) g_slice_free1 (sizeof (GReverseSemaphore), (sem)); else (void) ((GReverseSemaphore*) 0 == (sem)); } while (0);
}

canonical_original_code:
void g_reverse_semaphore_destroy(struct _GReverseSemaphore *sem)
{
 g_mutex_lock(sem->access);
 while (sem->value > 0)
  g_cond_wait(sem->cond, sem->access);
 g_mutex_unlock(sem->access);
 g_mutex_free(sem->access);
 g_cond_free(sem->cond);
 do { if (1) g_slice_free1 (sizeof (GReverseSemaphore), (sem)); else (void) ((struct _GReverseSemaphore *) 0 == (sem)); } while (0);
}


execute

repo: elboza/dwarf-ng

decompiled_code:
__int64 __fastcall execute(const char *a1)
{
if ( !a1 )
a1 = "quit";
yy_scan_string(a1);
yyparse();
return yylex_destroy();
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
if ( !a1 )
a1 = "quit";
yy_scan_string(a1);
yyparse();
return yylex_destroy();
}

original_code:
void execute(char *s)
{
 if(!s) s="quit";
 yy_scan_string(s);
 yyparse();
 yylex_destroy();
}

variable_types:
s
char *

return_type: void


decompiled_code:
int funny_shell_disclaimer()
{
puts(" ________________________________________ ");
puts(" / dwarf-ng Copyright (C) 2007-2013-2017 \\ ");
puts(" | Fernando Iazeolla. This program comes | ");
puts(" | with ABSOLUTELY NO WARRANTY. This is | ");
puts(" | free software (GNU GPLv2), and you are | ");
puts(" | welcome to redistribute it under GNU | ");
puts(" | GPL version 2 (see | ");
puts(" \\ <http://www.gnu.org/licenses/>). / ");
puts(" ---------------------------------------- ");
puts(" \\ ^__^ ");
puts(" \\ (oo)\\_______ ");
puts(" (__)\\ )\\/\\ ");
puts(" ||----w | ");
return puts(" || || ");
}

original_code:
void funny_shell_disclaimer()
{
printf("   ________________________________________  \n");
printf("  / dwarf-ng Copyright (C) 2007-2013-2017  \\ \n");
printf("  | Fernando Iazeolla. This program comes  | \n");
printf("  | with ABSOLUTELY NO WARRANTY. This is   | \n");
printf("  | free software (GNU GPLv2), and you are | \n");
printf("  | welcome to redistribute it under GNU   | \n");
printf("  | GPL version 2 (see                     | \n");
printf("  \\ <http://www.gnu.org/licenses/>).       / \n");
printf("   ----------------------------------------  \n");
printf("          \\   ^__^                           \n");
printf("           \\  (oo)\\_______                   \n");
printf("              (__)\\       )\\/\\               \n");
printf("                  ||----w |                  \n");
printf("                  ||     ||                  \n");
}


decompiled_code:
int normal_shell_disclaimer()
{
puts("dwarf-ng Copyright (C) 2007-2013-2017 Fernando Iazeolla.");
puts("This program comes with ABSOLUTELY NO WARRANTY.");
puts("This is free software (GNU GPLv2), and you are welcome to redistribute it");
return puts("under GNU GPL version 2 (see <http://www.gnu.org/licenses/>).");
}

canonical_decompiled_code:
int func3()
{
puts("dwarf-ng Copyright (C) 2007-2013-2017 Fernando Iazeolla.");
puts("This program comes with ABSOLUTELY NO WARRANTY.");
puts("This is free software (GNU GPLv2), and you are welcome to redistribute it");
return puts("under GNU GPL version 2 (see <http://www.gnu.org/licenses/>).");
}

original_code:
void normal_shell_disclaimer()
{
 printf("dwarf-ng Copyright (C) 2007-2013-2017 Fernando Iazeolla.\n");
 printf("This program comes with ABSOLUTELY NO WARRANTY.\n");
 printf("This is free software (GNU GPLv2), and you are welcome to redistribute it\n");
 printf("under GNU GPL version 2 (see <http://www.gnu.org/licenses/>).\n");
}


decompiled_code:
_BOOL8 check_funny()
{
time_t timer; // [rsp+8h] [rbp-10h] BYREF

time(&timer);
return div(timer, 10).rem == 7;
}

canonical_decompiled_code:
_BOOL8 func4()
{
time_t timer; // [rsp+8h] [rbp-10h] BYREF

time(&timer);
return div(timer, 10).rem == 7;
}

original_code:
int check_funny()
{
 time_t now;
 div_t d;
 time(&now);
 d=div(now,10);
 if(d.rem==7) return 1; else return 0;
}

canonical_original_code:
int check_funny()
{
 long now;
 struct div_t d;
 time(&now);
 d=div(now,10);
 if(d.rem==7) return 1; else return 0;
}

variable_types: now long

variable_types:
d
struct div_t { int quot; int rem; }

return_type: int


decompiled_code:
int __fastcall make_prompt(char *a1)
{
int result; // eax

if ( fc_ptr )
result = sprintf(
a1,
"%s[0x%.10llx]>%s ",
*(const char **)(ptr_colors + 64),
*(_QWORD *)(fc_ptr + 3144),
*(const char **)ptr_colors);
else
result = sprintf(a1, "%sdwarf>%s ", *(const char **)(ptr_colors + 64), *(const char **)ptr_colors);
return result;
}

canonical_decompiled_code:
int __fastcall func5(char *a1)
{
int result; // eax

if ( fc_ptr )
result = sprintf(
a1,
"%s[0x%.10llx]>%s ",
*(const char **)(ptr_colors + 64),
*(_QWORD *)(fc_ptr + 3144),
*(const char **)ptr_colors);
else
result = sprintf(a1, "%sdwarf>%s ", *(const char **)(ptr_colors + 64), *(const char **)ptr_colors);
return result;
}

original_code:
void make_prompt(char *s){
 if(!fc_ptr) {sprintf(s,"%sdwarf>%s ",ptr_colors[C_YELLOW],ptr_colors[C_RESET]);return;}
 sprintf(s,"%s[0x%.10llx]>%s ",ptr_colors[C_YELLOW],(long long unsigned)fc_ptr->seek,ptr_colors[C_RESET]);
}

canonical_original_code:
void make_prompt(char *s){
 if(!fc_ptr) {sprintf(s,"%sdwarf>%s ",ptr_colors[C_YELLOW],ptr_colors[C_RESET]);return;}
 sprintf(s,"%s[0x%.10llx]>%s ",ptr_colors[C_YELLOW],(unsigned long long)fc_ptr->seek,ptr_colors[C_RESET]);
}


shell

decompiled_code:
void shell()
{
char *v0; // rbp
const char *v1; // rax

reset_stdin();
quit_shell = 0;
v0 = (char *)malloc(0x80uLL);
if ( check_funny() )
funny_shell_disclaimer();
else
normal_shell_disclaimer();
puts("entering shell-interactive mode...");
puts("type '?' for help.");
while ( !quit_shell )
{
make_prompt(v0);
v1 = rl_gets((__int64)v0);
execute(v1);
}
free(v0);
}

canonical_decompiled_code:
void func6()
{
char *v0; // rbp
const char *v1; // rax

reset_stdin();
quit_shell = 0;
v0 = (char *)malloc(0x80uLL);
if ( func4() )
func2();
else
func3();
puts("entering shell-interactive mode...");
puts("type '?' for help.");
while ( !quit_shell )
{
func5(v0);
v1 = rl_gets((__int64)v0);
func0(v1);
}
free(v0);
}

original_code:
void shell(void)
{
 char *cmd,*prompt;
 reset_stdin();
 quit_shell=false;
 prompt=(char*)malloc(128*sizeof(char));
 if(check_funny()) funny_shell_disclaimer(); else normal_shell_disclaimer();
 printf("entering shell-interactive mode...\n");
 printf("type '?' for help.\n");
 while(!quit_shell)
 {
  make_prompt(prompt);
  cmd=rl_gets(prompt);
  execute(cmd);
 }
 free(prompt);
}

canonical_original_code:
void shell()
{
 char *cmd; char *prompt;
 reset_stdin();
 quit_shell=false;
 prompt=(char *)malloc(128*sizeof(char));
 if(check_funny()) funny_shell_disclaimer(); else normal_shell_disclaimer();
 printf("entering shell-interactive mode...\n");
 printf("type '?' for help.\n");
 while(!quit_shell)
 {
  make_prompt(prompt);
  cmd=rl_gets(prompt);
  execute(cmd);
 }
 free(prompt);
}

variable_types:
cmd
char *

variable_types:
prompt
char *


die

decompiled_code:
void __fastcall __noreturn die(const char *a1)
{
fwrite("** dwarf-ng critical error !!!\n", 1uLL, 0x1FuLL, stderr);
fwrite("------------------------------\n", 1uLL, 0x1FuLL, stderr);
fprintf(stderr, "%s\n", a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(const char *a1)
{
fwrite("** dwarf-ng critical error !!!\n", 1uLL, 0x1FuLL, stderr);
fwrite("------------------------------\n", 1uLL, 0x1FuLL, stderr);
fprintf(stderr, "%s\n", a1);
exit(1);
}

original_code:
void die(char *s)
{
 fprintf(stderr,"** dwarf-ng critical error !!!\n");
 fprintf(stderr,"------------------------------\n");
 fprintf(stderr,"%s\n",s);
 exit(1);
}


warn

decompiled_code:
int __fastcall warn(const char *a1)
{
fwrite("++ Warning !!! ", 1uLL, 0xFuLL, stderr);
return fprintf(stderr, "%s\n", a1);
}

canonical_decompiled_code:
int __fastcall func1(const char *a1)
{
fwrite("++ Warning !!! ", 1uLL, 0xFuLL, stderr);
return fprintf(stderr, "%s\n", a1);
}

original_code:
void warn(char *s)
{
 fprintf(stderr,"++ Warning !!! ");
 fprintf(stderr,"%s\n",s);
}


decompiled_code:
__int64 probe_cpu_endian()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func5()
{
return 0LL;
}

original_code:
int probe_cpu_endian()
{
 int x=1,res;
 char *h,*l;
 h=(char*)&x;
 l=h+3;
 res=(int)*l;
 if(res) return big_endian; else return little_endian;
}

canonical_original_code:
int probe_cpu_endian()
{
 int x = 1; int res;
 char *h; char *l;
 h=(char *)&x;
 l=h+3;
 res=(int)*l;
 if(res) return big_endian; else return little_endian;
}

variable_types: x int

variable_types: res int

variable_types:
h
char *

variable_types:
l
char *


decompiled_code:
__int64 __fastcall peek8(__int64 a1)
{
return *(unsigned __int8 *)(*(_QWORD *)(fc_ptr + 1080) + a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
return *(unsigned __int8 *)(*(_QWORD *)(fc_ptr + 1080) + a1);
}

original_code:
uint8_t peek8(off_t offset)
{
 int res;
 char *mem;
 mem=(char*)fc_ptr->faddr;
 mem+=offset;
 res=(int)*mem;
 return res;
}

canonical_original_code:
unsigned char peek8(long offset)
{
 int res;
 char *mem;
 mem=(char *)fc_ptr->faddr;
 mem+=offset;
 res=(int)*mem;
 return res;
}

variable_types: offset long

variable_types:
mem
char *

return_type: unsigned char


decompiled_code:
__int64 __fastcall peek16(__int64 a1)
{
int v1; // edx
__int64 result; // rax
unsigned __int16 v3; // [rsp+Eh] [rbp-2h] BYREF

v1 = *(_DWORD *)(fc_ptr + 1048);
result = *(unsigned __int16 *)(*(_QWORD *)(fc_ptr + 1080) + a1);
v3 = *(_WORD *)(*(_QWORD *)(fc_ptr + 1080) + a1);
if ( !v1 )
{
endian_swap_16(&v3);
result = v3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
int v1; // edx
__int64 result; // rax
unsigned __int16 v3; // [rsp+Eh] [rbp-2h] BYREF

v1 = *(_DWORD *)(fc_ptr + 1048);
result = *(unsigned __int16 *)(*(_QWORD *)(fc_ptr + 1080) + a1);
v3 = *(_WORD *)(*(_QWORD *)(fc_ptr + 1080) + a1);
if ( !v1 )
{
func2(&v3);
result = v3;
}
return result;
}

original_code:
uint16_t peek16(off_t offset)
{
 uint16_t res;
 uint16_t *mem;
 mem=(uint16_t*)fc_ptr->faddr;
 mem=(uint16_t*)((char*)mem+offset);
 res=*mem;
 if(fc_ptr->cpu_endian==little_endian) endian_swap_16(&res);
 return res;
}

canonical_original_code:
unsigned short peek16(long offset)
{
 unsigned short res;
 unsigned short *mem;
 mem=(unsigned short *)fc_ptr->faddr;
 mem=(unsigned short *)((char *)mem+offset);
 res=*mem;
 if(fc_ptr->cpu_endian==little_endian) endian_swap_16(&res);
 return res;
}

variable_types:
res
unsigned short

variable_types:
mem
unsigned short *

return_type: unsigned short


decompiled_code:
__int64 __fastcall peek32(__int64 a1)
{
int v1; // edx
__int64 result; // rax
unsigned int v3; // [rsp+Ch] [rbp-4h] BYREF

v1 = *(_DWORD *)(fc_ptr + 1048);
result = *(unsigned int *)(*(_QWORD *)(fc_ptr + 1080) + a1);
v3 = *(_DWORD *)(*(_QWORD *)(fc_ptr + 1080) + a1);
if ( !v1 )
{
endian_swap_32(&v3);
result = v3;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
int v1; // edx
__int64 result; // rax
unsigned int v3; // [rsp+Ch] [rbp-4h] BYREF

v1 = *(_DWORD *)(fc_ptr + 1048);
result = *(unsigned int *)(*(_QWORD *)(fc_ptr + 1080) + a1);
v3 = *(_DWORD *)(*(_QWORD *)(fc_ptr + 1080) + a1);
if ( !v1 )
{
func3(&v3);
result = v3;
}
return result;
}

original_code:
uint32_t peek32(off_t offset)
{
 uint32_t res;
 uint32_t *mem;
 mem=(uint32_t*)fc_ptr->faddr;
 mem=(uint32_t*)((char*)mem+offset);
 res=*mem;
 if(fc_ptr->cpu_endian==little_endian) endian_swap_32(&res);
 return res;
}

canonical_original_code:
unsigned int peek32(long offset)
{
 unsigned int res;
 unsigned int *mem;
 mem=(unsigned int *)fc_ptr->faddr;
 mem=(unsigned int *)((char *)mem+offset);
 res=*mem;
 if(fc_ptr->cpu_endian==little_endian) endian_swap_32(&res);
 return res;
}

variable_types:
res
unsigned int

variable_types:
mem
unsigned int *

return_type: unsigned int


decompiled_code:
unsigned __int64 __fastcall peek64(__int64 a1)
{
int v1; // edx
unsigned __int64 result; // rax
unsigned __int64 v3; // [rsp+8h] [rbp-8h] BYREF

v1 = *(_DWORD *)(fc_ptr + 1048);
result = *(_QWORD *)(*(_QWORD *)(fc_ptr + 1080) + a1);
v3 = result;
if ( !v1 )
{
endian_swap_64(&v3);
result = v3;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func9(__int64 a1)
{
int v1; // edx
unsigned __int64 result; // rax
unsigned __int64 v3; // [rsp+8h] [rbp-8h] BYREF

v1 = *(_DWORD *)(fc_ptr + 1048);
result = *(_QWORD *)(*(_QWORD *)(fc_ptr + 1080) + a1);
v3 = result;
if ( !v1 )
{
func4(&v3);
result = v3;
}
return result;
}

original_code:
uint64_t peek64(off_t offset)
{
 uint64_t res;
 uint64_t *mem;
 mem=(uint64_t*)fc_ptr->faddr;
 mem=(uint64_t*)((char*)mem+offset);
 res=*mem;
 if(fc_ptr->cpu_endian==little_endian) endian_swap_64(&res);
 return res;
}

canonical_original_code:
unsigned long peek64(long offset)
{
 unsigned long res;
 unsigned long *mem;
 mem=(unsigned long *)fc_ptr->faddr;
 mem=(unsigned long *)((char *)mem+offset);
 res=*mem;
 if(fc_ptr->cpu_endian==little_endian) endian_swap_64(&res);
 return res;
}

variable_types:
res
unsigned long

variable_types:
mem
unsigned long *

return_type: unsigned long


decompiled_code:
__int64 __fastcall get_data8(unsigned int a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func14(unsigned int a1)
{
return a1;
}

original_code:
uint8_t get_data8(uint8_t data)
{
 int res;
 res=(int)data;
 return res;
}

canonical_original_code:
unsigned char get_data8(unsigned char data)
{
 int res;
 res=(int)data;
 return res;
}

variable_types:
data
unsigned char


decompiled_code:
__int64 __fastcall get_data16(unsigned __int16 a1)
{
unsigned __int16 v2; // [rsp+4h] [rbp-4h] BYREF

v2 = a1;
if ( *(_DWORD *)(fc_ptr + 1048) != *(_DWORD *)(fc_ptr + 1052) )
endian_swap_16(&v2);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func15(unsigned __int16 a1)
{
unsigned __int16 v2; // [rsp+4h] [rbp-4h] BYREF

v2 = a1;
if ( *(_DWORD *)(fc_ptr + 1048) != *(_DWORD *)(fc_ptr + 1052) )
func2(&v2);
return v2;
}

original_code:
uint16_t get_data16(uint16_t data)
{
 int res;
 if(fc_ptr->cpu_endian!=fc_ptr->file_endian) endian_swap_16(&data);
 res=(int)data;
 return res;
}

canonical_original_code:
unsigned short get_data16(unsigned short data)
{
 int res;
 if(fc_ptr->cpu_endian!=fc_ptr->file_endian) endian_swap_16(&data);
 res=(int)data;
 return res;
}

variable_types:
data
unsigned short


decompiled_code:
__int64 __fastcall get_data32(unsigned int a1)
{
unsigned int v2; // [rsp+4h] [rbp-4h] BYREF

v2 = a1;
if ( *(_DWORD *)(fc_ptr + 1048) != *(_DWORD *)(fc_ptr + 1052) )
endian_swap_32(&v2);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func16(unsigned int a1)
{
unsigned int v2; // [rsp+4h] [rbp-4h] BYREF

v2 = a1;
if ( *(_DWORD *)(fc_ptr + 1048) != *(_DWORD *)(fc_ptr + 1052) )
func3(&v2);
return v2;
}

original_code:
uint32_t get_data32(uint32_t data)
{
 int res;
 if(fc_ptr->cpu_endian!=fc_ptr->file_endian) endian_swap_32(&data);
 res=(int)data;
 return res;
}

canonical_original_code:
unsigned int get_data32(unsigned int data)
{
 int res;
 if(fc_ptr->cpu_endian!=fc_ptr->file_endian) endian_swap_32(&data);
 res=(int)data;
 return res;
}

variable_types:
data
unsigned int


decompiled_code:
__int64 __fastcall get_data64(unsigned __int64 a1)
{
unsigned __int64 v2; // [rsp+0h] [rbp-8h] BYREF

v2 = a1;
if ( *(_DWORD *)(fc_ptr + 1048) != *(_DWORD *)(fc_ptr + 1052) )
endian_swap_64(&v2);
return (int)v2;
}

canonical_decompiled_code:
__int64 __fastcall func17(unsigned __int64 a1)
{
unsigned __int64 v2; // [rsp+0h] [rbp-8h] BYREF

v2 = a1;
if ( *(_DWORD *)(fc_ptr + 1048) != *(_DWORD *)(fc_ptr + 1052) )
func4(&v2);
return (int)v2;
}

original_code:
uint64_t get_data64(uint64_t data)
{
 int res;
 if(fc_ptr->cpu_endian!=fc_ptr->file_endian) endian_swap_64(&data);
 res=(int)data;
 return res;
}

canonical_original_code:
unsigned long get_data64(unsigned long data)
{
 int res;
 if(fc_ptr->cpu_endian!=fc_ptr->file_endian) endian_swap_64(&data);
 res=(int)data;
 return res;
}

variable_types:
data
unsigned long


decompiled_code:
char *__fastcall get_color_str(char *dest, unsigned __int8 *a2)
{
const unsigned __int16 **v2; // rax
__int64 v3; // rdx
unsigned __int16 v4; // ax
const char *v5; // rsi

v2 = _ctype_b_loc();
v3 = *a2;
v4 = (*v2)[v3];
if ( (v4 & 0x400) != 0 || (v4 & 8) != 0 || (v4 & 0x4000) != 0 )
return strcpy(dest, *(const char **)(ptr_colors + 64));
if ( (_BYTE)v3 == 0xFF )
{
v5 = *(const char **)(ptr_colors + 88);
return strcpy(dest, v5);
}
if ( (_BYTE)v3 )
{
v5 = *(const char **)ptr_colors;
return strcpy(dest, v5);
}
return strcpy(dest, *(const char **)(ptr_colors + 96));
}

canonical_decompiled_code:
char *__fastcall func18(char *dest, unsigned __int8 *a2)
{
const unsigned __int16 **v2; // rax
__int64 v3; // rdx
unsigned __int16 v4; // ax
const char *v5; // rsi

v2 = _ctype_b_loc();
v3 = *a2;
v4 = (*v2)[v3];
if ( (v4 & 0x400) != 0 || (v4 & 8) != 0 || (v4 & 0x4000) != 0 )
return strcpy(dest, *(const char **)(ptr_colors + 64));
if ( (_BYTE)v3 == 0xFF )
{
v5 = *(const char **)(ptr_colors + 88);
return strcpy(dest, v5);
}
if ( (_BYTE)v3 )
{
v5 = *(const char **)ptr_colors;
return strcpy(dest, v5);
}
return strcpy(dest, *(const char **)(ptr_colors + 96));
}

original_code:
void get_color_str(char *s,uint8_t *c){
 if(((*__ctype_b_loc ())[(int) ((*c))] & (unsigned short int) _ISalpha)){
  strcpy(s,ptr_colors[C_YELLOW]);
  return;
 }
 if(((*__ctype_b_loc ())[(int) ((*c))] & (unsigned short int) _ISalnum)){
  strcpy(s,ptr_colors[C_YELLOW]);
  return;
 }
 if(((*__ctype_b_loc ())[(int) ((*c))] & (unsigned short int) _ISprint)){
  strcpy(s,ptr_colors[C_YELLOW]);
  return;
 }
 if(*c==0xff){
  strcpy(s,ptr_colors[C_RED]);
  return;
 }
 if(*c==0){
  strcpy(s,ptr_colors[C_GREEN]);
  return;
 }
 strcpy(s,ptr_colors[C_RESET]);
}

canonical_original_code:
void get_color_str(char *s, unsigned char *c){
 if(((*__ctype_b_loc ())[(int) ((*c))] & (unsigned short) _ISalpha)){
  strcpy(s,ptr_colors[C_YELLOW]);
  return;
 }
 if(((*__ctype_b_loc ())[(int) ((*c))] & (unsigned short) _ISalnum)){
  strcpy(s,ptr_colors[C_YELLOW]);
  return;
 }
 if(((*__ctype_b_loc ())[(int) ((*c))] & (unsigned short) _ISprint)){
  strcpy(s,ptr_colors[C_YELLOW]);
  return;
 }
 if(*c==0xff){
  strcpy(s,ptr_colors[C_RED]);
  return;
 }
 if(*c==0){
  strcpy(s,ptr_colors[C_GREEN]);
  return;
 }
 strcpy(s,ptr_colors[C_RESET]);
}

variable_types:
s
char *

variable_types:
c
unsigned char *


decompiled_code:
int __fastcall extended_dump(__int64 a1, __int64 a2)
{
__int64 v3; // rbx
int v4; // er13
int v5; // er12
int result; // eax
int v7; // er15
unsigned __int8 *v8; // rbp
unsigned __int8 *v9; // r15
int v10; // ebx
unsigned __int8 *v11; // rsi
int v12; // ebx
int v13; // ebx
const unsigned __int16 **v14; // r15
__int64 v15; // rdx
char v16[88]; // [rsp-58h] [rbp-58h] BYREF

if ( !fc_ptr )
return puts("no file opened.");
LODWORD(v3) = a2;
if ( !a2 )
v3 = *(_QWORD *)(fc_ptr + 3152);
v4 = v3;
v5 = 0;
result = puts("-- offset -- 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF");
if ( (int)v3 > 0 )
{
while ( 1 )
{
v7 = 16;
printf("%s0x%.10x%s ", *(const char **)(ptr_colors + 96), (unsigned int)a1, *(const char **)ptr_colors);
v8 = (unsigned __int8 *)(a1 + *(_QWORD *)(fc_ptr + 1080));
if ( v4 > v5 )
{
v9 = v8 + 1;
v10 = 1;
get_color_str(v16, (unsigned __int8 *)(a1 + *(_QWORD *)(fc_ptr + 1080)));
printf("%s%.2x%s", v16, *v8, *(const char **)ptr_colors);
if ( v4 > v5 + 1 )
{
do
{
if ( v10 > 15 )
break;
v11 = v9++;
get_color_str(v16, v11);
printf("%s%.2x%s", v16, *(v9 - 1), *(const char **)ptr_colors);
if ( (v10 & 1) != 0 )
{
++v10;
putchar(32);
}
else
{
++v10;
}
}
while ( v4 > v5 + v10 );
}
v8 = (unsigned __int8 *)(a1 + *(_QWORD *)(fc_ptr + 1080));
v7 = 16 - v10;
if ( v10 == 16 )
break;
}
v12 = 0;
do
{
++v12;
printf(" ");
}
while ( v12 < v7 );
putchar(32);
if ( v4 > v5 )
goto LABEL_15;
LABEL_20:
v5 += 16;
a1 += 16LL;
result = putchar(10);
if ( v4 <= v5 )
return result;
}
putchar(32);
LABEL_15:
v13 = 0;
v14 = _ctype_b_loc();
while ( 1 )
{
get_color_str(v16, v8);
v15 = *v8;
if ( ((*v14)[v15] & 0x4000) != 0 )
{
++v13;
++v8;
printf("%s%c%s", v16, v15, *(const char **)ptr_colors);
if ( v4 <= v5 + v13 )
goto LABEL_20;
}
else
{
++v13;
++v8;
printf("%s.%s", v16, *(const char **)ptr_colors);
if ( v4 <= v5 + v13 )
goto LABEL_20;
}
if ( v13 > 15 )
goto LABEL_20;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func19(__int64 a1, __int64 a2)
{
__int64 v3; // rbx
int v4; // er13
int v5; // er12
int result; // eax
int v7; // er15
unsigned __int8 *v8; // rbp
unsigned __int8 *v9; // r15
int v10; // ebx
unsigned __int8 *v11; // rsi
int v12; // ebx
int v13; // ebx
const unsigned __int16 **v14; // r15
__int64 v15; // rdx
char v16[88]; // [rsp-58h] [rbp-58h] BYREF

if ( !fc_ptr )
return puts("no file opened.");
LODWORD(v3) = a2;
if ( !a2 )
v3 = *(_QWORD *)(fc_ptr + 3152);
v4 = v3;
v5 = 0;
result = puts("-- offset -- 0 1 2 3 4 5 6 7 8 9 A B C D E F 0123456789ABCDEF");
if ( (int)v3 > 0 )
{
while ( 1 )
{
v7 = 16;
printf("%s0x%.10x%s ", *(const char **)(ptr_colors + 96), (unsigned int)a1, *(const char **)ptr_colors);
v8 = (unsigned __int8 *)(a1 + *(_QWORD *)(fc_ptr + 1080));
if ( v4 > v5 )
{
v9 = v8 + 1;
v10 = 1;
func18(v16, (unsigned __int8 *)(a1 + *(_QWORD *)(fc_ptr + 1080)));
printf("%s%.2x%s", v16, *v8, *(const char **)ptr_colors);
if ( v4 > v5 + 1 )
{
do
{
if ( v10 > 15 )
break;
v11 = v9++;
func18(v16, v11);
printf("%s%.2x%s", v16, *(v9 - 1), *(const char **)ptr_colors);
if ( (v10 & 1) != 0 )
{
++v10;
putchar(32);
}
else
{
++v10;
}
}
while ( v4 > v5 + v10 );
}
v8 = (unsigned __int8 *)(a1 + *(_QWORD *)(fc_ptr + 1080));
v7 = 16 - v10;
if ( v10 == 16 )
break;
}
v12 = 0;
do
{
++v12;
printf(" ");
}
while ( v12 < v7 );
putchar(32);
if ( v4 > v5 )
goto LABEL_15;
LABEL_20:
v5 += 16;
a1 += 16LL;
result = putchar(10);
if ( v4 <= v5 )
return result;
}
putchar(32);
LABEL_15:
v13 = 0;
v14 = _ctype_b_loc();
while ( 1 )
{
func18(v16, v8);
v15 = *v8;
if ( ((*v14)[v15] & 0x4000) != 0 )
{
++v13;
++v8;
printf("%s%c%s", v16, v15, *(const char **)ptr_colors);
if ( v4 <= v5 + v13 )
goto LABEL_20;
}
else
{
++v13;
++v8;
printf("%s.%s", v16, *(const char **)ptr_colors);
if ( v4 <= v5 + v13 )
goto LABEL_20;
}
if ( v13 > 15 )
goto LABEL_20;
}
}
return result;
}

original_code:
void extended_dump(off_t offset,off_t nbytes)
{
 int n,m,bytes,line_offset,mx;
 void *mem;
 uint8_t *uc;
 off_t temp_offset;
 char *scolor,colorstr[30];
 scolor=&colorstr[0];
 if(!fc_ptr) {printf("no file opened.\n"); return;}
 if(nbytes==0) nbytes=fc_ptr->block;
 bytes=(int)nbytes;
 mem=fc_ptr->faddr+offset;
 temp_offset=offset;
 uc=(uint8_t*)mem;
 printf("-- offset --   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0123456789ABCDEF\n");
 for(m=0;m<bytes;m+=16)
 {
  line_offset=0;
  mx=m;
  printf("%s0x%.10x%s  ",ptr_colors[C_GREEN],(unsigned int)temp_offset,ptr_colors[C_RESET]);
  uc=(uint8_t*)(fc_ptr->faddr+temp_offset);
  for(n=0;n<16 && mx<bytes;n++,mx++)
  {
   get_color_str(scolor,uc);
   printf("%s%.2x%s",scolor,*(uc++),ptr_colors[C_RESET]);
   line_offset++;
   if(n&1) printf(" ");
  }
  uc=(uint8_t*)(fc_ptr->faddr+temp_offset);
  for(n=0;n<16-line_offset;n++) printf("   ");
  printf(" ");
  mx=m;
  for(n=0;n<16 && mx<bytes;n++,mx++)
  {
   get_color_str(scolor,uc);
   if(((*__ctype_b_loc ())[(int) ((*uc))] & (unsigned short int) _ISprint)) printf("%s%c%s",scolor,*uc,ptr_colors[C_RESET]); else printf("%s.%s",scolor,ptr_colors[C_RESET]);
   uc++;
  }
  printf("\n");
  temp_offset+=16;
 }
}

canonical_original_code:
void extended_dump(long offset, long nbytes)
{
 int n; int m; int bytes; int line_offset; int mx;
 void *mem;
 unsigned char *uc;
 long temp_offset;
 char *scolor; char colorstr[30];
 scolor=&colorstr[0];
 if(!fc_ptr) {printf("no file opened.\n"); return;}
 if(nbytes==0) nbytes=fc_ptr->block;
 bytes=(int)nbytes;
 mem=fc_ptr->faddr+offset;
 temp_offset=offset;
 uc=(unsigned char *)mem;
 printf("-- offset --   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0123456789ABCDEF\n");
 for(m=0;m<bytes;m+=16)
 {
  line_offset=0;
  mx=m;
  printf("%s0x%.10x%s  ",ptr_colors[C_GREEN],(unsigned int)temp_offset,ptr_colors[C_RESET]);
  uc=(unsigned char *)(fc_ptr->faddr+temp_offset);
  for(n=0;n<16 && mx<bytes;n++,mx++)
  {
   get_color_str(scolor,uc);
   printf("%s%.2x%s",scolor,*(uc++),ptr_colors[C_RESET]);
   line_offset++;
   if(n&1) printf(" ");
  }
  uc=(unsigned char *)(fc_ptr->faddr+temp_offset);
  for(n=0;n<16-line_offset;n++) printf("   ");
  printf(" ");
  mx=m;
  for(n=0;n<16 && mx<bytes;n++,mx++)
  {
   get_color_str(scolor,uc);
   if(((*__ctype_b_loc ())[(int) ((*uc))] & (unsigned short) _ISprint)) printf("%s%c%s",scolor,*uc,ptr_colors[C_RESET]); else printf("%s.%s",scolor,ptr_colors[C_RESET]);
   uc++;
  }
  printf("\n");
  temp_offset+=16;
 }
}

variable_types: nbytes long

variable_types: n int

variable_types: m int

variable_types: bytes int

variable_types: mx int

variable_types:
mem
void *

variable_types:
uc
unsigned char *

variable_types:
scolor
char *

variable_types:
colorstr
char [30]


decompiled_code:
__int64 __fastcall decode_file_bit(int a1)
{
__int64 v1; // rdi
__int64 result; // rax

v1 = (unsigned int)(a1 - 1);
result = 0LL;
if ( (unsigned int)v1 <= 4 )
result = (unsigned int)CSWTCH_86[v1];
return result;
}

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

v1 = (unsigned int)(a1 - 1);
result = 0LL;
if ( (unsigned int)v1 <= 4 )
result = (unsigned int)CSWTCH_86[v1];
return result;
}

original_code:
int decode_file_bit(int bits)
{
 switch(bits) {
  case bit8:
   return 8;
   break;
  case bit16:
   return 16;
   break;
  case bit32:
   return 32;
   break;
  case bit64:
   return 64;
   break;
  case bit128:
   return 128;
   break;
  default:
   return 0;
   break;
 }
}

variable_types: bits int


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

result = "little endian";
if ( a1 )
{
result = "unknown endian";
if ( a1 == 1 )
result = "big endian";
}
return result;
}

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

result = "little endian";
if ( a1 )
{
result = "unknown endian";
if ( a1 == 1 )
result = "big endian";
}
return result;
}

original_code:
char* decode_file_endian(int endian)
{
 switch(endian) {
  case little_endian:
     return "little endian";
     break;
    case big_endian:
     return "big endian";
     break;
    default:
     return "unknown endian";
     break;
 }
}

canonical_original_code:
char *decode_file_endian(int endian)
{
 switch(endian) {
  case little_endian:
     return "little endian";
     break;
    case big_endian:
     return "big endian";
     break;
    default:
     return "unknown endian";
     break;
 }
}

variable_types: endian int

return_type: char *


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

result = "no";
if ( a1 )
result = "yes";
return result;
}

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

result = "no";
if ( a1 )
result = "yes";
return result;
}

original_code:
char* decode_yes_no(int x){
 return (x==0)? "no":"yes";
}

canonical_original_code:
char *decode_yes_no(int x){
 return (x==0)? "no":"yes";
}

variable_types: x int


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

result = "false";
if ( a1 )
result = "true";
return result;
}

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

result = "false";
if ( a1 )
result = "true";
return result;
}

original_code:
char* decode_true_false(int x){
 return (x==0)? "false":"true";
}

canonical_original_code:
char *decode_true_false(int x){
 return (x==0)? "false":"true";
}


decompiled_code:
FILE *reset_stdin()
{
return freopen("/dev/tty", "rb", stdin);
}

canonical_decompiled_code:
FILE *func24()
{
return freopen("/dev/tty", "rb", stdin);
}

original_code:
void reset_stdin(void){
 freopen("/dev/tty","rb",stdin);
}

canonical_original_code:
void reset_stdin(){
 freopen("/dev/tty","rb",stdin);
}


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

result = "FD_STDIN";
if ( a1 )
{
result = "Unknown";
if ( a1 == 1 )
result = "FD_REGULAR_FILE";
}
return result;
}

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

result = "FD_STDIN";
if ( a1 )
{
result = "Unknown";
if ( a1 == 1 )
result = "FD_REGULAR_FILE";
}
return result;
}

original_code:
char* decode_fd_type(int type){
 if(type==0) return "FD_STDIN";
 if(type==1) return "FD_REGULAR_FILE";
 return "Unknown";
}

canonical_original_code:
char *decode_fd_type(int type){
 if(type==0) return "FD_STDIN";
 if(type==1) return "FD_REGULAR_FILE";
 return "Unknown";
}

variable_types: type int


decompiled_code:
void __fastcall convert_string_hex(char *dest)
{
char *v1; // rbx
int v2; // eax
size_t v3; // r14
int v4; // er15
char *v5; // rax
char *v6; // r12
char *v7; // rbp

v1 = dest;
v2 = strlen(dest);
v3 = v2;
v4 = v2;
v5 = (char *)malloc(v2);
v6 = v5;
v7 = v5;
if ( (v4 & 1) != 0 )
{
v7 = v5 + 1;
v1 = dest + 1;
_isoc99_sscanf(dest, "%1x", v5);
v3 = v4 + 1;
}
while ( *v1 )
{
_isoc99_sscanf(v1, "%02x", v7++);
v1 += 2;
}
strncpy(dest, v6, v3);
free(v6);
}

canonical_decompiled_code:
void __fastcall func26(char *dest)
{
char *v1; // rbx
int v2; // eax
size_t v3; // r14
int v4; // er15
char *v5; // rax
char *v6; // r12
char *v7; // rbp

v1 = dest;
v2 = strlen(dest);
v3 = v2;
v4 = v2;
v5 = (char *)malloc(v2);
v6 = v5;
v7 = v5;
if ( (v4 & 1) != 0 )
{
v7 = v5 + 1;
v1 = dest + 1;
_isoc99_sscanf(dest, "%1x", v5);
v3 = v4 + 1;
}
while ( *v1 )
{
_isoc99_sscanf(v1, "%02x", v7++);
v1 += 2;
}
strncpy(dest, v6, v3);
free(v6);
}

original_code:
void convert_string_hex(char *s){
 int len;
 char *p,*buff,*pbuff;
 len=strlen(s);
 buff=(char*)malloc(len*sizeof(char));
 p=s;
 pbuff=buff;
 if(len&1){
  sscanf(p,"%1x",(unsigned int*)pbuff++);
  p++;
  len++;
 }
 while(*p){
  sscanf(p,"%02x",(unsigned int*)pbuff++);
  p+=2;
 }
 strncpy(s,buff,len);
 free(buff);
}

canonical_original_code:
void convert_string_hex(char *s){
 int len;
 char *p; char *buff; char *pbuff;
 len=strlen(s);
 buff=(char *)malloc(len*sizeof(char));
 p=s;
 pbuff=buff;
 if(len&1){
  sscanf(p,"%1x",(unsigned int *)pbuff++);
  p++;
  len++;
 }
 while(*p){
  sscanf(p,"%02x",(unsigned int *)pbuff++);
  p+=2;
 }
 strncpy(s,buff,len);
 free(buff);
}

variable_types: len int

variable_types:
p
char *

variable_types:
buff
char *

variable_types:
pbuff
char *


usage

decompiled_code:
void __noreturn usage()
{
printf("dwarf-ng-%s (c) Fernando Iazeolla 2007-2013-2017.\n", "0.4.0");
printf("\nUSAGE: ");
puts("dwarf [options] [file]");
puts("valid options:");
puts("-s --stdin file from stdin");
puts("-i --shell --interactive interactive (shell mode)");
puts("-h --help show this help");
puts("-c '<commands>' --command '<commands>' command mode (execute commands)");
puts("-e '<commands>' --command '<commands>' command mode alias (execute commands)");
puts("-x <file> --execute <file> execute file script");
puts("-v --version show dwarf-ng's version number");
puts("-f <file> --file <file> open file");
puts("-p --probe probe file and print file type and info");
puts("-C [n] --colors [n] colored output (n=theme num (opt.))");
puts("-B --nocolors nocolored output");
puts("-T [n] --theme [n] theme 2 colored output (n=theme num (opt.))");
puts("-W --work-on-copy work on copy file");
puts("-P --no-work-on-copy no work on copy file");
puts("-D <name> --tmpdir <name> set tmp dir path");
puts("-N <name> --tmpname <name> set tmp filename");
puts("-s <offs> --seek <offs> set seek offset");
puts("-b <size> --block <size> set block size");
exit(1);
}

canonical_decompiled_code:
void __noreturn func0()
{
printf("dwarf-ng-%s (c) Fernando Iazeolla 2007-2013-2017.\n", "0.4.0");
printf("\nUSAGE: ");
puts("dwarf [options] [file]");
puts("valid options:");
puts("-s --stdin file from stdin");
puts("-i --shell --interactive interactive (shell mode)");
puts("-h --help show this help");
puts("-c '<commands>' --command '<commands>' command mode (execute commands)");
puts("-e '<commands>' --command '<commands>' command mode alias (execute commands)");
puts("-x <file> --execute <file> execute file script");
puts("-v --version show dwarf-ng's version number");
puts("-f <file> --file <file> open file");
puts("-p --probe probe file and print file type and info");
puts("-C [n] --colors [n] colored output (n=theme num (opt.))");
puts("-B --nocolors nocolored output");
puts("-T [n] --theme [n] theme 2 colored output (n=theme num (opt.))");
puts("-W --work-on-copy work on copy file");
puts("-P --no-work-on-copy no work on copy file");
puts("-D <name> --tmpdir <name> set tmp dir path");
puts("-N <name> --tmpname <name> set tmp filename");
puts("-s <offs> --seek <offs> set seek offset");
puts("-b <size> --block <size> set block size");
exit(1);
}

original_code:
void usage()
{
  printf("dwarf-ng-%s (c) Fernando Iazeolla 2007-2013-2017.\n","0.4.0");
 printf("\nUSAGE: ");
 printf("dwarf [options] [file]\n");
 printf("valid options:\n");
 printf("-s              --stdin                 file from stdin\n");
 printf("-i              --shell --interactive   interactive (shell mode)\n");
 printf("-h              --help                  show this help\n");
 printf("-c '<commands>' --command '<commands>'  command  mode (execute commands)\n");
 printf("-e '<commands>' --command '<commands>'  command  mode alias (execute commands)\n");
 printf("-x <file>       --execute <file>        execute file script\n");
 printf("-v              --version               show dwarf-ng's version number\n");
 printf("-f <file>       --file <file>           open file\n");
 printf("-p              --probe                 probe file and print file type and info\n");
 printf("-C [n]          --colors [n]            colored output (n=theme num (opt.))\n");
 printf("-B              --nocolors              nocolored output\n");
 printf("-T [n]          --theme [n]             theme 2 colored output (n=theme num (opt.))\n");
 printf("-W              --work-on-copy          work on copy file\n");
 printf("-P              --no-work-on-copy       no work on copy file\n");
 printf("-D <name>       --tmpdir <name>         set tmp dir path\n");
 printf("-N <name>       --tmpname <name>        set tmp filename\n");
 printf("-s <offs>       --seek <offs>           set seek offset\n");
 printf("-b <size>       --block <size>          set block size\n");
 exit(1);
}


decompiled_code:
int usage_b()
{
printf("dwarf-ng-%s (c) Fernando Iazeolla 2007-2013-2017\n", "0.4.0");
return puts("for help type: dwarf --help");
}

canonical_decompiled_code:
int func1()
{
printf("dwarf-ng-%s (c) Fernando Iazeolla 2007-2013-2017\n", "0.4.0");
return puts("for help type: dwarf --help");
}

original_code:
void usage_b()
{
 printf("dwarf-ng-%s (c) Fernando Iazeolla 2007-2013-2017\n","0.4.0");
 printf("for help type: dwarf --help\n");
}


decompiled_code:
__int64 __fastcall parse_num_arg(__int64 a1)
{
int v2; // [rsp+Ch] [rbp-Ch] BYREF

if ( *(_BYTE *)a1 != 48 || *(_BYTE *)(a1 + 1) != 120 )
return atoi((const char *)a1);
_isoc99_sscanf(a1 + 2, "%X", &v2);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
int v2; // [rsp+Ch] [rbp-Ch] BYREF

if ( *(_BYTE *)a1 != 48 || *(_BYTE *)(a1 + 1) != 120 )
return atoi((const char *)a1);
_isoc99_sscanf(a1 + 2, "%X", &v2);
return v2;
}

original_code:
off_t parse_num_arg(char *s){
 int x;
 if(*s=='0' && *(s+1)=='x'){
  sscanf(s+2,"%X",&x);
  return (off_t)x;
 }
 return (off_t) atoi(s);
}

canonical_original_code:
long parse_num_arg(char *s){
 int x;
 if(*s=='0' && *(s+1)=='x'){
  sscanf(s+2,"%X",&x);
  return (long)x;
 }
 return (long) atoi(s);
}

variable_types:
s
char *

return_type: long


decompiled_code:
int __fastcall parse_args(int argc, char **argv, __int64 a3, char *a4, char *a5, char *a6)
{
int result; // eax
char *v13; // rsi
char *v14; // rsi
char *v15; // rdi
unsigned int v16; // eax
int longind[15]; // [rsp+Ch] [rbp-3Ch] BYREF

*(_QWORD *)a3 = 0LL;
*(_QWORD *)(a3 + 8) = 0LL;
*(_QWORD *)(a3 + 16) = 0LL;
while ( 1 )
{
longind[0] = 0;
result = getopt_long(argc, argv, "pPT::C::Bsvhie:c:x:WD:N:S:b:f:", &long_options_0, longind);
if ( result == -1 )
return result;
switch ( result )
{
case '?':
case 'h':
usage();
return result;
case 'B':
*(_DWORD *)&cfg[3160] = 0;
set_colors(0LL);
continue;
case 'C':
*(_QWORD *)&cfg[3160] = 0x100000001LL;
set_colors(1LL);
v15 = optarg;
if ( !optarg )
continue;
goto LABEL_14;
case 'D':
strncpy((char *)(unsigned int)((_DWORD)cfg + 1088), optarg, 0x400uLL);
continue;
case 'N':
strncpy((char *)(unsigned int)((_DWORD)cfg + 2112), optarg, 0x400uLL);
continue;
case 'P':
*(_DWORD *)&cfg[1032] = 0;
continue;
case 'S':
*(_QWORD *)&cfg[3144] = parse_num_arg((__int64)optarg);
continue;
case 'T':
*(_QWORD *)&cfg[3160] = 0x200000001LL;
set_colors(2LL);
v15 = optarg;
if ( optarg )
{
LABEL_14:
v16 = atoi(v15);
set_colors(v16);
}
break;
case 'W':
*(_DWORD *)&cfg[1032] = 1;
break;
case 'b':
*(_QWORD *)&cfg[3152] = parse_num_arg((__int64)optarg);
break;
case 'c':
case 'e':
v13 = optarg;
*(_DWORD *)(a3 + 12) = 1;
strncpy(a5, v13, 0x400uLL);
break;
case 'f':
strncpy(a6, optarg, 0x400uLL);
*(_DWORD *)a3 = 1;
break;
case 'i':
*(_DWORD *)(a3 + 4) = 1;
*(_DWORD *)&cfg[3168] = 1;
break;
case 'p':
*(_DWORD *)(a3 + 20) = 1;
break;
case 's':
*(_DWORD *)(a3 + 16) = 1;
break;
case 'x':
v14 = optarg;
*(_DWORD *)(a3 + 8) = 1;
strncpy(a4, v14, 0x400uLL);
break;
default:
usage_b();
break;
}
}
}

canonical_decompiled_code:
int __fastcall func3(int argc, char **argv, __int64 a3, char *a4, char *a5, char *a6)
{
int result; // eax
char *v13; // rsi
char *v14; // rsi
char *v15; // rdi
unsigned int v16; // eax
int longind[15]; // [rsp+Ch] [rbp-3Ch] BYREF

*(_QWORD *)a3 = 0LL;
*(_QWORD *)(a3 + 8) = 0LL;
*(_QWORD *)(a3 + 16) = 0LL;
while ( 1 )
{
longind[0] = 0;
result = getopt_long(argc, argv, "pPT::C::Bsvhie:c:x:WD:N:S:b:f:", &long_options_0, longind);
if ( result == -1 )
return result;
switch ( result )
{
case '?':
case 'h':
func0();
return result;
case 'B':
*(_DWORD *)&cfg[3160] = 0;
set_colors(0LL);
continue;
case 'C':
*(_QWORD *)&cfg[3160] = 0x100000001LL;
set_colors(1LL);
v15 = optarg;
if ( !optarg )
continue;
goto LABEL_14;
case 'D':
strncpy((char *)(unsigned int)((_DWORD)cfg + 1088), optarg, 0x400uLL);
continue;
case 'N':
strncpy((char *)(unsigned int)((_DWORD)cfg + 2112), optarg, 0x400uLL);
continue;
case 'P':
*(_DWORD *)&cfg[1032] = 0;
continue;
case 'S':
*(_QWORD *)&cfg[3144] = func2((__int64)optarg);
continue;
case 'T':
*(_QWORD *)&cfg[3160] = 0x200000001LL;
set_colors(2LL);
v15 = optarg;
if ( optarg )
{
LABEL_14:
v16 = atoi(v15);
set_colors(v16);
}
break;
case 'W':
*(_DWORD *)&cfg[1032] = 1;
break;
case 'b':
*(_QWORD *)&cfg[3152] = func2((__int64)optarg);
break;
case 'c':
case 'e':
v13 = optarg;
*(_DWORD *)(a3 + 12) = 1;
strncpy(a5, v13, 0x400uLL);
break;
case 'f':
strncpy(a6, optarg, 0x400uLL);
*(_DWORD *)a3 = 1;
break;
case 'i':
*(_DWORD *)(a3 + 4) = 1;
*(_DWORD *)&cfg[3168] = 1;
break;
case 'p':
*(_DWORD *)(a3 + 20) = 1;
break;
case 's':
*(_DWORD *)(a3 + 16) = 1;
break;
case 'x':
v14 = optarg;
*(_DWORD *)(a3 + 8) = 1;
strncpy(a4, v14, 0x400uLL);
break;
default:
func1();
break;
}
}
}

original_code:
void parse_args(int argc,char **argv,struct m_action *action,char *f2,char *cmds,char *filename)
{
 int c;
 action->shell=0;
 action->script=0;
 action->file=0;
 action->exec=0;
 action->stdin=0;
 action->probe=0;
 while (1)
 {
  static struct option long_options[] =
  {
   {"execute",1,0,'x'},
   {"command",1,0,'c'},
   {"command",1,0,'e'},
   {"interactive",0,0,'i'},
   {"shell",0,0,'i'},
   {"help",0,0,'h'},
   {"version",0,0,'v'},
   {"stdin",0,0,'s'},
   {"colors",2,0,'C'},
   {"nocolors",0,0,'B'},
   {"theme",2,0,'T'},
   {"work-on-copy",0,0,'W'},
   {"no-work-on-copy",0,0,'P'},
   {"tmpdir",1,0,'D'},
   {"tmpname",1,0,'N'},
   {"seek",1,0,'S'},
   {"block",1,0,'b'},
   {"file",1,0,'f'},
   {"probe",1,0,'p'},
   {0,0,0,0,}
  };
  int option_index = 0;
  c = getopt_long (argc, argv, "pPT::C::Bsvhie:c:x:WD:N:S:b:f:",long_options, &option_index);
  if (c == -1) break;
  switch(c)
  {
   case 'i':
    action->shell=1;
    cfg.inshell=1;
    break;
   case 'x':
    action->script=1;
    strncpy(f2,optarg,1024);
    break;
   case 'v':
    usage_b();
    break;
   case 'c':
   case 'e':
    action->exec=1;
    strncpy(cmds,optarg,1024);
    break;
   case 's':
    action->stdin=1;
    break;
   case 'f':
    strncpy(filename,optarg,1024);
    action->file=1;
    break;
   case 'p':
    action->probe=1;
    break;
   case 'T':
    cfg.colors=true;
    cfg.theme=E_THEME_BCOLOR;
    set_colors(E_THEME_BCOLOR);
    if(optarg) set_colors(atoi(optarg));
    break;
   case 'W':
    cfg.work_on_copy=true;
    break;
   case 'P':
    cfg.work_on_copy=false;
    break;
   case 'S':
    cfg.seek=parse_num_arg(optarg);
    break;
   case 'b':
    cfg.block=parse_num_arg(optarg);
    break;
   case 'D':
    strncpy(cfg.copydir,optarg,1024);
    break;
   case 'N':
    strncpy(cfg.copyname,optarg,1024);
    break;
   case 'C':
    cfg.colors=true;
    cfg.theme=E_THEME_COLOR;
    set_colors(E_THEME_COLOR);
    if(optarg) set_colors(atoi(optarg));
    break;
   case 'B':
    cfg.colors=false;
    set_colors(cfg.colors);
    break;
   case 'h':
   case '?':
    usage();
    break;
   default:
    usage_b();
    break;
  }
 }
}

canonical_original_code:
void parse_args(int argc, char **argv, struct m_action *action, char *f2, char *cmds, char *filename)
{
 int c;
 action->shell=0;
 action->script=0;
 action->file=0;
 action->exec=0;
 action->stdin=0;
 action->probe=0;
 while (1)
 {
  static struct option long_options[] = {
   {"execute",1,0,'x'},
   {"command",1,0,'c'},
   {"command",1,0,'e'},
   {"interactive",0,0,'i'},
   {"shell",0,0,'i'},
   {"help",0,0,'h'},
   {"version",0,0,'v'},
   {"stdin",0,0,'s'},
   {"colors",2,0,'C'},
   {"nocolors",0,0,'B'},
   {"theme",2,0,'T'},
   {"work-on-copy",0,0,'W'},
   {"no-work-on-copy",0,0,'P'},
   {"tmpdir",1,0,'D'},
   {"tmpname",1,0,'N'},
   {"seek",1,0,'S'},
   {"block",1,0,'b'},
   {"file",1,0,'f'},
   {"probe",1,0,'p'},
   {0,0,0,0,}
  };
  int option_index = 0;
  c = getopt_long (argc, argv, "pPT::C::Bsvhie:c:x:WD:N:S:b:f:",long_options, &option_index);
  if (c == -1) break;
  switch(c)
  {
   case 'i':
    action->shell=1;
    cfg.inshell=1;
    break;
   case 'x':
    action->script=1;
    strncpy(f2,optarg,1024);
    break;
   case 'v':
    usage_b();
    break;
   case 'c':
   case 'e':
    action->exec=1;
    strncpy(cmds,optarg,1024);
    break;
   case 's':
    action->stdin=1;
    break;
   case 'f':
    strncpy(filename,optarg,1024);
    action->file=1;
    break;
   case 'p':
    action->probe=1;
    break;
   case 'T':
    cfg.colors=true;
    cfg.theme=E_THEME_BCOLOR;
    set_colors(E_THEME_BCOLOR);
    if(optarg) set_colors(atoi(optarg));
    break;
   case 'W':
    cfg.work_on_copy=true;
    break;
   case 'P':
    cfg.work_on_copy=false;
    break;
   case 'S':
    cfg.seek=parse_num_arg(optarg);
    break;
   case 'b':
    cfg.block=parse_num_arg(optarg);
    break;
   case 'D':
    strncpy(cfg.copydir,optarg,1024);
    break;
   case 'N':
    strncpy(cfg.copyname,optarg,1024);
    break;
   case 'C':
    cfg.colors=true;
    cfg.theme=E_THEME_COLOR;
    set_colors(E_THEME_COLOR);
    if(optarg) set_colors(atoi(optarg));
    break;
   case 'B':
    cfg.colors=false;
    set_colors(cfg.colors);
    break;
   case 'h':
   case '?':
    usage();
    break;
   default:
    usage_b();
    break;
  }
 }
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct m_action { int file; int shell; int script; int exec; int stdin; int probe; } *

variable_types:
cmds
char *

variable_types:
filename
char *

variable_types: c int

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


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4[8]; // [rsp+0h] [rbp-C38h] BYREF
char dest[1024]; // [rsp+20h] [rbp-C18h] BYREF
char v6[1024]; // [rsp+420h] [rbp-818h] BYREF
char v7[1048]; // [rsp+820h] [rbp-418h] BYREF

dw_init(argc, argv, envp);
initialize_readline();
add_cmds_completions();
strncpy(dest, "<NULL>", 0x400uLL);
v4[0] = 0;
parse_args(argc, (char **)argv, (__int64)v4, v6, v7, dest);
if ( argc <= 1 )
usage_b();
if ( optind < argc )
{
strncpy(dest, argv[optind], 0x400uLL);
v4[0] = 1;
}
else if ( !v4[0] )
{
goto LABEL_5;
}
file_open(0LL, dest, 1LL);
add_sh_completion();
LABEL_5:
if ( v4[4] )
{
open_stdin();
reset_stdin();
add_sh_completion();
}
if ( v4[5] )
sw_do_info();
if ( v4[2] )
run_script(v6);
if ( v4[3] )
execute(v7);
if ( v4[1] )
{
shell();
puts("Bye.");
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4[8]; // [rsp+0h] [rbp-C38h] BYREF
char dest[1024]; // [rsp+20h] [rbp-C18h] BYREF
char v6[1024]; // [rsp+420h] [rbp-818h] BYREF
char v7[1048]; // [rsp+820h] [rbp-418h] BYREF

dw_init(argc, argv, envp);
initialize_readline();
add_cmds_completions();
strncpy(dest, "<NULL>", 0x400uLL);
v4[0] = 0;
func3(argc, (char **)argv, (__int64)v4, v6, v7, dest);
if ( argc <= 1 )
func1();
if ( optind < argc )
{
strncpy(dest, argv[optind], 0x400uLL);
v4[0] = 1;
}
else if ( !v4[0] )
{
goto LABEL_5;
}
file_open(0LL, dest, 1LL);
add_sh_completion();
LABEL_5:
if ( v4[4] )
{
open_stdin();
reset_stdin();
add_sh_completion();
}
if ( v4[5] )
sw_do_info();
if ( v4[2] )
run_script(v6);
if ( v4[3] )
execute(v7);
if ( v4[1] )
{
shell();
puts("Bye.");
}
return 0;
}

original_code:
int main(int argc,char **argv)
{
 struct m_action action;
 char filename[1024],filescript[1024],cmd[1024];
 dw_init();
 initialize_readline();
 add_cmds_completions();
 strncpy(filename,"<NULL>",1024);
 action.file=0;
 parse_args(argc,argv,&action,&filescript[0],&cmd[0],&filename[0]);
 if(argc<2) usage_b();
 if(optind<argc) {strncpy(filename,argv[optind],1024);action.file=1;}
 if(action.file)
 {
  file_open(((void *)0),filename,true);
  add_sh_completion();
 }
 if(action.stdin){
  open_stdin();
  reset_stdin();
  add_sh_completion();
 }
 if(action.probe){
  sw_do_info();
 }
 if(action.script)
 {
  run_script(filescript);
 }
 if(action.exec)
 {
  execute(cmd);
 }
 if(action.shell)
 {
  shell();
  printf("Bye.\n");
 }
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 struct m_action action;
 char filename[1024]; char filescript[1024]; char cmd[1024];
 dw_init();
 initialize_readline();
 add_cmds_completions();
 strncpy(filename,"<NULL>",1024);
 action.file=0;
 parse_args(argc,argv,&action,&filescript[0],&cmd[0],&filename[0]);
 if(argc<2) usage_b();
 if(optind<argc) {strncpy(filename,argv[optind],1024);action.file=1;}
 if(action.file)
 {
  file_open(((void *)0),filename,true);
  add_sh_completion();
 }
 if(action.stdin){
  open_stdin();
  reset_stdin();
  add_sh_completion();
 }
 if(action.probe){
  sw_do_info();
 }
 if(action.script)
 {
  run_script(filescript);
 }
 if(action.exec)
 {
  execute(cmd);
 }
 if(action.shell)
 {
  shell();
  printf("Bye.\n");
 }
 return 0;
}

variable_types: struct m_action { int file; int shell; int script; int exec; int stdin; int probe; }

variable_types:
filename
char [1024]

variable_types:
filescript
char [1024]

variable_types:
cmd
char [1024]


decompiled_code:
int sw_do_info()
{
__int64 v0; // rax
int result; // eax
const char *v2; // r13
unsigned int v3; // er12
const char *v4; // rax
__int64 v5; // rsi
const char *v6; // r13
unsigned int v7; // er12
const char *v8; // rax
unsigned int v9; // eax
__int64 v10; // rsi
const char *v11; // r13
unsigned int v12; // er12
const char *v13; // rax
__int64 v14; // rsi
__int64 v15; // rsi

if ( !fc_ptr )
return puts("no file opened.");
v0 = filesize(*(unsigned int *)(fc_ptr + 3136));
printf("%s : %lld bytes, ", (const char *)(fc_ptr + 8), v0);
switch ( *(_DWORD *)(fc_ptr + 1056) )
{
case 1:
puts("MZ EXE 16 bit little endian");
result = puts("main header: mz");
break;
case 2:
v2 = (const char *)decode_file_endian(*(unsigned int *)(fc_ptr + 1052));
v3 = decode_file_bit(*(unsigned int *)(fc_ptr + 1060));
v4 = (const char *)decode_file_cpu(*(unsigned int *)(fc_ptr + 1064));
printf("PE Porable Executable %s cpu %d bit %s\n", v4, v3, v2);
puts("mzexe header: mz");
puts("pe header: pe");
v5 = (unsigned int)get_max_pesect();
result = printf("sections: sect[0..%d]\n", v5);
break;
case 3:
v6 = (const char *)decode_file_endian(*(unsigned int *)(fc_ptr + 1052));
v7 = decode_file_bit(*(unsigned int *)(fc_ptr + 1060));
v8 = (const char *)decode_file_cpu(*(unsigned int *)(fc_ptr + 1064));
printf("ELF %s cpu %d bit %s\n", v8, v7, v6);
puts("main header: elf");
v9 = max_ph();
printf("program header: ph [0..%d]\n", v9);
v10 = (unsigned int)max_sh();
result = printf("section header: sh [0..%d]\n", v10);
break;
case 4:
v11 = (const char *)decode_file_endian(*(unsigned int *)(fc_ptr + 1052));
v12 = decode_file_bit(*(unsigned int *)(fc_ptr + 1060));
v13 = (const char *)decode_file_cpu(*(unsigned int *)(fc_ptr + 1064));
printf("Mach-O %s cpu %d bit %s\n", v13, v12, v11);
puts("main header: mac");
v14 = (unsigned int)max_lc(0xFFFFFFFFLL);
result = printf("load commands: lc[0..%d]\n", v14);
break;
case 5:
puts("Fat Mach-O");
puts("main header: fat");
v15 = (unsigned int)max_fat_arch();
result = printf("arch headers: arch [0..%d]\n", v15);
break;
case 6:
result = puts("FAT fs");
break;
case 7:
result = puts("FAT16");
break;
case 8:
result = puts("FAT32");
break;
case 9:
result = puts("EXT fs");
break;
case 0xA:
result = puts("MBR Master Boot Record");
break;
default:
result = puts("unknown file type.");
break;
}
return result;
}

canonical_decompiled_code:
int func0()
{
__int64 v0; // rax
int result; // eax
const char *v2; // r13
unsigned int v3; // er12
const char *v4; // rax
__int64 v5; // rsi
const char *v6; // r13
unsigned int v7; // er12
const char *v8; // rax
unsigned int v9; // eax
__int64 v10; // rsi
const char *v11; // r13
unsigned int v12; // er12
const char *v13; // rax
__int64 v14; // rsi
__int64 v15; // rsi

if ( !fc_ptr )
return puts("no file opened.");
v0 = filesize(*(unsigned int *)(fc_ptr + 3136));
printf("%s : %lld bytes, ", (const char *)(fc_ptr + 8), v0);
switch ( *(_DWORD *)(fc_ptr + 1056) )
{
case 1:
puts("MZ EXE 16 bit little endian");
result = puts("main header: mz");
break;
case 2:
v2 = (const char *)decode_file_endian(*(unsigned int *)(fc_ptr + 1052));
v3 = decode_file_bit(*(unsigned int *)(fc_ptr + 1060));
v4 = (const char *)decode_file_cpu(*(unsigned int *)(fc_ptr + 1064));
printf("PE Porable Executable %s cpu %d bit %s\n", v4, v3, v2);
puts("mzexe header: mz");
puts("pe header: pe");
v5 = (unsigned int)get_max_pesect();
result = printf("sections: sect[0..%d]\n", v5);
break;
case 3:
v6 = (const char *)decode_file_endian(*(unsigned int *)(fc_ptr + 1052));
v7 = decode_file_bit(*(unsigned int *)(fc_ptr + 1060));
v8 = (const char *)decode_file_cpu(*(unsigned int *)(fc_ptr + 1064));
printf("ELF %s cpu %d bit %s\n", v8, v7, v6);
puts("main header: elf");
v9 = max_ph();
printf("program header: ph [0..%d]\n", v9);
v10 = (unsigned int)max_sh();
result = printf("section header: sh [0..%d]\n", v10);
break;
case 4:
v11 = (const char *)decode_file_endian(*(unsigned int *)(fc_ptr + 1052));
v12 = decode_file_bit(*(unsigned int *)(fc_ptr + 1060));
v13 = (const char *)decode_file_cpu(*(unsigned int *)(fc_ptr + 1064));
printf("Mach-O %s cpu %d bit %s\n", v13, v12, v11);
puts("main header: mac");
v14 = (unsigned int)max_lc(0xFFFFFFFFLL);
result = printf("load commands: lc[0..%d]\n", v14);
break;
case 5:
puts("Fat Mach-O");
puts("main header: fat");
v15 = (unsigned int)max_fat_arch();
result = printf("arch headers: arch [0..%d]\n", v15);
break;
case 6:
result = puts("FAT fs");
break;
case 7:
result = puts("FAT16");
break;
case 8:
result = puts("FAT32");
break;
case 9:
result = puts("EXT fs");
break;
case 0xA:
result = puts("MBR Master Boot Record");
break;
default:
result = puts("unknown file type.");
break;
}
return result;
}

original_code:
void sw_do_info(void)
{
 off_t len;
 if(!fc_ptr) {printf("no file opened.\n"); return;}
 len=filesize(fc_ptr->fd);
 printf("%s : %lld bytes, ",fc_ptr->name,(long long)len);
 switch(fc_ptr->file_type) {
  case FT_MZEXE:
   printf("MZ EXE 16 bit little endian\n");
   printf("main header: mz\n");
   break;
  case FT_PE:
   printf("PE Porable Executable %s cpu %d bit %s\n",decode_file_cpu(fc_ptr->file_cpu_type),decode_file_bit(fc_ptr->file_bit_class),decode_file_endian(fc_ptr->file_endian));
   printf("mzexe header: mz\n");
   printf("pe header: pe\n");
   printf("sections: sect[0..%d]\n",get_max_pesect());
   break;
  case FT_ELF:
   printf("ELF %s cpu %d bit %s\n",decode_file_cpu(fc_ptr->file_cpu_type),decode_file_bit(fc_ptr->file_bit_class),decode_file_endian(fc_ptr->file_endian));
   printf("main header: elf\n");
   printf("program header: ph [0..%d]\n",max_ph());
   printf("section header: sh [0..%d]\n",max_sh());
   break;
  case FT_MACHO:
   printf("Mach-O %s cpu %d bit %s\n",decode_file_cpu(fc_ptr->file_cpu_type),decode_file_bit(fc_ptr->file_bit_class),decode_file_endian(fc_ptr->file_endian));
   printf("main header: mac\n");
   printf("load commands: lc[0..%d]\n",max_lc(-1));
   break;
  case FT_FATMACHO:
   printf("Fat Mach-O\n");
   printf("main header: fat\n");
   printf("arch headers: arch [0..%d]\n",max_fat_arch());
   break;
  case FT_FAT:
   printf("FAT fs\n");
   break;
  case FT_FAT16:
   printf("FAT16\n");
   break;
  case FT_FAT32:
   printf("FAT32\n");
   break;
  case FT_EXT:
   printf("EXT fs\n");
   break;
  case FT_MBR:
   printf("MBR Master Boot Record\n");
   break;
  default:
   printf("unknown file type.\n");
   break;
 }
}

canonical_original_code:
void sw_do_info()
{
 long len;
 if(!fc_ptr) {printf("no file opened.\n"); return;}
 len=filesize(fc_ptr->fd);
 printf("%s : %lld bytes, ",fc_ptr->name,(long long)len);
 switch(fc_ptr->file_type) {
  case FT_MZEXE:
   printf("MZ EXE 16 bit little endian\n");
   printf("main header: mz\n");
   break;
  case FT_PE:
   printf("PE Porable Executable %s cpu %d bit %s\n",decode_file_cpu(fc_ptr->file_cpu_type),decode_file_bit(fc_ptr->file_bit_class),decode_file_endian(fc_ptr->file_endian));
   printf("mzexe header: mz\n");
   printf("pe header: pe\n");
   printf("sections: sect[0..%d]\n",get_max_pesect());
   break;
  case FT_ELF:
   printf("ELF %s cpu %d bit %s\n",decode_file_cpu(fc_ptr->file_cpu_type),decode_file_bit(fc_ptr->file_bit_class),decode_file_endian(fc_ptr->file_endian));
   printf("main header: elf\n");
   printf("program header: ph [0..%d]\n",max_ph());
   printf("section header: sh [0..%d]\n",max_sh());
   break;
  case FT_MACHO:
   printf("Mach-O %s cpu %d bit %s\n",decode_file_cpu(fc_ptr->file_cpu_type),decode_file_bit(fc_ptr->file_bit_class),decode_file_endian(fc_ptr->file_endian));
   printf("main header: mac\n");
   printf("load commands: lc[0..%d]\n",max_lc(-1));
   break;
  case FT_FATMACHO:
   printf("Fat Mach-O\n");
   printf("main header: fat\n");
   printf("arch headers: arch [0..%d]\n",max_fat_arch());
   break;
  case FT_FAT:
   printf("FAT fs\n");
   break;
  case FT_FAT16:
   printf("FAT16\n");
   break;
  case FT_FAT32:
   printf("FAT32\n");
   break;
  case FT_EXT:
   printf("EXT fs\n");
   break;
  case FT_MBR:
   printf("MBR Master Boot Record\n");
   break;
  default:
   printf("unknown file type.\n");
   break;
 }
}

variable_types: len long


decompiled_code:
__int64 get_offset()
{
int v0; // eax
__int64 result; // rax

if ( fc_ptr )
{
v0 = *(_DWORD *)(fc_ptr + 1056);
if ( v0 == 4 )
{
result = get_macho_offset();
}
else if ( v0 > 4 )
{
if ( v0 != 5 )
return 0LL;
result = get_fatmacho_offset();
}
else
{
if ( v0 == 3 )
return get_elf_offset();
if ( v0 <= 0 )
return 0LL;
result = get_pe_offset();
}
}
else
{
puts("no file opened.");
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
int v0; // eax
__int64 result; // rax

if ( fc_ptr )
{
v0 = *(_DWORD *)(fc_ptr + 1056);
if ( v0 == 4 )
{
result = get_macho_offset();
}
else if ( v0 > 4 )
{
if ( v0 != 5 )
return 0LL;
result = get_fatmacho_offset();
}
else
{
if ( v0 == 3 )
return get_elf_offset();
if ( v0 <= 0 )
return 0LL;
result = get_pe_offset();
}
}
else
{
puts("no file opened.");
result = 0LL;
}
return result;
}

original_code:
off_t get_offset(struct _structvar *ptr,int endoffset)
{
 off_t offs;
 if(!fc_ptr) {printf("no file opened.\n"); return 0;}
 switch(fc_ptr->file_type) {
  case FT_ELF:
   offs=get_elf_offset(ptr,endoffset);
   break;
  case FT_FATMACHO:
   offs=get_fatmacho_offset(ptr,endoffset);
   break;
  case FT_MACHO:
   offs=get_macho_offset(ptr,endoffset);
   break;
  case FT_PE:
  case FT_MZEXE:
   offs=get_pe_offset(ptr,endoffset);
   break;
  default:
   offs=0;
   break;
 }
 return offs;
}

canonical_original_code:
long get_offset(struct _structvar *ptr, int endoffset)
{
 long offs;
 if(!fc_ptr) {printf("no file opened.\n"); return 0;}
 switch(fc_ptr->file_type) {
  case FT_ELF:
   offs=get_elf_offset(ptr,endoffset);
   break;
  case FT_FATMACHO:
   offs=get_fatmacho_offset(ptr,endoffset);
   break;
  case FT_MACHO:
   offs=get_macho_offset(ptr,endoffset);
   break;
  case FT_PE:
  case FT_MZEXE:
   offs=get_pe_offset(ptr,endoffset);
   break;
  default:
   offs=0;
   break;
 }
 return offs;
}

variable_types: struct _structvar { char name[255]; int num; struct _structvar *next; } *

variable_types: endoffset int

variable_types: offs long


decompiled_code:
int add_sh_completion()
{
int result; // eax

if ( !fc_ptr )
return puts("no file opened.");
result = *(_DWORD *)(fc_ptr + 1056);
if ( result == 4 )
return add_macho_completion();
if ( result > 4 )
{
if ( result == 5 )
result = add_fatmacho_completion();
}
else if ( result == 3 )
{
result = add_elf_completion();
}
else if ( result > 0 )
{
result = add_pe_completion();
}
return result;
}

canonical_decompiled_code:
int func2()
{
int result; // eax

if ( !fc_ptr )
return puts("no file opened.");
result = *(_DWORD *)(fc_ptr + 1056);
if ( result == 4 )
return add_macho_completion();
if ( result > 4 )
{
if ( result == 5 )
result = add_fatmacho_completion();
}
else if ( result == 3 )
{
result = add_elf_completion();
}
else if ( result > 0 )
{
result = add_pe_completion();
}
return result;
}

original_code:
void add_sh_completion()
{
 if(!fc_ptr) {printf("no file opened.\n"); return;}
 switch(fc_ptr->file_type) {
  case FT_ELF:
   add_elf_completion();
   break;
  case FT_FATMACHO:
   add_fatmacho_completion();
   break;
  case FT_MACHO:
   add_macho_completion();
   break;
  case FT_PE:
  case FT_MZEXE:
   add_pe_completion();
   break;
  default:
   break;
 }
}


original_code:
void do_create(char *ss,off_t offs,int grow,int update)
{
 int sect;
 sect=SECT_NULL;
 if(!fc_ptr) {fprintf(stderr,"no file opened.\n"); return;}
 switch(fc_ptr->file_type) {
  case FT_ELF:
   if((strcmp(ss,"elf"))==0) sect=SECT_ELF;
   if((strcmp(ss,"ph"))==0) sect=SECT_PH;
   if((strcmp(ss,"sh"))==0) sect=SECT_SH;
   break;
  case FT_FATMACHO:
   if((strcmp(ss,"fat"))==0) sect=SECT_FATMACHO;
   if((strcmp(ss,"arch"))==0) sect=SECT_FATARCH;
   break;
  case FT_MACHO:
   if((strcmp(ss,"mac"))==0) sect=SECT_MAC;
   if((strcmp(ss,"lc"))==0) sect=SECT_LC;
   if((strcmp(ss,"sect"))==0) sect=SECT_MACSECT;
   break;
  case FT_PE:
   if((strcmp(ss,"mz"))==0) sect=SECT_MZ;
   if((strcmp(ss,"pe"))==0) sect=SECT_PE;
   if((strcmp(ss,"sect"))==0) sect=SECT_PESECT;
   break;
  default:
   printf("unknown file type, cannot create header.\n");
   break;
 }
 printf("%s %lld %d %d %d",ss,(long long)offs,grow,update,sect);
}

canonical_original_code:
void do_create(char *ss, long offs, int grow, int update)
{
 int sect;
 sect=SECT_NULL;
 if(!fc_ptr) {fprintf(stderr,"no file opened.\n"); return;}
 switch(fc_ptr->file_type) {
  case FT_ELF:
   if((strcmp(ss,"elf"))==0) sect=SECT_ELF;
   if((strcmp(ss,"ph"))==0) sect=SECT_PH;
   if((strcmp(ss,"sh"))==0) sect=SECT_SH;
   break;
  case FT_FATMACHO:
   if((strcmp(ss,"fat"))==0) sect=SECT_FATMACHO;
   if((strcmp(ss,"arch"))==0) sect=SECT_FATARCH;
   break;
  case FT_MACHO:
   if((strcmp(ss,"mac"))==0) sect=SECT_MAC;
   if((strcmp(ss,"lc"))==0) sect=SECT_LC;
   if((strcmp(ss,"sect"))==0) sect=SECT_MACSECT;
   break;
  case FT_PE:
   if((strcmp(ss,"mz"))==0) sect=SECT_MZ;
   if((strcmp(ss,"pe"))==0) sect=SECT_PE;
   if((strcmp(ss,"sect"))==0) sect=SECT_PESECT;
   break;
  default:
   printf("unknown file type, cannot create header.\n");
   break;
 }
 printf("%s %lld %d %d %d",ss,(long long)offs,grow,update,sect);
}

variable_types:
ss
char *

variable_types: grow int

variable_types: update int

variable_types: sect int


original_code:
char* decode_file_type(int x){
 char *file_type[]={"Unknown","MZ-exe","PE","ELF","Macho","FAT Macho","FAT","FAT16","FAT32","EXT","MBR"};
 return file_type[x];
}

canonical_original_code:
char *decode_file_type(int x){
 char *file_type[] = {"Unknown","MZ-exe","PE","ELF","Macho","FAT Macho","FAT","FAT16","FAT32","EXT","MBR"};
 return file_type[x];
}

variable_types: x int


decompiled_code:
int __fastcall dw_create_section(const char *a1, __int64 a2, int a3)
{
int v4; // edx
bool v5; // cc
int v6; // ecx
int v7; // edx
_BOOL4 v8; // ebx
int result; // eax
bool v10; // zf
unsigned int v11; // ebx
int v12; // edx
bool v13; // zf
int v14; // edx
unsigned int v15; // ebx
int v16; // edx
bool v17; // zf

if ( !fc_ptr )
return fwrite("no file open\n", 1uLL, 0xDuLL, stderr);
if ( a3 )
{
v4 = *(_DWORD *)(fc_ptr + 1056);
v5 = v4 <= 4;
if ( v4 != 4 )
goto LABEL_4;
}
else
{
v4 = *(_DWORD *)(fc_ptr + 1056);
a2 = *(_QWORD *)(fc_ptr + 3144);
v5 = v4 <= 4;
if ( v4 != 4 )
{
LABEL_4:
if ( !v5 )
{
if ( v4 == 5 )
{
v10 = strcmp(a1, "arch") == 0;
if ( !strcmp(a1, "fat") )
{
if ( !v10 )
return create_fatmacho_hdr(10LL, a2, 1LL, 1LL);
}
else if ( !v10 )
{
create_fatmacho_hdr(0LL, a2, 1LL, 1LL);
return fwrite("unknown section name\n", 1uLL, 0x15uLL, stderr);
}
return create_fatmacho_hdr(11LL, a2, 1LL, 1LL);
}
return puts("unknown file type, cannot create header.");
}
if ( v4 != 2 )
{
if ( v4 == 3 )
{
v6 = *(unsigned __int8 *)a1 - 112;
if ( *a1 == 112 )
{
v6 = *((unsigned __int8 *)a1 + 1) - 104;
if ( a1[1] == 104 )
v6 = *((unsigned __int8 *)a1 + 2);
}
v7 = *(unsigned __int8 *)a1 - 115;
if ( *a1 == 115 )
{
v7 = *((unsigned __int8 *)a1 + 1) - 104;
if ( a1[1] == 104 )
v7 = *((unsigned __int8 *)a1 + 2);
}
if ( v6 )
{
if ( v7 )
{
v8 = strcmp(a1, "elf") != 0;
result = create_elf_hdr(!v8, a2, 1LL, 1LL);
if ( !v8 )
return result;
return fwrite("unknown section name\n", 1uLL, 0x15uLL, stderr);
}
}
else if ( v7 )
{
return create_elf_hdr(2LL, a2, 1LL, 1LL);
}
return create_elf_hdr(3LL, a2, 1LL, 1LL);
}
return puts("unknown file type, cannot create header.");
}
v14 = *(unsigned __int8 *)a1;
if ( v14 == 109 && a1[1] == 122 && !a1[2] )
v15 = 6;
else
v15 = 0;
v16 = v14 - 112;
if ( !v16 )
{
v16 = *((unsigned __int8 *)a1 + 1) - 101;
if ( a1[1] == 101 )
v16 = *((unsigned __int8 *)a1 + 2);
}
v17 = strcmp(a1, "sect") == 0;
if ( v16 )
{
if ( !v17 )
{
result = create_pe_hdr(v15, a2, 1LL, 1LL);
if ( !v15 )
return fwrite("unknown section name\n", 1uLL, 0x15uLL, stderr);
return result;
}
}
else if ( !v17 )
{
return create_pe_hdr(7LL, a2, 1LL, 1LL);
}
return create_pe_hdr(8LL, a2, 1LL, 1LL);
}
}
v11 = strcmp(a1, "mac") == 0 ? 5 : 0;
v12 = *(unsigned __int8 *)a1 - 108;
if ( *a1 == 108 )
{
v12 = *((unsigned __int8 *)a1 + 1) - 99;
if ( a1[1] == 99 )
v12 = *((unsigned __int8 *)a1 + 2);
}
v13 = strcmp(a1, "sect") == 0;
if ( !v12 )
{
if ( !v13 )
return create_macho_hdr(4LL, a2, 1LL, 1LL);
return create_macho_hdr(9LL, a2, 1LL, 1LL);
}
if ( v13 )
return create_macho_hdr(9LL, a2, 1LL, 1LL);
result = create_macho_hdr(v11, a2, 1LL, 1LL);
if ( !v11 )
return fwrite("unknown section name\n", 1uLL, 0x15uLL, stderr);
return result;
}

canonical_decompiled_code:
int __fastcall func5(const char *a1, __int64 a2, int a3)
{
int v4; // edx
bool v5; // cc
int v6; // ecx
int v7; // edx
_BOOL4 v8; // ebx
int result; // eax
bool v10; // zf
unsigned int v11; // ebx
int v12; // edx
bool v13; // zf
int v14; // edx
unsigned int v15; // ebx
int v16; // edx
bool v17; // zf

if ( !fc_ptr )
return fwrite("no file open\n", 1uLL, 0xDuLL, stderr);
if ( a3 )
{
v4 = *(_DWORD *)(fc_ptr + 1056);
v5 = v4 <= 4;
if ( v4 != 4 )
goto LABEL_4;
}
else
{
v4 = *(_DWORD *)(fc_ptr + 1056);
a2 = *(_QWORD *)(fc_ptr + 3144);
v5 = v4 <= 4;
if ( v4 != 4 )
{
LABEL_4:
if ( !v5 )
{
if ( v4 == 5 )
{
v10 = strcmp(a1, "arch") == 0;
if ( !strcmp(a1, "fat") )
{
if ( !v10 )
return create_fatmacho_hdr(10LL, a2, 1LL, 1LL);
}
else if ( !v10 )
{
create_fatmacho_hdr(0LL, a2, 1LL, 1LL);
return fwrite("unknown section name\n", 1uLL, 0x15uLL, stderr);
}
return create_fatmacho_hdr(11LL, a2, 1LL, 1LL);
}
return puts("unknown file type, cannot create header.");
}
if ( v4 != 2 )
{
if ( v4 == 3 )
{
v6 = *(unsigned __int8 *)a1 - 112;
if ( *a1 == 112 )
{
v6 = *((unsigned __int8 *)a1 + 1) - 104;
if ( a1[1] == 104 )
v6 = *((unsigned __int8 *)a1 + 2);
}
v7 = *(unsigned __int8 *)a1 - 115;
if ( *a1 == 115 )
{
v7 = *((unsigned __int8 *)a1 + 1) - 104;
if ( a1[1] == 104 )
v7 = *((unsigned __int8 *)a1 + 2);
}
if ( v6 )
{
if ( v7 )
{
v8 = strcmp(a1, "elf") != 0;
result = create_elf_hdr(!v8, a2, 1LL, 1LL);
if ( !v8 )
return result;
return fwrite("unknown section name\n", 1uLL, 0x15uLL, stderr);
}
}
else if ( v7 )
{
return create_elf_hdr(2LL, a2, 1LL, 1LL);
}
return create_elf_hdr(3LL, a2, 1LL, 1LL);
}
return puts("unknown file type, cannot create header.");
}
v14 = *(unsigned __int8 *)a1;
if ( v14 == 109 && a1[1] == 122 && !a1[2] )
v15 = 6;
else
v15 = 0;
v16 = v14 - 112;
if ( !v16 )
{
v16 = *((unsigned __int8 *)a1 + 1) - 101;
if ( a1[1] == 101 )
v16 = *((unsigned __int8 *)a1 + 2);
}
v17 = strcmp(a1, "sect") == 0;
if ( v16 )
{
if ( !v17 )
{
result = create_pe_hdr(v15, a2, 1LL, 1LL);
if ( !v15 )
return fwrite("unknown section name\n", 1uLL, 0x15uLL, stderr);
return result;
}
}
else if ( !v17 )
{
return create_pe_hdr(7LL, a2, 1LL, 1LL);
}
return create_pe_hdr(8LL, a2, 1LL, 1LL);
}
}
v11 = strcmp(a1, "mac") == 0 ? 5 : 0;
v12 = *(unsigned __int8 *)a1 - 108;
if ( *a1 == 108 )
{
v12 = *((unsigned __int8 *)a1 + 1) - 99;
if ( a1[1] == 99 )
v12 = *((unsigned __int8 *)a1 + 2);
}
v13 = strcmp(a1, "sect") == 0;
if ( !v12 )
{
if ( !v13 )
return create_macho_hdr(4LL, a2, 1LL, 1LL);
return create_macho_hdr(9LL, a2, 1LL, 1LL);
}
if ( v13 )
return create_macho_hdr(9LL, a2, 1LL, 1LL);
result = create_macho_hdr(v11, a2, 1LL, 1LL);
if ( !v11 )
return fwrite("unknown section name\n", 1uLL, 0x15uLL, stderr);
return result;
}

original_code:
void dw_create_section(char *s,off_t x,int xb){
 int sect;
 sect=SECT_NULL;
 if(!fc_ptr) {fprintf(stderr,"no file open\n"); return;}
 if(!xb) x=fc_ptr->seek;
 switch(fc_ptr->file_type) {
  case FT_ELF:
   if((strcmp(s,"elf"))==0) sect=SECT_ELF;
   if((strcmp(s,"ph"))==0) sect=SECT_PH;
   if((strcmp(s,"sh"))==0) sect=SECT_SH;
   create_elf_hdr(sect,x,true,true);
   if(sect==SECT_NULL) fprintf(stderr,"unknown section name\n");
   break;
   break;
  case FT_FATMACHO:
   if((strcmp(s,"fat"))==0) sect=SECT_FATMACHO;
   if((strcmp(s,"arch"))==0) sect=SECT_FATARCH;
   create_fatmacho_hdr(sect,x,true,true);
   if(sect==SECT_NULL) fprintf(stderr,"unknown section name\n");
   break;
   break;
  case FT_MACHO:
   if((strcmp(s,"mac"))==0) sect=SECT_MAC;
   if((strcmp(s,"lc"))==0) sect=SECT_LC;
   if((strcmp(s,"sect"))==0) sect=SECT_MACSECT;
   create_macho_hdr(sect,x,true,true);
   if(sect==SECT_NULL) fprintf(stderr,"unknown section name\n");
   break;
   break;
  case FT_PE:
   if((strcmp(s,"mz"))==0) sect=SECT_MZ;
   if((strcmp(s,"pe"))==0) sect=SECT_PE;
   if((strcmp(s,"sect"))==0) sect=SECT_PESECT;
   create_pe_hdr(sect,x,true,true);
   if(sect==SECT_NULL) fprintf(stderr,"unknown section name\n");
   break;
  default:
   printf("unknown file type, cannot create header.\n");
   break;
 }
}

canonical_original_code:
void dw_create_section(char *s, long x, int xb){
 int sect;
 sect=SECT_NULL;
 if(!fc_ptr) {fprintf(stderr,"no file open\n"); return;}
 if(!xb) x=fc_ptr->seek;
 switch(fc_ptr->file_type) {
  case FT_ELF:
   if((strcmp(s,"elf"))==0) sect=SECT_ELF;
   if((strcmp(s,"ph"))==0) sect=SECT_PH;
   if((strcmp(s,"sh"))==0) sect=SECT_SH;
   create_elf_hdr(sect,x,true,true);
   if(sect==SECT_NULL) fprintf(stderr,"unknown section name\n");
   break;
   break;
  case FT_FATMACHO:
   if((strcmp(s,"fat"))==0) sect=SECT_FATMACHO;
   if((strcmp(s,"arch"))==0) sect=SECT_FATARCH;
   create_fatmacho_hdr(sect,x,true,true);
   if(sect==SECT_NULL) fprintf(stderr,"unknown section name\n");
   break;
   break;
  case FT_MACHO:
   if((strcmp(s,"mac"))==0) sect=SECT_MAC;
   if((strcmp(s,"lc"))==0) sect=SECT_LC;
   if((strcmp(s,"sect"))==0) sect=SECT_MACSECT;
   create_macho_hdr(sect,x,true,true);
   if(sect==SECT_NULL) fprintf(stderr,"unknown section name\n");
   break;
   break;
  case FT_PE:
   if((strcmp(s,"mz"))==0) sect=SECT_MZ;
   if((strcmp(s,"pe"))==0) sect=SECT_PE;
   if((strcmp(s,"sect"))==0) sect=SECT_PESECT;
   create_pe_hdr(sect,x,true,true);
   if(sect==SECT_NULL) fprintf(stderr,"unknown section name\n");
   break;
  default:
   printf("unknown file type, cannot create header.\n");
   break;
 }
}

variable_types:
s
char *

variable_types: x long

variable_types: xb int


makestructvar

decompiled_code:
char *__fastcall makestructvar(char *src, int a2, __int64 a3)
{
char *v4; // r12
char *result; // rax

v4 = (char *)malloc(0x110uLL);
if ( !v4 )
die("cannot allocate to create structvar");
result = strncpy(v4, src, 0xFFuLL);
*((_DWORD *)v4 + 64) = a2;
*((_QWORD *)v4 + 33) = a3;
return result;
}

canonical_decompiled_code:
char *__fastcall func0(char *src, int a2, __int64 a3)
{
char *v4; // r12
char *result; // rax

v4 = (char *)malloc(0x110uLL);
if ( !v4 )
die("cannot allocate to create structvar");
result = strncpy(v4, src, 0xFFuLL);
*((_DWORD *)v4 + 64) = a2;
*((_QWORD *)v4 + 33) = a3;
return result;
}

original_code:
struct _structvar* makestructvar(char *s,off_t num,struct _structvar *next)
{
 struct _structvar *ptr;
 ptr=(struct _structvar*)malloc(sizeof(struct _structvar));
 if(!ptr) die("cannot allocate to create structvar");
 strncpy(ptr->name,s,255);
 ptr->num=num;
 ptr->next=next;
 return ptr;
}

canonical_original_code:
struct _structvar *makestructvar(char *s, long num, struct _structvar *next)
{
 struct _structvar *ptr;
 ptr=(struct _structvar *)malloc(sizeof(struct _structvar));
 if(!ptr) die("cannot allocate to create structvar");
 strncpy(ptr->name,s,255);
 ptr->num=num;
 ptr->next=next;
 return ptr;
}

variable_types: num long

variable_types:
next
struct _structvar *

return_type: struct _structvar { char name[255]; int num; struct _structvar *next; } *


lookup

decompiled_code:
const char **__fastcall lookup(char *s1)
{
__int64 v1; // rbx
const char **v2; // r12

v1 = gv_first;
if ( !gv_first )
return 0LL;
while ( 1 )
{
v2 = *(const char ***)v1;
if ( !strcmp(s1, **(const char ***)v1) )
break;
v1 = *(_QWORD *)(v1 + 16);
if ( !v1 )
return 0LL;
}
return v2;
}

canonical_decompiled_code:
const char **__fastcall func1(char *s1)
{
__int64 v1; // rbx
const char **v2; // r12

v1 = gv_first;
if ( !gv_first )
return 0LL;
while ( 1 )
{
v2 = *(const char ***)v1;
if ( !strcmp(s1, **(const char ***)v1) )
break;
v1 = *(_QWORD *)(v1 + 16);
if ( !v1 )
return 0LL;
}
return v2;
}

original_code:
struct _var *lookup(char *name)
{
 struct _gvar *ptr;
 for(ptr=gv_first;ptr;ptr=ptr->next)
 {
  if((strcmp(name,ptr->var->name))==0) return ptr->var;
 }
 return ((void *)0);
}

variable_types:
name
char *

variable_types: struct _gvar { struct _var { char *name; int type; int var_type; union { char *s; long num; } val; } *var; struct _gvar *prev; } *

user_defined_types: struct _gvar { struct _var *var; struct _gvar *prev; }


setvarval

decompiled_code:
__int64 __fastcall setvarval(__int64 a1, int a2, const char *a3)
{
char *v4; // rax
__int64 result; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
if ( *(_DWORD *)(a1 + 8) == 2 )
free(*(void **)(a1 + 16));
*(_DWORD *)(a1 + 8) = a2;
if ( a2 == 1 )
{
*(_QWORD *)(a1 + 16) = a3;
result = 0LL;
}
else if ( a2 == 2 )
{
v4 = strdup(a3);
*(_QWORD *)(a1 + 16) = v4;
if ( v4 )
{
result = 0LL;
}
else
{
puts("error allocating new var strval!");
*(_DWORD *)(a1 + 8) = 0;
result = 0xFFFFFFFFLL;
}
}
else
{
puts("undefined var type, aborting new var setval.");
*(_DWORD *)(a1 + 8) = 0;
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2, const char *a3)
{
char *v4; // rax
__int64 result; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
if ( *(_DWORD *)(a1 + 8) == 2 )
free(*(void **)(a1 + 16));
*(_DWORD *)(a1 + 8) = a2;
if ( a2 == 1 )
{
*(_QWORD *)(a1 + 16) = a3;
result = 0LL;
}
else if ( a2 == 2 )
{
v4 = strdup(a3);
*(_QWORD *)(a1 + 16) = v4;
if ( v4 )
{
result = 0LL;
}
else
{
puts("error allocating new var strval!");
*(_DWORD *)(a1 + 8) = 0;
result = 0xFFFFFFFFLL;
}
}
else
{
puts("undefined var type, aborting new var setval.");
*(_DWORD *)(a1 + 8) = 0;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int setvarval(struct _var *ptr,int type, void *val)
{
 off_t *x;
 x=(off_t*)val;
 if(!ptr) return -1;
 if(ptr->type==VART_WORD) free(ptr->val.s);
 ptr->type=type;
 switch(type) {
  case VART_WORD:
   ptr->val.s=strdup((char*)val);
   if(!ptr->val.s) {printf("error allocating new var strval!\n"); ptr->type=VART_NULL; return -1;}
   break;
  case VART_NUM:
   ptr->val.num=(off_t)x;
   break;
  default:
   printf("undefined var type, aborting new var setval.\n");
   ptr->type=VART_NULL;
   return -1;
   break;
 }
 return 0;
}

canonical_original_code:
int setvarval(struct _var *ptr, int type, void *val)
{
 long *x;
 x=(long *)val;
 if(!ptr) return -1;
 if(ptr->type==VART_WORD) free(ptr->val.s);
 ptr->type=type;
 switch(type) {
  case VART_WORD:
   ptr->val.s=strdup((char *)val);
   if(!ptr->val.s) {printf("error allocating new var strval!\n"); ptr->type=VART_NULL; return -1;}
   break;
  case VART_NUM:
   ptr->val.num=(long)x;
   break;
  default:
   printf("undefined var type, aborting new var setval.\n");
   ptr->type=VART_NULL;
   return -1;
   break;
 }
 return 0;
}

variable_types: struct _var { char *name; int type; int var_type; union { char *s; long num; } val; } *

variable_types: type int

variable_types:
val
void *

variable_types:
x
long *


addvar

decompiled_code:
__int64 __fastcall addvar(__int64 a1)
{
unsigned int v1; // er12
_QWORD *v2; // rax
bool v3; // zf
__int64 v4; // rdx

v1 = -1;
if ( a1 )
{
v2 = malloc(0x18uLL);
if ( v2 )
{
v3 = gv_first == 0;
*v2 = a1;
v2[1] = 0LL;
v2[2] = 0LL;
if ( v3 )
{
gv_first = (__int64)v2;
}
else
{
v4 = gv_last;
*(_QWORD *)(gv_last + 16) = v2;
v2[1] = v4;
}
gv_last = (__int64)v2;
v1 = 1;
*(_DWORD *)(a1 + 12) = 1;
}
else
{
puts("error adding var to main table.");
}
}
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
unsigned int v1; // er12
_QWORD *v2; // rax
bool v3; // zf
__int64 v4; // rdx

v1 = -1;
if ( a1 )
{
v2 = malloc(0x18uLL);
if ( v2 )
{
v3 = gv_first == 0;
*v2 = a1;
v2[1] = 0LL;
v2[2] = 0LL;
if ( v3 )
{
gv_first = (__int64)v2;
}
else
{
v4 = gv_last;
*(_QWORD *)(gv_last + 16) = v2;
v2[1] = v4;
}
gv_last = (__int64)v2;
v1 = 1;
*(_DWORD *)(a1 + 12) = 1;
}
else
{
puts("error adding var to main table.");
}
}
return v1;
}

original_code:
int addvar(struct _var *var)
{
 struct _gvar *ptr;
 if(!var) return -1;
 ptr=malloc(sizeof(struct _gvar));
 if(!ptr) {printf("error adding var to main table.\n"); return -1;}
 ptr->var=var;
 ptr->prev=((void *)0);
 ptr->next=((void *)0);
 if(!gv_first)
 {
  gv_first=ptr;
 }
 else
 {
  gv_last->next=ptr;
  ptr->prev=gv_last;
 }
 gv_last=ptr;
 var->var_type=REGULAR_VAR;
 return true;
}

user_defined_types: struct _var { char *name; int type; int var_type; union { char *s; long num; } val; }


setvar

decompiled_code:
__int64 __fastcall setvar(char *s, int a2, const char *a3)
{
const char **v4; // rax
_QWORD *v6; // rbp

v4 = lookup(s);
if ( v4 )
return setvarval((__int64)v4, a2, a3);
v6 = newvar(s);
setvarval((__int64)v6, a2, a3);
return addvar((__int64)v6);
}

canonical_decompiled_code:
__int64 __fastcall func4(char *s, int a2, const char *a3)
{
const char **v4; // rax
_QWORD *v6; // rbp

v4 = func1(s);
if ( v4 )
return func2((__int64)v4, a2, a3);
v6 = newvar(s);
func2((__int64)v6, a2, a3);
return func3((__int64)v6);
}

original_code:
int setvar(char *name,int type, void *val)
{
 struct _var *ptr;
 int x;
 ptr=lookup(name);
 if(!ptr)
 {
  ptr=newvar(name);
  setvarval(ptr,type,val);
  x=addvar(ptr);
 }
 else
 {
  x=setvarval(ptr,type,val);
 }
 return x;
}

canonical_original_code:
int setvar(char *name, int type, void *val)
{
 struct _var *ptr;
 int x;
 ptr=lookup(name);
 if(!ptr)
 {
  ptr=newvar(name);
  setvarval(ptr,type,val);
  x=addvar(ptr);
 }
 else
 {
  x=setvarval(ptr,type,val);
 }
 return x;
}


delvar

decompiled_code:
__int64 delvar()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func5()
{
return 1LL;
}

original_code:
int delvar(struct _var *var)
{
 return true;
}


delallvar

decompiled_code:
__int64 delallvar()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func6()
{
return 1LL;
}

original_code:
int delallvar(void)
{
 return true;
}

canonical_original_code:
int delallvar()
{
 return true;
}


getvarnum

decompiled_code:
const char *__fastcall getvarnum(char *a1)
{
const char **v1; // rax
const char *result; // rax

v1 = lookup(a1);
if ( v1 )
{
if ( *((_DWORD *)v1 + 2) == 1 )
{
result = v1[2];
}
else
{
printf("wrong variable type. (assign zero to var %s)\n", a1);
result = 0LL;
}
}
else
{
printf("variable %s not found. (assign zero to var %s)\n", a1, a1);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func7(char *a1)
{
const char **v1; // rax
const char *result; // rax

v1 = func1(a1);
if ( v1 )
{
if ( *((_DWORD *)v1 + 2) == 1 )
{
result = v1[2];
}
else
{
printf("wrong variable type. (assign zero to var %s)\n", a1);
result = 0LL;
}
}
else
{
printf("variable %s not found. (assign zero to var %s)\n", a1, a1);
result = 0LL;
}
return result;
}

original_code:
off_t getvarnum(char *name)
{
 struct _var *ptr;
 ptr=lookup(name);
 if(!ptr) {printf("variable %s not found. (assign zero to var %s)\n",name,name); return 0;}
 if(ptr->type==VART_NUM)
 {
  return ptr->val.num;
 }
 else
 {
  printf("wrong variable type. (assign zero to var %s)\n",name); return 0;
 }
}

canonical_original_code:
long getvarnum(char *name)
{
 struct _var *ptr;
 ptr=lookup(name);
 if(!ptr) {printf("variable %s not found. (assign zero to var %s)\n",name,name); return 0;}
 if(ptr->type==VART_NUM)
 {
  return ptr->val.num;
 }
 else
 {
  printf("wrong variable type. (assign zero to var %s)\n",name); return 0;
 }
}


createtmpvar

decompiled_code:
_QWORD *createtmpvar()
{
_QWORD *result; // rax

result = newvar("tmpvar");
*((_DWORD *)result + 3) = 2;
return result;
}

canonical_decompiled_code:
_QWORD *func8()
{
_QWORD *result; // rax

result = newvar("tmpvar");
*((_DWORD *)result + 3) = 2;
return result;
}

original_code:
struct _var* createtmpvar()
{
 struct _var *ptr;
 ptr=newvar("tmpvar");
 ptr->var_type=TMP_VAR;
 return ptr;
}

canonical_original_code:
struct _var *createtmpvar()
{
 struct _var *ptr;
 ptr=newvar("tmpvar");
 ptr->var_type=TMP_VAR;
 return ptr;
}

return_type: struct _var { char *name; int type; int var_type; union { char *s; long num; } val; } *


destroytmpvar

decompiled_code:
void __fastcall destroytmpvar(void *ptr)
{
void *v2; // rdi

if ( ptr && *((_DWORD *)ptr + 3) == 2 )
{
if ( *((_DWORD *)ptr + 2) == 2 )
{
v2 = (void *)*((_QWORD *)ptr + 2);
if ( v2 )
free(v2);
}
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func9(void *ptr)
{
void *v2; // rdi

if ( ptr && *((_DWORD *)ptr + 3) == 2 )
{
if ( *((_DWORD *)ptr + 2) == 2 )
{
v2 = (void *)*((_QWORD *)ptr + 2);
if ( v2 )
free(v2);
}
free(ptr);
}
}

original_code:
void destroytmpvar(struct _var *var)
{
 if(!var) return;
 if(var->var_type==TMP_VAR)
 {
  if(var->type==VART_WORD)
  {
   if(var->val.s) free(var->val.s);
  }
  free(var);
 }
}


decompiled_code:
__int64 __fastcall var_tonum(__int64 a1)
{
__int64 result; // rax
__int64 v2; // [rsp+8h] [rbp-10h]

if ( a1 )
{
if ( *(_DWORD *)(a1 + 8) == 1 )
{
v2 = *(_QWORD *)(a1 + 16);
destroytmpvar((void *)a1);
result = v2;
}
else
{
destroytmpvar((void *)a1);
result = 0LL;
}
}
else
{
warn("null var");
destroytmpvar(0LL);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
__int64 result; // rax
__int64 v2; // [rsp+8h] [rbp-10h]

if ( a1 )
{
if ( *(_DWORD *)(a1 + 8) == 1 )
{
v2 = *(_QWORD *)(a1 + 16);
func9((void *)a1);
result = v2;
}
else
{
func9((void *)a1);
result = 0LL;
}
}
else
{
warn("null var");
func9(0LL);
result = 0LL;
}
return result;
}

original_code:
off_t var_tonum(struct _var *ptr)
{
 off_t x;
 if(!ptr) {warn("null var"); destroytmpvar(ptr); return 0;}
 if(ptr->type==VART_NUM)
 {
  x=ptr->val.num;
  destroytmpvar(ptr);
  return x;
 }
 destroytmpvar(ptr);
 return 0;
}

canonical_original_code:
long var_tonum(struct _var *ptr)
{
 long x;
 if(!ptr) {warn("null var"); destroytmpvar(ptr); return 0;}
 if(ptr->type==VART_NUM)
 {
  x=ptr->val.num;
  destroytmpvar(ptr);
  return x;
 }
 destroytmpvar(ptr);
 return 0;
}


decompiled_code:
char *__fastcall var_tostring(void *ptr)
{
char *v2; // r12

if ( !ptr )
{
warn("null var");
destroytmpvar(0LL);
return 0LL;
}
if ( *((_DWORD *)ptr + 2) != 2 )
{
destroytmpvar(ptr);
return 0LL;
}
v2 = strdup(*((const char **)ptr + 2));
destroytmpvar(ptr);
return v2;
}

canonical_decompiled_code:
char *__fastcall func11(void *ptr)
{
char *v2; // r12

if ( !ptr )
{
warn("null var");
func9(0LL);
return 0LL;
}
if ( *((_DWORD *)ptr + 2) != 2 )
{
func9(ptr);
return 0LL;
}
v2 = strdup(*((const char **)ptr + 2));
func9(ptr);
return v2;
}

original_code:
char* var_tostring(struct _var *ptr)
{
 char *str;
 if(!ptr) {warn("null var"); destroytmpvar(ptr); return ((void *)0);}
 if(ptr->type==VART_WORD)
 {
  str=strdup(ptr->val.s);
  destroytmpvar(ptr);
  return str;
 }
 destroytmpvar(ptr);
 return ((void *)0);
}

canonical_original_code:
char *var_tostring(struct _var *ptr)
{
 char *str;
 if(!ptr) {warn("null var"); destroytmpvar(ptr); return ((void *)0);}
 if(ptr->type==VART_WORD)
 {
  str=strdup(ptr->val.s);
  destroytmpvar(ptr);
  return str;
 }
 destroytmpvar(ptr);
 return ((void *)0);
}

variable_types:
str
char *


decompiled_code:
__int64 __fastcall dwarf_completion(__int64 a1)
{
return rl_completion_matches(a1, dwarf_command_generator);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return rl_completion_matches(a1, dwarf_command_generator);
}

original_code:
char** dwarf_completion(char *text,int start,int end)
{
 char **matches;
 matches=(char **)((void *)0);
 matches=rl_completion_matches(text,dwarf_command_generator);
 return (matches);
}

canonical_original_code:
char **dwarf_completion(char *text, int start, int end)
{
 char **matches;
 matches=(char **)((void *)0);
 matches=rl_completion_matches(text,dwarf_command_generator);
 return (matches);
}

variable_types:
text
char *

variable_types: start int

variable_types: end int

variable_types:
matches
char **

return_type: char **


decompiled_code:
char *__fastcall dwarf_command_generator(char *s2, int a2)
{
const char **v2; // rbx
size_t v3; // r13
const char *v4; // rbp

if ( a2 )
{
v3 = len_0;
v2 = (const char **)ptr_1;
}
else
{
v2 = (const char **)first_comp;
ptr_1 = (__int64)first_comp;
len_0 = strlen(s2);
v3 = len_0;
}
do
{
if ( !v2 )
return 0LL;
v4 = *v2;
v2 = (const char **)v2[3];
ptr_1 = (__int64)v2;
}
while ( strncmp(v4, s2, v3) );
return strdup(v4);
}

canonical_decompiled_code:
char *__fastcall func1(char *s2, int a2)
{
const char **v2; // rbx
size_t v3; // r13
const char *v4; // rbp

if ( a2 )
{
v3 = len_0;
v2 = (const char **)ptr_1;
}
else
{
v2 = (const char **)first_comp;
ptr_1 = (__int64)first_comp;
len_0 = strlen(s2);
v3 = len_0;
}
do
{
if ( !v2 )
return 0LL;
v4 = *v2;
v2 = (const char **)v2[3];
ptr_1 = (__int64)v2;
}
while ( strncmp(v4, s2, v3) );
return strdup(v4);
}

original_code:
char* dwarf_command_generator(char *text,int state)
{
 static struct comp_list *ptr;
 static int len;
 char *name;
 if(!state)
 {
  ptr=first_comp;
  len=strlen(text);
 }
 while(ptr)
 {
  name=ptr->s;
  if(ptr->next) ptr=ptr->next; else ptr=((void *)0);
  if(strncmp(name,text,len)==0) return(strdup(name));
 }
 return ((char *)((void *)0));
}

canonical_original_code:
char *dwarf_command_generator(char *text, int state)
{
 static struct comp_list *ptr;
 static int len;
 char *name;
 if(!state)
 {
  ptr=first_comp;
  len=strlen(text);
 }
 while(ptr)
 {
  name=ptr->s;
  if(ptr->next) ptr=ptr->next; else ptr=((void *)0);
  if(strncmp(name,text,len)==0) return(strdup(name));
 }
 return ((char *)((void *)0));
}

variable_types: state int

variable_types: struct comp_list { char *s; int type; struct comp_list *prev; } *

variable_types: len int


decompiled_code:
void initialize_readline()
{
rl_readline_name = "dwarf";
rl_attempted_completion_function = dwarf_completion;
rl_completer_word_break_characters = " \t\n\"\\'<=;+*/%^~#{}(),.->$@";
rl_completion_append_character = 32;
}

canonical_decompiled_code:
void func2()
{
rl_readline_name = "dwarf";
rl_attempted_completion_function = dwarf_completion;
rl_completer_word_break_characters = " \t\n\"\\'<=;+*/%^~#{}(),.->$@";
rl_completion_append_character = 32;
}

original_code:
void initialize_readline()
{
 rl_readline_name="dwarf";
 rl_attempted_completion_function=(rl_completion_func_t *)dwarf_completion;
 rl_completer_word_break_characters = " \t\n\"\\'<=;+*/%^~#{}(),.->$@";
 rl_completion_append_character = ' ';
}

canonical_original_code:
void initialize_readline()
{
 rl_readline_name="dwarf";
 rl_attempted_completion_function=(char **(*)(char *, int, int))dwarf_completion;
 rl_completer_word_break_characters = " \t\n\"\\'<=;+*/%^~#{}(),.->$@";
 rl_completion_append_character = ' ';
}


decompiled_code:
void __fastcall add_completion(__int128 src, int a2)
{
_QWORD *v3; // rbp
size_t v4; // r13
char *v5; // rax
bool v6; // zf
__int64 v7; // rax
char v8[1064]; // [rsp-428h] [rbp-428h] BYREF

if ( src != 0 )
{
if ( (_QWORD)src )
{
if ( *((_QWORD *)&src + 1) )
sprintf(v8, "%s.%s", (const char *)src, *((const char **)&src + 1));
else
strncpy(v8, (const char *)src, 0x400uLL);
}
else
{
strncpy(v8, *((const char **)&src + 1), 0x400uLL);
}
v3 = malloc(0x20uLL);
if ( v3 )
{
v4 = strlen(v8) + 1;
v5 = (char *)malloc(v4);
*v3 = v5;
if ( v5 )
{
strncpy(v5, v8, v4);
v6 = first_comp == 0LL;
*((_DWORD *)v3 + 2) = a2;
v3[2] = 0LL;
v3[3] = 0LL;
if ( v6 )
{
first_comp = v3;
}
else
{
v7 = last_comp;
v3[2] = last_comp;
*(_QWORD *)(v7 + 24) = v3;
}
last_comp = (__int64)v3;
}
else
{
warn("error allocating for completation item name");
free(v3);
}
}
else
{
warn("error allocating for completation item");
}
}
}

canonical_decompiled_code:
void __fastcall func3(__int128 src, int a2)
{
_QWORD *v3; // rbp
size_t v4; // r13
char *v5; // rax
bool v6; // zf
__int64 v7; // rax
char v8[1064]; // [rsp-428h] [rbp-428h] BYREF

if ( src != 0 )
{
if ( (_QWORD)src )
{
if ( *((_QWORD *)&src + 1) )
sprintf(v8, "%s.%s", (const char *)src, *((const char **)&src + 1));
else
strncpy(v8, (const char *)src, 0x400uLL);
}
else
{
strncpy(v8, *((const char **)&src + 1), 0x400uLL);
}
v3 = malloc(0x20uLL);
if ( v3 )
{
v4 = strlen(v8) + 1;
v5 = (char *)malloc(v4);
*v3 = v5;
if ( v5 )
{
strncpy(v5, v8, v4);
v6 = first_comp == 0LL;
*((_DWORD *)v3 + 2) = a2;
v3[2] = 0LL;
v3[3] = 0LL;
if ( v6 )
{
first_comp = v3;
}
else
{
v7 = last_comp;
v3[2] = last_comp;
*(_QWORD *)(v7 + 24) = v3;
}
last_comp = (__int64)v3;
}
else
{
warn("error allocating for completation item name");
free(v3);
}
}
else
{
warn("error allocating for completation item");
}
}
}

original_code:
void add_completion(char *path,char *item,int type)
{
 char str[1024];
 struct comp_list *ptr;
 int ok=0;
 if((path==((void *)0)) && (item==((void *)0))) return;
 if(path==((void *)0)) {strncpy(str,item,1024);ok=1;}
 if(item==((void *)0)) {strncpy(str,path,1024);ok=1;}
 if(!ok) sprintf(str,"%s.%s",path,item);
 ptr=(struct comp_list*)malloc(sizeof(struct comp_list));
 if(ptr==((void *)0)) {warn("error allocating for completation item");return;}
 ptr->s=(char*)malloc(strlen(str)+1);
 if(ptr->s==((void *)0)) {warn("error allocating for completation item name");free(ptr);return;}
 strncpy(ptr->s,str,strlen(str)+1);
 ptr->type=type;
 ptr->prev=((void *)0);
 ptr->next=((void *)0);
 if(first_comp==((void *)0))
 {
  first_comp=ptr;
 }
 else
 {
  ptr->prev=last_comp;
  last_comp->next=ptr;
 }
 last_comp=ptr;
}

canonical_original_code:
void add_completion(char *path, char *item, int type)
{
 char str[1024];
 struct comp_list *ptr;
 int ok = 0;
 if((path==((void *)0)) && (item==((void *)0))) return;
 if(path==((void *)0)) {strncpy(str,item,1024);ok=1;}
 if(item==((void *)0)) {strncpy(str,path,1024);ok=1;}
 if(!ok) sprintf(str,"%s.%s",path,item);
 ptr=(struct comp_list *)malloc(sizeof(struct comp_list));
 if(ptr==((void *)0)) {warn("error allocating for completation item");return;}
 ptr->s=(char *)malloc(strlen(str)+1);
 if(ptr->s==((void *)0)) {warn("error allocating for completation item name");free(ptr);return;}
 strncpy(ptr->s,str,strlen(str)+1);
 ptr->type=type;
 ptr->prev=((void *)0);
 ptr->next=((void *)0);
 if(first_comp==((void *)0))
 {
  first_comp=ptr;
 }
 else
 {
  ptr->prev=last_comp;
  last_comp->next=ptr;
 }
 last_comp=ptr;
}

variable_types:
path
char *

variable_types:
item
char *

variable_types:
str
char [1024]

variable_types: ok int

user_defined_types: struct comp_list { char *s; int type; struct comp_list *prev; }


decompiled_code:
void free_completion()
{
_QWORD *v0; // rbx
__int64 v1; // rax
__int64 v2; // rdx

v0 = first_comp;
if ( first_comp )
{
do
{
while ( *((_DWORD *)v0 + 2) != 2 )
{
v0 = (_QWORD *)v0[3];
if ( !v0 )
return;
}
v1 = v0[2];
if ( v1 )
{
if ( (_QWORD *)last_comp == v0 )
last_comp = v0[2];
*(_QWORD *)(v1 + 24) = v0[3];
}
v2 = v0[3];
if ( v2 )
{
if ( first_comp == v0 )
first_comp = (void *)v0[3];
*(_QWORD *)(v2 + 16) = v1;
}
free(v0);
v0 = (_QWORD *)v0[3];
}
while ( v0 );
}
}

original_code:
void free_completion()
{
 struct comp_list *ptr;
 for(ptr=first_comp;ptr;ptr=ptr->next)
 {
  if(ptr->type==comp_discardable)
  {
   if(ptr->prev)
   {
    if(ptr==last_comp) last_comp=ptr->prev;
    ptr->prev->next=ptr->next;
   }
   if(ptr->next)
   {
    if(ptr==first_comp) first_comp=ptr->next;
    ptr->next->prev=ptr->prev;
   }
   free(ptr);
  }
 }
}


decompiled_code:
void add_cmds_completions()
{
add_completion((unsigned __int64)"quit", 0);
add_completion((unsigned __int64)"open", 0);
add_completion((unsigned __int64)"cfg", 0);
add_completion((unsigned __int64)"maincfg", 0);
add_completion((unsigned __int64)"cfg::work_on_copy", 0);
add_completion((unsigned __int64)"cfg::writable", 0);
add_completion((unsigned __int64)"cfg::can_grow", 0);
add_completion((unsigned __int64)"cfg::changed_altered", 0);
add_completion((unsigned __int64)"cfg::verbose", 0);
add_completion((unsigned __int64)"cfg::fd", 0);
add_completion((unsigned __int64)"cfg::name", 0);
add_completion((unsigned __int64)"cfg::cpu_endian", 0);
add_completion((unsigned __int64)"cfg::file_endian", 0);
add_completion((unsigned __int64)"cfg::bitclass", 0);
add_completion((unsigned __int64)"cfg::faddr", 0);
add_completion((unsigned __int64)"cfg::copydir", 0);
add_completion((unsigned __int64)"cfg::copyname", 0);
add_completion((unsigned __int64)"cfg::xxx", 0);
add_completion((unsigned __int64)"maincfg::work_on_copy", 0);
add_completion((unsigned __int64)"maincfg::writable", 0);
add_completion((unsigned __int64)"maincfg::can_grow", 0);
add_completion((unsigned __int64)"maincfg::changed_altered", 0);
add_completion((unsigned __int64)"maincfg::verbose", 0);
add_completion((unsigned __int64)"maincfg::fd", 0);
add_completion((unsigned __int64)"maincfg::name", 0);
add_completion((unsigned __int64)"maincfg::cpu_endian", 0);
add_completion((unsigned __int64)"maincfg::file_endian", 0);
add_completion((unsigned __int64)"maincfg::file_bit_class", 0);
add_completion((unsigned __int64)"maincfg::faddr", 0);
add_completion((unsigned __int64)"maincfg::copydir", 0);
add_completion((unsigned __int64)"maincfg::copyname", 0);
add_completion((unsigned __int64)"maincfg::xxx", 0);
}

canonical_decompiled_code:
void func5()
{
func3((unsigned __int64)"quit", 0);
func3((unsigned __int64)"open", 0);
func3((unsigned __int64)"cfg", 0);
func3((unsigned __int64)"maincfg", 0);
func3((unsigned __int64)"cfg::work_on_copy", 0);
func3((unsigned __int64)"cfg::writable", 0);
func3((unsigned __int64)"cfg::can_grow", 0);
func3((unsigned __int64)"cfg::changed_altered", 0);
func3((unsigned __int64)"cfg::verbose", 0);
func3((unsigned __int64)"cfg::fd", 0);
func3((unsigned __int64)"cfg::name", 0);
func3((unsigned __int64)"cfg::cpu_endian", 0);
func3((unsigned __int64)"cfg::file_endian", 0);
func3((unsigned __int64)"cfg::bitclass", 0);
func3((unsigned __int64)"cfg::faddr", 0);
func3((unsigned __int64)"cfg::copydir", 0);
func3((unsigned __int64)"cfg::copyname", 0);
func3((unsigned __int64)"cfg::xxx", 0);
func3((unsigned __int64)"maincfg::work_on_copy", 0);
func3((unsigned __int64)"maincfg::writable", 0);
func3((unsigned __int64)"maincfg::can_grow", 0);
func3((unsigned __int64)"maincfg::changed_altered", 0);
func3((unsigned __int64)"maincfg::verbose", 0);
func3((unsigned __int64)"maincfg::fd", 0);
func3((unsigned __int64)"maincfg::name", 0);
func3((unsigned __int64)"maincfg::cpu_endian", 0);
func3((unsigned __int64)"maincfg::file_endian", 0);
func3((unsigned __int64)"maincfg::file_bit_class", 0);
func3((unsigned __int64)"maincfg::faddr", 0);
func3((unsigned __int64)"maincfg::copydir", 0);
func3((unsigned __int64)"maincfg::copyname", 0);
func3((unsigned __int64)"maincfg::xxx", 0);
}

original_code:
void add_cmds_completions()
{
 add_completion("quit",((void *)0),comp_fixed);
 add_completion("open",((void *)0),comp_fixed);
 add_completion("cfg",((void *)0),comp_fixed);
 add_completion("maincfg",((void *)0),comp_fixed);
 add_completion("cfg::work_on_copy",((void *)0),comp_fixed);
 add_completion("cfg::writable",((void *)0),comp_fixed);
 add_completion("cfg::can_grow",((void *)0),comp_fixed);
 add_completion("cfg::changed_altered",((void *)0),comp_fixed);
 add_completion("cfg::verbose",((void *)0),comp_fixed);
 add_completion("cfg::fd",((void *)0),comp_fixed);
 add_completion("cfg::name",((void *)0),comp_fixed);
 add_completion("cfg::cpu_endian",((void *)0),comp_fixed);
 add_completion("cfg::file_endian",((void *)0),comp_fixed);
 add_completion("cfg::bitclass",((void *)0),comp_fixed);
 add_completion("cfg::faddr",((void *)0),comp_fixed);
 add_completion("cfg::copydir",((void *)0),comp_fixed);
 add_completion("cfg::copyname",((void *)0),comp_fixed);
 add_completion("cfg::xxx",((void *)0),comp_fixed);
 add_completion("maincfg::work_on_copy",((void *)0),comp_fixed);
 add_completion("maincfg::writable",((void *)0),comp_fixed);
 add_completion("maincfg::can_grow",((void *)0),comp_fixed);
 add_completion("maincfg::changed_altered",((void *)0),comp_fixed);
 add_completion("maincfg::verbose",((void *)0),comp_fixed);
 add_completion("maincfg::fd",((void *)0),comp_fixed);
 add_completion("maincfg::name",((void *)0),comp_fixed);
 add_completion("maincfg::cpu_endian",((void *)0),comp_fixed);
 add_completion("maincfg::file_endian",((void *)0),comp_fixed);
 add_completion("maincfg::file_bit_class",((void *)0),comp_fixed);
 add_completion("maincfg::faddr",((void *)0),comp_fixed);
 add_completion("maincfg::copydir",((void *)0),comp_fixed);
 add_completion("maincfg::copyname",((void *)0),comp_fixed);
 add_completion("maincfg::xxx",((void *)0),comp_fixed);
}