GetRectangle

decompiled_code:
unsigned __int64 __fastcall GetRectangle(const void **a1, int *a2, _DWORD *a3, double a4, double a5)
{
_BYTE *v7; // rax
const void *v8; // rsi
unsigned __int64 result; // rax
double v10; // [rsp+0h] [rbp-28h] BYREF
double key[4]; // [rsp+8h] [rbp-20h] BYREF

key[0] = a4;
v10 = a5;
if ( !InsideGrid((__int64)a1, a4, a5) )
_assert_fail("InsideGrid(s1, t1, grid)", "PersonTime.c", 0x68u, "GetRectangle");
v7 = bsearch(key, *a1, *((int *)a1 + 2), 8uLL, (__compar_fn_t)SigmaComparison);
v8 = *(const void **)*a1;
*a2 = (v7 - (_BYTE *)*a1) >> 3;
result = 0xCCCCCCCCCCCCCCCDLL
* (((__int64)bsearch(&v10, v8, *((int *)a1 + 3), 0x28uLL, (__compar_fn_t)TauComparison) - *(_QWORD *)*a1) >> 3);
*a3 = result;
if ( *a2 < 0 )
_assert_fail("*i1 >= 0", "PersonTime.c", 0x70u, "GetRectangle");
if ( *a2 >= *((_DWORD *)a1 + 2) )
_assert_fail("*i1 < grid->m", "PersonTime.c", 0x71u, "GetRectangle");
if ( (result & 0x80000000) != 0LL )
_assert_fail("*j1 >= 0", "PersonTime.c", 0x72u, "GetRectangle");
if ( (int)result >= *((_DWORD *)a1 + 3) )
_assert_fail("*j1 < grid->n", "PersonTime.c", 0x73u, "GetRectangle");
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func3(const void **a1, int *a2, _DWORD *a3, double a4, double a5)
{
_BYTE *v7; // rax
const void *v8; // rsi
unsigned __int64 result; // rax
double v10; // [rsp+0h] [rbp-28h] BYREF
double key[4]; // [rsp+8h] [rbp-20h] BYREF

key[0] = a4;
v10 = a5;
if ( !func2((__int64)a1, a4, a5) )
_assert_fail("InsideGrid(s1, t1, grid)", "PersonTime.c", 0x68u, "GetRectangle");
v7 = bsearch(key, *a1, *((int *)a1 + 2), 8uLL, (__compar_fn_t)SigmaComparison);
v8 = *(const void **)*a1;
*a2 = (v7 - (_BYTE *)*a1) >> 3;
result = 0xCCCCCCCCCCCCCCCDLL
* (((__int64)bsearch(&v10, v8, *((int *)a1 + 3), 0x28uLL, (__compar_fn_t)TauComparison) - *(_QWORD *)*a1) >> 3);
*a3 = result;
if ( *a2 < 0 )
_assert_fail("*i1 >= 0", "PersonTime.c", 0x70u, "GetRectangle");
if ( *a2 >= *((_DWORD *)a1 + 2) )
_assert_fail("*i1 < grid->m", "PersonTime.c", 0x71u, "GetRectangle");
if ( (result & 0x80000000) != 0LL )
_assert_fail("*j1 >= 0", "PersonTime.c", 0x72u, "GetRectangle");
if ( (int)result >= *((_DWORD *)a1 + 3) )
_assert_fail("*j1 < grid->n", "PersonTime.c", 0x73u, "GetRectangle");
return result;
}

original_code:
static void GetRectangle(double s1, double t1, PersonTime_Grid grid, int *i1, int *j1)
{
 struct Rectangle **sigmaInterval;
 struct Rectangle *tauInterval;
 ((void) sizeof ((InsideGrid(s1, t1, grid)) ? 1 : 0), __extension__ ({ if (InsideGrid(s1, t1, grid)) ; else __assert_fail ("InsideGrid(s1, t1, grid)", "PersonTime.c", 104, __extension__ __PRETTY_FUNCTION__); }));
 sigmaInterval = bsearch(&s1, grid->rect, grid->m, sizeof *(grid->rect), SigmaComparison);
 *i1 = sigmaInterval - grid->rect;
 tauInterval = bsearch(&t1, grid->rect[0], grid->n, sizeof *(grid->rect[0]), TauComparison);
 *j1 = tauInterval - grid->rect[0];
 ((void) sizeof ((*i1 >= 0) ? 1 : 0), __extension__ ({ if (*i1 >= 0) ; else __assert_fail ("*i1 >= 0", "PersonTime.c", 112, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((*i1 < grid->m) ? 1 : 0), __extension__ ({ if (*i1 < grid->m) ; else __assert_fail ("*i1 < grid->m", "PersonTime.c", 113, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((*j1 >= 0) ? 1 : 0), __extension__ ({ if (*j1 >= 0) ; else __assert_fail ("*j1 >= 0", "PersonTime.c", 114, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((*j1 < grid->n) ? 1 : 0), __extension__ ({ if (*j1 < grid->n) ; else __assert_fail ("*j1 < grid->n", "PersonTime.c", 115, __extension__ __PRETTY_FUNCTION__); }));
}

canonical_original_code:
static void GetRectangle(double s1, double t1, struct PersonTime_GridDesc *grid, int *i1, int *j1)
{
 struct Rectangle **sigmaInterval;
 struct Rectangle *tauInterval;
 ((void) sizeof ((InsideGrid(s1, t1, grid)) ? 1 : 0), __extension__ ({ if (InsideGrid(s1, t1, grid)) ; else __assert_fail ("InsideGrid(s1, t1, grid)", "PersonTime.c", 104, __extension__ __PRETTY_FUNCTION__); }));
 sigmaInterval = bsearch(&s1, grid->rect, grid->m, sizeof *(grid->rect), SigmaComparison);
 *i1 = sigmaInterval - grid->rect;
 tauInterval = bsearch(&t1, grid->rect[0], grid->n, sizeof *(grid->rect[0]), TauComparison);
 *j1 = tauInterval - grid->rect[0];
 ((void) sizeof ((*i1 >= 0) ? 1 : 0), __extension__ ({ if (*i1 >= 0) ; else __assert_fail ("*i1 >= 0", "PersonTime.c", 112, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((*i1 < grid->m) ? 1 : 0), __extension__ ({ if (*i1 < grid->m) ; else __assert_fail ("*i1 < grid->m", "PersonTime.c", 113, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((*j1 >= 0) ? 1 : 0), __extension__ ({ if (*j1 >= 0) ; else __assert_fail ("*j1 >= 0", "PersonTime.c", 114, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((*j1 < grid->n) ? 1 : 0), __extension__ ({ if (*j1 < grid->n) ; else __assert_fail ("*j1 < grid->n", "PersonTime.c", 115, __extension__ __PRETTY_FUNCTION__); }));
}

user_defined_types: struct Rectangle { double sigmaMin; double tauMin; double personTime; }


AddToRectangle

repo: kland/person-time

original_code:
static void AddToRectangle(double s1, double t1, double s2, double t2, struct Rectangle *r)
{
 struct LineClipping_Rectangle rectangle;
 struct LineClipping_Segment segment;
 int done;
 rectangle.xMin = r->sigmaMin;
 rectangle.yMin = r->tauMin;
 rectangle.xMax = r->sigmaMax;
 rectangle.yMax = r->tauMax;
 segment.x0 = s1;
 segment.y0 = t1;
 segment.x1 = s2;
 segment.y1 = t2;
 LineClipping_Clip(&rectangle, &segment, &done);
 if (done) {
  r->personTime += segment.x1 - segment.x0;
 }
}

variable_types: struct Rectangle { double sigmaMin; double tauMin; double personTime; } *

variable_types: struct LineClipping_Rectangle { double xMin; }

variable_types: struct LineClipping_Segment { double x0; }

variable_types: done int

return_type: void


original_code:
PersonTime_Grid PersonTime_New(const double sigma[], int m, const double tau[], int n)
{
 PersonTime_Grid result;
 int i, j;
 ((void) sizeof ((m >= 2) ? 1 : 0), __extension__ ({ if (m >= 2) ; else __assert_fail ("m >= 2", "PersonTime.c", 28, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((n >= 2) ? 1 : 0), __extension__ ({ if (n >= 2) ; else __assert_fail ("n >= 2", "PersonTime.c", 29, __extension__ __PRETTY_FUNCTION__); }));
 ((((result)) = GC_malloc((1) * sizeof *((result)))));
 result->m = m - 1;
 result->n = n - 1;
 ((result->rect) = GC_malloc((result->m) * sizeof *(result->rect)));
 for (i = 0; i < result->m; i++) {
  ((result->rect[i]) = GC_malloc((result->n) * sizeof *(result->rect[i])));
  for (j = 0; j < result->n; j++) {
   ((void) sizeof ((sigma[i] < sigma[i + 1]) ? 1 : 0), __extension__ ({ if (sigma[i] < sigma[i + 1]) ; else __assert_fail ("sigma[i] < sigma[i + 1]", "PersonTime.c", 38, __extension__ __PRETTY_FUNCTION__); }));
   result->rect[i][j].sigmaMin = sigma[i];
   result->rect[i][j].sigmaMax = sigma[i + 1];
   ((void) sizeof ((tau[j] < tau[j + 1]) ? 1 : 0), __extension__ ({ if (tau[j] < tau[j + 1]) ; else __assert_fail ("tau[j] < tau[j + 1]", "PersonTime.c", 42, __extension__ __PRETTY_FUNCTION__); }));
   result->rect[i][j].tauMin = tau[j];
   result->rect[i][j].tauMax = tau[j + 1];
   result->rect[i][j].personTime = 0.0;
  }
 }
 return result;
}

canonical_original_code:
struct PersonTime_GridDesc *PersonTime_New(double sigma[], int m, double tau[], int n)
{
 struct PersonTime_GridDesc *result;
 int i; int j;
 ((void) sizeof ((m >= 2) ? 1 : 0), __extension__ ({ if (m >= 2) ; else __assert_fail ("m >= 2", "PersonTime.c", 28, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((n >= 2) ? 1 : 0), __extension__ ({ if (n >= 2) ; else __assert_fail ("n >= 2", "PersonTime.c", 29, __extension__ __PRETTY_FUNCTION__); }));
 ((((result)) = GC_malloc((1) * sizeof *((result)))));
 result->m = m - 1;
 result->n = n - 1;
 ((result->rect) = GC_malloc((result->m) * sizeof *(result->rect)));
 for (i = 0; i < result->m; i++) {
  ((result->rect[i]) = GC_malloc((result->n) * sizeof *(result->rect[i])));
  for (j = 0; j < result->n; j++) {
   ((void) sizeof ((sigma[i] < sigma[i + 1]) ? 1 : 0), __extension__ ({ if (sigma[i] < sigma[i + 1]) ; else __assert_fail ("sigma[i] < sigma[i + 1]", "PersonTime.c", 38, __extension__ __PRETTY_FUNCTION__); }));
   result->rect[i][j].sigmaMin = sigma[i];
   result->rect[i][j].sigmaMax = sigma[i + 1];
   ((void) sizeof ((tau[j] < tau[j + 1]) ? 1 : 0), __extension__ ({ if (tau[j] < tau[j + 1]) ; else __assert_fail ("tau[j] < tau[j + 1]", "PersonTime.c", 42, __extension__ __PRETTY_FUNCTION__); }));
   result->rect[i][j].tauMin = tau[j];
   result->rect[i][j].tauMax = tau[j + 1];
   result->rect[i][j].personTime = 0.0;
  }
 }
 return result;
}

variable_types:
sigma
double []

variable_types: m int

variable_types:
tau
double []

variable_types: n int

variable_types: struct PersonTime_GridDesc { struct Rectangle { double sigmaMin; double tauMin; double personTime; } **rect; int m; int n; } *

variable_types: i int

variable_types: j int

user_defined_types: struct PersonTime_GridDesc { struct Rectangle **rect; int m; int n; }


decompiled_code:
unsigned __int64 __fastcall PersonTime_Add(const void **a1, double a2, double a3, double a4)
{
double v4; // xmm3_8
unsigned __int64 result; // rax
int v7; // er14
__int64 v8; // r12
int v9; // ebx
__int64 v10; // rbp
__int64 v11; // rdi
double v12; // [rsp+0h] [rbp-58h]
int v13; // [rsp+20h] [rbp-38h] BYREF
int v14; // [rsp+24h] [rbp-34h] BYREF
int v15; // [rsp+28h] [rbp-30h] BYREF
int v16[11]; // [rsp+2Ch] [rbp-2Ch] BYREF

v4 = a4 + a3;
v12 = a2 + a4;
if ( !InsideGrid((__int64)a1, a2, a3) )
_assert_fail("InsideGrid(s1, t1, grid)", "PersonTime.c", 0x97u, "PersonTime_Add");
if ( !InsideGrid((__int64)a1, v12, v4) )
_assert_fail("InsideGrid(s2, t2, grid)", "PersonTime.c", 0x98u, "PersonTime_Add");
GetRectangle(a1, &v13, &v14, a2, a3);
result = GetRectangle(a1, &v15, v16, v12, v4);
v7 = v13;
if ( v13 <= v15 )
{
v8 = 8LL * v13;
do
{
v9 = v14;
if ( v14 <= v16[0] )
{
v10 = 40LL * v14;
do
{
++v9;
v11 = v10 + *(_QWORD *)((char *)*a1 + v8);
v10 += 40LL;
result = AddToRectangle(v11, a2, a3, v12, v4);
}
while ( v16[0] >= v9 );
}
++v7;
v8 += 8LL;
}
while ( v15 >= v7 );
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func6(const void **a1, double a2, double a3, double a4)
{
double v4; // xmm3_8
unsigned __int64 result; // rax
int v7; // er14
__int64 v8; // r12
int v9; // ebx
__int64 v10; // rbp
__int64 v11; // rdi
double v12; // [rsp+0h] [rbp-58h]
int v13; // [rsp+20h] [rbp-38h] BYREF
int v14; // [rsp+24h] [rbp-34h] BYREF
int v15; // [rsp+28h] [rbp-30h] BYREF
int v16[11]; // [rsp+2Ch] [rbp-2Ch] BYREF

v4 = a4 + a3;
v12 = a2 + a4;
if ( !func2((__int64)a1, a2, a3) )
_assert_fail("InsideGrid(s1, t1, grid)", "PersonTime.c", 0x97u, "PersonTime_Add");
if ( !func2((__int64)a1, v12, v4) )
_assert_fail("InsideGrid(s2, t2, grid)", "PersonTime.c", 0x98u, "PersonTime_Add");
func3(a1, &v13, &v14, a2, a3);
result = func3(a1, &v15, v16, v12, v4);
v7 = v13;
if ( v13 <= v15 )
{
v8 = 8LL * v13;
do
{
v9 = v14;
if ( v14 <= v16[0] )
{
v10 = 40LL * v14;
do
{
++v9;
v11 = v10 + *(_QWORD *)((char *)*a1 + v8);
v10 += 40LL;
result = func4(v11, a2, a3, v12, v4);
}
while ( v16[0] >= v9 );
}
++v7;
v8 += 8LL;
}
while ( v15 >= v7 );
}
return result;
}

original_code:
void PersonTime_Add(double s1, double t1, double dt, PersonTime_Grid grid)
{
 double s2, t2;
 int i1, j1;
 int i2, j2;
 int i, j;
 s2 = s1 + dt;
 t2 = t1 + dt;
 ((void) sizeof ((InsideGrid(s1, t1, grid)) ? 1 : 0), __extension__ ({ if (InsideGrid(s1, t1, grid)) ; else __assert_fail ("InsideGrid(s1, t1, grid)", "PersonTime.c", 151, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((InsideGrid(s2, t2, grid)) ? 1 : 0), __extension__ ({ if (InsideGrid(s2, t2, grid)) ; else __assert_fail ("InsideGrid(s2, t2, grid)", "PersonTime.c", 152, __extension__ __PRETTY_FUNCTION__); }));
 GetRectangle(s1, t1, grid, &i1, &j1);
 GetRectangle(s2, t2, grid, &i2, &j2);
 for (i = i1; i <= i2; i++) {
  for (j = j1; j <= j2; j++) {
   AddToRectangle(s1, t1, s2, t2, &(grid->rect[i][j]));
  }
 }
}

canonical_original_code:
void PersonTime_Add(double s1, double t1, double dt, struct PersonTime_GridDesc *grid)
{
 double s2; double t2;
 int i1; int j1;
 int i2; int j2;
 int i; int j;
 s2 = s1 + dt;
 t2 = t1 + dt;
 ((void) sizeof ((InsideGrid(s1, t1, grid)) ? 1 : 0), __extension__ ({ if (InsideGrid(s1, t1, grid)) ; else __assert_fail ("InsideGrid(s1, t1, grid)", "PersonTime.c", 151, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((InsideGrid(s2, t2, grid)) ? 1 : 0), __extension__ ({ if (InsideGrid(s2, t2, grid)) ; else __assert_fail ("InsideGrid(s2, t2, grid)", "PersonTime.c", 152, __extension__ __PRETTY_FUNCTION__); }));
 GetRectangle(s1, t1, grid, &i1, &j1);
 GetRectangle(s2, t2, grid, &i2, &j2);
 for (i = i1; i <= i2; i++) {
  for (j = j1; j <= j2; j++) {
   AddToRectangle(s1, t1, s2, t2, &(grid->rect[i][j]));
  }
 }
}

variable_types: dt double


original_code:
void PersonTime_Print(PersonTime_Grid grid)
{
 const int colSep = 2;
 const char sigmaMinLabel[] = "Sigma Min";
 const char sigmaMaxLabel[] = "Sigma Max";
 const char tauMinLabel[] = "Tau Min";
 const char tauMaxLabel[] = "Tau Max";
 const char personTimeLabel[] = "Person Time";
 int i, j;
 printf("%s", sigmaMinLabel);
 printf("%*s", (int) (colSep + strlen(sigmaMaxLabel)), sigmaMaxLabel);
 printf("%*s", (int) (colSep + strlen(tauMinLabel)), tauMinLabel);
 printf("%*s", (int) (colSep + strlen(tauMaxLabel)), tauMaxLabel);
 printf("%*s", (int) (colSep + strlen(personTimeLabel)), personTimeLabel);
 putchar('\n');
 for (i = 0; i < grid->m; i++) {
  for (j = 0; j < grid->n; j++) {
   printf("%*.1f", (int) strlen(sigmaMinLabel), grid->rect[i][j].sigmaMin);
   printf("%*.1f", (int) (colSep + strlen(sigmaMaxLabel)), grid->rect[i][j].sigmaMax);
   printf("%*.1f", (int) (colSep + strlen(tauMinLabel)), grid->rect[i][j].tauMin);
   printf("%*.1f", (int) (colSep + strlen(tauMaxLabel)), grid->rect[i][j].tauMax);
   printf("%*.1f", (int) (colSep + strlen(personTimeLabel)), grid->rect[i][j].personTime);
   putchar('\n');
  }
 }
}

canonical_original_code:
void PersonTime_Print(struct PersonTime_GridDesc *grid)
{
 int colSep = 2;
 char sigmaMinLabel[] = "Sigma Min";
 char sigmaMaxLabel[] = "Sigma Max";
 char tauMinLabel[] = "Tau Min";
 char tauMaxLabel[] = "Tau Max";
 char personTimeLabel[] = "Person Time";
 int i; int j;
 printf("%s", sigmaMinLabel);
 printf("%*s", (int) (colSep + strlen(sigmaMaxLabel)), sigmaMaxLabel);
 printf("%*s", (int) (colSep + strlen(tauMinLabel)), tauMinLabel);
 printf("%*s", (int) (colSep + strlen(tauMaxLabel)), tauMaxLabel);
 printf("%*s", (int) (colSep + strlen(personTimeLabel)), personTimeLabel);
 putchar('\n');
 for (i = 0; i < grid->m; i++) {
  for (j = 0; j < grid->n; j++) {
   printf("%*.1f", (int) strlen(sigmaMinLabel), grid->rect[i][j].sigmaMin);
   printf("%*.1f", (int) (colSep + strlen(sigmaMaxLabel)), grid->rect[i][j].sigmaMax);
   printf("%*.1f", (int) (colSep + strlen(tauMinLabel)), grid->rect[i][j].tauMin);
   printf("%*.1f", (int) (colSep + strlen(tauMaxLabel)), grid->rect[i][j].tauMax);
   printf("%*.1f", (int) (colSep + strlen(personTimeLabel)), grid->rect[i][j].personTime);
   putchar('\n');
  }
 }
}

variable_types: colSep int

variable_types:
sigmaMinLabel
char []

variable_types:
sigmaMaxLabel
char []

variable_types:
tauMinLabel
char []

variable_types:
tauMaxLabel
char []

variable_types:
personTimeLabel
char []


In

decompiled_code:
__int64 __fastcall In(char a1, int a2)
{
return (a2 >> a1) & 1;
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1, int a2)
{
return (a2 >> a1) & 1;
}

original_code:
static int In(int x, int A)
{
 return ((1 << x) & A) != 0;
}

variable_types: x int

variable_types: A int

return_type: int


Outcode

decompiled_code:
__int64 __fastcall Outcode(double *a1, double a2, double a3)
{
double v3; // xmm2_8
unsigned int v6; // [rsp+Ch] [rbp-4h] BYREF

v3 = *a1;
v6 = 0;
if ( v3 > a2 )
{
Include(0, &v6);
}
else if ( a2 > a1[1] )
{
Include(1, &v6);
if ( a1[2] <= a3 )
goto LABEL_4;
LABEL_8:
Include(2, &v6);
return v6;
}
if ( a1[2] > a3 )
goto LABEL_8;
LABEL_4:
if ( a3 > a1[3] )
Include(3, &v6);
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func2(double *a1, double a2, double a3)
{
double v3; // xmm2_8
unsigned int v6; // [rsp+Ch] [rbp-4h] BYREF

v3 = *a1;
v6 = 0;
if ( v3 > a2 )
{
func1(0, &v6);
}
else if ( a2 > a1[1] )
{
func1(1, &v6);
if ( a1[2] <= a3 )
goto LABEL_4;
LABEL_8:
func1(2, &v6);
return v6;
}
if ( a1[2] > a3 )
goto LABEL_8;
LABEL_4:
if ( a3 > a1[3] )
func1(3, &v6);
return v6;
}

original_code:
static int Outcode(double x, double y, const struct LineClipping_Rectangle *r)
{
 int result;
 result = 0;
 if (x < r->xMin) {
  Include(0, &result);
 } else if (x > r->xMax) {
  Include(1, &result);
 }
 if (y < r->yMin) {
  Include(2, &result);
 } else if (y > r->yMax) {
  Include(3, &result);
  }
 return result;
}

canonical_original_code:
static int Outcode(double x, double y, struct LineClipping_Rectangle *r)
{
 int result;
 result = 0;
 if (x < r->xMin) {
  Include(0, &result);
 } else if (x > r->xMax) {
  Include(1, &result);
 }
 if (y < r->yMin) {
  Include(2, &result);
 } else if (y > r->yMax) {
  Include(3, &result);
  }
 return result;
}

variable_types: x double

variable_types: y double

variable_types: struct LineClipping_Rectangle { double xMin; } *

variable_types: result int


SameSide

decompiled_code:
_BOOL8 __fastcall SameSide(int a1, int a2)
{
return (a2 & a1) != 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(int a1, int a2)
{
return (a2 & a1) != 0;
}

original_code:
static int SameSide(int outcode0, int outcode1)
{
 return (outcode0 & outcode1) != 0;
}


Inside

decompiled_code:
_BOOL8 __fastcall Inside(int a1, int a2)
{
return (a2 | a1) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func4(int a1, int a2)
{
return (a2 | a1) == 0;
}

original_code:
static int Inside(int outcode0, int outcode1)
{
 return (outcode0 == 0) && (outcode1 == 0);
}


GetIntersection

original_code:
static void GetIntersection(const struct LineClipping_Rectangle *r,
 const struct LineClipping_Segment *s,
 int outcode,
 double *x,
 double *y)
{
 if (In(3, outcode)) {
  ((void) sizeof ((s->y0 != s->y1) ? 1 : 0), __extension__ ({ if (s->y0 != s->y1) ; else __assert_fail ("s->y0 != s->y1", "LineClipping.c", 62, __extension__ __PRETTY_FUNCTION__); }));
  *x = s->x0 + (s->x1 - s->x0) * (r->yMax - s->y0) / (s->y1 - s->y0);
  *y = r->yMax;
 } else if (In(2, outcode)) {
  ((void) sizeof ((s->y0 != s->y1) ? 1 : 0), __extension__ ({ if (s->y0 != s->y1) ; else __assert_fail ("s->y0 != s->y1", "LineClipping.c", 66, __extension__ __PRETTY_FUNCTION__); }));
  *x = s->x0 + (s->x1 - s->x0) * (r->yMin - s->y0) / (s->y1 - s->y0);
  *y = r->yMin;
 } else if (In(1, outcode)) {
  ((void) sizeof ((s->x0 != s->x1) ? 1 : 0), __extension__ ({ if (s->x0 != s->x1) ; else __assert_fail ("s->x0 != s->x1", "LineClipping.c", 70, __extension__ __PRETTY_FUNCTION__); }));
  *y = s->y0 + (s->y1 - s->y0) * (r->xMax - s->x0) / (s->x1 - s->x0);
  *x = r->xMax;
 } else if (In(0, outcode)) {
  ((void) sizeof ((s->x0 != s->x1) ? 1 : 0), __extension__ ({ if (s->x0 != s->x1) ; else __assert_fail ("s->x0 != s->x1", "LineClipping.c", 74, __extension__ __PRETTY_FUNCTION__); }));
  *y = s->y0 + (s->y1 - s->y0) * (r->xMin - s->x0) / (s->x1 - s->x0);
  *x = r->xMin;
 }
}

canonical_original_code:
static void GetIntersection(struct LineClipping_Rectangle *r, struct LineClipping_Segment *s, int outcode, double *x, double *y)
{
 if (In(3, outcode)) {
  ((void) sizeof ((s->y0 != s->y1) ? 1 : 0), __extension__ ({ if (s->y0 != s->y1) ; else __assert_fail ("s->y0 != s->y1", "LineClipping.c", 62, __extension__ __PRETTY_FUNCTION__); }));
  *x = s->x0 + (s->x1 - s->x0) * (r->yMax - s->y0) / (s->y1 - s->y0);
  *y = r->yMax;
 } else if (In(2, outcode)) {
  ((void) sizeof ((s->y0 != s->y1) ? 1 : 0), __extension__ ({ if (s->y0 != s->y1) ; else __assert_fail ("s->y0 != s->y1", "LineClipping.c", 66, __extension__ __PRETTY_FUNCTION__); }));
  *x = s->x0 + (s->x1 - s->x0) * (r->yMin - s->y0) / (s->y1 - s->y0);
  *y = r->yMin;
 } else if (In(1, outcode)) {
  ((void) sizeof ((s->x0 != s->x1) ? 1 : 0), __extension__ ({ if (s->x0 != s->x1) ; else __assert_fail ("s->x0 != s->x1", "LineClipping.c", 70, __extension__ __PRETTY_FUNCTION__); }));
  *y = s->y0 + (s->y1 - s->y0) * (r->xMax - s->x0) / (s->x1 - s->x0);
  *x = r->xMax;
 } else if (In(0, outcode)) {
  ((void) sizeof ((s->x0 != s->x1) ? 1 : 0), __extension__ ({ if (s->x0 != s->x1) ; else __assert_fail ("s->x0 != s->x1", "LineClipping.c", 74, __extension__ __PRETTY_FUNCTION__); }));
  *y = s->y0 + (s->y1 - s->y0) * (r->xMin - s->x0) / (s->x1 - s->x0);
  *x = r->xMin;
 }
}

variable_types: struct LineClipping_Segment { double x0; } *

variable_types: outcode int

variable_types:
x
double *

variable_types:
y
double *

user_defined_types: struct LineClipping_Rectangle { double xMin; }


draw

repo: klausklapper/ctool

decompiled_code:
__int64 draw()
{
drawPic(images, 16LL, 16LL);
drawText((__int64)"100", 0x26u, 0x10u);
drawPic(font, 128LL, 16LL);
drawText((__int64)"1", 0x96u, 0x10u);
drawPic(screen, 256LL, 16LL);
drawText((__int64)"5", 0x116u, 0x10u);
drawPic(end, 384LL, 16LL);
drawText((__int64)"20", 0x196u, 0x10u);
drawPic(qword_4040B8, 16LL, 42LL);
drawText(4202547LL, 0x26u, 0x2Au);
return SDL_Flip();
}

original_code:
void draw(void)
{
 drawPic(images[GOLD], 16, 16);
 drawText("100", 38, 16);
 drawPic(images[TIME], 128, 16);
 drawText("1", 150, 16);
 drawPic(images[MAN], 256, 16);
 drawText("5", 278, 16);
 drawPic(images[FOOD], 384, 16);
 drawText("20", 406, 16);
 drawPic(images[HOUSE], 16, 42);
 drawText("0", 38, 42);
 SDL_Flip(screen);
}

canonical_original_code:
void draw()
{
 drawPic(images[GOLD], 16, 16);
 drawText("100", 38, 16);
 drawPic(images[TIME], 128, 16);
 drawText("1", 150, 16);
 drawPic(images[MAN], 256, 16);
 drawText("5", 278, 16);
 drawPic(images[FOOD], 384, 16);
 drawText("20", 406, 16);
 drawPic(images[HOUSE], 16, 42);
 drawText("0", 38, 42);
 SDL_Flip(screen);
}


decompiled_code:
__int64 __fastcall draw_menu_item(__int64 a1, unsigned int a2, unsigned int a3, __int64 a4, unsigned int a5, unsigned int a6, int a7)
{
__int64 v7; // rax

v7 = a1;
if ( a7 )
{
image_draw(
*(_QWORD *)(a1 + 80),
0LL,
a3 << (a6 + 2),
640LL,
(a3 + 1) << (a6 + 2),
&spr_menu,
0LL,
0LL,
spr_menu,
*((unsigned __int16 *)&spr_menu + 1),
4LL);
v7 = a1;
}
return draw_string(*(_QWORD *)(v7 + 80), a2, a3, a4, a5, a6, a7 == 0, 128LL);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned int a2, unsigned int a3, __int64 a4, unsigned int a5, unsigned int a6, int a7)
{
__int64 v7; // rax

v7 = a1;
if ( a7 )
{
image_draw(
*(_QWORD *)(a1 + 80),
0LL,
a3 << (a6 + 2),
640LL,
(a3 + 1) << (a6 + 2),
&spr_menu,
0LL,
0LL,
spr_menu,
*((unsigned __int16 *)&spr_menu + 1),
4LL);
v7 = a1;
}
return draw_string(*(_QWORD *)(v7 + 80), a2, a3, a4, a5, a6, a7 == 0, 128LL);
}

original_code:
void draw_menu_item(yeti_t *yeti, int x, int y, char *s, int xs, int ys, int selected)
{
    if (selected) {
        int y1 = ((y + 0)<<((ys)+2));
        int y2 = ((y + 1)<<((ys)+2));
        image_draw(
            yeti->viewport.back->pixels[0],
            0, y1, 640, y2,
            (spr_menu), 0, 0, ((spr_menu)[0]), ((spr_menu)[1]), (4));
    }
    draw_string(yeti->viewport.back, x, y, s, xs, ys,
                selected ? (0) : (1),
                128);
}

canonical_original_code:
void draw_menu_item(struct yeti_t *yeti, int x, int y, char *s, int xs, int ys, int selected)
{
    if (selected) {
        int y1 = ((y + 0)<<((ys)+2));
        int y2 = ((y + 1)<<((ys)+2));
        image_draw(
            yeti->viewport.back->pixels[0],
            0, y1, 640, y2,
            (spr_menu), 0, 0, ((spr_menu)[0]), ((spr_menu)[1]), (4));
    }
    draw_string(yeti->viewport.back, x, y, s, xs, ys,
                selected ? (0) : (1),
                128);
}

variable_types: struct yeti_t { struct game_t { short gravity; short jumping; short crawling; short walking; short ceiling; short tick; struct hud_t { unsigned char health; unsigned char ammo; } hud; struct menu_t { char main; char skill; char episode; char paused; char option; char language; } menu; char prevmode; short episode; } game; unsigned int mark; unsigned int fps; struct entity_t { struct entity_t *next; void *tag; struct entity_visual_t { unsigned char altpitch; unsigned char altroll; unsigned char altturn; unsigned char mode; short width; short height; void *data; void (*ondraw)(struct yeti_t *yeti, struct entity_t *e); } visual; struct animation_t { char mode; unsigned char nloops; unsigned short pos; unsigned short start; unsigned short length; unsigned short end; unsigned short speed; } animation; unsigned char emitlight; unsigned char castshadow; unsigned char nocollision; unsigned char alwaysvisible; unsigned char alwaysontop; struct entity_state_t { unsigned short pain; } state; unsigned short radius; short x; short y; short z; short p; short r; short t; short rx; short ry; short rz; void (*ontick)(struct yeti_t *yeti, struct entity_t *e); void (*onhit)(struct yeti_t *yeti, struct entity_t *e1, struct entity_t *e2); void (*onwall)(struct yeti_t *yeti, struct entity_t *e, struct cell_t { unsigned char swi; unsigned char ent; short top; short bot; short eos; short hos; char tos; char bos; short bots[4]; short tops[4]; short tsa; short bsa; unsigned char wtb; unsigned char sw2; short lit; unsigned char wtt; unsigned char ttx; unsigned char btx; unsigned char wwi; char xlod; char ylod; unsigned int mark; struct entity_t *entities; unsigned char vcache_size; struct vertex_t { int x; int y; int z; int l; int d; int i; int u; int v; int sx; int sy; } *vcache[3]; } *c); } *camera; struct entity_t *player; struct entity_t *player2; struct visual_t { int threshold_dithering; int threshold_perspective; int map_lod; int brightness; } visual; struct viewport_t { struct pixel_buffer_t { unsigned short pixels[480][640]; } *front; struct pixel_buffer_t *back; } viewport; struct keyboard_t { unsigned int tick; struct keys_t { unsigned short left; unsigned short right; unsigned short up; unsigned short down; unsigned short a; unsigned short b; unsigned short r; unsigned short l; unsigned short select; unsigned short start; unsigned short rotate; struct point_t { int x; } mouse; } state; struct keys_t saved; } keyboard; struct message_t { char s[256]; unsigned int tick; char *text; } message; struct map_t { int width; struct cell_t item[64][64]; } map; int is2d; int m[3][4]; struct entity_array_t { int length; struct entity_t item[70]; } entities; struct vertex_pool_t { int length; struct vertex_t item[1024]; } vpool; struct surface_array_t { int length; struct surface_t { unsigned char xsize; unsigned char ysize; unsigned char mode; short xpan; short ypan; } item[128]; } surfaces; struct bullet_array_t { int length; struct entity_t *item[8]; } bullets; unsigned char (*textures)[64][64]; unsigned char (*palette)[3]; unsigned short luas[4][64][256]; unsigned short *skyimage; struct vertex_t verts[500]; void (*onhit)(struct yeti_t *yeti, struct entity_t *e1, struct entity_t *e2); } *

variable_types: y int

variable_types:
s
char *

variable_types: xs int

variable_types: ys int

variable_types: selected int

user_defined_types: struct yeti_t { struct game_t game; unsigned int mark; unsigned int fps; struct entity_t *camera; struct entity_t *player; struct entity_t *player2; struct visual_t visual; struct viewport_t viewport; struct keyboard_t keyboard; struct message_t message; struct map_t map; int is2d; int m[3][4]; struct entity_array_t entities; struct vertex_pool_t vpool; struct surface_array_t surfaces; struct bullet_array_t bullets; unsigned char (*textures)[64][64]; unsigned char (*palette)[3]; unsigned short luas[4][64][256]; unsigned short *skyimage; struct vertex_t verts[500]; void (*onhit)(struct yeti_t *yeti, struct entity_t *e1, struct entity_t *e2); }

user_defined_types: struct game_t { short gravity; short jumping; short crawling; short walking; short ceiling; short tick; struct hud_t hud; struct menu_t menu; char prevmode; short episode; }

user_defined_types: struct viewport_t { struct pixel_buffer_t *front; struct pixel_buffer_t *back; }

user_defined_types: struct keyboard_t { unsigned int tick; struct keys_t state; struct keys_t saved; }

user_defined_types: struct surface_array_t { int length; struct surface_t item[128]; }

user_defined_types: struct entity_t { struct entity_t *next; void *tag; struct entity_visual_t visual; struct animation_t animation; unsigned char emitlight; unsigned char castshadow; unsigned char nocollision; unsigned char alwaysvisible; unsigned char alwaysontop; struct entity_state_t state; unsigned short radius; short x; short y; short z; short p; short r; short t; short rx; short ry; short rz; void (*ontick)(struct yeti_t *yeti, struct entity_t *e); void (*onhit)(struct yeti_t *yeti, struct entity_t *e1, struct entity_t *e2); void (*onwall)(struct yeti_t *yeti, struct entity_t *e, struct cell_t *c); }

user_defined_types: struct keys_t { unsigned short left; unsigned short right; unsigned short up; unsigned short down; unsigned short a; unsigned short b; unsigned short r; unsigned short l; unsigned short select; unsigned short start; unsigned short rotate; struct point_t mouse; }

user_defined_types: struct cell_t { unsigned char swi; unsigned char ent; short top; short bot; short eos; short hos; char tos; char bos; short bots[4]; short tops[4]; short tsa; short bsa; unsigned char wtb; unsigned char sw2; short lit; unsigned char wtt; unsigned char ttx; unsigned char btx; unsigned char wwi; char xlod; char ylod; unsigned int mark; struct entity_t *entities; unsigned char vcache_size; struct vertex_t *vcache[3]; }


decompiled_code:
__int64 __fastcall screen_monster(__int64 a1)
{
int v1; // er12
unsigned int v2; // ebx
int v3; // ebp
__int64 v4; // rdx
__int16 v5; // ax
int v6; // esi
int v7; // eax
__int64 result; // rax

v1 = 0;
v2 = 0;
v3 = (reciprocal[480] * *((unsigned __int16 *)&spr_face + 1)) >> 8;
do
{
v4 = v2;
v5 = v2++ + 4 * *(_DWORD *)(a1 + 88);
v6 = *((_DWORD *)&sintable + ((4 * v5) & 0x7FC));
v7 = v1;
v1 += v3;
result = image_draw(
*(_QWORD *)(a1 + 80),
(unsigned int)((v6 >> 3) - 320),
v4,
(unsigned int)((v6 >> 3) + 960),
v2,
&spr_face,
0LL,
(unsigned int)(v7 >> 8),
spr_face,
(unsigned int)((v7 >> 8) + 1),
4LL);
}
while ( v2 != 480 );
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
int v1; // er12
unsigned int v2; // ebx
int v3; // ebp
__int64 v4; // rdx
__int16 v5; // ax
int v6; // esi
int v7; // eax
__int64 result; // rax

v1 = 0;
v2 = 0;
v3 = (reciprocal[480] * *((unsigned __int16 *)&spr_face + 1)) >> 8;
do
{
v4 = v2;
v5 = v2++ + 4 * *(_DWORD *)(a1 + 88);
v6 = *((_DWORD *)&sintable + ((4 * v5) & 0x7FC));
v7 = v1;
v1 += v3;
result = image_draw(
*(_QWORD *)(a1 + 80),
(unsigned int)((v6 >> 3) - 320),
v4,
(unsigned int)((v6 >> 3) + 960),
v2,
&spr_face,
0LL,
(unsigned int)(v7 >> 8),
spr_face,
(unsigned int)((v7 >> 8) + 1),
4LL);
}
while ( v2 != 480 );
return result;
}

variable_types: v int

variable_types: vv int

user_defined_types: struct visual_t { int threshold_dithering; int threshold_perspective; int map_lod; int brightness; }

user_defined_types: struct message_t { char s[256]; unsigned int tick; char *text; }

user_defined_types: struct map_t { int width; struct cell_t item[64][64]; }

user_defined_types: struct entity_array_t { int length; struct entity_t item[70]; }

user_defined_types: struct vertex_pool_t { int length; struct vertex_t item[1024]; }

user_defined_types: struct bullet_array_t { int length; struct entity_t *item[8]; }

user_defined_types: struct hud_t { unsigned char health; unsigned char ammo; }

user_defined_types: struct menu_t { char main; char skill; char episode; char paused; char option; char language; }

user_defined_types: struct entity_visual_t { unsigned char altpitch; unsigned char altroll; unsigned char altturn; unsigned char mode; short width; short height; void *data; void (*ondraw)(struct yeti_t *yeti, struct entity_t *e); }

user_defined_types: struct animation_t { char mode; unsigned char nloops; unsigned short pos; unsigned short start; unsigned short length; unsigned short end; unsigned short speed; }

user_defined_types: struct entity_state_t { unsigned short pain; }

user_defined_types: struct pixel_buffer_t { unsigned short pixels[480][640]; }

user_defined_types: struct surface_t { unsigned char xsize; unsigned char ysize; unsigned char mode; short xpan; short ypan; }

user_defined_types: struct vertex_t { int x; int y; int z; int l; int d; int i; int u; int v; int sx; int sy; }


original_code:
void screen_flames(yeti_t *yeti, int rising)
{
    u16 *flames[] = {spr_flames0, spr_flames1, spr_flames2, spr_flames3};
    u16 *flame = flames[(yeti->game.tick >> 2) & 3];
    screen_monster(yeti);
    if (rising) {
        int zoom = ((yeti->game.tick)&0xFF);
        image_draw(
            yeti->viewport.back->pixels[0],
            0, ((480)+(((((((0 +480)>>1))-(480))*((zoom))))>>8)),
            640, 480,
            (flame), 0, 0, ((flame)[0]), ((flame)[1]), (1));
    } else {
        image_draw(
            yeti->viewport.back->pixels[0],
            0, ((0 +480)>>1),
            640, 480,
            (flame), 0, 0, ((flame)[0]), ((flame)[1]), (1));
    }
}

canonical_original_code:
void screen_flames(struct yeti_t *yeti, int rising)
{
    unsigned short *flames[] = {spr_flames0, spr_flames1, spr_flames2, spr_flames3};
    unsigned short *flame = flames[(yeti->game.tick >> 2) & 3];
    screen_monster(yeti);
    if (rising) {
        int zoom = ((yeti->game.tick)&0xFF);
        image_draw(
            yeti->viewport.back->pixels[0],
            0, ((480)+(((((((0 +480)>>1))-(480))*((zoom))))>>8)),
            640, 480,
            (flame), 0, 0, ((flame)[0]), ((flame)[1]), (1));
    } else {
        image_draw(
            yeti->viewport.back->pixels[0],
            0, ((0 +480)>>1),
            640, 480,
            (flame), 0, 0, ((flame)[0]), ((flame)[1]), (1));
    }
}

variable_types: rising int

variable_types:
flames
unsigned short *[]

variable_types:
flame
unsigned short *

variable_types: zoom int

user_defined_types: struct yeti_t { struct game_t game; unsigned int mark; unsigned int fps; struct entity_t *camera; struct entity_t *player; struct entity_t *player2; struct visual_t visual; struct viewport_t viewport; struct keyboard_t keyboard; struct message_t message; struct map_t map; int is2d; int m[3][4]; struct entity_array_t entities; struct vertex_pool_t vpool; struct surface_array_t surfaces; struct bullet_array_t bullets; unsigned char (*textures)[64][64]; unsigned char (*palette)[3]; unsigned short luas[4][64][256]; unsigned short *skyimage; struct vertex_t verts[500]; void (*onhit)(struct yeti_t *yeti, struct entity_t *e1, struct entity_t *e2); }

user_defined_types: struct game_t { short gravity; short jumping; short crawling; short walking; short ceiling; short tick; struct hud_t hud; struct menu_t menu; char prevmode; short episode; }

user_defined_types: struct viewport_t { struct pixel_buffer_t *front; struct pixel_buffer_t *back; }

user_defined_types: struct keyboard_t { unsigned int tick; struct keys_t state; struct keys_t saved; }

user_defined_types: struct surface_array_t { int length; struct surface_t item[128]; }

user_defined_types: struct entity_t { struct entity_t *next; void *tag; struct entity_visual_t visual; struct animation_t animation; unsigned char emitlight; unsigned char castshadow; unsigned char nocollision; unsigned char alwaysvisible; unsigned char alwaysontop; struct entity_state_t state; unsigned short radius; short x; short y; short z; short p; short r; short t; short rx; short ry; short rz; void (*ontick)(struct yeti_t *yeti, struct entity_t *e); void (*onhit)(struct yeti_t *yeti, struct entity_t *e1, struct entity_t *e2); void (*onwall)(struct yeti_t *yeti, struct entity_t *e, struct cell_t *c); }


user_defined_types: struct visual_t { int threshold_dithering; int threshold_perspective; int map_lod; int brightness; }

user_defined_types: struct message_t { char s[256]; unsigned int tick; char *text; }

user_defined_types: struct map_t { int width; struct cell_t item[64][64]; }

user_defined_types: struct entity_array_t { int length; struct entity_t item[70]; }

user_defined_types: struct keys_t { unsigned short left; unsigned short right; unsigned short up; unsigned short down; unsigned short a; unsigned short b; unsigned short r; unsigned short l; unsigned short select; unsigned short start; unsigned short rotate; struct point_t mouse; }

user_defined_types: struct cell_t { unsigned char swi; unsigned char ent; short top; short bot; short eos; short hos; char tos; char bos; short bots[4]; short tops[4]; short tsa; short bsa; unsigned char wtb; unsigned char sw2; short lit; unsigned char wtt; unsigned char ttx; unsigned char btx; unsigned char wwi; char xlod; char ylod; unsigned int mark; struct entity_t *entities; unsigned char vcache_size; struct vertex_t *vcache[3]; }


decompiled_code:
__int64 __fastcall screen_publisher(__int64 a1)
{
int v1; // eax
__int64 v2; // rdi
int v3; // esi

v1 = *(unsigned __int8 *)(a1 + 10);
v2 = *(_QWORD *)(a1 + 80);
v3 = 4 * v1;
if ( v1 > 64 )
v3 = 256;
return image_draw(
v2,
(unsigned int)(((-320 * v3) >> 8) + 320),
(unsigned int)(((-15 * v3) >> 4) + 240),
((unsigned int)(5 * v3) >> 2) + 320,
(unsigned int)(((240 * v3) >> 8) + 240),
&spr_publisher,
0LL,
0LL,
spr_publisher,
*((unsigned __int16 *)&spr_publisher + 1),
4LL);
}

user_defined_types: struct vertex_pool_t { int length; struct vertex_t item[1024]; }

user_defined_types: struct bullet_array_t { int length; struct entity_t *item[8]; }

user_defined_types: struct hud_t { unsigned char health; unsigned char ammo; }

user_defined_types: struct menu_t { char main; char skill; char episode; char paused; char option; char language; }

user_defined_types: struct entity_visual_t { unsigned char altpitch; unsigned char altroll; unsigned char altturn; unsigned char mode; short width; short height; void *data; void (*ondraw)(struct yeti_t *yeti, struct entity_t *e); }

user_defined_types: struct animation_t { char mode; unsigned char nloops; unsigned short pos; unsigned short start; unsigned short length; unsigned short end; unsigned short speed; }


user_defined_types: struct yeti_t { struct game_t game; unsigned int mark; unsigned int fps; struct entity_t *camera; struct entity_t *player; struct entity_t *player2; struct visual_t visual; struct viewport_t viewport; struct keyboard_t keyboard; struct message_t message; struct map_t map; int is2d; int m[3][4]; struct entity_array_t entities; struct vertex_pool_t vpool; struct surface_array_t surfaces; struct bullet_array_t bullets; unsigned char (*textures)[64][64]; unsigned char (*palette)[3]; unsigned short luas[4][64][256]; unsigned short *skyimage; struct vertex_t verts[500]; void (*onhit)(struct yeti_t *yeti, struct entity_t *e1, struct entity_t *e2); }

user_defined_types: struct game_t { short gravity; short jumping; short crawling; short walking; short ceiling; short tick; struct hud_t hud; struct menu_t menu; char prevmode; short episode; }

user_defined_types: struct entity_state_t { unsigned short pain; }

user_defined_types: struct pixel_buffer_t { unsigned short pixels[480][640]; }

user_defined_types: struct surface_t { unsigned char xsize; unsigned char ysize; unsigned char mode; short xpan; short ypan; }

user_defined_types: struct vertex_t { int x; int y; int z; int l; int d; int i; int u; int v; int sx; int sy; }


original_code:
void screen_menu(yeti_t *yeti)
{
    u16 *animation[] = {spr_blood0, spr_blood1, spr_blood2, spr_blood3};
    u16 *frame = animation[(yeti->game.tick >> 3) & 3];
    screen_flames(yeti, 0);
    if (yeti->game.menu.main < 0) {
        yeti->game.menu.main = 0;
    }
    if (yeti->game.menu.main > 3) {
        yeti->game.menu.main = 3;
    }
    image_draw(
        yeti->viewport.back->pixels[0],
        0, 0, (640 -0), 48,
        (frame), 0, 0, ((frame)[0]), ((frame)[1]), (1));
    draw_string(yeti->viewport.back, 0, 1, "The Temple", 5, 4, (0), 0);
    draw_menu_item(yeti, 6, 2, "New Game" , 4, 5, yeti->game.menu.main == 0);
    draw_menu_item(yeti, 6, 3, "Options" , 4, 5, yeti->game.menu.main == 1);
    draw_menu_item(yeti, 6, 4, "Load Game" , 4, 5, yeti->game.menu.main == 2);
    draw_menu_item(yeti, 6, 5, "Credits" , 4, 5, yeti->game.menu.main == 3);
}

canonical_original_code:
void screen_menu(struct yeti_t *yeti)
{
    unsigned short *animation[] = {spr_blood0, spr_blood1, spr_blood2, spr_blood3};
    unsigned short *frame = animation[(yeti->game.tick >> 3) & 3];
    screen_flames(yeti, 0);
    if (yeti->game.menu.main < 0) {
        yeti->game.menu.main = 0;
    }
    if (yeti->game.menu.main > 3) {
        yeti->game.menu.main = 3;
    }
    image_draw(
        yeti->viewport.back->pixels[0],
        0, 0, (640 -0), 48,
        (frame), 0, 0, ((frame)[0]), ((frame)[1]), (1));
    draw_string(yeti->viewport.back, 0, 1, "The Temple", 5, 4, (0), 0);
    draw_menu_item(yeti, 6, 2, "New Game" , 4, 5, yeti->game.menu.main == 0);
    draw_menu_item(yeti, 6, 3, "Options" , 4, 5, yeti->game.menu.main == 1);
    draw_menu_item(yeti, 6, 4, "Load Game" , 4, 5, yeti->game.menu.main == 2);
    draw_menu_item(yeti, 6, 5, "Credits" , 4, 5, yeti->game.menu.main == 3);
}

variable_types:
animation
unsigned short *[]

variable_types:
frame
unsigned short *

user_defined_types: struct visual_t { int threshold_dithering; int threshold_perspective; int map_lod; int brightness; }

user_defined_types: struct viewport_t { struct pixel_buffer_t *front; struct pixel_buffer_t *back; }

user_defined_types: struct keyboard_t { unsigned int tick; struct keys_t state; struct keys_t saved; }

user_defined_types: struct message_t { char s[256]; unsigned int tick; char *text; }

user_defined_types: struct surface_array_t { int length; struct surface_t item[128]; }

user_defined_types: struct entity_t { struct entity_t *next; void *tag; struct entity_visual_t visual; struct animation_t animation; unsigned char emitlight; unsigned char castshadow; unsigned char nocollision; unsigned char alwaysvisible; unsigned char alwaysontop; struct entity_state_t state; unsigned short radius; short x; short y; short z; short p; short r; short t; short rx; short ry; short rz; void (*ontick)(struct yeti_t *yeti, struct entity_t *e); void (*onhit)(struct yeti_t *yeti, struct entity_t *e1, struct entity_t *e2); void (*onwall)(struct yeti_t *yeti, struct entity_t *e, struct cell_t *c); }


original_code:
void screen_episode(yeti_t *yeti)
{
    screen_flames(yeti, 0);
    yeti->game.menu.episode = ((((yeti->game.menu.episode)>(0)? (yeti->game.menu.episode):(0)))<(2)? (((yeti->game.menu.episode)>(0)? (yeti->game.menu.episode):(0))):(2));
    draw_string(yeti->viewport.back, 3, 1, "Select Episode", 4, 5, (0), 0);
    draw_menu_item(yeti, 5, 3, "Evil Dead" , 4, 5, yeti->game.menu.episode == 0);
    draw_menu_item(yeti, 3, 4, "Secret Caverns" , 4, 5, yeti->game.menu.episode == 1);
    draw_menu_item(yeti, 5, 5, "The Temple" , 4, 5, yeti->game.menu.episode == 2);
}

canonical_original_code:
void screen_episode(struct yeti_t *yeti)
{
    screen_flames(yeti, 0);
    yeti->game.menu.episode = ((((yeti->game.menu.episode)>(0)? (yeti->game.menu.episode):(0)))<(2)? (((yeti->game.menu.episode)>(0)? (yeti->game.menu.episode):(0))):(2));
    draw_string(yeti->viewport.back, 3, 1, "Select Episode", 4, 5, (0), 0);
    draw_menu_item(yeti, 5, 3, "Evil Dead" , 4, 5, yeti->game.menu.episode == 0);
    draw_menu_item(yeti, 3, 4, "Secret Caverns" , 4, 5, yeti->game.menu.episode == 1);
    draw_menu_item(yeti, 5, 5, "The Temple" , 4, 5, yeti->game.menu.episode == 2);
}

user_defined_types: struct map_t { int width; struct cell_t item[64][64]; }

user_defined_types: struct entity_array_t { int length; struct entity_t item[70]; }

user_defined_types: struct vertex_pool_t { int length; struct vertex_t item[1024]; }

user_defined_types: struct bullet_array_t { int length; struct entity_t *item[8]; }

user_defined_types: struct keys_t { unsigned short left; unsigned short right; unsigned short up; unsigned short down; unsigned short a; unsigned short b; unsigned short r; unsigned short l; unsigned short select; unsigned short start; unsigned short rotate; struct point_t mouse; }

user_defined_types: struct cell_t { unsigned char swi; unsigned char ent; short top; short bot; short eos; short hos; char tos; char bos; short bots[4]; short tops[4]; short tsa; short bsa; unsigned char wtb; unsigned char sw2; short lit; unsigned char wtt; unsigned char ttx; unsigned char btx; unsigned char wwi; char xlod; char ylod; unsigned int mark; struct entity_t *entities; unsigned char vcache_size; struct vertex_t *vcache[3]; }


original_code:
void screen_skill(yeti_t *yeti)
{
    screen_flames(yeti, 0);
    yeti->game.menu.skill = ((((yeti->game.menu.skill)>(0)? (yeti->game.menu.skill):(0)))<(2)? (((yeti->game.menu.skill)>(0)? (yeti->game.menu.skill):(0))):(2));
    draw_string(yeti->viewport.back, 4, 1, "Choose Skill", 4, 5, (0), 0);
    draw_menu_item(yeti, 8, 3, "Easy" , 4, 5, yeti->game.menu.skill == 0);
    draw_menu_item(yeti, 7, 4, "Normal" , 4, 5, yeti->game.menu.skill == 1);
    draw_menu_item(yeti, 5, 5, "Nightmare!" , 4, 5, yeti->game.menu.skill == 2);
}

canonical_original_code:
void screen_skill(struct yeti_t *yeti)
{
    screen_flames(yeti, 0);
    yeti->game.menu.skill = ((((yeti->game.menu.skill)>(0)? (yeti->game.menu.skill):(0)))<(2)? (((yeti->game.menu.skill)>(0)? (yeti->game.menu.skill):(0))):(2));
    draw_string(yeti->viewport.back, 4, 1, "Choose Skill", 4, 5, (0), 0);
    draw_menu_item(yeti, 8, 3, "Easy" , 4, 5, yeti->game.menu.skill == 0);
    draw_menu_item(yeti, 7, 4, "Normal" , 4, 5, yeti->game.menu.skill == 1);
    draw_menu_item(yeti, 5, 5, "Nightmare!" , 4, 5, yeti->game.menu.skill == 2);
}

user_defined_types: struct yeti_t { struct game_t game; unsigned int mark; unsigned int fps; struct entity_t *camera; struct entity_t *player; struct entity_t *player2; struct visual_t visual; struct viewport_t viewport; struct keyboard_t keyboard; struct message_t message; struct map_t map; int is2d; int m[3][4]; struct entity_array_t entities; struct vertex_pool_t vpool; struct surface_array_t surfaces; struct bullet_array_t bullets; unsigned char (*textures)[64][64]; unsigned char (*palette)[3]; unsigned short luas[4][64][256]; unsigned short *skyimage; struct vertex_t verts[500]; void (*onhit)(struct yeti_t *yeti, struct entity_t *e1, struct entity_t *e2); }

user_defined_types: struct game_t { short gravity; short jumping; short crawling; short walking; short ceiling; short tick; struct hud_t hud; struct menu_t menu; char prevmode; short episode; }

user_defined_types: struct hud_t { unsigned char health; unsigned char ammo; }

user_defined_types: struct menu_t { char main; char skill; char episode; char paused; char option; char language; }

user_defined_types: struct entity_visual_t { unsigned char altpitch; unsigned char altroll; unsigned char altturn; unsigned char mode; short width; short height; void *data; void (*ondraw)(struct yeti_t *yeti, struct entity_t *e); }

user_defined_types: struct animation_t { char mode; unsigned char nloops; unsigned short pos; unsigned short start; unsigned short length; unsigned short end; unsigned short speed; }


decompiled_code:
__int64 __fastcall screen_credits(__int64 a1)
{
__int64 v2; // [rsp-10h] [rbp-18h]

screen_flames(a1, 0);
draw_string(*(_QWORD *)(a1 + 80), 0LL, 0LL, "Developer:", 4LL, 4LL, 0LL, 0LL);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 1LL, "Derek Evans", 4LL, 4LL, 0LL, 128LL);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 2LL, "AlienKinetics", 4LL, 4LL, 0LL, 128LL);
draw_string(*(_QWORD *)(a1 + 80), 0LL, 4LL, "Special Thanks:", 4LL, 4LL, 0LL, 0LL);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 5LL, "Greg Torlus", 4LL, 4LL, 0LL, 128LL);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 6LL, "Matt ThunderZ", 4LL, 4LL, 0LL, 128LL);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 7LL, "Phil Harvey", 4LL, 4LL, 0LL, 128LL);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 8LL, "Sean Cross", 4LL, 4LL, 0LL, 128LL);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 9LL, "Aardappel", 4LL, 4LL, 0LL, 128LL);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 v2; // [rsp-10h] [rbp-18h]

func2(a1, 0);
draw_string(*(_QWORD *)(a1 + 80), 0LL, 0LL, "Developer:", 4LL, 4LL, 0LL, 0LL);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 1LL, "Derek Evans", 4LL, 4LL, 0LL, 128LL);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 2LL, "AlienKinetics", 4LL, 4LL, 0LL, 128LL);
draw_string(*(_QWORD *)(a1 + 80), 0LL, 4LL, "Special Thanks:", 4LL, 4LL, 0LL, 0LL);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 5LL, "Greg Torlus", 4LL, 4LL, 0LL, 128LL);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 6LL, "Matt ThunderZ", 4LL, 4LL, 0LL, 128LL);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 7LL, "Phil Harvey", 4LL, 4LL, 0LL, 128LL);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 8LL, "Sean Cross", 4LL, 4LL, 0LL, 128LL);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 9LL, "Aardappel", 4LL, 4LL, 0LL, 128LL);
return v2;
}

original_code:
void screen_credits(yeti_t *yeti)
{
    int x = 4, y = 4, l = 0;
    screen_flames(yeti, 0);
    draw_string(yeti->viewport.back, 0, l++, "Developer:" , x, y, (0), 0);
    draw_string(yeti->viewport.back, 1, l++, "Derek Evans" , x, y, (0), 128);
    draw_string(yeti->viewport.back, 1, l++, "AlienKinetics" , x, y, (0), 128);
    l++;
    draw_string(yeti->viewport.back, 0, l++, "Special Thanks:" , x, y, (0), 0);
    draw_string(yeti->viewport.back, 1, l++, "Greg Torlus" , x, y, (0), 128);
    draw_string(yeti->viewport.back, 1, l++, "Matt ThunderZ" , x, y, (0), 128);
    draw_string(yeti->viewport.back, 1, l++, "Phil Harvey" , x, y, (0), 128);
    draw_string(yeti->viewport.back, 1, l++, "Sean Cross" , x, y, (0), 128);
    draw_string(yeti->viewport.back, 1, l++, "Aardappel" , x, y, (0), 128);
}

canonical_original_code:
void screen_credits(struct yeti_t *yeti)
{
    int x = 4; int y = 4; int l = 0;
    screen_flames(yeti, 0);
    draw_string(yeti->viewport.back, 0, l++, "Developer:" , x, y, (0), 0);
    draw_string(yeti->viewport.back, 1, l++, "Derek Evans" , x, y, (0), 128);
    draw_string(yeti->viewport.back, 1, l++, "AlienKinetics" , x, y, (0), 128);
    l++;
    draw_string(yeti->viewport.back, 0, l++, "Special Thanks:" , x, y, (0), 0);
    draw_string(yeti->viewport.back, 1, l++, "Greg Torlus" , x, y, (0), 128);
    draw_string(yeti->viewport.back, 1, l++, "Matt ThunderZ" , x, y, (0), 128);
    draw_string(yeti->viewport.back, 1, l++, "Phil Harvey" , x, y, (0), 128);
    draw_string(yeti->viewport.back, 1, l++, "Sean Cross" , x, y, (0), 128);
    draw_string(yeti->viewport.back, 1, l++, "Aardappel" , x, y, (0), 128);
}

variable_types: x int

variable_types: l int

user_defined_types: struct visual_t { int threshold_dithering; int threshold_perspective; int map_lod; int brightness; }

user_defined_types: struct viewport_t { struct pixel_buffer_t *front; struct pixel_buffer_t *back; }

user_defined_types: struct entity_state_t { unsigned short pain; }

user_defined_types: struct pixel_buffer_t { unsigned short pixels[480][640]; }

user_defined_types: struct surface_t { unsigned char xsize; unsigned char ysize; unsigned char mode; short xpan; short ypan; }

user_defined_types: struct vertex_t { int x; int y; int z; int l; int d; int i; int u; int v; int sx; int sy; }


decompiled_code:
__int64 __fastcall draw_option(__int64 a1, unsigned int a2, unsigned int a3, __int64 a4, unsigned int a5, unsigned int a6, int a7, unsigned int a8)
{
__int64 v11; // rax
char *v12; // rax
char v14[88]; // [rsp+0h] [rbp-58h] BYREF

v11 = ansic_stpcpy(v14, a4);
v12 = (char *)ansic_stpcpy(v11, ": ");
if ( a8 )
{
if ( a8 == -1 )
strcpy(v12, "On");
else
ansic_itos(a8, v12);
}
else
{
*(_DWORD *)v12 = 6710863;
}
return draw_menu_item(a1, a2, a3, (__int64)v14, a5, a6, a7);
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, unsigned int a2, unsigned int a3, __int64 a4, unsigned int a5, unsigned int a6, int a7, unsigned int a8)
{
__int64 v11; // rax
char *v12; // rax
char v14[88]; // [rsp+0h] [rbp-58h] BYREF

v11 = ansic_stpcpy(v14, a4);
v12 = (char *)ansic_stpcpy(v11, ": ");
if ( a8 )
{
if ( a8 == -1 )
strcpy(v12, "On");
else
ansic_itos(a8, v12);
}
else
{
*(_DWORD *)v12 = 6710863;
}
return func0(a1, a2, a3, (__int64)v14, a5, a6, a7);
}

original_code:
void draw_option(yeti_t *yeti, int x, int y, char *s, int xs, int ys, int selected, int value)
{
    char tmp[32];
    char *p = ansic_stpcpy(ansic_stpcpy(tmp, s), ": ");
    if (value == 0) {
        strcpy(p, "Off");
    } else if (value == -1) {
        strcpy(p, "On");
    } else {
        ansic_itos(value, p);
    }
    draw_menu_item(yeti, x, y, tmp, xs, ys, selected);
}

canonical_original_code:
void draw_option(struct yeti_t *yeti, int x, int y, char *s, int xs, int ys, int selected, int value)
{
    char tmp[32];
    char *p = ansic_stpcpy(ansic_stpcpy(tmp, s), ": ");
    if (value == 0) {
        strcpy(p, "Off");
    } else if (value == -1) {
        strcpy(p, "On");
    } else {
        ansic_itos(value, p);
    }
    draw_menu_item(yeti, x, y, tmp, xs, ys, selected);
}

variable_types: value int

variable_types:
tmp
char [32]

variable_types:
p
char *

user_defined_types: struct keyboard_t { unsigned int tick; struct keys_t state; struct keys_t saved; }

user_defined_types: struct message_t { char s[256]; unsigned int tick; char *text; }

user_defined_types: struct map_t { int width; struct cell_t item[64][64]; }

user_defined_types: struct entity_array_t { int length; struct entity_t item[70]; }

user_defined_types: struct surface_array_t { int length; struct surface_t item[128]; }

user_defined_types: struct entity_t { struct entity_t *next; void *tag; struct entity_visual_t visual; struct animation_t animation; unsigned char emitlight; unsigned char castshadow; unsigned char nocollision; unsigned char alwaysvisible; unsigned char alwaysontop; struct entity_state_t state; unsigned short radius; short x; short y; short z; short p; short r; short t; short rx; short ry; short rz; void (*ontick)(struct yeti_t *yeti, struct entity_t *e); void (*onhit)(struct yeti_t *yeti, struct entity_t *e1, struct entity_t *e2); void (*onwall)(struct yeti_t *yeti, struct entity_t *e, struct cell_t *c); }


original_code:
void screen_view_options(yeti_t *yeti)
{
    int x = 4, y = 4, l = 0;
    yeti->game.menu.option = ((((yeti->game.menu.option)>(0)? (yeti->game.menu.option):(0)))<(5)? (((yeti->game.menu.option)>(0)? (yeti->game.menu.option):(0))):(5));
    screen_flames(yeti, 0);
    draw_option(yeti, 0, l++, "Messages" , x, y, yeti->game.menu.option == 0, 0);
    draw_option(yeti, 0, l++, "SFX" , x, y, yeti->game.menu.option == 1, 0);
    draw_option(yeti, 0, l++, "Music" , x, y, yeti->game.menu.option == 2, 0);
    draw_option(yeti, 0, l++, "Lighting" , x, y, yeti->game.menu.option == 3, 0);
    draw_option(yeti, 0, l++, "Brightness" , x, y, yeti->game.menu.option == 4, yeti->visual.brightness);
    draw_menu_item(yeti, 0, l++, "Set Controls" , x, y, yeti->game.menu.option == 5);
}

canonical_original_code:
void screen_view_options(struct yeti_t *yeti)
{
    int x = 4; int y = 4; int l = 0;
    yeti->game.menu.option = ((((yeti->game.menu.option)>(0)? (yeti->game.menu.option):(0)))<(5)? (((yeti->game.menu.option)>(0)? (yeti->game.menu.option):(0))):(5));
    screen_flames(yeti, 0);
    draw_option(yeti, 0, l++, "Messages" , x, y, yeti->game.menu.option == 0, 0);
    draw_option(yeti, 0, l++, "SFX" , x, y, yeti->game.menu.option == 1, 0);
    draw_option(yeti, 0, l++, "Music" , x, y, yeti->game.menu.option == 2, 0);
    draw_option(yeti, 0, l++, "Lighting" , x, y, yeti->game.menu.option == 3, 0);
    draw_option(yeti, 0, l++, "Brightness" , x, y, yeti->game.menu.option == 4, yeti->visual.brightness);
    draw_menu_item(yeti, 0, l++, "Set Controls" , x, y, yeti->game.menu.option == 5);
}

variable_types: struct yeti_t { struct game_t { short gravity; short jumping; short crawling; short walking; short ceiling; short tick; struct hud_t { unsigned char health; unsigned char ammo; } hud; struct menu_t { char main; char skill; char episode; char paused; char option; char language; } menu; char prevmode; short episode; } game; unsigned int mark; unsigned int fps; struct entity_t { struct entity_t *next; void *tag; struct entity_visual_t { unsigned char altpitch; unsigned char altroll; unsigned char altturn; unsigned char mode; short width; short height; void *data; void (*ondraw)(struct yeti_t *yeti, struct entity_t *e); } visual; struct animation_t { char mode; unsigned char nloops; unsigned short pos; unsigned short start; unsigned short length; unsigned short end; unsigned short speed; } animation; unsigned char emitlight; unsigned char castshadow; unsigned char nocollision; unsigned char alwaysvisible; unsigned char alwaysontop; struct entity_state_t { unsigned short pain; } state; unsigned short radius; short x; short y; short z; short p; short r; short t; short rx; short ry; short rz; void (*ontick)(struct yeti_t *yeti, struct entity_t *e); void (*onhit)(struct yeti_t *yeti, struct entity_t *e1, struct entity_t *e2); void (*onwall)(struct yeti_t *yeti, struct entity_t *e, struct cell_t { unsigned char swi; unsigned char ent; short top; short bot; short eos; short hos; char tos; char bos; short bots[4]; short tops[4]; short tsa; short bsa; unsigned char wtb; unsigned char sw2; short lit; unsigned char wtt; unsigned char ttx; unsigned char btx; unsigned char wwi; char xlod; char ylod; unsigned int mark; struct entity_t *entities; unsigned char vcache_size; struct vertex_t { int x; int y; int z; int l; int d; int i; int u; int v; int sx; int sy; } *vcache[3]; } *c); } *camera; struct entity_t *player; struct entity_t *player2; struct visual_t { int threshold_dithering; int threshold_perspective; int map_lod; int brightness; } visual; struct viewport_t { struct pixel_buffer_t { unsigned short pixels[480][640]; } *front; struct pixel_buffer_t *back; } viewport; struct keyboard_t { unsigned int tick; struct keys_t { unsigned short left; unsigned short right; unsigned short up; unsigned short down; unsigned short a; unsigned short b; unsigned short r; unsigned short l; unsigned short select; unsigned short start; unsigned short rotate; struct point_t { int x; } mouse; } state; struct keys_t saved; } keyboard; struct message_t { char s[256]; unsigned int tick; char *text; } message; struct map_t { int width; struct cell_t item[64][64]; } map; int is2d; int m[3][4]; struct entity_array_t { int length; struct entity_t item[70]; } entities; struct vertex_pool_t { int length; struct vertex_t item[1024]; } vpool; struct surface_array_t { int length; struct surface_t { unsigned char xsize; unsigned char ysize; unsigned char mode; short xpan; short ypan; } item[128]; } surfaces; struct bullet_array_t { int length; struct entity_t *item[8]; } bullets; unsigned char (*textures)[64][64]; unsigned char (*palette)[3]; unsigned short luas[4][64][256]; unsigned short *skyimage; struct vertex_t verts[500]; void (*onhit)(struct yeti_t *yeti, struct entity_t *e1, struct entity_t *e2); } *

variable_types: y int

user_defined_types: struct yeti_t { struct game_t game; unsigned int mark; unsigned int fps; struct entity_t *camera; struct entity_t *player; struct entity_t *player2; struct visual_t visual; struct viewport_t viewport; struct keyboard_t keyboard; struct message_t message; struct map_t map; int is2d; int m[3][4]; struct entity_array_t entities; struct vertex_pool_t vpool; struct surface_array_t surfaces; struct bullet_array_t bullets; unsigned char (*textures)[64][64]; unsigned char (*palette)[3]; unsigned short luas[4][64][256]; unsigned short *skyimage; struct vertex_t verts[500]; void (*onhit)(struct yeti_t *yeti, struct entity_t *e1, struct entity_t *e2); }

user_defined_types: struct game_t { short gravity; short jumping; short crawling; short walking; short ceiling; short tick; struct hud_t hud; struct menu_t menu; char prevmode; short episode; }

user_defined_types: struct keys_t { unsigned short left; unsigned short right; unsigned short up; unsigned short down; unsigned short a; unsigned short b; unsigned short r; unsigned short l; unsigned short select; unsigned short start; unsigned short rotate; struct point_t mouse; }

user_defined_types: struct cell_t { unsigned char swi; unsigned char ent; short top; short bot; short eos; short hos; char tos; char bos; short bots[4]; short tops[4]; short tsa; short bsa; unsigned char wtb; unsigned char sw2; short lit; unsigned char wtt; unsigned char ttx; unsigned char btx; unsigned char wwi; char xlod; char ylod; unsigned int mark; struct entity_t *entities; unsigned char vcache_size; struct vertex_t *vcache[3]; }


decompiled_code:
__int64 __fastcall screen_load_game(__int64 a1)
{
screen_flames(a1, 0);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 1LL, "Load Not", 3LL, 3LL, 0LL, 0LL);
return draw_string(*(_QWORD *)(a1 + 80), 1LL, 2LL, "Avaliable", 3LL, 3LL, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
func2(a1, 0);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 1LL, "Load Not", 3LL, 3LL, 0LL, 0LL);
return draw_string(*(_QWORD *)(a1 + 80), 1LL, 2LL, "Avaliable", 3LL, 3LL, 0LL, 0LL);
}

original_code:
void screen_load_game(yeti_t *yeti)
{
    screen_flames(yeti, 0);
    draw_string(yeti->viewport.back, 1, 1, "Load Not", 3, 3, (0), 0);
    draw_string(yeti->viewport.back, 1, 2, "Avaliable", 3, 3, (0), 0);
}

canonical_original_code:
void screen_load_game(struct yeti_t *yeti)
{
    screen_flames(yeti, 0);
    draw_string(yeti->viewport.back, 1, 1, "Load Not", 3, 3, (0), 0);
    draw_string(yeti->viewport.back, 1, 2, "Avaliable", 3, 3, (0), 0);
}

user_defined_types: struct vertex_pool_t { int length; struct vertex_t item[1024]; }

user_defined_types: struct bullet_array_t { int length; struct entity_t *item[8]; }

user_defined_types: struct hud_t { unsigned char health; unsigned char ammo; }

user_defined_types: struct menu_t { char main; char skill; char episode; char paused; char option; char language; }

user_defined_types: struct entity_visual_t { unsigned char altpitch; unsigned char altroll; unsigned char altturn; unsigned char mode; short width; short height; void *data; void (*ondraw)(struct yeti_t *yeti, struct entity_t *e); }

user_defined_types: struct animation_t { char mode; unsigned char nloops; unsigned short pos; unsigned short start; unsigned short length; unsigned short end; unsigned short speed; }


decompiled_code:
__int64 __fastcall screen_quit_game(__int64 a1)
{
screen_flames(a1, 0);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 1LL, "Quit Not", 3LL, 3LL, 0LL, 0LL);
return draw_string(*(_QWORD *)(a1 + 80), 1LL, 2LL, "Avaliable", 3LL, 3LL, 0LL, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
func2(a1, 0);
draw_string(*(_QWORD *)(a1 + 80), 1LL, 1LL, "Quit Not", 3LL, 3LL, 0LL, 0LL);
return draw_string(*(_QWORD *)(a1 + 80), 1LL, 2LL, "Avaliable", 3LL, 3LL, 0LL, 0LL);
}

original_code:
void screen_quit_game(yeti_t *yeti)
{
    screen_flames(yeti, 0);
    draw_string(yeti->viewport.back, 1, 1, "Quit Not", 3, 3, (0), 0);
    draw_string(yeti->viewport.back, 1, 2, "Avaliable", 3, 3, (0), 0);
}

canonical_original_code:
void screen_quit_game(struct yeti_t *yeti)
{
    screen_flames(yeti, 0);
    draw_string(yeti->viewport.back, 1, 1, "Quit Not", 3, 3, (0), 0);
    draw_string(yeti->viewport.back, 1, 2, "Avaliable", 3, 3, (0), 0);
}

user_defined_types: struct visual_t { int threshold_dithering; int threshold_perspective; int map_lod; int brightness; }

user_defined_types: struct viewport_t { struct pixel_buffer_t *front; struct pixel_buffer_t *back; }

user_defined_types: struct entity_state_t { unsigned short pain; }

user_defined_types: struct pixel_buffer_t { unsigned short pixels[480][640]; }

user_defined_types: struct surface_t { unsigned char xsize; unsigned char ysize; unsigned char mode; short xpan; short ypan; }

user_defined_types: struct vertex_t { int x; int y; int z; int l; int d; int i; int u; int v; int sx; int sy; }


original_code:
void screen_play(yeti_t *yeti)
{
    char s[10];
    yeti_draw(yeti);
    s[0] = 1 + ((yeti->keyboard.tick >> 3) & 1);
    ansic_itos(yeti->game.hud.health, s + 1);
    draw_string(yeti->viewport.back, 1, 13, s, 4, 4, (1), 0);
    s[0] = 3;
    ansic_itos(yeti->game.hud.ammo, s + 1);
    draw_string(yeti->viewport.back, 15, 13, s, 4, 4, (1), 0);
}

canonical_original_code:
void screen_play(struct yeti_t *yeti)
{
    char s[10];
    yeti_draw(yeti);
    s[0] = 1 + ((yeti->keyboard.tick >> 3) & 1);
    ansic_itos(yeti->game.hud.health, s + 1);
    draw_string(yeti->viewport.back, 1, 13, s, 4, 4, (1), 0);
    s[0] = 3;
    ansic_itos(yeti->game.hud.ammo, s + 1);
    draw_string(yeti->viewport.back, 15, 13, s, 4, 4, (1), 0);
}

variable_types:
s
char [10]

user_defined_types: struct keyboard_t { unsigned int tick; struct keys_t state; struct keys_t saved; }

user_defined_types: struct message_t { char s[256]; unsigned int tick; char *text; }

user_defined_types: struct map_t { int width; struct cell_t item[64][64]; }

user_defined_types: struct entity_array_t { int length; struct entity_t item[70]; }

user_defined_types: struct surface_array_t { int length; struct surface_t item[128]; }

user_defined_types: struct entity_t { struct entity_t *next; void *tag; struct entity_visual_t visual; struct animation_t animation; unsigned char emitlight; unsigned char castshadow; unsigned char nocollision; unsigned char alwaysvisible; unsigned char alwaysontop; struct entity_state_t state; unsigned short radius; short x; short y; short z; short p; short r; short t; short rx; short ry; short rz; void (*ontick)(struct yeti_t *yeti, struct entity_t *e); void (*onhit)(struct yeti_t *yeti, struct entity_t *e1, struct entity_t *e2); void (*onwall)(struct yeti_t *yeti, struct entity_t *e, struct cell_t *c); }


original_code:
void screen_paused(yeti_t *yeti)
{
    yeti->game.menu.paused = ((((yeti->game.menu.paused)>(0)? (yeti->game.menu.paused):(0)))<(3)? (((yeti->game.menu.paused)>(0)? (yeti->game.menu.paused):(0))):(3));
    screen_play(yeti);
    draw_string(yeti->viewport.back, 4, 1, "Game Paused", 4, 5, (0), 0);
    draw_menu_item(yeti, 4, 5, "Resume Play" , 4, 4, yeti->game.menu.paused == 0);
    draw_menu_item(yeti, 6, 6, "Options" , 4, 4, yeti->game.menu.paused == 1);
    draw_menu_item(yeti, 5, 7, "Load Game" , 4, 4, yeti->game.menu.paused == 2);
    draw_menu_item(yeti, 5, 8, "Quit Game" , 4, 4, yeti->game.menu.paused == 3);
}

canonical_original_code:
void screen_paused(struct yeti_t *yeti)
{
    yeti->game.menu.paused = ((((yeti->game.menu.paused)>(0)? (yeti->game.menu.paused):(0)))<(3)? (((yeti->game.menu.paused)>(0)? (yeti->game.menu.paused):(0))):(3));
    screen_play(yeti);
    draw_string(yeti->viewport.back, 4, 1, "Game Paused", 4, 5, (0), 0);
    draw_menu_item(yeti, 4, 5, "Resume Play" , 4, 4, yeti->game.menu.paused == 0);
    draw_menu_item(yeti, 6, 6, "Options" , 4, 4, yeti->game.menu.paused == 1);
    draw_menu_item(yeti, 5, 7, "Load Game" , 4, 4, yeti->game.menu.paused == 2);
    draw_menu_item(yeti, 5, 8, "Quit Game" , 4, 4, yeti->game.menu.paused == 3);
}

user_defined_types: struct yeti_t { struct game_t game; unsigned int mark; unsigned int fps; struct entity_t *camera; struct entity_t *player; struct entity_t *player2; struct visual_t visual; struct viewport_t viewport; struct keyboard_t keyboard; struct message_t message; struct map_t map; int is2d; int m[3][4]; struct entity_array_t entities; struct vertex_pool_t vpool; struct surface_array_t surfaces; struct bullet_array_t bullets; unsigned char (*textures)[64][64]; unsigned char (*palette)[3]; unsigned short luas[4][64][256]; unsigned short *skyimage; struct vertex_t verts[500]; void (*onhit)(struct yeti_t *yeti, struct entity_t *e1, struct entity_t *e2); }

user_defined_types: struct game_t { short gravity; short jumping; short crawling; short walking; short ceiling; short tick; struct hud_t hud; struct menu_t menu; char prevmode; short episode; }

user_defined_types: struct vertex_pool_t { int length; struct vertex_t item[1024]; }

user_defined_types: struct bullet_array_t { int length; struct entity_t *item[8]; }

user_defined_types: struct keys_t { unsigned short left; unsigned short right; unsigned short up; unsigned short down; unsigned short a; unsigned short b; unsigned short r; unsigned short l; unsigned short select; unsigned short start; unsigned short rotate; struct point_t mouse; }

user_defined_types: struct cell_t { unsigned char swi; unsigned char ent; short top; short bot; short eos; short hos; char tos; char bos; short bots[4]; short tops[4]; short tsa; short bsa; unsigned char wtb; unsigned char sw2; short lit; unsigned char wtt; unsigned char ttx; unsigned char btx; unsigned char wwi; char xlod; char ylod; unsigned int mark; struct entity_t *entities; unsigned char vcache_size; struct vertex_t *vcache[3]; }


decompiled_code:
// attributes: thunk
__int64 screen_end_level()
{
return yeti_draw();
}

canonical_decompiled_code:
__int64 func16()
{
return yeti_draw();
}

original_code:
void screen_end_level(yeti_t *yeti)
{
    yeti_draw(yeti);
}

canonical_original_code:
void screen_end_level(struct yeti_t *yeti)
{
    yeti_draw(yeti);
}

user_defined_types: struct visual_t { int threshold_dithering; int threshold_perspective; int map_lod; int brightness; }

user_defined_types: struct viewport_t { struct pixel_buffer_t *front; struct pixel_buffer_t *back; }

user_defined_types: struct hud_t { unsigned char health; unsigned char ammo; }

user_defined_types: struct menu_t { char main; char skill; char episode; char paused; char option; char language; }

user_defined_types: struct entity_visual_t { unsigned char altpitch; unsigned char altroll; unsigned char altturn; unsigned char mode; short width; short height; void *data; void (*ondraw)(struct yeti_t *yeti, struct entity_t *e); }

user_defined_types: struct animation_t { char mode; unsigned char nloops; unsigned short pos; unsigned short start; unsigned short length; unsigned short end; unsigned short speed; }


decompiled_code:
__int64 render_frame()
{
int v0; // eax
int v1; // edx

v0 = SDL_GetTicks();
v1 = oldTick;
oldTick = v0;
if ( v1 + 35 - v0 > 0 )
SDL_Delay();
game_loop(yeti);
SDL_UpdateTexture(screen, 0LL, yeti[10], 1280LL);
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, screen, 0LL, 0LL);
return SDL_RenderPresent(renderer);
}

canonical_decompiled_code:
__int64 func0()
{
int v0; // eax
int v1; // edx

v0 = SDL_GetTicks();
v1 = oldTick;
oldTick = v0;
if ( v1 + 35 - v0 > 0 )
SDL_Delay();
game_loop(yeti);
SDL_UpdateTexture(screen, 0LL, yeti[10], 1280LL);
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, screen, 0LL, 0LL);
return SDL_RenderPresent(renderer);
}

original_code:
void render_frame()
{
    int currentTick;
    int waitTicks;
    currentTick = SDL_GetTicks();
    waitTicks = (oldTick + (35)) - currentTick;
    oldTick = currentTick;
    if (waitTicks > 0) {
        SDL_Delay(waitTicks);
    }
    game_loop(&yeti);
    SDL_UpdateTexture(screen, ((void *)0), yeti.viewport.back, (640 -0) * sizeof(u16));
    SDL_RenderClear(renderer);
    SDL_RenderCopy(renderer, screen, ((void *)0), ((void *)0));
    SDL_RenderPresent(renderer);
}

variable_types: currentTick int

variable_types: waitTicks int


tell

repo: klenovic/nucleos-utils

decompiled_code:
ssize_t __fastcall tell(void *buf)
{
size_t v1; // rax

v1 = strlen((const char *)buf);
return write(2, buf, v1);
}

canonical_decompiled_code:
ssize_t __fastcall func7(void *buf)
{
size_t v1; // rax

v1 = strlen((const char *)buf);
return write(2, buf, v1);
}

original_code:
void tell(char *what)
{
 write(2, what, strlen(what));
}

variable_types:
what
char *


main

canonical_name: main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
int v4; // er12
const char **v5; // rbp
char *v6; // rdi

if ( argc <= 1 )
{
tell("Usage: rmdir directory ...\n");
exit(1);
}
v3 = argv + 1;
v4 = 0;
v5 = &argv[(unsigned int)(argc - 2) + 2];
while ( 1 )
{
if ( rmdir(*v3) >= 0 )
{
if ( ++v3 == v5 )
goto LABEL_6;
}
else
{
v6 = (char *)*v3++;
v4 = 1;
report(v6);
if ( v3 == v5 )
LABEL_6:
exit(v4);
}
}
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
const char **v3; // rbx
int v4; // er12
const char **v5; // rbp
char *v6; // rdi

if ( argc <= 1 )
{
func7("Usage: rmdir directory ...\n");
exit(1);
}
v3 = argv + 1;
v4 = 0;
v5 = &argv[(unsigned int)(argc - 2) + 2];
while ( 1 )
{
if ( rmdir(*v3) >= 0 )
{
if ( ++v3 == v5 )
goto LABEL_6;
}
else
{
v6 = (char *)*v3++;
v4 = 1;
func8(v6);
if ( v3 == v5 )
LABEL_6:
exit(v4);
}
}
}

original_code:
int main(int argc, char **argv)
{
 int i, ex= 0;
 if (argc < 2) {
  tell("Usage: rmdir directory ...\n");
  exit(1);
 }
 i=1;
 do {
  if (rmdir(argv[i]) < 0) {
   report(argv[i]);
   ex= 1;
  }
 } while (++i < argc);
 exit(ex);
}

canonical_original_code:
int main(int argc, char **argv)
{
 int i; int ex = 0;
 if (argc < 2) {
  tell("Usage: rmdir directory ...\n");
  exit(1);
 }
 i=1;
 do {
  if (rmdir(argv[i]) < 0) {
   report(argv[i]);
   ex= 1;
  }
 } while (++i < argc);
 exit(ex);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: i int

variable_types: ex int


report

decompiled_code:
ssize_t __fastcall report(void *buf)
{
int *v1; // rax
char *v2; // rbp

v1 = __errno_location();
v2 = strerror(*v1);
tell("rmdir: ");
tell(buf);
tell(": ");
tell(v2);
return tell("\n");
}

canonical_decompiled_code:
ssize_t __fastcall func8(void *buf)
{
int *v1; // rax
char *v2; // rbp

v1 = __errno_location();
v2 = strerror(*v1);
func7("rmdir: ");
func7(buf);
func7(": ");
func7(v2);
return func7("\n");
}

original_code:
void report(char *label)
{
 char *err= strerror((*__errno_location ()));
 tell("rmdir: ");
 tell(label);
 tell(": ");
 tell(err);
 tell("\n");
}

canonical_original_code:
void report(char *label)
{
 char *err = strerror((*__errno_location ()));
 tell("rmdir: ");
 tell(label);
 tell(": ");
 tell(err);
 tell("\n");
}

variable_types:
label
char *

variable_types:
err
char *


selectlog

decompiled_code:
void __fastcall selectlog(int a1)
{
logto = a1;
}

canonical_decompiled_code:
void __fastcall func1(int a1)
{
logto = a1;
}

original_code:
void selectlog(enum logto where)
{
 logto= where;
}

variable_types:
where
enum logto { SYSLOG=0, STDERR=1 }


log

decompiled_code:
double log(int a1, const char *a2, ...)
{
double result; // xmm0_8
gcc_va_list ap; // [rsp+8h] [rbp-D0h] BYREF

va_start(ap, a2);
if ( logto )
{
fprintf(stderr, "%s: ", (const char *)prog_name);
vfprintf(stderr, a2, ap);
}
else
{
vsyslog(a1, a2, ap);
}
return result;
}

canonical_decompiled_code:
double func2(int a1, const char *a2, ...)
{
double result; // xmm0_8
gcc_va_list ap; // [rsp+8h] [rbp-D0h] BYREF

va_start(ap, a2);
if ( logto )
{
fprintf(stderr, "%s: ", (const char *)prog_name);
vfprintf(stderr, a2, ap);
}
else
{
vsyslog(a1, a2, ap);
}
return result;
}

original_code:
void log(int level, const char *fmt, ...)
{
 va_list ap;
 __builtin_va_start(ap,fmt);
 if (logto == SYSLOG) {
  vsyslog(level, fmt, ap);
 } else
 {
  fprintf(stderr, "%s: ", prog_name);
  vfprintf(stderr, fmt, ap);
 }
 __builtin_va_end(ap);
}

canonical_original_code:
void log(int level, char *fmt, ...)
{
 __builtin_va_list ap;
 __builtin_va_start(ap,fmt);
 if (logto == SYSLOG) {
  vsyslog(level, fmt, ap);
 } else
 {
  fprintf(stderr, "%s: ", prog_name);
  vfprintf(stderr, fmt, ap);
 }
 __builtin_va_end(ap);
}

variable_types: level int

variable_types:
fmt
char *


deallocate

decompiled_code:
void __fastcall deallocate(void *a1)
{
if ( a1 )
{
free(a1);
--alloc_count;
}
}

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

original_code:
void deallocate(void *mem)
{
 if (mem != ((void*)0)) {
  free(mem);
  alloc_count--;
 }
}

canonical_original_code:
void deallocate(void *mem)
{
 if (mem != ((void *)0)) {
  free(mem);
  alloc_count--;
 }
}

variable_types:
mem
void *


allocate

decompiled_code:
void *__fastcall allocate(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
{
log(1, "Out of memory, exiting\n");
exit(1);
}
++alloc_count;
return result;
}

canonical_decompiled_code:
void *__fastcall func3(size_t a1)
{
void *result; // rax

result = malloc(a1);
if ( !result )
{
func2(1, "Out of memory, exiting\n");
exit(1);
}
++alloc_count;
return result;
}

original_code:
void *allocate(size_t len)
{
 void *mem;
 if ((mem= malloc(len)) == ((void*)0)) {
  log(1, "Out of memory, exiting\n");
  exit(1);
 }
 alloc_count++;
 return mem;
}

canonical_original_code:
void *allocate(unsigned long len)
{
 void *mem;
 if ((mem= malloc(len)) == ((void *)0)) {
  log(1, "Out of memory, exiting\n");
  exit(1);
 }
 alloc_count++;
 return mem;
}

variable_types:
len
unsigned long

return_type: void *


decompiled_code:
int __fastcall print_usage(const char *a1)
{
return printf("Usage: %s command [arg...]\n", a1);
}

canonical_decompiled_code:
int __fastcall func7(const char *a1)
{
return printf("Usage: %s command [arg...]\n", a1);
}

original_code:
static void print_usage(const char *argv0)
{
 printf("Usage: %s command [arg...]\n", argv0);
}

canonical_original_code:
static void print_usage(char *argv0)
{
 printf("Usage: %s command [arg...]\n", argv0);
}


decompiled_code:
__int64 redirect_tty()
{
int v0; // ebp
__int64 result; // rax
char *v2; // rcx
char v3[4120]; // [rsp+0h] [rbp-1018h] BYREF

if ( !isatty(1) )
goto LABEL_7;
v0 = open("nohup.out", 1089, 384LL);
if ( v0 < 0 )
{
v2 = getenv("HOME");
if ( !v2 || (snprintf(v3, 0x1001uLL, "%s/%s", v2, "nohup.out"), v3[4096] = 0, v0 = open(v3, 1089, 384LL), v0 < 0) )
{
perror("cannot create nohup.out and $HOME/nohup.out");
return 0xFFFFFFFFLL;
}
}
if ( dup2(v0, 1) < 0 || close(v0) < 0 )
{
perror("cannot redirect stdout");
result = 0xFFFFFFFFLL;
}
else
{
LABEL_7:
if ( isatty(2) && dup2(1, 2) < 0 )
{
perror("cannot redirect stderr");
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 func8()
{
int v0; // ebp
__int64 result; // rax
char *v2; // rcx
char v3[4120]; // [rsp+0h] [rbp-1018h] BYREF

if ( !isatty(1) )
goto LABEL_7;
v0 = open("nohup.out", 1089, 384LL);
if ( v0 < 0 )
{
v2 = getenv("HOME");
if ( !v2 || (snprintf(v3, 0x1001uLL, "%s/%s", v2, "nohup.out"), v3[4096] = 0, v0 = open(v3, 1089, 384LL), v0 < 0) )
{
perror("cannot create nohup.out and $HOME/nohup.out");
return 0xFFFFFFFFLL;
}
}
if ( dup2(v0, 1) < 0 || close(v0) < 0 )
{
perror("cannot redirect stdout");
result = 0xFFFFFFFFLL;
}
else
{
LABEL_7:
if ( isatty(2) && dup2(1, 2) < 0 )
{
perror("cannot redirect stderr");
result = 0xFFFFFFFFLL;
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
static int redirect_tty(void)
{
 int fd;
 char buffer[4096 + 1], *home;
 if (isatty(1))
 {
  fd = open("nohup.out", 01 | 02000 | 0100, 0400 | 0200);
  if (fd < 0)
  {
   home = getenv("HOME");
   if (home)
   {
    snprintf(buffer, sizeof(buffer), "%s/%s", home, "nohup.out");
    buffer[sizeof(buffer) - 1] = 0;
    fd = open(buffer, 01 | 02000 | 0100, 0400 | 0200);
   }
  }
  if (fd < 0)
  {
   perror("cannot create " "nohup.out" " and $HOME/" "nohup.out");
   return -1;
  }
  if (dup2(fd, 1) < 0 || close(fd) < 0)
  {
   perror("cannot redirect stdout");
   return -1;
  }
 }
 if (isatty(2))
 {
  if (dup2(1, 2) < 0)
  {
   perror("cannot redirect stderr");
   return -1;
  }
 }
 return 0;
}

canonical_original_code:
static int redirect_tty()
{
 int fd;
 char buffer[-1]; char *home;
 if (isatty(1))
 {
  fd = open("nohup.out", 01 | 02000 | 0100, 0400 | 0200);
  if (fd < 0)
  {
   home = getenv("HOME");
   if (home)
   {
    snprintf(buffer, sizeof(buffer), "%s/%s", home, "nohup.out");
    buffer[sizeof(buffer) - 1] = 0;
    fd = open(buffer, 01 | 02000 | 0100, 0400 | 0200);
   }
  }
  if (fd < 0)
  {
   perror("cannot create " "nohup.out" " and $HOME/" "nohup.out");
   return -1;
  }
  if (dup2(fd, 1) < 0 || close(fd) < 0)
  {
   perror("cannot redirect stdout");
   return -1;
  }
 }
 if (isatty(2))
 {
  if (dup2(1, 2) < 0)
  {
   perror("cannot redirect stderr");
   return -1;
  }
 }
 return 0;
}

variable_types: fd int

variable_types:
buffer
char [-1]

variable_types:
home
char *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er8
int result; // eax
unsigned int v5; // ecx
struct sigaction v6; // [rsp+0h] [rbp-A8h] BYREF

if ( argc <= 1 )
{
print_usage(*argv);
result = 127;
}
else
{
v6.sa_handler = (__sighandler_t)1;
sigemptyset(&v6.sa_mask);
v6.sa_flags = 0;
if ( sigaction(1, &v6, 0LL) < 0 )
{
perror("cannot ignore SIGHUP");
result = 127;
}
else
{
v3 = redirect_tty(1LL);
result = 127;
if ( v3 >= 0 )
{
execvp(argv[1], (char *const *)argv + 1);
perror("cannot execute");
v5 = *__errno_location();
if ( v5 > 0x28 )
result = 126;
else
result = 127 - (((1LL << v5) & 0x11000100004LL) == 0);
}
}
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er8
int result; // eax
unsigned int v5; // ecx
struct sigaction v6; // [rsp+0h] [rbp-A8h] BYREF

if ( argc <= 1 )
{
func7(*argv);
result = 127;
}
else
{
v6.sa_handler = (__sighandler_t)1;
sigemptyset(&v6.sa_mask);
v6.sa_flags = 0;
if ( sigaction(1, &v6, 0LL) < 0 )
{
perror("cannot ignore SIGHUP");
result = 127;
}
else
{
v3 = func8(1LL);
result = 127;
if ( v3 >= 0 )
{
execvp(argv[1], (char *const *)argv + 1);
perror("cannot execute");
v5 = *__errno_location();
if ( v5 > 0x28 )
result = 126;
else
result = 127 - (((1LL << v5) & 0x11000100004LL) == 0);
}
}
}
return result;
}

original_code:
int main(int argc, char **argv)
{
 struct sigaction sa;
 if (argc < 2)
 {
  print_usage(argv[0]);
  return 127;
 }
 sa.__sigaction_handler.sa_handler = ((__sighandler_t) 1);
 sigemptyset(&sa.sa_mask);
 sa.sa_flags = 0;
 if (sigaction(1, &sa, ((void *)0)) < 0)
 {
  perror("cannot ignore SIGHUP");
  return 127;
 }
 if (redirect_tty() < 0)
  return 127;
 execvp(argv[1], argv + 1);
 perror("cannot execute");
 switch ((*__errno_location ()))
 {
  case 40:
  case 36:
  case 2:
  case 20:
   return 127;
  default:
   return 126;
 }
}

canonical_original_code:
int main(int argc, char **argv)
{
 struct sigaction sa;
 if (argc < 2)
 {
  print_usage(argv[0]);
  return 127;
 }
 sa.__sigaction_handler.sa_handler = ((void (*)(int)) 1);
 sigemptyset(&sa.sa_mask);
 sa.sa_flags = 0;
 if (sigaction(1, &sa, ((void *)0)) < 0)
 {
  perror("cannot ignore SIGHUP");
  return 127;
 }
 if (redirect_tty() < 0)
  return 127;
 execvp(argv[1], argv + 1);
 perror("cannot execute");
 switch ((*__errno_location ()))
 {
  case 40:
  case 36:
  case 2:
  case 20:
   return 127;
  default:
   return 126;
 }
}

variable_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval { int sival_int; void *sival_ptr; } si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; } *, void *); } __sigaction_handler; struct __sigset_t { unsigned long __val[-1]; } sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct sigaction { union { void (*sa_handler)(int); void (*sa_sigaction)(int, struct siginfo_t *, void *); } __sigaction_handler; struct __sigset_t sa_mask; int sa_flags; void (*sa_restorer)(); }

user_defined_types: struct siginfo_t { int si_signo; int si_errno; int si_code; int __pad0; union { int _pad[-1]; struct { int si_pid; unsigned int si_uid; } _kill; struct { int si_tid; int si_overrun; union sigval si_sigval; } _timer; struct { int si_pid; unsigned int si_uid; union sigval si_sigval; } _rt; struct { int si_pid; unsigned int si_uid; int si_status; long si_utime; long si_stime; } _sigchld; struct { void *si_addr; short si_addr_lsb; union { struct { void *_lower; void *_upper; } _addr_bnd; unsigned int _pkey; } _bounds; } _sigfault; struct { long si_band; int si_fd; } _sigpoll; struct { void *_call_addr; int _syscall; unsigned int _arch; } _sigsys; } _sifields; }


opentab

decompiled_code:
__int64 __fastcall opentab(__uid_t uid, char *file, int a3)
{
int *v4; // rax
int *v5; // rbp
unsigned int v6; // er12
int v8; // er15
__uid_t v9; // er14
int v10; // eax
int v11; // ebx

v4 = _errno_location();
v5 = v4;
if ( a3 == 114 )
{
v8 = 0;
goto LABEL_6;
}
if ( a3 == 119 )
{
v8 = 577;
LABEL_6:
v9 = geteuid();
seteuid(uid);
v10 = open(file, v8, 438LL);
v11 = *v5;
v6 = v10;
seteuid(v9);
*v5 = v11;
return v6;
}
*v4 = 22;
return (unsigned int)-1;
}

canonical_decompiled_code:
__int64 __fastcall func1(__uid_t uid, char *file, int a3)
{
int *v4; // rax
int *v5; // rbp
unsigned int v6; // er12
int v8; // er15
__uid_t v9; // er14
int v10; // eax
int v11; // ebx

v4 = _errno_location();
v5 = v4;
if ( a3 == 114 )
{
v8 = 0;
goto LABEL_6;
}
if ( a3 == 119 )
{
v8 = 577;
LABEL_6:
v9 = geteuid();
seteuid(uid);
v10 = open(file, v8, 438LL);
v11 = *v5;
v6 = v10;
seteuid(v9);
*v5 = v11;
return v6;
}
*v4 = 22;
return (unsigned int)-1;
}

original_code:
static int opentab(int uid, char *file, int how)
{
 uid_t safe_uid;
 int flags, r, err;
 switch (how) {
 case 'r': flags= 00; break;
 case 'w': flags= 01 | 0100 | 01000; break;
 default: (*__errno_location ())= 22; return -1;
 }
 safe_uid= geteuid();
 seteuid(uid);
 r= open(file, flags, 0666);
 err= (*__errno_location ());
 seteuid(safe_uid);
 (*__errno_location ())= err;
 return r;
}

canonical_original_code:
static int opentab(int uid, char *file, int how)
{
 unsigned int safe_uid;
 int flags; int r; int err;
 switch (how) {
 case 'r': flags= 00; break;
 case 'w': flags= 01 | 0100 | 01000; break;
 default: (*__errno_location ())= 22; return -1;
 }
 safe_uid= geteuid();
 seteuid(uid);
 r= open(file, flags, 0666);
 err= (*__errno_location ());
 seteuid(safe_uid);
 (*__errno_location ())= err;
 return r;
}

variable_types: uid int

variable_types:
file
char *

variable_types: how int

variable_types: flags int

variable_types: r int

variable_types: err int


copytab

decompiled_code:
__int64 __fastcall copytab(int fd, __int64 a2, int a3, __int64 a4)
{
ssize_t v6; // rax
__int64 result; // rax
char *v8; // r8
int *v9; // rax
int *v10; // rax
char *v11; // rax
_BYTE v12[1064]; // [rsp+0h] [rbp-428h] BYREF

while ( 1 )
{
result = read(fd, v12, 0x400uLL);
if ( result <= 0 )
break;
v6 = write(a3, v12, result);
if ( v6 <= 0 )
{
v8 = "End of file";
if ( v6 )
{
v9 = _errno_location();
v8 = strerror(*v9);
}
fprintf(stderr, "%s: Write error on %s: %s\n", prog_name, a4, v8);
LABEL_9:
exit(1);
}
}
if ( result )
{
v10 = _errno_location();
v11 = strerror(*v10);
fprintf(stderr, "%s: Read error on %s: %s\n", prog_name, a2, v11);
goto LABEL_9;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int fd, __int64 a2, int a3, __int64 a4)
{
ssize_t v6; // rax
__int64 result; // rax
char *v8; // r8
int *v9; // rax
int *v10; // rax
char *v11; // rax
_BYTE v12[1064]; // [rsp+0h] [rbp-428h] BYREF

while ( 1 )
{
result = read(fd, v12, 0x400uLL);
if ( result <= 0 )
break;
v6 = write(a3, v12, result);
if ( v6 <= 0 )
{
v8 = "End of file";
if ( v6 )
{
v9 = _errno_location();
v8 = strerror(*v9);
}
fprintf(stderr, "%s: Write error on %s: %s\n", prog_name, a4, v8);
LABEL_9:
exit(1);
}
}
if ( result )
{
v10 = _errno_location();
v11 = strerror(*v10);
fprintf(stderr, "%s: Read error on %s: %s\n", prog_name, a2, v11);
goto LABEL_9;
}
return result;
}

original_code:
static void copytab(int fd_in, char *file_in, int fd_out, char *file_out)
{
 ssize_t r, w;
 char buf[1024];
 while ((r= read(fd_in, buf, sizeof(buf))) > 0) {
  w= 0;
  while (w < r) {
   if ((r= write(fd_out, buf+w, r-w)) <= 0) {
    fprintf(stderr,
    "%s: Write error on %s: %s\n",
     prog_name,
     file_out,
     r == 0 ? "End of file"
       : strerror((*__errno_location ())));
    exit(1);
   }
   w+= r;
  }
 }
 if (r < 0) {
  fprintf(stderr, "%s: Read error on %s: %s\n",
   prog_name, file_in, strerror((*__errno_location ())));
  exit(1);
 }
}

canonical_original_code:
static void copytab(int fd_in, char *file_in, int fd_out, char *file_out)
{
 long r; long w;
 char buf[1024];
 while ((r= read(fd_in, buf, sizeof(buf))) > 0) {
  w= 0;
  while (w < r) {
   if ((r= write(fd_out, buf+w, r-w)) <= 0) {
    fprintf(stderr,
    "%s: Write error on %s: %s\n",
     prog_name,
     file_out,
     r == 0 ? "End of file"
       : strerror((*__errno_location ())));
    exit(1);
   }
   w+= r;
  }
 }
 if (r < 0) {
  fprintf(stderr, "%s: Read error on %s: %s\n",
   prog_name, file_in, strerror((*__errno_location ())));
  exit(1);
 }
}

variable_types: r long

variable_types: w long

variable_types:
buf
char [1024]


usage

decompiled_code:
void __noreturn usage()
{
fprintf(
stderr,
"Usage: %s -c [user] file # Change crontab\n"
" %s -l [user] # List crontab\n"
" %s -r [user] # Remove crontab\n"
" %s -p # Tell cron to reload\n",
prog_name,
prog_name,
prog_name,
prog_name);
exit(1);
}

canonical_decompiled_code:
void __noreturn func0()
{
fprintf(
stderr,
"Usage: %s -c [user] file # Change crontab\n"
" %s -l [user] # List crontab\n"
" %s -r [user] # Remove crontab\n"
" %s -p # Tell cron to reload\n",
prog_name,
prog_name,
prog_name,
prog_name);
exit(1);
}

original_code:
static void usage(void)
{
 fprintf(stderr,
  "Usage: %s -c [user] file  # Change crontab\n"
  "       %s -l [user]       # List crontab\n"
  "       %s -r [user]       # Remove crontab\n"
  "       %s -p              # Tell cron to reload\n",
  prog_name, prog_name, prog_name, prog_name);
 exit(1);
}

canonical_original_code:
static void usage()
{
 fprintf(stderr,
  "Usage: %s -c [user] file  # Change crontab\n"
  "       %s -l [user]       # List crontab\n"
  "       %s -r [user]       # Remove crontab\n"
  "       %s -p              # Tell cron to reload\n",
  prog_name, prog_name, prog_name, prog_name);
 exit(1);
}


say

decompiled_code:
ssize_t __fastcall say(void *buf)
{
size_t v1; // rax

v1 = strlen((const char *)buf);
return write(2, buf, v1);
}

original_code:
static void say(const char *s)
{
 write(2, s, strlen(s));
}

canonical_original_code:
static void say(char *s)
{
 write(2, s, strlen(s));
}

variable_types:
s
char *


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
int v4; // er14
unsigned int v5; // er15
const char *v6; // rdx
char v7; // al
const char *v8; // rbx
__int64 v9; // rax
unsigned __int64 v10; // rax
int v11; // eax
int v12; // er12
const char **v13; // rbx
int v14; // eax
int v15; // er12
int v16; // eax
int v17; // er12
char *endptr; // [rsp+8h] [rbp-40h] BYREF

if ( argc <= 1 )
{
v4 = 0;
v5 = 0;
v3 = 1;
}
else
{
v3 = 1;
v4 = 0;
v5 = 0;
do
{
v6 = argv[v3];
if ( *v6 != 45 )
break;
v7 = v6[1];
++v3;
v8 = v6 + 1;
if ( *(_WORD *)(v6 + 1) == 45 )
break;
while ( 1 )
{
if ( !v7 )
goto LABEL_16;
++v8;
if ( v7 != 100 )
break;
v7 = *v8;
v4 = 1;
}
if ( v7 != 116 )
goto LABEL_8;
if ( !*v8 )
{
if ( v3 == argc )
goto LABEL_8;
v9 = v3++;
v8 = argv[v9];
}
v10 = strtoul(v8, &endptr, 10);
if ( endptr == v8 )
goto LABEL_8;
if ( *endptr )
goto LABEL_8;
v5 = v10;
if ( (unsigned int)v10 != v10 )
goto LABEL_8;
LABEL_16:
;
}
while ( v3 < argc );
}
if ( argc - v3 <= 0 )
LABEL_8:
usage();
v11 = open("/dev/tty", 2);
v12 = v11;
if ( v11 < 0 )
{
if ( *__errno_location() != 6 )
fatal((void *)"/dev/tty");
if ( v4 )
goto LABEL_32;
if ( setsid() >= 0 )
{
v12 = open("/dev/console", 2);
if ( v12 < 0 )
{
LABEL_23:
__sysv_signal(1, 0LL);
__sysv_signal(2, 0LL);
__sysv_signal(3, 0LL);
__sysv_signal(15, 0LL);
goto LABEL_24;
}
LABEL_20:
if ( v12 )
{
dup2(v12, 0);
close(v12);
}
dup2(0, 1);
dup2(0, 2);
goto LABEL_23;
}
}
else
{
if ( !v4 )
goto LABEL_20;
close(v11);
if ( setsid() >= 0 )
{
LABEL_32:
v14 = open("/dev/null", 2);
v15 = v14;
if ( v14 < 0 )
fatal((void *)"/dev/null");
if ( v14 )
{
dup2(v14, 0);
close(v15);
}
v16 = open(DEV_LOG, 1);
v17 = v16;
if ( v16 < 0 )
fatal(DEV_LOG);
if ( v16 != 1 )
{
dup2(v16, 1);
close(v17);
}
dup2(1, 2);
chdir("/");
LABEL_24:
if ( v5 )
alarm(v5);
v13 = &argv[v3];
execvp(*v13, (char *const *)v13);
fatal((void *)*v13);
}
}
fatal("setsid()");
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
int v4; // er14
unsigned int v5; // er15
const char *v6; // rdx
char v7; // al
const char *v8; // rbx
__int64 v9; // rax
unsigned __int64 v10; // rax
int v11; // eax
int v12; // er12
const char **v13; // rbx
int v14; // eax
int v15; // er12
int v16; // eax
int v17; // er12
char *endptr; // [rsp+8h] [rbp-40h] BYREF

if ( argc <= 1 )
{
v4 = 0;
v5 = 0;
v3 = 1;
}
else
{
v3 = 1;
v4 = 0;
v5 = 0;
do
{
v6 = argv[v3];
if ( *v6 != 45 )
break;
v7 = v6[1];
++v3;
v8 = v6 + 1;
if ( *(_WORD *)(v6 + 1) == 45 )
break;
while ( 1 )
{
if ( !v7 )
goto LABEL_16;
++v8;
if ( v7 != 100 )
break;
v7 = *v8;
v4 = 1;
}
if ( v7 != 116 )
goto LABEL_8;
if ( !*v8 )
{
if ( v3 == argc )
goto LABEL_8;
v9 = v3++;
v8 = argv[v9];
}
v10 = strtoul(v8, &endptr, 10);
if ( endptr == v8 )
goto LABEL_8;
if ( *endptr )
goto LABEL_8;
v5 = v10;
if ( (unsigned int)v10 != v10 )
goto LABEL_8;
LABEL_16:
;
}
while ( v3 < argc );
}
if ( argc - v3 <= 0 )
LABEL_8:
func8();
v11 = open("/dev/tty", 2);
v12 = v11;
if ( v11 < 0 )
{
if ( *__errno_location() != 6 )
func9((void *)"/dev/tty");
if ( v4 )
goto LABEL_32;
if ( setsid() >= 0 )
{
v12 = open("/dev/console", 2);
if ( v12 < 0 )
{
LABEL_23:
__sysv_signal(1, 0LL);
__sysv_signal(2, 0LL);
__sysv_signal(3, 0LL);
__sysv_signal(15, 0LL);
goto LABEL_24;
}
LABEL_20:
if ( v12 )
{
dup2(v12, 0);
close(v12);
}
dup2(0, 1);
dup2(0, 2);
goto LABEL_23;
}
}
else
{
if ( !v4 )
goto LABEL_20;
close(v11);
if ( setsid() >= 0 )
{
LABEL_32:
v14 = open("/dev/null", 2);
v15 = v14;
if ( v14 < 0 )
func9((void *)"/dev/null");
if ( v14 )
{
dup2(v14, 0);
close(v15);
}
v16 = open(DEV_LOG, 1);
v17 = v16;
if ( v16 < 0 )
func9(DEV_LOG);
if ( v16 != 1 )
{
dup2(v16, 1);
close(v17);
}
dup2(1, 2);
chdir("/");
LABEL_24:
if ( v5 )
alarm(v5);
v13 = &argv[v3];
execvp(*v13, (char *const *)v13);
func9((void *)*v13);
}
}
func9("setsid()");
}

original_code:
int main(int argc, char **argv)
{
 int fd;
 unsigned n= 0;
 int daemonize= 0;
 int i;
 i= 1;
 while (i < argc && argv[i][0] == '-') {
  char *opt= argv[i++]+1, *end;
  unsigned long sec;
  if (opt[0] == '-' && opt[1] == 0) break;
  while (*opt != 0) switch (*opt++) {
  case 'd':
   daemonize= 1;
   break;
  case 't':
   if (*opt == 0) {
    if (i == argc) usage();
    opt= argv[i++];
   }
   sec= strtoul(opt, &end, 10);
   if (end == opt || *end != 0 || (n= sec) != sec)
    usage();
   opt= "";
   break;
  default:
   usage();
  }
 }
 if ((argc - i) < 1) usage();
 if ((fd= open("/dev/tty", 02)) < 0) {
  if ((*__errno_location ()) != 6) fatal("/dev/tty");
 }
 if (!daemonize) {
  if (fd < 0) {
   if (setsid() < 0) fatal("setsid()");
   fd= open("/dev/console", 02);
  }
  if (fd >= 0) {
   if (fd != 0) {
    dup2(fd, 0);
    close(fd);
   }
   dup2(0, 1);
   dup2(0, 2);
  }
  signal(1, ((__sighandler_t) 0));
  signal(2, ((__sighandler_t) 0));
  signal(3, ((__sighandler_t) 0));
  signal(15, ((__sighandler_t) 0));
 } else {
  if (fd >= 0) {
   close(fd);
   if (setsid() < 0) fatal("setsid()");
  }
  if ((fd= open("/dev/null", 02)) < 0) fatal("/dev/null");
  if (fd != 0) {
   dup2(fd, 0);
   close(fd);
  }
  if ((fd= open(DEV_LOG, 01)) < 0) fatal(DEV_LOG);
  if (fd != 1) {
   dup2(fd, 1);
   close(fd);
  }
  dup2(1, 2);
  (void) chdir("/");
 }
 if (n != 0) alarm(n);
 execvp(argv[i], argv + i);
 fatal(argv[i]);
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 int fd;
 unsigned int n = 0;
 int daemonize = 0;
 int i;
 i= 1;
 while (i < argc && argv[i][0] == '-') {
  char *opt = argv[i++]+1; char *end;
  unsigned long sec;
  if (opt[0] == '-' && opt[1] == 0) break;
  while (*opt != 0) switch (*opt++) {
  case 'd':
   daemonize= 1;
   break;
  case 't':
   if (*opt == 0) {
    if (i == argc) usage();
    opt= argv[i++];
   }
   sec= strtoul(opt, &end, 10);
   if (end == opt || *end != 0 || (n= sec) != sec)
    usage();
   opt= "";
   break;
  default:
   usage();
  }
 }
 if ((argc - i) < 1) usage();
 if ((fd= open("/dev/tty", 02)) < 0) {
  if ((*__errno_location ()) != 6) fatal("/dev/tty");
 }
 if (!daemonize) {
  if (fd < 0) {
   if (setsid() < 0) fatal("setsid()");
   fd= open("/dev/console", 02);
  }
  if (fd >= 0) {
   if (fd != 0) {
    dup2(fd, 0);
    close(fd);
   }
   dup2(0, 1);
   dup2(0, 2);
  }
  signal(1, ((void (*)(int)) 0));
  signal(2, ((void (*)(int)) 0));
  signal(3, ((void (*)(int)) 0));
  signal(15, ((void (*)(int)) 0));
 } else {
  if (fd >= 0) {
   close(fd);
   if (setsid() < 0) fatal("setsid()");
  }
  if ((fd= open("/dev/null", 02)) < 0) fatal("/dev/null");
  if (fd != 0) {
   dup2(fd, 0);
   close(fd);
  }
  if ((fd= open(DEV_LOG, 01)) < 0) fatal(DEV_LOG);
  if (fd != 1) {
   dup2(fd, 1);
   close(fd);
  }
  dup2(1, 2);
  (void) chdir("/");
 }
 if (n != 0) alarm(n);
 execvp(argv[i], argv + i);
 fatal(argv[i]);
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
n
unsigned int

variable_types: daemonize int

variable_types: i int

variable_types:
opt
char *

variable_types:
end
char *

variable_types:
sec
unsigned long


usage

decompiled_code:
void __noreturn usage()
{
say("Usage: intr [-d] [-t seconds] command [arg ...]\n");
exit(1);
}

canonical_decompiled_code:
void __noreturn func8()
{
func7("Usage: intr [-d] [-t seconds] command [arg ...]\n");
exit(1);
}

original_code:
static void usage(void)
{
 say("Usage: intr [-d] [-t seconds] command [arg ...]\n");
 exit(1);
}

canonical_original_code:
static void usage()
{
 say("Usage: intr [-d] [-t seconds] command [arg ...]\n");
 exit(1);
}


fatal

decompiled_code:
void __fastcall __noreturn fatal(void *buf)
{
int v1; // er12
char *v2; // rax

v1 = *__errno_location();
say("intr: ");
say(buf);
say(": ");
v2 = strerror(v1);
say(v2);
say("\n");
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func9(void *buf)
{
int v1; // er12
char *v2; // rax

v1 = *__errno_location();
func7("intr: ");
func7(buf);
func7(": ");
v2 = strerror(v1);
func7(v2);
func7("\n");
exit(1);
}

original_code:
static void fatal(const char *label)
{
 int err= (*__errno_location ());
 say("intr: ");
 say(label);
 say(": ");
 say(strerror(err));
 say("\n");
 exit(1);
}

canonical_original_code:
static void fatal(char *label)
{
 int err = (*__errno_location ());
 say("intr: ");
 say(label);
 say(": ");
 say(strerror(err));
 say("\n");
 exit(1);
}

variable_types:
label
char *