warn

decompiled_code:
int warn(char *format, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

++warnings;
if ( nowarn <= 0 )
{
fflush(stdout);
fwrite("Warning: ", 1uLL, 9uLL, errstd);
va_start(arg, format);
vfprintf(errstd, format, arg);
result = fputc(10, errstd);
}
return result;
}

canonical_decompiled_code:
int func3(char *format, ...)
{
int result; // eax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

++warnings;
if ( nowarn <= 0 )
{
fflush(stdout);
fwrite("Warning: ", 1uLL, 9uLL, errstd);
va_start(arg, format);
vfprintf(errstd, format, arg);
result = fputc(10, errstd);
}
return result;
}

original_code:
void warn(char *fmt,...)
{
    va_list ap;
    warnings++;
    if (nowarn > 0) return;
    fflush(stdout);
    fprintf(errstd,"Warning: ");
    __builtin_va_start(ap,fmt);
    vfprintf(errstd,fmt,ap);
    __builtin_va_end(ap);
    fputc('\n',errstd);
    return;
}

canonical_original_code:
void warn(char *fmt, ...)
{
    __builtin_va_list ap;
    warnings++;
    if (nowarn > 0) return;
    fflush(stdout);
    fprintf(errstd,"Warning: ");
    __builtin_va_start(ap,fmt);
    vfprintf(errstd,fmt,ap);
    __builtin_va_end(ap);
    fputc('\n',errstd);
    return;
}


alloc

decompiled_code:
void *__fastcall alloc(int a1)
{
void *v1; // rax

v1 = malloc(a1);
if ( !v1 )
pdie("Out of memory");
return memset(v1, 0, a1);
}

canonical_decompiled_code:
void *__fastcall func4(int a1)
{
void *v1; // rax

v1 = malloc(a1);
if ( !v1 )
func0("Out of memory");
return memset(v1, 0, a1);
}

original_code:
void *alloc(int size)
{
    void *this;
    if ((this = malloc(size)) == ((void *)0)) pdie("Out of memory");
    memset(this, 0, size);
    return this;
}

variable_types: size int

variable_types:
this
void *

return_type: void *


ralloc

decompiled_code:
void *__fastcall ralloc(void *a1, int a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
pdie("Out of memory");
return result;
}

canonical_decompiled_code:
void *__fastcall func5(void *a1, int a2)
{
void *result; // rax

result = realloc(a1, a2);
if ( !result )
func0("Out of memory");
return result;
}

original_code:
void *ralloc(void *old,int size)
{
    void *this;
    if ((this = realloc(old,size)) == ((void *)0)) pdie("Out of memory");
    return this;
}

canonical_original_code:
void *ralloc(void *old, int size)
{
    void *this;
    if ((this = realloc(old,size)) == ((void *)0)) pdie("Out of memory");
    return this;
}

variable_types:
old
void *


stralloc

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

result = strdup(a1);
if ( !result )
pdie("Out of memory");
return result;
}

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

result = strdup(a1);
if ( !result )
func0("Out of memory");
return result;
}

original_code:
char *stralloc(const char *str)
{
    char *this;
    if ((this = strdup(str)) == ((void *)0)) pdie("Out of memory");
    return this;
}

canonical_original_code:
char *stralloc(char *str)
{
    char *this;
    if ((this = strdup(str)) == ((void *)0)) pdie("Out of memory");
    return this;
}

variable_types:
str
char *

variable_types:
this
char *

return_type: char *


