decompiled_code:
int __fastcall mount_lv_set(const char *a1)
{
int result; // eax
int *v2; // rax
char *v3; // rax
int *v4; // rax
char *v5; // rax
int *v6; // rax
char *v7; // rax
char v8[4096]; // [rsp+0h] [rbp-2008h] BYREF
char s[4104]; // [rsp+1000h] [rbp-1008h] BYREF

logprintf("0mounting volumes starting with %s", a1);
sprintf(s, "/mnt/%s", a1);
mkdir(s, 0x1EDu);
sprintf(s, "/mnt/%s/system", a1);
mkdir(s, 0x1EDu);
sprintf(v8, "/dev/store/%s-system", a1);
if ( mount(v8, s, "ext4", 0x8000uLL, 0LL) == -1 )
{
v2 = _errno_location();
v3 = strerror(*v2);
logprintf("2%s: %s", "can't mount system volume", v3);
}
sprintf(s, "/mnt/%s/data", a1);
mkdir(s, 0x1EDu);
sprintf(v8, "/dev/store/%s-data", a1);
if ( mount(v8, s, "ext4", 0x8000uLL, 0LL) == -1 )
{
v6 = _errno_location();
v7 = strerror(*v6);
logprintf("2%s: %s", "can't mount data volume", v7);
}
sprintf(s, "/mnt/%s/cache", a1);
mkdir(s, 0x1EDu);
sprintf(v8, "/dev/store/%s-cache", a1);
result = mount(v8, s, "ext4", 0x8000uLL, 0LL);
if ( result == -1 )
{
v4 = _errno_location();
v5 = strerror(*v4);
result = logprintf("2%s: %s", "can't mount cache volume", v5);
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(const char *a1)
{
int result; // eax
int *v2; // rax
char *v3; // rax
int *v4; // rax
char *v5; // rax
int *v6; // rax
char *v7; // rax
char v8[4096]; // [rsp+0h] [rbp-2008h] BYREF
char s[4104]; // [rsp+1000h] [rbp-1008h] BYREF

logprintf("0mounting volumes starting with %s", a1);
sprintf(s, "/mnt/%s", a1);
mkdir(s, 0x1EDu);
sprintf(s, "/mnt/%s/system", a1);
mkdir(s, 0x1EDu);
sprintf(v8, "/dev/store/%s-system", a1);
if ( mount(v8, s, "ext4", 0x8000uLL, 0LL) == -1 )
{
v2 = _errno_location();
v3 = strerror(*v2);
logprintf("2%s: %s", "can't mount system volume", v3);
}
sprintf(s, "/mnt/%s/data", a1);
mkdir(s, 0x1EDu);
sprintf(v8, "/dev/store/%s-data", a1);
if ( mount(v8, s, "ext4", 0x8000uLL, 0LL) == -1 )
{
v6 = _errno_location();
v7 = strerror(*v6);
logprintf("2%s: %s", "can't mount data volume", v7);
}
sprintf(s, "/mnt/%s/cache", a1);
mkdir(s, 0x1EDu);
sprintf(v8, "/dev/store/%s-cache", a1);
result = mount(v8, s, "ext4", 0x8000uLL, 0LL);
if ( result == -1 )
{
v4 = _errno_location();
v5 = strerror(*v4);
result = logprintf("2%s: %s", "can't mount cache volume", v5);
}
return result;
}

original_code:
void mount_lv_set(const char *base) {
 char src[4096], targ[4096];
 logprintf("0mounting volumes starting with %s", base);
 sprintf(targ, "/mnt/%s", base);
 mkdir(targ, 0755);
 sprintf(targ, "/mnt/%s/system", base);
 mkdir(targ, 0755);
 sprintf(src, "/dev/store/%s-system", base);
 if (mount(src, targ, "ext4", MS_SILENT, ((void *)0)) == -1)
  logprintf("2%s: %s", "can't mount system volume", strerror((*__errno_location ())));
 sprintf(targ, "/mnt/%s/data", base);
 mkdir(targ, 0755);
 sprintf(src, "/dev/store/%s-data", base);
 if (mount(src, targ, "ext4", MS_SILENT, ((void *)0)) == -1)
  logprintf("2%s: %s", "can't mount data volume", strerror((*__errno_location ())));
 sprintf(targ, "/mnt/%s/cache", base);
 mkdir(targ, 0755);
 sprintf(src, "/dev/store/%s-cache", base);
 if (mount(src, targ, "ext4", MS_SILENT, ((void *)0)) == -1)
  logprintf("2%s: %s", "can't mount cache volume", strerror((*__errno_location ())));
}

canonical_original_code:
void mount_lv_set(char *base) {
 char src[4096]; char targ[4096];
 logprintf("0mounting volumes starting with %s", base);
 sprintf(targ, "/mnt/%s", base);
 mkdir(targ, 0755);
 sprintf(targ, "/mnt/%s/system", base);
 mkdir(targ, 0755);
 sprintf(src, "/dev/store/%s-system", base);
 if (mount(src, targ, "ext4", MS_SILENT, ((void *)0)) == -1)
  logprintf("2%s: %s", "can't mount system volume", strerror((*__errno_location ())));
 sprintf(targ, "/mnt/%s/data", base);
 mkdir(targ, 0755);
 sprintf(src, "/dev/store/%s-data", base);
 if (mount(src, targ, "ext4", MS_SILENT, ((void *)0)) == -1)
  logprintf("2%s: %s", "can't mount data volume", strerror((*__errno_location ())));
 sprintf(targ, "/mnt/%s/cache", base);
 mkdir(targ, 0755);
 sprintf(src, "/dev/store/%s-cache", base);
 if (mount(src, targ, "ext4", MS_SILENT, ((void *)0)) == -1)
  logprintf("2%s: %s", "can't mount cache volume", strerror((*__errno_location ())));
}

variable_types:
base
char *

variable_types:
src
char [4096]

variable_types:
targ
char [4096]


repo: willcast/nsboot

decompiled_code:
char *__fastcall deduce_lv_set(const char *a1)
{
char *v1; // rbp

v1 = basename(a1);
if ( !strncasecmp("froyo-", v1, 6uLL) || !strncasecmp("gapps-mdpi", v1, 0xAuLL) )
return strdup("android22");
if ( !strncasecmp("update-cm7", v1, 0xAuLL)
|| !strncasecmp("update-cm-7", v1, 0xBuLL)
|| !strncasecmp("cm-7", v1, 4uLL)
|| !strncasecmp("gapps-gb", v1, 8uLL) )
{
return strdup("android23");
}
if ( !strncasecmp("update-cm9", v1, 0xAuLL)
|| !strncasecmp("update-cm-9", v1, 0xBuLL)
|| !strncasecmp("cm-9", v1, 4uLL)
|| !strncasecmp("gapps-ics", v1, 9uLL) )
{
return strdup("android40");
}
if ( !strncasecmp("update-cm10-", v1, 0xAuLL)
|| !strncasecmp("update-cm-10-", v1, 0xBuLL)
|| !strncasecmp("cm-10-", v1, 6uLL)
|| !strncasecmp("skz_tenderloin-1.20", v1, 0x13uLL)
|| !strncasecmp("gapps-jb-20120", v1, 0xEuLL)
|| !strncasecmp("gapps-jb-201210", v1, 0xFuLL) )
{
return strdup("android41");
}
if ( !strncasecmp("ev", v1, 2uLL)
|| !strncasecmp("cm-10.1", v1, 7uLL)
|| !strncasecmp("skz_tenderloin-2.00", v1, 0x13uLL)
|| !strncasecmp("gapps-jb", v1, 8uLL) )
{
return strdup("android42");
}
return 0LL;
}

canonical_decompiled_code:
char *__fastcall func3(const char *a1)
{
char *v1; // rbp

v1 = basename(a1);
if ( !strncasecmp("froyo-", v1, 6uLL) || !strncasecmp("gapps-mdpi", v1, 0xAuLL) )
return strdup("android22");
if ( !strncasecmp("update-cm7", v1, 0xAuLL)
|| !strncasecmp("update-cm-7", v1, 0xBuLL)
|| !strncasecmp("cm-7", v1, 4uLL)
|| !strncasecmp("gapps-gb", v1, 8uLL) )
{
return strdup("android23");
}
if ( !strncasecmp("update-cm9", v1, 0xAuLL)
|| !strncasecmp("update-cm-9", v1, 0xBuLL)
|| !strncasecmp("cm-9", v1, 4uLL)
|| !strncasecmp("gapps-ics", v1, 9uLL) )
{
return strdup("android40");
}
if ( !strncasecmp("update-cm10-", v1, 0xAuLL)
|| !strncasecmp("update-cm-10-", v1, 0xBuLL)
|| !strncasecmp("cm-10-", v1, 6uLL)
|| !strncasecmp("skz_tenderloin-1.20", v1, 0x13uLL)
|| !strncasecmp("gapps-jb-20120", v1, 0xEuLL)
|| !strncasecmp("gapps-jb-201210", v1, 0xFuLL) )
{
return strdup("android41");
}
if ( !strncasecmp("ev", v1, 2uLL)
|| !strncasecmp("cm-10.1", v1, 7uLL)
|| !strncasecmp("skz_tenderloin-2.00", v1, 0x13uLL)
|| !strncasecmp("gapps-jb", v1, 8uLL) )
{
return strdup("android42");
}
return 0LL;
}

original_code:
char * deduce_lv_set(const char *name) {
 char *base = basename(name);
 char *result = ((void *)0);
 if ((!strncasecmp("froyo-", base, 6)) ||
    (!strncasecmp("gapps-mdpi", base, 10)))
  result = strdup("android22");
 else if ((!strncasecmp("update-cm7", base, 10)) ||
  (!strncasecmp("update-cm-7", base, 11)) ||
  (!strncasecmp("cm-7", base, 4)) ||
  (!strncasecmp("gapps-gb", base, 8)))
  result = strdup("android23");
 else if ((!strncasecmp("update-cm9", base, 10)) ||
  (!strncasecmp("update-cm-9", base, 11)) ||
  (!strncasecmp("cm-9", base, 4)) ||
  (!strncasecmp("gapps-ics", base, 9)))
  result = strdup("android40");
 else if ((!strncasecmp("update-cm10-", base, 10)) ||
  (!strncasecmp("update-cm-10-", base, 11)) ||
  (!strncasecmp("cm-10-", base, 6)) ||
  (!strncasecmp("skz_tenderloin-1.20", base, 19)) ||
  (!strncasecmp("gapps-jb-20120", base, 14)) ||
  (!strncasecmp("gapps-jb-201210", base, 15)))
  result = strdup("android41");
 else if ((!strncasecmp("ev", base, 2)) ||
  (!strncasecmp("cm-10.1", base, 7)) ||
  (!strncasecmp("skz_tenderloin-2.00", base, 19)) ||
  (!strncasecmp("gapps-jb", base, 8)))
  result = strdup("android42");
 return result;
}

canonical_original_code:
char *deduce_lv_set(char *name) {
 char *base = basename(name);
 char *result = ((void *)0);
 if ((!strncasecmp("froyo-", base, 6)) ||
    (!strncasecmp("gapps-mdpi", base, 10)))
  result = strdup("android22");
 else if ((!strncasecmp("update-cm7", base, 10)) ||
  (!strncasecmp("update-cm-7", base, 11)) ||
  (!strncasecmp("cm-7", base, 4)) ||
  (!strncasecmp("gapps-gb", base, 8)))
  result = strdup("android23");
 else if ((!strncasecmp("update-cm9", base, 10)) ||
  (!strncasecmp("update-cm-9", base, 11)) ||
  (!strncasecmp("cm-9", base, 4)) ||
  (!strncasecmp("gapps-ics", base, 9)))
  result = strdup("android40");
 else if ((!strncasecmp("update-cm10-", base, 10)) ||
  (!strncasecmp("update-cm-10-", base, 11)) ||
  (!strncasecmp("cm-10-", base, 6)) ||
  (!strncasecmp("skz_tenderloin-1.20", base, 19)) ||
  (!strncasecmp("gapps-jb-20120", base, 14)) ||
  (!strncasecmp("gapps-jb-201210", base, 15)))
  result = strdup("android41");
 else if ((!strncasecmp("ev", base, 2)) ||
  (!strncasecmp("cm-10.1", base, 7)) ||
  (!strncasecmp("skz_tenderloin-2.00", base, 19)) ||
  (!strncasecmp("gapps-jb", base, 8)))
  result = strdup("android42");
 return result;
}

variable_types:
name
char *

variable_types:
result
char *

return_type: char *


decompiled_code:
__int64 __fastcall new_lv_set(const char *a1, int a2, int a3, int a4)
{
__int64 result; // rax
char v7[72]; // [rsp+0h] [rbp-48h] BYREF

logprintf("0%s", "creating volume set with name %s");
result = get_free_vg_space();
if ( result != -1 )
{
resize_lv("media", 4LL, a4 + a2 + a3);
sprintf(v7, "%s-system", a1);
new_lv(v7, a2);
sprintf(v7, "%s-data", a1);
new_lv(v7, a3);
sprintf(v7, "%s-cache", a1);
result = new_lv(v7, a4);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(const char *a1, int a2, int a3, int a4)
{
__int64 result; // rax
char v7[72]; // [rsp+0h] [rbp-48h] BYREF

logprintf("0%s", "creating volume set with name %s");
result = get_free_vg_space();
if ( result != -1 )
{
resize_lv("media", 4LL, a4 + a2 + a3);
sprintf(v7, "%s-system", a1);
new_lv(v7, a2);
sprintf(v7, "%s-data", a1);
new_lv(v7, a3);
sprintf(v7, "%s-cache", a1);
result = new_lv(v7, a4);
}
return result;
}

original_code:
void new_lv_set(const char *name, int sys, int data, int cache) {
 char lv[32];
 long space;
 logprintf("0%s", "creating volume set with name %s", name);
 space = get_free_vg_space();
 if (space == -1) return;
 resize_lv("media", RS_FREE, sys + data + cache);
 sprintf(lv, "%s-system", name);
 new_lv(lv, sys);
 sprintf(lv, "%s-data", name);
 new_lv(lv, data);
 sprintf(lv, "%s-cache", name);
 new_lv(lv, cache);
}

canonical_original_code:
void new_lv_set(char *name, int sys, int data, int cache) {
 char lv[32];
 long space;
 logprintf("0%s", "creating volume set with name %s", name);
 space = get_free_vg_space();
 if (space == -1) return;
 resize_lv("media", RS_FREE, sys + data + cache);
 sprintf(lv, "%s-system", name);
 new_lv(lv, sys);
 sprintf(lv, "%s-data", name);
 new_lv(lv, data);
 sprintf(lv, "%s-cache", name);
 new_lv(lv, cache);
}

variable_types: sys int

variable_types: data int

variable_types: cache int

variable_types:
lv
char [32]

variable_types: space long

return_type: void


decompiled_code:
bool __fastcall deduce_lv_set_size(const char *a1, _DWORD *a2, _DWORD *a3, _DWORD *a4)
{
bool result; // al
bool v5; // zf

result = (char)a1;
if ( !strcmp(a1, "android22") )
{
*a2 = 256;
*a3 = 448;
*a4 = 200;
}
else if ( !strcmp(a1, "android23") )
{
*a2 = 304;
*a3 = 504;
*a4 = 200;
}
else if ( !strcmp(a1, "android40") )
{
*a2 = 352;
*a3 = 754;
*a4 = 200;
}
else if ( !strcmp(a1, "android41") || (v5 = strcmp(a1, "android42") == 0, result = !v5, v5) )
{
*a2 = 448;
*a3 = 754;
*a4 = 200;
}
return result;
}

canonical_decompiled_code:
bool __fastcall func5(const char *a1, _DWORD *a2, _DWORD *a3, _DWORD *a4)
{
bool result; // al
bool v5; // zf

result = (char)a1;
if ( !strcmp(a1, "android22") )
{
*a2 = 256;
*a3 = 448;
*a4 = 200;
}
else if ( !strcmp(a1, "android23") )
{
*a2 = 304;
*a3 = 504;
*a4 = 200;
}
else if ( !strcmp(a1, "android40") )
{
*a2 = 352;
*a3 = 754;
*a4 = 200;
}
else if ( !strcmp(a1, "android41") || (v5 = strcmp(a1, "android42") == 0, result = !v5, v5) )
{
*a2 = 448;
*a3 = 754;
*a4 = 200;
}
return result;
}

original_code:
void deduce_lv_set_size(const char *name, int *sys, int *dat, int *cac) {
 if (!strcmp(name, "android22")) {
  *sys = 256; *dat = 448; *cac = 200;
 } else if (!strcmp(name, "android23")) {
  *sys = 304; *dat = 504; *cac = 200;
 } else if (!strcmp(name, "android40")) {
  *sys = 352; *dat = 754; *cac = 200;
 } else if (!strcmp(name, "android41")) {
  *sys = 448; *dat = 754; *cac = 200;
 } else if (!strcmp(name, "android42")) {
  *sys = 448; *dat = 754; *cac = 200;
 }
}

canonical_original_code:
void deduce_lv_set_size(char *name, int *sys, int *dat, int *cac) {
 if (!strcmp(name, "android22")) {
  *sys = 256; *dat = 448; *cac = 200;
 } else if (!strcmp(name, "android23")) {
  *sys = 304; *dat = 504; *cac = 200;
 } else if (!strcmp(name, "android40")) {
  *sys = 352; *dat = 754; *cac = 200;
 } else if (!strcmp(name, "android41")) {
  *sys = 448; *dat = 754; *cac = 200;
 } else if (!strcmp(name, "android42")) {
  *sys = 448; *dat = 754; *cac = 200;
 }
}

variable_types:
sys
int *

variable_types:
dat
int *

variable_types:
cac
int *


decompiled_code:
__int64 init_log()
{
__int64 result; // rax

result = new_str_list(8LL);
loglist = result;
return result;
}

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

result = new_str_list(8LL);
loglist = result;
return result;
}

original_code:
void init_log(void) {
 loglist = new_str_list(8);
}

canonical_original_code:
void init_log() {
 loglist = new_str_list(8);
}


decompiled_code:
int display_logbar()
{
unsigned int v0; // ebp
int i; // ebx
int v2; // eax
int v3; // eax
__int64 v4; // r12
char *endptr; // [rsp+8h] [rbp-20h] BYREF

if ( !(unsigned int)is_fb_available() )
return fprintf(
stderr,
"%s\n",
(const char *)(*(_QWORD *)(*(_QWORD *)loglist + 8LL * *(int *)(loglist + 12) - 8) + 1LL));
v0 = 512;
for ( i = 0; i != 16; ++i )
{
v2 = i + *(_DWORD *)(loglist + 12) - 16;
if ( v2 >= 0 )
{
v3 = strtol(*(const char **)(*(_QWORD *)loglist + 8LL * v2), &endptr, 10);
if ( endptr )
{
if ( v3 > 3 )
v3 = 3;
if ( v3 < 0 )
v3 = 0;
v4 = (unsigned int)logpalette[v3];
fill_rect(0LL, v0, 1024LL, 16LL, v4);
text(endptr, 0LL, v0, 1LL, 1LL, 0xFFFFFFFFLL, v4);
}
}
v0 += 16;
}
return update_screen();
}

canonical_decompiled_code:
int func1()
{
unsigned int v0; // ebp
int i; // ebx
int v2; // eax
int v3; // eax
__int64 v4; // r12
char *endptr; // [rsp+8h] [rbp-20h] BYREF

if ( !(unsigned int)is_fb_available() )
return fprintf(
stderr,
"%s\n",
(const char *)(*(_QWORD *)(*(_QWORD *)loglist + 8LL * *(int *)(loglist + 12) - 8) + 1LL));
v0 = 512;
for ( i = 0; i != 16; ++i )
{
v2 = i + *(_DWORD *)(loglist + 12) - 16;
if ( v2 >= 0 )
{
v3 = strtol(*(const char **)(*(_QWORD *)loglist + 8LL * v2), &endptr, 10);
if ( endptr )
{
if ( v3 > 3 )
v3 = 3;
if ( v3 < 0 )
v3 = 0;
v4 = (unsigned int)logpalette[v3];
fill_rect(0LL, v0, 1024LL, 16LL, v4);
text(endptr, 0LL, v0, 1LL, 1LL, 0xFFFFFFFFLL, v4);
}
}
v0 += 16;
}
return update_screen();
}

original_code:
void display_logbar(void) {
 char *str;
 int loglevel = 0, logindex = 0;
 if (is_fb_available()) {
  for (int i = 0; i < 16; ++i) {
   logindex = loglist->used - 16 + i;
   if (logindex < 0) continue;
   loglevel = (int)strtol(loglist->data[logindex], &str, 10);
   if (str == ((void *)0)) continue;
   if (loglevel < 0) loglevel = 0;
   else if (loglevel > 3) loglevel = 3;
   fill_rect(0, 768 - 256 + i*16, 1024, 16, logpalette[loglevel]);
   text(str, 0, 768 - 256 + i*16, 1, 1, 0xFFFFFFFF, logpalette[loglevel]);
  }
  update_screen();
 } else
  fprintf(stderr, "%s\n", loglist->data[loglist->used-1]+1);
}

canonical_original_code:
void display_logbar() {
 char *str;
 int loglevel = 0; int logindex = 0;
 if (is_fb_available()) {
  for (int i = 0; i < 16; ++i) {
   logindex = loglist->used - 16 + i;
   if (logindex < 0) continue;
   loglevel = (int)strtol(loglist->data[logindex], &str, 10);
   if (str == ((void *)0)) continue;
   if (loglevel < 0) loglevel = 0;
   else if (loglevel > 3) loglevel = 3;
   fill_rect(0, 768 - 256 + i*16, 1024, 16, logpalette[loglevel]);
   text(str, 0, 768 - 256 + i*16, 1, 1, 0xFFFFFFFF, logpalette[loglevel]);
  }
  update_screen();
 } else
  fprintf(stderr, "%s\n", loglist->data[loglist->used-1]+1);
}

variable_types:
str
char *

variable_types: loglevel int

variable_types: logindex int

variable_types: i int


logprintf

decompiled_code:
int logprintf(char *format, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-150h] BYREF
char s[128]; // [rsp+20h] [rbp-138h] BYREF

va_start(arg, format);
vsnprintf(s, 0x80uLL, format, arg);
append_to_str_list(loglist, s);
return display_logbar();
}

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

va_start(arg, format);
vsnprintf(s, 0x80uLL, format, arg);
append_to_str_list(loglist, s);
return func1();
}

original_code:
void logprintf(const char *fmt, ...) {
 va_list args;
 char buf[128];
 __builtin_va_start(args,fmt);
 vsnprintf(buf, sizeof(buf), fmt, args);
 __builtin_va_end(args);
 append_to_str_list(loglist, buf);
 display_logbar();
}

canonical_original_code:
void logprintf(char *fmt, ...) {
 __builtin_va_list args;
 char buf[128];
 __builtin_va_start(args,fmt);
 vsnprintf(buf, sizeof(buf), fmt, args);
 __builtin_va_end(args);
 append_to_str_list(loglist, buf);
 display_logbar();
}

variable_types:
fmt
char *

variable_types:
buf
char [128]


decompiled_code:
__int64 __fastcall display_wholelog(const char *a1, char **a2)
{
__int64 result; // rax
__int64 i; // rbx
__int64 v4; // rdx
int v5; // ebp
__int64 v6; // rdx
__int64 v7; // rcx
__int64 v8; // r8
int v9; // er13
unsigned int v10; // ebx
__int64 v11; // r12
int v12; // eax
__int64 v13; // r14
const char *v14; // [rsp-10h] [rbp-48h]
__int64 v15; // [rsp-8h] [rbp-40h]
char *endptr[6]; // [rsp+8h] [rbp-30h] BYREF

if ( (unsigned int)is_fb_available() )
{
*((_BYTE *)&sbstr + 10) = 0;
v5 = 0;
sbstr = 0x7765697620676F6CLL;
*((_WORD *)&sbstr + 4) = 29285;
do
{
clear_screen();
v9 = v5;
v10 = 48;
v11 = 8LL * v5;
do
{
if ( *(_DWORD *)(loglist + 12) <= v9 )
break;
a1 = *(const char **)(*(_QWORD *)loglist + v11);
if ( a1 )
{
a2 = endptr;
v12 = strtol(a1, endptr, 10);
if ( endptr[0] )
{
if ( v12 > 3 )
v12 = 3;
if ( v12 < 0 )
v12 = 0;
v13 = (unsigned int)logpalette[v12];
fill_rect(0LL, v10, 1024LL, 16LL, v13);
a2 = 0LL;
text(endptr[0], 0LL, v10, 1LL, 1LL, 0xFFFFFFFFLL, v13);
a1 = v14;
v8 = v15;
}
}
v10 += 16;
++v9;
v11 += 8LL;
}
while ( v10 != 768 );
update_screen(a1, a2, v6, v7, v8);
input_read();
a2 = (char **)diff_input[3];
if ( (_DWORD)a2 )
{
if ( v5 <= 15 )
{
a1 = (_BYTE *)&loc_28;
vibrate(40LL);
}
else
{
v5 -= 16;
}
}
if ( diff_input[4] )
{
if ( *(_DWORD *)(loglist + 12) - 16 <= v5 )
{
a1 = (_BYTE *)&loc_28;
vibrate(40LL);
}
else
{
v5 += 16;
}
}
if ( diff_input[2] )
{
result = (unsigned int)(*(_DWORD *)(loglist + 12) - 45);
if ( (int)result <= v5 )
return result;
v5 += 45;
}
result = diff_input[5];
}
while ( !(_DWORD)result );
}
else
{
result = loglist;
for ( i = 0LL; *(_DWORD *)(loglist + 12) > (int)i; result = loglist )
{
v4 = *(_QWORD *)(*(_QWORD *)result + 8 * i++);
fprintf(stderr, "%s\n", (const char *)(v4 + 1));
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(const char *a1, char **a2)
{
__int64 result; // rax
__int64 i; // rbx
__int64 v4; // rdx
int v5; // ebp
__int64 v6; // rdx
__int64 v7; // rcx
__int64 v8; // r8
int v9; // er13
unsigned int v10; // ebx
__int64 v11; // r12
int v12; // eax
__int64 v13; // r14
const char *v14; // [rsp-10h] [rbp-48h]
__int64 v15; // [rsp-8h] [rbp-40h]
char *endptr[6]; // [rsp+8h] [rbp-30h] BYREF

if ( (unsigned int)is_fb_available() )
{
*((_BYTE *)&sbstr + 10) = 0;
v5 = 0;
sbstr = 0x7765697620676F6CLL;
*((_WORD *)&sbstr + 4) = 29285;
do
{
clear_screen();
v9 = v5;
v10 = 48;
v11 = 8LL * v5;
do
{
if ( *(_DWORD *)(loglist + 12) <= v9 )
break;
a1 = *(const char **)(*(_QWORD *)loglist + v11);
if ( a1 )
{
a2 = endptr;
v12 = strtol(a1, endptr, 10);
if ( endptr[0] )
{
if ( v12 > 3 )
v12 = 3;
if ( v12 < 0 )
v12 = 0;
v13 = (unsigned int)logpalette[v12];
fill_rect(0LL, v10, 1024LL, 16LL, v13);
a2 = 0LL;
text(endptr[0], 0LL, v10, 1LL, 1LL, 0xFFFFFFFFLL, v13);
a1 = v14;
v8 = v15;
}
}
v10 += 16;
++v9;
v11 += 8LL;
}
while ( v10 != 768 );
update_screen(a1, a2, v6, v7, v8);
input_read();
a2 = (char **)diff_input[3];
if ( (_DWORD)a2 )
{
if ( v5 <= 15 )
{
a1 = (_BYTE *)&loc_28;
vibrate(40LL);
}
else
{
v5 -= 16;
}
}
if ( diff_input[4] )
{
if ( *(_DWORD *)(loglist + 12) - 16 <= v5 )
{
a1 = (_BYTE *)&loc_28;
vibrate(40LL);
}
else
{
v5 += 16;
}
}
if ( diff_input[2] )
{
result = (unsigned int)(*(_DWORD *)(loglist + 12) - 45);
if ( (int)result <= v5 )
return result;
v5 += 45;
}
result = diff_input[5];
}
while ( !(_DWORD)result );
}
else
{
result = loglist;
for ( i = 0LL; *(_DWORD *)(loglist + 12) > (int)i; result = loglist )
{
v4 = *(_QWORD *)(*(_QWORD *)result + 8 * i++);
fprintf(stderr, "%s\n", (const char *)(v4 + 1));
}
}
return result;
}

original_code:
void display_wholelog(void) {
 char *str;
 int loglevel = 0, logindex = 0;
 if (is_fb_available()) {
  int start = 0;
  int done = 0;
  const int lines_per_page = 768 / 16 - 3;
  const int button_scroll = 16;
  strcpy(sbstr, "log viewer");
  while (!done) {
   clear_screen();
   for (int i = 0; i < lines_per_page; ++i) {
    logindex = start + i;
    if (logindex >= loglist->used) break;
    if (loglist->data[logindex] == ((void *)0)) continue;
    loglevel = (int)strtol(loglist->data[logindex], &str, 10);
    if (str == ((void *)0)) continue;
    if (loglevel < 0) loglevel = 0;
    else if (loglevel > 3) loglevel = 3;
    fill_rect(0, i*16+48, 1024, 16, logpalette[loglevel]);
    text(str, 0, i*16+48, 1, 1, 0xFFFFFFFF, logpalette[loglevel]);
   }
   update_screen();
   input_read();
   if (diff_input.vol_up) {
    if (start >= button_scroll) {
     start -= button_scroll;
    } else {
     vibrate(40);
    }
   }
   if (diff_input.vol_down) {
    if (start < loglist->used - button_scroll) {
     start += button_scroll;
    } else {
     vibrate(40);
    }
   }
   if (diff_input.touch) {
    if (start < loglist->used - lines_per_page) {
     start += lines_per_page;
    } else {
     done = 1;
    }
   }
   if (diff_input.center)
    done = 1;
  }
 } else {
  for (int i = 0; i < loglist->used; ++i)
   fprintf(stderr, "%s\n", loglist->data[i]+1);
 }
}

canonical_original_code:
void display_wholelog() {
 char *str;
 int loglevel = 0; int logindex = 0;
 if (is_fb_available()) {
  int start = 0;
  int done = 0;
  int lines_per_page = 768 / 16 - 3;
  int button_scroll = 16;
  strcpy(sbstr, "log viewer");
  while (!done) {
   clear_screen();
   for (int i = 0; i < lines_per_page; ++i) {
    logindex = start + i;
    if (logindex >= loglist->used) break;
    if (loglist->data[logindex] == ((void *)0)) continue;
    loglevel = (int)strtol(loglist->data[logindex], &str, 10);
    if (str == ((void *)0)) continue;
    if (loglevel < 0) loglevel = 0;
    else if (loglevel > 3) loglevel = 3;
    fill_rect(0, i*16+48, 1024, 16, logpalette[loglevel]);
    text(str, 0, i*16+48, 1, 1, 0xFFFFFFFF, logpalette[loglevel]);
   }
   update_screen();
   input_read();
   if (diff_input.vol_up) {
    if (start >= button_scroll) {
     start -= button_scroll;
    } else {
     vibrate(40);
    }
   }
   if (diff_input.vol_down) {
    if (start < loglist->used - button_scroll) {
     start += button_scroll;
    } else {
     vibrate(40);
    }
   }
   if (diff_input.touch) {
    if (start < loglist->used - lines_per_page) {
     start += lines_per_page;
    } else {
     done = 1;
    }
   }
   if (diff_input.center)
    done = 1;
  }
 } else {
  for (int i = 0; i < loglist->used; ++i)
   fprintf(stderr, "%s\n", loglist->data[i]+1);
 }
}

variable_types: start int

variable_types: done int


decompiled_code:
__int64 __fastcall install_native(const char *a1, const char *a2, int a3)
{
const char *v3; // r12
int *v6; // rax
char *v7; // rax
char v8[4120]; // [rsp+0h] [rbp-1018h] BYREF

v3 = a2;
logprintf("0installing new native Linux distro to %s", a2);
if ( !a2 )
v3 = (const char *)deduce_lv(a1);
if ( (unsigned int)lv_exists(v3) )
{
umount_lv(v3);
if ( a3 == -1 )
goto LABEL_7;
}
else
{
if ( a3 <= 0 )
return logprintf("2volume does not exist");
new_lv(v3, a3);
umount_lv(v3);
}
wipe_lv(v3);
LABEL_7:
mount_lv(v3);
snprintf(v8, 0x1000uLL, "/mnt/%s", v3);
if ( chdir(v8) == -1 )
{
v6 = _errno_location();
v7 = strerror(*v6);
logprintf("2%s: %s", "can't chdir into target root", v7);
}
logprintf("0extracting .tar.gz file, this may take 10+ minutes");
return sysprintf("tar -xzpf %s", a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, const char *a2, int a3)
{
const char *v3; // r12
int *v6; // rax
char *v7; // rax
char v8[4120]; // [rsp+0h] [rbp-1018h] BYREF

v3 = a2;
logprintf("0installing new native Linux distro to %s", a2);
if ( !a2 )
v3 = (const char *)deduce_lv(a1);
if ( (unsigned int)lv_exists(v3) )
{
umount_lv(v3);
if ( a3 == -1 )
goto LABEL_7;
}
else
{
if ( a3 <= 0 )
return logprintf("2volume does not exist");
new_lv(v3, a3);
umount_lv(v3);
}
wipe_lv(v3);
LABEL_7:
mount_lv(v3);
snprintf(v8, 0x1000uLL, "/mnt/%s", v3);
if ( chdir(v8) == -1 )
{
v6 = _errno_location();
v7 = strerror(*v6);
logprintf("2%s: %s", "can't chdir into target root", v7);
}
logprintf("0extracting .tar.gz file, this may take 10+ minutes");
return sysprintf("tar -xzpf %s", a1);
}

original_code:
void install_native(const char *tarname, const char *lv, int size) {
 char cmd[4096];
 int code;
 logprintf("0installing new native Linux distro to %s", lv);
 if (lv == ((void *)0)) lv = deduce_lv(tarname);
 if (!lv_exists(lv)) {
  if (size > 0) new_lv(lv, size);
  else {
   logprintf("2volume does not exist");
   return;
  }
 }
 umount_lv(lv);
 if (size != -1) wipe_lv(lv);
 mount_lv(lv);
 snprintf(cmd, sizeof(cmd), "/mnt/%s", lv);
 if (chdir(cmd) == -1)
  logprintf("2%s: %s", "can't chdir into target root", strerror((*__errno_location ())));
 logprintf("0extracting .tar.gz file, this may take 10+ minutes");
 sysprintf("tar -xzpf %s", tarname);
}

canonical_original_code:
void install_native(char *tarname, char *lv, int size) {
 char cmd[4096];
 int code;
 logprintf("0installing new native Linux distro to %s", lv);
 if (lv == ((void *)0)) lv = deduce_lv(tarname);
 if (!lv_exists(lv)) {
  if (size > 0) new_lv(lv, size);
  else {
   logprintf("2volume does not exist");
   return;
  }
 }
 umount_lv(lv);
 if (size != -1) wipe_lv(lv);
 mount_lv(lv);
 snprintf(cmd, sizeof(cmd), "/mnt/%s", lv);
 if (chdir(cmd) == -1)
  logprintf("2%s: %s", "can't chdir into target root", strerror((*__errno_location ())));
 logprintf("0extracting .tar.gz file, this may take 10+ minutes");
 sysprintf("tar -xzpf %s", tarname);
}

variable_types:
tarname
char *

variable_types:
lv
char *

variable_types: size int

variable_types:
cmd
char [4096]

variable_types: code int


decompiled_code:
int __fastcall install_android(const char *a1, const char *a2, char a3)
{
const char *v3; // rbp
int result; // eax
int *v6; // rax
char *v7; // rax
int *v8; // rax
char *v9; // rax
int *v10; // rax
char *v11; // rax
int *v12; // rax
char *v13; // rax
int *v14; // rax
char *v15; // rax
unsigned int v16; // [rsp+4h] [rbp-2024h] BYREF
unsigned int v17; // [rsp+8h] [rbp-2020h] BYREF
unsigned int v18; // [rsp+Ch] [rbp-201Ch] BYREF
char s[4096]; // [rsp+10h] [rbp-2018h] BYREF
char buf[4120]; // [rsp+1010h] [rbp-1018h] BYREF

v3 = a2;
logprintf("0installing to %s from file %s", a2, a1);
if ( !a2 )
v3 = (const char *)deduce_lv_set(a1);
umount_lv_set(v3);
snprintf(s, 0x1000uLL, "%s-data", v3);
if ( !(unsigned int)lv_exists(s) )
{
a3 |= 7u;
deduce_lv_set_size(v3, &v16, &v17, &v18);
new_lv_set(v3, v16, v17, v18);
}
if ( (a3 & 2) != 0 )
wipe_lv(s);
if ( (a3 & 1) != 0 )
{
snprintf(s, 0x1000uLL, "%s-system", v3);
wipe_lv(s);
}
if ( (a3 & 4) != 0 )
{
snprintf(s, 0x1000uLL, "%s-cache", v3);
wipe_lv(s);
}
mount_lv_set(v3);
if ( !getcwd(buf, 0x1000uLL) )
{
v10 = _errno_location();
v11 = strerror(*v10);
logprintf("2%s: %s", "getcwd", v11);
}
snprintf(s, 0x1000uLL, "/mnt/%s", v3);
if ( chdir(s) == -1 )
{
v6 = _errno_location();
v7 = strerror(*v6);
logprintf("2%s: %s", "chdir into root of new install", v7);
}
logprintf("0extracting zip file");
sysprintf("unzip -qo %s", a1);
snprintf(s, 0x1000uLL, "/mnt/%s/system/etc/firmware/q6.mdt", v3);
if ( !(unsigned int)test_file(s) )
{
mount_lv("firmware");
logprintf("0copying firmware");
sysprintf("cp /mnt/firmware/IMAGE/* /mnt/%s/system/etc/firmware", v3);
}
logprintf("0converting updater script");
system_logged(update_str);
logprintf("0running updater script");
if ( !(unsigned int)is_lv_mounted("root") )
mount_lv("root");
chmod("updatescript", 0x1EDu);
system_logged("bash updatescript");
snprintf(s, 0x1000uLL, "/mnt/%s/boot.img", v3);
if ( (unsigned int)test_file(s) && (a3 & 8) != 0 )
{
snprintf(s, 0x1000uLL, "/mnt/%s/moboot.splash.CyanogenMod.tga", v3);
if ( (unsigned int)test_file(s) )
{
logprintf("0installing moboot splash");
sysprintf("cp moboot.splash.CyanogenMod.tga /mnt/boot/moboot.splash.%s.tga", v3);
}
logprintf("0patching uImage");
system_logged("uimage-extract boot.img");
system_logged("mv ramdisk.img ramdisk.gz");
system_logged("gunzip ramdisk.gz");
mkdir("extracted", 0x1EDu);
if ( chdir("extracted") == -1 )
{
v12 = _errno_location();
v13 = strerror(*v12);
logprintf("2%s: %s", "error changing directory into extraction area", v13);
}
system_logged("cpio -i < ../ramdisk");
sysprintf(
"sed -i -e 's/cm-system/%s-system/' -e 's/cm-data/%s-data/' -e 's/cm-cache/%s-cache/' init.tenderloin.rc",
v3,
v3,
v3);
system_logged("find . | cpio -o --format=newc | lzma > ../ramdisk");
if ( chdir("..") == -1 )
{
v14 = _errno_location();
v15 = strerror(*v14);
logprintf("2%s: %s", "changing into parent directory failed", v15);
}
system_logged("mkimage -A arm -O linux -T kernel -C none -a 0x40208000 -e 0x40208000 -n kernel -d kernel.img uKernel");
system_logged(
"mkimage -A arm -O linux -T ramdisk -C none -a 0x60000000 -e 0x60000000 -n nsboot_patched_ramdisk -d ramdisk uRamdisk");
system_logged(
"mkimage -A arm -O linux -T multi -C none -a 0x40208000 -e 0x40208000 -n nsboot_patched_multi -d uKernel:uRamdisk uImage");
sysprintf("mv uImage /mnt/boot/uImage.%s", v3);
unlink("kernel.img");
unlink("ramdisk");
unlink("uImage");
}
result = chdir(buf);
if ( result == -1 )
{
v8 = _errno_location();
v9 = strerror(*v8);
result = logprintf("2%s: %s", "restoration of working directory failed", v9);
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(const char *a1, const char *a2, char a3)
{
const char *v3; // rbp
int result; // eax
int *v6; // rax
char *v7; // rax
int *v8; // rax
char *v9; // rax
int *v10; // rax
char *v11; // rax
int *v12; // rax
char *v13; // rax
int *v14; // rax
char *v15; // rax
unsigned int v16; // [rsp+4h] [rbp-2024h] BYREF
unsigned int v17; // [rsp+8h] [rbp-2020h] BYREF
unsigned int v18; // [rsp+Ch] [rbp-201Ch] BYREF
char s[4096]; // [rsp+10h] [rbp-2018h] BYREF
char buf[4120]; // [rsp+1010h] [rbp-1018h] BYREF

v3 = a2;
logprintf("0installing to %s from file %s", a2, a1);
if ( !a2 )
v3 = (const char *)deduce_lv_set(a1);
umount_lv_set(v3);
snprintf(s, 0x1000uLL, "%s-data", v3);
if ( !(unsigned int)lv_exists(s) )
{
a3 |= 7u;
deduce_lv_set_size(v3, &v16, &v17, &v18);
new_lv_set(v3, v16, v17, v18);
}
if ( (a3 & 2) != 0 )
wipe_lv(s);
if ( (a3 & 1) != 0 )
{
snprintf(s, 0x1000uLL, "%s-system", v3);
wipe_lv(s);
}
if ( (a3 & 4) != 0 )
{
snprintf(s, 0x1000uLL, "%s-cache", v3);
wipe_lv(s);
}
mount_lv_set(v3);
if ( !getcwd(buf, 0x1000uLL) )
{
v10 = _errno_location();
v11 = strerror(*v10);
logprintf("2%s: %s", "getcwd", v11);
}
snprintf(s, 0x1000uLL, "/mnt/%s", v3);
if ( chdir(s) == -1 )
{
v6 = _errno_location();
v7 = strerror(*v6);
logprintf("2%s: %s", "chdir into root of new install", v7);
}
logprintf("0extracting zip file");
sysprintf("unzip -qo %s", a1);
snprintf(s, 0x1000uLL, "/mnt/%s/system/etc/firmware/q6.mdt", v3);
if ( !(unsigned int)test_file(s) )
{
mount_lv("firmware");
logprintf("0copying firmware");
sysprintf("cp /mnt/firmware/IMAGE/* /mnt/%s/system/etc/firmware", v3);
}
logprintf("0converting updater script");
system_logged(update_str);
logprintf("0running updater script");
if ( !(unsigned int)is_lv_mounted("root") )
mount_lv("root");
chmod("updatescript", 0x1EDu);
system_logged("bash updatescript");
snprintf(s, 0x1000uLL, "/mnt/%s/boot.img", v3);
if ( (unsigned int)test_file(s) && (a3 & 8) != 0 )
{
snprintf(s, 0x1000uLL, "/mnt/%s/moboot.splash.CyanogenMod.tga", v3);
if ( (unsigned int)test_file(s) )
{
logprintf("0installing moboot splash");
sysprintf("cp moboot.splash.CyanogenMod.tga /mnt/boot/moboot.splash.%s.tga", v3);
}
logprintf("0patching uImage");
system_logged("uimage-extract boot.img");
system_logged("mv ramdisk.img ramdisk.gz");
system_logged("gunzip ramdisk.gz");
mkdir("extracted", 0x1EDu);
if ( chdir("extracted") == -1 )
{
v12 = _errno_location();
v13 = strerror(*v12);
logprintf("2%s: %s", "error changing directory into extraction area", v13);
}
system_logged("cpio -i < ../ramdisk");
sysprintf(
"sed -i -e 's/cm-system/%s-system/' -e 's/cm-data/%s-data/' -e 's/cm-cache/%s-cache/' init.tenderloin.rc",
v3,
v3,
v3);
system_logged("find . | cpio -o --format=newc | lzma > ../ramdisk");
if ( chdir("..") == -1 )
{
v14 = _errno_location();
v15 = strerror(*v14);
logprintf("2%s: %s", "changing into parent directory failed", v15);
}
system_logged("mkimage -A arm -O linux -T kernel -C none -a 0x40208000 -e 0x40208000 -n kernel -d kernel.img uKernel");
system_logged(
"mkimage -A arm -O linux -T ramdisk -C none -a 0x60000000 -e 0x60000000 -n nsboot_patched_ramdisk -d ramdisk uRamdisk");
system_logged(
"mkimage -A arm -O linux -T multi -C none -a 0x40208000 -e 0x40208000 -n nsboot_patched_multi -d uKernel:uRamdisk uImage");
sysprintf("mv uImage /mnt/boot/uImage.%s", v3);
unlink("kernel.img");
unlink("ramdisk");
unlink("uImage");
}
result = chdir(buf);
if ( result == -1 )
{
v8 = _errno_location();
v9 = strerror(*v8);
result = logprintf("2%s: %s", "restoration of working directory failed", v9);
}
return result;
}

original_code:
void install_android(const char *zipname, const char *base, int flags) {
 char cmd[4096], pwd[4096];
 int sys, dat, cac;
 int code;
 logprintf("0installing to %s from file %s", base, zipname);
 if (base == ((void *)0)) base = deduce_lv_set(zipname);
 umount_lv_set(base);
 snprintf(cmd, sizeof(cmd), "%s-data", base);
 if (!lv_exists(cmd)) {
  deduce_lv_set_size(base, &sys, &dat, &cac);
  new_lv_set(base, sys, dat, cac);
  flags |= 0x01 | 0x02 | 0x04;
 }
 if (flags & 0x02)
  wipe_lv(cmd);
 if (flags & 0x01) {
  snprintf(cmd, sizeof(cmd), "%s-system", base);
  wipe_lv(cmd);
 }
 if (flags & 0x04) {
  snprintf(cmd, sizeof(cmd), "%s-cache", base);
  wipe_lv(cmd);
 }
 mount_lv_set(base);
 if (getcwd(pwd, 4096) == ((void *)0))
  logprintf("2%s: %s", "getcwd", strerror((*__errno_location ())));
 snprintf(cmd, sizeof(cmd), "/mnt/%s", base);
 if (chdir(cmd) == -1)
  logprintf("2%s: %s", "chdir into root of new install", strerror((*__errno_location ())));
 logprintf("0extracting zip file");
 sysprintf("unzip -qo %s", zipname);
 snprintf(cmd, sizeof(cmd), "/mnt/%s/system/etc/firmware/q6.mdt", base);
 if (!test_file(cmd)) {
  mount_lv("firmware");
  logprintf("0copying firmware");
  sysprintf("cp /mnt/firmware/IMAGE/* /mnt/%s/system/etc/firmware",
   base);
 }
 logprintf("0converting updater script");
 system_logged(update_str);
 logprintf("0running updater script");
 if (!is_lv_mounted("root")) mount_lv("root");
 chmod("updatescript", 0755);
 system_logged("bash updatescript");
 snprintf(cmd, sizeof(cmd), "/mnt/%s/boot.img", base);
 if (test_file(cmd) && (flags & 0x08)) {
  snprintf(cmd, sizeof(cmd),
   "/mnt/%s/moboot.splash.CyanogenMod.tga", base);
  if (test_file(cmd)) {
   logprintf("0installing moboot splash");
   sysprintf("cp moboot.splash.CyanogenMod.tga "
    "/mnt/boot/moboot.splash.%s.tga",
    base);
  }
  logprintf("0patching uImage");
  system_logged("uimage-extract boot.img");
  system_logged("mv ramdisk.img ramdisk.gz");
  system_logged("gunzip ramdisk.gz");
  mkdir("extracted", 0755);
  if (chdir("extracted") == -1)
   logprintf("2%s: %s", "error changing directory into extraction " " area", strerror((*__errno_location ())));
  system_logged("cpio -i < ../ramdisk");
  sysprintf("sed -i -e 's/cm-system/%s-system/'"
   " -e 's/cm-data/%s-data/' -e 's/cm-cache/%s-cache/' "
   "init.tenderloin.rc", base, base, base);
  system_logged("find . | cpio -o --format=newc | lzma > ../ramdisk");
  if (chdir("..") == -1)
   logprintf("2%s: %s", "changing into parent directory failed", strerror((*__errno_location ())));
  system_logged("mkimage -A arm -O linux -T kernel -C none "
   "-a 0x40208000 -e 0x40208000 -n kernel -d kernel.img "
   "uKernel");
  system_logged("mkimage -A arm -O linux -T ramdisk -C none "
   "-a 0x60000000 -e 0x60000000 -n nsboot_patched_ramdisk "
   "-d ramdisk uRamdisk");
  system_logged("mkimage -A arm -O linux -T multi -C none "
   "-a 0x40208000 -e 0x40208000 -n nsboot_patched_multi "
   "-d uKernel:uRamdisk uImage");
  sysprintf("mv uImage /mnt/boot/uImage.%s", base);
  unlink("kernel.img");
  unlink("ramdisk");
  unlink("uImage");
 }
 if (chdir(pwd) == -1) logprintf("2%s: %s", "restoration of working directory failed", strerror((*__errno_location ())));
}

canonical_original_code:
void install_android(char *zipname, char *base, int flags) {
 char cmd[4096]; char pwd[4096];
 int sys; int dat; int cac;
 int code;
 logprintf("0installing to %s from file %s", base, zipname);
 if (base == ((void *)0)) base = deduce_lv_set(zipname);
 umount_lv_set(base);
 snprintf(cmd, sizeof(cmd), "%s-data", base);
 if (!lv_exists(cmd)) {
  deduce_lv_set_size(base, &sys, &dat, &cac);
  new_lv_set(base, sys, dat, cac);
  flags |= 0x01 | 0x02 | 0x04;
 }
 if (flags & 0x02)
  wipe_lv(cmd);
 if (flags & 0x01) {
  snprintf(cmd, sizeof(cmd), "%s-system", base);
  wipe_lv(cmd);
 }
 if (flags & 0x04) {
  snprintf(cmd, sizeof(cmd), "%s-cache", base);
  wipe_lv(cmd);
 }
 mount_lv_set(base);
 if (getcwd(pwd, 4096) == ((void *)0))
  logprintf("2%s: %s", "getcwd", strerror((*__errno_location ())));
 snprintf(cmd, sizeof(cmd), "/mnt/%s", base);
 if (chdir(cmd) == -1)
  logprintf("2%s: %s", "chdir into root of new install", strerror((*__errno_location ())));
 logprintf("0extracting zip file");
 sysprintf("unzip -qo %s", zipname);
 snprintf(cmd, sizeof(cmd), "/mnt/%s/system/etc/firmware/q6.mdt", base);
 if (!test_file(cmd)) {
  mount_lv("firmware");
  logprintf("0copying firmware");
  sysprintf("cp /mnt/firmware/IMAGE/* /mnt/%s/system/etc/firmware",
   base);
 }
 logprintf("0converting updater script");
 system_logged(update_str);
 logprintf("0running updater script");
 if (!is_lv_mounted("root")) mount_lv("root");
 chmod("updatescript", 0755);
 system_logged("bash updatescript");
 snprintf(cmd, sizeof(cmd), "/mnt/%s/boot.img", base);
 if (test_file(cmd) && (flags & 0x08)) {
  snprintf(cmd, sizeof(cmd),
   "/mnt/%s/moboot.splash.CyanogenMod.tga", base);
  if (test_file(cmd)) {
   logprintf("0installing moboot splash");
   sysprintf("cp moboot.splash.CyanogenMod.tga "
    "/mnt/boot/moboot.splash.%s.tga",
    base);
  }
  logprintf("0patching uImage");
  system_logged("uimage-extract boot.img");
  system_logged("mv ramdisk.img ramdisk.gz");
  system_logged("gunzip ramdisk.gz");
  mkdir("extracted", 0755);
  if (chdir("extracted") == -1)
   logprintf("2%s: %s", "error changing directory into extraction " " area", strerror((*__errno_location ())));
  system_logged("cpio -i < ../ramdisk");
  sysprintf("sed -i -e 's/cm-system/%s-system/'"
   " -e 's/cm-data/%s-data/' -e 's/cm-cache/%s-cache/' "
   "init.tenderloin.rc", base, base, base);
  system_logged("find . | cpio -o --format=newc | lzma > ../ramdisk");
  if (chdir("..") == -1)
   logprintf("2%s: %s", "changing into parent directory failed", strerror((*__errno_location ())));
  system_logged("mkimage -A arm -O linux -T kernel -C none "
   "-a 0x40208000 -e 0x40208000 -n kernel -d kernel.img "
   "uKernel");
  system_logged("mkimage -A arm -O linux -T ramdisk -C none "
   "-a 0x60000000 -e 0x60000000 -n nsboot_patched_ramdisk "
   "-d ramdisk uRamdisk");
  system_logged("mkimage -A arm -O linux -T multi -C none "
   "-a 0x40208000 -e 0x40208000 -n nsboot_patched_multi "
   "-d uKernel:uRamdisk uImage");
  sysprintf("mv uImage /mnt/boot/uImage.%s", base);
  unlink("kernel.img");
  unlink("ramdisk");
  unlink("uImage");
 }
 if (chdir(pwd) == -1) logprintf("2%s: %s", "restoration of working directory failed", strerror((*__errno_location ())));
}

variable_types:
zipname
char *

variable_types:
base
char *

variable_types: flags int

variable_types:
pwd
char [4096]

variable_types: sys int

variable_types: dat int

variable_types: cac int


decompiled_code:
__int64 __fastcall delete_lv_set(const char *a1)
{
char v2[40]; // [rsp+0h] [rbp-28h] BYREF

logprintf("0deleting volume set %s", a1);
snprintf(v2, 0x20uLL, "%s-system", a1);
delete_lv(v2);
snprintf(v2, 0x20uLL, "%s-data", a1);
delete_lv(v2);
snprintf(v2, 0x20uLL, "%s-cache", a1);
return delete_lv(v2);
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1)
{
char v2[40]; // [rsp+0h] [rbp-28h] BYREF

logprintf("0deleting volume set %s", a1);
snprintf(v2, 0x20uLL, "%s-system", a1);
delete_lv(v2);
snprintf(v2, 0x20uLL, "%s-data", a1);
delete_lv(v2);
snprintf(v2, 0x20uLL, "%s-cache", a1);
return delete_lv(v2);
}

original_code:
void delete_lv_set(const char *set) {
 char lv[32];
 logprintf("0deleting volume set %s", set);
 snprintf(lv, sizeof(lv), "%s-system", set);
 delete_lv(lv);
 snprintf(lv, sizeof(lv), "%s-data", set);
 delete_lv(lv);
 snprintf(lv, sizeof(lv), "%s-cache", set);
 delete_lv(lv);
}

canonical_original_code:
void delete_lv_set(char *set) {
 char lv[32];
 logprintf("0deleting volume set %s", set);
 snprintf(lv, sizeof(lv), "%s-system", set);
 delete_lv(lv);
 snprintf(lv, sizeof(lv), "%s-data", set);
 delete_lv(lv);
 snprintf(lv, sizeof(lv), "%s-cache", set);
 delete_lv(lv);
}

variable_types:
set
char *

variable_types:
lv
char [32]


decompiled_code:
char *__fastcall install_uimage(char *s)
{
char *result; // rax
__int64 v2; // rbx
char v3[4120]; // [rsp+0h] [rbp-1018h] BYREF

logprintf("0installing uImage file %s", s);
result = strchr(s, 46);
if ( result )
{
v2 = (__int64)result;
sysprintf("cp %s /mnt/boot", s);
sprintf(v3, "/mnt/boot/moboot.verbose.%s", (const char *)(v2 + 1));
result = (char *)qfprintf(v3, "yes");
}
return result;
}

canonical_decompiled_code:
char *__fastcall func4(char *s)
{
char *result; // rax
__int64 v2; // rbx
char v3[4120]; // [rsp+0h] [rbp-1018h] BYREF

logprintf("0installing uImage file %s", s);
result = strchr(s, 46);
if ( result )
{
v2 = (__int64)result;
sysprintf("cp %s /mnt/boot", s);
sprintf(v3, "/mnt/boot/moboot.verbose.%s", (const char *)(v2 + 1));
result = (char *)qfprintf(v3, "yes");
}
return result;
}

original_code:
void install_uimage(char *file) {
 char cmd[4096];
 int code;
 int verbose_fd;
 char *dot;
 logprintf("0installing uImage file %s", file);
 dot = strchr(file, '.');
 if (dot == ((void *)0)) return;
 ++dot;
 sysprintf("cp %s /mnt/boot", file);
 sprintf(cmd, "/mnt/boot/moboot.verbose.%s", dot);
 qfprintf(cmd, "yes");
 return;
}

variable_types:
file
char *

variable_types:
dot
char *


decompiled_code:
int replace_moboot()
{
int result; // eax
int *v1; // rax
char *v2; // rax
int *v3; // rax
char *v4; // rax

logprintf("0replacing noboot with nsboot");
if ( !(unsigned int)test_file("/mnt/boot/uImage.nsboot") )
return logprintf("2nsboot is not installed in boot");
if ( chdir("/mnt/boot") == -1 )
{
v1 = _errno_location();
v2 = strerror(*v1);
result = logprintf("2%s: %s", "error changing directory to boot", v2);
}
else
{
system_logged("mv uImage uImage.old");
if ( (unsigned int)test_file("uImage") || !(unsigned int)test_file("uImage.old") )
{
logprintf("2relocation of old bootloader failed!");
LABEL_6:
logprintf("3%s", "WARNING: YOU MAY NEED TO USE NOVACOM TO REINSTALL A BOOTLOADER");
return sleep(1u);
}
result = symlink("uImage.nsboot", "uImage");
if ( result == -1 )
{
v3 = _errno_location();
v4 = strerror(*v3);
logprintf("2%s: %s", "error symlinking nsboot as main bootloader!", v4);
goto LABEL_6;
}
}
return result;
}

canonical_decompiled_code:
int func5()
{
int result; // eax
int *v1; // rax
char *v2; // rax
int *v3; // rax
char *v4; // rax

logprintf("0replacing noboot with nsboot");
if ( !(unsigned int)test_file("/mnt/boot/uImage.nsboot") )
return logprintf("2nsboot is not installed in boot");
if ( chdir("/mnt/boot") == -1 )
{
v1 = _errno_location();
v2 = strerror(*v1);
result = logprintf("2%s: %s", "error changing directory to boot", v2);
}
else
{
system_logged("mv uImage uImage.old");
if ( (unsigned int)test_file("uImage") || !(unsigned int)test_file("uImage.old") )
{
logprintf("2relocation of old bootloader failed!");
LABEL_6:
logprintf("3%s", "WARNING: YOU MAY NEED TO USE NOVACOM TO REINSTALL A BOOTLOADER");
return sleep(1u);
}
result = symlink("uImage.nsboot", "uImage");
if ( result == -1 )
{
v3 = _errno_location();
v4 = strerror(*v3);
logprintf("2%s: %s", "error symlinking nsboot as main bootloader!", v4);
goto LABEL_6;
}
}
return result;
}

original_code:
void replace_moboot(void) {
 int code;
 logprintf("0replacing noboot with nsboot");
 if (!test_file("/mnt/boot/uImage.nsboot")) {
  logprintf("2nsboot is not installed in boot");
  return;
 }
 if (chdir("/mnt/boot") == -1) {
  logprintf("2%s: %s", "error changing directory to boot", strerror((*__errno_location ())));
  return;
 }
 system_logged("mv uImage uImage.old");
 if (test_file("uImage") || !test_file("uImage.old")) {
  logprintf("2relocation of old bootloader failed!");
  logprintf("3%s", "WARNING: YOU MAY NEED TO USE NOVACOM TO REINSTALL A BOOTLOADER");
  sleep(1);
  return;
 }
 if (symlink("uImage.nsboot", "uImage") == -1) {
  logprintf("2%s: %s", "error symlinking nsboot as main bootloader!", strerror((*__errno_location ())));
  logprintf("3%s", "WARNING: YOU MAY NEED TO USE NOVACOM TO REINSTALL A BOOTLOADER");
  sleep(1);
 }
}

canonical_original_code:
void replace_moboot() {
 int code;
 logprintf("0replacing noboot with nsboot");
 if (!test_file("/mnt/boot/uImage.nsboot")) {
  logprintf("2nsboot is not installed in boot");
  return;
 }
 if (chdir("/mnt/boot") == -1) {
  logprintf("2%s: %s", "error changing directory to boot", strerror((*__errno_location ())));
  return;
 }
 system_logged("mv uImage uImage.old");
 if (test_file("uImage") || !test_file("uImage.old")) {
  logprintf("2relocation of old bootloader failed!");
  logprintf("3%s", "WARNING: YOU MAY NEED TO USE NOVACOM TO REINSTALL A BOOTLOADER");
  sleep(1);
  return;
 }
 if (symlink("uImage.nsboot", "uImage") == -1) {
  logprintf("2%s: %s", "error symlinking nsboot as main bootloader!", strerror((*__errno_location ())));
  logprintf("3%s", "WARNING: YOU MAY NEED TO USE NOVACOM TO REINSTALL A BOOTLOADER");
  sleep(1);
 }
}


decompiled_code:
void __fastcall free_str_list(void *ptr)
{
_QWORD *v2; // r8
__int64 v3; // rbx
void *v4; // rdi

v2 = *(_QWORD **)ptr;
if ( *((int *)ptr + 3) > 0 )
{
v3 = 0LL;
do
{
v4 = (void *)v2[v3];
if ( v4 )
{
free(v4);
v2 = *(_QWORD **)ptr;
}
++v3;
}
while ( *((_DWORD *)ptr + 3) > (int)v3 );
}
free(v2);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
_QWORD *v2; // r8
__int64 v3; // rbx
void *v4; // rdi

v2 = *(_QWORD **)ptr;
if ( *((int *)ptr + 3) > 0 )
{
v3 = 0LL;
do
{
v4 = (void *)v2[v3];
if ( v4 )
{
free(v4);
v2 = *(_QWORD **)ptr;
}
++v3;
}
while ( *((_DWORD *)ptr + 3) > (int)v3 );
}
free(v2);
free(ptr);
}

original_code:
void free_str_list(str_list *list) {
 for (int i = 0; i < list->used; ++i)
  if (list->data[i] != ((void *)0))
   free(list->data[i]);
 free(list->data);
 free(list);
}

canonical_original_code:
void free_str_list(struct str_list *list) {
 for (int i = 0; i < list->used; ++i)
  if (list->data[i] != ((void *)0))
   free(list->data[i]);
 free(list->data);
 free(list);
}

variable_types: struct str_list { char **data; int size; int used; } *

variable_types: i int


decompiled_code:
__int64 __fastcall append_to_str_list(__int64 a1, const char *a2)
{
int v2; // ebp
int v3; // eax
_QWORD *v4; // r12
int v5; // ebp
_QWORD *v6; // rax
__int64 v7; // rax
char *v8; // r8
__int64 result; // rax

v2 = *(_DWORD *)(a1 + 12);
v3 = *(_DWORD *)(a1 + 8);
v4 = *(_QWORD **)a1;
if ( v2 >= v3 )
{
v5 = 2 * v3;
v6 = realloc(*(void **)a1, 16LL * v3);
v4 = v6;
if ( !v6 )
{
perror("can't realloc string data");
exit(1);
}
*(_QWORD *)a1 = v6;
v7 = *(int *)(a1 + 8);
if ( v5 > (int)v7 )
memset(&v4[v7], 0, 8LL * (unsigned int)(v5 - v7 - 1) + 8);
*(_DWORD *)(a1 + 8) = v5;
v2 = *(_DWORD *)(a1 + 12);
}
v8 = strdup(a2);
result = v2;
v4[v2] = v8;
*(_DWORD *)(a1 + 12) = v2 + 1;
return result;
}

original_code:
void append_to_str_list(str_list *list, char *str) {
 if (list->used >= list->size) {
  int newsize = list->size * 2;
  char **newdata = realloc(list->data, newsize * sizeof(char *));
  if (newdata == ((void *)0)) {
   perror("can't realloc string data");
   exit(1);
  }
  list->data = newdata;
  for (int i = list->size; i < newsize; ++i)
   list->data[i] = ((void *)0);
  list->size = newsize;
 }
 list->data[list->used] = strdup(str);
 ++list->used;
}

canonical_original_code:
void append_to_str_list(struct str_list *list, char *str) {
 if (list->used >= list->size) {
  int newsize = list->size * 2;
  char **newdata = realloc(list->data, newsize * sizeof(char *));
  if (newdata == ((void *)0)) {
   perror("can't realloc string data");
   exit(1);
  }
  list->data = newdata;
  for (int i = list->size; i < newsize; ++i)
   list->data[i] = ((void *)0);
  list->size = newsize;
 }
 list->data[list->used] = strdup(str);
 ++list->used;
}

variable_types:
str
char *

variable_types: newsize int

variable_types:
newdata
char **

user_defined_types: struct str_list { char **data; int size; int used; }


main

canonical_name: main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
*((_BYTE *)&sbstr + 10) = 0;
sbstr = 0x2E676E6964616F6CLL;
*((_WORD *)&sbstr + 4) = 11822;
do_init(argc, argv, envp);
main_menu();
exit(0);
}

original_code:
int main(int argc, char **argv) {
 strcpy(sbstr, "loading...");
 do_init();
 main_menu();
 exit(0);
}

variable_types: argc int

variable_types:
argv
char **

return_type: int


variable_types:
prompt
char *

variable_types: done int

variable_types:
buf
char [12]

return_type: long


typeinit

repo: willghatch/cpslc

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

int_type = (__int64)typecreate(4, 0, 0LL, 0LL, (__int64)"integer");
bool_type = (__int64)typecreate(4, 2, 0LL, 0LL, (__int64)"boolean");
char_type = (__int64)typecreate(4, 1, 0LL, 0LL, (__int64)"char");
str_type = (__int64)typecreate(4, 3, 0LL, 0LL, (__int64)"string");
result = typecreate(0, 6, 0LL, 0LL, (__int64)"undefinded");
undef_type = (__int64)result;
return result;
}

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

int_type = (__int64)typecreate(4, 0, 0LL, 0LL, (__int64)"integer");
bool_type = (__int64)typecreate(4, 2, 0LL, 0LL, (__int64)"boolean");
char_type = (__int64)typecreate(4, 1, 0LL, 0LL, (__int64)"char");
str_type = (__int64)typecreate(4, 3, 0LL, 0LL, (__int64)"string");
result = typecreate(0, 6, 0LL, 0LL, (__int64)"undefinded");
undef_type = (__int64)result;
return result;
}

original_code:
void typeinit (void)
{ int_type = typecreate(4, Integer, ((void *)0), ((void *)0), "integer");
 bool_type = typecreate(4, Boolean, ((void *)0), ((void *)0), "boolean");
 char_type = typecreate(4, Char, ((void *)0), ((void *)0), "char");
 str_type = typecreate(4, String, ((void *)0), ((void *)0), "string");
 undef_type = typecreate(0, UndefinedType, ((void *)0), ((void *)0), "undefinded");
}

canonical_original_code:
void typeinit()
{ int_type = typecreate(4, Integer, ((void *)0), ((void *)0), "integer");
 bool_type = typecreate(4, Boolean, ((void *)0), ((void *)0), "boolean");
 char_type = typecreate(4, Char, ((void *)0), ((void *)0), "char");
 str_type = typecreate(4, String, ((void *)0), ((void *)0), "string");
 undef_type = typecreate(0, UndefinedType, ((void *)0), ((void *)0), "undefinded");
}


getTypeName

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

if ( !a1 )
return "void";
result = *(const char **)(a1 + 8);
if ( !result )
result = "unnamed-type";
return result;
}

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

if ( !a1 )
return "void";
result = *(const char **)(a1 + 8);
if ( !result )
result = "unnamed-type";
return result;
}

original_code:
char* getTypeName(TYPE* type) {
    if (type == ((void *)0)) {
        return "void";
    }
    if (type->ty_name == ((void *)0)) {
        return "unnamed-type";
    }
    return type->ty_name;
}

canonical_original_code:
char *getTypeName(struct type_info *type) {
    if (type == ((void *)0)) {
        return "void";
    }
    if (type->ty_name == ((void *)0)) {
        return "unnamed-type";
    }
    return type->ty_name;
}

variable_types: struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct { struct type_info *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct { struct slist_struct { struct slist_struct *next; void *data; } *head; struct slist_struct *tail; } *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *funcCall; struct expression_struct *innerExpr; } edata; } *const_expr; struct slist_struct *typedIdentLists; int param_size; int pointer_p; } *FirstField; } ty_record; } ty_form; } *

