initOpts

decompiled_code:
__int64 __fastcall initOpts(int argc, char **argv)
{
int i; // ebx
int v3; // eax

opterr = 0;
for ( i = 2; ; ++i )
{
v3 = getopt(argc, argv, "ax");
if ( v3 == -1 )
break;
if ( v3 == 97 )
{
printFlags |= 2u;
}
else if ( v3 == 120 )
{
printFlags |= 1u;
}
else
{
report(254, "ERROR: bad option %c", (unsigned int)optopt);
}
}
return (unsigned int)(i - 1);
}

canonical_decompiled_code:
__int64 __fastcall func2(int argc, char **argv)
{
int i; // ebx
int v3; // eax

opterr = 0;
for ( i = 2; ; ++i )
{
v3 = getopt(argc, argv, "ax");
if ( v3 == -1 )
break;
if ( v3 == 97 )
{
printFlags |= 2u;
}
else if ( v3 == 120 )
{
printFlags |= 1u;
}
else
{
func1(254, "ERROR: bad option %c", (unsigned int)optopt);
}
}
return (unsigned int)(i - 1);
}

original_code:
static int initOpts(int argc, char *argv[])
{
   int opt, args;
   opterr = 0;
   args = 1;
   while ((opt = getopt(argc, argv, "ax")) != -1)
   {
      switch (opt)
      {
         case 'a':
            printFlags |= 2;
            args++;
            break;
         case 'x':
            printFlags |= 1;
            args++;
            break;
         default:
            args++;
            report(254, "ERROR: bad option %c", optopt);
      }
    }
   return args;
}

canonical_original_code:
static int initOpts(int argc, char *argv[])
{
   int opt; int args;
   opterr = 0;
   args = 1;
   while ((opt = getopt(argc, argv, "ax")) != -1)
   {
      switch (opt)
      {
         case 'a':
            printFlags |= 2;
            args++;
            break;
         case 'x':
            printFlags |= 1;
            args++;
            break;
         default:
            args++;
            report(254, "ERROR: bad option %c", optopt);
      }
    }
   return args;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: opt int

variable_types: args int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er14
int v4; // eax
const char **v5; // rbx
const char **v6; // r15
unsigned int v7; // er13
const char *v8; // r12
unsigned int v9; // ebp
int v10; // ebp
int v11; // eax
int v12; // ebx
int v13; // er12
const char *v14; // rax
const char *v16; // rax
signed int v17; // [rsp+Ch] [rbp-100DCh]
char buf[65536]; // [rsp+10h] [rbp-100D8h] BYREF
void *ptr; // [rsp+10010h] [rbp-D8h] BYREF
int v20; // [rsp+10048h] [rbp-A0h] BYREF
__int64 v21; // [rsp+10050h] [rbp-98h] BYREF
__int64 v22; // [rsp+10058h] [rbp-90h]
__int64 v23; // [rsp+10060h] [rbp-88h]
size_t n; // [rsp+10068h] [rbp-80h]
__int64 v25; // [rsp+100A0h] [rbp-48h] BYREF
unsigned __int64 v26; // [rsp+100A8h] [rbp-40h]

v3 = openSocket(argc, argv, envp);
v4 = initOpts(argc, (char **)argv);
command_buf[0] = 0;
if ( argc > v4 )
{
v5 = &argv[v4];
v6 = &(&argv[v4])[(unsigned __int64)(unsigned int)(argc - 1 - v4) + 1];
v7 = 0;
v17 = 0;
do
{
v8 = *v5;
v9 = v7 + strlen(*v5) + 1;
v7 = v9;
if ( v9 <= 0xFFFF )
{
sprintf(&command_buf[v17], "%s ", v8);
v17 = v9;
}
++v5;
}
while ( v5 != v6 );
if ( v17 )
command_buf[v17 - 1] = 0;
}
v20 = 0;
v10 = strlen(command_buf);
while ( v20 < v10 )
{
v11 = cmdParse(command_buf, &v21, &unk_10000, buf, &v20);
v12 = v11;
if ( v11 < 0 )
{
if ( v11 == -1 )
{
v16 = (const char *)cmdStr();
report(253, "%s? unknown command, pigs h for help", v16);
}
else
{
v14 = (const char *)cmdStr();
report(253, "%s: bad parameter, pigs h for help", v14);
}
break;
}
v13 = v21;
if ( (int)v21 > 799 )
{
report(253, "%s only allowed within a script", *((const char **)&cmdInfo + 4 * v11 + 1));
}
else if ( (_DWORD)v21 == 25 )
{
printf("%s", cmdUsage);
}
else if ( (_DWORD)v21 == 48 )
{
cmdParseScript(buf, &ptr, 1LL);
if ( ptr )
free(ptr);
}
else
{
v25 = __PAIR64__(v22, v21);
v26 = __PAIR64__(n, v23);
if ( v3 == -1 )
{
report(255, "socket connect failed");
}
else if ( send(v3, &v25, 0x10uLL, 0) == 16 )
{
if ( n )
send(v3, buf, n, 0);
if ( recv(v3, &v25, 0x10uLL, 256) == 16 )
{
get_extensions(v3, v13, SHIDWORD(v26));
print_result((unsigned int)v3, *((_DWORD *)&cmdInfo + 8 * v12 + 5), v25, v26);
}
else
{
report(255, "socket receive failed");
}
}
else
{
report(255, "socket send failed");
}
}
}
if ( v3 >= 0 )
close(v3);
return status;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er14
int v4; // eax
const char **v5; // rbx
const char **v6; // r15
unsigned int v7; // er13
const char *v8; // r12
unsigned int v9; // ebp
int v10; // ebp
int v11; // eax
int v12; // ebx
int v13; // er12
const char *v14; // rax
const char *v16; // rax
signed int v17; // [rsp+Ch] [rbp-100DCh]
char buf[65536]; // [rsp+10h] [rbp-100D8h] BYREF
void *ptr; // [rsp+10010h] [rbp-D8h] BYREF
int v20; // [rsp+10048h] [rbp-A0h] BYREF
__int64 v21; // [rsp+10050h] [rbp-98h] BYREF
__int64 v22; // [rsp+10058h] [rbp-90h]
__int64 v23; // [rsp+10060h] [rbp-88h]
size_t n; // [rsp+10068h] [rbp-80h]
__int64 v25; // [rsp+100A0h] [rbp-48h] BYREF
unsigned __int64 v26; // [rsp+100A8h] [rbp-40h]

v3 = func0(argc, argv, envp);
v4 = func2(argc, (char **)argv);
command_buf[0] = 0;
if ( argc > v4 )
{
v5 = &argv[v4];
v6 = &(&argv[v4])[(unsigned __int64)(unsigned int)(argc - 1 - v4) + 1];
v7 = 0;
v17 = 0;
do
{
v8 = *v5;
v9 = v7 + strlen(*v5) + 1;
v7 = v9;
if ( v9 <= 0xFFFF )
{
sprintf(&command_buf[v17], "%s ", v8);
v17 = v9;
}
++v5;
}
while ( v5 != v6 );
if ( v17 )
command_buf[v17 - 1] = 0;
}
v20 = 0;
v10 = strlen(command_buf);
while ( v20 < v10 )
{
v11 = cmdParse(command_buf, &v21, &unk_10000, buf, &v20);
v12 = v11;
if ( v11 < 0 )
{
if ( v11 == -1 )
{
v16 = (const char *)cmdStr();
func1(253, "%s? unknown command, pigs h for help", v16);
}
else
{
v14 = (const char *)cmdStr();
func1(253, "%s: bad parameter, pigs h for help", v14);
}
break;
}
v13 = v21;
if ( (int)v21 > 799 )
{
func1(253, "%s only allowed within a script", *((const char **)&cmdInfo + 4 * v11 + 1));
}
else if ( (_DWORD)v21 == 25 )
{
printf("%s", cmdUsage);
}
else if ( (_DWORD)v21 == 48 )
{
cmdParseScript(buf, &ptr, 1LL);
if ( ptr )
free(ptr);
}
else
{
v25 = __PAIR64__(v22, v21);
v26 = __PAIR64__(n, v23);
if ( v3 == -1 )
{
func1(255, "socket connect failed");
}
else if ( send(v3, &v25, 0x10uLL, 0) == 16 )
{
if ( n )
send(v3, buf, n, 0);
if ( recv(v3, &v25, 0x10uLL, 256) == 16 )
{
func4(v3, v13, SHIDWORD(v26));
func3((unsigned int)v3, *((_DWORD *)&cmdInfo + 8 * v12 + 5), v25, v26);
}
else
{
func1(255, "socket receive failed");
}
}
else
{
func1(255, "socket send failed");
}
}
}
if ( v3 >= 0 )
close(v3);
return status;
}

original_code:
int main(int argc , char *argv[])
{
   int sock, command;
   int args, idx, i, pp, l, len;
   cmdCmd_t cmd;
   uintptr_t p[10];
   cmdCtlParse_t ctl;
   cmdScript_t s;
   char v[(1<<16)];
   sock = openSocket();
   args = initOpts(argc, argv);
   command_buf[0] = 0;
   l = 0;
   pp = 0;
   for (i=args; i<argc; i++)
   {
      l += (strlen(argv[i]) + 1);
      if (l < sizeof(command_buf))
         {sprintf(command_buf+pp, "%s ", argv[i]); pp=l;}
   }
   if (pp) {command_buf[--pp] = 0;}
   ctl.eaten = 0;
   len = strlen(command_buf);
   idx = 0;
   while ((idx >= 0) && (ctl.eaten < len))
   {
      if ((idx=cmdParse(command_buf, p, (1<<16), v, &ctl)) >= 0)
      {
         command = p[0];
         if (command < 800)
         {
            if (command == 25)
            {
               printf("%s", cmdUsage);
            }
            else if (command == 48)
            {
               cmdParseScript(v, &s, 1);
               if (s.par) free (s.par);
            }
            else
            {
               cmd.cmd = command;
               cmd.p1 = p[1];
               cmd.p2 = p[2];
               cmd.p3 = p[3];
               if (sock != -1)
               {
                  if (send(sock, &cmd, sizeof(cmdCmd_t), 0) ==
                     sizeof(cmdCmd_t))
                  {
                     if (p[3]) send(sock, v, p[3], 0);
                     if (recv(sock, &cmd, sizeof(cmdCmd_t), MSG_WAITALL) ==
                        sizeof(cmdCmd_t))
                     {
                        get_extensions(sock, command, cmd.res);
                        print_result(sock, cmdInfo[idx].rv, cmd);
                     }
                     else report(255, "socket receive failed");
                  }
                  else report(255, "socket send failed");
               }
               else report(255, "socket connect failed");
            }
         }
         else report(253,
                 "%s only allowed within a script", cmdInfo[idx].name);
      }
      else
      {
         if (idx == -1)
            report(253,
               "%s? unknown command, pigs h for help", cmdStr());
         else
            report(253,
               "%s: bad parameter, pigs h for help", cmdStr());
      }
   }
   if (sock >= 0) close(sock);
   return status;
}

canonical_original_code:
int main(int argc, char *argv[])
{
   int sock; int command;
   int args; int idx; int i; int pp; int l; int len;
   struct cmdCmd_t cmd;
   unsigned long p[10];
   struct cmdCtlParse_t ctl;
   struct cmdScript_t s;
   char v[-1];
   sock = openSocket();
   args = initOpts(argc, argv);
   command_buf[0] = 0;
   l = 0;
   pp = 0;
   for (i=args; i<argc; i++)
   {
      l += (strlen(argv[i]) + 1);
      if (l < sizeof(command_buf))
         {sprintf(command_buf+pp, "%s ", argv[i]); pp=l;}
   }
   if (pp) {command_buf[--pp] = 0;}
   ctl.eaten = 0;
   len = strlen(command_buf);
   idx = 0;
   while ((idx >= 0) && (ctl.eaten < len))
   {
      if ((idx=cmdParse(command_buf, p, (1<<16), v, &ctl)) >= 0)
      {
         command = p[0];
         if (command < 800)
         {
            if (command == 25)
            {
               printf("%s", cmdUsage);
            }
            else if (command == 48)
            {
               cmdParseScript(v, &s, 1);
               if (s.par) free (s.par);
            }
            else
            {
               cmd.cmd = command;
               cmd.p1 = p[1];
               cmd.p2 = p[2];
               cmd.p3 = p[3];
               if (sock != -1)
               {
                  if (send(sock, &cmd, sizeof(cmdCmd_t), 0) ==
                     sizeof(cmdCmd_t))
                  {
                     if (p[3]) send(sock, v, p[3], 0);
                     if (recv(sock, &cmd, sizeof(cmdCmd_t), MSG_WAITALL) ==
                        sizeof(cmdCmd_t))
                     {
                        get_extensions(sock, command, cmd.res);
                        print_result(sock, cmdInfo[idx].rv, cmd);
                     }
                     else report(255, "socket receive failed");
                  }
                  else report(255, "socket send failed");
               }
               else report(255, "socket connect failed");
            }
         }
         else report(253,
                 "%s only allowed within a script", cmdInfo[idx].name);
      }
      else
      {
         if (idx == -1)
            report(253,
               "%s? unknown command, pigs h for help", cmdStr());
         else
            report(253,
               "%s: bad parameter, pigs h for help", cmdStr());
      }
   }
   if (sock >= 0) close(sock);
   return status;
}

variable_types: sock int

variable_types: command int

variable_types: idx int

variable_types: i int

variable_types: pp int

variable_types: l int

variable_types: len int

variable_types: struct cmdCmd_t { unsigned int cmd; unsigned int p1; unsigned int p2; union { unsigned int p3; unsigned int ext_len; unsigned int res; }; }

variable_types:
p
unsigned long [10]

variable_types: struct cmdCtlParse_t { int eaten; char opt[4]; }

variable_types: struct cmdScript_t { int *par; int *var; struct cmdInstr_t { unsigned long p[5]; char opt[4]; } *instr; int instrs; char *str_area; int str_area_len; int str_area_pos; }

variable_types:
v
char [-1]

return_type: int

user_defined_types: struct cmdScript_t { int *par; int *var; struct cmdInstr_t *instr; int instrs; char *str_area; int str_area_len; int str_area_pos; }


timeStamp

decompiled_code:
char *timeStamp()
{
struct tm v1; // [rsp+0h] [rbp-58h] BYREF
struct timeval tv; // [rsp+40h] [rbp-18h] BYREF

gettimeofday(&tv, 0LL);
localtime_r(&tv.tv_sec, &v1);
strftime(buf_0, 0x20uLL, "%F %T", &v1);
return buf_0;
}

canonical_decompiled_code:
char *func0()
{
struct tm v1; // [rsp+0h] [rbp-58h] BYREF
struct timeval tv; // [rsp+40h] [rbp-18h] BYREF

gettimeofday(&tv, 0LL);
localtime_r(&tv.tv_sec, &v1);
strftime(buf_0, 0x20uLL, "%F %T", &v1);
return buf_0;
}

