decompiled_code:
float __fastcall field_laplacian(__int64 a1, __int16 a2, __int16 a3)
{
__int16 v3; // r8
float v4; // xmm1_4
__int16 v5; // r9
__int16 v6; // r9
__int16 v7; // r8
__int16 v8; // r9
float v9; // xmm2_4
__int16 v10; // r8
int v11; // er8
int v12; // er9
float v13; // xmm0_4
float v14; // xmm5_4
float v15; // xmm4_4

v4 = field_get_safe(a1, a2 - 1, a3);
field_get_safe(a1, v3 + 1, v5);
v9 = field_get_safe(a1, v7, v6 - 1);
field_get_safe(a1, v10, v8 + 1);
v13 = field_get(a1, v11, v12);
return (float)((float)(v4 - (float)(v13 + v13)) + v14) + (float)((float)(v9 - (float)(v13 + v13)) + v15);
}

original_code:
float field_laplacian(const float *field, int x, int y)
{
 float west = field_get_safe(field, x - 1, y);
 float east = field_get_safe(field, x + 1, y);
 float north = field_get_safe(field, x, y - 1);
 float south = field_get_safe(field, x, y + 1);
 float u = field_get(field, x, y);
 return (west - 2 * u + east) / (1.0f * 1.0f) +
  (north - 2 * u + south) / (1.0f * 1.0f);
}

canonical_original_code:
float field_laplacian(float *field, int x, int y)
{
 float west = field_get_safe(field, x - 1, y);
 float east = field_get_safe(field, x + 1, y);
 float north = field_get_safe(field, x, y - 1);
 float south = field_get_safe(field, x, y + 1);
 float u = field_get(field, x, y);
 return (west - 2 * u + east) / (1.0f * 1.0f) +
  (north - 2 * u + south) / (1.0f * 1.0f);
}

variable_types: west float

variable_types: east float

variable_types: north float

variable_types: south float


repo: AndrewBelt/pandemic

decompiled_code:
float __fastcall field_laplacian_boundary(__int64 a1, unsigned int a2, unsigned int a3, __int64 (__fastcall *a4)(_QWORD, _QWORD, double))
{
float result; // xmm0_4
char v7; // r15
char v8; // r14
float v9; // xmm1_4
float v10; // xmm3_4
char v11; // al
float v12; // xmm2_4
float v13; // xmm4_4
float v14; // xmm5_4
float v15; // xmm0_4
float v16; // xmm3_4
float v17; // xmm2_4
char v18; // [rsp+1Bh] [rbp-3Dh]

result = 0.0;
if ( ((unsigned __int8 (__fastcall *)(_QWORD, _QWORD))a4)(a2, a3) )
{
v18 = a4(a2 - 1, a3, 0.0);
v7 = ((__int64 (__fastcall *)(_QWORD, _QWORD))a4)(a2 + 1, a3);
v8 = ((__int64 (__fastcall *)(_QWORD, _QWORD))a4)(a2, a3 - 1);
((void (__fastcall *)(_QWORD, _QWORD))a4)(a2, a3 + 1);
v9 = field_get_safe(a1, a2 - 1, a3);
field_get_safe(a1, a2 + 1, a3);
v10 = field_get_safe(a1, a2, a3 - 1);
field_get_safe(a1, a2, a3 + 1);
v12 = -2.0 * field_get(a1, a2, a3);
if ( v18 )
{
if ( v7 )
v15 = (float)(v9 + v14) + v12;
else
v15 = (float)(v9 + v9) + v12;
}
else
{
if ( v7 )
{
v15 = (float)(v14 + v14) + v12;
if ( v8 )
goto LABEL_6;
goto LABEL_13;
}
v15 = 0.0;
}
if ( v8 )
{
LABEL_6:
if ( v11 )
v16 = v10 + v13;
else
v16 = v10 + v10;
v17 = v12 + v16;
goto LABEL_9;
}
LABEL_13:
if ( v11 )
v17 = v12 + (float)(v13 + v13);
else
v17 = 0.0;
LABEL_9:
result = v15 + v17;
}
return result;
}

canonical_decompiled_code:
float __fastcall func9(__int64 a1, unsigned int a2, unsigned int a3, __int64 (__fastcall *a4)(_QWORD, _QWORD, double))
{
float result; // xmm0_4
char v7; // r15
char v8; // r14
float v9; // xmm1_4
float v10; // xmm3_4
char v11; // al
float v12; // xmm2_4
float v13; // xmm4_4
float v14; // xmm5_4
float v15; // xmm0_4
float v16; // xmm3_4
float v17; // xmm2_4
char v18; // [rsp+1Bh] [rbp-3Dh]

result = 0.0;
if ( ((unsigned __int8 (__fastcall *)(_QWORD, _QWORD))a4)(a2, a3) )
{
v18 = a4(a2 - 1, a3, 0.0);
v7 = ((__int64 (__fastcall *)(_QWORD, _QWORD))a4)(a2 + 1, a3);
v8 = ((__int64 (__fastcall *)(_QWORD, _QWORD))a4)(a2, a3 - 1);
((void (__fastcall *)(_QWORD, _QWORD))a4)(a2, a3 + 1);
v9 = func6(a1, a2 - 1, a3);
func6(a1, a2 + 1, a3);
v10 = func6(a1, a2, a3 - 1);
func6(a1, a2, a3 + 1);
v12 = -2.0 * func0(a1, a2, a3);
if ( v18 )
{
if ( v7 )
v15 = (float)(v9 + v14) + v12;
else
v15 = (float)(v9 + v9) + v12;
}
else
{
if ( v7 )
{
v15 = (float)(v14 + v14) + v12;
if ( v8 )
goto LABEL_6;
goto LABEL_13;
}
v15 = 0.0;
}
if ( v8 )
{
LABEL_6:
if ( v11 )
v16 = v10 + v13;
else
v16 = v10 + v10;
v17 = v12 + v16;
goto LABEL_9;
}
LABEL_13:
if ( v11 )
v17 = v12 + (float)(v13 + v13);
else
v17 = 0.0;
LABEL_9:
result = v15 + v17;
}
return result;
}

original_code:
float field_laplacian_boundary(const float *field, int x, int y,
 boundary_callback bc)
{
 if (!(*bc)(x, y))
  return 0.0f;
 _Bool has_west = (*bc)(x - 1, y);
 _Bool has_east = (*bc)(x + 1, y);
 _Bool has_north = (*bc)(x, y - 1);
 _Bool has_south = (*bc)(x, y + 1);
 float west = field_get_safe(field, x - 1, y);
 float east = field_get_safe(field, x + 1, y);
 float north = field_get_safe(field, x, y - 1);
 float south = field_get_safe(field, x, y + 1);
 float ddx = -2 * field_get(field, x, y);
 float ddy = ddx;
 if (has_west && has_east)
 {
  ddx += west + east;
 }
 else if (has_east)
 {
  ddx += 2 * east;
 }
 else if (has_west)
 {
  ddx += 2 * west;
 }
 else
 {
  ddx = 0;
 }
 if (has_north && has_south)
 {
  ddy += north + south;
 }
 else if (has_south)
 {
  ddy += 2 * south;
 }
 else if (has_north)
 {
  ddy += 2 * north;
 }
 else
 {
  ddy = 0;
 }
 return ddx / (1.0f * 1.0f) + ddy / (1.0f * 1.0f);
}

canonical_original_code:
float field_laplacian_boundary(float *field, int x, int y, _Bool (*bc)(int x, int y))
{
 if (!(*bc)(x, y))
  return 0.0f;
 _Bool has_west = (*bc)(x - 1, y);
 _Bool has_east = (*bc)(x + 1, y);
 _Bool has_north = (*bc)(x, y - 1);
 _Bool has_south = (*bc)(x, y + 1);
 float west = field_get_safe(field, x - 1, y);
 float east = field_get_safe(field, x + 1, y);
 float north = field_get_safe(field, x, y - 1);
 float south = field_get_safe(field, x, y + 1);
 float ddx = -2 * field_get(field, x, y);
 float ddy = ddx;
 if (has_west && has_east)
 {
  ddx += west + east;
 }
 else if (has_east)
 {
  ddx += 2 * east;
 }
 else if (has_west)
 {
  ddx += 2 * west;
 }
 else
 {
  ddx = 0;
 }
 if (has_north && has_south)
 {
  ddy += north + south;
 }
 else if (has_south)
 {
  ddy += 2 * south;
 }
 else if (has_north)
 {
  ddy += 2 * north;
 }
 else
 {
  ddy = 0;
 }
 return ddx / (1.0f * 1.0f) + ddy / (1.0f * 1.0f);
}

variable_types:
field
float *

variable_types: x int

variable_types: y int

variable_types:
bc
_Bool (*)(int x, int y)

variable_types: ddx float

variable_types: ddy float

return_type: float


decompiled_code:
int __fastcall field_print(__int64 a1)
{
int i; // ebp
int j; // ebx
float v3; // xmm0_4
int result; // eax

for ( i = 0; i != 512; ++i )
{
for ( j = 0; j != 1024; ++j )
{
v3 = field_get(a1, j, i);
printf("%6.2f ", v3);
}
result = putchar(10);
}
return result;
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1)
{
int i; // ebp
int j; // ebx
float v3; // xmm0_4
int result; // eax

for ( i = 0; i != 512; ++i )
{
for ( j = 0; j != 1024; ++j )
{
v3 = func0(a1, j, i);
printf("%6.2f ", v3);
}
result = putchar(10);
}
return result;
}

original_code:
void field_print(const float *field)
{
 for (int y = 0; y < 512; y++)
 {
  for (int x = 0; x < 1024; x++)
  {
   printf("%6.2f ", field_get(field, x, y));
  }
  printf("\n");
 }
}

canonical_original_code:
void field_print(float *field)
{
 for (int y = 0; y < 512; y++)
 {
  for (int x = 0; x < 1024; x++)
  {
   printf("%6.2f ", field_get(field, x, y));
  }
  printf("\n");
 }
}

return_type: void


decompiled_code:
float *__fastcall field_sum(float *a1)
{
float *result; // rax
float v2; // xmm0_4

result = a1 + 0x80000;
v2 = 0.0;
do
v2 = v2 + *a1++;
while ( a1 != result );
return result;
}

canonical_decompiled_code:
float *__fastcall func11(float *a1)
{
float *result; // rax
float v2; // xmm0_4

result = a1 + 0x80000;
v2 = 0.0;
do
v2 = v2 + *a1++;
while ( a1 != result );
return result;
}

original_code:
float field_sum(const float *field)
{
 float sum = 0.0f;
 for (int i = 0; i < 1024 * 512; i++)
 {
  sum += field[i];
 }
 return sum;
}

canonical_original_code:
float field_sum(float *field)
{
 float sum = 0.0f;
 for (int i = 0; i < 1024 * 512; i++)
 {
  sum += field[i];
 }
 return sum;
}

variable_types: sum float

variable_types: i int


decompiled_code:
void __fastcall field_set(__int64 a1, int a2, int a3, float a4)
{
*(float *)(a1 + 4LL * (a2 + (a3 << 10))) = a4;
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1, int a2, int a3, float a4)
{
*(float *)(a1 + 4LL * (a2 + (a3 << 10))) = a4;
}

original_code:
static inline void field_set(float *field, int x, int y, float value)
{
 field[x + 1024 * y] = value;
}

variable_types: value float


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

fields[0] = field_create();
fields[1] = field_create();
result = field_create();
fields[2] = result;
return result;
}

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

fields[0] = field_create();
fields[1] = field_create();
result = field_create();
fields[2] = result;
return result;
}

original_code:
void world_init()
{
 for (int i = 0; i < FIELD_TYPE_LENGTH; i++)
 {
  fields[i] = field_create();
 }
}


decompiled_code:
__int64 world_destroy()
{
field_destroy(fields[0]);
field_destroy(fields[1]);
return field_destroy(fields[2]);
}

canonical_decompiled_code:
__int64 func2()
{
field_destroy(fields[0]);
field_destroy(fields[1]);
return field_destroy(fields[2]);
}

original_code:
void world_destroy()
{
 for (int i = 0; i < FIELD_TYPE_LENGTH; i++)
 {
  field_destroy(fields[i]);
 }
}


decompiled_code:
void world_step()
{
__int64 i; // r12
unsigned int v1; // ebp
__int64 v2; // r13
unsigned int j; // ebx
float v4; // xmm0_4

for ( i = 0LL; i != 3; ++i )
{
if ( field_callbacks[i] )
{
v1 = 0;
v2 = field_create();
do
{
for ( j = 0; j != 1024; ++j )
{
v4 = ((float (__fastcall *)(_QWORD, _QWORD))field_callbacks[i])(j, v1);
field_set(v2, j, v1, v4);
}
++v1;
}
while ( v1 != 512 );
field_destroy(fields[i]);
fields[i] = v2;
}
}
}

canonical_decompiled_code:
void func3()
{
__int64 i; // r12
unsigned int v1; // ebp
__int64 v2; // r13
unsigned int j; // ebx
float v4; // xmm0_4

for ( i = 0LL; i != 3; ++i )
{
if ( field_callbacks[i] )
{
v1 = 0;
v2 = field_create();
do
{
for ( j = 0; j != 1024; ++j )
{
v4 = ((float (__fastcall *)(_QWORD, _QWORD))field_callbacks[i])(j, v1);
func0(v2, j, v1, v4);
}
++v1;
}
while ( v1 != 512 );
field_destroy(fields[i]);
fields[i] = v2;
}
}
}

original_code:
void world_step()
{
 for (int i = 0; i < FIELD_TYPE_LENGTH; i++)
 {
  if (field_callbacks[i])
  {
   float *new_field = field_create();
   for (int y = 0; y < 512; y++)
   {
    for (int x = 0; x < 1024; x++)
    {
     float u = (*field_callbacks[i])(x, y);
     field_set(new_field, x, y, u);
    }
   }
   field_destroy(fields[i]);
   fields[i] = new_field;
  }
 }
}

variable_types: u float


map

decompiled_code:
float __fastcall map(float a1, float a2, float a3, float a4, float a5)
{
return (float)((float)((float)(a1 - a2) * (float)(a5 - a4)) / (float)(a3 - a2)) + a4;
}

canonical_decompiled_code:
float __fastcall func0(float a1, float a2, float a3, float a4, float a5)
{
return (float)((float)((float)(a1 - a2) * (float)(a5 - a4)) / (float)(a3 - a2)) + a4;
}