user_defined_types: struct type_info { int ty_size; char *ty_name; enum type_kind ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info *FirstField; } ty_record; } ty_form; }

user_defined_types: struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info *id_type; enum identifier_kind id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct *const_expr; struct slist_struct *typedIdentLists; int param_size; int pointer_p; }

user_defined_types: struct expression_struct { struct type_info *type; enum expr_kind_enum kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum op; } opdata; int reg_number; struct id_info *id; struct stmt_struct *funcCall; struct expression_struct *innerExpr; } edata; }

user_defined_types: struct stmt_struct { enum stmt_type_enum type; union { struct htslist_struct *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; }

user_defined_types: struct htslist_struct { struct slist_struct *head; struct slist_struct *tail; }

user_defined_types: struct conditional_struct { struct expression_struct *condition; enum BranchType_enum branchType; struct htslist_struct *statements; }


getIdKindName

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

result = "Unknown Kind";
if ( a1 <= 6 )
result = CSWTCH_28[a1];
return result;
}

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

result = "Unknown Kind";
if ( a1 <= 6 )
result = CSWTCH_28[a1];
return result;
}

original_code:
char* getIdKindName(ID_KIND kind) {
    switch(kind) {
        case Constant_id:
            return "Constant";
        case Type:
            return "Type";
        case Variable:
            return "Variable";
        case Procedure:
            return "Procedure";
        case Function:
            return "Function";
        default:
            return "Unknown Kind";
    }
}