original_code:
static char * timeStamp()
{
   static char buf[32];
   struct timeval now;
   struct tm tmp;
   gettimeofday(&now, ((void *)0));
   localtime_r(&now.tv_sec, &tmp);
   strftime(buf, sizeof(buf), "%F %T", &tmp);
   return buf;
}

canonical_original_code:
static char *timeStamp()
{
   static char buf[32];
   struct timeval now;
   struct tm tmp;
   gettimeofday(&now, ((void *)0));
   localtime_r(&now.tv_sec, &tmp);
   strftime(buf, sizeof(buf), "%F %T", &tmp);
   return buf;
}

variable_types:
buf
char [32]

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

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

return_type: char *


symbol

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

result = (unsigned int)(a1 + 71);
if ( a1 <= 25 )
result = (unsigned int)(a1 + 65);
return result;
}

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

result = (unsigned int)(a1 + 71);
if ( a1 <= 25 )
result = (unsigned int)(a1 + 65);
return result;
}

original_code:
int symbol(int bit)
{
   if (bit < 26) return ('A' + bit);
   else return ('a' + bit - 26);
}

variable_types: bit int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
unsigned int i; // ebx
unsigned int v5; // eax
int v6; // er14
int v7; // ebp
int v8; // er13
int v9; // ebp
int j; // ebx
unsigned int v11; // er15
unsigned int v12; // eax
char buf[4]; // [rsp+4h] [rbp-44h] BYREF
int v15; // [rsp+8h] [rbp-40h]
int v16; // [rsp+Ch] [rbp-3Ch]

if ( (unsigned int)read(0, buf, 0xCuLL) != 12 )
exit(-1);
v3 = timeStamp();
printf("$date %s $end\n", v3);
puts("$version pig2vcd V1 $end");
puts("$timescale 1 us $end");
puts("$scope module top $end");
for ( i = 0; i != 32; ++i )
{
v5 = symbol(i);
printf("$var wire 1 %c %d $end\n", v5, i);
}
puts("$upscope $end");
puts("$enddefinitions $end");
v6 = v15;
v7 = 0;
while ( (unsigned int)read(0, buf, 0xCuLL) == 12 )
{
if ( v16 != v7 )
{
printf("#%u\n", (unsigned int)(v15 - v6));
v8 = v16;
v9 = v16 ^ v7;
for ( j = 0; j != 32; ++j )
{
if ( (v9 & (1 << j)) != 0 )
{
v11 = 48 - (((v16 & (1 << j)) == 0) - 1);
v12 = symbol(j);
printf("%c%c\n", v11, v12);
}
}
v7 = v8;
}
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char *v3; // rax
unsigned int i; // ebx
unsigned int v5; // eax
int v6; // er14
int v7; // ebp
int v8; // er13
int v9; // ebp
int j; // ebx
unsigned int v11; // er15
unsigned int v12; // eax
char buf[4]; // [rsp+4h] [rbp-44h] BYREF
int v15; // [rsp+8h] [rbp-40h]
int v16; // [rsp+Ch] [rbp-3Ch]

if ( (unsigned int)read(0, buf, 0xCuLL) != 12 )
exit(-1);
v3 = func0();
printf("$date %s $end\n", v3);
puts("$version pig2vcd V1 $end");
puts("$timescale 1 us $end");
puts("$scope module top $end");
for ( i = 0; i != 32; ++i )
{
v5 = func1(i);
printf("$var wire 1 %c %d $end\n", v5, i);
}
puts("$upscope $end");
puts("$enddefinitions $end");
v6 = v15;
v7 = 0;
while ( (unsigned int)read(0, buf, 0xCuLL) == 12 )
{
if ( v16 != v7 )
{
printf("#%u\n", (unsigned int)(v15 - v6));
v8 = v16;
v9 = v16 ^ v7;
for ( j = 0; j != 32; ++j )
{
if ( (v9 & (1 << j)) != 0 )
{
v11 = 48 - (((v16 & (1 << j)) == 0) - 1);
v12 = func1(j);
printf("%c%c\n", v11, v12);
}
}
v7 = v8;
}
}
return 0;
}

original_code:
int main(int argc, char * argv[])
{
   int b, r, v;
   uint32_t t0;
   uint32_t lastLevel, changed;
   gpioReport_t report;
   r=read(0, &report, (sizeof(gpioReport_t)));
   if (r != (sizeof(gpioReport_t))) exit(-1);
   printf("$date %s $end\n", timeStamp());
   printf("$version pig2vcd V1 $end\n");
   printf("$timescale 1 us $end\n");
   printf("$scope module top $end\n");
   for (b=0; b<32; b++)
      printf("$var wire 1 %c %d $end\n", symbol(b), b);
   printf("$upscope $end\n");
   printf("$enddefinitions $end\n");
   t0 = report.tick;
   lastLevel =0;
   while ((r=read(0, &report, (sizeof(gpioReport_t)))) == (sizeof(gpioReport_t)))
   {
      if (report.level != lastLevel)
      {
         printf("#%u\n", report.tick - t0);
         changed = report.level ^ lastLevel;
         lastLevel = report.level;
         for (b=0; b<32; b++)
         {
            if (changed & (1<<b))
            {
               if (report.level & (1<<b)) v='1'; else v='0';
               printf("%c%c\n", v, symbol(b));
            }
         }
      }
   }
   return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
   int b; int r; int v;
   unsigned int t0;
   unsigned int lastLevel; unsigned int changed;
   struct gpioReport_t report;
   r=read(0, &report, (sizeof(gpioReport_t)));
   if (r != (sizeof(gpioReport_t))) exit(-1);
   printf("$date %s $end\n", timeStamp());
   printf("$version pig2vcd V1 $end\n");
   printf("$timescale 1 us $end\n");
   printf("$scope module top $end\n");
   for (b=0; b<32; b++)
      printf("$var wire 1 %c %d $end\n", symbol(b), b);
   printf("$upscope $end\n");
   printf("$enddefinitions $end\n");
   t0 = report.tick;
   lastLevel =0;
   while ((r=read(0, &report, (sizeof(gpioReport_t)))) == (sizeof(gpioReport_t)))
   {
      if (report.level != lastLevel)
      {
         printf("#%u\n", report.tick - t0);
         changed = report.level ^ lastLevel;
         lastLevel = report.level;
         for (b=0; b<32; b++)
         {
            if (changed & (1<<b))
            {
               if (report.level & (1<<b)) v='1'; else v='0';
               printf("%c%c\n", v, symbol(b));
            }
         }
      }
   }
   return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: b int

variable_types: r int

variable_types: v int

variable_types:
lastLevel
unsigned int

variable_types:
changed
unsigned int

variable_types: struct gpioReport_t { unsigned short seqno; unsigned short flags; unsigned int tick; unsigned int level; }


dsign

repo: joao-o/prjprog

decompiled_code:
double __fastcall dsign(double a1)
{
return (double)((a1 > 0.0) - (a1 < 0.0));
}

canonical_decompiled_code:
double __fastcall func0(double a1)
{
return (double)((a1 > 0.0) - (a1 < 0.0));
}

original_code:
double
dsign (double x)
{
  return (x > 0) - (x < 0);
}

canonical_original_code:
double dsign(double x)
{
  return (x > 0) - (x < 0);
}

variable_types: x double

return_type: double


min

decompiled_code:
__m128 __fastcall min(double a1, __m128 a2)
{
*(double *)a2.m128_u64 = fmin(*(double *)a2.m128_u64, a1);
return a2;
}

canonical_decompiled_code:
__m128 __fastcall func1(double a1, __m128 a2)
{
*(double *)a2.m128_u64 = fmin(*(double *)a2.m128_u64, a1);
return a2;
}

original_code:
double
min (double x, double y)
{
  return x > y ? y : x;
}

canonical_original_code:
double min(double x, double y)
{
  return x > y ? y : x;
}

variable_types: y double


repo: joaomlneto/asa-jobs

decompiled_code:
__int64 read_input()
{
__int64 v0; // r12
unsigned __int64 v1; // rbp
unsigned __int64 i; // rbx
__int64 v4; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v5; // [rsp+8h] [rbp-30h] BYREF
__int64 v6; // [rsp+10h] [rbp-28h] BYREF
unsigned __int64 v7[4]; // [rsp+18h] [rbp-20h] BYREF

scanf("%lu", v7);
scanf("%lu", &v6);
v0 = testcase_create(v7[0], v6);
if ( v7[0] )
{
v1 = 0LL;
do
{
scanf("%lu", &v5);
if ( v5 )
{
for ( i = 0LL; i < v5; ++i )
{
scanf("%lu", &v4);
testcase_add_application(v0, v1, v4);
}
}
++v1;
}
while ( v7[0] > v1 );
}
return v0;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 v0; // r12
unsigned __int64 v1; // rbp
unsigned __int64 i; // rbx
__int64 v4; // [rsp+0h] [rbp-38h] BYREF
unsigned __int64 v5; // [rsp+8h] [rbp-30h] BYREF
__int64 v6; // [rsp+10h] [rbp-28h] BYREF
unsigned __int64 v7[4]; // [rsp+18h] [rbp-20h] BYREF

scanf("%lu", v7);
scanf("%lu", &v6);
v0 = testcase_create(v7[0], v6);
if ( v7[0] )
{
v1 = 0LL;
do
{
scanf("%lu", &v5);
if ( v5 )
{
for ( i = 0LL; i < v5; ++i )
{
scanf("%lu", &v4);
func11(v0, v1, v4);
}
}
++v1;
}
while ( v7[0] > v1 );
}
return v0;
}

original_code:
testcase read_input() {
 testcase t;
 long unsigned int num_students, num_jobs;
 long unsigned int student, application, num_applications, job;
 scanf("%lu", &num_students);
 scanf("%lu", &num_jobs);
 t = testcase_create(num_students, num_jobs);
 for(student=0; student<num_students; student++) {
  scanf("%lu", &num_applications);
  for(application=0; application<num_applications; application++) {
   scanf("%lu", &job);
   testcase_add_application(t, student, job);
  }
 }
 return t;
}

canonical_original_code:
struct testcase *read_input() {
 struct testcase *t;
 unsigned long num_students; unsigned long num_jobs;
 unsigned long student; unsigned long application; unsigned long num_applications; unsigned long job;
 scanf("%lu", &num_students);
 scanf("%lu", &num_jobs);
 t = testcase_create(num_students, num_jobs);
 for(student=0; student<num_students; student++) {
  scanf("%lu", &num_applications);
  for(application=0; application<num_applications; application++) {
   scanf("%lu", &job);
   testcase_add_application(t, student, job);
  }
 }
 return t;
}

variable_types: struct testcase { unsigned long num_students; unsigned long num_jobs; unsigned long num_vertices; struct fifo { int size; struct fifo_item { struct fifo_item *next; unsigned long value; } *first; struct fifo_item *last; } **adjacencies; unsigned long *pair_g1; unsigned long *pair_g2; unsigned long *dist; unsigned long matching; } *

variable_types:
student
unsigned long

variable_types:
application
unsigned long

variable_types:
job
unsigned long

user_defined_types: struct testcase { unsigned long num_students; unsigned long num_jobs; unsigned long num_vertices; struct fifo **adjacencies; unsigned long *pair_g1; unsigned long *pair_g2; unsigned long *dist; unsigned long matching; }

user_defined_types: struct fifo { int size; struct fifo_item *first; struct fifo_item *last; }


main

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

v3 = (_QWORD *)read_input(argc, argv, envp);
hopcroft_karp(v3);
printf("%lu\n", v3[7]);
testcase_destroy(v3);
return 0;
}

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

v3 = (_QWORD *)func7(argc, argv, envp);
func15(v3);
printf("%lu\n", v3[7]);
func10(v3);
return 0;
}

original_code:
int main() {
 testcase t = read_input();
 hopcroft_karp(t);
 printf("%lu\n", t->matching);
 testcase_destroy(t);
 return 0;
}

canonical_original_code:
int main() {
 struct testcase *t = read_input();
 hopcroft_karp(t);
 printf("%lu\n", t->matching);
 testcase_destroy(t);
 return 0;
}

user_defined_types: struct fifo_item { struct fifo_item *next; unsigned long value; }


decompiled_code:
__int64 __fastcall job_index(_QWORD *a1, __int64 a2)
{
return *a1 + a2 + 1;
}

canonical_decompiled_code:
__int64 __fastcall func8(_QWORD *a1, __int64 a2)
{
return *a1 + a2 + 1;
}

original_code:
long unsigned int job_index(testcase t, long unsigned int job) {
 return t->num_students + job + 1;
}

canonical_original_code:
unsigned long job_index(struct testcase *t, unsigned long job) {
 return t->num_students + job + 1;
}

return_type: unsigned long


decompiled_code:
__int64 __fastcall student_index(__int64 a1, __int64 a2)
{
return a2 + 1;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2)
{
return a2 + 1;
}

original_code:
long unsigned int student_index(testcase t, long unsigned int student) {
 return student + 1;
}

canonical_original_code:
unsigned long student_index(struct testcase *t, unsigned long student) {
 return student + 1;
}