original_code:
float map(float in, float in_low, float in_high,
 float out_low, float out_high)
{
 return (in - in_low) * (out_high - out_low) / (in_high - in_low) + out_low;
}

variable_types: in float


clip

original_code:
float clip(float in, float low, float high)
{
 if (in < low)
  in = low;
 if (in > high)
  in = high;
 return in;
}

variable_types: low float

variable_types: high float


check

decompiled_code:
void *check(char a1, const char *a2, ...)
{
void *result; // rax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a2);
result = arg[0].reg_save_area;
if ( !a1 )
{
if ( a2 )
{
vfprintf(stderr, a2, arg);
fputc(10, stderr);
}
check_cold();
}
return result;
}

canonical_decompiled_code:
void *func0(char a1, const char *a2, ...)
{
void *result; // rax
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a2);
result = arg[0].reg_save_area;
if ( !a1 )
{
if ( a2 )
{
vfprintf(stderr, a2, arg);
fputc(10, stderr);
}
func1();
}
return result;
}

original_code:
void check(_Bool success, const char *err_format, ...)
{
 va_list vl;
 __builtin_va_start(vl,err_format);
 if (!success)
 {
  if (err_format)
  {
   vfprintf(stderr, err_format, vl);
   fprintf(stderr, "\n");
  }
  abort();
 }
 __builtin_va_end(vl);
}

canonical_original_code:
void check(_Bool success, char *err_format, ...)
{
 __builtin_va_list vl;
 __builtin_va_start(vl,err_format);
 if (!success)
 {
  if (err_format)
  {
   vfprintf(stderr, err_format, vl);
   fprintf(stderr, "\n");
  }
  abort();
 }
 __builtin_va_end(vl);
}


append

decompiled_code:
unsigned int __fastcall append(int a1)
{
_DWORD *v1; // rcx
int v2; // eax
int v3; // eax
unsigned int result; // eax

v1 = buffer;
v2 = *((_DWORD *)buffer + 1);
*((_DWORD *)buffer + v2 + 3) = a1;
v1[1] = (v2 + 1) % 20;
v3 = v1[2];
if ( v3 > 19 )
{
puts(s);
result = sleep(1u);
}
else
{
result = v3 + 1;
v1[2] = result;
}
return result;
}

canonical_decompiled_code:
unsigned int __fastcall func7(int a1)
{
_DWORD *v1; // rcx
int v2; // eax
int v3; // eax
unsigned int result; // eax

v1 = buffer;
v2 = *((_DWORD *)buffer + 1);
*((_DWORD *)buffer + v2 + 3) = a1;
v1[1] = (v2 + 1) % 20;
v3 = v1[2];
if ( v3 > 19 )
{
puts(s);
result = sleep(1u);
}
else
{
result = v3 + 1;
v1[2] = result;
}
return result;
}

original_code:
void append(int value) {
 buffer->values[buffer->out_index] = value;
     buffer->out_index = (buffer->out_index + 1) % 20;
     if (buffer->active < 20){
      buffer->active++;
     } else {
         printf("Shouldn't get here, go away.( ͡° ͜ʖ ͡°)\n");
  sleep(1);
     }
}

variable_types: value int


take

decompiled_code:
__int64 take()
{
int *v0; // rcx
int v1; // esi
int v2; // eax
unsigned int v3; // er8
__int64 result; // rax
unsigned int v5; // eax

v0 = (int *)buffer;
v1 = *(_DWORD *)(buffer + 8);
if ( v1 )
{
v2 = *(_DWORD *)buffer;
v3 = *(_DWORD *)(buffer + 4LL * *(int *)buffer + 12);
*(_DWORD *)(buffer + 8) = v1 - 1;
*v0 = (v2 + 1) % 20;
result = v3;
}
else
{
v5 = getpid();
printf("Buffer is empty. Consumer %d waiting.", v5);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 func7()
{
int *v0; // rcx
int v1; // esi
int v2; // eax
unsigned int v3; // er8
__int64 result; // rax
unsigned int v5; // eax

v0 = (int *)buffer;
v1 = *(_DWORD *)(buffer + 8);
if ( v1 )
{
v2 = *(_DWORD *)buffer;
v3 = *(_DWORD *)(buffer + 4LL * *(int *)buffer + 12);
*(_DWORD *)(buffer + 8) = v1 - 1;
*v0 = (v2 + 1) % 20;
result = v3;
}
else
{
v5 = getpid();
printf("Buffer is empty. Consumer %d waiting.", v5);
result = 0LL;
}
return result;
}

original_code:
int take(void)
{
 if (!(buffer->active))
 {
  printf("Buffer is empty. Consumer %d waiting.", getpid());
  return ((void *)0);
 }
     int v = buffer->values[buffer->in_index];
     buffer->in_index = (buffer->in_index + 1) % 20;
     buffer->active--;
     return v;
}

canonical_original_code:
int take()
{
 if (!(buffer->active))
 {
  printf("Buffer is empty. Consumer %d waiting.", getpid());
  return ((void *)0);
 }
     int v = buffer->values[buffer->in_index];
     buffer->in_index = (buffer->in_index + 1) % 20;
     buffer->active--;
     return v;
}

variable_types: v int

return_type: int


keyPressed

repo: AndrewFromMelbourne/raspidmx

decompiled_code:
__int64 __fastcall keyPressed(int *a1)
{
unsigned int v1; // er12
int v2; // ebp
int v4; // eax
struct termios v5; // [rsp+0h] [rbp-58h] BYREF

v2 = stdin_fd;
if ( stdin_fd == -1 )
{
v2 = fileno(stdin);
stdin_fd = v2;
tcgetattr(v2, &original);
*(_QWORD *)&v5.c_cc[31] = *(_QWORD *)&original.c_cc[31];
*(__m128i *)&v5.c_iflag = _mm_load_si128((const __m128i *)&original);
*(__m128i *)&v5.c_line = _mm_load_si128((const __m128i *)&original.c_line);
v5.c_lflag &= 0xFFFFFFF5;
v5.c_ospeed = original.c_ospeed;
*(__m128i *)&v5.c_cc[15] = _mm_load_si128((const __m128i *)&original.c_cc[15]);
tcsetattr(v2, 0, &v5);
setbuf(stdin, 0LL);
}
v5.c_iflag = 0;
ioctl(v2, 0x541BuLL, &v5);
LOBYTE(v1) = v5.c_iflag != 0;
if ( v5.c_iflag != 1 )
{
if ( (int)v5.c_iflag > 1 )
{
do
{
fgetc(stdin);
--v5.c_iflag;
}
while ( v5.c_iflag );
}
return v1;
}
v4 = fgetc(stdin);
if ( !a1 )
return v1;
*a1 = v4;
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func0(int *a1)
{
unsigned int v1; // er12
int v2; // ebp
int v4; // eax
struct termios v5; // [rsp+0h] [rbp-58h] BYREF

v2 = stdin_fd;
if ( stdin_fd == -1 )
{
v2 = fileno(stdin);
stdin_fd = v2;
tcgetattr(v2, &original);
*(_QWORD *)&v5.c_cc[31] = *(_QWORD *)&original.c_cc[31];
*(__m128i *)&v5.c_iflag = _mm_load_si128((const __m128i *)&original);
*(__m128i *)&v5.c_line = _mm_load_si128((const __m128i *)&original.c_line);
v5.c_lflag &= 0xFFFFFFF5;
v5.c_ospeed = original.c_ospeed;
*(__m128i *)&v5.c_cc[15] = _mm_load_si128((const __m128i *)&original.c_cc[15]);
tcsetattr(v2, 0, &v5);
setbuf(stdin, 0LL);
}
v5.c_iflag = 0;
ioctl(v2, 0x541BuLL, &v5);
LOBYTE(v1) = v5.c_iflag != 0;
if ( v5.c_iflag != 1 )
{
if ( (int)v5.c_iflag > 1 )
{
do
{
fgetc(stdin);
--v5.c_iflag;
}
while ( v5.c_iflag );
}
return v1;
}
v4 = fgetc(stdin);
if ( !a1 )
return v1;
*a1 = v4;
return v1;
}

original_code:
_Bool keyPressed(int *character)
{
    if (stdin_fd == -1)
    {
        stdin_fd = fileno(stdin);
        tcgetattr(stdin_fd, &original);
        struct termios term;
        memcpy(&term, &original, sizeof(term));
        term.c_lflag &= ~(0000002|0000010);
        tcsetattr(stdin_fd, 0, &term);
        setbuf(stdin, ((void *)0));
    }
    int characters_buffered = 0;
    ioctl(stdin_fd, 0x541B, &characters_buffered);
    _Bool pressed = (characters_buffered != 0);
    if (characters_buffered == 1)
    {
        int c = fgetc(stdin);
        if (character != ((void *)0))
        {
            *character = c;
        }
    }
    else if (characters_buffered > 1)
    {
        while (characters_buffered)
        {
            fgetc(stdin);
            --characters_buffered;
        }
    }
    return pressed;
}

variable_types:
character
int *

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }

variable_types: c int


keyboardReset

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

if ( stdin_fd != -1 )
result = tcsetattr(stdin_fd, 0, &original);
return result;
}

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

if ( stdin_fd != -1 )
result = tcsetattr(stdin_fd, 0, &original);
return result;
}

original_code:
void keyboardReset(void)
{
    if (stdin_fd != -1)
    {
        tcsetattr(stdin_fd, 0, &original);
    }
}

canonical_original_code:
void keyboardReset()
{
    if (stdin_fd != -1)
    {
        tcsetattr(stdin_fd, 0, &original);
    }
}


resize