canonical_original_code:
char *getIdKindName(enum identifier_kind kind) {
    switch(kind) {
        case Constant_id:
            return "Constant";
        case Type:
            return "Type";
        case Variable:
            return "Variable";
        case Procedure:
            return "Procedure";
        case Function:
            return "Function";
        default:
            return "Unknown Kind";
    }
}

variable_types: enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 }


IDsearch

decompiled_code:
__int64 __fastcall IDsearch(char *s1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rax
int v4; // eax
bool v5; // sf

if ( !a2 )
return 0LL;
v2 = a2;
do
{
v4 = strcmp(s1, *(const char **)v2);
v5 = v4 < 0;
if ( !v4 )
return v2;
v3 = *(_QWORD *)(v2 + 40);
if ( !v5 )
v3 = *(_QWORD *)(v2 + 48);
v2 = v3;
}
while ( v3 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *s1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rax
int v4; // eax
bool v5; // sf

if ( !a2 )
return 0LL;
v2 = a2;
do
{
v4 = strcmp(s1, *(const char **)v2);
v5 = v4 < 0;
if ( !v4 )
return v2;
v3 = *(_QWORD *)(v2 + 40);
if ( !v5 )
v3 = *(_QWORD *)(v2 + 48);
v2 = v3;
}
while ( v3 );
return 0LL;
}

original_code:
ID *IDsearch (char *name, ID *table)
{ int temp;
 if (table == ((void *)0))
  return(((void *)0));
 temp = strcmp(name, table->id_name);
 if (temp == 0)
  return(table);
 else if (temp < 0)
  return(IDsearch(name, table->id_left));
 else
  return(IDsearch(name, table->id_right));
}

canonical_original_code:
struct id_info *IDsearch(char *name, struct id_info *table)
{ int temp;
 if (table == ((void *)0))
  return(((void *)0));
 temp = strcmp(name, table->id_name);
 if (temp == 0)
  return(table);
 else if (temp < 0)
  return(IDsearch(name, table->id_left));
 else
  return(IDsearch(name, table->id_right));
}

variable_types:
name
char *

variable_types:
table
struct id_info *

variable_types: temp int

return_type: struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info *FirstField; } ty_record; } ty_form; } *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct { struct type_info *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct { struct slist_struct { struct slist_struct *next; void *data; } *head; struct slist_struct *tail; } *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *funcCall; struct expression_struct *innerExpr; } edata; } *const_expr; struct slist_struct *typedIdentLists; int param_size; int pointer_p; } *