decompiled_code:
void __fastcall testcase_destroy(void *ptr)
{
unsigned __int64 v1; // rbx

if ( *((_QWORD *)ptr + 2) )
{
v1 = 0LL;
do
fifo_destroy(*(void **)(*((_QWORD *)ptr + 3) + 8 * v1++));
while ( *((_QWORD *)ptr + 2) > v1 );
}
free(*((void **)ptr + 3));
free(*((void **)ptr + 4));
free(*((void **)ptr + 5));
free(*((void **)ptr + 6));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func10(void *ptr)
{
unsigned __int64 v1; // rbx

if ( *((_QWORD *)ptr + 2) )
{
v1 = 0LL;
do
func18(*(void **)(*((_QWORD *)ptr + 3) + 8 * v1++));
while ( *((_QWORD *)ptr + 2) > v1 );
}
free(*((void **)ptr + 3));
free(*((void **)ptr + 4));
free(*((void **)ptr + 5));
free(*((void **)ptr + 6));
free(ptr);
}

original_code:
void testcase_destroy(testcase t) {
 long unsigned int i;
 for(i=0; i<t->num_vertices; i++) {
  fifo_destroy(t->adjacencies[i]);
 }
 free(t->adjacencies);
 free(t->pair_g1);
 free(t->pair_g2);
 free(t->dist);
 free(t);
}

canonical_original_code:
void testcase_destroy(struct testcase *t) {
 unsigned long i;
 for(i=0; i<t->num_vertices; i++) {
  fifo_destroy(t->adjacencies[i]);
 }
 free(t->adjacencies);
 free(t->pair_g1);
 free(t->pair_g2);
 free(t->dist);
 free(t);
}

variable_types:
i
unsigned long

return_type: void


decompiled_code:
__int64 __fastcall testcase_add_application(_QWORD *a1, __int64 a2, __int64 a3)
{
__int64 v4; // r13
__int64 v5; // rbp
__int64 v6; // rax

v4 = job_index(a1, a3);
v5 = student_index((__int64)a1, a2);
fifo_queue(*(_QWORD *)(a1[3] + 8 * v5), v4);
v6 = job_index(a1, a3);
return fifo_queue(*(_QWORD *)(a1[3] + 8 * v6), v5);
}

original_code:
void testcase_add_application(testcase t, long unsigned int student, long unsigned int job) {
 fifo_queue(t->adjacencies[student_index(t, student)], job_index(t, job));
 fifo_queue(t->adjacencies[job_index(t, job)], student_index(t, student));
}

canonical_original_code:
void testcase_add_application(struct testcase *t, unsigned long student, unsigned long job) {
 fifo_queue(t->adjacencies[student_index(t, student)], job_index(t, job));
 fifo_queue(t->adjacencies[job_index(t, job)], student_index(t, student));
}


decompiled_code:
int __fastcall testcase_print(_QWORD *a1)
{
unsigned __int64 v1; // rbx
int result; // eax
unsigned __int64 v3; // rbx

puts("==========[TESTCASE]==========");
printf("num_students = %lu\n", *a1);
printf("num_jobs = %lu\n", a1[1]);
printf("matching = %lu\n", a1[7]);
puts("=========[ADJACENCIES]=========");
if ( a1[2] )
{
v1 = 0LL;
do
{
printf("Adjacencies for vertex %lu: ", v1);
fifo_print(*(_QWORD *)(a1[3] + 8 * v1));
putchar(10);
++v1;
}
while ( a1[2] > v1 );
}
result = puts("====[OTHERS]==== (pair_g1, pair_g2, dist)");
if ( a1[2] )
{
v3 = 0LL;
do
{
result = printf(
"Vertex %lu: pair_g1=%lu pair_g2=%lu dist=%lu\n",
v3,
*(_QWORD *)(a1[4] + 8 * v3),
*(_QWORD *)(a1[5] + 8 * v3),
*(_QWORD *)(a1[6] + 8 * v3));
++v3;
}
while ( a1[2] > v3 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func12(_QWORD *a1)
{
unsigned __int64 v1; // rbx
int result; // eax
unsigned __int64 v3; // rbx

puts("==========[TESTCASE]==========");
printf("num_students = %lu\n", *a1);
printf("num_jobs = %lu\n", a1[1]);
printf("matching = %lu\n", a1[7]);
puts("=========[ADJACENCIES]=========");
if ( a1[2] )
{
v1 = 0LL;
do
{
printf("Adjacencies for vertex %lu: ", v1);
func21(*(_QWORD *)(a1[3] + 8 * v1));
putchar(10);
++v1;
}
while ( a1[2] > v1 );
}
result = puts("====[OTHERS]==== (pair_g1, pair_g2, dist)");
if ( a1[2] )
{
v3 = 0LL;
do
{
result = printf(
"Vertex %lu: pair_g1=%lu pair_g2=%lu dist=%lu\n",
v3,
*(_QWORD *)(a1[4] + 8 * v3),
*(_QWORD *)(a1[5] + 8 * v3),
*(_QWORD *)(a1[6] + 8 * v3));
++v3;
}
while ( a1[2] > v3 );
}
return result;
}

original_code:
void testcase_print(testcase t) {
 long unsigned int i;
 printf("==========[TESTCASE]==========\n");
 printf("num_students = %lu\n", t->num_students);
 printf("num_jobs = %lu\n", t->num_jobs);
 printf("matching = %lu\n", t->matching);
 printf("=========[ADJACENCIES]=========\n");
 for(i=0; i<t->num_vertices; i++) {
  printf("Adjacencies for vertex %lu: ", i);
  fifo_print(t->adjacencies[i]);
  printf("\n");
 }
 printf("====[OTHERS]==== (pair_g1, pair_g2, dist)\n");
 for(i=0; i<t->num_vertices; i++) {
  printf("Vertex %lu: pair_g1=%lu pair_g2=%lu dist=%lu\n", i, t->pair_g1[i], t->pair_g2[i], t->dist[i]);
 }
}

canonical_original_code:
void testcase_print(struct testcase *t) {
 unsigned long i;
 printf("==========[TESTCASE]==========\n");
 printf("num_students = %lu\n", t->num_students);
 printf("num_jobs = %lu\n", t->num_jobs);
 printf("matching = %lu\n", t->matching);
 printf("=========[ADJACENCIES]=========\n");
 for(i=0; i<t->num_vertices; i++) {
  printf("Adjacencies for vertex %lu: ", i);
  fifo_print(t->adjacencies[i]);
  printf("\n");
 }
 printf("====[OTHERS]==== (pair_g1, pair_g2, dist)\n");
 for(i=0; i<t->num_vertices; i++) {
  printf("Vertex %lu: pair_g1=%lu pair_g2=%lu dist=%lu\n", i, t->pair_g1[i], t->pair_g2[i], t->dist[i]);
 }
}


original_code:
_Bool hopcroft_karp_bfs(testcase t) {
 fifo q = fifo_create();
 fifo_item item;
 long unsigned int v, u;
 for(v=1; v<t->num_students+1; v++) {
  if(t->pair_g1[v] == 0) {
   t->dist[v] = 0;
   fifo_queue(q, v);
  }
  else {
   t->dist[v] = 1000000000;
  }
 }
 t->dist[0] = 1000000000;
 while(q->size != 0) {
  v = fifo_dequeue(q);
  if(t->dist[v] < t->dist[0]) {
   for(item = t->adjacencies[v]->first; item != ((void *)0); item = item->next) {
    u = item->value;
    if(t->dist[t->pair_g2[u]] == 1000000000) {
     t->dist[t->pair_g2[u]] = t->dist[v] + 1;
     fifo_queue(q, t->pair_g2[u]);
    }
   }
  }
 }
 fifo_destroy(q);
 return (t->dist[0] != 1000000000);
}

canonical_original_code:
_Bool hopcroft_karp_bfs(struct testcase *t) {
 struct fifo *q = fifo_create();
 struct fifo_item *item;
 unsigned long v; unsigned long u;
 for(v=1; v<t->num_students+1; v++) {
  if(t->pair_g1[v] == 0) {
   t->dist[v] = 0;
   fifo_queue(q, v);
  }
  else {
   t->dist[v] = 1000000000;
  }
 }
 t->dist[0] = 1000000000;
 while(q->size != 0) {
  v = fifo_dequeue(q);
  if(t->dist[v] < t->dist[0]) {
   for(item = t->adjacencies[v]->first; item != ((void *)0); item = item->next) {
    u = item->value;
    if(t->dist[t->pair_g2[u]] == 1000000000) {
     t->dist[t->pair_g2[u]] = t->dist[v] + 1;
     fifo_queue(q, t->pair_g2[u]);
    }
   }
  }
 }
 fifo_destroy(q);
 return (t->dist[0] != 1000000000);
}

variable_types: struct fifo { int size; struct fifo_item { struct fifo_item *next; unsigned long value; } *first; struct fifo_item *last; } *

variable_types:
v
unsigned long

variable_types:
u
unsigned long


original_code:
_Bool hopcroft_karp_dfs(testcase t, long unsigned int v) {
 fifo_item item;
 long unsigned int u;
 if(v == 0) {
  return 1;
 }
 for(item = t->adjacencies[v]->first; item != ((void *)0); item = item->next) {
  u = item->value;
  if(t->dist[t->pair_g2[u]] == t->dist[v] + 1) {
   if(hopcroft_karp_dfs(t, t->pair_g2[u])) {
    t->pair_g2[u] = v;
    t->pair_g1[v] = u;
    return 1;
   }
  }
 }
 t->dist[v] = 1000000000;
 return 0;
}

canonical_original_code:
_Bool hopcroft_karp_dfs(struct testcase *t, unsigned long v) {
 struct fifo_item *item;
 unsigned long u;
 if(v == 0) {
  return 1;
 }
 for(item = t->adjacencies[v]->first; item != ((void *)0); item = item->next) {
  u = item->value;
  if(t->dist[t->pair_g2[u]] == t->dist[v] + 1) {
   if(hopcroft_karp_dfs(t, t->pair_g2[u])) {
    t->pair_g2[u] = v;
    t->pair_g1[v] = u;
    return 1;
   }
  }
 }
 t->dist[v] = 1000000000;
 return 0;
}

variable_types: struct fifo_item { struct fifo_item *next; unsigned long value; } *


decompiled_code:
__int64 __fastcall hopcroft_karp(_QWORD *a1)
{
unsigned __int64 v1; // rax
unsigned __int64 i; // rbx

if ( a1[2] )
{
v1 = 0LL;
do
{
*(_QWORD *)(a1[4] + 8 * v1) = 0LL;
*(_QWORD *)(a1[5] + 8 * v1++) = 0LL;
}
while ( a1[2] > v1 );
}
a1[7] = 0LL;
while ( hopcroft_karp_bfs(a1) )
{
for ( i = 1LL; *a1 + 1LL > i; ++i )
{
if ( !*(_QWORD *)(a1[4] + 8 * i) )
{
if ( (unsigned __int8)hopcroft_karp_dfs(a1, i) )
++a1[7];
}
}
}
return a1[7];
}

original_code:
long unsigned int hopcroft_karp(testcase t) {
 long unsigned int v;
 for(v=0; v<t->num_vertices; v++) {
  t->pair_g1[v] = 0;
  t->pair_g2[v] = 0;
 }
 t->matching = 0;
 while(hopcroft_karp_bfs(t)) {
  for(v=1; v<t->num_students+1; v++) {
   if(t->pair_g1[v] == 0) {
    if(hopcroft_karp_dfs(t, v)) {
     t->matching++;
    }
   }
  }
 }
 return t->matching;
}

canonical_original_code:
unsigned long hopcroft_karp(struct testcase *t) {
 unsigned long v;
 for(v=0; v<t->num_vertices; v++) {
  t->pair_g1[v] = 0;
  t->pair_g2[v] = 0;
 }
 t->matching = 0;
 while(hopcroft_karp_bfs(t)) {
  for(v=1; v<t->num_students+1; v++) {
   if(t->pair_g1[v] == 0) {
    if(hopcroft_karp_dfs(t, v)) {
     t->matching++;
    }
   }
  }
 }
 return t->matching;
}


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

result = malloc(0x18uLL);
*(_DWORD *)result = 0;
result[1] = 0LL;
result[2] = 0LL;
return result;
}

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

result = malloc(0x18uLL);
*(_DWORD *)result = 0;
result[1] = 0LL;
result[2] = 0LL;
return result;
}

original_code:
fifo fifo_create() {
 fifo f = malloc(sizeof(fifo_t));
 f->size = 0;
 f->first = ((void *)0);
 f->last = ((void *)0);
 return f;
}

canonical_original_code:
struct fifo *fifo_create() {
 struct fifo *f = malloc(sizeof(fifo_t));
 f->size = 0;
 f->first = ((void *)0);
 f->last = ((void *)0);
 return f;
}

return_type: struct fifo { int size; struct fifo_item { struct fifo_item *next; unsigned long value; } *first; struct fifo_item *last; } *


decompiled_code:
__int64 __fastcall fifo_item_destroy(_QWORD *a1)
{
__int64 v1; // rbx

v1 = a1[1];
free(a1);
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func17(_QWORD *a1)
{
__int64 v1; // rbx

v1 = a1[1];
free(a1);
return v1;
}

original_code:
long unsigned int fifo_item_destroy(fifo_item item) {
 long unsigned int value = item->value;
 free(item);
 return value;
}

canonical_original_code:
unsigned long fifo_item_destroy(struct fifo_item *item) {
 unsigned long value = item->value;
 free(item);
 return value;
}

variable_types:
value
unsigned long


decompiled_code:
void __fastcall fifo_destroy(void *ptr)
{
_QWORD *v2; // rbx
_QWORD *v3; // rdi

v2 = (_QWORD *)*((_QWORD *)ptr + 1);
while ( v2 )
{
v3 = v2;
v2 = (_QWORD *)*v2;
fifo_item_destroy(v3);
}
free(ptr);
}

canonical_decompiled_code:
void __fastcall func18(void *ptr)
{
_QWORD *v2; // rbx
_QWORD *v3; // rdi

v2 = (_QWORD *)*((_QWORD *)ptr + 1);
while ( v2 )
{
v3 = v2;
v2 = (_QWORD *)*v2;
func17(v3);
}
free(ptr);
}

original_code:
void fifo_destroy(fifo f) {
 fifo_item item = f->first;
 fifo_item aux;
 while(item != ((void *)0)) {
  aux = item->next;
  fifo_item_destroy(item);
  item = aux;
 }
 free(f);
}

canonical_original_code:
void fifo_destroy(struct fifo *f) {
 struct fifo_item *item = f->first;
 struct fifo_item *aux;
 while(item != ((void *)0)) {
  aux = item->next;
  fifo_item_destroy(item);
  item = aux;
 }
 free(f);
}


decompiled_code:
__int64 __fastcall fifo_dequeue(__int64 a1)
{
_QWORD *v1; // rax

v1 = *(_QWORD **)(a1 + 8);
if ( !v1 )
return -1LL;
*(_QWORD *)(a1 + 8) = *v1;
--*(_DWORD *)a1;
return fifo_item_destroy(v1);
}

original_code:
long unsigned int fifo_dequeue(fifo f) {
 fifo_item item = f->first;
 if(f->first == ((void *)0)) {
  return -1;
 }
 f->first = item->next;
 f->size--;
 return fifo_item_destroy(item);
}

canonical_original_code:
unsigned long fifo_dequeue(struct fifo *f) {
 struct fifo_item *item = f->first;
 if(f->first == ((void *)0)) {
  return -1;
 }
 f->first = item->next;
 f->size--;
 return fifo_item_destroy(item);
}


decompiled_code:
int __fastcall fifo_item_print(__int64 a1)
{
return printf("%lu", *(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
int __fastcall func20(__int64 a1)
{
return printf("%lu", *(_QWORD *)(a1 + 8));
}

original_code:
void fifo_item_print(fifo_item item) {
 printf("%lu", item->value);
}

canonical_original_code:
void fifo_item_print(struct fifo_item *item) {
 printf("%lu", item->value);
}


decompiled_code:
int __fastcall fifo_print(unsigned int *a1)
{
_QWORD *v1; // rbx

v1 = (_QWORD *)*((_QWORD *)a1 + 1);
printf("[FIFO size=%d] ", *a1);
for ( ; v1; v1 = (_QWORD *)*v1 )
{
fifo_item_print((__int64)v1);
putchar(32);
}
return printf("[/FIFO]");
}

canonical_decompiled_code:
int __fastcall func21(unsigned int *a1)
{
_QWORD *v1; // rbx

v1 = (_QWORD *)*((_QWORD *)a1 + 1);
printf("[FIFO size=%d] ", *a1);
for ( ; v1; v1 = (_QWORD *)*v1 )
{
func20((__int64)v1);
putchar(32);
}
return printf("[/FIFO]");
}

original_code:
void fifo_print(fifo f) {
 fifo_item p = f->first;
 printf("[FIFO size=%d] ", f->size);
 while(p != ((void *)0)) {
  fifo_item_print(p);
  printf(" ");
  p = p->next;
 }
 printf("[/FIFO]");
}

canonical_original_code:
void fifo_print(struct fifo *f) {
 struct fifo_item *p = f->first;
 printf("[FIFO size=%d] ", f->size);
 while(p != ((void *)0)) {
  fifo_item_print(p);
  printf(" ");
  p = p->next;
 }
 printf("[/FIFO]");
}


deleteHeightMap

repo: joaomlneto/iaed-tetraminos

decompiled_code:
void __fastcall deleteHeightMap(void *a1)
{
free(a1);
}

canonical_decompiled_code:
void __fastcall func0(void *a1)
{
free(a1);
}

original_code:
void deleteHeightMap(HeightMap *heightMap) {
 free(heightMap);
 return;
}

canonical_original_code:
void deleteHeightMap(struct HeightMap *heightMap) {
 free(heightMap);
 return;
}

variable_types:
heightMap
struct HeightMap { int columns[10]; } *


resetHeightMap

decompiled_code:
__int64 __fastcall resetHeightMap(__int64 a1)
{
return vectorInit(a1, 10LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return vectorInit(a1, 10LL, 0LL);
}

original_code:
void resetHeightMap(HeightMap *heightMap) {
 vectorInit(heightMap->columns, 10, 0);
}

canonical_original_code:
void resetHeightMap(struct HeightMap *heightMap) {
 vectorInit(heightMap->columns, 10, 0);
}


newHeightMap

decompiled_code:
void *newHeightMap()
{
void *v0; // rbx

v0 = malloc(0x28uLL);
resetHeightMap((__int64)v0);
return v0;
}

canonical_decompiled_code:
void *func2()
{
void *v0; // rbx

v0 = malloc(0x28uLL);
func1((__int64)v0);
return v0;
}

original_code:
HeightMap* newHeightMap() {
 HeightMap *heightMap = malloc(sizeof(HeightMap));
 resetHeightMap(heightMap);
 return heightMap;
}

canonical_original_code:
struct HeightMap *newHeightMap() {
 struct HeightMap *heightMap = malloc(sizeof(HeightMap));
 resetHeightMap(heightMap);
 return heightMap;
}

return_type: struct HeightMap { int columns[10]; } *


getHeightMapMax

decompiled_code:
__int64 __fastcall getHeightMapMax(__int64 a1)
{
return vectorMax(a1, 10LL);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return vectorMax(a1, 10LL);
}

original_code:
int getHeightMapMax(HeightMap *heightMap) {
 return vectorMax(heightMap->columns, 10);
}

canonical_original_code:
int getHeightMapMax(struct HeightMap *heightMap) {
 return vectorMax(heightMap->columns, 10);
}


getColumnHeight

decompiled_code:
__int64 __fastcall getColumnHeight(__int64 a1, int a2)
{
return *(unsigned int *)(a1 + 4LL * (a2 - 1));
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int a2)
{
return *(unsigned int *)(a1 + 4LL * (a2 - 1));
}

original_code:
int getColumnHeight(HeightMap *heightMap, int column) {
 return (heightMap->columns)[column-1];
}

canonical_original_code:
int getColumnHeight(struct HeightMap *heightMap, int column) {
 return (heightMap->columns)[column-1];
}

variable_types: column int


setColumnHeight

decompiled_code:
void __fastcall setColumnHeight(__int64 a1, int a2, int a3)
{
*(_DWORD *)(a1 + 4LL * (a2 - 1)) = a3;
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, int a2, int a3)
{
*(_DWORD *)(a1 + 4LL * (a2 - 1)) = a3;
}

original_code:
void setColumnHeight(HeightMap *heightMap, int column, int height) {
 (heightMap->columns)[column-1] = height;
 return;
}

canonical_original_code:
void setColumnHeight(struct HeightMap *heightMap, int column, int height) {
 (heightMap->columns)[column-1] = height;
 return;
}

variable_types: height int


getGameAreaFirst

decompiled_code:
__int64 __fastcall getGameAreaFirst(__int64 a1)
{
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return *(_QWORD *)a1;
}

original_code:
Line* getGameAreaFirst(GameArea *g) {
 return g->gameLineFirst;
}

canonical_original_code:
struct Line *getGameAreaFirst(struct GameArea *g) {
 return g->gameLineFirst;
}

variable_types: struct GameArea { struct Line *gameLineFirst; struct Line *gameLineLast; int num_lines; struct HeightMap { int columns[10]; } *heightMap; struct Line *deletedLinesFirst; struct Line *deletedLinesLast; int num_deleted_lines; int score; int *piece_count; } *

return_type: struct Line { struct Line *previous; struct Line *next; char column[10]; struct t_location { int hash_pos; int num_lines; struct Line **lines; } **pieces; int num_t_locations; } *

user_defined_types: struct GameArea { struct Line *gameLineFirst; struct Line *gameLineLast; int num_lines; struct HeightMap *heightMap; struct Line *deletedLinesFirst; struct Line *deletedLinesLast; int num_deleted_lines; int score; int *piece_count; }

user_defined_types: struct Line { struct Line *previous; struct Line *next; char column[10]; struct t_location **pieces; int num_t_locations; }


getGameAreaLast

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

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

original_code:
Line* getGameAreaLast(GameArea *g) {
 return g->gameLineLast;
}

canonical_original_code:
struct Line *getGameAreaLast(struct GameArea *g) {
 return g->gameLineLast;
}

user_defined_types: struct t_location { int hash_pos; int num_lines; struct Line **lines; }


getGameAreaNumLines

decompiled_code:
__int64 __fastcall getGameAreaNumLines(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return *(unsigned int *)(a1 + 16);
}

original_code:
int getGameAreaNumLines(GameArea *g) {
 return g->num_lines;
}

canonical_original_code:
int getGameAreaNumLines(struct GameArea *g) {
 return g->num_lines;
}

variable_types: struct GameArea { struct Line { struct Line *previous; struct Line *next; char column[10]; struct t_location { int hash_pos; int num_lines; struct Line **lines; } **pieces; int num_t_locations; } *gameLineFirst; struct Line *gameLineLast; int num_lines; struct HeightMap { int columns[10]; } *heightMap; struct Line *deletedLinesFirst; struct Line *deletedLinesLast; int num_deleted_lines; int score; int *piece_count; } *


getGameAreaHeightMap

decompiled_code:
__int64 __fastcall getGameAreaHeightMap(__int64 a1)
{
return *(_QWORD *)(a1 + 24);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return *(_QWORD *)(a1 + 24);
}

original_code:
HeightMap* getGameAreaHeightMap(GameArea *g) {
 return g->heightMap;
}

canonical_original_code:
struct HeightMap *getGameAreaHeightMap(struct GameArea *g) {
 return g->heightMap;
}

variable_types: struct GameArea { struct Line { struct Line *previous; struct Line *next; char column[10]; struct t_location { int hash_pos; int num_lines; struct Line **lines; } **pieces; int num_t_locations; } *gameLineFirst; struct Line *gameLineLast; int num_lines; struct HeightMap *heightMap; struct Line *deletedLinesFirst; struct Line *deletedLinesLast; int num_deleted_lines; int score; int *piece_count; } *


getGameAreaDeletedFirst

decompiled_code:
__int64 __fastcall getGameAreaDeletedFirst(__int64 a1)
{
return *(_QWORD *)(a1 + 32);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return *(_QWORD *)(a1 + 32);
}

original_code:
Line* getGameAreaDeletedFirst(GameArea *g) {
 return g->deletedLinesFirst;
}

canonical_original_code:
struct Line *getGameAreaDeletedFirst(struct GameArea *g) {
 return g->deletedLinesFirst;
}


getGameAreaDeletedLast

decompiled_code:
__int64 __fastcall getGameAreaDeletedLast(__int64 a1)
{
return *(_QWORD *)(a1 + 40);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return *(_QWORD *)(a1 + 40);
}

original_code:
Line* getGameAreaDeletedLast(GameArea *g) {
 return g->deletedLinesLast;
}

canonical_original_code:
struct Line *getGameAreaDeletedLast(struct GameArea *g) {
 return g->deletedLinesLast;
}


getGameAreaNumDeletedLines

decompiled_code:
__int64 __fastcall getGameAreaNumDeletedLines(__int64 a1)
{
return *(unsigned int *)(a1 + 48);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
return *(unsigned int *)(a1 + 48);
}

original_code:
int getGameAreaNumDeletedLines(GameArea *g) {
 return g->num_deleted_lines;
}

canonical_original_code:
int getGameAreaNumDeletedLines(struct GameArea *g) {
 return g->num_deleted_lines;
}


getGameAreaScore

decompiled_code:
__int64 __fastcall getGameAreaScore(__int64 a1)
{
return *(unsigned int *)(a1 + 52);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
return *(unsigned int *)(a1 + 52);
}

original_code:
int getGameAreaScore(GameArea *g) {
 return g->score;
}

canonical_original_code:
int getGameAreaScore(struct GameArea *g) {
 return g->score;
}


getGameAreaPieceCounts

decompiled_code:
__int64 __fastcall getGameAreaPieceCounts(__int64 a1)
{
return *(_QWORD *)(a1 + 56);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
return *(_QWORD *)(a1 + 56);
}

original_code:
int* getGameAreaPieceCounts(GameArea *g) {
 return g->piece_count;
}

canonical_original_code:
int *getGameAreaPieceCounts(struct GameArea *g) {
 return g->piece_count;
}

return_type: int *


clearGameArea

decompiled_code:
void __fastcall clearGameArea(void *ptr)
{
__int64 v1; // rbx
__int64 v2; // r12
void *v3; // rax
__int64 v4; // rbx
__int64 v5; // r12
void *v6; // rax

v1 = getGameAreaFirst((__int64)ptr);
while ( v1 )
{
v2 = v1;
v1 = getNextLine(v1);
eraseTLocations(ptr, v2);
deleteLine(v2);
}
v3 = (void *)getGameAreaHeightMap((__int64)ptr);
free(v3);
v4 = getGameAreaDeletedFirst((__int64)ptr);
while ( v4 )
{
v5 = v4;
v4 = getNextLine(v4);
deleteLine(v5);
}
v6 = (void *)getGameAreaPieceCounts((__int64)ptr);
free(v6);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func9(void *ptr)
{
__int64 v1; // rbx
__int64 v2; // r12
void *v3; // rax
__int64 v4; // rbx
__int64 v5; // r12
void *v6; // rax

v1 = func0((__int64)ptr);
while ( v1 )
{
v2 = v1;
v1 = getNextLine(v1);
eraseTLocations(ptr, v2);
deleteLine(v2);
}
v3 = (void *)func3((__int64)ptr);
free(v3);
v4 = func4((__int64)ptr);
while ( v4 )
{
v5 = v4;
v4 = getNextLine(v4);
deleteLine(v5);
}
v6 = (void *)func8((__int64)ptr);
free(v6);
free(ptr);
}

original_code:
void clearGameArea(GameArea *gameArea) {
 Line *line, *aux;
 line = getGameAreaFirst(gameArea);
 while(line != ((void *)0)) {
  aux = getNextLine(line);
  eraseTLocations(gameArea, line);
  deleteLine(line);
  line = aux;
 }
 free(getGameAreaHeightMap(gameArea));
 line = getGameAreaDeletedFirst(gameArea);
 while(line != ((void *)0)) {
  aux = getNextLine(line);
  deleteLine(line);
  line = aux;
 }
 free(getGameAreaPieceCounts(gameArea));
 free(gameArea);
 return;
}

canonical_original_code:
void clearGameArea(struct GameArea *gameArea) {
 struct Line *line; struct Line *aux;
 line = getGameAreaFirst(gameArea);
 while(line != ((void *)0)) {
  aux = getNextLine(line);
  eraseTLocations(gameArea, line);
  deleteLine(line);
  line = aux;
 }
 free(getGameAreaHeightMap(gameArea));
 line = getGameAreaDeletedFirst(gameArea);
 while(line != ((void *)0)) {
  aux = getNextLine(line);
  deleteLine(line);
  line = aux;
 }
 free(getGameAreaPieceCounts(gameArea));
 free(gameArea);
 return;
}

variable_types: struct Line { struct Line *previous; struct Line *next; char column[10]; struct t_location { int hash_pos; int num_lines; struct Line **lines; } **pieces; int num_t_locations; } *


setGameAreaLast

decompiled_code:
void __fastcall setGameAreaLast(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 8) = a2;
}

original_code:
void setGameAreaLast(GameArea *g, Line *l) {
 g->gameLineLast = l;
 return;
}

canonical_original_code:
void setGameAreaLast(struct GameArea *g, struct Line *l) {
 g->gameLineLast = l;
 return;
}

variable_types:
l
struct Line *


setGameAreaNumLines

decompiled_code:
void __fastcall setGameAreaNumLines(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 16) = a2;
}

canonical_decompiled_code:
void __fastcall func12(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 16) = a2;
}

original_code:
void setGameAreaNumLines(GameArea *g, int n) {
 g->num_lines = n;
 return;
}

canonical_original_code:
void setGameAreaNumLines(struct GameArea *g, int n) {
 g->num_lines = n;
 return;
}

variable_types: n int


setGameAreaHeightMap

decompiled_code:
void __fastcall setGameAreaHeightMap(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 24) = a2;
}

original_code:
void setGameAreaHeightMap(GameArea *gameArea, HeightMap *heightMap) {
 gameArea->heightMap = heightMap;
 return;
}

canonical_original_code:
void setGameAreaHeightMap(struct GameArea *gameArea, struct HeightMap *heightMap) {
 gameArea->heightMap = heightMap;
 return;
}

variable_types:
heightMap
struct HeightMap *


setGameAreaDeletedFirst

decompiled_code:
void __fastcall setGameAreaDeletedFirst(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 32) = a2;
}

original_code:
void setGameAreaDeletedFirst(GameArea *gameArea, Line *l) {
 gameArea->deletedLinesFirst = l;
 return;
}

canonical_original_code:
void setGameAreaDeletedFirst(struct GameArea *gameArea, struct Line *l) {
 gameArea->deletedLinesFirst = l;
 return;
}


setGameAreaDeletedLast

decompiled_code:
void __fastcall setGameAreaDeletedLast(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 40) = a2;
}

original_code:
void setGameAreaDeletedLast(GameArea *gameArea, Line *l) {
 gameArea->deletedLinesLast = l;
 return;
}

canonical_original_code:
void setGameAreaDeletedLast(struct GameArea *gameArea, struct Line *l) {
 gameArea->deletedLinesLast = l;
 return;
}


setGameAreaNumDeletedLines

decompiled_code:
void __fastcall setGameAreaNumDeletedLines(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 48) = a2;
}

canonical_decompiled_code:
void __fastcall func16(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 48) = a2;
}