decompiled_code:
int __fastcall resize(const char *a1, const char *a2, __int64 a3)
{
int v4; // er12
int result; // eax
__int64 v6[6]; // [rsp+0h] [rbp-178h] BYREF
struct stat v7; // [rsp+30h] [rbp-148h] BYREF
struct stat v8; // [rsp+C0h] [rbp-B8h] BYREF

v4 = stat(a1, &v7);
result = stat(a2, &v8);
if ( result || !v4 && (result = v8.st_mtim.tv_sec, v7.st_mtim.tv_sec > v8.st_mtim.tv_sec) )
{
v6[0] = (__int64)"convert";
v6[1] = (__int64)"-resize";
v6[2] = a3;
v6[3] = (__int64)a1;
v6[4] = (__int64)a2;
v6[5] = 0LL;
result = g_spawn_sync(0LL, v6, 0LL, 4LL, 0LL, 0LL, 0LL, 0LL, 0LL, 0LL);
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(const char *a1, const char *a2, __int64 a3)
{
int v4; // er12
int result; // eax
__int64 v6[6]; // [rsp+0h] [rbp-178h] BYREF
struct stat v7; // [rsp+30h] [rbp-148h] BYREF
struct stat v8; // [rsp+C0h] [rbp-B8h] BYREF

v4 = stat(a1, &v7);
result = stat(a2, &v8);
if ( result || !v4 && (result = v8.st_mtim.tv_sec, v7.st_mtim.tv_sec > v8.st_mtim.tv_sec) )
{
v6[0] = (__int64)"convert";
v6[1] = (__int64)"-resize";
v6[2] = a3;
v6[3] = (__int64)a1;
v6[4] = (__int64)a2;
v6[5] = 0LL;
result = g_spawn_sync(0LL, v6, 0LL, 4LL, 0LL, 0LL, 0LL, 0LL, 0LL, 0LL);
}
return result;
}

original_code:
void resize(gchar *orig, gchar *thumb, gchar *size)
{
 GStatBuf oinfo, tinfo;
 int oval = stat(orig, &oinfo);
 int tval = stat(thumb, &tinfo);
 if (tval || (!oval && oinfo.st_mtime > tinfo.st_mtime)) {
  gchar *argv[] = {"convert", "-resize", size, orig, thumb, ((void *)0)};
  g_spawn_sync(((void *)0), argv, ((void *)0), G_SPAWN_SEARCH_PATH,
   ((void *)0), ((void *)0), ((void *)0), ((void *)0), ((void *)0), ((void *)0));
 }
}

canonical_original_code:
void resize(char *orig, char *thumb, char *size)
{
 struct stat oinfo; struct stat tinfo;
 int oval = stat(orig, &oinfo);
 int tval = stat(thumb, &tinfo);
 if (tval || (!oval && oinfo.st_mtime > tinfo.st_mtime)) {
  char *argv[] = {"convert", "-resize", size, orig, thumb, ((void *)0)};
  g_spawn_sync(((void *)0), argv, ((void *)0), G_SPAWN_SEARCH_PATH,
   ((void *)0), ((void *)0), ((void *)0), ((void *)0), ((void *)0), ((void *)0));
 }
}

variable_types:
orig
char *

variable_types:
thumb
char *

variable_types:
size
char *

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; long st_atime; unsigned long st_atimensec; long st_mtime; unsigned long st_mtimensec; long st_ctime; unsigned long st_ctimensec; long __glibc_reserved[3]; }

variable_types: oval int

variable_types: tval int

variable_types:
argv
char *[]


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
__int64 v4; // r13
_QWORD *v5; // rdi
_QWORD *v6; // rax
_QWORD *v7; // r12

ct_print_header("text/html", 0LL, envp);
v3 = ct_get_path_info();
v4 = ct_get_query_string();
v5 = (_QWORD *)read_dir((__int64)"large");
v6 = gen_thumbs(v5);
if ( v3 && (v7 = v6, !(unsigned int)g_str_equal(v3, "/")) )
{
if ( (unsigned int)g_str_equal(v3, "/head") )
{
frame_head();
}
else if ( (unsigned int)g_str_equal(v3, "/nav") )
{
frame_nav(0LL, v7);
}
else if ( (unsigned int)g_str_equal(v3, "/noframe") )
{
frame_nav(1LL, v7);
}
else if ( (unsigned int)g_str_equal(v3, "/show_small") )
{
frame_show("small", "show_large", v4);
}
else if ( (unsigned int)g_str_equal(v3, "/show_large") )
{
frame_show("large", "show_small", v4);
}
}
else
{
frame_index();
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
__int64 v4; // r13
_QWORD *v5; // rdi
_QWORD *v6; // rax
_QWORD *v7; // r12

ct_print_header("text/html", 0LL, envp);
v3 = ct_get_path_info();
v4 = ct_get_query_string();
v5 = (_QWORD *)func1((__int64)"large");
v6 = gen_thumbs(v5);
if ( v3 && (v7 = v6, !(unsigned int)g_str_equal(v3, "/")) )
{
if ( (unsigned int)g_str_equal(v3, "/head") )
{
frame_head();
}
else if ( (unsigned int)g_str_equal(v3, "/nav") )
{
frame_nav(0LL, v7);
}
else if ( (unsigned int)g_str_equal(v3, "/noframe") )
{
frame_nav(1LL, v7);
}
else if ( (unsigned int)g_str_equal(v3, "/show_small") )
{
frame_show("small", "show_large", v4);
}
else if ( (unsigned int)g_str_equal(v3, "/show_large") )
{
frame_show("large", "show_small", v4);
}
}
else
{
frame_index();
}
return 0;
}

original_code:
int main()
{
 ct_print_header("text/html", ((void *)0));
 const gchar *path = ct_get_path_info();
 const gchar *query = ct_get_query_string();
 GList *thumbs = gen_thumbs(read_dir("large"));
 if (!path || g_str_equal(path, "/"))
  frame_index();
 else if (g_str_equal(path, "/head"))
  frame_head();
 else if (g_str_equal(path, "/nav"))
  frame_nav((0), thumbs);
 else if (g_str_equal(path, "/noframe"))
  frame_nav((!(0)), thumbs);
 else if (g_str_equal(path, "/show_small"))
  frame_show("small", "show_large", query);
 else if (g_str_equal(path, "/show_large"))
  frame_show("large", "show_small", query);
}

canonical_original_code:
int main()
{
 ct_print_header("text/html", ((void *)0));
 char *path = ct_get_path_info();
 char *query = ct_get_query_string();
 struct _GList *thumbs = gen_thumbs(read_dir("large"));
 if (!path || g_str_equal(path, "/"))
  frame_index();
 else if (g_str_equal(path, "/head"))
  frame_head();
 else if (g_str_equal(path, "/nav"))
  frame_nav((0), thumbs);
 else if (g_str_equal(path, "/noframe"))
  frame_nav((!(0)), thumbs);
 else if (g_str_equal(path, "/show_small"))
  frame_show("small", "show_large", query);
 else if (g_str_equal(path, "/show_large"))
  frame_show("large", "show_small", query);
}

variable_types:
path
char *

variable_types:
query
char *

variable_types: struct _GList { void *data; struct _GList *next; struct _GList *prev; } *


decompiled_code:
__int64 __fastcall yysyntax_error(unsigned __int64 *a1, const char **a2, __int16 *a3, int a4)
{
char *v6; // r15
_BYTE *v7; // rax
_BYTE *v8; // r14
__int64 v9; // rax
int v10; // eax
__int64 v11; // rbx
int v12; // er12
__int64 v13; // rbp
__int64 v14; // r13
char *v15; // rsi
_BYTE *v16; // rax
bool v17; // cf
__int64 v18; // rax
const char *v19; // rbx
unsigned __int64 v20; // rax
__int64 v21; // rcx
char *v22; // r12
char v23; // al
char v24; // dl
int v25; // er13
_BYTE *v26; // rax
__int64 result; // rax
_BYTE *v28; // [rsp+8h] [rbp-80h]
__int64 v30[13]; // [rsp+20h] [rbp-68h]

v6 = yytname[a4];
v7 = yytnamerr(0LL, v6);
v28 = v7;
if ( a4 == -2 )
{
v18 = 12LL;
LODWORD(v13) = 0;
v19 = "syntax error";
}
else
{
v8 = v7;
v9 = *a3;
v30[0] = (__int64)v6;
v10 = yypact[v9];
if ( (_BYTE)v10 == 0xFA )
{
LABEL_16:
v18 = 27LL;
LODWORD(v13) = 1;
v19 = "syntax error, unexpected %s";
}
else
{
LODWORD(v11) = -v10;
if ( v10 >= 0 )
LODWORD(v11) = 0;
v12 = 14 - v10;
if ( 14 - v10 > 8 )
v12 = 8;
if ( (int)v11 >= v12 )
{
v8 = v28;
LABEL_38:
v28 = v8;
v18 = 27LL;
LODWORD(v13) = 1;
v19 = "syntax error, unexpected %s";
}
else
{
v11 = (int)v11;
v13 = 1LL;
v14 = (char)v10;
do
{
while ( yycheck[v14 + v11] != (_DWORD)v11 || (_DWORD)v11 == 1 )
{
if ( v12 <= (int)++v11 )
goto LABEL_15;
}
if ( (_DWORD)v13 == 5 )
goto LABEL_16;
v15 = yytname[v11];
v30[v13] = (__int64)v15;
v16 = yytnamerr(0LL, v15);
v17 = __CFADD__(v8, v16);
v8 = &v16[(_QWORD)v8];
if ( v17 )
return 2LL;
++v11;
v13 = (int)v13 + 1;
}
while ( v12 > (int)v11 );
LABEL_15:
switch ( (int)v13 )
{
case 1:
goto LABEL_38;
case 2:
v28 = v8;
v18 = 41LL;
v19 = "syntax error, unexpected %s, expecting %s";
break;
case 3:
v28 = v8;
v18 = 47LL;
v19 = "syntax error, unexpected %s, expecting %s or %s";
break;
case 4:
v28 = v8;
v18 = 53LL;
v19 = "syntax error, unexpected %s, expecting %s or %s or %s";
break;
case 5:
v28 = v8;
v18 = 59LL;
v19 = "syntax error, unexpected %s, expecting %s or %s or %s or %s";
break;
default:
v28 = v8;
v18 = 12LL;
v19 = "syntax error";
break;
}
}
}
}
v17 = __CFADD__(v28, v18);
v20 = (unsigned __int64)&v28[v18];
if ( v17 )
return 2LL;
if ( *a1 < v20 )
{
if ( 2 * v20 >= v20 )
*a1 = 2 * v20;
else
*a1 = -1LL;
result = 1LL;
}
else
{
v21 = 0LL;
v22 = (char *)*a2;
v23 = *v19;
for ( **a2 = *v19; v23; *v22 = *v19 )
{
while ( 1 )
{
v24 = v19[1];
if ( v23 == 37 && v24 == 115 && (int)v13 > (int)v21 )
break;
++v22;
v23 = *++v19;
*v22 = v24;
if ( !v24 )
goto LABEL_26;
}
v25 = v21 + 1;
v19 += 2;
v26 = yytnamerr(v22, (char *)v30[v21]);
v21 = v25;
v22 = &v22[(_QWORD)v26];
v23 = *v19;
}
LABEL_26:
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int64 *a1, const char **a2, __int16 *a3, int a4)
{
char *v6; // r15
_BYTE *v7; // rax
_BYTE *v8; // r14
__int64 v9; // rax
int v10; // eax
__int64 v11; // rbx
int v12; // er12
__int64 v13; // rbp
__int64 v14; // r13
char *v15; // rsi
_BYTE *v16; // rax
bool v17; // cf
__int64 v18; // rax
const char *v19; // rbx
unsigned __int64 v20; // rax
__int64 v21; // rcx
char *v22; // r12
char v23; // al
char v24; // dl
int v25; // er13
_BYTE *v26; // rax
__int64 result; // rax
_BYTE *v28; // [rsp+8h] [rbp-80h]
__int64 v30[13]; // [rsp+20h] [rbp-68h]

v6 = yytname[a4];
v7 = yytnamerr(0LL, v6);
v28 = v7;
if ( a4 == -2 )
{
v18 = 12LL;
LODWORD(v13) = 0;
v19 = "syntax error";
}
else
{
v8 = v7;
v9 = *a3;
v30[0] = (__int64)v6;
v10 = yypact[v9];
if ( (_BYTE)v10 == 0xFA )
{
LABEL_16:
v18 = 27LL;
LODWORD(v13) = 1;
v19 = "syntax error, unexpected %s";
}
else
{
LODWORD(v11) = -v10;
if ( v10 >= 0 )
LODWORD(v11) = 0;
v12 = 14 - v10;
if ( 14 - v10 > 8 )
v12 = 8;
if ( (int)v11 >= v12 )
{
v8 = v28;
LABEL_38:
v28 = v8;
v18 = 27LL;
LODWORD(v13) = 1;
v19 = "syntax error, unexpected %s";
}
else
{
v11 = (int)v11;
v13 = 1LL;
v14 = (char)v10;
do
{
while ( yycheck[v14 + v11] != (_DWORD)v11 || (_DWORD)v11 == 1 )
{
if ( v12 <= (int)++v11 )
goto LABEL_15;
}
if ( (_DWORD)v13 == 5 )
goto LABEL_16;
v15 = yytname[v11];
v30[v13] = (__int64)v15;
v16 = yytnamerr(0LL, v15);
v17 = __CFADD__(v8, v16);
v8 = &v16[(_QWORD)v8];
if ( v17 )
return 2LL;
++v11;
v13 = (int)v13 + 1;
}
while ( v12 > (int)v11 );
LABEL_15:
switch ( (int)v13 )
{
case 1:
goto LABEL_38;
case 2:
v28 = v8;
v18 = 41LL;
v19 = "syntax error, unexpected %s, expecting %s";
break;
case 3:
v28 = v8;
v18 = 47LL;
v19 = "syntax error, unexpected %s, expecting %s or %s";
break;
case 4:
v28 = v8;
v18 = 53LL;
v19 = "syntax error, unexpected %s, expecting %s or %s or %s";
break;
case 5:
v28 = v8;
v18 = 59LL;
v19 = "syntax error, unexpected %s, expecting %s or %s or %s or %s";
break;
default:
v28 = v8;
v18 = 12LL;
v19 = "syntax error";
break;
}
}
}
}
v17 = __CFADD__(v28, v18);
v20 = (unsigned __int64)&v28[v18];
if ( v17 )
return 2LL;
if ( *a1 < v20 )
{
if ( 2 * v20 >= v20 )
*a1 = 2 * v20;
else
*a1 = -1LL;
result = 1LL;
}
else
{
v21 = 0LL;
v22 = (char *)*a2;
v23 = *v19;
for ( **a2 = *v19; v23; *v22 = *v19 )
{
while ( 1 )
{
v24 = v19[1];
if ( v23 == 37 && v24 == 115 && (int)v13 > (int)v21 )
break;
++v22;
v23 = *++v19;
*v22 = v24;
if ( !v24 )
goto LABEL_26;
}
v25 = v21 + 1;
v19 += 2;
v26 = yytnamerr(v22, (char *)v30[v21]);
v21 = v25;
v22 = &v22[(_QWORD)v26];
v23 = *v19;
}
LABEL_26:
result = 0LL;
}
return result;
}

original_code:
static int
yysyntax_error (long unsigned int *yymsg_alloc, char **yymsg,
                yytype_int16 *yyssp, int yytoken)
{
  long unsigned int yysize0 = yytnamerr (((void*)0), yytname[yytoken]);
  long unsigned int yysize = yysize0;
  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
  const char *yyformat = ((void*)0);
  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
  int yycount = 0;
  if (yytoken != (-2))
    {
      int yyn = yypact[*yyssp];
      yyarg[yycount++] = yytname[yytoken];
      if (!(!!((yyn) == (-6))))
        {
          int yyxbegin = yyn < 0 ? -yyn : 0;
          int yychecklim = 13 - yyn + 1;
          int yyxend = yychecklim < 8 ? yychecklim : 8;
          int yyx;
          for (yyx = yyxbegin; yyx < yyxend; ++yyx)
            if (yycheck[yyx + yyn] == yyx && yyx != 1
                && !0)
              {
                if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
                  {
                    yycount = 1;
                    yysize = yysize0;
                    break;
                  }
                yyarg[yycount++] = yytname[yyx];
                {
                  long unsigned int yysize1 = yysize + yytnamerr (((void*)0), yytname[yyx]);
                  if (yysize <= yysize1 && yysize1 <= ((long unsigned int) -1))
                    yysize = yysize1;
                  else
                    return 2;
                }
              }
        }
    }
  switch (yycount)
    {
    default:
      case 0: yyformat = "syntax error"; break;
      case 1: yyformat = "syntax error, unexpected %s"; break;
      case 2: yyformat = "syntax error, unexpected %s, expecting %s"; break;
      case 3: yyformat = "syntax error, unexpected %s, expecting %s or %s"; break;
      case 4: yyformat = "syntax error, unexpected %s, expecting %s or %s or %s"; break;
      case 5: yyformat = "syntax error, unexpected %s, expecting %s or %s or %s or %s"; break;
    }
  {
    long unsigned int yysize1 = yysize + strlen (yyformat);
    if (yysize <= yysize1 && yysize1 <= ((long unsigned int) -1))
      yysize = yysize1;
    else
      return 2;
  }
  if (*yymsg_alloc < yysize)
    {
      *yymsg_alloc = 2 * yysize;
      if (! (yysize <= *yymsg_alloc
             && *yymsg_alloc <= ((long unsigned int) -1)))
        *yymsg_alloc = ((long unsigned int) -1);
      return 1;
    }
  {
    char *yyp = *yymsg;
    int yyi = 0;
    while ((*yyp = *yyformat) != '\0')
      if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
        {
          yyp += yytnamerr (yyp, yyarg[yyi++]);
          yyformat += 2;
        }
      else
        {
          yyp++;
          yyformat++;
        }
  }
  return 0;
}

canonical_original_code:
static int yysyntax_error(unsigned long *yymsg_alloc, char **yymsg, short *yyssp, int yytoken)
{
  unsigned long yysize0 = yytnamerr (((void*)0), yytname[yytoken]);
  unsigned long yysize = yysize0;
  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
  char *yyformat = ((void*)0);
  char *yyarg[-1];
  int yycount = 0;
  if (yytoken != (-2))
    {
      int yyn = yypact[*yyssp];
      yyarg[yycount++] = yytname[yytoken];
      if (!(!!((yyn) == (-6))))
        {
          int yyxbegin = yyn < 0 ? -yyn : 0;
          int yychecklim = 13 - yyn + 1;
          int yyxend = yychecklim < 8 ? yychecklim : 8;
          int yyx;
          for (yyx = yyxbegin; yyx < yyxend; ++yyx)
            if (yycheck[yyx + yyn] == yyx && yyx != 1
                && !0)
              {
                if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
                  {
                    yycount = 1;
                    yysize = yysize0;
                    break;
                  }
                yyarg[yycount++] = yytname[yyx];
                {
                  unsigned long yysize1 = yysize + yytnamerr (((void*)0), yytname[yyx]);
                  if (yysize <= yysize1 && yysize1 <= ((unsigned long) -1))
                    yysize = yysize1;
                  else
                    return 2;
                }
              }
        }
    }
  switch (yycount)
    {
    default:
      case 0: yyformat = "syntax error"; break;
      case 1: yyformat = "syntax error, unexpected %s"; break;
      case 2: yyformat = "syntax error, unexpected %s, expecting %s"; break;
      case 3: yyformat = "syntax error, unexpected %s, expecting %s or %s"; break;
      case 4: yyformat = "syntax error, unexpected %s, expecting %s or %s or %s"; break;
      case 5: yyformat = "syntax error, unexpected %s, expecting %s or %s or %s or %s"; break;
    }
  {
    unsigned long yysize1 = yysize + strlen (yyformat);
    if (yysize <= yysize1 && yysize1 <= ((unsigned long) -1))
      yysize = yysize1;
    else
      return 2;
  }
  if (*yymsg_alloc < yysize)
    {
      *yymsg_alloc = 2 * yysize;
      if (! (yysize <= *yymsg_alloc
             && *yymsg_alloc <= ((unsigned long) -1)))
        *yymsg_alloc = ((unsigned long) -1);
      return 1;
    }
  {
    char *yyp = *yymsg;
    int yyi = 0;
    while ((*yyp = *yyformat) != '\0')
      if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
        {
          yyp += yytnamerr (yyp, yyarg[yyi++]);
          yyformat += 2;
        }
      else
        {
          yyp++;
          yyformat++;
        }
  }
  return 0;
}

variable_types:
yymsg
char **

variable_types:
yyssp
short *

variable_types: yytoken int

variable_types:
yysize
unsigned long

variable_types:
yyformat
char *

variable_types:
yyarg
char *[-1]

variable_types: yycount int

variable_types: yyn int

variable_types: yyxbegin int

variable_types: yychecklim int

variable_types: yyxend int

variable_types: yyx int

variable_types:
yyp
char *

variable_types: yyi int


yyerror

decompiled_code:
void __fastcall __noreturn yyerror(__int64 a1, const char *a2)
{
g_log(0LL, 4LL, "[%s]\n", a2);
while ( 1 )
;
}

canonical_decompiled_code:
void __fastcall __noreturn func1(__int64 a1, const char *a2)
{
g_log(0LL, 4LL, "[%s]\n", a2);
while ( 1 )
;
}

original_code:
void yyerror(gpointer root, char const *s)
{
 do { g_log (((gchar*) 0), G_LOG_LEVEL_ERROR, "[%s]\n", s); for (;;) ; } while (0);
}

canonical_original_code:
void yyerror(void *root, char *s)
{
 do { g_log (((char *) 0), G_LOG_LEVEL_ERROR, "[%s]\n", s); for (;;) ; } while (0);
}

variable_types:
root
void *

variable_types:
s
char *


yyparse

decompiled_code:
__int64 __fastcall yyparse(__int64 a1)
{
__int64 v1; // r15
unsigned __int64 v2; // rbp
__int16 *v3; // r14
__int16 *v4; // r13
char *v5; // rbx
unsigned int v6; // er12
int v7; // eax
__int16 *v8; // rdx
unsigned __int64 v9; // rax
__int64 v10; // r13
__int64 v11; // rbx
__int16 *v12; // rax
__int16 *v13; // r12
char *v14; // rax
__int64 v15; // rdx
char *v16; // r10
int v17; // eax
char v18; // al
unsigned __int8 v19; // si
__int64 v20; // r12
const char *v21; // rax
__int64 v22; // rax
__int64 v23; // rax
__int64 v24; // rax
char *v25; // rsi
int v26; // ecx
int v27; // edi
int v28; // eax
__int16 v29; // si
unsigned int v30; // eax
__int64 v31; // rax
__int64 v32; // rax
const char *v33; // rsi
__int64 v34; // rax
__int64 v35; // rax
__int64 v36; // rax
__int64 v37; // rax
__int64 v38; // rax
__int64 v39; // rax
unsigned int v40; // er12
__int64 v42; // rax
const char *v43; // rsi
int v44; // er12
int v45; // eax
char *v46; // [rsp+8h] [rbp-8C0h]
char *v47; // [rsp+18h] [rbp-8B0h]
__int16 *v48; // [rsp+20h] [rbp-8A8h]
void *ptr; // [rsp+30h] [rbp-898h] BYREF
size_t size; // [rsp+38h] [rbp-890h] BYREF
char v52[128]; // [rsp+40h] [rbp-888h] BYREF
__int16 src[200]; // [rsp+C0h] [rbp-808h] BYREF
char v54[1656]; // [rsp+250h] [rbp-678h] BYREF

v1 = 0LL;
v2 = 200LL;
yynerrs = 0;
ptr = v52;
src[0] = 0;
v3 = src;
v46 = v54;
v4 = src;
v5 = v54;
size = 128LL;
yychar = -2;
do
{
v6 = yypact[v1];
if ( v6 == -6 )
goto LABEL_23;
v17 = yychar;
if ( yychar == -2 )
{
v17 = yylex();
yychar = v17;
}
if ( v17 > 0 )
{
if ( v17 <= 262 )
{
v7 = (unsigned __int8)yytranslate[v17];
v6 += v7;
}
else
{
v6 += 2;
v7 = 2;
}
if ( v6 > 0xD )
goto LABEL_23;
}
else
{
yychar = 0;
v7 = 0;
if ( v6 > 0xD )
goto LABEL_23;
}
if ( yycheck[v6] == v7 )
{
v1 = (unsigned __int8)yytable[v6];
if ( yytable[v6] )
{
v5 += 8;
v8 = v4;
yychar = -2;
*(_QWORD *)v5 = yylval;
goto LABEL_8;
}
v20 = *((_QWORD *)v5 + 1);
v8 = v4;
v25 = v5;
v26 = -8;
v27 = 13;
goto LABEL_28;
}
LABEL_23:
v18 = yydefact[v1];
if ( !v18 )
{
v44 = yychar;
if ( yychar != -2 )
{
if ( (unsigned int)yychar > 0x106 )
v44 = 2;
else
v44 = (unsigned __int8)yytranslate[yychar];
}
++yynerrs;
v45 = yysyntax_error(&size, (const char **)&ptr, v4, v44);
if ( v45 )
{
v43 = "syntax error";
if ( v45 != 1 )
goto LABEL_47;
if ( ptr != v52 )
free(ptr);
ptr = malloc(size);
if ( !ptr )
{
v43 = "syntax error";
size = 128LL;
ptr = v52;
LABEL_47:
yyerror(a1, v43);
}
yysyntax_error(&size, (const char **)&ptr, v4, v44);
}
v43 = (const char *)ptr;
goto LABEL_47;
}
v19 = yyr2[(unsigned __int8)yydefact[v1]];
v20 = *(_QWORD *)&v5[8 * (1 - v19)];
if ( v18 == 10 )
{
v38 = g_strdup_printf("printf(\"%%s\", %s);\n", *((const char **)v5 - 1));
v39 = g_list_prepend(code, v38);
v25 = v5 - 32;
v8 = v4 - 4;
v26 = 5;
code = v39;
v27 = -6;
}
else if ( (unsigned __int8)v18 > 0xAu )
{
if ( v18 != 11 )
{
LABEL_44:
v26 = (unsigned __int8)yyr1[(unsigned __int8)yydefact[v1]] - 8;
v27 = yypgoto[v26];
v42 = 2LL * v19;
v25 = &v5[-8 * v19];
v8 = &v4[v42 / 0xFFFFFFFFFFFFFFFELL];
goto LABEL_28;
}
v36 = g_strdup_printf("printf(%s);\n", *((const char **)v5 - 1));
v37 = g_list_prepend(code, v36);
v25 = v5 - 32;
v8 = v4 - 4;
v26 = 6;
code = v37;
v27 = -6;
}
else if ( v18 == 8 )
{
v21 = (const char *)g_strescape(*(_QWORD *)v5, &unk_9EF);
v22 = g_strdup_printf("static char data%d[] = \"%s\";\n", (unsigned int)i_0, v21);
data = g_list_prepend(data, v22);
v23 = g_strdup_printf("fwrite(data%d, sizeof(data%d)-1, 1, stdout);\n", (unsigned int)i_0, (unsigned int)i_0);
v24 = g_list_prepend(code, v23);
++i_0;
v25 = v5 - 8;
v8 = v4 - 1;
code = v24;
v26 = 3;
v27 = -6;
}
else
{
if ( v18 != 9 )
goto LABEL_44;
v31 = g_strdup_printf("#line %d \"%s\"\n", yylineno, (const char *)name);
v32 = g_list_prepend(code, v31);
v33 = (const char *)*((_QWORD *)v5 - 1);
code = v32;
v34 = g_strdup_printf("%s\n", v33);
v35 = g_list_prepend(code, v34);
v25 = v5 - 24;
v8 = v4 - 3;
v26 = 4;
code = v35;
v27 = -6;
}
LABEL_28:
v28 = *v8;
*((_QWORD *)v25 + 1) = v20;
v5 = v25 + 8;
v29 = v28;
v30 = v27 + v28;
if ( v30 <= 0xD && v29 == yycheck[v30] )
v1 = (unsigned __int8)yytable[v30];
else
v1 = yydefgoto[v26];
LABEL_8:
v9 = 2 * v2;
v8[1] = v1;
v4 = v8 + 1;
if ( v8 + 1 >= &v3[v2 - 1] )
{
v10 = (char *)v4 - (char *)v3;
v11 = (v10 >> 1) + 1;
if ( v2 > 0x270F )
goto LABEL_46;
v2 = 10000LL;
if ( v9 <= 0x2710 )
v2 = v9;
v12 = (__int16 *)malloc(10 * v2 + 7);
v13 = v12;
if ( !v12 )
{
LABEL_46:
v43 = "memory exhausted";
goto LABEL_47;
}
v48 = v12;
memcpy(v12, v3, v10 + 2);
v14 = (char *)memcpy(&v13[v2], v46, 8 * v11);
v15 = 8 * v11;
v16 = v14;
if ( v3 != src )
{
v47 = v14;
free(v3);
v16 = v47;
v15 = 8 * v11;
}
v4 = (__int16 *)((char *)v13 + v10);
v5 = &v16[v15 - 8];
if ( v4 >= &v13[v2 - 1] )
{
v40 = 1;
free(v48);
goto LABEL_41;
}
v46 = v16;
v3 = v13;
}
}
while ( (_DWORD)v1 != 12 );
v40 = 0;
if ( v3 != src )
free(v3);
LABEL_41:
if ( ptr != v52 )
free(ptr);
return v40;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 v1; // r15
unsigned __int64 v2; // rbp
__int16 *v3; // r14
__int16 *v4; // r13
char *v5; // rbx
unsigned int v6; // er12
int v7; // eax
__int16 *v8; // rdx
unsigned __int64 v9; // rax
__int64 v10; // r13
__int64 v11; // rbx
__int16 *v12; // rax
__int16 *v13; // r12
char *v14; // rax
__int64 v15; // rdx
char *v16; // r10
int v17; // eax
char v18; // al
unsigned __int8 v19; // si
__int64 v20; // r12
const char *v21; // rax
__int64 v22; // rax
__int64 v23; // rax
__int64 v24; // rax
char *v25; // rsi
int v26; // ecx
int v27; // edi
int v28; // eax
__int16 v29; // si
unsigned int v30; // eax
__int64 v31; // rax
__int64 v32; // rax
const char *v33; // rsi
__int64 v34; // rax
__int64 v35; // rax
__int64 v36; // rax
__int64 v37; // rax
__int64 v38; // rax
__int64 v39; // rax
unsigned int v40; // er12
__int64 v42; // rax
const char *v43; // rsi
int v44; // er12
int v45; // eax
char *v46; // [rsp+8h] [rbp-8C0h]
char *v47; // [rsp+18h] [rbp-8B0h]
__int16 *v48; // [rsp+20h] [rbp-8A8h]
void *ptr; // [rsp+30h] [rbp-898h] BYREF
size_t size; // [rsp+38h] [rbp-890h] BYREF
char v52[128]; // [rsp+40h] [rbp-888h] BYREF
__int16 src[200]; // [rsp+C0h] [rbp-808h] BYREF
char v54[1656]; // [rsp+250h] [rbp-678h] BYREF

v1 = 0LL;
v2 = 200LL;
yynerrs = 0;
ptr = v52;
src[0] = 0;
v3 = src;
v46 = v54;
v4 = src;
v5 = v54;
size = 128LL;
yychar = -2;
do
{
v6 = yypact[v1];
if ( v6 == -6 )
goto LABEL_23;
v17 = yychar;
if ( yychar == -2 )
{
v17 = yylex();
yychar = v17;
}
if ( v17 > 0 )
{
if ( v17 <= 262 )
{
v7 = (unsigned __int8)yytranslate[v17];
v6 += v7;
}
else
{
v6 += 2;
v7 = 2;
}
if ( v6 > 0xD )
goto LABEL_23;
}
else
{
yychar = 0;
v7 = 0;
if ( v6 > 0xD )
goto LABEL_23;
}
if ( yycheck[v6] == v7 )
{
v1 = (unsigned __int8)yytable[v6];
if ( yytable[v6] )
{
v5 += 8;
v8 = v4;
yychar = -2;
*(_QWORD *)v5 = yylval;
goto LABEL_8;
}
v20 = *((_QWORD *)v5 + 1);
v8 = v4;
v25 = v5;
v26 = -8;
v27 = 13;
goto LABEL_28;
}
LABEL_23:
v18 = yydefact[v1];
if ( !v18 )
{
v44 = yychar;
if ( yychar != -2 )
{
if ( (unsigned int)yychar > 0x106 )
v44 = 2;
else
v44 = (unsigned __int8)yytranslate[yychar];
}
++yynerrs;
v45 = func0(&size, (const char **)&ptr, v4, v44);
if ( v45 )
{
v43 = "syntax error";
if ( v45 != 1 )
goto LABEL_47;
if ( ptr != v52 )
free(ptr);
ptr = malloc(size);
if ( !ptr )
{
v43 = "syntax error";
size = 128LL;
ptr = v52;
LABEL_47:
func1(a1, v43);
}
func0(&size, (const char **)&ptr, v4, v44);
}
v43 = (const char *)ptr;
goto LABEL_47;
}
v19 = yyr2[(unsigned __int8)yydefact[v1]];
v20 = *(_QWORD *)&v5[8 * (1 - v19)];
if ( v18 == 10 )
{
v38 = g_strdup_printf("printf(\"%%s\", %s);\n", *((const char **)v5 - 1));
v39 = g_list_prepend(code, v38);
v25 = v5 - 32;
v8 = v4 - 4;
v26 = 5;
code = v39;
v27 = -6;
}
else if ( (unsigned __int8)v18 > 0xAu )
{
if ( v18 != 11 )
{
LABEL_44:
v26 = (unsigned __int8)yyr1[(unsigned __int8)yydefact[v1]] - 8;
v27 = yypgoto[v26];
v42 = 2LL * v19;
v25 = &v5[-8 * v19];
v8 = &v4[v42 / 0xFFFFFFFFFFFFFFFELL];
goto LABEL_28;
}
v36 = g_strdup_printf("printf(%s);\n", *((const char **)v5 - 1));
v37 = g_list_prepend(code, v36);
v25 = v5 - 32;
v8 = v4 - 4;
v26 = 6;
code = v37;
v27 = -6;
}
else if ( v18 == 8 )
{
v21 = (const char *)g_strescape(*(_QWORD *)v5, &unk_9EF);
v22 = g_strdup_printf("static char data%d[] = \"%s\";\n", (unsigned int)i_0, v21);
data = g_list_prepend(data, v22);
v23 = g_strdup_printf("fwrite(data%d, sizeof(data%d)-1, 1, stdout);\n", (unsigned int)i_0, (unsigned int)i_0);
v24 = g_list_prepend(code, v23);
++i_0;
v25 = v5 - 8;
v8 = v4 - 1;
code = v24;
v26 = 3;
v27 = -6;
}
else
{
if ( v18 != 9 )
goto LABEL_44;
v31 = g_strdup_printf("#line %d \"%s\"\n", yylineno, (const char *)name);
v32 = g_list_prepend(code, v31);
v33 = (const char *)*((_QWORD *)v5 - 1);
code = v32;
v34 = g_strdup_printf("%s\n", v33);
v35 = g_list_prepend(code, v34);
v25 = v5 - 24;
v8 = v4 - 3;
v26 = 4;
code = v35;
v27 = -6;
}
LABEL_28:
v28 = *v8;
*((_QWORD *)v25 + 1) = v20;
v5 = v25 + 8;
v29 = v28;
v30 = v27 + v28;
if ( v30 <= 0xD && v29 == yycheck[v30] )
v1 = (unsigned __int8)yytable[v30];
else
v1 = yydefgoto[v26];
LABEL_8:
v9 = 2 * v2;
v8[1] = v1;
v4 = v8 + 1;
if ( v8 + 1 >= &v3[v2 - 1] )
{
v10 = (char *)v4 - (char *)v3;
v11 = (v10 >> 1) + 1;
if ( v2 > 0x270F )
goto LABEL_46;
v2 = 10000LL;
if ( v9 <= 0x2710 )
v2 = v9;
v12 = (__int16 *)malloc(10 * v2 + 7);
v13 = v12;
if ( !v12 )
{
LABEL_46:
v43 = "memory exhausted";
goto LABEL_47;
}
v48 = v12;
memcpy(v12, v3, v10 + 2);
v14 = (char *)memcpy(&v13[v2], v46, 8 * v11);
v15 = 8 * v11;
v16 = v14;
if ( v3 != src )
{
v47 = v14;
free(v3);
v16 = v47;
v15 = 8 * v11;
}
v4 = (__int16 *)((char *)v13 + v10);
v5 = &v16[v15 - 8];
if ( v4 >= &v13[v2 - 1] )
{
v40 = 1;
free(v48);
goto LABEL_41;
}
v46 = v16;
v3 = v13;
}
}
while ( (_DWORD)v1 != 12 );
v40 = 0;
if ( v3 != src )
free(v3);
LABEL_41:
if ( ptr != v52 )
free(ptr);
return v40;
}

original_code:
int
yyparse (gpointer root)
{
    int yystate;
    int yyerrstatus;
    yytype_int16 yyssa[200];
    yytype_int16 *yyss;
    yytype_int16 *yyssp;
    char * yyvsa[200];
    char * *yyvs;
    char * *yyvsp;
    long unsigned int yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  char * yyval;
  char yymsgbuf[128];
  char *yymsg = yymsgbuf;
  long unsigned int yymsg_alloc = sizeof yymsgbuf;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  ;
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (yytype_int16) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      long unsigned int yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        yytype_int16 *yyss1 = yyss;
        union yyalloc *yyptr =
          (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (char *)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      ;
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  ;
  if (yystate == 12)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-6))))
    goto yydefault;
  if (yychar == (-2))
    {
      ;
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      ;
    }
  else
    {
      yytoken = ((unsigned) (yychar) <= 262 ? yytranslate[yychar] : 2);
      ;
    }
  yyn += yytoken;
  if (yyn < 0 || 13 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  ;
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 8:
    {
 static int i = 0;
 data = g_list_prepend(data, g_strdup_printf(
  "static char data%d[] = \"%s\";\n",
  i, g_strescape(yyvsp[0], "")));
 code = g_list_prepend(code, g_strdup_printf(
  "fwrite(data%d, sizeof(data%d)-1, 1, stdout);\n",
  i, i));
 i++;
}
    break;
  case 9:
    {
 code = g_list_prepend(code, g_strdup_printf("#line %d \"%s\"\n", yylineno, name));
 code = g_list_prepend(code, g_strdup_printf("%s\n", yyvsp[-1]));
}
    break;
  case 10:
    {
 code = g_list_prepend(code, g_strdup_printf("printf(\"%%s\", %s);\n", yyvsp[-1]));
}
    break;
  case 11:
    {
 code = g_list_prepend(code, g_strdup_printf("printf(%s);\n", yyvsp[-1]));
}
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  {
    const int yylhs = yyr1[yyn] - 8;
    const int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 13 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned) (yychar) <= 262 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      {
        char const *yymsgp = "syntax error";
        int yysyntax_error_status;
        yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, yyssp, yytoken);
        if (yysyntax_error_status == 0)
          yymsgp = yymsg;
        else if (yysyntax_error_status == 1)
          {
            if (yymsg != yymsgbuf)
              free (yymsg);
            yymsg = (char *) malloc (yymsg_alloc);
            if (!yymsg)
              {
                yymsg = yymsgbuf;
                yymsg_alloc = sizeof yymsgbuf;
                yysyntax_error_status = 2;
              }
            else
              {
                yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, yyssp, yytoken);
                yymsgp = yymsg;
              }
          }
        yyerror (root, yymsgp);
        if (yysyntax_error_status == 2)
          goto yyexhaustedlab;
      }
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval, root);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-6))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 13 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp, root);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  ;
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror (root, "memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned) (yychar) <= 262 ? yytranslate[yychar] : 2);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval, root);
    }
  (yyvsp -= (yylen), yyssp -= (yylen));
  ;
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp, root);
      (yyvsp -= (1), yyssp -= (1));
    }
  if (yyss != yyssa)
    free (yyss);
  if (yymsg != yymsgbuf)
    free (yymsg);
  return yyresult;
}