decompiled_code:
__int64 __fastcall to_number(const char *a1)
{
__int64 result; // rax
char *endptr; // [rsp+8h] [rbp-10h] BYREF

result = strtol(a1, &endptr, 0);
if ( endptr )
{
if ( *endptr )
die("Not a number: \"%s\"", a1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1)
{
__int64 result; // rax
char *endptr; // [rsp+8h] [rbp-10h] BYREF

result = strtol(a1, &endptr, 0);
if ( endptr )
{
if ( *endptr )
func1("Not a number: \"%s\"", a1);
}
return result;
}

original_code:
int to_number(char *num)
{
    int number;
    char *end;
    number = strtol(num,&end,0);
    if (end && *end) die("Not a number: \"%s\"",num);
    return number;
}

variable_types:
num
char *

variable_types: number int

variable_types:
end
char *

return_type: int


decompiled_code:
__int64 __fastcall timer_number(const char *a1)
{
__int64 result; // rax
char *endptr; // [rsp+8h] [rbp-10h] BYREF

result = strtol(a1, &endptr, 0);
if ( endptr && *endptr )
{
switch ( *endptr )
{
case 'H':
case 'h':
LODWORD(result) = 60 * result;
goto LABEL_5;
case 'M':
case 'm':
LABEL_5:
LODWORD(result) = 60 * result;
goto LABEL_6;
case 'S':
case 's':
LABEL_6:
result = (unsigned int)(10 * result);
break;
case 'T':
case 't':
break;
default:
goto LABEL_8;
}
}
if ( (unsigned int)result > 0x8CA0 )
LABEL_8:
die("Not a valid timer value: \"%s\"", a1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(const char *a1)
{
__int64 result; // rax
char *endptr; // [rsp+8h] [rbp-10h] BYREF

result = strtol(a1, &endptr, 0);
if ( endptr && *endptr )
{
switch ( *endptr )
{
case 'H':
case 'h':
LODWORD(result) = 60 * result;
goto LABEL_5;
case 'M':
case 'm':
LABEL_5:
LODWORD(result) = 60 * result;
goto LABEL_6;
case 'S':
case 's':
LABEL_6:
result = (unsigned int)(10 * result);
break;
case 'T':
case 't':
break;
default:
goto LABEL_8;
}
}
if ( (unsigned int)result > 0x8CA0 )
LABEL_8:
func1("Not a valid timer value: \"%s\"", a1);
return result;
}

original_code:
int timer_number(char *num)
{
    int number;
    char *end;
    number = strtol(num,&end,0);
    if (end && *end) {
 switch (*end) {
     case 'h':
     case 'H':
  number *= 60;
     case 'm':
     case 'M':
  number *= 60;
     case 's':
     case 'S':
  number *= 10;
     case 't':
     case 'T':
  break;
     default:
  number = -1;
 }
    }
    if (number < 0 || number > 36000) die("Not a valid timer value: \"%s\"",num);
    return number;
}


decompiled_code:
__int64 __fastcall check_version(__int64 a1, unsigned int a2)
{
__int64 result; // rax
unsigned int v4; // ebx
__int16 v5; // bx
const char *v6; // rax
const char *v7; // rax
const char *v8; // rax
const char *v9; // rax

result = a1;
if ( !memcmp((const void *)(a1 + 2), "LILO", 4uLL) )
{
v6 = name(a2);
die("%s has a pre-21 LILO signature", v6);
}
if ( memcmp((const void *)(result + 6), "LILO", 4uLL) )
{
v7 = name(a2);
die("%s doesn't have a valid LILO signature", v7);
}
v4 = *(unsigned __int8 *)(result + 3);
if ( v4 != a2 )
{
v8 = name(a2);
die("%s has an invalid stage code (%d)", v8, v4);
}
v5 = *(_WORD *)(result + 10);
if ( v5 != 535 )
{
v9 = name(a2);
die("%s is version %d.%d. Expecting version %d.%d.", v9, (unsigned __int8)v5, HIBYTE(v5), 23LL, 2LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, unsigned int a2)
{
__int64 result; // rax
unsigned int v4; // ebx
__int16 v5; // bx
const char *v6; // rax
const char *v7; // rax
const char *v8; // rax
const char *v9; // rax

result = a1;
if ( !memcmp((const void *)(a1 + 2), "LILO", 4uLL) )
{
v6 = func2(a2);
func1("%s has a pre-21 LILO signature", v6);
}
if ( memcmp((const void *)(result + 6), "LILO", 4uLL) )
{
v7 = func2(a2);
func1("%s doesn't have a valid LILO signature", v7);
}
v4 = *(unsigned __int8 *)(result + 3);
if ( v4 != a2 )
{
v8 = func2(a2);
func1("%s has an invalid stage code (%d)", v8, v4);
}
v5 = *(_WORD *)(result + 10);
if ( v5 != 535 )
{
v9 = func2(a2);
func1("%s is version %d.%d. Expecting version %d.%d.", v9, (unsigned __int8)v5, HIBYTE(v5), 23LL, 2LL);
}
return result;
}

original_code:
void check_version(BOOT_SECTOR *sect,int stage)
{
    int bs_major, bs_minor;
    if (!strncmp(sect->par_1.signature-4,"LILO",4))
 die("%s has a pre-21 LILO signature",name(stage));
    if (strncmp(sect->par_1.signature,"LILO",4))
 die("%s doesn't have a valid LILO signature",name(stage));
    if ((sect->par_1.stage&0xFF) != stage)
 die("%s has an invalid stage code (%d)",name(stage),sect->par_1.stage);
    bs_major = sect->par_1.version & 255;
    bs_minor = sect->par_1.version >> 8;
    if (sect->par_1.version != 256*2 +23)
 die("%s is version %d.%d. Expecting version %d.%d.",name(stage),
     bs_major,bs_minor, 23,2);
}

canonical_original_code:
void check_version(union BOOT_SECTOR *sect, int stage)
{
    int bs_major; int bs_minor;
    if (!strncmp(sect->par_1.signature-4,"LILO",4))
 die("%s has a pre-21 LILO signature",name(stage));
    if (strncmp(sect->par_1.signature,"LILO",4))
 die("%s doesn't have a valid LILO signature",name(stage));
    if ((sect->par_1.stage&0xFF) != stage)
 die("%s has an invalid stage code (%d)",name(stage),sect->par_1.stage);
    bs_major = sect->par_1.version & 255;
    bs_minor = sect->par_1.version >> 8;
    if (sect->par_1.version != 256*2 +23)
 die("%s is version %d.%d. Expecting version %d.%d.",name(stage),
     bs_major,bs_minor, 23,2);
}

variable_types: union BOOT_SECTOR { struct BOOT_PARAMS_1 { unsigned char cli; unsigned char jmp0; unsigned char stage; unsigned short code_length; char signature[4]; unsigned short version; unsigned int map_stamp; unsigned int raid_offset; unsigned int timestamp; unsigned int map_serial_no; unsigned short prompt; struct SECTOR_ADDR { unsigned char sector; unsigned char device; unsigned char num_sect; } secondary; } par_1; struct BOOT_PARAMS_2 { char jump[6]; char signature[4]; unsigned short version; unsigned int map_stamp; unsigned short stage; unsigned char port; unsigned char ser_param; unsigned short timeout; unsigned short delay; unsigned short msg_len; struct SECTOR_ADDR keytab; unsigned char flag2; } par_2; struct BOOT_PARAMS_C { char jump[6]; char signature[4]; unsigned short stage; unsigned short offset; unsigned char drive; unsigned char head; unsigned short drvmap; unsigned char ptable[-1]; unsigned short p_devmap[2]; } par_c; struct BOOT_PARAMS_DOS { unsigned char jump[3]; char system[8]; struct BIOS_PARAMETER_BLOCK { unsigned char bytes_per_sector[2]; unsigned char sectors_per_cluster; unsigned char reserved_sectors[2]; unsigned char number_of_FATs; unsigned char root_dir_entries[2]; unsigned char total_sectors[2]; unsigned char media_descriptor; unsigned char sectors_per_FAT[2]; unsigned char sectors_per_track[2]; unsigned char heads_per_cylinder[2]; unsigned char hidden_sectors[4]; unsigned char total_sectors_long[4]; unsigned char reserved[7]; } bpb; } par_d; struct BOOT_VOLID { unsigned char bootcode[438]; unsigned short mbz; int volume_id; unsigned short marker; unsigned char part[-1]; unsigned short boot_ind; } boot; unsigned char sector[512]; } *

variable_types: stage int

return_type: void

user_defined_types: union BOOT_SECTOR { struct BOOT_PARAMS_1 par_1; struct BOOT_PARAMS_2 par_2; struct BOOT_PARAMS_C par_c; struct BOOT_PARAMS_DOS par_d; struct BOOT_VOLID boot; unsigned char sector[512]; }

user_defined_types: struct BOOT_PARAMS_1 { unsigned char cli; unsigned char jmp0; unsigned char stage; unsigned short code_length; char signature[4]; unsigned short version; unsigned int map_stamp; unsigned int raid_offset; unsigned int timestamp; unsigned int map_serial_no; unsigned short prompt; struct SECTOR_ADDR secondary; }

user_defined_types: struct BOOT_PARAMS_DOS { unsigned char jump[3]; char system[8]; struct BIOS_PARAMETER_BLOCK bpb; }


decompiled_code:
_BOOL8 __fastcall stat_equal(_QWORD *a1, _QWORD *a2)
{
_BOOL8 result; // rax

result = 0LL;
if ( *a1 == *a2 )
result = a1[1] == a2[1];
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func10(_QWORD *a1, _QWORD *a2)
{
_BOOL8 result; // rax

result = 0LL;
if ( *a1 == *a2 )
result = a1[1] == a2[1];
return result;
}

original_code:
int stat_equal(struct stat *a,struct stat *b)
{
    return a->st_dev == b->st_dev && a->st_ino == b->st_ino;
}

canonical_original_code:
int stat_equal(struct stat *a, struct stat *b)
{
    return a->st_dev == b->st_dev && a->st_ino == b->st_ino;
}

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; } *

variable_types:
b
struct stat *

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


original_code:
unsigned int crc32partial(unsigned char *cp, int nsize,
   unsigned int polynomial, unsigned int *accum)
{
   unsigned int poly, crc;
   int i;
   unsigned char ch;
   crc = ~*accum;
   while (nsize--) {
      ch = *cp++;
      for (i=0; i<8; i++) {
         if ( ( (crc>>31) ^ (ch>>(7-i)) ) & 1) poly = polynomial;
         else poly = 0UL;
         crc = (crc<<1) ^ poly;
      }
   }
   return (*accum = ~crc);
}

canonical_original_code:
unsigned int crc32partial(unsigned char *cp, int nsize, unsigned int polynomial, unsigned int *accum)
{
   unsigned int poly; unsigned int crc;
   int i;
   unsigned char ch;
   crc = ~*accum;
   while (nsize--) {
      ch = *cp++;
      for (i=0; i<8; i++) {
         if ( ( (crc>>31) ^ (ch>>(7-i)) ) & 1) poly = polynomial;
         else poly = 0UL;
         crc = (crc<<1) ^ poly;
      }
   }
   return (*accum = ~crc);
}

variable_types:
cp
unsigned char *

variable_types: nsize int

variable_types:
polynomial
unsigned int

variable_types:
accum
unsigned int *

variable_types:
poly
unsigned int

variable_types:
crc
unsigned int

variable_types: i int

variable_types:
ch
unsigned char

return_type: unsigned int


decompiled_code:
__int64 __fastcall crc32(__int64 a1, unsigned int a2, int a3)
{
int v4; // [rsp+Ch] [rbp-4h] BYREF

v4 = 0;
return crc32partial(a1, a2, a3, &v4);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, unsigned int a2, int a3)
{
int v4; // [rsp+Ch] [rbp-4h] BYREF

v4 = 0;
return func11(a1, a2, a3, &v4);
}

original_code:
unsigned int crc32 (unsigned char *cp, int nsize, unsigned int polynomial)
{
    unsigned int crc = 0;
    return crc32partial(cp, nsize, polynomial, &crc);
}

canonical_original_code:
unsigned int crc32(unsigned char *cp, int nsize, unsigned int polynomial)
{
    unsigned int crc = 0;
    return crc32partial(cp, nsize, polynomial, &crc);
}


decompiled_code:
int __fastcall show_link(const char *a1)
{
int result; // eax
char v2[1032]; // [rsp+0h] [rbp-408h] BYREF

result = readlink(a1, v2, 0x3FFuLL);
if ( result > 0 )
{
v2[result] = 0;
result = printf(" -> %s", v2);
}
return result;
}

canonical_decompiled_code:
int __fastcall func13(const char *a1)
{
int result; // eax
char v2[1032]; // [rsp+0h] [rbp-408h] BYREF

result = readlink(a1, v2, 0x3FFuLL);
if ( result > 0 )
{
v2[result] = 0;
result = printf(" -> %s", v2);
}
return result;
}

original_code:
void show_link(char *name)
{
    int count;
    char lname[1024];
    count = readlink(name, lname, sizeof(lname)-1);
    if (count>0) {
     lname[count] = 0;
     printf(" -> %s", lname);
    }
}

variable_types:
name
char *

variable_types: count int

variable_types:
lname
char [1024]


decompiled_code:
__int64 id_image()
{
cfg_init(&cf_image);
cfg_parse(&cf_image);
do_identify((__int64)"image");
return cfg_init(&cf_identify);
}

canonical_decompiled_code:
__int64 func1()
{
cfg_init(&cf_image);
cfg_parse(&cf_image);
func0((__int64)"image");
return cfg_init(&cf_identify);
}

original_code:
void id_image(void)
{
    cfg_init(cf_image);
    (void) cfg_parse(cf_image);
    do_identify("image",'i');
    cfg_init(cf_identify);
}

canonical_original_code:
void id_image()
{
    cfg_init(cf_image);
    (void) cfg_parse(cf_image);
    do_identify("image",'i');
    cfg_init(cf_identify);
}


decompiled_code:
__int64 id_other()
{
cfg_init(&cf_other);
cfg_init(&cf_kernel);
curr_prt_map = 0;
curr_drv_map = 0;
cfg_parse(&cf_other);
return cfg_init(&cf_identify);
}

canonical_decompiled_code:
__int64 func2()
{
cfg_init(&cf_other);
cfg_init(&cf_kernel);
curr_prt_map = 0;
curr_drv_map = 0;
cfg_parse(&cf_other);
return cfg_init(&cf_identify);
}

original_code:
void id_other(void)
{
    cfg_init(cf_other);
    cfg_init(cf_kernel);
    curr_drv_map = curr_prt_map = 0;
    (void) cfg_parse(cf_other);
    cfg_init(cf_identify);
}

canonical_original_code:
void id_other()
{
    cfg_init(cf_other);
    cfg_init(cf_kernel);
    curr_drv_map = curr_prt_map = 0;
    (void) cfg_parse(cf_other);
    cfg_init(cf_identify);
}


decompiled_code:
void __fastcall identify_image(char *a1, char *a2)
{
char *v2; // rax
const char *v3; // rdi

identify = a1;
opt = a2;
if ( verbose > 1 )
printf("identify_image: id='%s' opt='%s'\n", a1, a2);
v2 = strchr(opt, 68);
idefault = v2 != 0LL;
if ( v2 )
identify = (char *)&unk_611;
cfg_init(&cf_identify);
if ( (unsigned int)cfg_parse(&cf_identify) )
cfg_error("Syntax error");
if ( idefault && first )
{
v3 = (const char *)dflt;
if ( !dflt )
v3 = first;
puts(v3);
exit(0);
}
die("No image found for \"%s\"", a1);
JUMPOUT(0x525LL);
}

canonical_decompiled_code:
void __fastcall func3(char *a1, char *a2)
{
char *v2; // rax
const char *v3; // rdi

identify = a1;
opt = a2;
if ( verbose > 1 )
printf("identify_image: id='%s' opt='%s'\n", a1, a2);
v2 = strchr(opt, 68);
idefault = v2 != 0LL;
if ( v2 )
identify = (char *)&unk_611;
cfg_init(&cf_identify);
if ( (unsigned int)cfg_parse(&cf_identify) )
cfg_error("Syntax error");
if ( idefault && first )
{
v3 = (const char *)dflt;
if ( !dflt )
v3 = first;
puts(v3);
exit(0);
}
die("No image found for \"%s\"", a1);
JUMPOUT(0x525LL);
}

original_code:
void identify_image(char *label,char *options)
{
    identify = label;
    opt = options;
    if (verbose>=2) printf("identify_image: id='%s' opt='%s'\n", label, options);
    idefault = !!strchr(opt,'D');
    if (idefault) identify = "";
    cfg_init(cf_identify);
    if (cfg_parse(cf_identify)) cfg_error("Syntax error");
    if (idefault && first) {
 printf("%s\n", dflt ? dflt : first);
 exit(0);
    }
    die("No image found for \"%s\"",label);
}

canonical_original_code:
void identify_image(char *label, char *options)
{
    identify = label;
    opt = options;
    if (verbose>=2) printf("identify_image: id='%s' opt='%s'\n", label, options);
    idefault = !!strchr(opt,'D');
    if (idefault) identify = "";
    cfg_init(cf_identify);
    if (cfg_parse(cf_identify)) cfg_error("Syntax error");
    if (idefault && first) {
 printf("%s\n", dflt ? dflt : first);
 exit(0);
    }
    die("No image found for \"%s\"",label);
}

variable_types:
label
char *

variable_types:
options
char *


decompiled_code:
void __fastcall cfg_return_token(__int64 a1)
{
last_token = a1;
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1)
{
last_token = a1;
}

original_code:
static void cfg_return_token(char *token)
{
    last_token = token;
}

variable_types:
token
char *


decompiled_code:
void __fastcall cfg_return(__int64 a1, __int64 a2)
{
last_item = a1;
last_value = a2;
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1, __int64 a2)
{
last_item = a1;
last_value = a2;
}

original_code:
static void cfg_return(char *item,char *value)
{
    last_item = item;
    last_value = value;
}

canonical_original_code:
static void cfg_return(char *item, char *value)
{
    last_item = item;
    last_value = value;
}

variable_types:
item
char *

variable_types:
value
char *


again

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

if ( back )
{
die("internal error: again invoked twice");
result = cfg_end("internal error: again invoked twice");
}
else
{
back = a1;
}
return result;
}

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

if ( back )
{
die("internal error: again invoked twice");
result = func3("internal error: again invoked twice");
}
else
{
back = a1;
}
return result;
}

original_code:
static void again(int ch)
{
    if (back) die("internal error: again invoked twice");
    back = ch;
}

variable_types: ch int


decompiled_code:
__int64 __fastcall cfg_end(char *s2)
{
char *v2; // rbx
void **v3; // r12
__int64 result; // rax
const char *v5; // rdi

v2 = (char *)keywords;
v3 = &off_D28;
result = 0LL;
if ( keywords )
{
while ( 1 )
{
v5 = (const char *)*((_QWORD *)v2 + 1);
if ( v5 )
break;
LABEL_5:
v2 = (char *)*v3++;
if ( !v2 )
return 0LL;
}
while ( strcasecmp(v5, s2) )
{
v2 += 40;
v5 = (const char *)*((_QWORD *)v2 + 1);
if ( !v5 )
goto LABEL_5;
}
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *s2)
{
char *v2; // rbx
void **v3; // r12
__int64 result; // rax
const char *v5; // rdi

v2 = (char *)keywords;
v3 = &off_D28;
result = 0LL;
if ( keywords )
{
while ( 1 )
{
v5 = (const char *)*((_QWORD *)v2 + 1);
if ( v5 )
break;
LABEL_5:
v2 = (char *)*v3++;
if ( !v2 )
return 0LL;
}
while ( strcasecmp(v5, s2) )
{
v2 += 40;
v5 = (const char *)*((_QWORD *)v2 + 1);
if ( !v5 )
goto LABEL_5;
}
result = 1LL;
}
return result;
}

original_code:
static int cfg_end (char *item)
{
    CONFIG **key;
    CONFIG *c;
key = keywords;
while ((c = *key++)) {
    while (c->name) {
        if (!strcasecmp(c->name, item)) return 1;
        c++;
    }
}
    return 0;
}

canonical_original_code:
static int cfg_end(char *item)
{
    struct CONFIG **key;
    struct CONFIG *c;
key = keywords;
while ((c = *key++)) {
    while (c->name) {
        if (!strcasecmp(c->name, item)) return 1;
        c++;
    }
}
    return 0;
}

variable_types: struct CONFIG { enum CONFIG_TYPE { cft_strg=0, cft_flag=1, cft_link=2, cft_end=3 } type; char *name; void *action; void *data; void *context; } **

user_defined_types: struct CONFIG { enum CONFIG_TYPE type; char *name; void *action; void *data; void *context; }


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

result = back;
if ( !back )
return getc(file);
back = 0;
return result;
}

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

result = back;
if ( !back )
return getc(file);
back = 0;
return result;
}

original_code:
static int next_raw(void)
{
    int ch;
    if (!back) return getc(file);
    ch = back;
    back = 0;
    return ch;
}

canonical_original_code:
static int next_raw()
{
    int ch;
    if (!back) return getc(file);
    ch = back;
    back = 0;
    return ch;
}


decompiled_code:
int __fastcall cfg_open(char *filename)
{
line_num = 1;
if ( !strcmp(filename, "-") )
{
file = stdin;
}
else
{
file_name = filename;
file = fopen(filename, "r");
if ( !file )
{
die("Cannot open: %s", filename);
cfg_error("Cannot open: %s", (char)filename);
}
}
return fileno(file);
}

canonical_decompiled_code:
int __fastcall func5(char *filename)
{
line_num = 1;
if ( !strcmp(filename, "-") )
{
file = stdin;
}
else
{
file_name = filename;
file = fopen(filename, "r");
if ( !file )
{
die("Cannot open: %s", filename);
func6("Cannot open: %s", (char)filename);
}
}
return fileno(file);
}

original_code:
int cfg_open(char *name)
{
    line_num = 1;
    if (!strcmp(name,"-")) file = stdin;
    else if (!(file = fopen(file_name = name,"r"))) {
  die("Cannot open: %s", name);
    }
    return fileno(file);
}


decompiled_code:
void __noreturn cfg_error(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
fflush(stdout);
vfprintf(errstd, format, arg);
if ( file_name )
fprintf(errstd, " at or above line %d in file '%s'\n", (unsigned int)line_num, file_name);
else
fputc(10, errstd);
exit(1);
}

canonical_decompiled_code:
void __noreturn func6(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
fflush(stdout);
vfprintf(errstd, format, arg);
if ( file_name )
fprintf(errstd, " at or above line %d in file '%s'\n", (unsigned int)line_num, file_name);
else
fputc(10, errstd);
exit(1);
}

original_code:
void __attribute__ ((format (printf, 1, 2))) cfg_error(char *msg,...)
{
    va_list ap;
    fflush(stdout);
    __builtin_va_start(ap,msg);
    vfprintf(errstd,msg,ap);
    __builtin_va_end(ap);
    if (!file_name) fputc('\n',errstd);
    else fprintf(errstd," at or above line %d in file '%s'\n",line_num,file_name);
    exit(1);
}

canonical_original_code:
void cfg_error(char *msg, ...)
{
    __builtin_va_list ap;
    fflush(stdout);
    __builtin_va_start(ap,msg);
    vfprintf(errstd,msg,ap);
    __builtin_va_end(ap);
    if (!file_name) fputc('\n',errstd);
    else fprintf(errstd," at or above line %d in file '%s'\n",line_num,file_name);
    exit(1);
}

variable_types:
msg
char *


decompiled_code:
__int64 __fastcall cfg_do_set(_DWORD *a1, const char *a2, void *a3, int a4, __int64 a5)
{
_DWORD *v5; // rbx
int v8; // ebp
__int64 result; // rax
__int64 v10; // rax
void (*v11)(void); // rax
const char *v12; // r12
__int64 v13; // rax

v5 = a1;
v8 = *a1;
if ( *a1 == 3 )
{
LABEL_2:
cfg_return((__int64)a2, (__int64)a3);
return 0LL;
}
while ( 1 )
{
v12 = (const char *)*((_QWORD *)v5 + 1);
if ( v12 )
{
if ( !strcasecmp(*((const char **)v5 + 1), a2) )
break;
}
v13 = (__int64)v5;
if ( v8 == 2 )
v13 = *((_QWORD *)v5 + 2) - 40LL;
v5 = (_DWORD *)(v13 + 40);
v8 = *(_DWORD *)(v13 + 40);
if ( v8 == 3 )
goto LABEL_2;
}
if ( v8 && a3 )
cfg_error("'%s' doesn't have a value", v12);
if ( !v8 && !a3 )
cfg_error("Value expected for '%s'", v12);
if ( *((_QWORD *)v5 + 3) )
{
if ( *((_QWORD *)v5 + 4) == a5 )
cfg_error("Duplicate entry '%s'", v12);
warn("Ignoring entry '%s'", v12);
result = 1LL;
if ( !a4 )
{
free(a3);
result = 1LL;
}
}
else
{
if ( v8 == 1 )
{
*((_QWORD *)v5 + 3) = &flag_set;
}
else if ( !v8 )
{
v10 = (__int64)a3;
if ( a4 )
v10 = stralloc(a3);
*((_QWORD *)v5 + 3) = v10;
}
*((_QWORD *)v5 + 4) = a5;
v11 = (void (*)(void))*((_QWORD *)v5 + 2);
if ( v11 )
v11();
if ( *v5 == 3 )
goto LABEL_2;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(_DWORD *a1, const char *a2, void *a3, int a4, __int64 a5)
{
_DWORD *v5; // rbx
int v8; // ebp
__int64 result; // rax
__int64 v10; // rax
void (*v11)(void); // rax
const char *v12; // r12
__int64 v13; // rax

v5 = a1;
v8 = *a1;
if ( *a1 == 3 )
{
LABEL_2:
func1((__int64)a2, (__int64)a3);
return 0LL;
}
while ( 1 )
{
v12 = (const char *)*((_QWORD *)v5 + 1);
if ( v12 )
{
if ( !strcasecmp(*((const char **)v5 + 1), a2) )
break;
}
v13 = (__int64)v5;
if ( v8 == 2 )
v13 = *((_QWORD *)v5 + 2) - 40LL;
v5 = (_DWORD *)(v13 + 40);
v8 = *(_DWORD *)(v13 + 40);
if ( v8 == 3 )
goto LABEL_2;
}
if ( v8 && a3 )
func6("'%s' doesn't have a value", v12);
if ( !v8 && !a3 )
func6("Value expected for '%s'", v12);
if ( *((_QWORD *)v5 + 3) )
{
if ( *((_QWORD *)v5 + 4) == a5 )
func6("Duplicate entry '%s'", v12);
warn("Ignoring entry '%s'", v12);
result = 1LL;
if ( !a4 )
{
free(a3);
result = 1LL;
}
}
else
{
if ( v8 == 1 )
{
*((_QWORD *)v5 + 3) = &flag_set;
}
else if ( !v8 )
{
v10 = (__int64)a3;
if ( a4 )
v10 = stralloc(a3);
*((_QWORD *)v5 + 3) = v10;
}
*((_QWORD *)v5 + 4) = a5;
v11 = (void (*)(void))*((_QWORD *)v5 + 2);
if ( v11 )
v11();
if ( *v5 == 3 )
goto LABEL_2;
result = 1LL;
}
return result;
}

original_code:
static int cfg_do_set(CONFIG *table,char *item,char *value,int copy,
    void *context)
{
    CONFIG *walk;
    for (walk = table; walk->type != cft_end; walk++) {
 if (walk->name && !strcasecmp(walk->name,item)) {
     if (value && walk->type != cft_strg)
  cfg_error("'%s' doesn't have a value",walk->name);
     if (!value && walk->type == cft_strg)
  cfg_error("Value expected for '%s'",walk->name);
     if (walk->data) {
  if (walk->context == context)
      cfg_error("Duplicate entry '%s'",walk->name);
  else {
      warn("Ignoring entry '%s'",walk->name);
      if (!copy) free(value);
      return 1;
  }
     }
     if (walk->type == cft_flag) walk->data = &flag_set;
     else if (walk->type == cft_strg)
      walk->data = copy ? stralloc(value) : value;
     walk->context = context;
     if (walk->action) ((void (*)(void)) walk->action)();
     break;
 }
 if (walk->type == cft_link) walk = ((CONFIG *) walk->action)-1;
    }
    if (walk->type != cft_end) return 1;
    cfg_return(item,value);
    return 0;
}

canonical_original_code:
static int cfg_do_set(struct CONFIG *table, char *item, char *value, int copy, void *context)
{
    struct CONFIG *walk;
    for (walk = table; walk->type != cft_end; walk++) {
 if (walk->name && !strcasecmp(walk->name,item)) {
     if (value && walk->type != cft_strg)
  cfg_error("'%s' doesn't have a value",walk->name);
     if (!value && walk->type == cft_strg)
  cfg_error("Value expected for '%s'",walk->name);
     if (walk->data) {
  if (walk->context == context)
      cfg_error("Duplicate entry '%s'",walk->name);
  else {
      warn("Ignoring entry '%s'",walk->name);
      if (!copy) free(value);
      return 1;
  }
     }
     if (walk->type == cft_flag) walk->data = &flag_set;
     else if (walk->type == cft_strg)
      walk->data = copy ? stralloc(value) : value;
     walk->context = context;
     if (walk->action) ((void (*)()) walk->action)();
     break;
 }
 if (walk->type == cft_link) walk = ((struct CONFIG *) walk->action)-1;
    }
    if (walk->type != cft_end) return 1;
    cfg_return(item,value);
    return 0;
}

variable_types: struct CONFIG { enum CONFIG_TYPE { cft_strg=0, cft_flag=1, cft_link=2, cft_end=3 } type; char *name; void *action; void *data; void *context; } *

variable_types: copy int

variable_types:
context
void *


next

decompiled_code:
__int64 next()
{
unsigned int v0; // ebx
int v1; // eax
int v2; // er12
char *v3; // rbp
bool v4; // r14
int v6; // eax
int v7; // eax
int v8; // ebx
char v9; // [rsp+0h] [rbp-428h] BYREF
char v10; // [rsp+1h] [rbp-427h] BYREF

v0 = back;
if ( back )
{
back = 0;
}
else if ( var_0 && (LOBYTE(v0) = *(_BYTE *)var_0) != 0 )
{
++var_0;
v0 = (char)v0;
}
else
{
v0 = getc(file);
if ( v0 == 13 )
v0 = getc(file);
if ( v0 == 92 )
{
v6 = getc(file);
if ( v6 == 36 )
v0 = 36;
else
ungetc(v6, file);
}
else if ( v0 == 36 )
{
v1 = getc(file);
v2 = v1;
v3 = &v9;
v4 = v1 == 123;
if ( v1 != 123 )
{
v9 = v1;
v3 = &v10;
}
while ( 1 )
{
v7 = getc(file);
v8 = v7;
if ( v7 == -1 )
cfg_error("EOF in variable name");
if ( v7 <= 31 )
cfg_error("control character in variable name");
if ( v7 == 125 && v4 )
break;
if ( v2 != 123 && ((*_ctype_b_loc())[v7] & 0xC00) == 0 && v8 != 95 )
{
ungetc(v8, file);
break;
}
if ( v3 - &v9 == 1023 )
cfg_error("variable name too long");
*v3++ = v8;
}
*v3 = 0;
var_0 = (__int64)getenv(&v9);
if ( !var_0 )
cfg_error("unknown variable \"%s\"", &v9);
v0 = next(&v9);
}
}
return v0;
}

canonical_decompiled_code:
__int64 func8()
{
unsigned int v0; // ebx
int v1; // eax
int v2; // er12
char *v3; // rbp
bool v4; // r14
int v6; // eax
int v7; // eax
int v8; // ebx
char v9; // [rsp+0h] [rbp-428h] BYREF
char v10; // [rsp+1h] [rbp-427h] BYREF

v0 = back;
if ( back )
{
back = 0;
}
else if ( var_0 && (LOBYTE(v0) = *(_BYTE *)var_0) != 0 )
{
++var_0;
v0 = (char)v0;
}
else
{
v0 = getc(file);
if ( v0 == 13 )
v0 = getc(file);
if ( v0 == 92 )
{
v6 = getc(file);
if ( v6 == 36 )
v0 = 36;
else
ungetc(v6, file);
}
else if ( v0 == 36 )
{
v1 = getc(file);
v2 = v1;
v3 = &v9;
v4 = v1 == 123;
if ( v1 != 123 )
{
v9 = v1;
v3 = &v10;
}
while ( 1 )
{
v7 = getc(file);
v8 = v7;
if ( v7 == -1 )
func6("EOF in variable name");
if ( v7 <= 31 )
func6("control character in variable name");
if ( v7 == 125 && v4 )
break;
if ( v2 != 123 && ((*_ctype_b_loc())[v7] & 0xC00) == 0 && v8 != 95 )
{
ungetc(v8, file);
break;
}
if ( v3 - &v9 == 1023 )
func6("variable name too long");
*v3++ = v8;
}
*v3 = 0;
var_0 = (__int64)getenv(&v9);
if ( !var_0 )
func6("unknown variable \"%s\"", &v9);
v0 = func8(&v9);
}
}
return v0;
}

original_code:
static int next(void)
{
    static char *var;
    char buffer[1023 +1];
    int ch,braced;
    char *put;
    if (back) {
 ch = back;
 back = 0;
 return ch;
    }
    if (var && *var) return *var++;
    ch = getc(file);
    if (ch == '\r')
        ch = getc(file);
    if (ch == '\\') {
 ch = getc(file);
 if (ch == '$') return ch;
 ungetc(ch,file);
 return '\\';
    }
    if (ch != '$') return ch;
    ch = getc(file);
    braced = ch == '{';
    put = buffer;
    if (!braced) *put++ = ch;
    while (1) {
 ch = getc(file);
 if (ch == (-1)) cfg_error("EOF in variable name");
 if (ch < ' ') cfg_error("control character in variable name");
 if (braced && ch == '}') break;
 if (!braced && !((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISalpha) && !((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISdigit) && ch != '_') {
     ungetc(ch,file);
     break;
 }
 if (put-buffer == 1023) cfg_error("variable name too long");
 *put++ = ch;
    }
    *put = 0;
    if (!(var = getenv(buffer))) cfg_error("unknown variable \"%s\"",buffer);
    return next();
}

canonical_original_code:
static int next()
{
    static char *var;
    char buffer[-1];
    int ch; int braced;
    char *put;
    if (back) {
 ch = back;
 back = 0;
 return ch;
    }
    if (var && *var) return *var++;
    ch = getc(file);
    if (ch == '\r')
        ch = getc(file);
    if (ch == '\\') {
 ch = getc(file);
 if (ch == '$') return ch;
 ungetc(ch,file);
 return '\\';
    }
    if (ch != '$') return ch;
    ch = getc(file);
    braced = ch == '{';
    put = buffer;
    if (!braced) *put++ = ch;
    while (1) {
 ch = getc(file);
 if (ch == (-1)) cfg_error("EOF in variable name");
 if (ch < ' ') cfg_error("control character in variable name");
 if (braced && ch == '}') break;
 if (!braced && !((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISalpha) && !((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short) _ISdigit) && ch != '_') {
     ungetc(ch,file);
     break;
 }
 if (put-buffer == 1023) cfg_error("variable name too long");
 *put++ = ch;
    }
    *put = 0;
    if (!(var = getenv(buffer))) cfg_error("unknown variable \"%s\"",buffer);
    return next();
}

variable_types:
var
char *

variable_types:
buffer
char [-1]

variable_types: braced int

variable_types:
put
char *


decompiled_code:
__int64 cfg_get_token()
{
__int64 v0; // rbx
int v2; // eax
int v3; // eax
_BOOL4 v4; // ebp
_BYTE *v5; // rbx
__int64 v6; // r12
int v7; // eax
int v8; // eax
unsigned __int64 v9; // rdx
_BYTE v10[1048]; // [rsp+0h] [rbp-418h] BYREF

v0 = last_token;
if ( !last_token )
{
while ( 1 )
{
while ( 1 )
{
v2 = next();
if ( (unsigned int)(v2 - 9) > 1 && v2 != 32 )
break;
if ( v2 == 10 )
++line_num;
}
if ( v2 == -1 )
return v0;
if ( v2 != 35 )
break;
while ( 1 )
{
v3 = next_raw();
if ( v3 == 10 )
break;
if ( v3 == -1 )
return v0;
}
++line_num;
}
if ( v2 == 61 )
return stralloc("=");
v4 = 0;
v5 = v10;
v6 = 0x4000001200000C01LL;
if ( v2 == 34 )
{
while ( 1 )
{
v7 = next();
if ( v7 == -1 )
cfg_error("EOF in quoted string");
if ( v7 == 34 )
{
*v5 = 0;
return stralloc(v10);
}
if ( v7 != 92 )
break;
v7 = next();
if ( v7 != 92 && v7 != 34 && v7 != 10 )
cfg_error("Bad use of \\ in quoted string");
if ( v7 != 10 )
break;
do
{
do
v8 = next();
while ( v8 == 32 );
}
while ( v8 == 9 );
if ( v8 )
{
again(v8);
LOBYTE(v7) = 32;
LABEL_22:
*v5++ = v7;
}
if ( v5 - v10 > 1022 )
cfg_error("Quoted string is too long");
}
if ( (unsigned int)(v7 - 9) <= 1 )
cfg_error("\\n and \\t are not allowed in quoted strings");
goto LABEL_22;
}
while ( 1 )
{
if ( v4 )
{
if ( v2 == -1 )
cfg_error("\\ precedes EOF");
if ( v2 == 10 )
{
++line_num;
v4 = 0;
}
else
{
if ( v2 == 9 )
LOBYTE(v2) = 32;
*v5++ = v2;
v4 = 0;
}
}
else
{
v9 = (unsigned int)(v2 + 1);
if ( (unsigned int)v9 > 0x3E )
{
v4 = v2 == 92;
if ( v2 == 92 )
goto LABEL_42;
}
else
{
if ( _bittest64(&v6, v9) )
{
again(v2);
*v5 = 0;
return stralloc(v10);
}
v4 = v2 == 92;
}
*v5++ = v2;
}
LABEL_42:
v2 = next();
if ( v5 - v10 > 1022 )
cfg_error("Token is too long");
}
}
last_token = 0LL;
return v0;
}

canonical_decompiled_code:
__int64 func9()
{
__int64 v0; // rbx
int v2; // eax
int v3; // eax
_BOOL4 v4; // ebp
_BYTE *v5; // rbx
__int64 v6; // r12
int v7; // eax
int v8; // eax
unsigned __int64 v9; // rdx
_BYTE v10[1048]; // [rsp+0h] [rbp-418h] BYREF

v0 = last_token;
if ( !last_token )
{
while ( 1 )
{
while ( 1 )
{
v2 = func8();
if ( (unsigned int)(v2 - 9) > 1 && v2 != 32 )
break;
if ( v2 == 10 )
++line_num;
}
if ( v2 == -1 )
return v0;
if ( v2 != 35 )
break;
while ( 1 )
{
v3 = func4();
if ( v3 == 10 )
break;
if ( v3 == -1 )
return v0;
}
++line_num;
}
if ( v2 == 61 )
return stralloc("=");
v4 = 0;
v5 = v10;
v6 = 0x4000001200000C01LL;
if ( v2 == 34 )
{
while ( 1 )
{
v7 = func8();
if ( v7 == -1 )
func6("EOF in quoted string");
if ( v7 == 34 )
{
*v5 = 0;
return stralloc(v10);
}
if ( v7 != 92 )
break;
v7 = func8();
if ( v7 != 92 && v7 != 34 && v7 != 10 )
func6("Bad use of \\ in quoted string");
if ( v7 != 10 )
break;
do
{
do
v8 = func8();
while ( v8 == 32 );
}
while ( v8 == 9 );
if ( v8 )
{
func2(v8);
LOBYTE(v7) = 32;
LABEL_22:
*v5++ = v7;
}
if ( v5 - v10 > 1022 )
func6("Quoted string is too long");
}
if ( (unsigned int)(v7 - 9) <= 1 )
func6("\\n and \\t are not allowed in quoted strings");
goto LABEL_22;
}
while ( 1 )
{
if ( v4 )
{
if ( v2 == -1 )
func6("\\ precedes EOF");
if ( v2 == 10 )
{
++line_num;
v4 = 0;
}
else
{
if ( v2 == 9 )
LOBYTE(v2) = 32;
*v5++ = v2;
v4 = 0;
}
}
else
{
v9 = (unsigned int)(v2 + 1);
if ( (unsigned int)v9 > 0x3E )
{
v4 = v2 == 92;
if ( v2 == 92 )
goto LABEL_42;
}
else
{
if ( _bittest64(&v6, v9) )
{
func2(v2);
*v5 = 0;
return stralloc(v10);
}
v4 = v2 == 92;
}
*v5++ = v2;
}
LABEL_42:
v2 = func8();
if ( v5 - v10 > 1022 )
func6("Token is too long");
}
}
last_token = 0LL;
return v0;
}

original_code:
static char *cfg_get_token(void)
{
    char buf[1023 +1];
    char *here;
    int ch,escaped;
    if (last_token) {
 here = last_token;
 last_token = ((void *)0);
 return here;
    }
    while (1) {
 while ((ch = next()), ch == ' ' || ch == '\t' || ch == '\n')
     if (ch == '\n') line_num++;
 if (ch == (-1)) return ((void *)0);
 if (ch != '#') break;
 while ((ch = next_raw()), ch != '\n')
     if (ch == (-1)) return ((void *)0);
 line_num++;
    }
    if (ch == '=') return stralloc("=");
    if (ch == '"') {
 here = buf;
 while (here-buf < 1023) {
     if ((ch = next()) == (-1)) cfg_error("EOF in quoted string");
     if (ch == '"') {
  *here = 0;
  return stralloc(buf);
     }
     if (ch == '\\') {
  ch = next();
  if (ch != '"' && ch != '\\' && ch != '\n')
      cfg_error("Bad use of \\ in quoted string");
  if (ch == '\n') {
      while ((ch = next()), ch == ' ' || ch == '\t');
      if (!ch) continue;
      again(ch);
      ch = ' ';
  }
     }
     if (ch == '\n' || ch == '\t')
  cfg_error("\\n and \\t are not allowed in quoted strings");
     *here++ = ch;
 }
 cfg_error("Quoted string is too long");
 return 0;
    }
    here = buf;
    escaped = 0;
    while (here-buf < 1023) {
 if (escaped) {
     if (ch == (-1)) cfg_error("\\ precedes EOF");
     if (ch == '\n') line_num++;
     else *here++ = ch == '\t' ? ' ' : ch;
     escaped = 0;
 }
 else {
     if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '#' ||
       ch == '=' || ch == (-1)) {
  again(ch);
  *here = 0;
  return stralloc(buf);
     }
     if (!(escaped = (ch == '\\')))
  *here++ = ch;
 }
 ch = next();
    }
    cfg_error("Token is too long");
    return 0;
}

canonical_original_code:
static char *cfg_get_token()
{
    char buf[-1];
    char *here;
    int ch; int escaped;
    if (last_token) {
 here = last_token;
 last_token = ((void *)0);
 return here;
    }
    while (1) {
 while ((ch = next()), ch == ' ' || ch == '\t' || ch == '\n')
     if (ch == '\n') line_num++;
 if (ch == (-1)) return ((void *)0);
 if (ch != '#') break;
 while ((ch = next_raw()), ch != '\n')
     if (ch == (-1)) return ((void *)0);
 line_num++;
    }
    if (ch == '=') return stralloc("=");
    if (ch == '"') {
 here = buf;
 while (here-buf < 1023) {
     if ((ch = next()) == (-1)) cfg_error("EOF in quoted string");
     if (ch == '"') {
  *here = 0;
  return stralloc(buf);
     }
     if (ch == '\\') {
  ch = next();
  if (ch != '"' && ch != '\\' && ch != '\n')
      cfg_error("Bad use of \\ in quoted string");
  if (ch == '\n') {
      while ((ch = next()), ch == ' ' || ch == '\t');
      if (!ch) continue;
      again(ch);
      ch = ' ';
  }
     }
     if (ch == '\n' || ch == '\t')
  cfg_error("\\n and \\t are not allowed in quoted strings");
     *here++ = ch;
 }
 cfg_error("Quoted string is too long");
 return 0;
    }
    here = buf;
    escaped = 0;
    while (here-buf < 1023) {
 if (escaped) {
     if (ch == (-1)) cfg_error("\\ precedes EOF");
     if (ch == '\n') line_num++;
     else *here++ = ch == '\t' ? ' ' : ch;
     escaped = 0;
 }
 else {
     if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '#' ||
       ch == '=' || ch == (-1)) {
  again(ch);
  *here = 0;
  return stralloc(buf);
     }
     if (!(escaped = (ch == '\\')))
  *here++ = ch;
 }
 ch = next();
    }
    cfg_error("Token is too long");
    return 0;
}

variable_types:
buf
char [-1]

variable_types:
here
char *

variable_types: escaped int


decompiled_code:
__int64 __fastcall cfg_next(const char **a1, const char **a2)
{
__int64 result; // rax
const char *v5; // rsi
bool v6; // cf
bool v7; // zf
const char *v8; // rdi
__int64 v9; // rcx
__int64 v10; // rax
bool v11; // cf
bool v12; // zf
const char *v13; // rdi
__int64 v14; // rcx
const char *v15; // rsi
const char *v16; // rsi

if ( last_item )
{
*a1 = (const char *)last_item;
*a2 = (const char *)last_value;
last_item = 0LL;
result = 1LL;
}
else
{
*a2 = 0LL;
v5 = (const char *)((__int64 (*)(void))cfg_get_token)();
*a1 = v5;
v6 = 0;
v7 = v5 == 0LL;
if ( v5 )
{
v8 = "=";
v9 = 2LL;
do
{
if ( !v9 )
break;
v6 = *v5 < (unsigned int)*v8;
v7 = *v5++ == *v8++;
--v9;
}
while ( v7 );
if ( (!v6 && !v7) == v6 )
cfg_error("Syntax error", v5);
v10 = cfg_get_token(v8, v5);
v11 = 0;
v12 = v10 == 0;
if ( v10 )
{
v13 = "=";
v14 = 2LL;
v15 = (const char *)v10;
do
{
if ( !v14 )
break;
v11 = *v15 < (unsigned int)*v13;
v12 = *v15++ == *v13++;
--v14;
}
while ( v12 );
if ( (!v11 && !v12) == v11 )
{
v16 = (const char *)cfg_get_token(v13, v15);
*a2 = v16;
if ( !v16 )
cfg_error("Value expected at EOF");
if ( !strcmp(v16, "=") )
cfg_error("Syntax error after %s", *a1);
result = 1LL;
}
else
{
cfg_return_token(v10);
result = 1LL;
}
}
else
{
result = 1LL;
}
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(const char **a1, const char **a2)
{
__int64 result; // rax
const char *v5; // rsi
bool v6; // cf
bool v7; // zf
const char *v8; // rdi
__int64 v9; // rcx
__int64 v10; // rax
bool v11; // cf
bool v12; // zf
const char *v13; // rdi
__int64 v14; // rcx
const char *v15; // rsi
const char *v16; // rsi

if ( last_item )
{
*a1 = (const char *)last_item;
*a2 = (const char *)last_value;
last_item = 0LL;
result = 1LL;
}
else
{
*a2 = 0LL;
v5 = (const char *)((__int64 (*)(void))cfg_get_token)();
*a1 = v5;
v6 = 0;
v7 = v5 == 0LL;
if ( v5 )
{
v8 = "=";
v9 = 2LL;
do
{
if ( !v9 )
break;
v6 = *v5 < (unsigned int)*v8;
v7 = *v5++ == *v8++;
--v9;
}
while ( v7 );
if ( (!v6 && !v7) == v6 )
func6("Syntax error", v5);
v10 = func9(v8, v5);
v11 = 0;
v12 = v10 == 0;
if ( v10 )
{
v13 = "=";
v14 = 2LL;
v15 = (const char *)v10;
do
{
if ( !v14 )
break;
v11 = *v15 < (unsigned int)*v13;
v12 = *v15++ == *v13++;
--v14;
}
while ( v12 );
if ( (!v11 && !v12) == v11 )
{
v16 = (const char *)func9(v13, v15);
*a2 = v16;
if ( !v16 )
func6("Value expected at EOF");
if ( !strcmp(v16, "=") )
func6("Syntax error after %s", *a1);
result = 1LL;
}
else
{
func0(v10);
result = 1LL;
}
}
else
{
result = 1LL;
}
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
static int cfg_next(char **item,char **value)
{
    char *this;
    if (last_item) {
 *item = last_item;
 *value = last_value;
 last_item = ((void *)0);
 return 1;
    }
    *value = ((void *)0);
    if (!(*item = cfg_get_token())) return 0;
    if (!strcmp(*item,"=")) cfg_error("Syntax error");
    if (!(this = cfg_get_token())) return 1;
    if (strcmp(this,"=")) {
 cfg_return_token(this);
 return 1;
    }
    if (!(*value = cfg_get_token())) cfg_error("Value expected at EOF");
    if (!strcmp(*value,"=")) cfg_error("Syntax error after %s",*item);
    return 1;
}

canonical_original_code:
static int cfg_next(char **item, char **value)
{
    char *this;
    if (last_item) {
 *item = last_item;
 *value = last_value;
 last_item = ((void *)0);
 return 1;
    }
    *value = ((void *)0);
    if (!(*item = cfg_get_token())) return 0;
    if (!strcmp(*item,"=")) cfg_error("Syntax error");
    if (!(this = cfg_get_token())) return 1;
    if (strcmp(this,"=")) {
 cfg_return_token(this);
 return 1;
    }
    if (!(*value = cfg_get_token())) cfg_error("Value expected at EOF");
    if (!strcmp(*value,"=")) cfg_error("Syntax error after %s",*item);
    return 1;
}

variable_types:
item
char **

variable_types:
value
char **

variable_types:
this
char *


decompiled_code:
void __fastcall cfg_init(unsigned int *a1)
{
unsigned int *v1; // rbx
__int64 i; // rsi
void *v3; // rdi
__int64 v4; // rax

v1 = a1;
for ( i = *a1; (_DWORD)i != 3; i = *(unsigned int *)(v4 + 40) )
{
if ( (_DWORD)i != 1 )
{
if ( (_DWORD)i == 2 )
goto LABEL_11;
if ( (_DWORD)i )
{
die("Unknown syntax code %d", i);
LABEL_11:
v4 = *((_QWORD *)v1 + 2) - 40LL;
goto LABEL_6;
}
v3 = (void *)*((_QWORD *)v1 + 3);
if ( v3 )
free(v3);
}
*((_QWORD *)v1 + 3) = 0LL;
v4 = (__int64)v1;
LABEL_6:
v1 = (unsigned int *)(v4 + 40);
}
}

canonical_decompiled_code:
void __fastcall func11(unsigned int *a1)
{
unsigned int *v1; // rbx
__int64 i; // rsi
void *v3; // rdi
__int64 v4; // rax

v1 = a1;
for ( i = *a1; (_DWORD)i != 3; i = *(unsigned int *)(v4 + 40) )
{
if ( (_DWORD)i != 1 )
{
if ( (_DWORD)i == 2 )
goto LABEL_11;
if ( (_DWORD)i )
{
die("Unknown syntax code %d", i);
LABEL_11:
v4 = *((_QWORD *)v1 + 2) - 40LL;
goto LABEL_6;
}
v3 = (void *)*((_QWORD *)v1 + 3);
if ( v3 )
free(v3);
}
*((_QWORD *)v1 + 3) = 0LL;
v4 = (__int64)v1;
LABEL_6:
v1 = (unsigned int *)(v4 + 40);
}
}

original_code:
void cfg_init(CONFIG *table)
{
    while (table->type != cft_end) {
 switch (table->type) {
     case cft_strg:
  if (table->data) free(table->data);
     case cft_flag:
  table->data = ((void *)0);
  break;
     case cft_link:
  table = ((CONFIG *) table->action)-1;
  break;
     default:
  die("Unknown syntax code %d",table->type);
 }
 table++;
    }
}

canonical_original_code:
void cfg_init(struct CONFIG *table)
{
    while (table->type != cft_end) {
 switch (table->type) {
     case cft_strg:
  if (table->data) free(table->data);
     case cft_flag:
  table->data = ((void *)0);
  break;
     case cft_link:
  table = ((struct CONFIG *) table->action)-1;
  break;
     default:
  die("Unknown syntax code %d",table->type);
 }
 table++;
    }
}

user_defined_types: enum CONFIG_TYPE { cft_strg=0, cft_flag=1, cft_link=2, cft_end=3 }


decompiled_code:
__int64 __fastcall cfg_set(_DWORD *a1, const char *a2, void *a3, __int64 a4)
{
__int64 result; // rax

result = cfg_do_set(a1, a2, a3, 1, a4);
if ( (_DWORD)result != 1 )
cfg_error("cfg_set: Can't set %s", a2);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(_DWORD *a1, const char *a2, void *a3, __int64 a4)
{
__int64 result; // rax

result = func7(a1, a2, a3, 1, a4);
if ( (_DWORD)result != 1 )
func6("cfg_set: Can't set %s", a2);
return result;
}

original_code:
void cfg_set(CONFIG *table,char *item,char *value,void *context)
{
    if (cfg_do_set(table,item,value,1,context) != 1)
 cfg_error("cfg_set: Can't set %s",item);
}

canonical_original_code:
void cfg_set(struct CONFIG *table, char *item, char *value, void *context)
{
    if (cfg_do_set(table,item,value,1,context) != 1)
 cfg_error("cfg_set: Can't set %s",item);
}

variable_types:
item
char *

variable_types:
value
char *


decompiled_code:
void __fastcall cfg_unset(_DWORD *a1, const char *a2)
{
_DWORD *v2; // rbx
int v3; // ebp
char *v4; // rdi
const char *v5; // rdi

v2 = a1;
v3 = *a1;
if ( *a1 == 3 )
{
LABEL_2:
die("internal error (cfg_unset %s, unknown", a2);
}
else
{
while ( 1 )
{
v5 = (const char *)*((_QWORD *)v2 + 1);
if ( v5 )
{
if ( !strcasecmp(v5, a2) )
break;
}
v2 += 10;
v3 = *v2;
if ( *v2 == 3 )
goto LABEL_2;
}
v4 = (char *)*((_QWORD *)v2 + 3);
if ( v4 )
{
if ( v3 )
goto LABEL_10;
goto LABEL_4;
}
}
v4 = "internal error (cfg_unset %s, unset)";
die("internal error (cfg_unset %s, unset)", a2);
LABEL_4:
free(v4);
LABEL_10:
*((_QWORD *)v2 + 3) = 0LL;
}

canonical_decompiled_code:
void __fastcall func13(_DWORD *a1, const char *a2)
{
_DWORD *v2; // rbx
int v3; // ebp
char *v4; // rdi
const char *v5; // rdi

v2 = a1;
v3 = *a1;
if ( *a1 == 3 )
{
LABEL_2:
die("internal error (cfg_unset %s, unknown", a2);
}
else
{
while ( 1 )
{
v5 = (const char *)*((_QWORD *)v2 + 1);
if ( v5 )
{
if ( !strcasecmp(v5, a2) )
break;
}
v2 += 10;
v3 = *v2;
if ( *v2 == 3 )
goto LABEL_2;
}
v4 = (char *)*((_QWORD *)v2 + 3);
if ( v4 )
{
if ( v3 )
goto LABEL_10;
goto LABEL_4;
}
}
v4 = "internal error (cfg_unset %s, unset)";
die("internal error (cfg_unset %s, unset)", a2);
LABEL_4:
free(v4);
LABEL_10:
*((_QWORD *)v2 + 3) = 0LL;
}

original_code:
void cfg_unset(CONFIG *table,char *item)
{
    CONFIG *walk;
    for (walk = table; walk->type != cft_end; walk++)
 if (walk->name && !strcasecmp(walk->name,item)) {
     if (!walk->data) die("internal error (cfg_unset %s, unset)",item);
     if (walk->type == cft_strg) free(walk->data);
     walk->data = ((void *)0);
     return;
 }
    die("internal error (cfg_unset %s, unknown",item);
}

canonical_original_code:
void cfg_unset(struct CONFIG *table, char *item)
{
    struct CONFIG *walk;
    for (walk = table; walk->type != cft_end; walk++)
 if (walk->name && !strcasecmp(walk->name,item)) {
     if (!walk->data) die("internal error (cfg_unset %s, unset)",item);
     if (walk->type == cft_strg) free(walk->data);
     walk->data = ((void *)0);
     return;
 }
    die("internal error (cfg_unset %s, unknown",item);
}


decompiled_code:
__int64 __fastcall cfg_parse(_DWORD *a1)
{
__int64 result; // rax
const char *v2; // rbx
char *v3; // [rsp+0h] [rbp-18h] BYREF
void *ptr; // [rsp+8h] [rbp-10h] BYREF

while ( 1 )
{
result = cfg_next((const char **)&ptr, (const char **)&v3);
if ( !(_DWORD)result )
break;
if ( verbose > 5 )
printf("cfg_parse: item=\"%s\" value=\"%s\"\n", (const char *)ptr, v3);
if ( !(unsigned int)cfg_do_set(a1, (const char *)ptr, v3, 0, (__int64)a1) )
{
v2 = (const char *)ptr;
if ( !(unsigned int)cfg_end((char *)ptr) )
cfg_error("Unrecognized token \"%s\"", v2);
return 1LL;
}
free(ptr);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(_DWORD *a1)
{
__int64 result; // rax
const char *v2; // rbx
char *v3; // [rsp+0h] [rbp-18h] BYREF
void *ptr; // [rsp+8h] [rbp-10h] BYREF

while ( 1 )
{
result = func10((const char **)&ptr, (const char **)&v3);
if ( !(_DWORD)result )
break;
if ( verbose > 5 )
printf("cfg_parse: item=\"%s\" value=\"%s\"\n", (const char *)ptr, v3);
if ( !(unsigned int)func7(a1, (const char *)ptr, v3, 0, (__int64)a1) )
{
v2 = (const char *)ptr;
if ( !(unsigned int)func3((char *)ptr) )
func6("Unrecognized token \"%s\"", v2);
return 1LL;
}
free(ptr);
}
return result;
}

original_code:
int cfg_parse(CONFIG *table)
{
    char *item,*value;
    while (1) {
 if (!cfg_next(&item,&value)) return 0;
if(verbose>=6) printf("cfg_parse:  item=\"%s\" value=\"%s\"\n", item, value);
 if (!cfg_do_set(table,item,value,0,table)) {
     if (cfg_end(item)) return 1;
     else cfg_error("Unrecognized token \"%s\"", item);
 }
 free(item);
    }
}

canonical_original_code:
int cfg_parse(struct CONFIG *table)
{
    char *item; char *value;
    while (1) {
 if (!cfg_next(&item,&value)) return 0;
if(verbose>=6) printf("cfg_parse:  item=\"%s\" value=\"%s\"\n", item, value);
 if (!cfg_do_set(table,item,value,0,table)) {
     if (cfg_end(item)) return 1;
     else cfg_error("Unrecognized token \"%s\"", item);
 }
 free(item);
    }
}


decompiled_code:
_BOOL8 __fastcall cfg_get_flag(_DWORD *a1, const char *a2)
{
_QWORD *v2; // rbx
int v3; // ebp
__int64 v5; // rax
const char *v6; // rdi

v2 = a1;
v3 = *a1;
if ( *a1 != 3 )
goto LABEL_7;
while ( 1 )
{
die("cfg_get_flag: unknown item %s", a2);
LABEL_3:
if ( v3 == 1 )
return v2[3] != 0LL;
v5 = die("cfg_get_flag: operating on non-flag %s", a2);
while ( 1 )
{
v2 = (_QWORD *)(v5 + 40);
v3 = *(_DWORD *)(v5 + 40);
if ( v3 == 3 )
break;
LABEL_7:
v6 = (const char *)v2[1];
if ( v6 && !strcasecmp(v6, a2) )
goto LABEL_3;
v5 = (__int64)v2;
if ( v3 == 2 )
v5 = v2[2] - 40LL;
}
}
}

canonical_decompiled_code:
_BOOL8 __fastcall func15(_DWORD *a1, const char *a2)
{
_QWORD *v2; // rbx
int v3; // ebp
__int64 v5; // rax
const char *v6; // rdi

v2 = a1;
v3 = *a1;
if ( *a1 != 3 )
goto LABEL_7;
while ( 1 )
{
die("cfg_get_flag: unknown item %s", a2);
LABEL_3:
if ( v3 == 1 )
return v2[3] != 0LL;
v5 = die("cfg_get_flag: operating on non-flag %s", a2);
while ( 1 )
{
v2 = (_QWORD *)(v5 + 40);
v3 = *(_DWORD *)(v5 + 40);
if ( v3 == 3 )
break;
LABEL_7:
v6 = (const char *)v2[1];
if ( v6 && !strcasecmp(v6, a2) )
goto LABEL_3;
v5 = (__int64)v2;
if ( v3 == 2 )
v5 = v2[2] - 40LL;
}
}
}

original_code:
int cfg_get_flag(CONFIG *table,char *item)
{
    CONFIG *walk;
    for (walk = table; walk->type != cft_end; walk++) {
 if (walk->name && !strcasecmp(walk->name,item)) {
     if (walk->type != cft_flag)
  die("cfg_get_flag: operating on non-flag %s",item);
     return !!walk->data;
 }
 if (walk->type == cft_link) walk = ((CONFIG *) walk->action)-1;
    }
    die("cfg_get_flag: unknown item %s",item);
    return 0;
}

canonical_original_code:
int cfg_get_flag(struct CONFIG *table, char *item)
{
    struct CONFIG *walk;
    for (walk = table; walk->type != cft_end; walk++) {
 if (walk->name && !strcasecmp(walk->name,item)) {
     if (walk->type != cft_flag)
  die("cfg_get_flag: operating on non-flag %s",item);
     return !!walk->data;
 }
 if (walk->type == cft_link) walk = ((struct CONFIG *) walk->action)-1;
    }
    die("cfg_get_flag: unknown item %s",item);
    return 0;
}


decompiled_code:
__int64 __fastcall cfg_get_strg(_DWORD *a1, const char *a2)
{
_QWORD *v2; // rbx
int v3; // ebp
__int64 v5; // rax
const char *v6; // rdi

v2 = a1;
v3 = *a1;
if ( *a1 != 3 )
goto LABEL_7;
while ( 1 )
{
die("cfg_get_strg: unknown item %s", a2);
LABEL_3:
if ( !v3 )
return v2[3];
v5 = die("cfg_get_strg: operating on non-string %s", a2);
while ( 1 )
{
v2 = (_QWORD *)(v5 + 40);
v3 = *(_DWORD *)(v5 + 40);
if ( v3 == 3 )
break;
LABEL_7:
v6 = (const char *)v2[1];
if ( v6 && !strcasecmp(v6, a2) )
goto LABEL_3;
v5 = (__int64)v2;
if ( v3 == 2 )
v5 = v2[2] - 40LL;
}
}
}

canonical_decompiled_code:
__int64 __fastcall func16(_DWORD *a1, const char *a2)
{
_QWORD *v2; // rbx
int v3; // ebp
__int64 v5; // rax
const char *v6; // rdi

v2 = a1;
v3 = *a1;
if ( *a1 != 3 )
goto LABEL_7;
while ( 1 )
{
die("cfg_get_strg: unknown item %s", a2);
LABEL_3:
if ( !v3 )
return v2[3];
v5 = die("cfg_get_strg: operating on non-string %s", a2);
while ( 1 )
{
v2 = (_QWORD *)(v5 + 40);
v3 = *(_DWORD *)(v5 + 40);
if ( v3 == 3 )
break;
LABEL_7:
v6 = (const char *)v2[1];
if ( v6 && !strcasecmp(v6, a2) )
goto LABEL_3;
v5 = (__int64)v2;
if ( v3 == 2 )
v5 = v2[2] - 40LL;
}
}
}

original_code:
char *cfg_get_strg(CONFIG *table,char *item)
{
    CONFIG *walk;
    for (walk = table; walk->type != cft_end; walk++) {
 if (walk->name && !strcasecmp(walk->name,item)) {
     if (walk->type != cft_strg)
  die("cfg_get_strg: operating on non-string %s",item);
     return walk->data;
 }
 if (walk->type == cft_link) walk = ((CONFIG *) walk->action)-1;
    }
    die("cfg_get_strg: unknown item %s",item);
    return 0;
}

canonical_original_code:
char *cfg_get_strg(struct CONFIG *table, char *item)
{
    struct CONFIG *walk;
    for (walk = table; walk->type != cft_end; walk++) {
 if (walk->name && !strcasecmp(walk->name,item)) {
     if (walk->type != cft_strg)
  die("cfg_get_strg: operating on non-string %s",item);
     return walk->data;
 }
 if (walk->type == cft_link) walk = ((struct CONFIG *) walk->action)-1;
    }
    die("cfg_get_strg: unknown item %s",item);
    return 0;
}


decompiled_code:
void cfg_bitmap_only()
{
keywords = &cf_bitmap;
off_D28 = 0LL;
}

canonical_decompiled_code:
void func18()
{
keywords = &cf_bitmap;
off_D28 = 0LL;
}

original_code:
void cfg_bitmap_only(void)
{
    keywords[0] = cf_bitmap;
    keywords[1] = ((void *)0);
}

canonical_original_code:
void cfg_bitmap_only()
{
    keywords[0] = cf_bitmap;
    keywords[1] = ((void *)0);
}


shsTransform

variable_types: i int

variable_types:
A
unsigned int

variable_types:
B
unsigned int

variable_types:
C
unsigned int

variable_types:
D
unsigned int

variable_types:
E
unsigned int

variable_types:
temp
unsigned int


shsInit

original_code:
void shsInit(void)
{
   shsInfo.digest[0] = 0x67452301L;
   shsInfo.digest[1] = 0xEFCDAB89L;
   shsInfo.digest[2] = 0x98BADCFEL;
   shsInfo.digest[3] = 0x10325476L;
   shsInfo.digest[4] = 0xC3D2E1F0L;
   shsInfo.countLo = shsInfo.countHi = 0L;
}

canonical_original_code:
void shsInit()
{
   shsInfo.digest[0] = 0x67452301L;
   shsInfo.digest[1] = 0xEFCDAB89L;
   shsInfo.digest[2] = 0x98BADCFEL;
   shsInfo.digest[3] = 0x10325476L;
   shsInfo.digest[4] = 0xC3D2E1F0L;
   shsInfo.countLo = shsInfo.countHi = 0L;
}


shsUpdate

decompiled_code:
__int64 __fastcall shsUpdate(void *src, int a2)
{
int v3; // ebx
int v4; // eax
int v5; // edi
bool v6; // cf
__int64 result; // rax
int v8; // ebp

v3 = a2;
v4 = *(&shsInfo + 5);
v5 = v4 & 0x3F;
v6 = __CFADD__(a2, v4);
result = (unsigned int)(a2 + v4);
if ( v6 )
++*(&shsInfo + 6);
*(&shsInfo + 5) = result;
v8 = 64 - v5;
if ( a2 >= 64 - v5 )
{
do
{
memcpy((char *)&W + v5, src, v8);
byteReverse(&W, 64);
result = shsTransform();
src = (char *)src + v8;
v3 -= v8;
v8 = 64;
v5 = 0;
}
while ( v3 > 63 );
v5 = 0;
}
if ( v3 )
result = (__int64)memcpy((char *)&W + v5, src, v3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(void *src, int a2)
{
int v3; // ebx
int v4; // eax
int v5; // edi
bool v6; // cf
__int64 result; // rax
int v8; // ebp

v3 = a2;
v4 = *(&shsInfo + 5);
v5 = v4 & 0x3F;
v6 = __CFADD__(a2, v4);
result = (unsigned int)(a2 + v4);
if ( v6 )
++*(&shsInfo + 6);
*(&shsInfo + 5) = result;
v8 = 64 - v5;
if ( a2 >= 64 - v5 )
{
do
{
memcpy((char *)&W + v5, src, v8);
func1(&W, 64);
result = func0();
src = (char *)src + v8;
v3 -= v8;
v8 = 64;
v5 = 0;
}
while ( v3 > 63 );
v5 = 0;
}
if ( v3 )
result = (__int64)memcpy((char *)&W + v5, src, v3);
return result;
}

original_code:
void shsUpdate(BYTE *buffer, int count)
{
   int remain;
   remain = shsInfo.countLo & (64 -1);
   if ( (shsInfo.countLo + (LONG)count) < shsInfo.countLo )
      shsInfo.countHi++;
   shsInfo.countLo += (LONG)count;
   while (count >= 64 -remain) {
      memcpy((BYTE*)&W+remain, buffer, 64 -remain);
      byteReverse(W, 64);
      shsTransform();
      buffer += 64 -remain;
      count -= 64 -remain;
      remain = 0;
   }
   if (count) memcpy((BYTE*)&W+remain, buffer, count);
}

canonical_original_code:
void shsUpdate(unsigned char *buffer, int count)
{
   int remain;
   remain = shsInfo.countLo & (64 -1);
   if ( (shsInfo.countLo + (unsigned int)count) < shsInfo.countLo )
      shsInfo.countHi++;
   shsInfo.countLo += (unsigned int)count;
   while (count >= 64 -remain) {
      memcpy((unsigned char *)&W+remain, buffer, 64 -remain);
      byteReverse(W, 64);
      shsTransform();
      buffer += 64 -remain;
      count -= 64 -remain;
      remain = 0;
   }
   if (count) memcpy((unsigned char *)&W+remain, buffer, count);
}

variable_types:
buffer
unsigned char *

variable_types: count int

variable_types: remain int


shsFinal

decompiled_code:
__int64 shsFinal()
{
int v0; // eax
int v1; // edx
unsigned int v2; // eax
unsigned int v3; // eax
int v5; // eax
char *v6; // rcx
unsigned __int64 v7; // rsi
unsigned int v8; // eax
unsigned int v9; // eax
unsigned int v10; // edx

v0 = *(&shsInfo + 5) & 0x3F;
v1 = v0 + 1;
*((_BYTE *)&W + v0) = 0x80;
if ( v0 + 1 <= 56 )
{
v5 = 56 - v1;
v6 = (char *)&W + v1;
if ( (unsigned int)(56 - v1) >= 8 )
{
*(__int64 *)((char *)&W + v1) = 0LL;
*(_QWORD *)&v6[v5 - 8] = 0LL;
v7 = (unsigned __int64)(v6 + 8) & 0xFFFFFFFFFFFFFFF8LL;
v8 = ((_DWORD)v6 - v7 + v5) & 0xFFFFFFF8;
if ( v8 >= 8 )
{
v9 = v8 & 0xFFFFFFF8;
v10 = 0;
do
{
*(_QWORD *)(v7 + v10) = 0LL;
v10 += 8;
}
while ( v10 < v9 );
}
}
else if ( (v5 & 4) != 0 )
{
*(_DWORD *)((char *)&W + v1) = 0;
*(_DWORD *)&v6[v5 - 4] = 0;
}
else if ( v5 )
{
*((_BYTE *)&W + v1) = 0;
if ( (v5 & 2) != 0 )
*(_WORD *)&v6[v5 - 2] = 0;
}
}
else
{
if ( v0 != 63 )
{
v2 = 0;
do
*((_BYTE *)&W + v1 + v2++) = 0;
while ( v2 < 64 - v1 );
}
byteReverse(&W, 64);
shsTransform();
W = 0LL;
qword_488 = 0LL;
qword_490 = 0LL;
qword_498 = 0LL;
qword_4A0 = 0LL;
qword_4A8 = 0LL;
qword_4B0 = 0LL;
}
byteReverse(&W, 56);
v3 = *(&shsInfo + 5);
dword_4B8 = (v3 >> 29) + 8 * *(&shsInfo + 6);
dword_4BC = 8 * v3;
return shsTransform();
}

original_code:
void shsFinal(void)
{
   int count;
   count = shsInfo.countLo & (64 -1);
   ((BYTE*)W)[count++] = 0x80;
   if (count > 56) {
      memset((BYTE*)W + count, 0, 64 -count);
      byteReverse(W, 64);
      shsTransform ();
      memset( W, 0, 64 -8);
   }
   else {
      memset((BYTE*)W + count, 0, (64 -8)-count);
   }
   byteReverse(W, 64 -8);
   W[14] = (shsInfo.countHi<<3) + (shsInfo.countLo>>29);
   W[15] = shsInfo.countLo<<3;
   shsTransform ();
}

canonical_original_code:
void shsFinal()
{
   int count;
   count = shsInfo.countLo & (64 -1);
   ((unsigned char *)W)[count++] = 0x80;
   if (count > 56) {
      memset((unsigned char *)W + count, 0, 64 -count);
      byteReverse(W, 64);
      shsTransform ();
      memset( W, 0, 64 -8);
   }
   else {
      memset((unsigned char *)W + count, 0, (64 -8)-count);
   }
   byteReverse(W, 64 -8);
   W[14] = (shsInfo.countHi<<3) + (shsInfo.countLo>>29);
   W[15] = shsInfo.countLo<<3;
   shsTransform ();
}


process

decompiled_code:
int __fastcall process(const char *a1, const char *a2)
{
int v2; // eax
int v3; // er13
int v4; // ebx
int v5; // er12
int v6; // ebp
__int64 v7; // rbx
char v9[16]; // [rsp+0h] [rbp-C8h] BYREF
struct stat stat_buf; // [rsp+10h] [rbp-B8h] BYREF

v2 = open(a1, 0);
if ( v2 < 0 )
exit(1);
v3 = v2;
if ( (unsigned int)fstat(v2, &stat_buf) )
exit(1);
v4 = stat_buf.st_size;
v5 = stat_buf.st_size;
printf(
"struct { int size; unsigned char data[%d]; } %s = { %d, {",
LODWORD(stat_buf.st_size),
a2,
LODWORD(stat_buf.st_size));
if ( v4 > 0 )
{
while ( 1 )
{
v6 = 16;
if ( v5 <= 16 )
v6 = v5;
if ( read(v3, v9, v6) != v6 )
exit(1);
v7 = 0LL;
if ( v5 > 0 )
{
do
{
printf("%c%3d", (_DWORD)v7 == 0 ? 10 : 44, (unsigned __int8)v9[v7]);
++v7;
}
while ( v6 > (int)v7 );
}
v5 -= v6;
if ( v5 <= 0 )
break;
putchar(44);
}
}
puts("}};");
return close(v3);
}

canonical_decompiled_code:
int __fastcall func7(const char *a1, const char *a2)
{
int v2; // eax
int v3; // er13
int v4; // ebx
int v5; // er12
int v6; // ebp
__int64 v7; // rbx
char v9[16]; // [rsp+0h] [rbp-C8h] BYREF
struct stat stat_buf; // [rsp+10h] [rbp-B8h] BYREF

v2 = open(a1, 0);
if ( v2 < 0 )
exit(1);
v3 = v2;
if ( (unsigned int)func10(v2, &stat_buf) )
exit(1);
v4 = stat_buf.st_size;
v5 = stat_buf.st_size;
printf(
"struct { int size; unsigned char data[%d]; } %s = { %d, {",
LODWORD(stat_buf.st_size),
a2,
LODWORD(stat_buf.st_size));
if ( v4 > 0 )
{
while ( 1 )
{
v6 = 16;
if ( v5 <= 16 )
v6 = v5;
if ( read(v3, v9, v6) != v6 )
exit(1);
v7 = 0LL;
if ( v5 > 0 )
{
do
{
printf("%c%3d", (_DWORD)v7 == 0 ? 10 : 44, (unsigned __int8)v9[v7]);
++v7;
}
while ( v6 > (int)v7 );
}
v5 -= v6;
if ( v5 <= 0 )
break;
putchar(44);
}
}
puts("}};");
return close(v3);
}

original_code:
void process(char *file, char *name)
{
    struct stat buf;
    int fd;
    int nchar, nrd, i;
    unsigned char data[16];
    if ((fd = open(file, 00)) < 0) exit(1);
    if (fstat(fd, &buf)) exit(1);
    nchar = buf.st_size;
    printf("struct { int size; unsigned char data[%d]; } %s = { %d, {",
     nchar, name, nchar);
    while (nchar>0) {
 nrd = (nchar>16 ? 16 : nchar);
 if (read(fd, data, nrd) != nrd) exit(1);
 for (i=0; i<nrd; i++) {
     printf("%c%3d", i?',':'\n', (int)data[i]);
 }
 nchar -= nrd;
 if (nchar>0) printf(",");
    }
    printf("}};\n");
    close(fd);
    return;
}

canonical_original_code:
void process(char *file, char *name)
{
    struct stat buf;
    int fd;
    int nchar; int nrd; int i;
    unsigned char data[16];
    if ((fd = open(file, 00)) < 0) exit(1);
    if (fstat(fd, &buf)) exit(1);
    nchar = buf.st_size;
    printf("struct { int size; unsigned char data[%d]; } %s = { %d, {",
     nchar, name, nchar);
    while (nchar>0) {
 nrd = (nchar>16 ? 16 : nchar);
 if (read(fd, data, nrd) != nrd) exit(1);
 for (i=0; i<nrd; i++) {
     printf("%c%3d", i?',':'\n', (int)data[i]);
 }
 nchar -= nrd;
 if (nchar>0) printf(",");
    }
    printf("}};\n");
    close(fd);
    return;
}

variable_types:
file
char *

variable_types:
name
char *

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types: fd int

variable_types: nchar int

variable_types: nrd int

variable_types:
data
unsigned char [16]


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
puts("/* begin loader ***/");
process("first.b", "First");
process("second.b", "Second");
process("third.b", "Third");
process("bitmap.b", "Bitmap");
process("mbr.b", "Mbr");
process("mbr2.b", "Mbr2");
process("chain.b", "Chain");
puts("/*** end loader ***/");
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
puts("/* begin loader ***/");
func7("first.b", "First");
func7("second.b", "Second");
func7("third.b", "Third");
func7("bitmap.b", "Bitmap");
func7("mbr.b", "Mbr");
func7("mbr2.b", "Mbr2");
func7("chain.b", "Chain");
puts("/*** end loader ***/");
return 0;
}

original_code:
int main(void)
{
    printf("/* begin loader ***/\n");
    process("first.b", "First");
    process("second.b", "Second");
    process("third.b", "Third");
    process("bitmap.b", "Bitmap");
    process("mbr.b", "Mbr");
    process("mbr2.b", "Mbr2");
    process("chain.b", "Chain");
    printf("/*** end loader ***/\n");
    return 0;
}

canonical_original_code:
int main()
{
    printf("/* begin loader ***/\n");
    process("first.b", "First");
    process("second.b", "Second");
    process("third.b", "Third");
    process("bitmap.b", "Bitmap");
    process("mbr.b", "Mbr");
    process("mbr2.b", "Mbr2");
    process("chain.b", "Chain");
    printf("/*** end loader ***/\n");
    return 0;
}


original_code:
unsigned int crc32partial(unsigned char *cp, int nsize,
   unsigned int polynomial, unsigned int *accum)
{
   unsigned int poly, crc;
   int i;
   unsigned char ch;
   crc = ~*accum;
   while (nsize--) {
      ch = *cp++;
      for (i=0; i<8; i++) {
         if ( ( (crc>>31) ^ (ch>>(7-i)) ) & 1) poly = polynomial;
         else poly = 0UL;
         crc = (crc<<1) ^ poly;
      }
   }
   return (*accum = ~crc);
}

canonical_original_code:
unsigned int crc32partial(unsigned char *cp, int nsize, unsigned int polynomial, unsigned int *accum)
{
   unsigned int poly; unsigned int crc;
   int i;
   unsigned char ch;
   crc = ~*accum;
   while (nsize--) {
      ch = *cp++;
      for (i=0; i<8; i++) {
         if ( ( (crc>>31) ^ (ch>>(7-i)) ) & 1) poly = polynomial;
         else poly = 0UL;
         crc = (crc<<1) ^ poly;
      }
   }
   return (*accum = ~crc);
}

variable_types:
cp
unsigned char *

variable_types: nsize int

variable_types:
polynomial
unsigned int

variable_types:
accum
unsigned int *

variable_types:
poly
unsigned int

variable_types:
crc
unsigned int

variable_types: i int

variable_types:
ch
unsigned char


decompiled_code:
__int64 __fastcall crc32(__int64 a1, unsigned int a2, int a3)
{
int v4; // [rsp+Ch] [rbp-4h] BYREF

v4 = 0;
return crc32partial(a1, a2, a3, &v4);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, unsigned int a2, int a3)
{
int v4; // [rsp+Ch] [rbp-4h] BYREF

v4 = 0;
return func7(a1, a2, a3, &v4);
}

original_code:
unsigned int crc32 (unsigned char *cp, int nsize, unsigned int polynomial)
{
    unsigned int crc = 0;
    return crc32partial(cp, nsize, polynomial, &crc);
}

canonical_original_code:
unsigned int crc32(unsigned char *cp, int nsize, unsigned int polynomial)
{
    unsigned int crc = 0;
    return crc32partial(cp, nsize, polynomial, &crc);
}


decompiled_code:
int __fastcall show_link(const char *a1)
{
int result; // eax
char v2[1032]; // [rsp+0h] [rbp-408h] BYREF

result = readlink(a1, v2, 0x3FFuLL);
if ( result > 0 )
{
v2[result] = 0;
result = printf(" -> %s", v2);
}
return result;
}

canonical_decompiled_code:
int __fastcall func9(const char *a1)
{
int result; // eax
char v2[1032]; // [rsp+0h] [rbp-408h] BYREF

result = readlink(a1, v2, 0x3FFuLL);
if ( result > 0 )
{
v2[result] = 0;
result = printf(" -> %s", v2);
}
return result;
}

original_code:
void show_link(char *name)
{
    int count;
    char lname[1024];
    count = readlink(name, lname, sizeof(lname)-1);
    if (count>0) {
     lname[count] = 0;
     printf(" -> %s", lname);
    }
}

variable_types: count int

variable_types:
lname
char [1024]


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
signed int i; // esi
unsigned int v6; // [rsp+Ch] [rbp-100Ch] BYREF
char buf[4104]; // [rsp+10h] [rbp-1008h] BYREF

v3 = open(argv[1], 0, envp);
v6 = 0;
for ( i = read(v3, buf, 0x1000uLL); i > 0; i = read(v3, buf, 0x1000uLL) )
crc32partial((__int64)buf, i, 79764919, &v6);
close(v3);
printf("0x%08x\n", v6);
fwrite("**Note: LONG is bigger than INT\n", 1uLL, 0x21uLL, stderr);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
signed int i; // esi
unsigned int v6; // [rsp+Ch] [rbp-100Ch] BYREF
char buf[4104]; // [rsp+10h] [rbp-1008h] BYREF

v3 = open(argv[1], 0, envp);
v6 = 0;
for ( i = read(v3, buf, 0x1000uLL); i > 0; i = read(v3, buf, 0x1000uLL) )
func7((__int64)buf, i, 79764919, &v6);
close(v3);
printf("0x%08x\n", v6);
fwrite("**Note: LONG is bigger than INT\n", 1uLL, 0x21uLL, stderr);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
    unsigned char buf[4096];
    int fd, n;
    unsigned int crc;
    fd = open(argv[1],00);
    crc = 0;
    n = read(fd,buf,sizeof(buf));
    while (n>0) {
 crc32partial(buf, n, 0x04c11db7, &crc);
 n = read(fd,buf,sizeof(buf));
    }
    close(fd);
    printf("0x%08x\n", (int)crc);
    if (sizeof(short)!=2) {
 fprintf(stderr,"***Fatal:  SHORT != 2\n");
 return 1;
    }
    if (sizeof(int)!=4) {
 fprintf(stderr, "*****Fatal:  INT != 4\n");
 return 1;
    }
    if (sizeof(long)>sizeof(int))
 fprintf(stderr, "**Note:  LONG is bigger than INT\n");
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
    unsigned char buf[4096];
    int fd; int n;
    unsigned int crc;
    fd = open(argv[1],00);
    crc = 0;
    n = read(fd,buf,sizeof(buf));
    while (n>0) {
 crc32partial(buf, n, 0x04c11db7, &crc);
 n = read(fd,buf,sizeof(buf));
    }
    close(fd);
    printf("0x%08x\n", (int)crc);
    if (sizeof(short)!=2) {
 fprintf(stderr,"***Fatal:  SHORT != 2\n");
 return 1;
    }
    if (sizeof(int)!=4) {
 fprintf(stderr, "*****Fatal:  INT != 4\n");
 return 1;
    }
    if (sizeof(long)>sizeof(int))
 fprintf(stderr, "**Note:  LONG is bigger than INT\n");
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
buf
unsigned char [4096]

variable_types: n int


repo: xalach/toteduanhop

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

if ( verbose == 1 )
result = puts(a1);
return result;
}

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

if ( verbose == 1 )
result = puts(a1);
return result;
}

original_code:
void write_verbose(char * message)
{
 if( verbose == 1)
  printf("%s\n", message);
}

canonical_original_code:
void write_verbose(char *message)
{
 if( verbose == 1)
  printf("%s\n", message);
}

variable_types:
message
char *


decompiled_code:
int __fastcall afficher_file(__int64 a1)
{
int v1; // eax
char *v2; // rax
unsigned int v3; // eax
unsigned int v4; // eax
__int16 v5; // ax
unsigned __int16 v6; // ax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

printf("******** %s *********\n", *(const char **)a1);
v1 = atoi((const char *)(a1 + 8));
timer = (unsigned int)_bswap_32(v1);
v2 = ctime(&timer);
printf("* date creation : %s", v2);
v3 = atol((const char *)(a1 + 1608));
v4 = _bswap_32(v3);
printf("* size : %ld\n", v4);
v5 = atoi((const char *)(a1 + 808));
v6 = _bswap_16(v5);
printf("* Access mode 0%i\n", v6);
return printf("**********************\n");
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1)
{
int v1; // eax
char *v2; // rax
unsigned int v3; // eax
unsigned int v4; // eax
__int16 v5; // ax
unsigned __int16 v6; // ax
time_t timer; // [rsp+8h] [rbp-10h] BYREF

printf("******** %s *********\n", *(const char **)a1);
v1 = atoi((const char *)(a1 + 8));
timer = (unsigned int)func0(v1);
v2 = ctime(&timer);
printf("* date creation : %s", v2);
v3 = atol((const char *)(a1 + 1608));
v4 = func0(v3);
printf("* size : %ld\n", v4);
v5 = atoi((const char *)(a1 + 808));
v6 = func1(v5);
printf("* Access mode 0%i\n", v6);
return printf("**********************\n");
}

original_code:
void afficher_file(struct file_info * file)
{
 printf("******** %s *********\n", file->name);
 time_t t = ntohl(atoi(&file->create_time));
 printf("*   date creation : %s", ctime(&t));
 printf("*   size : %ld\n", ntohl(atol(&file->size)));
 printf("*   Access mode 0%i\n", ntohs(atoi(&file->mode)));
 printf("**********************\n", file->name);
}

canonical_original_code:
void afficher_file(struct file_info *file)
{
 printf("******** %s *********\n", file->name);
 long t = ntohl(atoi(&file->create_time));
 printf("*   date creation : %s", ctime(&t));
 printf("*   size : %ld\n", ntohl(atol(&file->size)));
 printf("*   Access mode 0%i\n", ntohs(atoi(&file->mode)));
 printf("**********************\n", file->name);
}

variable_types: struct file_info { char *name; char *create_time[100]; char *mode[100]; char *size[100]; } *

variable_types: t long


decompiled_code:
void __fastcall __noreturn afficher_erreur(const char *a1)
{
perror(a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func4(const char *a1)
{
perror(a1);
exit(1);
}

original_code:
void afficher_erreur(char * info)
{
 perror(info);
 exit(1);
}

canonical_original_code:
void afficher_erreur(char *info)
{
 perror(info);
 exit(1);
}

variable_types:
info
char *


decompiled_code:
void afficher_help()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void afficher_help()
{
}

canonical_original_code:
void afficher_help()
{
}


decompiled_code:
char *default_tar_name()
{
struct tm *v0; // rbp
char *v1; // rbx
time_t timer; // [rsp+8h] [rbp-20h] BYREF

timer = time(0LL);
v0 = localtime(&timer);
v1 = (char *)malloc(0x21uLL);
strftime(v1, 0x21uLL, "Archive_%Y-%m-%d_%H-%M-%S.tarx", v0);
return v1;
}

canonical_decompiled_code:
char *func6()
{
struct tm *v0; // rbp
char *v1; // rbx
time_t timer; // [rsp+8h] [rbp-20h] BYREF

timer = time(0LL);
v0 = localtime(&timer);
v1 = (char *)malloc(0x21uLL);
strftime(v1, 0x21uLL, "Archive_%Y-%m-%d_%H-%M-%S.tarx", v0);
return v1;
}

original_code:
char * default_tar_name()
{
 time_t n = time(((void *)0));
 struct tm * t = localtime(&n);
 char * date = malloc(sizeof(char)*33);
 strftime(date, 33, "Archive_%Y-%m-%d_%H-%M-%S.tarx", t);
 return date;
}

canonical_original_code:
char *default_tar_name()
{
 long n = time(((void *)0));
 struct tm *t = localtime(&n);
 char *date = malloc(sizeof(char)*33);
 strftime(date, 33, "Archive_%Y-%m-%d_%H-%M-%S.tarx", t);
 return date;
}

variable_types: n long

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *

variable_types:
date
char *


decompiled_code:
int __fastcall create_directory(const char **a1)
{
if ( mkdir(*a1, 0) )
afficher_erreur(*a1);
if ( utime(*a1, 0LL) )
afficher_erreur(*a1);
return puts(aDossierCr);
}

canonical_decompiled_code:
int __fastcall func8(const char **a1)
{
if ( mkdir(*a1, 0) )
func4(*a1);
if ( utime(*a1, 0LL) )
func4(*a1);
return puts(aDossierCr);
}

original_code:
void create_directory(struct file_info * dir)
{
 mode_t dirmod = ntohs(atoi(&dir->mode));
 if ( mkdir(dir->name, ((void *)0)) != 0 )
  afficher_erreur(dir->name);
 struct utimbuf chgtm;
 chgtm.modtime = ntohl(atoi(&dir->create_time));
 if ( utime(dir->name, ((void *)0)) != 0 )
  afficher_erreur(dir->name);
 printf("dossier créer\n");
}

canonical_original_code:
void create_directory(struct file_info *dir)
{
 unsigned int dirmod = ntohs(atoi(&dir->mode));
 if ( mkdir(dir->name, ((void *)0)) != 0 )
  afficher_erreur(dir->name);
 struct utimbuf chgtm;
 chgtm.modtime = ntohl(atoi(&dir->create_time));
 if ( utime(dir->name, ((void *)0)) != 0 )
  afficher_erreur(dir->name);
 printf("dossier créer\n");
}

variable_types:
dirmod
unsigned int

variable_types: struct utimbuf { long actime; long modtime; }

user_defined_types: struct file_info { char *name; char *create_time[100]; char *mode[100]; char *size[100]; }


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

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

original_code:
int compress_archive()
{
 return 0;
}

canonical_original_code:
int compress_archive()
{
 return 0;
}


decompiled_code:
void ajouter_flag()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void ajouter_flag(int bit)
{
}

canonical_original_code:
void ajouter_flag(int bit)
{
}

variable_types: bit int


decompiled_code:
__int64 __fastcall is_compress(const char *a1)
{
int v1; // eax
unsigned int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = 0;
v1 = open(a1, 0);
if ( read(v1, buf, 1uLL) != 1 )
exit(1);
printf("le bit lu est : %d\n", buf[0]);
return buf[0];
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1)
{
int v1; // eax
unsigned int buf[3]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = 0;
v1 = open(a1, 0);
if ( read(v1, buf, 1uLL) != 1 )
exit(1);
printf("le bit lu est : %d\n", buf[0]);
return buf[0];
}

original_code:
int is_compress(char * path)
{
 int bit = 0;
 int fd = open(path, 00);
 if ( read(fd, &bit, 1) != 1 )
  exit(1);
 printf("le bit lu est : %d\n", bit);
 return bit;
}

canonical_original_code:
int is_compress(char *path)
{
 int bit = 0;
 int fd = open(path, 00);
 if ( read(fd, &bit, 1) != 1 )
  exit(1);
 printf("le bit lu est : %d\n", bit);
 return bit;
}

variable_types:
path
char *

variable_types: fd int


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

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

original_code:
int is_more_recent(struct file_info * file1, struct file_info * file2)
{
 return 0;
}

canonical_original_code:
int is_more_recent(struct file_info *file1, struct file_info *file2)
{
 return 0;
}


repo: xanmanning/alarm-fake-hwclock

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rbp
__time_t v4; // rbx
int result; // eax
struct utimbuf v6; // [rsp+0h] [rbp-B8h] BYREF
struct stat v7; // [rsp+10h] [rbp-A8h] BYREF

if ( argc <= 1 )
v3 = (char *)*argv;
else
v3 = (char *)argv[1];
v4 = time(0LL);
result = 1;
if ( v4 != -1 )
{
if ( (int)stat(v3, &v7) < 0 )
{
result = 1;
}
else if ( (unsigned __int64)(v7.st_mtim.tv_sec - v4 + 315360000) <= 0x25980600 && v4 >= v7.st_mtim.tv_sec )
{
v6.actime = v7.st_atim.tv_sec;
v6.modtime = time(0LL);
puts("Saving current time.");
utime(v3, &v6);
result = 0;
}
else
{
v6.actime = v7.st_mtim.tv_sec;
v6.modtime = 0LL;
puts("Setting Clock.");
settimeofday((const struct timeval *)&v6, 0LL);
result = 0;
}
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rbp
__time_t v4; // rbx
int result; // eax
struct utimbuf v6; // [rsp+0h] [rbp-B8h] BYREF
struct stat v7; // [rsp+10h] [rbp-A8h] BYREF

if ( argc <= 1 )
v3 = (char *)*argv;
else
v3 = (char *)argv[1];
v4 = time(0LL);
result = 1;
if ( v4 != -1 )
{
if ( (int)func9(v3, &v7) < 0 )
{
result = 1;
}
else if ( (unsigned __int64)(v7.st_mtim.tv_sec - v4 + 315360000) <= 0x25980600 && v4 >= v7.st_mtim.tv_sec )
{
v6.actime = v7.st_atim.tv_sec;
v6.modtime = time(0LL);
puts("Saving current time.");
utime(v3, &v6);
result = 0;
}
else
{
v6.actime = v7.st_mtim.tv_sec;
v6.modtime = 0LL;
puts("Setting Clock.");
settimeofday((const struct timeval *)&v6, 0LL);
result = 0;
}
}
return result;
}

original_code:
int main (int argc, char *argv[])
{
 struct stat temp;
 const char *timefile;
 if (argc > 1)
  timefile = argv[1];
 else
  timefile = argv[0];
 time_t current_time;
 time_t time_store;
 time_t diff;
 current_time = time(((void *)0));
 if(current_time == ((time_t) - 1))
  return 1;
 if(stat(timefile, &temp) < 0)
  return 1;
 time_store = temp.st_mtim.tv_sec;
 diff = time_store - current_time;
 if(time_store > current_time || diff > max_diff || diff < -max_diff)
 {
  struct timeval sys_update;
  sys_update.tv_sec =time_store;
  sys_update.tv_usec=0;
  printf("Setting Clock.\n");
  settimeofday(&sys_update,((void *)0));
 } else {
  struct utimbuf time_update;
  time_update.actime = temp.st_atim.tv_sec;
  time_update.modtime = time(((void *)0));
  printf("Saving current time.\n");
  utime(timefile, &time_update);
 }
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 struct stat temp;
 char *timefile;
 if (argc > 1)
  timefile = argv[1];
 else
  timefile = argv[0];
 long current_time;
 long time_store;
 long diff;
 current_time = time(((void *)0));
 if(current_time == ((time_t) - 1))
  return 1;
 if(stat(timefile, &temp) < 0)
  return 1;
 time_store = temp.st_mtim.tv_sec;
 diff = time_store - current_time;
 if(time_store > current_time || diff > max_diff || diff < -max_diff)
 {
  struct timeval sys_update;
  sys_update.tv_sec =time_store;
  sys_update.tv_usec=0;
  printf("Setting Clock.\n");
  settimeofday(&sys_update,((void *)0));
 } else {
  struct utimbuf time_update;
  time_update.actime = temp.st_atim.tv_sec;
  time_update.modtime = time(((void *)0));
  printf("Saving current time.\n");
  utime(timefile, &time_update);
 }
 return 0;
}

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types:
timefile
char *

variable_types: diff long

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

user_defined_types: struct utimbuf { long actime; long modtime; }


repo: xant/heyoka-unix

original_code:
alt_buffer_t *
alt_buffer_new(unsigned int size, int fd_r, int fd_w)
{
 alt_buffer_t *buffer;
 buffer = (alt_buffer_t *) malloc_or_die(sizeof(alt_buffer_t));
 buffer->size = size;
 buffer->read_data = (uint8 *) malloc_or_die(size);
 buffer->write_data = (uint8 *) malloc_or_die(size);
 buffer->write_map = (uint8 *) malloc_or_die(size);
 memset(buffer->write_map, 0x00, size);
 buffer->read_window_size = 12000;
 buffer->read_window_start = 0;
 buffer->read_window_end = 12000;
 buffer->read_pos = 0;
 buffer->read_start = 0;
 buffer->read_end = 0;
 buffer->write_window_size = 12000;
 buffer->write_window_start = 0;
 buffer->write_window_end = 12000;
 buffer->write_fd = fd_w;
 buffer->read_fd = fd_r;
 buffer->ackn = 65535;
 buffer->seqn = 0;
 buffer->same_ack_counter = 0;
 buffer->max_same_ack = 16;
 return buffer;
}

canonical_original_code:
struct _alt_buffer_t *alt_buffer_new(unsigned int size, int fd_r, int fd_w)
{
 struct _alt_buffer_t *buffer;
 buffer = (struct _alt_buffer_t *) malloc_or_die(sizeof(alt_buffer_t));
 buffer->size = size;
 buffer->read_data = (unsigned char *) malloc_or_die(size);
 buffer->write_data = (unsigned char *) malloc_or_die(size);
 buffer->write_map = (unsigned char *) malloc_or_die(size);
 memset(buffer->write_map, 0x00, size);
 buffer->read_window_size = 12000;
 buffer->read_window_start = 0;
 buffer->read_window_end = 12000;
 buffer->read_pos = 0;
 buffer->read_start = 0;
 buffer->read_end = 0;
 buffer->write_window_size = 12000;
 buffer->write_window_start = 0;
 buffer->write_window_end = 12000;
 buffer->write_fd = fd_w;
 buffer->read_fd = fd_r;
 buffer->ackn = 65535;
 buffer->seqn = 0;
 buffer->same_ack_counter = 0;
 buffer->max_same_ack = 16;
 return buffer;
}

variable_types:
size
unsigned int

variable_types: struct _alt_buffer_t { unsigned int ackn; unsigned int seqn; unsigned char *read_data; unsigned char *write_data; unsigned char *write_map; unsigned int size; unsigned int read_window_size; unsigned int read_window_start; unsigned int read_window_end; unsigned int read_start; unsigned int read_end; unsigned int read_pos; unsigned int write_window_size; unsigned int write_window_start; unsigned int write_window_end; int write_fd; int read_fd; unsigned int same_ack_counter; unsigned int max_same_ack; } *


original_code:
int
alt_buffer_write(alt_buffer_t *buffer, uint8 *data, int length, unsigned int seqn, unsigned int ackn)
{
 unsigned int pos;
 int consumed_bytes = -1;
 unsigned int w, flushed_bytes;
 uint8 *temp;
 if (!buffer || !data) {
  return -1;
 }
 if (ackn == buffer->ackn) {
  buffer->same_ack_counter++;
 } else {
  buffer->same_ack_counter = 0;
 }
 if (!length) {
  return 0;
 }
 if (!(buffer->read_window_end % buffer->size > buffer->read_window_start % buffer->size ? ((seqn % buffer->size >= buffer->read_window_start % buffer->size && seqn % buffer->size <= buffer->read_window_end % buffer->size) ? 1 : 0) : ((seqn % buffer->size >= buffer->read_window_start % buffer->size || seqn % buffer->size <= buffer->read_window_end % buffer->size) ? 1 : 0))
   && !(buffer->read_window_end % buffer->size > buffer->read_window_start % buffer->size ? ((seqn + length % buffer->size >= buffer->read_window_start % buffer->size && seqn + length % buffer->size <= buffer->read_window_end % buffer->size) ? 1 : 0) : ((seqn + length % buffer->size >= buffer->read_window_start % buffer->size || seqn + length % buffer->size <= buffer->read_window_end % buffer->size) ? 1 : 0)) ) {
  return 0;
 }
 (buffer->read_window_end = (buffer->read_window_end + ( (ackn % buffer->size >= buffer->read_window_start % buffer->size) ? (ackn % buffer->size - buffer->read_window_start % buffer->size) : (buffer->size - buffer->read_window_start % buffer->size + ackn % buffer->size) )) % buffer->size);
 buffer->read_window_start = ackn;
 (buffer->read_window_start = (buffer->read_window_start + 1) % buffer->size);
 buffer->ackn = ackn;
 pos = seqn % buffer->size;
 if ((buffer->read_window_start % buffer->size > buffer->read_window_end % buffer->size ? ((seqn % buffer->size >= buffer->read_window_end % buffer->size && seqn % buffer->size <= buffer->read_window_start % buffer->size) ? 1 : 0) : ((seqn % buffer->size >= buffer->read_window_end % buffer->size || seqn % buffer->size <= buffer->read_window_start % buffer->size) ? 1 : 0))) {
  pos = buffer->read_window_start;
 }
 for (consumed_bytes = 0;
   consumed_bytes < length
    && pos != buffer->write_window_end
     && !buffer->write_map[pos];
    consumed_bytes++) {
  buffer->write_data[pos] = data[consumed_bytes];
  buffer->write_map[pos] = 0x01;
  (pos = (pos + 1) % buffer->size);
 }
 temp = (uint8*) malloc_or_die(buffer->write_window_size);
 flushed_bytes = 0;
 for (w = buffer->write_window_start, flushed_bytes = 0;
   w != buffer->write_window_end && buffer->write_map[w] && flushed_bytes < buffer->write_window_size;
    (w = (w + 1) % buffer->size), flushed_bytes++) {
  temp[flushed_bytes] = buffer->write_data[w];
  buffer->write_map[w] = 0x00;
 }
 (buffer->write_window_start = (buffer->write_window_start + flushed_bytes) % buffer->size);
 (buffer->write_window_end = (buffer->write_window_end + flushed_bytes) % buffer->size);
 net_write(buffer->write_fd, temp, flushed_bytes);
 free(temp);
 return consumed_bytes;
}

canonical_original_code:
int alt_buffer_write(struct _alt_buffer_t *buffer, unsigned char *data, int length, unsigned int seqn, unsigned int ackn)
{
 unsigned int pos;
 int consumed_bytes = -1;
 unsigned int w; unsigned int flushed_bytes;
 unsigned char *temp;
 if (!buffer || !data) {
  return -1;
 }
 if (ackn == buffer->ackn) {
  buffer->same_ack_counter++;
 } else {
  buffer->same_ack_counter = 0;
 }
 if (!length) {
  return 0;
 }
 if (!(buffer->read_window_end % buffer->size > buffer->read_window_start % buffer->size ? ((seqn % buffer->size >= buffer->read_window_start % buffer->size && seqn % buffer->size <= buffer->read_window_end % buffer->size) ? 1 : 0) : ((seqn % buffer->size >= buffer->read_window_start % buffer->size || seqn % buffer->size <= buffer->read_window_end % buffer->size) ? 1 : 0))
   && !(buffer->read_window_end % buffer->size > buffer->read_window_start % buffer->size ? ((seqn + length % buffer->size >= buffer->read_window_start % buffer->size && seqn + length % buffer->size <= buffer->read_window_end % buffer->size) ? 1 : 0) : ((seqn + length % buffer->size >= buffer->read_window_start % buffer->size || seqn + length % buffer->size <= buffer->read_window_end % buffer->size) ? 1 : 0)) ) {
  return 0;
 }
 (buffer->read_window_end = (buffer->read_window_end + ( (ackn % buffer->size >= buffer->read_window_start % buffer->size) ? (ackn % buffer->size - buffer->read_window_start % buffer->size) : (buffer->size - buffer->read_window_start % buffer->size + ackn % buffer->size) )) % buffer->size);
 buffer->read_window_start = ackn;
 (buffer->read_window_start = (buffer->read_window_start + 1) % buffer->size);
 buffer->ackn = ackn;
 pos = seqn % buffer->size;
 if ((buffer->read_window_start % buffer->size > buffer->read_window_end % buffer->size ? ((seqn % buffer->size >= buffer->read_window_end % buffer->size && seqn % buffer->size <= buffer->read_window_start % buffer->size) ? 1 : 0) : ((seqn % buffer->size >= buffer->read_window_end % buffer->size || seqn % buffer->size <= buffer->read_window_start % buffer->size) ? 1 : 0))) {
  pos = buffer->read_window_start;
 }
 for (consumed_bytes = 0;
   consumed_bytes < length
    && pos != buffer->write_window_end
     && !buffer->write_map[pos];
    consumed_bytes++) {
  buffer->write_data[pos] = data[consumed_bytes];
  buffer->write_map[pos] = 0x01;
  (pos = (pos + 1) % buffer->size);
 }
 temp = (unsigned char *) malloc_or_die(buffer->write_window_size);
 flushed_bytes = 0;
 for (w = buffer->write_window_start, flushed_bytes = 0;
   w != buffer->write_window_end && buffer->write_map[w] && flushed_bytes < buffer->write_window_size;
    (w = (w + 1) % buffer->size), flushed_bytes++) {
  temp[flushed_bytes] = buffer->write_data[w];
  buffer->write_map[w] = 0x00;
 }
 (buffer->write_window_start = (buffer->write_window_start + flushed_bytes) % buffer->size);
 (buffer->write_window_end = (buffer->write_window_end + flushed_bytes) % buffer->size);
 net_write(buffer->write_fd, temp, flushed_bytes);
 free(temp);
 return consumed_bytes;
}

variable_types:
data
unsigned char *

variable_types: length int

variable_types:
seqn
unsigned int

variable_types:
ackn
unsigned int

variable_types:
pos
unsigned int

variable_types:
w
unsigned int

variable_types:
temp
unsigned char *

user_defined_types: struct _alt_buffer_t { unsigned int ackn; unsigned int seqn; unsigned char *read_data; unsigned char *write_data; unsigned char *write_map; unsigned int size; unsigned int read_window_size; unsigned int read_window_start; unsigned int read_window_end; unsigned int read_start; unsigned int read_end; unsigned int read_pos; unsigned int write_window_size; unsigned int write_window_start; unsigned int write_window_end; int write_fd; int read_fd; unsigned int same_ack_counter; unsigned int max_same_ack; }


original_code:
int
alt_buffer_read(alt_buffer_t *buffer, uint8 *data, unsigned int length, unsigned int *seqn, unsigned int *ackn)
{
 int consumed_bytes;
 unsigned int *pos, temp_pos;
 unsigned int read_more_bytes;
 unsigned int read_bytes, r;
 uint8 *temp;
printf("A\n");
 if (!buffer || !data) {
  return -1;
 }
printf("B\n");
 do {
  printf("C: %i %i %i %i %i\n", buffer->read_pos, buffer->read_window_end, buffer->size, length, ( (buffer->read_end % buffer->size >= buffer->read_pos % buffer->size) ? (buffer->read_end % buffer->size - buffer->read_pos % buffer->size) : (buffer->size - buffer->read_pos % buffer->size + buffer->read_end % buffer->size) ));
  if (( (buffer->read_end % buffer->size >= buffer->read_pos % buffer->size) ? (buffer->read_end % buffer->size - buffer->read_pos % buffer->size) : (buffer->size - buffer->read_pos % buffer->size + buffer->read_end % buffer->size) ) >= length) {
   printf("C.2\n");
   if (( (buffer->read_window_end % buffer->size >= buffer->read_pos % buffer->size) ? (buffer->read_window_end % buffer->size - buffer->read_pos % buffer->size) : (buffer->size - buffer->read_pos % buffer->size + buffer->read_window_end % buffer->size) ) >= length
     && buffer->same_ack_counter != buffer->max_same_ack) {
    pos = &(buffer->read_pos);
   } else {
    temp_pos = buffer->read_window_start;
    pos = &temp_pos;
   }
   printf("C.3\n");
   for (consumed_bytes = 0; consumed_bytes < length && *pos != buffer->read_window_end; consumed_bytes++) {
    data[consumed_bytes] = buffer->read_data[*pos + consumed_bytes];
    (*pos = (*pos + 1) % buffer->size);
   }
   printf("C.4\n");
  } else {
   printf("D\n");
   read_more_bytes = buffer->size - ( (buffer->read_end % buffer->size >= buffer->read_start % buffer->size) ? (buffer->read_end % buffer->size - buffer->read_start % buffer->size) : (buffer->size - buffer->read_start % buffer->size + buffer->read_end % buffer->size) );
   temp = (uint8 *) malloc_or_die(read_more_bytes);
   read_bytes = net_read(buffer->read_fd, temp, read_more_bytes, 0, 10);
   printf("D.2: %i\n", read_bytes);
   if (!read_bytes) {
    consumed_bytes = 0;
   } else {
    printf("READ SOME BYTES: %i\n", read_bytes);
    system("pause");
    for (r = 0; r < read_bytes; r++) {
     buffer->read_data[buffer->read_end] = temp[r];
     (buffer->read_end = (buffer->read_end + 1) % buffer->size);
    }
    consumed_bytes = -1;
   }
   free(temp);
  }
 } while (consumed_bytes == -1);
printf("E\n");
 printf("CONSUMED BYTES: %i\n", consumed_bytes);
 return consumed_bytes;
}

canonical_original_code:
int alt_buffer_read(struct _alt_buffer_t *buffer, unsigned char *data, unsigned int length, unsigned int *seqn, unsigned int *ackn)
{
 int consumed_bytes;
 unsigned int *pos; unsigned int temp_pos;
 unsigned int read_more_bytes;
 unsigned int read_bytes; unsigned int r;
 unsigned char *temp;
printf("A\n");
 if (!buffer || !data) {
  return -1;
 }
printf("B\n");
 do {
  printf("C: %i %i %i %i %i\n", buffer->read_pos, buffer->read_window_end, buffer->size, length, ( (buffer->read_end % buffer->size >= buffer->read_pos % buffer->size) ? (buffer->read_end % buffer->size - buffer->read_pos % buffer->size) : (buffer->size - buffer->read_pos % buffer->size + buffer->read_end % buffer->size) ));
  if (( (buffer->read_end % buffer->size >= buffer->read_pos % buffer->size) ? (buffer->read_end % buffer->size - buffer->read_pos % buffer->size) : (buffer->size - buffer->read_pos % buffer->size + buffer->read_end % buffer->size) ) >= length) {
   printf("C.2\n");
   if (( (buffer->read_window_end % buffer->size >= buffer->read_pos % buffer->size) ? (buffer->read_window_end % buffer->size - buffer->read_pos % buffer->size) : (buffer->size - buffer->read_pos % buffer->size + buffer->read_window_end % buffer->size) ) >= length
     && buffer->same_ack_counter != buffer->max_same_ack) {
    pos = &(buffer->read_pos);
   } else {
    temp_pos = buffer->read_window_start;
    pos = &temp_pos;
   }
   printf("C.3\n");
   for (consumed_bytes = 0; consumed_bytes < length && *pos != buffer->read_window_end; consumed_bytes++) {
    data[consumed_bytes] = buffer->read_data[*pos + consumed_bytes];
    (*pos = (*pos + 1) % buffer->size);
   }
   printf("C.4\n");
  } else {
   printf("D\n");
   read_more_bytes = buffer->size - ( (buffer->read_end % buffer->size >= buffer->read_start % buffer->size) ? (buffer->read_end % buffer->size - buffer->read_start % buffer->size) : (buffer->size - buffer->read_start % buffer->size + buffer->read_end % buffer->size) );
   temp = (unsigned char *) malloc_or_die(read_more_bytes);
   read_bytes = net_read(buffer->read_fd, temp, read_more_bytes, 0, 10);
   printf("D.2: %i\n", read_bytes);
   if (!read_bytes) {
    consumed_bytes = 0;
   } else {
    printf("READ SOME BYTES: %i\n", read_bytes);
    system("pause");
    for (r = 0; r < read_bytes; r++) {
     buffer->read_data[buffer->read_end] = temp[r];
     (buffer->read_end = (buffer->read_end + 1) % buffer->size);
    }
    consumed_bytes = -1;
   }
   free(temp);
  }
 } while (consumed_bytes == -1);
printf("E\n");
 printf("CONSUMED BYTES: %i\n", consumed_bytes);
 return consumed_bytes;
}

variable_types:
length
unsigned int

variable_types:
seqn
unsigned int *

variable_types:
ackn
unsigned int *

variable_types:
pos
unsigned int *

variable_types:
r
unsigned int


debug

decompiled_code:
int debug(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
printf("[DEBUG]: ");
return vfprintf(stderr, format, arg);
}

canonical_decompiled_code:
int func0(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
printf("[DEBUG]: ");
return vfprintf(stderr, format, arg);
}

original_code:
void
debug(const char *format, ...)
{
 va_list args;
 __builtin_va_start(args,format);
 printf("[DEBUG]: ");
 vfprintf(stderr, format, args);
 __builtin_va_end(args);
}

canonical_original_code:
void debug(char *format, ...)
{
 __builtin_va_list args;
 __builtin_va_start(args,format);
 printf("[DEBUG]: ");
 vfprintf(stderr, format, args);
 __builtin_va_end(args);
}

variable_types:
format
char *


error

decompiled_code:
int error(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
printf("[ERROR]: ");
return vfprintf(stderr, format, arg);
}

canonical_decompiled_code:
int func1(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
printf("[ERROR]: ");
return vfprintf(stderr, format, arg);
}

original_code:
void
error(const char *format, ...)
{
 char buffer[256];
 va_list args;
 __builtin_va_start(args,format);
 printf("[ERROR]: ");
 vfprintf(stderr, format, args);
 __builtin_va_end(args);
}

canonical_original_code:
void error(char *format, ...)
{
 char buffer[256];
 __builtin_va_list args;
 __builtin_va_start(args,format);
 printf("[ERROR]: ");
 vfprintf(stderr, format, args);
 __builtin_va_end(args);
}

variable_types:
buffer
char [256]


warning

decompiled_code:
int warning(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
printf("[WARNING]: ");
return vfprintf(stderr, format, arg);
}

canonical_decompiled_code:
int func2(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, format);
printf("[WARNING]: ");
return vfprintf(stderr, format, arg);
}

original_code:
void
warning(const char *format, ...)
{
 va_list args;
 __builtin_va_start(args,format);
 printf("[WARNING]: ");
 vfprintf(stderr, format, args);
 __builtin_va_end(args);
}

canonical_original_code:
void warning(char *format, ...)
{
 __builtin_va_list args;
 __builtin_va_start(args,format);
 printf("[WARNING]: ");
 vfprintf(stderr, format, args);
 __builtin_va_end(args);
}