original_code:
void setGameAreaNumDeletedLines(GameArea *gameArea, int n) {
 gameArea->num_deleted_lines = n;
 return;
}

canonical_original_code:
void setGameAreaNumDeletedLines(struct GameArea *gameArea, int n) {
 gameArea->num_deleted_lines = n;
 return;
}


setGameAreaScore

decompiled_code:
void __fastcall setGameAreaScore(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 52) = a2;
}

canonical_decompiled_code:
void __fastcall func17(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 52) = a2;
}

original_code:
void setGameAreaScore(GameArea *g, int score) {
 g->score = score;
 return;
}

canonical_original_code:
void setGameAreaScore(struct GameArea *g, int score) {
 g->score = score;
 return;
}

variable_types: score int


setGameAreaPieceCounts

decompiled_code:
void __fastcall setGameAreaPieceCounts(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 56) = a2;
}

original_code:
void setGameAreaPieceCounts(GameArea *g, int* piece_counts) {
 g->piece_count = piece_counts;
 return;
}

canonical_original_code:
void setGameAreaPieceCounts(struct GameArea *g, int *piece_counts) {
 g->piece_count = piece_counts;
 return;
}


newGameArea

decompiled_code:
_QWORD *newGameArea()
{
_QWORD *v0; // rbx
__int64 v1; // rax
__int64 v2; // rax

v0 = malloc(0x40uLL);
setGameAreaFirst(v0, 0LL);
setGameAreaLast((__int64)v0, 0LL);
setGameAreaNumLines((__int64)v0, 0);
v1 = newHeightMap();
setGameAreaHeightMap((__int64)v0, v1);
setGameAreaDeletedFirst((__int64)v0, 0LL);
setGameAreaDeletedLast((__int64)v0, 0LL);
setGameAreaNumDeletedLines((__int64)v0, 0);
setGameAreaScore((__int64)v0, 0);
v2 = newTHash();
setGameAreaPieceCounts((__int64)v0, v2);
return v0;
}