canonical_original_code:
int yyparse(void *root)
{
    int yystate;
    int yyerrstatus;
    short yyssa[200];
    short *yyss;
    short *yyssp;
    char *yyvsa[200];
    char **yyvs;
    char **yyvsp;
    unsigned long yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  char *yyval;
  char yymsgbuf[128];
  char *yymsg = yymsgbuf;
  unsigned long yymsg_alloc = sizeof yymsgbuf;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  ;
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (short) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      unsigned long yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        short *yyss1 = yyss;
        union yyalloc *yyptr = (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (char *)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      ;
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  ;
  if (yystate == 12)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-6))))
    goto yydefault;
  if (yychar == (-2))
    {
      ;
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      ;
    }
  else
    {
      yytoken = ((unsigned int) (yychar) <= 262 ? yytranslate[yychar] : 2);
      ;
    }
  yyn += yytoken;
  if (yyn < 0 || 13 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  ;
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 8:
    {
 static int i = 0;
 data = g_list_prepend(data, g_strdup_printf(
  "static char data%d[] = \"%s\";\n",
  i, g_strescape(yyvsp[0], "")));
 code = g_list_prepend(code, g_strdup_printf(
  "fwrite(data%d, sizeof(data%d)-1, 1, stdout);\n",
  i, i));
 i++;
}
    break;
  case 9:
    {
 code = g_list_prepend(code, g_strdup_printf("#line %d \"%s\"\n", yylineno, name));
 code = g_list_prepend(code, g_strdup_printf("%s\n", yyvsp[-1]));
}
    break;
  case 10:
    {
 code = g_list_prepend(code, g_strdup_printf("printf(\"%%s\", %s);\n", yyvsp[-1]));
}
    break;
  case 11:
    {
 code = g_list_prepend(code, g_strdup_printf("printf(%s);\n", yyvsp[-1]));
}
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  {
    int yylhs = yyr1[yyn] - 8;
    int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 13 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned int) (yychar) <= 262 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      {
        char *yymsgp = "syntax error";
        int yysyntax_error_status;
        yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, yyssp, yytoken);
        if (yysyntax_error_status == 0)
          yymsgp = yymsg;
        else if (yysyntax_error_status == 1)
          {
            if (yymsg != yymsgbuf)
              free (yymsg);
            yymsg = (char *) malloc (yymsg_alloc);
            if (!yymsg)
              {
                yymsg = yymsgbuf;
                yymsg_alloc = sizeof yymsgbuf;
                yysyntax_error_status = 2;
              }
            else
              {
                yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, yyssp, yytoken);
                yymsgp = yymsg;
              }
          }
        yyerror (root, yymsgp);
        if (yysyntax_error_status == 2)
          goto yyexhaustedlab;
      }
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval, root);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-6))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 13 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp, root);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  ;
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror (root, "memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned int) (yychar) <= 262 ? yytranslate[yychar] : 2);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval, root);
    }
  (yyvsp -= (yylen), yyssp -= (yylen));
  ;
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp, root);
      (yyvsp -= (1), yyssp -= (1));
    }
  if (yyss != yyssa)
    free (yyss);
  if (yymsg != yymsgbuf)
    free (yymsg);
  return yyresult;
}