scopeLookup

decompiled_code:
__int64 __fastcall scopeLookup(char *s1)
{
__int64 v1; // rbx
__int64 result; // rax

v1 = currscope;
if ( currscope < 0 )
return 0LL;
do
{
result = IDsearch(s1, scope[v1]);
if ( result )
break;
--v1;
}
while ( (int)v1 >= 0 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(char *s1)
{
__int64 v1; // rbx
__int64 result; // rax

v1 = currscope;
if ( currscope < 0 )
return 0LL;
do
{
result = func3(s1, scope[v1]);
if ( result )
break;
--v1;
}
while ( (int)v1 >= 0 );
return result;
}

original_code:
ID* scopeLookup(char* name) {
    ID* id;
    for (int i = currscope; i >= 0; --i) {
        id = IDsearch(name, scope[i]);
        if(id) {
            return id;
        }
    }
    return ((void *)0);
}

canonical_original_code:
struct id_info *scopeLookup(char *name) {
    struct id_info *id;
    for (int i = currscope; i >= 0; --i) {
        id = IDsearch(name, scope[i]);
        if(id) {
            return id;
        }
    }
    return ((void *)0);
}

variable_types: struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info *FirstField; } ty_record; } ty_form; } *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct { struct type_info *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct { struct slist_struct { struct slist_struct *next; void *data; } *head; struct slist_struct *tail; } *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *funcCall; struct expression_struct *innerExpr; } edata; } *const_expr; struct slist_struct *typedIdentLists; int param_size; int pointer_p; } *