original_code:
GameArea* newGameArea() {
 GameArea *g = malloc(sizeof(GameArea));
 setGameAreaFirst(g, ((void *)0));
 setGameAreaLast(g, ((void *)0));
 setGameAreaNumLines(g, 0);
 setGameAreaHeightMap(g, newHeightMap());
 setGameAreaDeletedFirst(g, ((void *)0));
 setGameAreaDeletedLast(g, ((void *)0));
 setGameAreaNumDeletedLines(g, 0);
 setGameAreaScore(g, 0);
 setGameAreaPieceCounts(g, newTHash());
 return g;
}

canonical_original_code:
struct GameArea *newGameArea() {
 struct GameArea *g = malloc(sizeof(GameArea));
 setGameAreaFirst(g, ((void *)0));
 setGameAreaLast(g, ((void *)0));
 setGameAreaNumLines(g, 0);
 setGameAreaHeightMap(g, newHeightMap());
 setGameAreaDeletedFirst(g, ((void *)0));
 setGameAreaDeletedLast(g, ((void *)0));
 setGameAreaNumDeletedLines(g, 0);
 setGameAreaScore(g, 0);
 setGameAreaPieceCounts(g, newTHash());
 return g;
}

return_type: struct GameArea { struct Line { struct Line *previous; struct Line *next; char column[10]; struct t_location { int hash_pos; int num_lines; struct Line **lines; } **pieces; int num_t_locations; } *gameLineFirst; struct Line *gameLineLast; int num_lines; struct HeightMap { int columns[10]; } *heightMap; struct Line *deletedLinesFirst; struct Line *deletedLinesLast; int num_deleted_lines; int score; int *piece_count; } *


getGameLine

decompiled_code:
__int64 __fastcall getGameLine(__int64 a1, int a2)
{
int v2; // eax
int v3; // ebp
__int64 v4; // rax
__int64 v5; // rdi
int v6; // ebp
__int64 v7; // rax
__int64 v9; // rax
__int64 v10; // rax

v2 = getGameAreaNumLines(a1);
if ( v2 < a2 )
return 0LL;
v3 = v2;
if ( a2 <= 0 )
return 0LL;
if ( v2 / 2 < a2 )
{
v9 = getGameAreaLast(a1);
v5 = v9;
if ( v3 > a2 && v9 )
{
do
{
v10 = getPreviousLine(v5);
v5 = v10;
--v3;
}
while ( a2 < v3 && v10 );
}
}
else
{
v4 = getGameAreaFirst(a1);
v5 = v4;
if ( a2 > 1 && v4 )
{
v6 = 1;
do
{
v7 = getNextLine(v5);
v5 = v7;
++v6;
}
while ( a2 > v6 && v7 );
}
}
return v5;
}

original_code:
Line* getGameLine(GameArea *g, int line_num) {
 int i;
 int num_lines = getGameAreaNumLines(g);
 Line *line;
 if (line_num > num_lines || line_num < 1) {
  return ((void *)0);
 }
 if((line_num <= (num_lines/2))) {
  line = getGameAreaFirst(g);
  for (i=1; (i<line_num && line != ((void *)0)); i++) {
   line = getNextLine(line);
  }
 }
 else {
  line = getGameAreaLast(g);
  for (i=num_lines; i>line_num && line != ((void *)0); i--) {
   line = getPreviousLine(line);
  }
 }
 return line;
}

canonical_original_code:
struct Line *getGameLine(struct GameArea *g, int line_num) {
 int i;
 int num_lines = getGameAreaNumLines(g);
 struct Line *line;
 if (line_num > num_lines || line_num < 1) {
  return ((void *)0);
 }
 if((line_num <= (num_lines/2))) {
  line = getGameAreaFirst(g);
  for (i=1; (i<line_num && line != ((void *)0)); i++) {
   line = getNextLine(line);
  }
 }
 else {
  line = getGameAreaLast(g);
  for (i=num_lines; i>line_num && line != ((void *)0); i--) {
   line = getPreviousLine(line);
  }
 }
 return line;
}

variable_types: i int


getGameAreaColumnHeight

decompiled_code:
__int64 __fastcall getGameAreaColumnHeight(__int64 a1, unsigned int a2)
{
__int64 v2; // rax

v2 = getGameAreaHeightMap(a1);
return getColumnHeight(v2, a2);
}

canonical_decompiled_code:
__int64 __fastcall func21(__int64 a1, unsigned int a2)
{
__int64 v2; // rax

v2 = func3(a1);
return getColumnHeight(v2, a2);
}

original_code:
int getGameAreaColumnHeight(GameArea *gameArea, int column) {
 HeightMap *heightMap = getGameAreaHeightMap(gameArea);
 return getColumnHeight(heightMap, column);
}

canonical_original_code:
int getGameAreaColumnHeight(struct GameArea *gameArea, int column) {
 struct HeightMap *heightMap = getGameAreaHeightMap(gameArea);
 return getColumnHeight(heightMap, column);
}


setGameAreaColumnHeight