variable_types: yystate int

variable_types: yyerrstatus int

variable_types:
yyssa
short [200]

variable_types:
yyss
short *

variable_types:
yyvsa
char *[200]

variable_types:
yyvs
char **

variable_types:
yyvsp
char **

variable_types:
yystacksize
unsigned long

variable_types: yyresult int

variable_types:
yyval
char *

variable_types:
yymsgbuf
char [128]

variable_types:
yymsg
char *

variable_types: yylen int

variable_types: union yyalloc { short yyss_alloc; char *yyvs_alloc; } *

variable_types:
yynewbytes
unsigned long

variable_types: i int

variable_types: yylhs int

variable_types:
yymsgp
char *


original_code:
static void do_tile(row_t *rows, int row, int col)
{
 tile_t *t = &rows[row].cols[col];
 switch (t->c) {
 case '-': t->top = LEFT | RIGHT; break;
 case '|': t->top = UP | DOWN; break;
 case '\'': t->top = UP; break;
 case '.': t->top = DOWN; break;
 }
 if (col > 0) {
  tile_t *l = &rows[row].cols[col-1];
  if (t->c == '|' && (l->top | l->bot) & RIGHT)
   t->bot = LEFT | RIGHT;
 }
 if (row > 0 && rows[row-1].ncols > col) {
  tile_t *u = &rows[row-1].cols[col];
  if (t->c == '-' && (u->top | u->bot) & DOWN)
   t->bot = UP | DOWN;
 }
 if (t->c == '.' || t->c == '\'') {
  tile_t *l = &rows[row].cols[col-1];
  if (col > 0 && (l->top | l->bot) & RIGHT)
   t->top |= LEFT;
  else
   t->top |= RIGHT;
 }
}

canonical_original_code:
static void do_tile(struct row_t *rows, int row, int col)
{
 struct tile_t *t = &rows[row].cols[col];
 switch (t->c) {
 case '-': t->top = LEFT | RIGHT; break;
 case '|': t->top = UP | DOWN; break;
 case '\'': t->top = UP; break;
 case '.': t->top = DOWN; break;
 }
 if (col > 0) {
  struct tile_t *l = &rows[row].cols[col-1];
  if (t->c == '|' && (l->top | l->bot) & RIGHT)
   t->bot = LEFT | RIGHT;
 }
 if (row > 0 && rows[row-1].ncols > col) {
  struct tile_t *u = &rows[row-1].cols[col];
  if (t->c == '-' && (u->top | u->bot) & DOWN)
   t->bot = UP | DOWN;
 }
 if (t->c == '.' || t->c == '\'') {
  struct tile_t *l = &rows[row].cols[col-1];
  if (col > 0 && (l->top | l->bot) & RIGHT)
   t->top |= LEFT;
  else
   t->top |= RIGHT;
 }
}

variable_types: struct row_t { struct tile_t { char c; int top; int bot; } *cols; int ncols; } *

variable_types: row int

variable_types: col int

user_defined_types: struct row_t { struct tile_t *cols; int ncols; }


main

original_code:
int main()
{
 char c;
 int row = 0, col = 0;
 row_t *rows = calloc(sizeof(row_t), (row+2));
 while ((c = getchar()) != (-1)) {
  if (c == '\n') {
   row++;
   col = 0;
   rows = realloc(rows, sizeof(row_t) * (row+2));
   rows[row+0] = (row_t){.ncols = 0};
   rows[row+1] = (row_t){.ncols = -1};
  } else {
   rows[row].cols = realloc(rows[row].cols, sizeof(tile_t) * (col+1));
   rows[row].ncols = col+1;
   rows[row].cols[col] = (tile_t){.c = c};
   do_tile(rows, row, col);
   col++;
  }
 }
 if (0)
 for (row = 0; rows[row].ncols >= 0; row++) {
  for (col = 0; col > rows[row].ncols; col++) {
   print_ptrn(rows[row].cols[col].top);
   print_ptrn(rows[row].cols[col].bot);
   printf(" ");
  }
  printf("\n");
 }
 print_index(rows);
 for (int row = 0; rows[row].ncols >= 0; row++)
  if (rows[row].cols > 0)
   free(rows[row].cols);
 free(rows);
 return 0;
}