decompiled_code:
void __fastcall addIdToTable_noAddrMove(const char **a1, const char ***a2)
{
const char **v2; // rbx
const char *v3; // rbp
int v4; // eax

v2 = *a2;
if ( !*a2 )
{
LABEL_7:
*a2 = a1;
return;
}
v3 = *a1;
while ( 1 )
{
v4 = strcmp(v3, *v2);
a2 = (const char ***)(v2 + 5);
if ( v4 >= 0 )
break;
LABEL_6:
v2 = *a2;
if ( !*a2 )
goto LABEL_7;
}
if ( v4 )
{
a2 = (const char ***)(v2 + 6);
goto LABEL_6;
}
printf("Error - symbol %s defined twice in the same scope\n", v3);
}

canonical_decompiled_code:
void __fastcall func5(const char **a1, const char ***a2)
{
const char **v2; // rbx
const char *v3; // rbp
int v4; // eax

v2 = *a2;
if ( !*a2 )
{
LABEL_7:
*a2 = a1;
return;
}
v3 = *a1;
while ( 1 )
{
v4 = strcmp(v3, *v2);
a2 = (const char ***)(v2 + 5);
if ( v4 >= 0 )
break;
LABEL_6:
v2 = *a2;
if ( !*a2 )
goto LABEL_7;
}
if ( v4 )
{
a2 = (const char ***)(v2 + 6);
goto LABEL_6;
}
printf("Error - symbol %s defined twice in the same scope\n", v3);
}