decompiled_code:
__int64 __fastcall setGameAreaColumnHeight(__int64 a1, unsigned int a2, unsigned int a3)
{
__int64 v4; // rax

v4 = getGameAreaHeightMap(a1);
return setColumnHeight(v4, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1, unsigned int a2, unsigned int a3)
{
__int64 v4; // rax

v4 = func3(a1);
return setColumnHeight(v4, a2, a3);
}

original_code:
void setGameAreaColumnHeight(GameArea *gameArea, int column, int height) {
 HeightMap *heightMap = getGameAreaHeightMap(gameArea);
 setColumnHeight(heightMap, column, height);
 return ;
}

canonical_original_code:
void setGameAreaColumnHeight(struct GameArea *gameArea, int column, int height) {
 struct HeightMap *heightMap = getGameAreaHeightMap(gameArea);
 setColumnHeight(heightMap, column, height);
 return ;
}


decompiled_code:
__int64 __fastcall getPosition2(__int64 a1, int a2, int a3)
{
__int64 v4; // rax

v4 = getGameLine(a1, a2);
if ( a2 <= 0 )
return 88LL;
if ( v4 )
return *(unsigned __int8 *)(a3 + getLineColumn(v4) - 1);
return 32LL;
}

canonical_decompiled_code:
__int64 __fastcall func23(__int64 a1, int a2, int a3)
{
__int64 v4; // rax

v4 = func20(a1, a2);
if ( a2 <= 0 )
return 88LL;
if ( v4 )
return *(unsigned __int8 *)(a3 + getLineColumn(v4) - 1);
return 32LL;
}

original_code:
char getPosition2(GameArea *g, int line, int column) {
 Line *l = getGameLine(g, line);
 if (line < 1) {
  return 'X';
 }
 if (l == ((void *)0)) {
  return ' ';
 }
 return ((getLineColumn(l))[column-1]);
}

canonical_original_code:
char getPosition2(struct GameArea *g, int line, int column) {
 struct Line *l = getGameLine(g, line);
 if (line < 1) {
  return 'X';
 }
 if (l == ((void *)0)) {
  return ' ';
 }
 return ((getLineColumn(l))[column-1]);
}

variable_types: line int

return_type: char


getPosition

decompiled_code:
__int64 __fastcall getPosition(__int64 a1, __int64 a2)
{
int v2; // er12
int v3; // eax

v2 = getColumn(a2);
v3 = getLine(a2);
return getPosition2(a1, v3, v2);
}

canonical_decompiled_code:
__int64 __fastcall func24(__int64 a1, __int64 a2)
{
int v2; // er12
int v3; // eax

v2 = getColumn(a2);
v3 = getLine(a2);
return func23(a1, v3, v2);
}

original_code:
char getPosition(GameArea *g, position *position) {
 return getPosition2(g, getLine(position), getColumn(position));
}

canonical_original_code:
char getPosition(struct GameArea *g, struct position *position) {
 return getPosition2(g, getLine(position), getColumn(position));
}

variable_types: struct position { int line; int column; } *


increaseScore

decompiled_code:
void __fastcall increaseScore(__int64 a1, int a2)
{
int v2; // eax

v2 = getGameAreaScore(a1);
setGameAreaScore(a1, v2 + a2);
}

canonical_decompiled_code:
void __fastcall func25(__int64 a1, int a2)
{
int v2; // eax

v2 = func7(a1);
func17(a1, v2 + a2);
}

original_code:
void increaseScore(GameArea *gameArea, int increment) {
 int score = getGameAreaScore(gameArea);
 setGameAreaScore(gameArea, score + increment);
 return;
}

canonical_original_code:
void increaseScore(struct GameArea *gameArea, int increment) {
 int score = getGameAreaScore(gameArea);
 setGameAreaScore(gameArea, score + increment);
 return;
}

variable_types: increment int


addLine

decompiled_code:
void __fastcall addLine(_QWORD *a1)
{
__int64 v1; // r12
__int64 v2; // r13
int v3; // ebp

v1 = newLine();
v2 = getGameAreaLast((__int64)a1);
v3 = getGameAreaNumLines((__int64)a1);
if ( v2 )
{
setNextLine(v2, v1);
setPreviousLine(v1, v2);
}
else
{
setGameAreaFirst(a1, v1);
setGameAreaLast((__int64)a1, v1);
}
setGameAreaLast((__int64)a1, v1);
setGameAreaNumLines((__int64)a1, v3 + 1);
}

original_code:
void addLine(GameArea *g) {
 Line *l = newLine();
 Line *last = getGameAreaLast(g);
 int num_lines = getGameAreaNumLines(g);
 if (last == ((void *)0)) {
  setGameAreaFirst(g, l);
  setGameAreaLast(g, l);
 }
 else {
  setNextLine(last, l);
  setPreviousLine(l, last);
 }
 setGameAreaLast(g, l);
 setGameAreaNumLines(g, ++num_lines);
 return;
}

canonical_original_code:
void addLine(struct GameArea *g) {
 struct Line *l = newLine();
 struct Line *last = getGameAreaLast(g);
 int num_lines = getGameAreaNumLines(g);
 if (last == ((void *)0)) {
  setGameAreaFirst(g, l);
  setGameAreaLast(g, l);
 }
 else {
  setNextLine(last, l);
  setPreviousLine(l, last);
 }
 setGameAreaLast(g, l);
 setGameAreaNumLines(g, ++num_lines);
 return;
}


decompiled_code:
__int64 __fastcall setPosition2(_QWORD *a1, int a2, unsigned int a3, char a4)
{
int v6; // ebx
__int64 v7; // rax

v6 = getGameAreaNumLines((__int64)a1);
if ( v6 < a2 )
{
do
{
addLine(a1);
++v6;
}
while ( a2 != v6 );
}
v7 = getGameLine((__int64)a1, a2);
return setLineColumn(v7, a3, (unsigned int)a4);
}

canonical_decompiled_code:
__int64 __fastcall func27(_QWORD *a1, int a2, unsigned int a3, char a4)
{
int v6; // ebx
__int64 v7; // rax

v6 = func2((__int64)a1);
if ( v6 < a2 )
{
do
{
func26(a1);
++v6;
}
while ( a2 != v6 );
}
v7 = func20((__int64)a1, a2);
return setLineColumn(v7, a3, (unsigned int)a4);
}

original_code:
void setPosition2(GameArea *g, int line, int column, char contents) {
 int i, num_lines;
 Line *l;
 num_lines = getGameAreaNumLines(g);
 for(i=num_lines; i<line; i++) {
  addLine(g);
 }
 l = getGameLine(g, line);
 setLineColumn(l, column, contents);
 return;
}

canonical_original_code:
void setPosition2(struct GameArea *g, int line, int column, char contents) {
 int i; int num_lines;
 struct Line *l;
 num_lines = getGameAreaNumLines(g);
 for(i=num_lines; i<line; i++) {
  addLine(g);
 }
 l = getGameLine(g, line);
 setLineColumn(l, column, contents);
 return;
}

variable_types: contents char


setPosition

decompiled_code:
__int64 __fastcall setPosition(_QWORD *a1, __int64 a2, char a3)
{
unsigned int v4; // er13
int v5; // eax

v4 = getColumn(a2);
v5 = getLine(a2);
return setPosition2(a1, v5, v4, a3);
}

canonical_decompiled_code:
__int64 __fastcall func28(_QWORD *a1, __int64 a2, char a3)
{
unsigned int v4; // er13
int v5; // eax

v4 = getColumn(a2);
v5 = getLine(a2);
return func27(a1, v5, v4, a3);
}

original_code:
void setPosition(GameArea *gameArea, position *position, char contents) {
 setPosition2(gameArea, getLine(position), getColumn(position), contents);
 return;
}

canonical_original_code:
void setPosition(struct GameArea *gameArea, struct position *position, char contents) {
 setPosition2(gameArea, getLine(position), getColumn(position), contents);
 return;
}

user_defined_types: struct position { int line; int column; }


fixHeightMap

decompiled_code:
__int64 __fastcall fixHeightMap(__int64 a1)
{
int i; // ebp
unsigned int j; // ebx
__int64 result; // rax

for ( i = 1; i != 11; ++i )
{
for ( j = getGameAreaColumnHeight(a1, i); (unsigned __int8)getPosition2(a1, j, i) == 32; --j )
;
result = setGameAreaColumnHeight(a1, i, j);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func29(__int64 a1)
{
int i; // ebp
unsigned int j; // ebx
__int64 result; // rax

for ( i = 1; i != 11; ++i )
{
for ( j = func21(a1, i); (unsigned __int8)func23(a1, j, i) == 32; --j )
;
result = func22(a1, i, j);
}
return result;
}

original_code:
void fixHeightMap(GameArea *gameArea) {
 int i, height;
 for (i=1; i<=10; i++) {
  height = getGameAreaColumnHeight(gameArea, i);
  while(getPosition2(gameArea, height, i) == ' ') {
   height--;
  }
  setGameAreaColumnHeight(gameArea, i, height);
 }
 return;
}

canonical_original_code:
void fixHeightMap(struct GameArea *gameArea) {
 int i; int height;
 for (i=1; i<=10; i++) {
  height = getGameAreaColumnHeight(gameArea, i);
  while(getPosition2(gameArea, height, i) == ' ') {
   height--;
  }
  setGameAreaColumnHeight(gameArea, i, height);
 }
 return;
}


insertPiece

decompiled_code:
void __fastcall insertPiece(_QWORD *a1, __int64 a2)
{
__int64 v2; // rbx
char v3; // al
signed int v4; // er12
unsigned int v5; // ebp
__int64 v6; // rbp
__int64 v7; // rbx
int v8; // eax
char *ptr; // [rsp+8h] [rbp-40h]

ptr = (char *)getPositions(a2);
v2 = (__int64)ptr;
do
{
v3 = getPieceColor(a2);
setPosition(a1, v2, v3);
v4 = getLine(v2);
v5 = getColumn(v2);
if ( (int)getGameAreaColumnHeight((__int64)a1, v5) < v4 )
setGameAreaColumnHeight((__int64)a1, v5, v4);
v2 += 8LL;
}
while ( (char *)v2 != ptr + 32 );
v6 = createTLocation(a1, a2);
v7 = getGameAreaPieceCounts((__int64)a1);
v8 = getTLocationHashPos(v6);
++*(_DWORD *)(v7 + 4LL * v8);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func30(_QWORD *a1, __int64 a2)
{
__int64 v2; // rbx
char v3; // al
signed int v4; // er12
unsigned int v5; // ebp
__int64 v6; // rbp
__int64 v7; // rbx
int v8; // eax
char *ptr; // [rsp+8h] [rbp-40h]

ptr = (char *)getPositions(a2);
v2 = (__int64)ptr;
do
{
v3 = getPieceColor(a2);
func28(a1, v2, v3);
v4 = getLine(v2);
v5 = getColumn(v2);
if ( (int)func21((__int64)a1, v5) < v4 )
func22((__int64)a1, v5, v4);
v2 += 8LL;
}
while ( (char *)v2 != ptr + 32 );
v6 = createTLocation(a1, a2);
v7 = func8((__int64)a1);
v8 = getTLocationHashPos(v6);
++*(_DWORD *)(v7 + 4LL * v8);
free(ptr);
}

original_code:
void insertPiece(GameArea *g, tetromino *piece) {
 position *pos;
 t_location *tl;
 int i;
 int line;
 int column;
 pos = getPositions(piece);
 for (i=0; i<4; i++) {
  setPosition(g, &pos[i], getPieceColor(piece));
  line = getLine(&pos[i]);
  column = getColumn(&pos[i]);
  if(getGameAreaColumnHeight(g, column) < line)
   setGameAreaColumnHeight(g, column, line);
 }
 tl = createTLocation(g, piece);
 getGameAreaPieceCounts(g)[getTLocationHashPos(tl)] += 1;
 free(pos);
 return;
}

canonical_original_code:
void insertPiece(struct GameArea *g, struct tetromino *piece) {
 struct position *pos;
 struct t_location *tl;
 int i;
 int line;
 int column;
 pos = getPositions(piece);
 for (i=0; i<4; i++) {
  setPosition(g, &pos[i], getPieceColor(piece));
  line = getLine(&pos[i]);
  column = getColumn(&pos[i]);
  if(getGameAreaColumnHeight(g, column) < line)
   setGameAreaColumnHeight(g, column, line);
 }
 tl = createTLocation(g, piece);
 getGameAreaPieceCounts(g)[getTLocationHashPos(tl)] += 1;
 free(pos);
 return;
}

variable_types: struct tetromino { struct position { int line; int column; } position; int type; char color; } *

variable_types: struct t_location { int hash_pos; int num_lines; struct Line { struct Line *previous; struct Line *next; char column[10]; struct t_location **pieces; int num_t_locations; } **lines; } *

user_defined_types: struct tetromino { struct position position; int type; char color; }


minDiversityLine

decompiled_code:
__int64 __fastcall minDiversityLine(__int64 a1)
{
int v1; // er13
_DWORD *v2; // r14
__int64 v3; // rax
__int64 v4; // rbx
_DWORD *v5; // rbp

v1 = getGameAreaNumLines(a1);
v2 = malloc(4LL * v1);
v3 = getGameAreaFirst(a1);
if ( v1 > 0 )
{
v4 = v3;
v5 = v2;
do
{
*v5 = lineDiversity(v4);
v4 = getNextLine(v4);
++v5;
}
while ( v5 != &v2[v1 - 1 + 1] );
}
return (unsigned int)vectorMaxPos(v2, (unsigned int)v1) + 1;
}

canonical_decompiled_code:
__int64 __fastcall func31(__int64 a1)
{
int v1; // er13
_DWORD *v2; // r14
__int64 v3; // rax
__int64 v4; // rbx
_DWORD *v5; // rbp

v1 = func2(a1);
v2 = malloc(4LL * v1);
v3 = func0(a1);
if ( v1 > 0 )
{
v4 = v3;
v5 = v2;
do
{
*v5 = lineDiversity(v4);
v4 = getNextLine(v4);
++v5;
}
while ( v5 != &v2[v1 - 1 + 1] );
}
return (unsigned int)vectorMaxPos(v2, (unsigned int)v1) + 1;
}

original_code:
int minDiversityLine(GameArea *gameArea) {
 int i, num_lines, *line_diversity;
 Line *line;
 num_lines = getGameAreaNumLines(gameArea);
 line_diversity = malloc(num_lines*sizeof(int));
 line = getGameAreaFirst(gameArea);
 for (i=0; i < num_lines; i++) {
  line_diversity[i] = lineDiversity(line);
  line = getNextLine(line);
 }
 return vectorMaxPos(line_diversity, num_lines) + 1;
}

canonical_original_code:
int minDiversityLine(struct GameArea *gameArea) {
 int i; int num_lines; int *line_diversity;
 struct Line *line;
 num_lines = getGameAreaNumLines(gameArea);
 line_diversity = malloc(num_lines*sizeof(int));
 line = getGameAreaFirst(gameArea);
 for (i=0; i < num_lines; i++) {
  line_diversity[i] = lineDiversity(line);
  line = getNextLine(line);
 }
 return vectorMaxPos(line_diversity, num_lines) + 1;
}


insertSortDeletedLine

decompiled_code:
void __fastcall insertSortDeletedLine(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
char *v3; // r13
char *v4; // rax
int v5; // eax
__int64 v6; // rbx
const char *v7; // r13
const char *v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
char src[50]; // [rsp+6h] [rbp-32h] BYREF

setPreviousLine(a2, 0LL);
setNextLine(a2, 0LL);
vectorCharInit(src, 10LL, 32LL);
v2 = 0LL;
v3 = src;
do
{
if ( *(_BYTE *)(getLineColumn(a2) + v2) != 32 )
*v3++ = *(_BYTE *)(getLineColumn(a2) + v2);
++v2;
}
while ( v2 != 10 );
v4 = (char *)getLineColumn(a2);
strncpy(v4, src, 0xAuLL);
v5 = getGameAreaNumDeletedLines(a1);
setGameAreaNumDeletedLines(a1, v5 + 1);
v6 = getGameAreaDeletedFirst(a1);
if ( v6 )
{
while ( 1 )
{
v7 = (const char *)getLineColumn(a2);
v8 = (const char *)getLineColumn(v6);
if ( strncmp(v8, v7, 0xAuLL) >= 0 )
break;
v6 = getNextLine(v6);
if ( !v6 )
{
v9 = getGameAreaDeletedLast(a1);
setNextLine(v9, a2);
v10 = getGameAreaDeletedLast(a1);
setPreviousLine(a2, v10);
setGameAreaDeletedLast(a1, a2);
return;
}
}
if ( getPreviousLine(v6) )
{
v11 = getPreviousLine(v6);
setNextLine(v11, a2);
v12 = getPreviousLine(v6);
setPreviousLine(a2, v12);
setNextLine(a2, v6);
setPreviousLine(v6, a2);
}
else
{
v13 = getGameAreaDeletedFirst(a1);
setPreviousLine(v13, a2);
v14 = getGameAreaDeletedFirst(a1);
setNextLine(a2, v14);
setGameAreaDeletedFirst(a1, a2);
}
}
else
{
setGameAreaDeletedFirst(a1, a2);
setGameAreaDeletedLast(a1, a2);
}
}

canonical_decompiled_code:
void __fastcall func32(__int64 a1, __int64 a2)
{
__int64 v2; // rbx
char *v3; // r13
char *v4; // rax
int v5; // eax
__int64 v6; // rbx
const char *v7; // r13
const char *v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rax
char src[50]; // [rsp+6h] [rbp-32h] BYREF

setPreviousLine(a2, 0LL);
setNextLine(a2, 0LL);
vectorCharInit(src, 10LL, 32LL);
v2 = 0LL;
v3 = src;
do
{
if ( *(_BYTE *)(getLineColumn(a2) + v2) != 32 )
*v3++ = *(_BYTE *)(getLineColumn(a2) + v2);
++v2;
}
while ( v2 != 10 );
v4 = (char *)getLineColumn(a2);
strncpy(v4, src, 0xAuLL);
v5 = func6(a1);
func16(a1, v5 + 1);
v6 = func4(a1);
if ( v6 )
{
while ( 1 )
{
v7 = (const char *)getLineColumn(a2);
v8 = (const char *)getLineColumn(v6);
if ( strncmp(v8, v7, 0xAuLL) >= 0 )
break;
v6 = getNextLine(v6);
if ( !v6 )
{
v9 = func5(a1);
setNextLine(v9, a2);
v10 = func5(a1);
setPreviousLine(a2, v10);
func15(a1, a2);
return;
}
}
if ( getPreviousLine(v6) )
{
v11 = getPreviousLine(v6);
setNextLine(v11, a2);
v12 = getPreviousLine(v6);
setPreviousLine(a2, v12);
setNextLine(a2, v6);
setPreviousLine(v6, a2);
}
else
{
v13 = func4(a1);
setPreviousLine(v13, a2);
v14 = func4(a1);
setNextLine(a2, v14);
func14(a1, a2);
}
}
else
{
func14(a1, a2);
func15(a1, a2);
}
}

original_code:
void insertSortDeletedLine(GameArea *gameArea, Line* line) {
 char columns[10], *ptr;
 int i;
 Line* aux;
 setPreviousLine(line, ((void *)0));
 setNextLine(line, ((void *)0));
 vectorCharInit(columns, 10, ' ');
 ptr = columns;
 for(i=0; i<10; i++) {
  if(getLineColumn(line)[i] != ' ') {
   *(ptr++) = getLineColumn(line)[i];
  }
 }
 strncpy(getLineColumn(line), columns, 10);
 i = getGameAreaNumDeletedLines(gameArea) + 1;
 setGameAreaNumDeletedLines(gameArea, i);
 if(getGameAreaDeletedFirst(gameArea) == ((void *)0)) {
  setGameAreaDeletedFirst(gameArea, line);
  setGameAreaDeletedLast(gameArea, line);
  return;
 }
 aux = getGameAreaDeletedFirst(gameArea);
 while(aux != ((void *)0) && strncmp(getLineColumn(aux), getLineColumn(line), 10) < 0) {
  aux = getNextLine(aux);
 }
 if(aux == ((void *)0)) {
  setNextLine(getGameAreaDeletedLast(gameArea), line);
  setPreviousLine(line, getGameAreaDeletedLast(gameArea));
  setGameAreaDeletedLast(gameArea, line);
  return;
 }
 if(getPreviousLine(aux) == ((void *)0)) {
  setPreviousLine(getGameAreaDeletedFirst(gameArea), line);
  setNextLine(line, getGameAreaDeletedFirst(gameArea));
  setGameAreaDeletedFirst(gameArea, line);
  return;
 }
 setNextLine(getPreviousLine(aux), line);
 setPreviousLine(line, getPreviousLine(aux));
 setNextLine(line, aux);
 setPreviousLine(aux, line);
 return;
}

canonical_original_code:
void insertSortDeletedLine(struct GameArea *gameArea, struct Line *line) {
 char columns[10]; char *ptr;
 int i;
 struct Line *aux;
 setPreviousLine(line, ((void *)0));
 setNextLine(line, ((void *)0));
 vectorCharInit(columns, 10, ' ');
 ptr = columns;
 for(i=0; i<10; i++) {
  if(getLineColumn(line)[i] != ' ') {
   *(ptr++) = getLineColumn(line)[i];
  }
 }
 strncpy(getLineColumn(line), columns, 10);
 i = getGameAreaNumDeletedLines(gameArea) + 1;
 setGameAreaNumDeletedLines(gameArea, i);
 if(getGameAreaDeletedFirst(gameArea) == ((void *)0)) {
  setGameAreaDeletedFirst(gameArea, line);
  setGameAreaDeletedLast(gameArea, line);
  return;
 }
 aux = getGameAreaDeletedFirst(gameArea);
 while(aux != ((void *)0) && strncmp(getLineColumn(aux), getLineColumn(line), 10) < 0) {
  aux = getNextLine(aux);
 }
 if(aux == ((void *)0)) {
  setNextLine(getGameAreaDeletedLast(gameArea), line);
  setPreviousLine(line, getGameAreaDeletedLast(gameArea));
  setGameAreaDeletedLast(gameArea, line);
  return;
 }
 if(getPreviousLine(aux) == ((void *)0)) {
  setPreviousLine(getGameAreaDeletedFirst(gameArea), line);
  setNextLine(line, getGameAreaDeletedFirst(gameArea));
  setGameAreaDeletedFirst(gameArea, line);
  return;
 }
 setNextLine(getPreviousLine(aux), line);
 setPreviousLine(line, getPreviousLine(aux));
 setNextLine(line, aux);
 setPreviousLine(aux, line);
 return;
}

variable_types:
line
struct Line *

variable_types:
columns
char [10]

variable_types:
ptr
char *


eraseLine

decompiled_code:
__int64 __fastcall eraseLine(_QWORD *a1, int a2)
{
__int64 result; // rax
__int64 v3; // rbp
int v4; // er12
__int64 v5; // r13
__int64 v6; // rax
__int64 v7; // r14

result = getGameLine((__int64)a1, a2);
if ( result )
{
v3 = result;
v4 = getGameAreaNumLines((__int64)a1);
v5 = getNextLine(v3);
v6 = getPreviousLine(v3);
v7 = v6;
if ( v5 )
setPreviousLine(v5, v6);
else
setGameAreaLast((__int64)a1, v6);
if ( v7 )
setNextLine(v7, v5);
else
setGameAreaFirst(a1, v5);
setGameAreaNumLines((__int64)a1, v4 - 1);
fixHeightMap((__int64)a1);
insertSortDeletedLine((__int64)a1, v3);
result = eraseTLocations(a1, v3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func33(_QWORD *a1, int a2)
{
__int64 result; // rax
__int64 v3; // rbp
int v4; // er12
__int64 v5; // r13
__int64 v6; // rax
__int64 v7; // r14

result = func20((__int64)a1, a2);
if ( result )
{
v3 = result;
v4 = func2((__int64)a1);
v5 = getNextLine(v3);
v6 = getPreviousLine(v3);
v7 = v6;
if ( v5 )
setPreviousLine(v5, v6);
else
func11((__int64)a1, v6);
if ( v7 )
setNextLine(v7, v5);
else
func10(a1, v5);
func12((__int64)a1, v4 - 1);
func29((__int64)a1);
func32((__int64)a1, v3);
result = eraseTLocations(a1, v3);
}
return result;
}

original_code:
void eraseLine(GameArea *g, int line) {
 Line *l = getGameLine(g, line);
 Line *next;
 Line *previous;
 int num_lines = getGameAreaNumLines(g);
 if (l != ((void *)0)) {
  next = getNextLine(l);
  previous = getPreviousLine(l);
 }
 else {
  return;
 }
 if (next != ((void *)0)) {
  setPreviousLine(next, previous);
 }
 else {
  setGameAreaLast(g, previous);
 }
 if (previous != ((void *)0)) {
  setNextLine(previous, next);
 }
 else {
  setGameAreaFirst(g, next);
 }
 setGameAreaNumLines(g, --num_lines);
 fixHeightMap(g);
 insertSortDeletedLine(g, l);
 eraseTLocations(g, l);
 return;
}

canonical_original_code:
void eraseLine(struct GameArea *g, int line) {
 struct Line *l = getGameLine(g, line);
 struct Line *next;
 struct Line *previous;
 int num_lines = getGameAreaNumLines(g);
 if (l != ((void *)0)) {
  next = getNextLine(l);
  previous = getPreviousLine(l);
 }
 else {
  return;
 }
 if (next != ((void *)0)) {
  setPreviousLine(next, previous);
 }
 else {
  setGameAreaLast(g, previous);
 }
 if (previous != ((void *)0)) {
  setNextLine(previous, next);
 }
 else {
  setGameAreaFirst(g, next);
 }
 setGameAreaNumLines(g, --num_lines);
 fixHeightMap(g);
 insertSortDeletedLine(g, l);
 eraseTLocations(g, l);
 return;
}

variable_types: struct GameArea { struct Line { struct Line *previous; struct Line *next; char column[10]; struct t_location { int hash_pos; int num_lines; struct Line **lines; } **pieces; int num_t_locations; } *gameLineFirst; struct Line *gameLineLast; int num_lines; struct HeightMap { int columns[10]; } *heightMap; struct Line *deletedLinesFirst; struct Line *deletedLinesLast; int num_deleted_lines; int score; int *piece_count; } *


newTHash

decompiled_code:
void *newTHash()
{
void *v0; // rbx

v0 = malloc(0x78uLL);
vectorInit(v0, 30LL, 0LL);
return v0;
}

canonical_decompiled_code:
void *func0()
{
void *v0; // rbx

v0 = malloc(0x78uLL);
vectorInit(v0, 30LL, 0LL);
return v0;
}

original_code:
int* newTHash() {
 int *hash = malloc(5*6*sizeof(int));
 vectorInit(hash, 5*6, 0);
 return hash;
}

canonical_original_code:
int *newTHash() {
 int *hash = malloc(5*6*sizeof(int));
 vectorInit(hash, 5*6, 0);
 return hash;
}

variable_types:
hash
int *


getTHashPos

decompiled_code:
__int64 __fastcall getTHashPos(__int64 a1)
{
int v1; // ebx
char v2; // al

v1 = getPieceType();
v2 = getPieceColor(a1);
return (unsigned int)color2int((unsigned int)v2) + 2 * (3 * v1 - 3) - 1;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
int v1; // ebx
char v2; // al

v1 = getPieceType();
v2 = getPieceColor(a1);
return (unsigned int)color2int((unsigned int)v2) + 2 * (3 * v1 - 3) - 1;
}

original_code:
int getTHashPos(tetromino *t) {
 int type = getPieceType(t);
 char color = getPieceColor(t);
 return (6*(type-1) + color2int(color) - 1);
}

canonical_original_code:
int getTHashPos(struct tetromino *t) {
 int type = getPieceType(t);
 char color = getPieceColor(t);
 return (6*(type-1) + color2int(color) - 1);
}

variable_types: type int

variable_types: color char


deletePiece

decompiled_code:
void __fastcall deletePiece(void *a1)
{
free(a1);
}

canonical_decompiled_code:
void __fastcall func0(void *a1)
{
free(a1);
}

original_code:
void deletePiece(tetromino* piece) {
 free(piece);
}

canonical_original_code:
void deletePiece(struct tetromino *piece) {
 free(piece);
}


getPieceLine

decompiled_code:
__int64 getPieceLine()
{
return getLine();
}

canonical_decompiled_code:
__int64 func1()
{
return getLine();
}

original_code:
int getPieceLine(tetromino *t) {
 return getLine(&(t->position));
}

canonical_original_code:
int getPieceLine(struct tetromino *t) {
 return getLine(&(t->position));
}


getPieceColumn

decompiled_code:
__int64 getPieceColumn()
{
return getColumn();
}

canonical_decompiled_code:
__int64 func2()
{
return getColumn();
}

original_code:
int getPieceColumn(tetromino *t) {
 return getColumn(&(t->position));
}

canonical_original_code:
int getPieceColumn(struct tetromino *t) {
 return getColumn(&(t->position));
}


getPieceType

decompiled_code:
__int64 __fastcall getPieceType(__int64 a1)
{
return *(unsigned int *)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return *(unsigned int *)(a1 + 8);
}

original_code:
int getPieceType(tetromino *t) {
 return t->type;
}

canonical_original_code:
int getPieceType(struct tetromino *t) {
 return t->type;
}


getPieceColor

decompiled_code:
__int64 __fastcall getPieceColor(__int64 a1)
{
return *(unsigned __int8 *)(a1 + 12);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return *(unsigned __int8 *)(a1 + 12);
}

original_code:
char getPieceColor(tetromino *t) {
 return t->color;
}

canonical_original_code:
char getPieceColor(struct tetromino *t) {
 return t->color;
}


setPieceLine

decompiled_code:
__int64 setPieceLine()
{
return setLine();
}

canonical_decompiled_code:
__int64 func5()
{
return setLine();
}

original_code:
void setPieceLine(tetromino *t, int line) {
 setLine(&(t->position), line);
}

canonical_original_code:
void setPieceLine(struct tetromino *t, int line) {
 setLine(&(t->position), line);
}


setPieceColumn

decompiled_code:
__int64 setPieceColumn()
{
return setColumn();
}

canonical_decompiled_code:
__int64 func6()
{
return setColumn();
}

original_code:
void setPieceColumn(tetromino *t, int column) {
 setColumn(&(t->position), column);
}

canonical_original_code:
void setPieceColumn(struct tetromino *t, int column) {
 setColumn(&(t->position), column);
}

variable_types: column int


setPieceType

decompiled_code:
void __fastcall setPieceType(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 8) = a2;
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 8) = a2;
}

original_code:
void setPieceType(tetromino *t, int type) {
 t->type = type;
}

canonical_original_code:
void setPieceType(struct tetromino *t, int type) {
 t->type = type;
}


setPieceColor

decompiled_code:
void __fastcall setPieceColor(__int64 a1, char a2)
{
*(_BYTE *)(a1 + 12) = a2;
}

canonical_decompiled_code:
void __fastcall func8(__int64 a1, char a2)
{
*(_BYTE *)(a1 + 12) = a2;
}

original_code:
void setPieceColor(tetromino *t, char color) {
 t->color = color;
}

canonical_original_code:
void setPieceColor(struct tetromino *t, char color) {
 t->color = color;
}


newPiece

decompiled_code:
void *__fastcall newPiece(int a1, unsigned int a2, unsigned int a3, char a4)
{
void *v6; // rbx

v6 = malloc(0x10uLL);
setPieceLine(v6, a2);
setPieceColumn(v6, a3);
setPieceType((__int64)v6, a1);
setPieceColor((__int64)v6, a4);
return v6;
}

canonical_decompiled_code:
void *__fastcall func9(int a1, unsigned int a2, unsigned int a3, char a4)
{
void *v6; // rbx

v6 = malloc(0x10uLL);
func5(v6, a2);
func6(v6, a3);
func7((__int64)v6, a1);
func8((__int64)v6, a4);
return v6;
}

original_code:
tetromino* newPiece(int type, int line, int column, char color) {
 tetromino *t;
 t = malloc(sizeof(tetromino));
 setPieceLine(t, line);
 setPieceColumn(t, column);
 setPieceType(t, type);
 setPieceColor(t, color);
 return t;
}

canonical_original_code:
struct tetromino *newPiece(int type, int line, int column, char color) {
 struct tetromino *t;
 t = malloc(sizeof(tetromino));
 setPieceLine(t, line);
 setPieceColumn(t, column);
 setPieceType(t, type);
 setPieceColor(t, color);
 return t;
}

return_type: struct tetromino { struct position { int line; int column; } position; int type; char color; } *


getPositionsL

decompiled_code:
__int64 __fastcall getPositionsL(_DWORD *a1, int a2, int a3)
{
__int64 result; // rax

*a1 = a2;
a1[1] = a3;
a1[2] = a2;
a1[3] = a3 + 1;
a1[4] = a2;
result = (unsigned int)(a3 + 2);
a1[5] = result;
a1[6] = a2 - 1;
a1[7] = a3;
return result;
}

original_code:
void getPositionsL(position *pos, int line, int column) {
 pos[0].line = line;
 pos[0].column = column;
 pos[1].line = line;
 pos[1].column = column + 1;
 pos[2].line = line;
 pos[2].column = column + 2;
 pos[3].line = line - 1;
 pos[3].column = column;
 return;
}

canonical_original_code:
void getPositionsL(struct position *pos, int line, int column) {
 pos[0].line = line;
 pos[0].column = column;
 pos[1].line = line;
 pos[1].column = column + 1;
 pos[2].line = line;
 pos[2].column = column + 2;
 pos[3].line = line - 1;
 pos[3].column = column;
 return;
}


getFloorSize

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

result = getPieceType(a1);
switch ( (int)result )
{
case 1:
result = 4LL;
break;
case 2:
case 3:
return result;
case 4:
result = 3LL;
break;
case 5:
result = 3LL;
break;
default:
result = 0LL;
break;
}
return result;
}

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

result = func3(a1);
switch ( (int)result )
{
case 1:
result = 4LL;
break;
case 2:
case 3:
return result;
case 4:
result = 3LL;
break;
case 5:
result = 3LL;
break;
default:
result = 0LL;
break;
}
return result;
}

original_code:
int getFloorSize(tetromino *t) {
 int piece_type = getPieceType(t);
 switch(piece_type) {
  case 1: return 4;
  case 2: return 2;
  case 3: return 3;
  case 4: return 3;
  case 5: return 3;
 }
 return 0;
}

canonical_original_code:
int getFloorSize(struct tetromino *t) {
 int piece_type = getPieceType(t);
 switch(piece_type) {
  case 1: return 4;
  case 2: return 2;
  case 3: return 3;
  case 4: return 3;
  case 5: return 3;
 }
 return 0;
}


getColumnSpan

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

result = getPieceType(a1);
switch ( (int)result )
{
case 1:
result = 4LL;
break;
case 2:
case 3:
return result;
case 4:
result = 3LL;
break;
case 5:
result = 3LL;
break;
default:
result = 0LL;
break;
}
return result;
}

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

result = func3(a1);
switch ( (int)result )
{
case 1:
result = 4LL;
break;
case 2:
case 3:
return result;
case 4:
result = 3LL;
break;
case 5:
result = 3LL;
break;
default:
result = 0LL;
break;
}
return result;
}

original_code:
int getColumnSpan(tetromino *t) {
 int piece_type = getPieceType(t);
 switch(piece_type) {
  case 1: return 4;
  case 2: return 2;
  case 3: return 3;
  case 4: return 3;
  case 5: return 3;
 }
 return 0;
}

canonical_original_code:
int getColumnSpan(struct tetromino *t) {
 int piece_type = getPieceType(t);
 switch(piece_type) {
  case 1: return 4;
  case 2: return 2;
  case 3: return 3;
  case 4: return 3;
  case 5: return 3;
 }
 return 0;
}


getLineSpan

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

result = getPieceType(a1);
if ( (_DWORD)result != 1 )
result = 2 * (unsigned int)((unsigned int)(result - 2) < 4);
return result;
}

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