canonical_original_code:
int main()
{
 char c;
 int row = 0; int col = 0;
 struct row_t *rows = calloc(sizeof(row_t), (row+2));
 while ((c = getchar()) != (-1)) {
  if (c == '\n') {
   row++;
   col = 0;
   rows = realloc(rows, sizeof(row_t) * (row+2));
   rows[row+0] = (struct row_t){.ncols = 0};
   rows[row+1] = (struct row_t){.ncols = -1};
  } else {
   rows[row].cols = realloc(rows[row].cols, sizeof(tile_t) * (col+1));
   rows[row].ncols = col+1;
   rows[row].cols[col] = (struct tile_t){.c = c};
   do_tile(rows, row, col);
   col++;
  }
 }
 if (0)
 for (row = 0; rows[row].ncols >= 0; row++) {
  for (col = 0; col > rows[row].ncols; col++) {
   print_ptrn(rows[row].cols[col].top);
   print_ptrn(rows[row].cols[col].bot);
   printf(" ");
  }
  printf("\n");
 }
 print_index(rows);
 for (int row = 0; rows[row].ncols >= 0; row++)
  if (rows[row].cols > 0)
   free(rows[row].cols);
 free(rows);
 return 0;
}

variable_types: c char

user_defined_types: struct tile_t { char c; int top; int bot; }