original_code:
void addIdToTable_noAddrMove(ID* newId, ID** table) {
    if (*table == ((void *)0)) {
        *table = newId;
        return;
    }
    int cmp = strcmp(newId->id_name, (*table)->id_name);
    if (cmp < 0) {
        ID** p = &((*table)->id_left);
        addIdToTable_noAddrMove(newId, p);
    } else if (cmp > 0) {
        ID** p = &((*table)->id_right);
        addIdToTable_noAddrMove(newId, p);
    } else {
        printf("Error - symbol %s defined twice in the same scope\n", newId->id_name);
    }
}

canonical_original_code:
void addIdToTable_noAddrMove(struct id_info *newId, struct id_info **table) {
    if (*table == ((void *)0)) {
        *table = newId;
        return;
    }
    int cmp = strcmp(newId->id_name, (*table)->id_name);
    if (cmp < 0) {
        struct id_info **p = &((*table)->id_left);
        addIdToTable_noAddrMove(newId, p);
    } else if (cmp > 0) {
        struct id_info **p = &((*table)->id_right);
        addIdToTable_noAddrMove(newId, p);
    } else {
        printf("Error - symbol %s defined twice in the same scope\n", newId->id_name);
    }
}

variable_types:
table
struct id_info **

variable_types: cmp int

variable_types: struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info *FirstField; } ty_record; } ty_form; } *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct { struct type_info *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct { struct slist_struct { struct slist_struct *next; void *data; } *head; struct slist_struct *tail; } *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *funcCall; struct expression_struct *innerExpr; } edata; } *const_expr; struct slist_struct *typedIdentLists; int param_size; int pointer_p; } **


symtabInit

decompiled_code:
__int64 symtabInit()
{
const char **v0; // rax
const char **v1; // rax
const char **v2; // rax
const char **v3; // rax
const char **v4; // rax
const char **v5; // rax
const char **v6; // rax
const char **v7; // rax
const char **v8; // rax
const char **v9; // rax
const char **v10; // rax
const char **v11; // rax
__int64 result; // rax

typeinit();
v0 = (const char **)typeIdCreate(int_type, (__int64)"integer");
addIdToTable_noAddrMove(v0, (const char ***)scope);
v1 = (const char **)typeIdCreate(int_type, (__int64)"INTEGER");
addIdToTable_noAddrMove(v1, (const char ***)scope);
v2 = (const char **)typeIdCreate(char_type, (__int64)"char");
addIdToTable_noAddrMove(v2, (const char ***)scope);
v3 = (const char **)typeIdCreate(char_type, (__int64)"CHAR");
addIdToTable_noAddrMove(v3, (const char ***)scope);
v4 = (const char **)typeIdCreate(bool_type, (__int64)"boolean");
addIdToTable_noAddrMove(v4, (const char ***)scope);
v5 = (const char **)typeIdCreate(bool_type, (__int64)"BOOLEAN");
addIdToTable_noAddrMove(v5, (const char ***)scope);
v6 = (const char **)typeIdCreate(str_type, (__int64)"string");
addIdToTable_noAddrMove(v6, (const char ***)scope);
v7 = (const char **)typeIdCreate(str_type, (__int64)"STRING");
addIdToTable_noAddrMove(v7, (const char ***)scope);
true_expr = newBoolExpr(1LL);
false_expr = newBoolExpr(0LL);
v8 = (const char **)mkBoolId((__int64)"true", true_expr);
addIdToTable_noAddrMove(v8, (const char ***)scope);
v9 = (const char **)mkBoolId((__int64)"TRUE", true_expr);
addIdToTable_noAddrMove(v9, (const char ***)scope);
v10 = (const char **)mkBoolId((__int64)"false", false_expr);
addIdToTable_noAddrMove(v10, (const char ***)scope);
v11 = (const char **)mkBoolId((__int64)"FALSE", false_expr);
addIdToTable_noAddrMove(v11, (const char ***)scope);
result = newNumExpr(1LL);
one_expr = result;
return result;
}

canonical_decompiled_code:
__int64 func6()
{
const char **v0; // rax
const char **v1; // rax
const char **v2; // rax
const char **v3; // rax
const char **v4; // rax
const char **v5; // rax
const char **v6; // rax
const char **v7; // rax
const char **v8; // rax
const char **v9; // rax
const char **v10; // rax
const char **v11; // rax
__int64 result; // rax

func0();
v0 = (const char **)typeIdCreate(int_type, (__int64)"integer");
func5(v0, (const char ***)scope);
v1 = (const char **)typeIdCreate(int_type, (__int64)"INTEGER");
func5(v1, (const char ***)scope);
v2 = (const char **)typeIdCreate(char_type, (__int64)"char");
func5(v2, (const char ***)scope);
v3 = (const char **)typeIdCreate(char_type, (__int64)"CHAR");
func5(v3, (const char ***)scope);
v4 = (const char **)typeIdCreate(bool_type, (__int64)"boolean");
func5(v4, (const char ***)scope);
v5 = (const char **)typeIdCreate(bool_type, (__int64)"BOOLEAN");
func5(v5, (const char ***)scope);
v6 = (const char **)typeIdCreate(str_type, (__int64)"string");
func5(v6, (const char ***)scope);
v7 = (const char **)typeIdCreate(str_type, (__int64)"STRING");
func5(v7, (const char ***)scope);
true_expr = newBoolExpr(1LL);
false_expr = newBoolExpr(0LL);
v8 = (const char **)mkBoolId((__int64)"true", true_expr);
func5(v8, (const char ***)scope);
v9 = (const char **)mkBoolId((__int64)"TRUE", true_expr);
func5(v9, (const char ***)scope);
v10 = (const char **)mkBoolId((__int64)"false", false_expr);
func5(v10, (const char ***)scope);
v11 = (const char **)mkBoolId((__int64)"FALSE", false_expr);
func5(v11, (const char ***)scope);
result = newNumExpr(1LL);
one_expr = result;
return result;
}