result = func3(a1);
if ( (_DWORD)result != 1 )
result = 2 * (unsigned int)((unsigned int)(result - 2) < 4);
return result;
}

original_code:
int getLineSpan(tetromino *t) {
 int piece_type = getPieceType(t);
 switch(piece_type) {
  case 1: return 1;
  case 2: return 2;
  case 3: return 2;
  case 4: return 2;
  case 5: return 2;
 }
 return 0;
}

canonical_original_code:
int getLineSpan(struct tetromino *t) {
 int piece_type = getPieceType(t);
 switch(piece_type) {
  case 1: return 1;
  case 2: return 2;
  case 3: return 2;
  case 4: return 2;
  case 5: return 2;
 }
 return 0;
}


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

switch ( a1 )
{
case 'B':
result = 1LL;
break;
case 'G':
result = 2LL;
break;
case 'O':
result = 3LL;
break;
case 'R':
result = 4LL;
break;
case 'V':
result = 5LL;
break;
case 'Y':
result = 6LL;
break;
default:
result = 0LL;
break;
}
return result;
}

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

switch ( a1 )
{
case 'B':
result = 1LL;
break;
case 'G':
result = 2LL;
break;
case 'O':
result = 3LL;
break;
case 'R':
result = 4LL;
break;
case 'V':
result = 5LL;
break;
case 'Y':
result = 6LL;
break;
default:
result = 0LL;
break;
}
return result;
}