decompiled_code:
int __fastcall print_month(unsigned int a1, int a2, int a3)
{
int v3; // er15
__int64 v5; // rbx
const char *v6; // r14
char v7; // r13
size_t v8; // rax
const char *v9; // r8
unsigned int v10; // er14
__int64 v11; // rdi
const char *v12; // rax
int result; // eax
unsigned int v14; // er14
int v15; // er13
int v16; // er12
int v17; // eax
unsigned int v18; // er9
int v19; // [rsp+8h] [rbp-50h]
unsigned int v20; // [rsp+Ch] [rbp-4Ch]
int v21; // [rsp+10h] [rbp-48h]
int v22; // [rsp+18h] [rbp-40h]

v3 = a3;
v5 = EVENTS;
v6 = (const char *)month_to_string();
v21 = start_of_month(SEL[0], a1);
v7 = days_in_month(SEL[0], a1);
v8 = strlen(v6);
v9 = v6;
v10 = 0;
mvwprintw(win, a2, v3 + 10 - (v8 >> 1), "%s", v9);
wmove(win, a2 + 1, v3);
do
{
v11 = v10++;
v12 = (const char *)day_to_st(v11);
wprintw(win, "%-3s", v12);
}
while ( v10 != 7 );
result = v7;
v14 = 0;
v22 = v7;
if ( v7 > 0 )
{
while ( 1 )
{
v15 = (int)(v14 + v21) / 7;
v19 = (int)(v14 + v21) % 7;
if ( !v5 )
break;
v16 = 0;
do
{
if ( !(unsigned int)before(v5 + 32, SEL[0], a1, v14, 24LL, 0LL) )
break;
v17 = before(v5 + 32, SEL[0], a1, v14, 0LL, 0LL);
v5 = *(_QWORD *)(v5 + 88);
if ( !v17 )
v16 = 1;
}
while ( v5 );
if ( SEL[1] == a1 && SEL[2] == v14 )
{
v18 = v16 == 0 ? 1310720 : 2490368;
goto LABEL_12;
}
v18 = 2228224;
if ( !v16 )
goto LABEL_15;
LABEL_12:
++v14;
v20 = v18;
wattr_on(win, v18, 0LL);
mvwprintw(win, a2 + 2 + v15, a3 + 3 * v19, "%2d", v14);
result = wattr_off(win, v20, 0LL);
if ( v14 == v22 )
return result;
}
if ( SEL[1] == a1 )
{
v18 = 1310720;
if ( SEL[2] == v14 )
goto LABEL_12;
}
LABEL_15:
v18 = 0x100000;
goto LABEL_12;
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(unsigned int a1, int a2, int a3)
{
int v3; // er15
__int64 v5; // rbx
const char *v6; // r14
char v7; // r13
size_t v8; // rax
const char *v9; // r8
unsigned int v10; // er14
__int64 v11; // rdi
const char *v12; // rax
int result; // eax
unsigned int v14; // er14
int v15; // er13
int v16; // er12
int v17; // eax
unsigned int v18; // er9
int v19; // [rsp+8h] [rbp-50h]
unsigned int v20; // [rsp+Ch] [rbp-4Ch]
int v21; // [rsp+10h] [rbp-48h]
int v22; // [rsp+18h] [rbp-40h]

v3 = a3;
v5 = EVENTS;
v6 = (const char *)month_to_string();
v21 = start_of_month(SEL[0], a1);
v7 = days_in_month(SEL[0], a1);
v8 = strlen(v6);
v9 = v6;
v10 = 0;
mvwprintw(win, a2, v3 + 10 - (v8 >> 1), "%s", v9);
wmove(win, a2 + 1, v3);
do
{
v11 = v10++;
v12 = (const char *)day_to_st(v11);
wprintw(win, "%-3s", v12);
}
while ( v10 != 7 );
result = v7;
v14 = 0;
v22 = v7;
if ( v7 > 0 )
{
while ( 1 )
{
v15 = (int)(v14 + v21) / 7;
v19 = (int)(v14 + v21) % 7;
if ( !v5 )
break;
v16 = 0;
do
{
if ( !(unsigned int)before(v5 + 32, SEL[0], a1, v14, 24LL, 0LL) )
break;
v17 = before(v5 + 32, SEL[0], a1, v14, 0LL, 0LL);
v5 = *(_QWORD *)(v5 + 88);
if ( !v17 )
v16 = 1;
}
while ( v5 );
if ( SEL[1] == a1 && SEL[2] == v14 )
{
v18 = v16 == 0 ? 1310720 : 2490368;
goto LABEL_12;
}
v18 = 2228224;
if ( !v16 )
goto LABEL_15;
LABEL_12:
++v14;
v20 = v18;
wattr_on(win, v18, 0LL);
mvwprintw(win, a2 + 2 + v15, a3 + 3 * v19, "%2d", v14);
result = wattr_off(win, v20, 0LL);
if ( v14 == v22 )
return result;
}
if ( SEL[1] == a1 )
{
v18 = 1310720;
if ( SEL[2] == v14 )
goto LABEL_12;
}
LABEL_15:
v18 = 0x100000;
goto LABEL_12;
}
return result;
}

original_code:
static void print_month(month_t month, int y, int x)
{
 event_t *event = EVENTS;
 const char *name = month_to_string(month);
 const int start = start_of_month(SEL.year, month);
 const char days = days_in_month(SEL.year, month);
 mvwprintw(win, y, x+(2*7+6)/2-strlen(name)/2, "%s", name);
 wmove(win, y+1, x);
 for (int d = 0; d < 7; d++)
  wprintw(win, "%-3s", day_to_st(d));
 for (int d = 0; d < days; d++) {
  int row = (start + d) / 7;
  int col = (start + d) % 7;
  int busy = 0;
  while (event && before(&event->start, SEL.year, month, d, 24, 0)) {
   if (!before(&event->start, SEL.year, month, d, 0, 0))
    busy = 1;
   event = event->next;
  }
  int today = month == SEL.month && d == SEL.day;
  int attr = (busy ? ((chtype)((1U)) << ((13) + 8))|((chtype)((1U)) << ((9) + 8)) : ((chtype)((1U)) << ((12) + 8)))
            | (today ? ((chtype)((1U)) << ((10) + 8)) : 0 );
  wattr_on(win, (attr_t)(attr), ((void *)0));
  mvwprintw(win, y+2+row, x+col*3, "%2d", d+1);
  wattr_off(win, (attr_t)(attr), ((void *)0));
 }
}

canonical_original_code:
static void print_month(enum month_t month, int y, int x)
{
 struct event_t *event = EVENTS;
 char *name = month_to_string(month);
 int start = start_of_month(SEL.year, month);
 char days = days_in_month(SEL.year, month);
 mvwprintw(win, y, x+(2*7+6)/2-strlen(name)/2, "%s", name);
 wmove(win, y+1, x);
 for (int d = 0; d < 7; d++)
  wprintw(win, "%-3s", day_to_st(d));
 for (int d = 0; d < days; d++) {
  int row = (start + d) / 7;
  int col = (start + d) % 7;
  int busy = 0;
  while (event && before(&event->start, SEL.year, month, d, 24, 0)) {
   if (!before(&event->start, SEL.year, month, d, 0, 0))
    busy = 1;
   event = event->next;
  }
  int today = month == SEL.month && d == SEL.day;
  int attr = (busy ? ((chtype)((1U)) << ((13) + 8))|((chtype)((1U)) << ((9) + 8)) : ((chtype)((1U)) << ((12) + 8)))
            | (today ? ((chtype)((1U)) << ((10) + 8)) : 0 );
  wattr_on(win, (attr_t)(attr), ((void *)0));
  mvwprintw(win, y+2+row, x+col*3, "%2d", d+1);
  wattr_off(win, (attr_t)(attr), ((void *)0));
 }
}

variable_types: y int

variable_types: x int

variable_types: struct event_t { char *name; char *desc; char *loc; char *cat; struct date_t { int year; enum month_t { JAN=0, FEB=1, MAR=2, APR=3, MAY=4, JUN=5, JUL=6, AUG=7, SEP=8, OCT=9, NOV=10, DEC=11 } month; int day; int hour; int min; int sec; } start; struct date_t end; struct cal_t { char *type; char *name; char *desc; struct cal_t *next; } *cal; struct event_t *next; struct event_t *prev; } *

variable_types:
name
char *

variable_types: start int

variable_types: days char

variable_types: d int

variable_types: busy int

variable_types: today int

variable_types: attr int

user_defined_types: struct event_t { char *name; char *desc; char *loc; char *cat; struct date_t start; struct date_t end; struct cal_t *cal; struct event_t *next; struct event_t *prev; }

user_defined_types: struct date_t { int year; enum month_t month; int day; int hour; int min; int sec; }


decompiled_code:
void year_size()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
void year_size(int rows, int cols)
{
}

canonical_original_code:
void year_size(int rows, int cols)
{
}

variable_types: rows int

variable_types: cols int


variable_types: w int

variable_types:
h
int [4]

variable_types: m int

variable_types: weeks int

variable_types: sum int

variable_types: i int


decompiled_code:
__int64 __fastcall year_run(int a1)
{
unsigned int v1; // esi
unsigned int v2; // eax
int v3; // eax
int v4; // edx
unsigned int v6; // er15
unsigned int v7; // ebp
int v8; // ebx
unsigned int v9; // eax
int v10; // ebx
int v11; // eax
unsigned int v12; // ecx
int v13; // [rsp+0h] [rbp-58h]
int v14; // [rsp+4h] [rbp-54h]
unsigned int v15; // [rsp+8h] [rbp-50h]
bool v16; // [rsp+Fh] [rbp-49h]
unsigned int v17; // [rsp+14h] [rbp-44h] BYREF
unsigned int v18; // [rsp+18h] [rbp-40h] BYREF
int v19[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

v1 = SEL[1];
v17 = SEL[2];
v18 = v1;
v19[0] = SEL[0];
v13 = ((__int64 (*)(void))day_of_week)();
v14 = start_of_month((unsigned int)v19[0], v1);
v15 = v17;
v2 = a1 - 106;
if ( a1 == 105 )
{
--SEL[0];
}
else if ( a1 == 111 )
{
++SEL[0];
if ( v2 > 1 )
{
LABEL_4:
v3 = v19[0];
if ( SEL[0] != v19[0] )
{
werase(win);
year_draw();
wrefresh(win);
v3 = SEL[0];
}
v4 = v19[0];
return v3 != v4;
}
v16 = 0;
v6 = 0;
goto LABEL_30;
}
v16 = (a1 & 0xFFFFFFFB) == 104;
if ( (v2 & 0xFFFFFFFD) == 0 )
{
if ( a1 == 108 )
{
v6 = 1;
LABEL_20:
v10 = 90;
while ( 1 )
{
add_days(v19, &v18, &v17, v6);
v11 = start_of_month((unsigned int)v19[0], v18);
v12 = v17;
if ( (v14 + v15) / 7 == (v11 + v17) / 7 )
{
v3 = SEL[0];
v4 = v19[0];
if ( SEL[0] == v19[0] && v18 / 3 == SEL[1] / 3 )
break;
}
if ( !--v10 )
goto LABEL_27;
}
SEL[1] = v18;
SEL[2] = v12;
if ( !v6 )
return v3 != v4;
goto LABEL_26;
}
v7 = 7;
v6 = 1;
goto LABEL_13;
}
v6 = -(a1 == 104 || a1 == 107);
if ( a1 != 107 )
goto LABEL_19;
LABEL_30:
v7 = 7 * v6;
LABEL_13:
v8 = 12;
while ( 1 )
{
add_days(v19, &v18, &v17, v7);
if ( (unsigned int)day_of_week((unsigned int)v19[0], v18, v17) == v13 && SEL[0] == v19[0] && v18 % 3 == SEL[1] % 3 )
break;
if ( !--v8 )
goto LABEL_19;
}
v9 = v17;
SEL[1] = v18;
SEL[2] = v9;
LABEL_19:
if ( v16 )
goto LABEL_20;
LABEL_27:
if ( !v6 )
goto LABEL_4;
LABEL_26:
werase(win);
year_draw();
wrefresh(win);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
unsigned int v1; // esi
unsigned int v2; // eax
int v3; // eax
int v4; // edx
unsigned int v6; // er15
unsigned int v7; // ebp
int v8; // ebx
unsigned int v9; // eax
int v10; // ebx
int v11; // eax
unsigned int v12; // ecx
int v13; // [rsp+0h] [rbp-58h]
int v14; // [rsp+4h] [rbp-54h]
unsigned int v15; // [rsp+8h] [rbp-50h]
bool v16; // [rsp+Fh] [rbp-49h]
unsigned int v17; // [rsp+14h] [rbp-44h] BYREF
unsigned int v18; // [rsp+18h] [rbp-40h] BYREF
int v19[15]; // [rsp+1Ch] [rbp-3Ch] BYREF

v1 = SEL[1];
v17 = SEL[2];
v18 = v1;
v19[0] = SEL[0];
v13 = ((__int64 (*)(void))day_of_week)();
v14 = start_of_month((unsigned int)v19[0], v1);
v15 = v17;
v2 = a1 - 106;
if ( a1 == 105 )
{
--SEL[0];
}
else if ( a1 == 111 )
{
++SEL[0];
if ( v2 > 1 )
{
LABEL_4:
v3 = v19[0];
if ( SEL[0] != v19[0] )
{
werase(win);
func3();
wrefresh(win);
v3 = SEL[0];
}
v4 = v19[0];
return v3 != v4;
}
v16 = 0;
v6 = 0;
goto LABEL_30;
}
v16 = (a1 & 0xFFFFFFFB) == 104;
if ( (v2 & 0xFFFFFFFD) == 0 )
{
if ( a1 == 108 )
{
v6 = 1;
LABEL_20:
v10 = 90;
while ( 1 )
{
add_days(v19, &v18, &v17, v6);
v11 = start_of_month((unsigned int)v19[0], v18);
v12 = v17;
if ( (v14 + v15) / 7 == (v11 + v17) / 7 )
{
v3 = SEL[0];
v4 = v19[0];
if ( SEL[0] == v19[0] && v18 / 3 == SEL[1] / 3 )
break;
}
if ( !--v10 )
goto LABEL_27;
}
SEL[1] = v18;
SEL[2] = v12;
if ( !v6 )
return v3 != v4;
goto LABEL_26;
}
v7 = 7;
v6 = 1;
goto LABEL_13;
}
v6 = -(a1 == 104 || a1 == 107);
if ( a1 != 107 )
goto LABEL_19;
LABEL_30:
v7 = 7 * v6;
LABEL_13:
v8 = 12;
while ( 1 )
{
add_days(v19, &v18, &v17, v7);
if ( (unsigned int)day_of_week((unsigned int)v19[0], v18, v17) == v13 && SEL[0] == v19[0] && v18 % 3 == SEL[1] % 3 )
break;
if ( !--v8 )
goto LABEL_19;
}
v9 = v17;
SEL[1] = v18;
SEL[2] = v9;
LABEL_19:
if ( v16 )
goto LABEL_20;
LABEL_27:
if ( !v6 )
goto LABEL_4;
LABEL_26:
werase(win);
func3();
wrefresh(win);
return 1LL;
}

original_code:
int year_run(int key, mmask_t btn, int row, int col)
{
 day_t d = SEL.day;
 month_t m = SEL.month;
 year_t y = SEL.year;
 wday_t day = day_of_week(SEL.year, SEL.month, SEL.day);
 int week = (start_of_month(y, m) + d) / 7;
 int dir = 0;
 if (key == 'i')
  SEL.year--;
 if (key == 'o')
  SEL.year++;
 if (key == 'h' || key == 'k')
  dir = -1;
 if (key == 'j' || key == 'l')
  dir = 1;
 if (key == 'j' || key == 'k') {
  for (int i = 0; i < 90/7; i++) {
   add_days(&y, &m, &d, dir*7);
   if (day_of_week(y, m, d) == day &&
       y == SEL.year && m%3 == SEL.month%3) {
    SEL.month = m;
    SEL.day = d;
    break;
   }
  }
 }
 if (key == 'h' || key == 'l') {
  for (int i = 0; i < 90; i++) {
   add_days(&y, &m, &d, dir);
   if ((start_of_month(y, m) + d) / 7 == week &&
       y == SEL.year && m/3 == SEL.month/3) {
    SEL.month = m;
    SEL.day = d;
    break;
   }
  }
 }
 if (dir || y != SEL.year) {
  werase(win);
  year_draw();
  wrefresh(win);
 }
 return dir || y != SEL.year;
}

canonical_original_code:
int year_run(int key, unsigned int btn, int row, int col)
{
 int d = SEL.day;
 enum month_t m = SEL.month;
 int y = SEL.year;
 enum wday_t day = day_of_week(SEL.year, SEL.month, SEL.day);
 int week = (start_of_month(y, m) + d) / 7;
 int dir = 0;
 if (key == 'i')
  SEL.year--;
 if (key == 'o')
  SEL.year++;
 if (key == 'h' || key == 'k')
  dir = -1;
 if (key == 'j' || key == 'l')
  dir = 1;
 if (key == 'j' || key == 'k') {
  for (int i = 0; i < 90/7; i++) {
   add_days(&y, &m, &d, dir*7);
   if (day_of_week(y, m, d) == day &&
       y == SEL.year && m%3 == SEL.month%3) {
    SEL.month = m;
    SEL.day = d;
    break;
   }
  }
 }
 if (key == 'h' || key == 'l') {
  for (int i = 0; i < 90; i++) {
   add_days(&y, &m, &d, dir);
   if ((start_of_month(y, m) + d) / 7 == week &&
       y == SEL.year && m/3 == SEL.month/3) {
    SEL.month = m;
    SEL.day = d;
    break;
   }
  }
 }
 if (dir || y != SEL.year) {
  werase(win);
  year_draw();
  wrefresh(win);
 }
 return dir || y != SEL.year;
}

variable_types: key int

variable_types:
btn
unsigned int

variable_types: row int

variable_types: col int

variable_types: enum month_t { JAN=0, FEB=1, MAR=2, APR=3, MAY=4, JUN=5, JUL=6, AUG=7, SEP=8, OCT=9, NOV=10, DEC=11 }

variable_types: y int

variable_types: enum wday_t { SUN=0, MON=1, TUE=2, WED=3, THU=4, FRI=5, SAT=6 }

variable_types: week int

variable_types: dir int


decompiled_code:
__int64 __fastcall add_event(_QWORD *a1, __int64 a2, __int64 *a3)
{
__int64 v3; // rcx
__int64 v4; // rax
__int64 result; // rax

v3 = *a3;
if ( *(_QWORD *)a2 )
*(_QWORD *)(*(_QWORD *)a2 + 88LL) = v3;
else
*a1 = v3;
*(_QWORD *)(*a3 + 96) = *(_QWORD *)a2;
v4 = *a3;
*(_QWORD *)a2 = *a3;
result = *(_QWORD *)(v4 + 88);
*a3 = result;
return result;
}

original_code:
static void add_event(event_t **first, event_t **last, event_t **next)
{
 if (*last)
  (*last)->next = *next;
 else
  (*first) = *next;
 (*next)->prev = *last;
 (*last) = (*next);
 (*next) = (*next)->next;
}

canonical_original_code:
static void add_event(struct event_t **first, struct event_t **last, struct event_t **next)
{
 if (*last)
  (*last)->next = *next;
 else
  (*first) = *next;
 (*next)->prev = *last;
 (*last) = (*next);
 (*next) = (*next)->next;
}

variable_types: struct event_t { char *name; char *desc; char *loc; char *cat; struct date_t { int year; enum month_t { JAN=0, FEB=1, MAR=2, APR=3, MAY=4, JUN=5, JUL=6, AUG=7, SEP=8, OCT=9, NOV=10, DEC=11 } month; int day; int hour; int min; int sec; } start; struct date_t end; struct cal_t { char *type; char *name; char *desc; struct cal_t *next; } *cal; struct event_t *next; struct event_t *prev; } **

variable_types:
last
struct event_t **

variable_types:
next
struct event_t **


decompiled_code:
__int64 __fastcall add_todo(_QWORD *a1, __int64 a2, __int64 *a3)
{
__int64 v3; // rcx
__int64 v4; // rax
__int64 result; // rax

v3 = *a3;
if ( *(_QWORD *)a2 )
*(_QWORD *)(*(_QWORD *)a2 + 88LL) = v3;
else
*a1 = v3;
*(_QWORD *)(*a3 + 96) = *(_QWORD *)a2;
v4 = *a3;
*(_QWORD *)a2 = *a3;
result = *(_QWORD *)(v4 + 88);
*a3 = result;
return result;
}

original_code:
static void add_todo(todo_t **first, todo_t **last, todo_t **next)
{
 if (*last)
  (*last)->next = *next;
 else
  (*first) = *next;
 (*next)->prev = *last;
 (*last) = (*next);
 (*next) = (*next)->next;
}

canonical_original_code:
static void add_todo(struct todo_t **first, struct todo_t **last, struct todo_t **next)
{
 if (*last)
  (*last)->next = *next;
 else
  (*first) = *next;
 (*next)->prev = *last;
 (*last) = (*next);
 (*next) = (*next)->next;
}

variable_types: struct todo_t { char *name; char *desc; char *cat; enum status_t { NEW=0, DONE=100 } status; struct date_t { int year; enum month_t { JAN=0, FEB=1, MAR=2, APR=3, MAY=4, JUN=5, JUL=6, AUG=7, SEP=8, OCT=9, NOV=10, DEC=11 } month; int day; int hour; int min; int sec; } start; struct date_t due; struct cal_t { char *type; char *name; char *desc; struct cal_t *next; } *cal; struct todo_t *next; struct todo_t *prev; } **

variable_types:
last
struct todo_t **

variable_types:
next
struct todo_t **

user_defined_types: struct todo_t { char *name; char *desc; char *cat; enum status_t status; struct date_t start; struct date_t due; struct cal_t *cal; struct todo_t *next; struct todo_t *prev; }


decompiled_code:
__int64 __fastcall merge_cals(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rdx

if ( !a1 )
return a2;
result = a1;
if ( a2 )
{
do
{
v3 = result;
result = *(_QWORD *)(result + 24);
}
while ( result );
*(_QWORD *)(v3 + 24) = a2;
result = a1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rdx

if ( !a1 )
return a2;
result = a1;
if ( a2 )
{
do
{
v3 = result;
result = *(_QWORD *)(result + 24);
}
while ( result );
*(_QWORD *)(v3 + 24) = a2;
result = a1;
}
return result;
}

original_code:
static cal_t *merge_cals(cal_t *a, cal_t *b)
{
 if (!a) return b;
 if (!b) return a;
 cal_t *last = a;
 while (last->next)
  last = last->next;
 last->next = b;
 return a;
}

canonical_original_code:
static struct cal_t *merge_cals(struct cal_t *a, struct cal_t *b)
{
 if (!a) return b;
 if (!b) return a;
 struct cal_t *last = a;
 while (last->next)
  last = last->next;
 last->next = b;
 return a;
}

variable_types:
a
struct cal_t *

variable_types:
b
struct cal_t *

variable_types: struct cal_t { char *type; char *name; char *desc; struct cal_t *next; } *


original_code:
static event_t *merge_events(event_t *a, event_t *b)
{
 event_t *first = ((void *)0), *last = ((void *)0);
 while (a && b)
  if (compare(&a->start, &b->start) <= 0)
   add_event(&first, &last, &a);
  else
   add_event(&first, &last, &b);
 while (a) add_event(&first, &last, &a);
 while (b) add_event(&first, &last, &b);
 return first;
}

canonical_original_code:
static struct event_t *merge_events(struct event_t *a, struct event_t *b)
{
 struct event_t *first = ((void *)0); struct event_t *last = ((void *)0);
 while (a && b)
  if (compare(&a->start, &b->start) <= 0)
   add_event(&first, &last, &a);
  else
   add_event(&first, &last, &b);
 while (a) add_event(&first, &last, &a);
 while (b) add_event(&first, &last, &b);
 return first;
}

variable_types:
a
struct event_t *

variable_types:
b
struct event_t *

variable_types: struct event_t { char *name; char *desc; char *loc; char *cat; struct date_t { int year; enum month_t { JAN=0, FEB=1, MAR=2, APR=3, MAY=4, JUN=5, JUL=6, AUG=7, SEP=8, OCT=9, NOV=10, DEC=11 } month; int day; int hour; int min; int sec; } start; struct date_t end; struct cal_t { char *type; char *name; char *desc; struct cal_t *next; } *cal; struct event_t *next; struct event_t *prev; } *


original_code:
static todo_t *merge_todos(todo_t *a, todo_t *b)
{
 todo_t *first = ((void *)0), *last = ((void *)0);
 while (a && b)
  if (compare(&a->start, &b->start) <= 0)
   add_todo(&first, &last, &a);
  else
   add_todo(&first, &last, &b);
 while (a) add_todo(&first, &last, &a);
 while (b) add_todo(&first, &last, &b);
 return first;
}

canonical_original_code:
static struct todo_t *merge_todos(struct todo_t *a, struct todo_t *b)
{
 struct todo_t *first = ((void *)0); struct todo_t *last = ((void *)0);
 while (a && b)
  if (compare(&a->start, &b->start) <= 0)
   add_todo(&first, &last, &a);
  else
   add_todo(&first, &last, &b);
 while (a) add_todo(&first, &last, &a);
 while (b) add_todo(&first, &last, &b);
 return first;
}

variable_types:
a
struct todo_t *

variable_types:
b
struct todo_t *

variable_types: struct todo_t { char *name; char *desc; char *cat; enum status_t { NEW=0, DONE=100 } status; struct date_t { int year; enum month_t { JAN=0, FEB=1, MAR=2, APR=3, MAY=4, JUN=5, JUL=6, AUG=7, SEP=8, OCT=9, NOV=10, DEC=11 } month; int day; int hour; int min; int sec; } start; struct date_t due; struct cal_t { char *type; char *name; char *desc; struct cal_t *next; } *cal; struct todo_t *next; struct todo_t *prev; } *


decompiled_code:
void *cal_init()
{
__int64 v0; // rbp
__int64 v1; // rax
__int64 v2; // rax
int v3; // edx
unsigned int v4; // esi

v0 = ical_cals();
v1 = dummy_cals();
v2 = merge_cals(v1, v0);
v3 = SEL[2];
v4 = SEL[1];
CALS = v2;
return cal_load(SEL[0], v4, v3);
}

canonical_decompiled_code:
void *func6()
{
__int64 v0; // rbp
__int64 v1; // rax
__int64 v2; // rax
int v3; // edx
unsigned int v4; // esi

v0 = ical_cals();
v1 = dummy_cals();
v2 = func2(v1, v0);
v3 = SEL[2];
v4 = SEL[1];
CALS = v2;
return func5(SEL[0], v4, v3);
}

original_code:
void cal_init(void)
{
 CALS = merge_cals(
  dummy_cals(),
   ical_cals());
 cal_load(SEL.year, SEL.month, SEL.day, 1);
}

canonical_original_code:
void cal_init()
{
 CALS = merge_cals(
  dummy_cals(),
   ical_cals());
 cal_load(SEL.year, SEL.month, SEL.day, 1);
}


decompiled_code:
__int64 __fastcall cal_config(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

if ( (unsigned int)match(a1, "dummy") )
return dummy_config(a1, a2, a3, a4);
result = match(a1, "ical");
if ( (_DWORD)result )
result = ical_config(a1, a2, a3, a4);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

if ( (unsigned int)match(a1, "dummy") )
return dummy_config(a1, a2, a3, a4);
result = match(a1, "ical");
if ( (_DWORD)result )
result = ical_config(a1, a2, a3, a4);
return result;
}

original_code:
void cal_config(const char *group, const char *name, const char *key, const char *value)
{
 if (match(group, "dummy"))
  dummy_config(group, name, key, value);
 else if (match(group, "ical"))
  ical_config(group, name, key, value);
}

canonical_original_code:
void cal_config(char *group, char *name, char *key, char *value)
{
 if (match(group, "dummy"))
  dummy_config(group, name, key, value);
 else if (match(group, "ical"))
  ical_config(group, name, key, value);
}

variable_types:
group
char *

variable_types:
name
char *

variable_types:
key
char *

variable_types:
value
char *


original_code:
event_t *find_event(date_t *target)
{
 int min = 0;
 event_t *event = ((void *)0);
 if (EVENT && compare(&EVENT->start, target) == 0)
  return EVENT;
 for (event_t *cur = EVENTS; cur; cur = cur->next) {
  if ((target->year != cur->start.year) ||
      (target->month != cur->start.month) ||
      (target->day != cur->start.day))
       continue;
  int diff = (target->hour - cur->start.hour) * 60 * 24 +
      (target->min - cur->start.min) * 60 +
      (target->sec - cur->start.sec);
  if (event == ((void *)0) || ((diff) > 0 ? (diff) : -(diff)) < min) {
   min = ((diff) > 0 ? (diff) : -(diff));
   event = cur;
  }
 }
 return event;
}

canonical_original_code:
struct event_t *find_event(struct date_t *target)
{
 int min = 0;
 struct event_t *event = ((void *)0);
 if (EVENT && compare(&EVENT->start, target) == 0)
  return EVENT;
 for (struct event_t *cur = EVENTS; cur; cur = cur->next) {
  if ((target->year != cur->start.year) ||
      (target->month != cur->start.month) ||
      (target->day != cur->start.day))
       continue;
  int diff = (target->hour - cur->start.hour) * 60 * 24 +
      (target->min - cur->start.min) * 60 +
      (target->sec - cur->start.sec);
  if (event == ((void *)0) || ((diff) > 0 ? (diff) : -(diff)) < min) {
   min = ((diff) > 0 ? (diff) : -(diff));
   event = cur;
  }
 }
 return event;
}

variable_types:
target
struct date_t *

variable_types: min int

variable_types: diff int

return_type: struct event_t { char *name; char *desc; char *loc; char *cat; struct date_t { int year; enum month_t { JAN=0, FEB=1, MAR=2, APR=3, MAY=4, JUN=5, JUL=6, AUG=7, SEP=8, OCT=9, NOV=10, DEC=11 } month; int day; int hour; int min; int sec; } start; struct date_t end; struct cal_t { char *type; char *name; char *desc; struct cal_t *next; } *cal; struct event_t *next; struct event_t *prev; } *


decompiled_code:
__int64 __fastcall dummy_config(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

result = match(a1, "dummy");
if ( (_DWORD)result )
{
result = match(a3, "enable");
if ( (_DWORD)result )
{
result = get_bool(a4);
enable = result;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
__int64 result; // rax

result = match(a1, "dummy");
if ( (_DWORD)result )
{
result = match(a3, "enable");
if ( (_DWORD)result )
{
result = get_bool(a4);
enable = result;
}
}
return result;
}

original_code:
void dummy_config(const char *group, const char *name, const char *key, const char *value)
{
 if (match(group, "dummy") && match(key, "enable"))
  enable = get_bool(value);
}

canonical_original_code:
void dummy_config(char *group, char *name, char *key, char *value)
{
 if (match(group, "dummy") && match(key, "enable"))
  enable = get_bool(value);
}


decompiled_code:
char **dummy_cals()
{
return cal;
}

canonical_decompiled_code:
char **func1()
{
return cal;
}

original_code:
cal_t *dummy_cals(void)
{
 return &cal;
}

canonical_original_code:
struct cal_t *dummy_cals()
{
 return &cal;
}

return_type: struct cal_t { char *type; char *name; char *desc; struct cal_t *next; } *


original_code:
event_t *dummy_events(date_t start, date_t end)
{
 event_t *last = &event;
 for (int i = 0; i < 8; i++) {
  last->next = alloc0(sizeof(event_t));
  last->next->cal = event.cal;
  last->next->start = event.start;
  last->next->end = event.end;
  last->next->name = strcopy(event.name);
  last->next->desc = strcopy(event.desc);
  date_t *s = &last->next->start;
  date_t *e = &last->next->end;
  add_days(&s->year, &s->month, &s->day, 7*i);
  add_days(&e->year, &e->month, &e->day, 7*i);
  last = last->next;
  last->next = ((void *)0);
 }
 return enable ? event.next : 0;
}

canonical_original_code:
struct event_t *dummy_events(struct date_t start, struct date_t end)
{
 struct event_t *last = &event;
 for (int i = 0; i < 8; i++) {
  last->next = alloc0(sizeof(event_t));
  last->next->cal = event.cal;
  last->next->start = event.start;
  last->next->end = event.end;
  last->next->name = strcopy(event.name);
  last->next->desc = strcopy(event.desc);
  struct date_t *s = &last->next->start;
  struct date_t *e = &last->next->end;
  add_days(&s->year, &s->month, &s->day, 7*i);
  add_days(&e->year, &e->month, &e->day, 7*i);
  last = last->next;
  last->next = ((void *)0);
 }
 return enable ? event.next : 0;
}

variable_types:
start
struct date_t

variable_types:
end
struct date_t

variable_types: i int

variable_types: struct date_t { int year; enum month_t { JAN=0, FEB=1, MAR=2, APR=3, MAY=4, JUN=5, JUL=6, AUG=7, SEP=8, OCT=9, NOV=10, DEC=11 } month; int day; int hour; int min; int sec; } *

user_defined_types: struct cal_t { char *type; char *name; char *desc; struct cal_t *next; }


original_code:
todo_t *dummy_todos(date_t start, date_t end)
{
 todo_t *last = &todo;
 for (int i = 0; i < 6; i++) {
  last->next = alloc0(sizeof(event_t));
  last->next->cal = todo.cal;
  last->next->name = strcopy(todo.name);
  last->next->desc = strcopy(todo.desc);
  last->next->due = todo.due;
  last->next->status = todo.status;
  last = last->next;
  last->next = ((void *)0);
 }
 return enable ? todo.next : 0;
}

canonical_original_code:
struct todo_t *dummy_todos(struct date_t start, struct date_t end)
{
 struct todo_t *last = &todo;
 for (int i = 0; i < 6; i++) {
  last->next = alloc0(sizeof(event_t));
  last->next->cal = todo.cal;
  last->next->name = strcopy(todo.name);
  last->next->desc = strcopy(todo.desc);
  last->next->due = todo.due;
  last->next->status = todo.status;
  last = last->next;
  last->next = ((void *)0);
 }
 return enable ? todo.next : 0;
}

return_type: struct todo_t { char *name; char *desc; char *cat; enum status_t { NEW=0, DONE=100 } status; struct date_t { int year; enum month_t { JAN=0, FEB=1, MAR=2, APR=3, MAY=4, JUN=5, JUL=6, AUG=7, SEP=8, OCT=9, NOV=10, DEC=11 } month; int day; int hour; int min; int sec; } start; struct date_t due; struct cal_t { char *type; char *name; char *desc; struct cal_t *next; } *cal; struct todo_t *next; struct todo_t *prev; } *


decompiled_code:
void help_size()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void help_size(int rows, int cols)
{
}

canonical_original_code:
void help_size(int rows, int cols)
{
}

variable_types: rows int

variable_types: cols int


decompiled_code:
int help_draw()
{
return mvwprintw(win, 0, 1, "%s\n", "help");
}

canonical_decompiled_code:
int func2()
{
return mvwprintw(win, 0, 1, "%s\n", "help");
}

original_code:
void help_draw(void)
{
 mvwprintw(win, 0, 1, "%s\n", "help");
}

canonical_original_code:
void help_draw()
{
 mvwprintw(win, 0, 1, "%s\n", "help");
}


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

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

original_code:
int help_run(int key, mmask_t btn, int row, int col)
{
 return 0;
}

canonical_original_code:
int help_run(int key, unsigned int btn, int row, int col)
{
 return 0;
}

variable_types: key int

variable_types:
btn
unsigned int

variable_types: row int

variable_types: col int


decompiled_code:
__int64 __fastcall on_config(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
view_config();
return cal_config(a1, a2, a3, a4);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3, __int64 a4)
{
view_config();
return cal_config(a1, a2, a3, a4);
}

original_code:
static void on_config(const char *group, const char *name, const char *key, const char *value)
{
 view_config(group, name, key, value);
 cal_config(group, name, key, value);
}

canonical_original_code:
static void on_config(char *group, char *name, char *key, char *value)
{
 view_config(group, name, key, value);
 cal_config(group, name, key, value);
}

variable_types:
group
char *


decompiled_code:
void __noreturn on_sigint()
{
endwin();
exit(0);
}

canonical_decompiled_code:
void __noreturn func1()
{
endwin();
exit(0);
}

original_code:
static void on_sigint(int signum)
{
 endwin();
 exit(0);
}

variable_types: signum int


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // ebp
MEVENT v5; // [rsp+0h] [rbp-38h] BYREF

signal(2, (__sighandler_t)on_sigint);
if ( !getenv("ESCDELAY") )
putenv("ESCDELAY=25");
setlocale(6, &locale);
initscr();
cbreak();
noecho();
keypad(stdscr, 1);
start_color();
curs_set(0);
wtimeout(stdscr, 100);
use_default_colors();
mousemask(0xFFFFFFFuLL, 0LL);
init_pair(1, 2, -1);
init_pair(2, 1, -1);
init_pair(3, 1, -1);
init_pair(4, 3, -1);
init_pair(5, 2, -1);
init_pair(6, 4, -1);
init_pair(7, 2, -1);
init_pair(8, 5, -1);
init_pair(9, 1, -1);
conf_setup((unsigned int)argc, argv, ".lackeyrc", on_config);
util_init();
conf_init();
date_init();
cal_init();
view_init();
date_sync();
view_draw();
while ( 1 )
{
conf_sync();
v3 = wgetch(stdscr);
date_sync();
if ( v3 == 113 )
break;
switch ( v3 )
{
case 0x199u:
if ( !getmouse(&v5) )
goto LABEL_9;
break;
case 0xCu:
wclear(stdscr);
LABEL_13:
view_resize();
view_draw();
break;
case 0x19Au:
endwin();
wrefresh(stdscr);
view_resize();
view_draw();
break;
case 7u:
goto LABEL_13;
default:
LABEL_9:
if ( !(unsigned int)view_run(v3, LODWORD(v5.bstate), (unsigned int)v5.y, (unsigned int)v5.x) && v3 != -1 )
debug("main: Unhandled key - Dec %3d, Hex %02x, Oct %03o, Chr <%c>", v3, v3, v3, v3);
break;
}
}
endwin();
return 0;
}

original_code:
int main(int argc, char **argv)
{
 signal(2, on_sigint);
 if (!getenv("ESCDELAY"))
  putenv("ESCDELAY=25");
 setlocale(6, "");
 initscr();
 cbreak();
 noecho();
 keypad(stdscr, 1);
 start_color();
 curs_set(0);
 wtimeout(stdscr,(100));
 use_default_colors();
 mousemask((((0010L) << (((6) - 1) * 5)) - 1), ((void *)0));
 init_pair(1, 2, -1);
 init_pair(2, 1, -1);
 init_pair(3, 1, -1);
 init_pair(4, 3, -1);
 init_pair(5, 2, -1);
 init_pair(6, 4, -1);
 init_pair(7, 2, -1);
 init_pair(8, 5, -1);
 init_pair(9, 1, -1);
 conf_setup(argc, argv, ".lackeyrc", on_config);
 util_init();
 conf_init();
 date_init();
 cal_init();
 view_init();
 date_sync();
 view_draw();
 while (1) {
  MEVENT btn;
  conf_sync();
  int chr = wgetch(stdscr);
  date_sync();
  if (chr == 'q')
   break;
  if (chr == 0631)
   if (getmouse(&btn) != (0))
    continue;
  switch (chr) {
   case 0632:
    endwin();
    wrefresh(stdscr);
    view_resize();
    view_draw();
    continue;
   case '\14':
    wclear(stdscr);
   case '\7':
    view_resize();
    view_draw();
    continue;
  }
  if (view_run(chr, btn.bstate, btn.y, btn.x))
   continue;
  if (chr == (-1))
   continue;
  debug("main: Unhandled key - Dec %3d,  Hex %02x,  Oct %03o,  Chr <%c>",
    chr, chr, chr, chr);
 }
 endwin();
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 signal(2, on_sigint);
 if (!getenv("ESCDELAY"))
  putenv("ESCDELAY=25");
 setlocale(6, "");
 initscr();
 cbreak();
 noecho();
 keypad(stdscr, 1);
 start_color();
 curs_set(0);
 wtimeout(stdscr,(100));
 use_default_colors();
 mousemask((((0010L) << (((6) - 1) * 5)) - 1), ((void *)0));
 init_pair(1, 2, -1);
 init_pair(2, 1, -1);
 init_pair(3, 1, -1);
 init_pair(4, 3, -1);
 init_pair(5, 2, -1);
 init_pair(6, 4, -1);
 init_pair(7, 2, -1);
 init_pair(8, 5, -1);
 init_pair(9, 1, -1);
 conf_setup(argc, argv, ".lackeyrc", on_config);
 util_init();
 conf_init();
 date_init();
 cal_init();
 view_init();
 date_sync();
 view_draw();
 while (1) {
  struct MEVENT btn;
  conf_sync();
  int chr = wgetch(stdscr);
  date_sync();
  if (chr == 'q')
   break;
  if (chr == 0631)
   if (getmouse(&btn) != (0))
    continue;
  switch (chr) {
   case 0632:
    endwin();
    wrefresh(stdscr);
    view_resize();
    view_draw();
    continue;
   case '\14':
    wclear(stdscr);
   case '\7':
    view_resize();
    view_draw();
    continue;
  }
  if (view_run(chr, btn.bstate, btn.y, btn.x))
   continue;
  if (chr == (-1))
   continue;
  debug("main: Unhandled key - Dec %3d,  Hex %02x,  Oct %03o,  Chr <%c>",
    chr, chr, chr, chr);
 }
 endwin();
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct MEVENT { short id; int x; unsigned int bstate; }

variable_types: chr int


decompiled_code:
void settings_size()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void settings_size(int rows, int cols)
{
}