original_code:
void symtabInit(void) {
    typeinit();
    ID** s = scope;
    addIdToTable_noAddrMove(typeIdCreate(int_type, "integer"), s);
    addIdToTable_noAddrMove(typeIdCreate(int_type, "INTEGER"), s);
    addIdToTable_noAddrMove(typeIdCreate(char_type, "char"), s);
    addIdToTable_noAddrMove(typeIdCreate(char_type, "CHAR"), s);
    addIdToTable_noAddrMove(typeIdCreate(bool_type, "boolean"), s);
    addIdToTable_noAddrMove(typeIdCreate(bool_type, "BOOLEAN"), s);
    addIdToTable_noAddrMove(typeIdCreate(str_type, "string"), s);
    addIdToTable_noAddrMove(typeIdCreate(str_type, "STRING"), s);
    true_expr = newBoolExpr(1);
    false_expr = newBoolExpr(0);
    ID* boolid = mkBoolId("true", true_expr);
    addIdToTable_noAddrMove(boolid, s);
    boolid = mkBoolId("TRUE", true_expr);
    addIdToTable_noAddrMove(boolid, s);
    boolid = mkBoolId("false", false_expr);
    addIdToTable_noAddrMove(boolid, s);
    boolid = mkBoolId("FALSE", false_expr);
    addIdToTable_noAddrMove(boolid, s);
    one_expr = newNumExpr(1);
}

canonical_original_code:
void symtabInit() {
    typeinit();
    struct id_info **s = scope;
    addIdToTable_noAddrMove(typeIdCreate(int_type, "integer"), s);
    addIdToTable_noAddrMove(typeIdCreate(int_type, "INTEGER"), s);
    addIdToTable_noAddrMove(typeIdCreate(char_type, "char"), s);
    addIdToTable_noAddrMove(typeIdCreate(char_type, "CHAR"), s);
    addIdToTable_noAddrMove(typeIdCreate(bool_type, "boolean"), s);
    addIdToTable_noAddrMove(typeIdCreate(bool_type, "BOOLEAN"), s);
    addIdToTable_noAddrMove(typeIdCreate(str_type, "string"), s);
    addIdToTable_noAddrMove(typeIdCreate(str_type, "STRING"), s);
    true_expr = newBoolExpr(1);
    false_expr = newBoolExpr(0);
    struct id_info *boolid = mkBoolId("true", true_expr);
    addIdToTable_noAddrMove(boolid, s);
    boolid = mkBoolId("TRUE", true_expr);
    addIdToTable_noAddrMove(boolid, s);
    boolid = mkBoolId("false", false_expr);
    addIdToTable_noAddrMove(boolid, s);
    boolid = mkBoolId("FALSE", false_expr);
    addIdToTable_noAddrMove(boolid, s);
    one_expr = newNumExpr(1);
}

user_defined_types: enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 }

user_defined_types: enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 }

user_defined_types: enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 }

user_defined_types: enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 }

user_defined_types: enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 }

user_defined_types: struct slist_struct { struct slist_struct *next; void *data; }

user_defined_types: enum BranchType_enum { bt_equal0=0, bt_nequal0=1 }


addVarToCurTable

decompiled_code:
void __fastcall addVarToCurTable(__int64 a1)
{
__int64 v1; // rdx
int v2; // ecx
int v3; // eax
int v4; // eax

v1 = currscope;
v2 = *(_DWORD *)(a1 + 84);
v3 = scopeAddr[currscope];
*(_DWORD *)(a1 + 8) = v3;
if ( v2 )
v4 = v3 + 4;
else
v4 = **(_DWORD **)(a1 + 24) + v3;
scopeAddr[v1] = v4;
addIdToTable_noAddrMove((const char **)a1, (const char ***)&scope[v1]);
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1)
{
__int64 v1; // rdx
int v2; // ecx
int v3; // eax
int v4; // eax

v1 = currscope;
v2 = *(_DWORD *)(a1 + 84);
v3 = scopeAddr[currscope];
*(_DWORD *)(a1 + 8) = v3;
if ( v2 )
v4 = v3 + 4;
else
v4 = **(_DWORD **)(a1 + 24) + v3;
scopeAddr[v1] = v4;
func5((const char **)a1, (const char ***)&scope[v1]);
}

original_code:
void addVarToCurTable(ID* var) {
    var->id_addr = scopeAddr[currscope];
    if(var->pointer_p) {
        scopeAddr[currscope] += 4;
    } else {
        scopeAddr[currscope] += var->id_type->ty_size;
    }
    addIdToTable_noAddrMove(var, scope+currscope);
}

canonical_original_code:
void addVarToCurTable(struct id_info *var) {
    var->id_addr = scopeAddr[currscope];
    if(var->pointer_p) {
        scopeAddr[currscope] += 4;
    } else {
        scopeAddr[currscope] += var->id_type->ty_size;
    }
    addIdToTable_noAddrMove(var, scope+currscope);
}


getSizeOfScopeVars

decompiled_code:
__int64 __fastcall getSizeOfScopeVars(__int64 a1)
{
unsigned int v1; // er12
__int64 v2; // rbx
int v3; // eax
int v4; // ebp
int v5; // eax

v1 = 0;
if ( a1 )
{
v2 = a1;
do
{
v3 = *(_DWORD *)(v2 + 84);
*(_DWORD *)(v2 + 32) = 2;
v4 = 4;
if ( !v3 )
v4 = **(_DWORD **)(v2 + 24);
v5 = getSizeOfScopeVars(*(_QWORD *)(v2 + 40));
v2 = *(_QWORD *)(v2 + 48);
v1 += v5 + v4;
}
while ( v2 );
}
return v1;
}

original_code:
int getSizeOfScopeVars(ID* scope) {
    int size = 0;
    if (scope != ((void *)0)) {
        if(scope->id_kind = Variable) {
            if(scope->pointer_p) {
                size += 4;
            } else {
                TYPE* t = scope->id_type;
                size += t->ty_size;
            }
        }
        size += getSizeOfScopeVars(scope->id_left);
        size += getSizeOfScopeVars(scope->id_right);
    }
    return size;
}

canonical_original_code:
int getSizeOfScopeVars(struct id_info *scope) {
    int size = 0;
    if (scope != ((void *)0)) {
        if(scope->id_kind = Variable) {
            if(scope->pointer_p) {
                size += 4;
            } else {
                struct type_info *t = scope->id_type;
                size += t->ty_size;
            }
        }
        size += getSizeOfScopeVars(scope->id_left);
        size += getSizeOfScopeVars(scope->id_right);
    }
    return size;
}

variable_types: size int


freeIdTree

decompiled_code:
void __fastcall freeIdTree(void *ptr)
{
if ( ptr )
{
freeIdTree(*((void **)ptr + 5));
freeIdTree(*((void **)ptr + 6));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func9(void *ptr)
{
if ( ptr )
{
func9(*((void **)ptr + 5));
func9(*((void **)ptr + 6));
free(ptr);
}
}

original_code:
void freeIdTree(ID* tree) {
    if (tree == ((void *)0)) {
        return;
    }
    freeIdTree(tree->id_left);
    freeIdTree(tree->id_right);
    free(tree);
}

canonical_original_code:
void freeIdTree(struct id_info *tree) {
    if (tree == ((void *)0)) {
        return;
    }
    freeIdTree(tree->id_left);
    freeIdTree(tree->id_right);
    free(tree);
}


getTypeKindName

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

if ( a1 <= 6 )
result = CSWTCH_40[a1];
return result;
}

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

if ( a1 <= 6 )
result = CSWTCH_40[a1];
return result;
}

original_code:
char* getTypeKindName(TY_KIND kind) {
    switch(kind) {
        case Integer:
            return "Integer";
        case Char:
            return "Char";
        case Boolean:
            return "Boolean";
        case String:
            return "String";
        case Array:
            return "Array";
        case Record:
            return "Record";
        case UndefinedType:
            return "UndefinedType";
    }
}

canonical_original_code:
char *getTypeKindName(enum type_kind kind) {
    switch(kind) {
        case Integer:
            return "Integer";
        case Char:
            return "Char";
        case Boolean:
            return "Boolean";
        case String:
            return "String";
        case Array:
            return "Array";
        case Record:
            return "Record";
        case UndefinedType:
            return "UndefinedType";
    }
}

variable_types: enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 }


printTypeInfo

decompiled_code:
int __fastcall printTypeInfo(unsigned int *a1)
{
char *v1; // rax
int result; // eax
__int64 i; // rbx

v1 = getTypeKindName(a1[4]);
printf(" Type kind: %s\n", v1);
printf(" Type size: %i\n", *a1);
result = a1[4];
if ( result != 5 )
{
if ( result != 4 )
return result;
LABEL_7:
printf(" Elem Type: %s\n", *(const char **)(*((_QWORD *)a1 + 4) + 8LL));
printf(" Min index: %i\n", a1[12]);
return printf(" Max index: %i\n", a1[13]);
}
puts(" Layout:");
for ( i = *((_QWORD *)a1 + 4); i; i = *(_QWORD *)(i + 56) )
printf(" field %s of type %s\n", *(const char **)i, *(const char **)(*(_QWORD *)(i + 24) + 8LL));
result = a1[4];
if ( result == 4 )
goto LABEL_7;
return result;
}

canonical_decompiled_code:
int __fastcall func11(unsigned int *a1)
{
char *v1; // rax
int result; // eax
__int64 i; // rbx

v1 = func10(a1[4]);
printf(" Type kind: %s\n", v1);
printf(" Type size: %i\n", *a1);
result = a1[4];
if ( result != 5 )
{
if ( result != 4 )
return result;
LABEL_7:
printf(" Elem Type: %s\n", *(const char **)(*((_QWORD *)a1 + 4) + 8LL));
printf(" Min index: %i\n", a1[12]);
return printf(" Max index: %i\n", a1[13]);
}
puts(" Layout:");
for ( i = *((_QWORD *)a1 + 4); i; i = *(_QWORD *)(i + 56) )
printf(" field %s of type %s\n", *(const char **)i, *(const char **)(*(_QWORD *)(i + 24) + 8LL));
result = a1[4];
if ( result == 4 )
goto LABEL_7;
return result;
}

original_code:
void printTypeInfo(TYPE* type) {
    printf(" Type kind: %s\n", getTypeKindName(type->ty_kind));
    printf(" Type size: %i\n", type->ty_size);
    if(type->ty_kind == Record) {
        printf(" Layout:\n");
        ID* id = type->ty_form.ty_record.FirstField;
        while(id != ((void *)0)) {
            printf("  field %s of type %s\n", id->id_name, id->id_type->ty_name);
            id = id->id_next;
        }
    }
    if(type->ty_kind == Array) {
        printf(" Elem Type: %s\n", type->ty_form.ty_array.ElementType->ty_name);
        printf(" Min index: %i\n", type->ty_form.ty_array.min);
        printf(" Max index: %i\n", type->ty_form.ty_array.max);
    }
}

canonical_original_code:
void printTypeInfo(struct type_info *type) {
    printf(" Type kind: %s\n", getTypeKindName(type->ty_kind));
    printf(" Type size: %i\n", type->ty_size);
    if(type->ty_kind == Record) {
        printf(" Layout:\n");
        struct id_info *id = type->ty_form.ty_record.FirstField;
        while(id != ((void *)0)) {
            printf("  field %s of type %s\n", id->id_name, id->id_type->ty_name);
            id = id->id_next;
        }
    }
    if(type->ty_kind == Array) {
        printf(" Elem Type: %s\n", type->ty_form.ty_array.ElementType->ty_name);
        printf(" Min index: %i\n", type->ty_form.ty_array.min);
        printf(" Max index: %i\n", type->ty_form.ty_array.max);
    }
}


printConstInfo

decompiled_code:
void __fastcall printConstInfo(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rdx

if ( a1 )
{
if ( !*(_DWORD *)(a1 + 32) )
{
v1 = *(_QWORD *)(a1 + 64);
if ( !*(_DWORD *)(v1 + 8) )
{
v2 = *(_QWORD *)(a1 + 24);
if ( v2 == int_type )
{
printf(" Value: %i\n", *(unsigned int *)(v1 + 12));
}
else if ( v2 == char_type )
{
printf(" Value: %c\n", (unsigned int)*(char *)(v1 + 16));
}
else if ( v2 == str_type )
{
printf(" Value: \"%s\"", *(const char **)(v1 + 24));
}
}
}
}
}

canonical_decompiled_code:
void __fastcall func12(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rdx

if ( a1 )
{
if ( !*(_DWORD *)(a1 + 32) )
{
v1 = *(_QWORD *)(a1 + 64);
if ( !*(_DWORD *)(v1 + 8) )
{
v2 = *(_QWORD *)(a1 + 24);
if ( v2 == int_type )
{
printf(" Value: %i\n", *(unsigned int *)(v1 + 12));
}
else if ( v2 == char_type )
{
printf(" Value: %c\n", (unsigned int)*(char *)(v1 + 16));
}
else if ( v2 == str_type )
{
printf(" Value: \"%s\"", *(const char **)(v1 + 24));
}
}
}
}
}

original_code:
void printConstInfo(ID* c) {
    if(c == ((void *)0) || c->id_kind != Constant_id) {
        return;
    }
    expr* e = c->const_expr;
    if(e->kind == constant_expr) {
        if(c->id_type == int_type) {
            printf(" Value: %i\n", e->int_val);
        } else if (c->id_type == char_type) {
            printf(" Value: %c\n", e->char_val);
        } else if (c->id_type == str_type) {
            printf(" Value: \"%s\"", e->str_val);
        }
    }
}

canonical_original_code:
void printConstInfo(struct id_info *c) {
    if(c == ((void *)0) || c->id_kind != Constant_id) {
        return;
    }
    struct expression_struct *e = c->const_expr;
    if(e->kind == constant_expr) {
        if(c->id_type == int_type) {
            printf(" Value: %i\n", e->int_val);
        } else if (c->id_type == char_type) {
            printf(" Value: %c\n", e->char_val);
        } else if (c->id_type == str_type) {
            printf(" Value: \"%s\"", e->str_val);
        }
    }
}