original_code:
int color2int(char color) {
 switch(color) {
  case 'B': return 1;
  case 'G': return 2;
  case 'O': return 3;
  case 'R': return 4;
  case 'V': return 5;
  case 'Y': return 6;
 }
 return 0;
}


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

switch ( a1 )
{
case 1:
result = 66LL;
break;
case 2:
result = 71LL;
break;
case 3:
result = 79LL;
break;
case 4:
result = 82LL;
break;
case 5:
result = 86LL;
break;
case 6:
result = 89LL;
break;
default:
result = 0LL;
break;
}
return result;
}

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

switch ( a1 )
{
case 1:
result = 66LL;
break;
case 2:
result = 71LL;
break;
case 3:
result = 79LL;
break;
case 4:
result = 82LL;
break;
case 5:
result = 86LL;
break;
case 6:
result = 89LL;
break;
default:
result = 0LL;
break;
}
return result;
}

original_code:
char int2color(int color) {
 switch(color) {
  case 1: return 'B';
  case 2: return 'G';
  case 3: return 'O';
  case 4: return 'R';
  case 5: return 'V';
  case 6: return 'Y';
 }
 return 0;
}

variable_types: color int


getTLocationHashPos

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

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

original_code:
int getTLocationHashPos(t_location *loc) {
 return loc->hash_pos;
}

canonical_original_code:
int getTLocationHashPos(struct t_location *loc) {
 return loc->hash_pos;
}


getTLocationNumLines

decompiled_code:
__int64 __fastcall getTLocationNumLines(__int64 a1)
{
return *(unsigned int *)(a1 + 4);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return *(unsigned int *)(a1 + 4);
}

original_code:
int getTLocationNumLines(t_location *loc) {
 return loc->num_lines;
}

canonical_original_code:
int getTLocationNumLines(struct t_location *loc) {
 return loc->num_lines;
}


getTLocationLines

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

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

original_code:
Line** getTLocationLines(t_location *loc) {
 return loc->lines;
}

canonical_original_code:
struct Line **getTLocationLines(struct t_location *loc) {
 return loc->lines;
}

variable_types:
loc
struct t_location *

return_type: struct Line { struct Line *previous; struct Line *next; char column[10]; struct t_location { int hash_pos; int num_lines; struct Line **lines; } **pieces; int num_t_locations; } **


setTLocationNumLines

decompiled_code:
void __fastcall setTLocationNumLines(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 4) = a2;
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 4) = a2;
}

original_code:
void setTLocationNumLines(t_location *loc, int num) {
 loc->num_lines = num;
 return;
}

canonical_original_code:
void setTLocationNumLines(struct t_location *loc, int num) {
 loc->num_lines = num;
 return;
}

variable_types: num int


setTLocationLines

decompiled_code:
void __fastcall setTLocationLines(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 8) = a2;
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 8) = a2;
}

original_code:
void setTLocationLines(t_location *loc, Line* *lines) {
 loc->lines = lines;
 return;
}

canonical_original_code:
void setTLocationLines(struct t_location *loc, struct Line **lines) {
 loc->lines = lines;
 return;
}

variable_types:
lines
struct Line **


processTLocation

decompiled_code:
void __fastcall processTLocation(void *ptr)
{
int v1; // eax
__int64 v2; // r15
__int64 v3; // r14
__int64 v4; // rbx
__int64 v5; // r12
int v6; // eax
__int64 v7; // rbp
void *v8; // rax

v1 = getTLocationNumLines((__int64)ptr);
if ( v1 > 0 )
{
v2 = 8LL * (unsigned int)v1;
v3 = 0LL;
do
{
v5 = *(_QWORD *)(getTLocationLines((__int64)ptr) + v3);
v6 = getLineTLIndex(v5);
if ( v6 > 0 )
{
v7 = 8LL * (unsigned int)v6;
v4 = 0LL;
while ( *(void **)(getLineT_location(v5) + v4) != ptr )
{
v4 += 8LL;
if ( v4 == v7 )
goto LABEL_6;
}
*(_QWORD *)(getLineT_location(v5) + v4) = 0LL;
}
LABEL_6:
v3 += 8LL;
}
while ( v3 != v2 );
}
v8 = (void *)getTLocationLines((__int64)ptr);
free(v8);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func6(void *ptr)
{
int v1; // eax
__int64 v2; // r15
__int64 v3; // r14
__int64 v4; // rbx
__int64 v5; // r12
int v6; // eax
__int64 v7; // rbp
void *v8; // rax

v1 = func1((__int64)ptr);
if ( v1 > 0 )
{
v2 = 8LL * (unsigned int)v1;
v3 = 0LL;
do
{
v5 = *(_QWORD *)(func2((__int64)ptr) + v3);
v6 = getLineTLIndex(v5);
if ( v6 > 0 )
{
v7 = 8LL * (unsigned int)v6;
v4 = 0LL;
while ( *(void **)(getLineT_location(v5) + v4) != ptr )
{
v4 += 8LL;
if ( v4 == v7 )
goto LABEL_6;
}
*(_QWORD *)(getLineT_location(v5) + v4) = 0LL;
}
LABEL_6:
v3 += 8LL;
}
while ( v3 != v2 );
}
v8 = (void *)func2((__int64)ptr);
free(v8);
free(ptr);
}

original_code:
void processTLocation(t_location* loc) {
 int i, j, num_lines, line_num_pieces, found;
 Line* line;
 num_lines = getTLocationNumLines(loc);
 for(i=0; i<num_lines; i++) {
  line = getTLocationLines(loc)[i];
  line_num_pieces = getLineTLIndex(line);
  found = 0;
  for(j=0; j<line_num_pieces && (!found); j++) {
   if(getLineT_location(line)[j] == loc) {
    getLineT_location(line)[j] = ((void *)0);
    found = 1;
   }
  }
 }
 free(getTLocationLines(loc));
 free(loc);
}

canonical_original_code:
void processTLocation(struct t_location *loc) {
 int i; int j; int num_lines; int line_num_pieces; int found;
 struct Line *line;
 num_lines = getTLocationNumLines(loc);
 for(i=0; i<num_lines; i++) {
  line = getTLocationLines(loc)[i];
  line_num_pieces = getLineTLIndex(line);
  found = 0;
  for(j=0; j<line_num_pieces && (!found); j++) {
   if(getLineT_location(line)[j] == loc) {
    getLineT_location(line)[j] = ((void *)0);
    found = 1;
   }
  }
 }
 free(getTLocationLines(loc));
 free(loc);
}

variable_types: i int

variable_types: j int

variable_types: found int

variable_types: struct Line { struct Line *previous; struct Line *next; char column[10]; struct t_location { int hash_pos; int num_lines; struct Line **lines; } **pieces; int num_t_locations; } *


eraseTLocations

decompiled_code:
void __fastcall eraseTLocations(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 v3; // r13
__int64 v4; // rbx
__int64 v5; // rax
int v6; // ebp
__int64 v7; // rax
__int64 v8; // rax

v2 = getLineTLIndex(a2);
if ( v2 > 0 )
{
v3 = 8LL * (unsigned int)v2;
v4 = 0LL;
do
{
if ( *(_QWORD *)(getLineT_location(a2) + v4) )
{
v5 = getLineT_location(a2);
v6 = getTLocationHashPos(*(unsigned int **)(v5 + v4));
v7 = getGameAreaPieceCounts(a1);
--*(_DWORD *)(v7 + 4LL * v6);
v8 = getLineT_location(a2);
processTLocation(*(void **)(v8 + v4));
}
v4 += 8LL;
}
while ( v4 != v3 );
}
}

canonical_decompiled_code:
void __fastcall func7(__int64 a1, __int64 a2)
{
int v2; // eax
__int64 v3; // r13
__int64 v4; // rbx
__int64 v5; // rax
int v6; // ebp
__int64 v7; // rax
__int64 v8; // rax

v2 = getLineTLIndex(a2);
if ( v2 > 0 )
{
v3 = 8LL * (unsigned int)v2;
v4 = 0LL;
do
{
if ( *(_QWORD *)(getLineT_location(a2) + v4) )
{
v5 = getLineT_location(a2);
v6 = func0(*(unsigned int **)(v5 + v4));
v7 = getGameAreaPieceCounts(a1);
--*(_DWORD *)(v7 + 4LL * v6);
v8 = getLineT_location(a2);
func6(*(void **)(v8 + v4));
}
v4 += 8LL;
}
while ( v4 != v3 );
}
}

original_code:
void eraseTLocations(GameArea *g, Line* l) {
 int i, index, hashpos;
 index = getLineTLIndex(l);
 for(i=0; i<index; i++) {
  if(getLineT_location(l)[i] != ((void *)0)) {
   hashpos = getTLocationHashPos(getLineT_location(l)[i]);
   getGameAreaPieceCounts(g)[hashpos] -= 1;
   processTLocation(getLineT_location(l)[i]);
  }
 }
 return;
}

canonical_original_code:
void eraseTLocations(struct GameArea *g, struct Line *l) {
 int i; int index; int hashpos;
 index = getLineTLIndex(l);
 for(i=0; i<index; i++) {
  if(getLineT_location(l)[i] != ((void *)0)) {
   hashpos = getTLocationHashPos(getLineT_location(l)[i]);
   getGameAreaPieceCounts(g)[hashpos] -= 1;
   processTLocation(getLineT_location(l)[i]);
  }
 }
 return;
}

variable_types:
l
struct Line *

variable_types: index int

variable_types: hashpos int


getNextLine

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

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

original_code:
Line* getNextLine(Line *l) {
 return l->next;
}

canonical_original_code:
struct Line *getNextLine(struct Line *l) {
 return l->next;
}


getPreviousLine

decompiled_code:
__int64 __fastcall getPreviousLine(__int64 a1)
{
return *(_QWORD *)a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return *(_QWORD *)a1;
}

original_code:
Line* getPreviousLine(Line *l) {
 return l->previous;
}

canonical_original_code:
struct Line *getPreviousLine(struct Line *l) {
 return l->previous;
}


getLineColumn

decompiled_code:
__int64 __fastcall getLineColumn(__int64 a1)
{
return a1 + 16;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return a1 + 16;
}

original_code:
char* getLineColumn(Line *l) {
 return l->column;
}

canonical_original_code:
char *getLineColumn(struct Line *l) {
 return l->column;
}


setNextLine

decompiled_code:
void __fastcall setNextLine(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 8) = a2;
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1, __int64 a2)
{
*(_QWORD *)(a1 + 8) = a2;
}

original_code:
void setNextLine(Line *line, Line *next_line) {
 line->next = next_line;
}

canonical_original_code:
void setNextLine(struct Line *line, struct Line *next_line) {
 line->next = next_line;
}


setLineColumn

decompiled_code:
void __fastcall setLineColumn(__int64 a1, int a2, char a3)
{
*(_BYTE *)(a2 - 1 + a1 + 16) = a3;
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, int a2, char a3)
{
*(_BYTE *)(a2 - 1 + a1 + 16) = a3;
}

original_code:
void setLineColumn(Line *l, int c, char contents) {
 l->column[c-1] = contents;
}

canonical_original_code:
void setLineColumn(struct Line *l, int c, char contents) {
 l->column[c-1] = contents;
}

variable_types: c int

variable_types: contents char


lineDiversity

original_code:
int lineDiversity(Line *line) {
 char *column;
 int i, diversityMap[10];
 if (line == ((void *)0)) {
  return 0;
 }
 column = getLineColumn(line);
 vectorInit(diversityMap, 10, 0);
 for (i=0; i<10; i++) {
  switch(column[i]) {
   case 'R': diversityMap[0] = 1; break;
   case 'Y': diversityMap[1] = 1; break;
   case 'B': diversityMap[2] = 1; break;
   case 'G': diversityMap[3] = 1; break;
   case 'O': diversityMap[4] = 1; break;
   case 'V': diversityMap[5] = 1; break;
  }
 }
 return vectorSum(diversityMap, 6);
}

canonical_original_code:
int lineDiversity(struct Line *line) {
 char *column;
 int i; int diversityMap[10];
 if (line == ((void *)0)) {
  return 0;
 }
 column = getLineColumn(line);
 vectorInit(diversityMap, 10, 0);
 for (i=0; i<10; i++) {
  switch(column[i]) {
   case 'R': diversityMap[0] = 1; break;
   case 'Y': diversityMap[1] = 1; break;
   case 'B': diversityMap[2] = 1; break;
   case 'G': diversityMap[3] = 1; break;
   case 'O': diversityMap[4] = 1; break;
   case 'V': diversityMap[5] = 1; break;
  }
 }
 return vectorSum(diversityMap, 6);
}

variable_types:
column
char *

variable_types:
diversityMap
int [10]


lineFilled

decompiled_code:
__int64 __fastcall lineFilled(__int64 a1)
{
_BYTE *v1; // rax
_BYTE *v2; // rdx

if ( !a1 )
return 0LL;
v1 = (_BYTE *)getLineColumn(a1);
v2 = v1 + 10;
while ( *v1 != 32 )
{
if ( ++v1 == v2 )
return 1LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
_BYTE *v1; // rax
_BYTE *v2; // rdx

if ( !a1 )
return 0LL;
v1 = (_BYTE *)func2(a1);
v2 = v1 + 10;
while ( *v1 != 32 )
{
if ( ++v1 == v2 )
return 1LL;
}
return 0LL;
}

original_code:
int lineFilled(Line *line) {
 int i;
 char *col;
 if (line == ((void *)0)) {
  return 0;
 }
 col = getLineColumn(line);
 for (i=0; i<10; i++) {
  if (col[i] == ' ') {
   return 0;
  }
 }
 return 1;
}

canonical_original_code:
int lineFilled(struct Line *line) {
 int i;
 char *col;
 if (line == ((void *)0)) {
  return 0;
 }
 col = getLineColumn(line);
 for (i=0; i<10; i++) {
  if (col[i] == ' ') {
   return 0;
  }
 }
 return 1;
}

variable_types:
col
char *