variable_types: struct expression_struct { struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct *const_expr; struct slist_struct { struct slist_struct *next; void *data; } *typedIdentLists; int param_size; int pointer_p; } *FirstField; } ty_record; } ty_form; } *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct { struct slist_struct *head; struct slist_struct *tail; } *if_conditionals; struct slist_struct *exprList; struct expression_struct *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *funcCall; struct expression_struct *innerExpr; } edata; } *


printVarInfo

decompiled_code:
int __fastcall printVarInfo(__int64 a1)
{
printf(" Size: %i\n", **(unsigned int **)(a1 + 24));
return printf(" Offset in scope space: %i\n", *(unsigned int *)(a1 + 8));
}

canonical_decompiled_code:
int __fastcall func13(__int64 a1)
{
printf(" Size: %i\n", **(unsigned int **)(a1 + 24));
return printf(" Offset in scope space: %i\n", *(unsigned int *)(a1 + 8));
}

original_code:
void printVarInfo(ID* v) {
    printf(" Size: %i\n", v->id_type->ty_size);
    printf(" Offset in scope space: %i\n", v->id_addr);
}

canonical_original_code:
void printVarInfo(struct id_info *v) {
    printf(" Size: %i\n", v->id_type->ty_size);
    printf(" Offset in scope space: %i\n", v->id_addr);
}


printIdTree

decompiled_code:
void __fastcall printIdTree(__int64 a1)
{
__int64 v1; // rbx
const char *v2; // rax
const char *v3; // rax
int v4; // eax

if ( a1 )
{
v1 = a1;
do
{
printIdTree(*(_QWORD *)(v1 + 40));
puts("Identifier:");
printf(" Name: %s\n", *(const char **)v1);
v2 = getIdKindName(*(_DWORD *)(v1 + 32));
printf(" Id Kind: %s\n", v2);
v3 = getTypeName(*(_QWORD *)(v1 + 24));
printf(" Type: %s\n", v3);
v4 = *(_DWORD *)(v1 + 32);
if ( v4 == 1 )
{
printTypeInfo(*(unsigned int **)(v1 + 24));
v4 = *(_DWORD *)(v1 + 32);
}
if ( v4 )
{
if ( v4 == 2 )
goto LABEL_10;
}
else
{
printConstInfo(v1);
if ( *(_DWORD *)(v1 + 32) == 2 )
{
LABEL_10:
printVarInfo(v1);
goto LABEL_7;
}
}
LABEL_7:
v1 = *(_QWORD *)(v1 + 48);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func14(__int64 a1)
{
__int64 v1; // rbx
const char *v2; // rax
const char *v3; // rax
int v4; // eax

if ( a1 )
{
v1 = a1;
do
{
func14(*(_QWORD *)(v1 + 40));
puts("Identifier:");
printf(" Name: %s\n", *(const char **)v1);
v2 = func2(*(_DWORD *)(v1 + 32));
printf(" Id Kind: %s\n", v2);
v3 = func1(*(_QWORD *)(v1 + 24));
printf(" Type: %s\n", v3);
v4 = *(_DWORD *)(v1 + 32);
if ( v4 == 1 )
{
func11(*(unsigned int **)(v1 + 24));
v4 = *(_DWORD *)(v1 + 32);
}
if ( v4 )
{
if ( v4 == 2 )
goto LABEL_10;
}
else
{
func12(v1);
if ( *(_DWORD *)(v1 + 32) == 2 )
{
LABEL_10:
func13(v1);
goto LABEL_7;
}
}
LABEL_7:
v1 = *(_QWORD *)(v1 + 48);
}
while ( v1 );
}
}

original_code:
void printIdTree(ID* tree) {
    if (tree == ((void *)0)) {
        return;
    }
    printIdTree(tree->id_left);
    printf("Identifier:\n");
    printf(" Name: %s\n", tree->id_name);
    printf(" Id Kind: %s\n", getIdKindName(tree->id_kind));
    printf(" Type: %s\n", getTypeName(tree->id_type));
    if (tree->id_kind == Type) {
        printTypeInfo(tree->id_type);
    }
    if (tree->id_kind == Procedure || tree->id_kind == Function) {
    }
    if (tree->id_kind == Constant_id) {
        printConstInfo(tree);
    }
    if (tree->id_kind == Variable) {
        printVarInfo(tree);
    }
    printIdTree(tree->id_right);
}

canonical_original_code:
void printIdTree(struct id_info *tree) {
    if (tree == ((void *)0)) {
        return;
    }
    printIdTree(tree->id_left);
    printf("Identifier:\n");
    printf(" Name: %s\n", tree->id_name);
    printf(" Id Kind: %s\n", getIdKindName(tree->id_kind));
    printf(" Type: %s\n", getTypeName(tree->id_type));
    if (tree->id_kind == Type) {
        printTypeInfo(tree->id_type);
    }
    if (tree->id_kind == Procedure || tree->id_kind == Function) {
    }
    if (tree->id_kind == Constant_id) {
        printConstInfo(tree);
    }
    if (tree->id_kind == Variable) {
        printVarInfo(tree);
    }
    printIdTree(tree->id_right);
}


scopePrint

decompiled_code:
void __fastcall scopePrint(unsigned int a1)
{
printf("Printing symbol table at scope level %i:\n", a1);
printIdTree(scope[a1]);
}

canonical_decompiled_code:
void __fastcall func15(unsigned int a1)
{
printf("Printing symbol table at scope level %i:\n", a1);
func14(scope[a1]);
}

original_code:
void scopePrint(int s) {
    printf("Printing symbol table at scope level %i:\n", s);
    printIdTree(scope[s]);
}

variable_types: s int


reserveGlobal

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

result = m_reserve_global_var(**(unsigned int **)(a1 + 24));
*(_DWORD *)(a1 + 12) = result;
return result;
}

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

result = m_reserve_global_var(**(unsigned int **)(a1 + 24));
*(_DWORD *)(a1 + 12) = result;
return result;
}

original_code:
void reserveGlobal(ID* gvar) {
    int size = gvar->id_type->ty_size;
    int reservation = m_reserve_global_var(size);
    gvar->id_label = reservation;
}

canonical_original_code:
void reserveGlobal(struct id_info *gvar) {
    int size = gvar->id_type->ty_size;
    int reservation = m_reserve_global_var(size);
    gvar->id_label = reservation;
}

variable_types: reservation int


isGlobal

decompiled_code:
_BOOL8 __fastcall isGlobal(__int64 a1)
{
return *(_DWORD *)(a1 + 16) <= 1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func17(__int64 a1)
{
return *(_DWORD *)(a1 + 16) <= 1;
}

original_code:
int isGlobal(ID* id) {
    if(id->id_level < 2)
        return 1;
    return 0;
}

canonical_original_code:
int isGlobal(struct id_info *id) {
    if(id->id_level < 2)
        return 1;
    return 0;
}


reserveGlobals

decompiled_code:
void reserveGlobals()
{
reserveGlobals_recursive(scope[0]);
reserveGlobals_recursive(scope[1]);
}

canonical_decompiled_code:
void func19()
{
func18(scope[0]);
func18(scope[1]);
}

original_code:
void reserveGlobals() {
    _reserveGlobals_recursive(scope[0]);
    _reserveGlobals_recursive(scope[1]);
}


decompiled_code:
_BOOL8 __fastcall isByte_p(_DWORD *a1)
{
return *a1 == 1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func20(_DWORD *a1)
{
return *a1 == 1;
}

original_code:
int isByte_p(TYPE* t) {
    return t->ty_size == 1;
}

canonical_original_code:
int isByte_p(struct type_info *t) {
    return t->ty_size == 1;
}


decompiled_code:
_BOOL8 __fastcall isWord_p(_DWORD *a1)
{
return *a1 == 4;
}

canonical_decompiled_code:
_BOOL8 __fastcall func21(_DWORD *a1)
{
return *a1 == 4;
}

original_code:
int isWord_p(TYPE* t) {
    return t->ty_size == 4;
}

canonical_original_code:
int isWord_p(struct type_info *t) {
    return t->ty_size == 4;
}


findRecordField

decompiled_code:
__int64 __fastcall findRecordField(__int64 a1, const char *a2)
{
__int64 i; // r12

for ( i = *(_QWORD *)(a1 + 32); i; i = *(_QWORD *)(i + 56) )
{
if ( !strcmp(*(const char **)i, a2) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1, const char *a2)
{
__int64 i; // r12

for ( i = *(_QWORD *)(a1 + 32); i; i = *(_QWORD *)(i + 56) )
{
if ( !strcmp(*(const char **)i, a2) )
break;
}
return i;
}

original_code:
ID* findRecordField(TYPE* rtype, char* fname) {
    ID* field = rtype->ty_form.ty_record.FirstField;
    while(field != ((void *)0)) {
        if (!strcmp(field->id_name, fname)) {
            return field;
        }
        field = field->id_next;
    }
    return ((void *)0);
}

canonical_original_code:
struct id_info *findRecordField(struct type_info *rtype, char *fname) {
    struct id_info *field = rtype->ty_form.ty_record.FirstField;
    while(field != ((void *)0)) {
        if (!strcmp(field->id_name, fname)) {
            return field;
        }
        field = field->id_next;
    }
    return ((void *)0);
}

variable_types:
rtype
struct type_info *

variable_types:
fname
char *


mkStopStmt

decompiled_code:
_DWORD *mkStopStmt()
{
_DWORD *result; // rax

result = malloc(0x18uLL);
*result = 5;
return result;
}

canonical_decompiled_code:
_DWORD *func0()
{
_DWORD *result; // rax

result = malloc(0x18uLL);
*result = 5;
return result;
}

original_code:
statement* mkStopStmt() {
    statement* s = malloc(sizeof(statement));
    s->type = stop_stmt;
    return s;
}

canonical_original_code:
struct stmt_struct *mkStopStmt() {
    struct stmt_struct *s = malloc(sizeof(statement));
    s->type = stop_stmt;
    return s;
}

variable_types: struct stmt_struct { enum stmt_type_enum { assign_stmt=0, if_stmt=1, while_stmt=2, repeat_stmt=3, for_stmt=4, stop_stmt=5, return_stmt=6, read_stmt=7, write_stmt=8, proc_stmt=9, null_stmt=10 } type; union { struct htslist_struct { struct slist_struct { struct slist_struct *next; void *data; } *head; struct slist_struct *tail; } *if_conditionals; struct slist_struct *exprList; struct expression_struct { struct type_info { int ty_size; char *ty_name; enum type_kind { Integer=0, Char=1, Boolean=2, String=3, Array=4, Record=5, UndefinedType=6 } ty_kind; struct type_info *ty_next; union { struct { struct type_info *RangeType; int min; int max; } ty_subrange; struct { struct type_info *ElementType; struct type_info *IndexType; int min; int max; } ty_array; struct { struct id_info { char *id_name; int id_addr; int id_label; int id_level; struct type_info *id_type; enum identifier_kind { Constant_id=0, Type=1, Variable=2, FParameter=3, Field=4, Procedure=5, Function=6 } id_kind; struct id_info *id_left; struct id_info *id_right; struct id_info *id_next; struct expression_struct *const_expr; struct slist_struct *typedIdentLists; int param_size; int pointer_p; } *FirstField; } ty_record; } ty_form; } *type; enum expr_kind_enum { constant_expr=0, operation_bin=1, operation_un=2, registerVal=3, globalVar=4, localVar=5, functionCall=6, typecast=7 } kind; int int_val; char char_val; int bool_val; char *str_val; int str_const_index; struct expression_struct *offsetExpr; int pointer_p; int to_pointer_p; union { struct { struct expression_struct *operand1; struct expression_struct *operand2; enum operator_enum { op_and=0, op_or=1, op_not=2, op_negate=3, op_add=4, op_sub=5, op_mult=6, op_div=7, op_mod=8, op_equal=9, op_nequal=10, op_gt=11, op_lt=12, op_gte=13, op_lte=14 } op; } opdata; int reg_number; struct id_info *id; struct stmt_struct *funcCall; struct expression_struct *innerExpr; } edata; } *expression; struct { struct stmt_struct *init; struct conditional_struct { struct expression_struct *condition; enum BranchType_enum { bt_equal0=0, bt_nequal0=1 } branchType; struct htslist_struct *statements; } *cBlock; } loopdata; struct { struct expression_struct *lvalue; struct expression_struct *rvalue; } assigndata; struct { char *name; struct slist_struct *paramExprs; } procdata; } data; } *


decompiled_code:
__int64 __fastcall stmt_eval_assign(__int64 a1)
{
return m_assign_stmt(*(_QWORD *)(a1 + 8), *(_QWORD *)(a1 + 16));
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return m_assign_stmt(*(_QWORD *)(a1 + 8), *(_QWORD *)(a1 + 16));
}

original_code:
void stmt_eval_assign(statement* s) {
    m_assign_stmt(s->data.assigndata.lvalue, s->data.assigndata.rvalue);
}

canonical_original_code:
void stmt_eval_assign(struct stmt_struct *s) {
    m_assign_stmt(s->data.assigndata.lvalue, s->data.assigndata.rvalue);
}


decompiled_code:
__int64 __fastcall stmt_eval_if(__int64 a1)
{
return m_if_stmt(*(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return m_if_stmt(*(_QWORD *)(a1 + 8));
}

original_code:
void stmt_eval_if(statement* s) {
    m_if_stmt(s->data.if_conditionals);
}

canonical_original_code:
void stmt_eval_if(struct stmt_struct *s) {
    m_if_stmt(s->data.if_conditionals);
}