center

decompiled_code:
int __fastcall center(const char *a1, const char *a2, int a3, char a4, const char *a5)
{
int v7; // er13
int i; // ebx
int v9; // ebx
int v12; // [rsp+10h] [rbp-48h]
char v13; // [rsp+1Ch] [rbp-3Ch]

v13 = a4;
v12 = strlen(a2);
v7 = (int)((double)(a3 - v12 - 2) * 0.5);
printf("%s", a1);
if ( v7 > 0 )
{
for ( i = 0; i != v7; ++i )
putchar(a4);
}
if ( *a2 )
printf(" %s ", a2);
else
printf("%c%c", (unsigned int)v13, (unsigned int)v13);
v9 = v7 + v12 + 2;
if ( a3 > v9 )
{
do
{
putchar(a4);
++v9;
}
while ( a3 != v9 );
}
return printf("%s", a5);
}

canonical_decompiled_code:
int __fastcall func7(const char *a1, const char *a2, int a3, char a4, const char *a5)
{
int v7; // er13
int i; // ebx
int v9; // ebx
int v12; // [rsp+10h] [rbp-48h]
char v13; // [rsp+1Ch] [rbp-3Ch]

v13 = a4;
v12 = strlen(a2);
v7 = (int)((double)(a3 - v12 - 2) * 0.5);
printf("%s", a1);
if ( v7 > 0 )
{
for ( i = 0; i != v7; ++i )
putchar(a4);
}
if ( *a2 )
printf(" %s ", a2);
else
printf("%c%c", (unsigned int)v13, (unsigned int)v13);
v9 = v7 + v12 + 2;
if ( a3 > v9 )
{
do
{
putchar(a4);
++v9;
}
while ( a3 != v9 );
}
return printf("%s", a5);
}

original_code:
void center( char* begin, char* text, int col, char pad, char* end )
{
 int length = strlen(text);
 int i, j = 0.5 * ( col - length - 2 );
 printf("%s", begin);
 for ( i = 0; i < j; i++ ) printf("%c",pad);
 if ( *text != '\0' ) printf(" %s ", text);
 else printf("%c%c", pad, pad);
 j += 2 + length;
 for ( i = j; i < col; i++ ) printf("%c",pad);
 printf("%s", end);
}

canonical_original_code:
void center(char *begin, char *text, int col, char pad, char *end)
{
 int length = strlen(text);
 int i; int j = 0.5 * ( col - length - 2 );
 printf("%s", begin);
 for ( i = 0; i < j; i++ ) printf("%c",pad);
 if ( *text != '\0' ) printf(" %s ", text);
 else printf("%c%c", pad, pad);
 j += 2 + length;
 for ( i = j; i < col; i++ ) printf("%c",pad);
 printf("%s", end);
}

variable_types:
begin
char *

variable_types:
text
char *

variable_types: col int

variable_types: pad char

variable_types:
end
char *

variable_types: length int

variable_types: i int

variable_types: j int


eqcap

decompiled_code:
float __fastcall eqcap(int a1, int a2)
{
return (float)((float)a2 * *(float *)&MCC) / (float)a1;
}

canonical_decompiled_code:
float __fastcall func10(int a1, int a2)
{
return (float)((float)a2 * *(float *)&MCC) / (float)a1;
}

original_code:
float eqcap( int ser, int par )
{
 return par*MCC/ser;
}

canonical_original_code:
float eqcap(int ser, int par)
{
 return par*MCC/ser;
}

variable_types: ser int

variable_types: par int

return_type: float


timeNowUsec

repo: roevhat/matriC

decompiled_code:
__int64 timeNowUsec()
{
struct timeval v1; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v1, 0LL);
return (unsigned int)(LODWORD(v1.tv_usec) + 1000000 * LODWORD(v1.tv_sec));
}

canonical_decompiled_code:
__int64 func0()
{
struct timeval v1; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v1, 0LL);
return (unsigned int)(LODWORD(v1.tv_usec) + 1000000 * LODWORD(v1.tv_sec));
}

original_code:
int timeNowUsec(){
    struct timeval now;
    gettimeofday(&now, ((void *)0));
    return (now.tv_sec) * 1000000 + (now.tv_usec);
}

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

return_type: int


timestampNow

decompiled_code:
unsigned __int64 timestampNow()
{
struct tm *v0; // rax
time_t timer; // [rsp+8h] [rbp-30h] BYREF
char s[40]; // [rsp+10h] [rbp-28h] BYREF

timer = time(0LL);
v0 = localtime(&timer);
sprintf(
s,
"%02i%02i%i%02i%02i%02i",
(unsigned int)v0->tm_mday,
(unsigned int)(v0->tm_mon + 1),
(unsigned int)(v0->tm_year + 1900),
(unsigned int)v0->tm_hour,
(unsigned int)v0->tm_min,
(unsigned int)v0->tm_sec);
return strtoul(s, 0LL, 10);
}

canonical_decompiled_code:
unsigned __int64 func1()
{
struct tm *v0; // rax
time_t timer; // [rsp+8h] [rbp-30h] BYREF
char s[40]; // [rsp+10h] [rbp-28h] BYREF

timer = time(0LL);
v0 = localtime(&timer);
sprintf(
s,
"%02i%02i%i%02i%02i%02i",
(unsigned int)v0->tm_mday,
(unsigned int)(v0->tm_mon + 1),
(unsigned int)(v0->tm_year + 1900),
(unsigned int)v0->tm_hour,
(unsigned int)v0->tm_min,
(unsigned int)v0->tm_sec);
return strtoul(s, 0LL, 10);
}

original_code:
unsigned long timestampNow(){
    char timestamp[32];
    time_t currentTime;
    struct tm * ts;
    currentTime = time(((void *)0));
    ts = localtime(&currentTime);
    sprintf(timestamp,"%02i%02i%i%02i%02i%02i", ts->tm_mday, ts->tm_mon+1, ts->tm_year+1900, ts->tm_hour, ts->tm_min, ts->tm_sec);
    return strtoul(timestamp, ((void *)0), 10);
}

canonical_original_code:
unsigned long timestampNow(){
    char timestamp[32];
    long currentTime;
    struct tm *ts;
    currentTime = time(((void *)0));
    ts = localtime(&currentTime);
    sprintf(timestamp,"%02i%02i%i%02i%02i%02i", ts->tm_mday, ts->tm_mon+1, ts->tm_year+1900, ts->tm_hour, ts->tm_min, ts->tm_sec);
    return strtoul(timestamp, ((void *)0), 10);
}

variable_types:
timestamp
char [32]

variable_types: currentTime long

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

return_type: unsigned long


outputDet

decompiled_code:
__int64 __fastcall outputDet(unsigned int *a1, int a2, int a3)
{
int v4; // er12
unsigned int v5; // ebx
int v7; // er12
float v8; // [rsp+Ch] [rbp-1Ch]

if ( a2 )
{
printf("{INPUT(%ix%i)}\n", *a1, a1[1]);
putchar(10);
printMatrix(a1);
putchar(10);
v7 = timeNowUsec();
v8 = cofactorExpansion(a1, 1LL);
v5 = timeNowUsec() - v7;
puts("{DETERMINANT OF MATRIX}");
putchar(10);
}
else
{
v4 = timeNowUsec();
v8 = cofactorExpansion(a1, 1LL);
v5 = timeNowUsec() - v4;
}
printf("det(INPUT) = %f\n", v8);
if ( a3 )
{
putchar(10);
puts("{TIMER}");
printf("It took %i microseconds!\n", v5);
putchar(10);
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int *a1, int a2, int a3)
{
int v4; // er12
unsigned int v5; // ebx
int v7; // er12
float v8; // [rsp+Ch] [rbp-1Ch]

if ( a2 )
{
printf("{INPUT(%ix%i)}\n", *a1, a1[1]);
putchar(10);
printMatrix(a1);
putchar(10);
v7 = func0();
v8 = cofactorExpansion(a1, 1LL);
v5 = func0() - v7;
puts("{DETERMINANT OF MATRIX}");
putchar(10);
}
else
{
v4 = func0();
v8 = cofactorExpansion(a1, 1LL);
v5 = func0() - v4;
}
printf("det(INPUT) = %f\n", v8);
if ( a3 )
{
putchar(10);
puts("{TIMER}");
printf("It took %i microseconds!\n", v5);
putchar(10);
}
return 1LL;
}

original_code:
int outputDet(matrix * entity, int all, int timer){
    if (all){
        printf("{INPUT(%ix%i)}\n", entity->m, entity->n);
        printf("\n");
        printMatrix(entity);
        printf("\n");
    }
    int t1 = timeNowUsec();
    float det = cofactorExpansion(entity, 1);
    int t2 = timeNowUsec();
    int tDiff = t2-t1;
    if (all){
        printf("%s\n", "{DETERMINANT OF MATRIX}");
        printf("\n");
    }
    printf("det(INPUT) = %f\n", det);
    if (timer){
        printf("\n");
        printf("%s\n", "{TIMER}");
        printf("It took %i microseconds!\n", tDiff);
        printf("\n");
    }
    return 1;
}

canonical_original_code:
int outputDet(struct matrix *entity, int all, int timer){
    if (all){
        printf("{INPUT(%ix%i)}\n", entity->m, entity->n);
        printf("\n");
        printMatrix(entity);
        printf("\n");
    }
    int t1 = timeNowUsec();
    float det = cofactorExpansion(entity, 1);
    int t2 = timeNowUsec();
    int tDiff = t2-t1;
    if (all){
        printf("%s\n", "{DETERMINANT OF MATRIX}");
        printf("\n");
    }
    printf("det(INPUT) = %f\n", det);
    if (timer){
        printf("\n");
        printf("%s\n", "{TIMER}");
        printf("It took %i microseconds!\n", tDiff);
        printf("\n");
    }
    return 1;
}

variable_types: struct matrix { int m; int n; float matrix[100][100]; } *

variable_types: all int

variable_types: timer int

variable_types: det float

variable_types: tDiff int


outputRref

decompiled_code:
__int64 __fastcall outputRref(unsigned int *a1, int a2, int a3)
{
int v4; // er12
__int64 result; // rax
unsigned int v6; // er13
int v7; // er12
unsigned int v8; // er12
unsigned int v9; // eax
int v10[10004]; // [rsp+0h] [rbp-138C8h] BYREF
char v11[40056]; // [rsp+9C50h] [rbp-9C78h] BYREF

if ( a2 )
{
printf("{INPUT(%ix%i)}\n", *a1, a1[1]);
putchar(10);
printMatrix(a1);
putchar(10);
v7 = timeNowUsec();
result = toRowEchelonForm(v11, a1, 1LL);
if ( !(_DWORD)result )
return result;
puts("{ROW ECHELON FORM}");
putchar(10);
printMatrix(v11);
putchar(10);
result = toReducedRowEchelonForm(v10, v11, 1LL);
if ( !(_DWORD)result )
return result;
v6 = timeNowUsec() - v7;
puts("{REDUCED ROW ECHELON FORM}");
putchar(10);
printMatrix(v10);
putchar(10);
puts("{RANK AND NULLITY}");
v8 = matrixNullity(v10);
v9 = matrixRank(v10);
printf("Rank is %i and nullity is %i\n", v9, v8);
}
else
{
v4 = timeNowUsec();
result = toRowEchelonForm(v11, a1, 0LL);
if ( !(_DWORD)result )
return result;
result = toReducedRowEchelonForm(v10, v11, 0LL);
if ( !(_DWORD)result )
return result;
v6 = timeNowUsec() - v4;
printMatrix(v10);
}
if ( a3 )
{
putchar(10);
puts("{TIMER}");
printf("It took %i microseconds!\n", v6);
putchar(10);
}
logToJSON((int *)a1, v10, v6, "rref");
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int *a1, int a2, int a3)
{
int v4; // er12
__int64 result; // rax
unsigned int v6; // er13
int v7; // er12
unsigned int v8; // er12
unsigned int v9; // eax
int v10[10004]; // [rsp+0h] [rbp-138C8h] BYREF
char v11[40056]; // [rsp+9C50h] [rbp-9C78h] BYREF

if ( a2 )
{
printf("{INPUT(%ix%i)}\n", *a1, a1[1]);
putchar(10);
printMatrix(a1);
putchar(10);
v7 = func0();
result = toRowEchelonForm(v11, a1, 1LL);
if ( !(_DWORD)result )
return result;
puts("{ROW ECHELON FORM}");
putchar(10);
printMatrix(v11);
putchar(10);
result = toReducedRowEchelonForm(v10, v11, 1LL);
if ( !(_DWORD)result )
return result;
v6 = func0() - v7;
puts("{REDUCED ROW ECHELON FORM}");
putchar(10);
printMatrix(v10);
putchar(10);
puts("{RANK AND NULLITY}");
v8 = matrixNullity(v10);
v9 = matrixRank(v10);
printf("Rank is %i and nullity is %i\n", v9, v8);
}
else
{
v4 = func0();
result = toRowEchelonForm(v11, a1, 0LL);
if ( !(_DWORD)result )
return result;
result = toReducedRowEchelonForm(v10, v11, 0LL);
if ( !(_DWORD)result )
return result;
v6 = func0() - v4;
printMatrix(v10);
}
if ( a3 )
{
putchar(10);
puts("{TIMER}");
printf("It took %i microseconds!\n", v6);
putchar(10);
}
func3((int *)a1, v10, v6, "rref");
return 1LL;
}

original_code:
int outputRref(matrix * entity, int all, int timer){
    if (all){
        printf("{INPUT(%ix%i)}\n", entity->m, entity->n);
        printf("\n");
        printMatrix(entity);
        printf("\n");
    }
    int t1 = timeNowUsec();
    matrix rowEchelonForm;
    if (all){
        if(!toRowEchelonForm(&rowEchelonForm, entity, 1)){
            return 0;
        }
    } else {
        if(!toRowEchelonForm(&rowEchelonForm, entity, 0)){
            return 0;
        }
    }
    if (all){
        printf("%s\n", "{ROW ECHELON FORM}");
        printf("\n");
        printMatrix(&rowEchelonForm);
        printf("\n");
    }
    matrix reducedRowEchelonForm;
    if (all){
        if(!toReducedRowEchelonForm(&reducedRowEchelonForm, &rowEchelonForm, 1)){
            return 0;
        }
    } else {
        if(!toReducedRowEchelonForm(&reducedRowEchelonForm, &rowEchelonForm, 0)){
            return 0;
        }
    }
    int t2 = timeNowUsec();
    int tDiff = t2-t1;
    if (all){
        printf("%s\n", "{REDUCED ROW ECHELON FORM}");
        printf("\n");
    }
    printMatrix(&reducedRowEchelonForm);
    if (all){
        printf("\n");
        printf("%s\n", "{RANK AND NULLITY}");
        printf("Rank is %i and nullity is %i\n", matrixRank(&reducedRowEchelonForm), matrixNullity(&reducedRowEchelonForm));
    }
    if (timer){
        printf("\n");
        printf("%s\n", "{TIMER}");
        printf("It took %i microseconds!\n", tDiff);
        printf("\n");
    }
    logToJSON(entity, &reducedRowEchelonForm, tDiff, "rref");
    return 1;
}

canonical_original_code:
int outputRref(struct matrix *entity, int all, int timer){
    if (all){
        printf("{INPUT(%ix%i)}\n", entity->m, entity->n);
        printf("\n");
        printMatrix(entity);
        printf("\n");
    }
    int t1 = timeNowUsec();
    struct matrix rowEchelonForm;
    if (all){
        if(!toRowEchelonForm(&rowEchelonForm, entity, 1)){
            return 0;
        }
    } else {
        if(!toRowEchelonForm(&rowEchelonForm, entity, 0)){
            return 0;
        }
    }
    if (all){
        printf("%s\n", "{ROW ECHELON FORM}");
        printf("\n");
        printMatrix(&rowEchelonForm);
        printf("\n");
    }
    struct matrix reducedRowEchelonForm;
    if (all){
        if(!toReducedRowEchelonForm(&reducedRowEchelonForm, &rowEchelonForm, 1)){
            return 0;
        }
    } else {
        if(!toReducedRowEchelonForm(&reducedRowEchelonForm, &rowEchelonForm, 0)){
            return 0;
        }
    }
    int t2 = timeNowUsec();
    int tDiff = t2-t1;
    if (all){
        printf("%s\n", "{REDUCED ROW ECHELON FORM}");
        printf("\n");
    }
    printMatrix(&reducedRowEchelonForm);
    if (all){
        printf("\n");
        printf("%s\n", "{RANK AND NULLITY}");
        printf("Rank is %i and nullity is %i\n", matrixRank(&reducedRowEchelonForm), matrixNullity(&reducedRowEchelonForm));
    }
    if (timer){
        printf("\n");
        printf("%s\n", "{TIMER}");
        printf("It took %i microseconds!\n", tDiff);
        printf("\n");
    }
    logToJSON(entity, &reducedRowEchelonForm, tDiff, "rref");
    return 1;
}

variable_types: struct matrix { int m; int n; float matrix[100][100]; }


outputInverse

decompiled_code:
__int64 __fastcall outputInverse(unsigned int *a1, int a2, int a3)
{
int v4; // er12
__int64 result; // rax
unsigned int v6; // er13
int v7; // er12
int v8[10014]; // [rsp+0h] [rbp-9C78h] BYREF

if ( a2 )
{
printf("{INPUT(%ix%i)}\n", *a1, a1[1]);
putchar(10);
printMatrix(a1);
putchar(10);
v7 = timeNowUsec();
result = inverseOfMatrix(v8, a1);
if ( !(_DWORD)result )
return result;
v6 = timeNowUsec() - v7;
puts("{INVERSE OF MATRIX}");
putchar(10);
}
else
{
v4 = timeNowUsec();
result = inverseOfMatrix(v8, a1);
if ( !(_DWORD)result )
return result;
v6 = timeNowUsec() - v4;
}
printMatrix(v8);
if ( a3 )
{
putchar(10);
puts("{TIMER}");
printf("It took %i microseconds!\n", v6);
putchar(10);
}
logToJSON((int *)a1, v8, v6, "inverse");
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned int *a1, int a2, int a3)
{
int v4; // er12
__int64 result; // rax
unsigned int v6; // er13
int v7; // er12
int v8[10014]; // [rsp+0h] [rbp-9C78h] BYREF

if ( a2 )
{
printf("{INPUT(%ix%i)}\n", *a1, a1[1]);
putchar(10);
printMatrix(a1);
putchar(10);
v7 = func0();
result = inverseOfMatrix(v8, a1);
if ( !(_DWORD)result )
return result;
v6 = func0() - v7;
puts("{INVERSE OF MATRIX}");
putchar(10);
}
else
{
v4 = func0();
result = inverseOfMatrix(v8, a1);
if ( !(_DWORD)result )
return result;
v6 = func0() - v4;
}
printMatrix(v8);
if ( a3 )
{
putchar(10);
puts("{TIMER}");
printf("It took %i microseconds!\n", v6);
putchar(10);
}
func3((int *)a1, v8, v6, "inverse");
return 1LL;
}

original_code:
int outputInverse(matrix * entity, int all, int timer){
    if (all){
        printf("{INPUT(%ix%i)}\n", entity->m, entity->n);
        printf("\n");
        printMatrix(entity);
        printf("\n");
    }
    int t1 = timeNowUsec();
    matrix inverse;
    if(!inverseOfMatrix(&inverse, entity)){
        return 0;
    }
    int t2 = timeNowUsec();
    int tDiff = t2-t1;
    if (all){
        printf("%s\n", "{INVERSE OF MATRIX}");
        printf("\n");
    }
    printMatrix(&inverse);
    if (timer){
        printf("\n");
        printf("%s\n", "{TIMER}");
        printf("It took %i microseconds!\n", tDiff);
        printf("\n");
    }
    logToJSON(entity, &inverse, tDiff, "inverse");
    return 1;
}

canonical_original_code:
int outputInverse(struct matrix *entity, int all, int timer){
    if (all){
        printf("{INPUT(%ix%i)}\n", entity->m, entity->n);
        printf("\n");
        printMatrix(entity);
        printf("\n");
    }
    int t1 = timeNowUsec();
    struct matrix inverse;
    if(!inverseOfMatrix(&inverse, entity)){
        return 0;
    }
    int t2 = timeNowUsec();
    int tDiff = t2-t1;
    if (all){
        printf("%s\n", "{INVERSE OF MATRIX}");
        printf("\n");
    }
    printMatrix(&inverse);
    if (timer){
        printf("\n");
        printf("%s\n", "{TIMER}");
        printf("It took %i microseconds!\n", tDiff);
        printf("\n");
    }
    logToJSON(entity, &inverse, tDiff, "inverse");
    return 1;
}

user_defined_types: struct matrix { int m; int n; float matrix[100][100]; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rbx
int v4; // er13
int v5; // er12
char *v6; // r14
unsigned int v8[10014]; // [rsp+0h] [rbp-9C78h] BYREF

if ( argc <= 2 )
{
puts("matriC needs additional arguments!");
puts("Specify a primary function as an argument:");
puts(" -> R (reduced row echelon form)");
puts(" -> I (inverse)");
puts(" -> D (determinant)");
puts("Additional arguments:");
puts(" -> t (add timer)");
puts(" -> all (verbose output)");
puts(" -> f (specify a file instead of inline matrix)");
}
else
{
v3 = argv[1];
if ( *v3 == 45 )
{
v4 = strchr(v3, 116) != 0LL;
v5 = strstr(v3, "all") != 0LL;
v6 = strchr(v3, 102);
if ( !strchr(v3, 82) )
{
if ( !strchr(v3, 73) )
{
if ( !strchr(v3, 68) )
{
puts("matriC needs a primary function specified as an argument:");
puts(" -> R (reduced row echelon form)");
puts(" -> I (inverse)");
puts(" -> D (determinant)");
return 0;
}
if ( v6 )
{
if ( !(unsigned int)parseInput(v8, argv[2], 1LL) )
return 0;
}
else if ( !(unsigned int)parseInput(v8, argv[2], 0LL) )
{
return 0;
}
outputDet(v8, v5, v4);
return 0;
}
if ( v6 )
{
if ( !(unsigned int)parseInput(v8, argv[2], 1LL) )
return 0;
}
else if ( !(unsigned int)parseInput(v8, argv[2], 0LL) )
{
return 0;
}
outputInverse(v8, v5, v4);
return 0;
}
if ( v6 && (unsigned int)parseInput(v8, argv[2], 1LL) )
outputRref(v8, v5, v4);
}
else
{
puts("With no options specified, you have to many arguments.");
puts("Remember the syntax for options: ma3c -(R/I/D) input_here.");
}
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // rbx
int v4; // er13
int v5; // er12
char *v6; // r14
unsigned int v8[10014]; // [rsp+0h] [rbp-9C78h] BYREF

if ( argc <= 2 )
{
puts("matriC needs additional arguments!");
puts("Specify a primary function as an argument:");
puts(" -> R (reduced row echelon form)");
puts(" -> I (inverse)");
puts(" -> D (determinant)");
puts("Additional arguments:");
puts(" -> t (add timer)");
puts(" -> all (verbose output)");
puts(" -> f (specify a file instead of inline matrix)");
}
else
{
v3 = argv[1];
if ( *v3 == 45 )
{
v4 = strchr(v3, 116) != 0LL;
v5 = strstr(v3, "all") != 0LL;
v6 = strchr(v3, 102);
if ( !strchr(v3, 82) )
{
if ( !strchr(v3, 73) )
{
if ( !strchr(v3, 68) )
{
puts("matriC needs a primary function specified as an argument:");
puts(" -> R (reduced row echelon form)");
puts(" -> I (inverse)");
puts(" -> D (determinant)");
return 0;
}
if ( v6 )
{
if ( !(unsigned int)parseInput(v8, argv[2], 1LL) )
return 0;
}
else if ( !(unsigned int)parseInput(v8, argv[2], 0LL) )
{
return 0;
}
func2(v8, v5, v4);
return 0;
}
if ( v6 )
{
if ( !(unsigned int)parseInput(v8, argv[2], 1LL) )
return 0;
}
else if ( !(unsigned int)parseInput(v8, argv[2], 0LL) )
{
return 0;
}
func5(v8, v5, v4);
return 0;
}
if ( v6 && (unsigned int)parseInput(v8, argv[2], 1LL) )
func4(v8, v5, v4);
}
else
{
puts("With no options specified, you have to many arguments.");
puts("Remember the syntax for options: ma3c -(R/I/D) input_here.");
}
}
return 0;
}

original_code:
int main(int argc, char *argv[]){
    int options = 0;
    int timer = 0;
    int all = 0;
    int file = 0;
    matrix input;
    if (argc <= 2){
        printf("%s\n", "matriC needs additional arguments!");
        printf("%s\n", "Specify a primary function as an argument:");
        printf("%s\n", "    -> R (reduced row echelon form)");
        printf("%s\n", "    -> I (inverse)");
        printf("%s\n", "    -> D (determinant)");
        printf("%s\n", "Additional arguments:");
        printf("%s\n", "    -> t (add timer)");
        printf("%s\n", "    -> all (verbose output)");
        printf("%s\n", "    -> f (specify a file instead of inline matrix)");
    } else {
        if (argv[1][0] == '-'){
            options = 1;
        } else {
            if (argc > 2){
                printf("%s\n", "With no options specified, you have to many arguments.");
                printf("%s\n", "Remember the syntax for options: ma3c -(R/I/D) input_here.");
                return 0;
            }
        }
        if (strstr(argv[1], "t") && options == 1){
            timer = 1;
        }
        if (strstr(argv[1], "all") && options == 1){
            all = 1;
        }
        if (strstr(argv[1], "f") && options == 1){
            file = 1;
        }
        if ((strstr(argv[1], "R") && options == 1) || options == 0){
            if (file){
                if (parseInput(&input, argv[2], 1)){
                    outputRref(&input, all, timer);
                } else {
                    return 0;
                }
            } else {
                if (options == 0 && parseInput(&input, argv[1], 0)){
                    outputRref(&input, all, timer);
                } else {
                    return 0;
                }
                if (options == 1 && parseInput(&input, argv[2], 0)){
                    outputRref(&input, all, timer);
                } else {
                    return 0;
                }
            }
        } else if (strstr(argv[1], "I")){
            if (file){
                if (parseInput(&input, argv[2], 1)){
                    outputInverse(&input, all, timer);
                } else {
                    return 0;
                }
            } else {
                if (parseInput(&input, argv[2], 0)){
                    outputInverse(&input, all, timer);
                } else {
                    return 0;
                }
            }
        } else if (strstr(argv[1], "D")){
            if (file){
                if (parseInput(&input, argv[2], 1)){
                    outputDet(&input, all, timer);
                } else {
                    return 0;
                }
            } else {
                if (parseInput(&input, argv[2], 0)){
                    outputDet(&input, all, timer);
                } else {
                    return 0;
                }
            }
        } else {
            printf("%s\n", "matriC needs a primary function specified as an argument:");
            printf("%s\n", "    -> R (reduced row echelon form)");
            printf("%s\n", "    -> I (inverse)");
            printf("%s\n", "    -> D (determinant)");
        }
    }
}

canonical_original_code:
int main(int argc, char *argv[]){
    int options = 0;
    int timer = 0;
    int all = 0;
    int file = 0;
    struct matrix input;
    if (argc <= 2){
        printf("%s\n", "matriC needs additional arguments!");
        printf("%s\n", "Specify a primary function as an argument:");
        printf("%s\n", "    -> R (reduced row echelon form)");
        printf("%s\n", "    -> I (inverse)");
        printf("%s\n", "    -> D (determinant)");
        printf("%s\n", "Additional arguments:");
        printf("%s\n", "    -> t (add timer)");
        printf("%s\n", "    -> all (verbose output)");
        printf("%s\n", "    -> f (specify a file instead of inline matrix)");
    } else {
        if (argv[1][0] == '-'){
            options = 1;
        } else {
            if (argc > 2){
                printf("%s\n", "With no options specified, you have to many arguments.");
                printf("%s\n", "Remember the syntax for options: ma3c -(R/I/D) input_here.");
                return 0;
            }
        }
        if (strstr(argv[1], "t") && options == 1){
            timer = 1;
        }
        if (strstr(argv[1], "all") && options == 1){
            all = 1;
        }
        if (strstr(argv[1], "f") && options == 1){
            file = 1;
        }
        if ((strstr(argv[1], "R") && options == 1) || options == 0){
            if (file){
                if (parseInput(&input, argv[2], 1)){
                    outputRref(&input, all, timer);
                } else {
                    return 0;
                }
            } else {
                if (options == 0 && parseInput(&input, argv[1], 0)){
                    outputRref(&input, all, timer);
                } else {
                    return 0;
                }
                if (options == 1 && parseInput(&input, argv[2], 0)){
                    outputRref(&input, all, timer);
                } else {
                    return 0;
                }
            }
        } else if (strstr(argv[1], "I")){
            if (file){
                if (parseInput(&input, argv[2], 1)){
                    outputInverse(&input, all, timer);
                } else {
                    return 0;
                }
            } else {
                if (parseInput(&input, argv[2], 0)){
                    outputInverse(&input, all, timer);
                } else {
                    return 0;
                }
            }
        } else if (strstr(argv[1], "D")){
            if (file){
                if (parseInput(&input, argv[2], 1)){
                    outputDet(&input, all, timer);
                } else {
                    return 0;
                }
            } else {
                if (parseInput(&input, argv[2], 0)){
                    outputDet(&input, all, timer);
                } else {
                    return 0;
                }
            }
        } else {
            printf("%s\n", "matriC needs a primary function specified as an argument:");
            printf("%s\n", "    -> R (reduced row echelon form)");
            printf("%s\n", "    -> I (inverse)");
            printf("%s\n", "    -> D (determinant)");
        }
    }
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: options int

variable_types: file int


usage

repo: roganartu/autodjtg

decompiled_code:
void __noreturn usage()
{
puts(
"Usage:\n"
" autodjtg [-h]\n"
" \n"
" This tool automates the usage of djtgcfg from Digilent.\n"
" Currently does not support file paths as arguments.\n"
" In the meantime just run the tool from the directory\n"
" containing the .bit file you wish to program.");
exit(1);
}

canonical_decompiled_code:
void __noreturn func7()
{
puts(
"Usage:\n"
" autodjtg [-h]\n"
" \n"
" This tool automates the usage of djtgcfg from Digilent.\n"
" Currently does not support file paths as arguments.\n"
" In the meantime just run the tool from the directory\n"
" containing the .bit file you wish to program.");
exit(1);
}

original_code:
void usage() {
    char* usage = "Usage:\n       autodjtg [-h]\n   \n   This tool automates the usage of djtgcfg from Digilent.\n   Currently does not support file paths as arguments.\n   In the meantime just run the tool from the directory\n   containing the .bit file you wish to program.";
    printf("%s\n", usage);
    exit(1);
}

canonical_original_code:
void usage() {
    char *usage = "Usage:\n       autodjtg [-h]\n   \n   This tool automates the usage of djtgcfg from Digilent.\n   Currently does not support file paths as arguments.\n   In the meantime just run the tool from the directory\n   containing the .bit file you wish to program.";
    printf("%s\n", usage);
    exit(1);
}

variable_types:
usage
char *

return_type: void


decompiled_code:
void __fastcall get_options(int a1, __int64 a2)
{
const char **v2; // rax

if ( a1 > 1 )
{
v2 = (const char **)(a2 + 8);
do
{
if ( !strcmp(*v2, "--help") || !strcmp(*v2, "-h") )
cmd_args = 1;
++v2;
}
while ( v2 != (const char **)(a2 + 8LL * (unsigned int)(a1 - 2) + 16) );
}
if ( a1 > 2 || a1 == 2 && !cmd_args )
cmd_args = 1;
}

canonical_decompiled_code:
void __fastcall func8(int a1, __int64 a2)
{
const char **v2; // rax

if ( a1 > 1 )
{
v2 = (const char **)(a2 + 8);
do
{
if ( !strcmp(*v2, "--help") || !strcmp(*v2, "-h") )
cmd_args = 1;
++v2;
}
while ( v2 != (const char **)(a2 + 8LL * (unsigned int)(a1 - 2) + 16) );
}
if ( a1 > 2 || a1 == 2 && !cmd_args )
cmd_args = 1;
}

original_code:
void get_options(int argc, char** argv) {
    int i;
    for (i = 1; i < argc; i++) {
        if (strcmp(argv[i], "--help") == 0 ||
                strcmp(argv[i], "-h") == 0)
            cmd_args.help = 1;
    }
    if (argc > 2 || (argc == 2 && !cmd_args.help))
        cmd_args.help = 1;
}

canonical_original_code:
void get_options(int argc, char **argv) {
    int i;
    for (i = 1; i < argc; i++) {
        if (strcmp(argv[i], "--help") == 0 ||
                strcmp(argv[i], "-h") == 0)
            cmd_args.help = 1;
    }
    if (argc > 2 || (argc == 2 && !cmd_args.help))
        cmd_args.help = 1;
}

variable_types:
argv
char **

variable_types: i int


decompiled_code:
void __fastcall __noreturn program_device(char **a1)
{
__int64 *v1; // rbx
char *v2[8]; // [rsp+0h] [rbp-68h] BYREF
__int64 v3; // [rsp+40h] [rbp-28h] BYREF

v2[0] = "djtgcfg";
v2[1] = "prog";
v2[2] = "-d";
v2[3] = *a1;
v2[4] = "-i";
v2[5] = a1[2];
v2[6] = "-f";
v2[7] = a1[1];
v3 = 0LL;
execvp("djtgcfg", v2);
printf("There was an error executing: ");
v1 = (__int64 *)v2;
do
printf("%s ", (const char *)*v1++);
while ( v1 != &v3 );
putchar(10);
exit(999);
}

original_code:
void program_device(Device *device) {
    char* args[9];
    args[0] = "djtgcfg";
    args[1] = "prog";
    args[2] = "-d";
    args[3] = device->id;
    args[4] = "-i";
    args[5] = device->index;
    args[6] = "-f";
    args[7] = device->file;
    args[8] = (char*) 0;
    execvp("djtgcfg", args);
    printf("There was an error executing: ");
    for (int i = 0; i < 8; i++)
        printf("%s ", args[i]);
    printf("\n");
    exit(999);
}

canonical_original_code:
void program_device(struct Device *device) {
    char *args[9];
    args[0] = "djtgcfg";
    args[1] = "prog";
    args[2] = "-d";
    args[3] = device->id;
    args[4] = "-i";
    args[5] = device->index;
    args[6] = "-f";
    args[7] = device->file;
    args[8] = (char *) 0;
    execvp("djtgcfg", args);
    printf("There was an error executing: ");
    for (int i = 0; i < 8; i++)
        printf("%s ", args[i]);
    printf("\n");
    exit(999);
}

variable_types: struct Device { char *id; char *file; char *index; } *

variable_types:
args
char *[9]


decompiled_code:
__int64 pipe_and_fork()
{
__int64 result; // rax
int pipedes[2]; // [rsp+8h] [rbp-10h] BYREF

pipe(pipedes);
childPid = fork();
if ( childPid )
{
close(pipedes[1]);
result = (unsigned int)pipedes[0];
}
else
{
close(pipedes[0]);
dup2(pipedes[1], 1);
result = (unsigned int)pipedes[1];
}
return result;
}

canonical_decompiled_code:
__int64 func11()
{
__int64 result; // rax
int pipedes[2]; // [rsp+8h] [rbp-10h] BYREF

pipe(pipedes);
childPid = fork();
if ( childPid )
{
close(pipedes[1]);
result = (unsigned int)pipedes[0];
}
else
{
close(pipedes[0]);
dup2(pipedes[1], 1);
result = (unsigned int)pipedes[1];
}
return result;
}

original_code:
int pipe_and_fork() {
    int pipes[2];
    int output;
    pid_t pid;
    if (pipe(pipes) != 0) {
    }
    if ((pid = fork()) == -1) {
    }
    childPid = pid;
    if (pid == 0) {
        close(pipes[0]);
        output = 1;
        if (dup2(pipes[1], output) == -1) {
        }
        return pipes[1];
    } else {
        close(pipes[1]);
        return pipes[0];
    }
}

canonical_original_code:
int pipe_and_fork() {
    int pipes[2];
    int output;
    int pid;
    if (pipe(pipes) != 0) {
    }
    if ((pid = fork()) == -1) {
    }
    childPid = pid;
    if (pid == 0) {
        close(pipes[0]);
        output = 1;
        if (dup2(pipes[1], output) == -1) {
        }
        return pipes[1];
    } else {
        close(pipes[1]);
        return pipes[0];
    }
}

variable_types:
pipes
int [2]

variable_types: output int

variable_types: pid int


main

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

retcode = 0;
get_options(argc, (__int64)argv);
if ( cmd_args )
usage();
v3 = (const char **)malloc(0x18uLL);
get_device_id((char **)v3);
if ( *v3 )
{
printf("Found USB Device: %s\n", *v3);
get_device_index((char **)v3);
get_file_path((__int64)v3);
program_device((char **)v3);
}
retcode = 2;
free((void *)v3[1]);
free(v3);
return retcode;
}

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

retcode = 0;
func8(argc, (__int64)argv);
if ( cmd_args )
func7();
v3 = (const char **)malloc(0x18uLL);
func12((char **)v3);
if ( *v3 )
{
printf("Found USB Device: %s\n", *v3);
func13((char **)v3);
func9((__int64)v3);
func10((char **)v3);
}
retcode = 2;
free((void *)v3[1]);
free(v3);
return retcode;
}

original_code:
int main(int argc, char** argv) {
    Device* device;
    retcode = 0;
    get_options(argc, argv);
    if (cmd_args.help)
        usage();
    device = (Device*) malloc(sizeof(Device));
    get_device_id(device);
    if (device->id == ((void *)0)) {
        retcode = 2;
        goto cleanup;
    }
    printf("Found USB Device: %s\n", device->id);
    get_device_index(device);
    if (device->index < 0) {
        retcode = 3;
        goto cleanup;
    }
    get_file_path(device);
    program_device(device);
cleanup:
    free(device->id);
    free(device->file);
    free(device);
    return retcode;
}

canonical_original_code:
int main(int argc, char **argv) {
    struct Device *device;
    retcode = 0;
    get_options(argc, argv);
    if (cmd_args.help)
        usage();
    device = (struct Device *) malloc(sizeof(Device));
    get_device_id(device);
    if (device->id == ((void *)0)) {
        retcode = 2;
        goto cleanup;
    }
    printf("Found USB Device: %s\n", device->id);
    get_device_index(device);
    if (device->index < 0) {
        retcode = 3;
        goto cleanup;
    }
    get_file_path(device);
    program_device(device);
cleanup:
    free(device->id);
    free(device->file);
    free(device);
    return retcode;
}

user_defined_types: struct Device { char *id; char *file; char *index; }


repo: rogerhil/racergame

original_code:
int main(void){
    double r = 0;
    double t = 0;
    double aceleracao = 2;
    double c_desac = 1;
    double natural_desac = .5;
    double v_max = 1.0;
    double torque = 1.5;
    int ang = 0, ttt = 0;
    MAPA mapa;
    MAPA tcmapa;
    int criar_cenario = 0;
    mapa = zerar_matriz_mapa(mapa);
    tcmapa = zerar_matriz_mapa(tcmapa);
    inicializar_allegro(criar_cenario);
    BITMAP *buffer = create_bitmap(71, 58);
    BITMAP *buffer2 = create_bitmap(71, 58);
    BITMAP *mapa_buffer = create_bitmap(640, 480);
    BITMAP *menu_buffer = create_bitmap(640, 40);
    CONSTR_MENU menu;
    menu = define_menu(menu);
    menu_buffer = desenha_constr_menu(menu_buffer, menu);
    BITMAP *intro_bmp = load_bitmap("imagens/intro_logo.bmp", ((void *)0));
    draw_sprite(screen, intro_bmp, 40, 150);
    textprintf(screen, font, 200, 300, makecol(255,255,255), "PRESSIONE ENTER PARA COMECAR");
    textprintf(screen, font, 190, 340, makecol(255,255,255), "PRESSIONE TAB PARA EDITAR FASE");
    while(!key[__allegro_KEY_ENTER])
    {
        if (key[__allegro_KEY_TAB]){
            criar_cenario = 1;
            break;
        }
    }
    if (criar_cenario)
    {
        mapa = zerar_matriz_mapa(mapa);
    }
    else
    {
        mapa = define_mapa();
    }
    BITMAP *spr_carro = load_bitmap("imagens/carro.bmp", ((void *)0));
    BITMAP *spr_img;
    BITMAP *bmp;
    BITMAP *setinha = load_bitmap("imagens/setinha.bmp", ((void *)0));
    BITMAP *limp_setinhas = create_bitmap(640, 10);
    BITMAP *limp_menu = create_bitmap(640, 40);
    carro.x = 240;
    carro.y = 40;
    carro.largura = spr_carro->w;
    carro.altura = spr_carro->h;
    carro.angulo = 0;
    carro.spr = create_bitmap(carro.largura, carro.altura);
    mapa_buffer = desenha_mapa(mapa, buffer);
    draw_sprite(screen, mapa_buffer, 0, 0);
    draw_sprite(screen, menu_buffer, 0, 480);
    blit(screen, buffer2, carro.x, carro.y, 0, 0, 71, 58);
    draw_sprite(buffer, buffer2, 0, 0);
    int cmx, cmy, ma_x, ma_y, mmx, mmy, rmx, rmy, menux;
    int obj_selec = 0, i, j;
    int smodx = 0;
    int smody = 0;
    char *arquivo_img;
    arquivo_img = malloc (100);
    arquivo_img = strdup ("imagens/estrada.bmp");
    char *img_cursor;
    img_cursor = malloc (100);
    img_cursor = strdup ("imagens/cursor.bmp");
    ma_x = mouse_x;
    ma_y = mouse_y;
    BITMAP *cursor_bmp = load_bitmap(img_cursor, ((void *)0));
    set_mouse_sprite(cursor_bmp);
    set_mouse_sprite_focus(0,0);
    show_mouse(screen);
    if (criar_cenario)
    {
        while(!key[__allegro_KEY_ESC])
        {
            if (mouse_y > 0 && mouse_y < 480)
            {
                if (mouse_b)
                {
                    mmx = mouse_x / 20;
                    mmy = mouse_y / 20;
                    rmx = mouse_x % 20;
                    rmy = mouse_y % 20;
                    tcmapa.matriz[mmy][mmx] = obj_selec;
                    arquivo_img = retorna_nome_arq_imagem (obj_selec);
                    spr_img = load_bitmap(arquivo_img, ((void *)0));
                    bmp = create_bitmap(spr_img->w, spr_img->h);
                    draw_sprite(bmp, spr_img, 0, 0);
                    scare_mouse();
                    draw_sprite(screen, bmp, mouse_x - rmx, mouse_y - rmy);
                    unscare_mouse();
                    mouse_b = 0;
                }
            }
            if (mouse_y > 490 && mouse_y < 510)
            {
                menux = mouse_x / 30;
                if (mouse_b)
                {
                    obj_selec = menu.objs[menux];
                    smodx = mouse_x % 30;
                    smody = 20 - (mouse_y % 20);
                    draw_sprite(screen, limp_setinhas, 0, 510);
                    draw_sprite(screen, setinha, mouse_x - smodx, mouse_y + smody + 10);
                    if (obj_selec == -2)
                    {
                        obj_selec = 0;
                        if (deseja_salvar())
                        {
                            salvar_fase(tcmapa);
                            mapa = define_mapa();
                            criar_cenario = 0;
                            break;
                        }
                    }
                }
            }
            ma_x = mouse_x;
            ma_y = mouse_y;
        }
    }
    if (!criar_cenario)
    {
        draw_sprite(screen, limp_menu, 0, 480);
        while(!key[__allegro_KEY_ESC]){
            ttt++;
            if (ttt > 40)
            {
                if (key[__allegro_KEY_RIGHT]){
                    carro.angulo+=torque;
                }
                if (key[__allegro_KEY_LEFT]){
                    carro.angulo-=torque;
                }
                blit(buffer2, screen, 0, 0, carro.x, carro.y, 640, 480);
                if (key[__allegro_KEY_UP]){
                    ang = carro.angulo;
                    t+=.05;
                }
                ang = carro.angulo;
                r = aceleracao*t*t;
                if (r > v_max)
                {
                    t -= .1;
                    r = v_max;
                }
                cmy = (int)(carro.y + 35 + (int)(r * sin((ang*(3.1416))/128)))/20;
                cmx = (int)(carro.x + 29 + (int)(r * cos((ang*(3.1416))/128)))/20;
                if (mapa.matriz[cmy][cmx] != 0)
                {
                    t -= .2;
                    r -= 4;
                }
                if (t < 0)
                {
                    t = 0;
                }
                if (key[__allegro_KEY_DOWN]) {
                    ang = carro.angulo;
                    t-=c_desac;
                }
                t-= natural_desac;
                carro.x+= (int)(r * cos((ang*(3.1416))/128));
                carro.y+= (int)(r * sin((ang*(3.1416))/128));
                ttt = 0;
                blit(screen, buffer2, carro.x, carro.y, 0, 0, 71, 58);
                draw_sprite(buffer, buffer2, 0, 0);
            }
            desenha_sprite(buffer2, carro.spr, spr_carro, carro.angulo);
            draw_sprite(buffer, carro.spr, 10, 10);
            blit(buffer, screen, 0, 0, carro.x, carro.y, 640, 480);
        }
    }
    return(0);
}

canonical_original_code:
int main(){
    double r = 0;
    double t = 0;
    double aceleracao = 2;
    double c_desac = 1;
    double natural_desac = .5;
    double v_max = 1.0;
    double torque = 1.5;
    int ang = 0; int ttt = 0;
    struct MAPA mapa;
    struct MAPA tcmapa;
    int criar_cenario = 0;
    mapa = zerar_matriz_mapa(mapa);
    tcmapa = zerar_matriz_mapa(tcmapa);
    inicializar_allegro(criar_cenario);
    struct BITMAP *buffer = create_bitmap(71, 58);
    struct BITMAP *buffer2 = create_bitmap(71, 58);
    struct BITMAP *mapa_buffer = create_bitmap(640, 480);
    struct BITMAP *menu_buffer = create_bitmap(640, 40);
    struct CONSTR_MENU menu;
    menu = define_menu(menu);
    menu_buffer = desenha_constr_menu(menu_buffer, menu);
    struct BITMAP *intro_bmp = load_bitmap("imagens/intro_logo.bmp", ((void *)0));
    draw_sprite(screen, intro_bmp, 40, 150);
    textprintf(screen, font, 200, 300, makecol(255,255,255), "PRESSIONE ENTER PARA COMECAR");
    textprintf(screen, font, 190, 340, makecol(255,255,255), "PRESSIONE TAB PARA EDITAR FASE");
    while(!key[__allegro_KEY_ENTER])
    {
        if (key[__allegro_KEY_TAB]){
            criar_cenario = 1;
            break;
        }
    }
    if (criar_cenario)
    {
        mapa = zerar_matriz_mapa(mapa);
    }
    else
    {
        mapa = define_mapa();
    }
    struct BITMAP *spr_carro = load_bitmap("imagens/carro.bmp", ((void *)0));
    struct BITMAP *spr_img;
    struct BITMAP *bmp;
    struct BITMAP *setinha = load_bitmap("imagens/setinha.bmp", ((void *)0));
    struct BITMAP *limp_setinhas = create_bitmap(640, 10);
    struct BITMAP *limp_menu = create_bitmap(640, 40);
    carro.x = 240;
    carro.y = 40;
    carro.largura = spr_carro->w;
    carro.altura = spr_carro->h;
    carro.angulo = 0;
    carro.spr = create_bitmap(carro.largura, carro.altura);
    mapa_buffer = desenha_mapa(mapa, buffer);
    draw_sprite(screen, mapa_buffer, 0, 0);
    draw_sprite(screen, menu_buffer, 0, 480);
    blit(screen, buffer2, carro.x, carro.y, 0, 0, 71, 58);
    draw_sprite(buffer, buffer2, 0, 0);
    int cmx; int cmy; int ma_x; int ma_y; int mmx; int mmy; int rmx; int rmy; int menux;
    int obj_selec = 0; int i; int j;
    int smodx = 0;
    int smody = 0;
    char *arquivo_img;
    arquivo_img = malloc (100);
    arquivo_img = strdup ("imagens/estrada.bmp");
    char *img_cursor;
    img_cursor = malloc (100);
    img_cursor = strdup ("imagens/cursor.bmp");
    ma_x = mouse_x;
    ma_y = mouse_y;
    struct BITMAP *cursor_bmp = load_bitmap(img_cursor, ((void *)0));
    set_mouse_sprite(cursor_bmp);
    set_mouse_sprite_focus(0,0);
    show_mouse(screen);
    if (criar_cenario)
    {
        while(!key[__allegro_KEY_ESC])
        {
            if (mouse_y > 0 && mouse_y < 480)
            {
                if (mouse_b)
                {
                    mmx = mouse_x / 20;
                    mmy = mouse_y / 20;
                    rmx = mouse_x % 20;
                    rmy = mouse_y % 20;
                    tcmapa.matriz[mmy][mmx] = obj_selec;
                    arquivo_img = retorna_nome_arq_imagem (obj_selec);
                    spr_img = load_bitmap(arquivo_img, ((void *)0));
                    bmp = create_bitmap(spr_img->w, spr_img->h);
                    draw_sprite(bmp, spr_img, 0, 0);
                    scare_mouse();
                    draw_sprite(screen, bmp, mouse_x - rmx, mouse_y - rmy);
                    unscare_mouse();
                    mouse_b = 0;
                }
            }
            if (mouse_y > 490 && mouse_y < 510)
            {
                menux = mouse_x / 30;
                if (mouse_b)
                {
                    obj_selec = menu.objs[menux];
                    smodx = mouse_x % 30;
                    smody = 20 - (mouse_y % 20);
                    draw_sprite(screen, limp_setinhas, 0, 510);
                    draw_sprite(screen, setinha, mouse_x - smodx, mouse_y + smody + 10);
                    if (obj_selec == -2)
                    {
                        obj_selec = 0;
                        if (deseja_salvar())
                        {
                            salvar_fase(tcmapa);
                            mapa = define_mapa();
                            criar_cenario = 0;
                            break;
                        }
                    }
                }
            }
            ma_x = mouse_x;
            ma_y = mouse_y;
        }
    }
    if (!criar_cenario)
    {
        draw_sprite(screen, limp_menu, 0, 480);
        while(!key[__allegro_KEY_ESC]){
            ttt++;
            if (ttt > 40)
            {
                if (key[__allegro_KEY_RIGHT]){
                    carro.angulo+=torque;
                }
                if (key[__allegro_KEY_LEFT]){
                    carro.angulo-=torque;
                }
                blit(buffer2, screen, 0, 0, carro.x, carro.y, 640, 480);
                if (key[__allegro_KEY_UP]){
                    ang = carro.angulo;
                    t+=.05;
                }
                ang = carro.angulo;
                r = aceleracao*t*t;
                if (r > v_max)
                {
                    t -= .1;
                    r = v_max;
                }
                cmy = (int)(carro.y + 35 + (int)(r * sin((ang*(3.1416))/128)))/20;
                cmx = (int)(carro.x + 29 + (int)(r * cos((ang*(3.1416))/128)))/20;
                if (mapa.matriz[cmy][cmx] != 0)
                {
                    t -= .2;
                    r -= 4;
                }
                if (t < 0)
                {
                    t = 0;
                }
                if (key[__allegro_KEY_DOWN]) {
                    ang = carro.angulo;
                    t-=c_desac;
                }
                t-= natural_desac;
                carro.x+= (int)(r * cos((ang*(3.1416))/128));
                carro.y+= (int)(r * sin((ang*(3.1416))/128));
                ttt = 0;
                blit(screen, buffer2, carro.x, carro.y, 0, 0, 71, 58);
                draw_sprite(buffer, buffer2, 0, 0);
            }
            desenha_sprite(buffer2, carro.spr, spr_carro, carro.angulo);
            draw_sprite(buffer, carro.spr, 10, 10);
            blit(buffer, screen, 0, 0, carro.x, carro.y, 640, 480);
        }
    }
    return(0);
}

variable_types: r double

variable_types: t double

variable_types: aceleracao double

variable_types: torque double

variable_types: ang int

variable_types: ttt int

variable_types: struct MAPA { int largura; int altura; int matriz[24][32]; struct BITMAP { int w; int clip; int cl; struct GFX_VTABLE { int color_depth; int mask_color; void *unwrite_bank; void (*set_clip)(struct BITMAP *bmp); void (*acquire)(struct BITMAP *bmp); void (*release)(struct BITMAP *bmp); struct BITMAP *(*create_sub_bitmap)(struct BITMAP *parent, int x, int y, int width, int height); void (*created_sub_bitmap)(struct BITMAP *bmp, struct BITMAP *parent); int (*getpixel)(struct BITMAP *bmp, int x, int y); void (*putpixel)(struct BITMAP *bmp, int x, int y, int color); void (*vline)(struct BITMAP *bmp, int x, int y_1, int y2, int color); void (*hline)(struct BITMAP *bmp, int x1, int y, int x2, int color); void (*hfill)(struct BITMAP *bmp, int x1, int y, int x2, int color); void (*line)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*fastline)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*rectfill)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*triangle)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int x3, int y3, int color); void (*draw_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_256_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_sprite_v_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_sprite_h_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_sprite_vh_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_trans_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_trans_rgba_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_lit_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color); void (*draw_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE { int w; int color_depth; int size; char dat[]; } *sprite, int x, int y); void (*draw_trans_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y); void (*draw_trans_rgba_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y); void (*draw_lit_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color); void (*draw_character)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color, int bg); void (*draw_glyph)(struct BITMAP *bmp, struct FONT_GLYPH { short w; unsigned char dat[]; } *glyph, int x, int y, int color, int bg); void (*blit_from_memory)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_memory)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_from_system)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_system)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_self)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_self_forward)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_self_backward)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_between_formats)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*masked_blit)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*clear_to_color)(struct BITMAP *bitmap, int color); void (*pivot_scaled_sprite_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int cx, int cy, int angle, int scale, int v_flip); void (*do_stretch_blit)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int source_width, int source_height, int dest_x, int dest_y, int dest_width, int dest_height, int masked); void (*draw_gouraud_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int c1, int c2, int c3, int c4); void (*draw_sprite_end)(); void (*blit_end)(); void (*polygon)(struct BITMAP *bmp, int vertices, int *points, int color); void (*rect)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*circle)(struct BITMAP *bmp, int x, int y, int radius, int color); void (*circlefill)(struct BITMAP *bmp, int x, int y, int radius, int color); void (*ellipse)(struct BITMAP *bmp, int x, int y, int rx, int ry, int color); void (*ellipsefill)(struct BITMAP *bmp, int x, int y, int rx, int ry, int color); void (*arc)(struct BITMAP *bmp, int x, int y, int ang1, int ang2, int r, int color); void (*spline)(struct BITMAP *bmp, int points[8], int color); void (*floodfill)(struct BITMAP *bmp, int x, int y, int color); void (*polygon3d)(struct BITMAP *bmp, int type, struct BITMAP *texture, int vc, struct V3D { int x; int u; int c; } *vtx[]); void (*polygon3d_f)(struct BITMAP *bmp, int type, struct BITMAP *texture, int vc, struct V3D_f { float x; float u; int c; } *vtx[]); void (*triangle3d)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D *v1, struct V3D *v2, struct V3D *v3); void (*triangle3d_f)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D_f *v1, struct V3D_f *v2, struct V3D_f *v3); void (*quad3d)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D *v1, struct V3D *v2, struct V3D *v3, struct V3D *v4); void (*quad3d_f)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D_f *v1, struct V3D_f *v2, struct V3D_f *v3, struct V3D_f *v4); void (*draw_sprite_ex)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int mode, int flip); } *vtable; void *write_bank; void *read_bank; void *dat; unsigned long id; void *extra; int x_ofs; int y_ofs; int seg; unsigned char *line[]; } *spr; }

variable_types:
menu
struct CONSTR_MENU { int objs[32]; }

variable_types: cmx int

variable_types: cmy int

variable_types: mmx int

variable_types: mmy int

variable_types: rmx int

variable_types: rmy int

variable_types: menux int

variable_types: j int

variable_types: smodx int

variable_types: smody int

user_defined_types: struct MAPA { int largura; int altura; int matriz[24][32]; struct BITMAP *spr; }

user_defined_types: struct BITMAP { int w; int clip; int cl; struct GFX_VTABLE *vtable; void *write_bank; void *read_bank; void *dat; unsigned long id; void *extra; int x_ofs; int y_ofs; int seg; unsigned char *line[]; }

user_defined_types: struct GFX_VTABLE { int color_depth; int mask_color; void *unwrite_bank; void (*set_clip)(struct BITMAP *bmp); void (*acquire)(struct BITMAP *bmp); void (*release)(struct BITMAP *bmp); struct BITMAP *(*create_sub_bitmap)(struct BITMAP *parent, int x, int y, int width, int height); void (*created_sub_bitmap)(struct BITMAP *bmp, struct BITMAP *parent); int (*getpixel)(struct BITMAP *bmp, int x, int y); void (*putpixel)(struct BITMAP *bmp, int x, int y, int color); void (*vline)(struct BITMAP *bmp, int x, int y_1, int y2, int color); void (*hline)(struct BITMAP *bmp, int x1, int y, int x2, int color); void (*hfill)(struct BITMAP *bmp, int x1, int y, int x2, int color); void (*line)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*fastline)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*rectfill)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*triangle)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int x3, int y3, int color); void (*draw_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_256_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_sprite_v_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_sprite_h_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_sprite_vh_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_trans_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_trans_rgba_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y); void (*draw_lit_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color); void (*draw_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y); void (*draw_trans_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y); void (*draw_trans_rgba_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y); void (*draw_lit_rle_sprite)(struct BITMAP *bmp, struct RLE_SPRITE *sprite, int x, int y, int color); void (*draw_character)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int color, int bg); void (*draw_glyph)(struct BITMAP *bmp, struct FONT_GLYPH *glyph, int x, int y, int color, int bg); void (*blit_from_memory)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_memory)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_from_system)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_system)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_self)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_self_forward)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_to_self_backward)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*blit_between_formats)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*masked_blit)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height); void (*clear_to_color)(struct BITMAP *bitmap, int color); void (*pivot_scaled_sprite_flip)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int cx, int cy, int angle, int scale, int v_flip); void (*do_stretch_blit)(struct BITMAP *source, struct BITMAP *dest, int source_x, int source_y, int source_width, int source_height, int dest_x, int dest_y, int dest_width, int dest_height, int masked); void (*draw_gouraud_sprite)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int c1, int c2, int c3, int c4); void (*draw_sprite_end)(); void (*blit_end)(); void (*polygon)(struct BITMAP *bmp, int vertices, int *points, int color); void (*rect)(struct BITMAP *bmp, int x1, int y_1, int x2, int y2, int color); void (*circle)(struct BITMAP *bmp, int x, int y, int radius, int color); void (*circlefill)(struct BITMAP *bmp, int x, int y, int radius, int color); void (*ellipse)(struct BITMAP *bmp, int x, int y, int rx, int ry, int color); void (*ellipsefill)(struct BITMAP *bmp, int x, int y, int rx, int ry, int color); void (*arc)(struct BITMAP *bmp, int x, int y, int ang1, int ang2, int r, int color); void (*spline)(struct BITMAP *bmp, int points[8], int color); void (*floodfill)(struct BITMAP *bmp, int x, int y, int color); void (*polygon3d)(struct BITMAP *bmp, int type, struct BITMAP *texture, int vc, struct V3D *vtx[]); void (*polygon3d_f)(struct BITMAP *bmp, int type, struct BITMAP *texture, int vc, struct V3D_f *vtx[]); void (*triangle3d)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D *v1, struct V3D *v2, struct V3D *v3); void (*triangle3d_f)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D_f *v1, struct V3D_f *v2, struct V3D_f *v3); void (*quad3d)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D *v1, struct V3D *v2, struct V3D *v3, struct V3D *v4); void (*quad3d_f)(struct BITMAP *bmp, int type, struct BITMAP *texture, struct V3D_f *v1, struct V3D_f *v2, struct V3D_f *v3, struct V3D_f *v4); void (*draw_sprite_ex)(struct BITMAP *bmp, struct BITMAP *sprite, int x, int y, int mode, int flip); }


yyparse

repo: rohitjha/hoc

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

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 4:
    { code(pop); code((Inst) 0); return 1; }
    break;
  case 5:
    { code((Inst) 0); return 1; }
    break;
  case 6:
    { code(print); code((Inst) 0); return 1; }
    break;
  case 7:
    { (yyerrstatus = 0); }
    break;
  case 8:
    { (yyval.inst)=(yyvsp[0].inst); code(varpush); code((Inst)(yyvsp[-2].sym)); code(assign); }
    break;
  case 9:
    { code(pop); }
    break;
  case 10:
    { code(prexpr); (yyval.inst)=(yyvsp[0].inst); }
    break;
  case 11:
    {
     ((yyvsp[-3].inst))[1] = (Inst)(yyvsp[-1].inst);
     ((yyvsp[-3].inst))[2] = (Inst)(yyvsp[0].inst);
    }
    break;
  case 12:
    {
     ((yyvsp[-3].inst))[1] = (Inst)(yyvsp[-1].inst);
     ((yyvsp[-3].inst))[3] = (Inst)(yyvsp[0].inst);
    }
    break;
  case 13:
    {
       ((yyvsp[-6].inst))[1] = (Inst)(yyvsp[-4].inst);
       ((yyvsp[-6].inst))[2] = (Inst)(yyvsp[-1].inst);
       ((yyvsp[-6].inst))[3] = (Inst)(yyvsp[0].inst);
      }
    break;
  case 14:
    { (yyval.inst)=(yyvsp[-1].inst); }
    break;
  case 15:
    { code((Inst) 0); (yyval.inst)=(yyvsp[-1].inst); }
    break;
  case 16:
    { (yyval.inst)=code(whilecode); code((Inst) 0); code((Inst) 0); }
    break;
  case 17:
    { (yyval.inst)=code(ifcode); code((Inst) 0); code((Inst) 0); code((Inst) 0); }
    break;
  case 18:
    { code((Inst) 0); (yyval.inst)=progp; }
    break;
  case 19:
    { (yyval.inst)=progp; }
    break;
  case 22:
    { (yyval.inst)=code(constpush); code((Inst)(yyvsp[0].sym)); }
    break;
  case 23:
    { (yyval.inst)=code(varpush); code((Inst)(yyvsp[0].sym)); code(eval); }
    break;
  case 25:
    { (yyval.inst)=(yyvsp[-1].inst); code(bltin); code((Inst)(yyvsp[-3].sym)->u.ptr); }
    break;
  case 26:
    { (yyval.inst)=(yyvsp[-1].inst); }
    break;
  case 27:
    { code(add); }
    break;
  case 28:
    { code(sub); }
    break;
  case 29:
    { code(mul); }
    break;
  case 30:
    { code(div); }
    break;
  case 31:
    { code(power); }
    break;
  case 32:
    { (yyval.inst)=(yyvsp[0].inst); code(positive); }
    break;
  case 33:
    { (yyval.inst)=(yyvsp[0].inst); code(negate); }
    break;
  case 34:
    { code(gt); }
    break;
  case 35:
    { code(ge); }
    break;
  case 36:
    { code(lt); }
    break;
  case 37:
    { code(le); }
    break;
  case 38:
    { code(eq); }
    break;
  case 39:
    { code(ne); }
    break;
  case 40:
    { code(and); }
    break;
  case 41:
    { code(or); }
    break;
  case 42:
    { (yyval.inst)=(yyvsp[0].inst); code(not); }
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  {
    const int yylhs = yyr1[yyn] - 33;
    const int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 260 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned) (yychar) <= 276 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-59))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 260 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

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

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

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 4:
    { code(pop); code((int (*)()) 0); return 1; }
    break;
  case 5:
    { code((int (*)()) 0); return 1; }
    break;
  case 6:
    { code(print); code((int (*)()) 0); return 1; }
    break;
  case 7:
    { (yyerrstatus = 0); }
    break;
  case 8:
    { (yyval.inst)=(yyvsp[0].inst); code(varpush); code((Inst)(yyvsp[-2].sym)); code(assign); }
    break;
  case 9:
    { code(pop); }
    break;
  case 10:
    { code(prexpr); (yyval.inst)=(yyvsp[0].inst); }
    break;
  case 11:
    {
     ((yyvsp[-3].inst))[1] = (Inst)(yyvsp[-1].inst);
     ((yyvsp[-3].inst))[2] = (Inst)(yyvsp[0].inst);
    }
    break;
  case 12:
    {
     ((yyvsp[-3].inst))[1] = (Inst)(yyvsp[-1].inst);
     ((yyvsp[-3].inst))[3] = (Inst)(yyvsp[0].inst);
    }
    break;
  case 13:
    {
       ((yyvsp[-6].inst))[1] = (Inst)(yyvsp[-4].inst);
       ((yyvsp[-6].inst))[2] = (Inst)(yyvsp[-1].inst);
       ((yyvsp[-6].inst))[3] = (Inst)(yyvsp[0].inst);
      }
    break;
  case 14:
    { (yyval.inst)=(yyvsp[-1].inst); }
    break;
  case 15:
    { code((int (*)()) 0); (yyval.inst)=(yyvsp[-1].inst); }
    break;
  case 16:
    { (yyval.inst)=code(whilecode); code((int (*)()) 0); code((int (*)()) 0); }
    break;
  case 17:
    { (yyval.inst)=code(ifcode); code((int (*)()) 0); code((int (*)()) 0); code((int (*)()) 0); }
    break;
  case 18:
    { code((int (*)()) 0); (yyval.inst)=progp; }
    break;
  case 19:
    { (yyval.inst)=progp; }
    break;
  case 22:
    { (yyval.inst)=code(constpush); code((Inst)(yyvsp[0].sym)); }
    break;
  case 23:
    { (yyval.inst)=code(varpush); code((Inst)(yyvsp[0].sym)); code(eval); }
    break;
  case 25:
    { (yyval.inst)=(yyvsp[-1].inst); code(bltin); code((Inst)(yyvsp[-3].sym)->u.ptr); }
    break;
  case 26:
    { (yyval.inst)=(yyvsp[-1].inst); }
    break;
  case 27:
    { code(add); }
    break;
  case 28:
    { code(sub); }
    break;
  case 29:
    { code(mul); }
    break;
  case 30:
    { code(div); }
    break;
  case 31:
    { code(power); }
    break;
  case 32:
    { (yyval.inst)=(yyvsp[0].inst); code(positive); }
    break;
  case 33:
    { (yyval.inst)=(yyvsp[0].inst); code(negate); }
    break;
  case 34:
    { code(gt); }
    break;
  case 35:
    { code(ge); }
    break;
  case 36:
    { code(lt); }
    break;
  case 37:
    { code(le); }
    break;
  case 38:
    { code(eq); }
    break;
  case 39:
    { code(ne); }
    break;
  case 40:
    { code(and); }
    break;
  case 41:
    { code(or); }
    break;
  case 42:
    { (yyval.inst)=(yyvsp[0].inst); code(not); }
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  {
    int yylhs = yyr1[yyn] - 33;
    int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 260 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned int) (yychar) <= 276 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-59))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 260 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

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

variable_types: yystate int

variable_types: yyerrstatus int

variable_types:
yyssa
short [200]

variable_types:
yyss
short *

variable_types:
yyssp
short *

variable_types: union YYSTYPE { struct Symbol { char *name; short type; union { double val; double (*ptr)(); } u; struct Symbol *next; } *sym; int (**inst)(); } [200]

variable_types: union YYSTYPE { struct Symbol { char *name; short type; union { double val; double (*ptr)(); } u; struct Symbol *next; } *sym; int (**inst)(); } *

variable_types:
yystacksize
unsigned long

variable_types: yyn int

variable_types: yyresult int

variable_types: yytoken int

variable_types: yylen int

variable_types:
yysize
unsigned long

variable_types: union yyalloc { short yyss_alloc; union YYSTYPE { struct Symbol { char *name; short type; union { double val; double (*ptr)(); } u; struct Symbol *next; } *sym; int (**inst)(); } yyvs_alloc; } *

variable_types:
yynewbytes
unsigned long

variable_types: yylhs int

variable_types: yyi int

user_defined_types: union YYSTYPE { struct Symbol *sym; int (**inst)(); }

user_defined_types: union yyalloc { short yyss_alloc; union YYSTYPE yyvs_alloc; }


execerror

decompiled_code:
void __fastcall __noreturn execerror(const char *a1, const char *a2)
{
warning(a1, a2);
longjmp(begin, 0);
}

canonical_decompiled_code:
void __fastcall __noreturn func3(const char *a1, const char *a2)
{
func2(a1, a2);
longjmp(begin, 0);
}

original_code:
void execerror(char *s, char *t)
{
 warning(s, t);
 longjmp(begin, 0);
}

variable_types:
s
char *

variable_types:
t
char *


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax

progname = (__int64)*argv;
init(argc, argv, envp);
setjmp(begin);
initcode();
while ( 1 )
{
result = yyparse();
if ( !result )
break;
execute(&prog);
initcode();
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax

progname = (__int64)*argv;
init(argc, argv, envp);
setjmp(begin);
initcode();
while ( 1 )
{
result = func5();
if ( !result )
break;
execute(&prog);
initcode();
}
return result;
}

original_code:
int main(int argc, char *argv[])
{
 progname = argv[0];
 init();
 _setjmp (begin);
 for (initcode(); yyparse(); initcode())
  execute(prog);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


initcode

decompiled_code:
void initcode()
{
stackp = (__int64)&stack;
progp = (__int64)&prog;
}

canonical_decompiled_code:
void func0()
{
stackp = (__int64)&stack;
progp = (__int64)&prog;
}

original_code:
void initcode()
{
 stackp = stack;
 progp = prog;
}


pop

decompiled_code:
__int64 pop()
{
if ( stackp <= (unsigned __int64)&stack )
execerror("stack underflow", 0LL);
stackp -= 8LL;
return *(_QWORD *)stackp;
}

canonical_decompiled_code:
__int64 func1()
{
if ( stackp <= (unsigned __int64)&stack )
execerror("stack underflow", 0LL);
stackp -= 8LL;
return *(_QWORD *)stackp;
}

canonical_original_code:
union Datum pop()
{
 if (stackp <= stack)
  execerror("stack underflow", (char *) 0);
 return *--stackp;
}

return_type: union Datum { double val; struct Symbol { char *name; short type; union { double val; double (*ptr)(); } u; struct Symbol *next; } *sym; }

user_defined_types: union Datum { double val; struct Symbol *sym; }


code

decompiled_code:
__int64 __fastcall code(__int64 a1)
{
__int64 v1; // rbp
_QWORD *v2; // rax

v1 = progp;
if ( progp >= (unsigned __int64)&prog + 16000 )
execerror("program too big", 0LL);
v2 = (_QWORD *)progp;
progp += 8LL;
*v2 = a1;
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 v1; // rbp
_QWORD *v2; // rax

v1 = progp;
if ( progp >= (unsigned __int64)&prog + 16000 )
execerror("program too big", 0LL);
v2 = (_QWORD *)progp;
progp += 8LL;
*v2 = a1;
return v1;
}

original_code:
Inst *code(Inst f)
{
 Inst *oprogp = progp;
 if (progp >= &prog[2000])
  execerror("program too big", (char *) 0);
 *progp++ = f;
 return oprogp;
}

canonical_original_code:
int (**code(int (*f)()))()
{
 int (**oprogp)() = progp;
 if (progp >= &prog[2000])
  execerror("program too big", (char *) 0);
 *progp++ = f;
 return oprogp;
}

variable_types:
oprogp
int (**)()


execute

decompiled_code:
__int64 __fastcall execute(__int64 (**a1)(void))
{
__int64 result; // rax

for ( pc = (__int64)a1; *(_QWORD *)pc; a1 = (__int64 (**)(void))pc )
{
pc = (__int64)(a1 + 1);
result = (*a1)();
}
return result;
}

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

for ( pc = (__int64)a1; *(_QWORD *)pc; a1 = (__int64 (**)(void))pc )
{
pc = (__int64)(a1 + 1);
result = (*a1)();
}
return result;
}

original_code:
void execute(Inst *p)
{
 for (pc = p; *pc != (Inst) 0; )
  (*(*pc++))();
}


constpush

decompiled_code:
_QWORD *constpush()
{
__int64 v0; // rax

v0 = pc;
pc += 8LL;
return push(*(_QWORD *)(*(_QWORD *)v0 + 16LL));
}

canonical_decompiled_code:
_QWORD *func4()
{
__int64 v0; // rax

v0 = pc;
pc += 8LL;
return push(*(_QWORD *)(*(_QWORD *)v0 + 16LL));
}

original_code:
void constpush()
{
 Datum d;
 d.val = ((Symbol *)*pc++)->u.val;
 push(d);
}

canonical_original_code:
void constpush()
{
 union Datum d;
 d.val = ((struct Symbol *)*pc++)->u.val;
 push(d);
}

variable_types: union Datum { double val; struct Symbol { char *name; short type; union { double val; double (*ptr)(); } u; struct Symbol *next; } *sym; }


varpush

decompiled_code:
_QWORD *varpush()
{
__int64 *v0; // rax

v0 = (__int64 *)pc;
pc += 8LL;
return push(*v0);
}

canonical_decompiled_code:
_QWORD *func5()
{
__int64 *v0; // rax

v0 = (__int64 *)pc;
pc += 8LL;
return push(*v0);
}

original_code:
void varpush()
{
 Datum d;
 d.sym = (Symbol *)(*pc++);
 push(d);
}

canonical_original_code:
void varpush()
{
 union Datum d;
 d.sym = (struct Symbol *)(*pc++);
 push(d);
}

user_defined_types: struct Symbol { char *name; short type; union { double val; double (*ptr)(); } u; struct Symbol *next; }


add

decompiled_code:
_QWORD *add()
{
double v0; // rbx
double v1; // rax

v0 = COERCE_DOUBLE(pop());
v1 = COERCE_DOUBLE(pop());
return push(COERCE__INT64(v1 + v0));
}

canonical_decompiled_code:
_QWORD *func6()
{
double v0; // rbx
double v1; // rax

v0 = COERCE_DOUBLE(pop());
v1 = COERCE_DOUBLE(pop());
return push(COERCE__INT64(v1 + v0));
}

original_code:
void add()
{
 Datum d1, d2;
 d2 = pop();
 d1 = pop();
 d1.val += d2.val;
 push(d1);
}

canonical_original_code:
void add()
{
 union Datum d1; union Datum d2;
 d2 = pop();
 d1 = pop();
 d1.val += d2.val;
 push(d1);
}


sub

decompiled_code:
_QWORD *sub()
{
double v0; // rbx
double v1; // rax

v0 = COERCE_DOUBLE(pop());
v1 = COERCE_DOUBLE(pop());
return push(COERCE__INT64(v1 - v0));
}

canonical_decompiled_code:
_QWORD *func7()
{
double v0; // rbx
double v1; // rax

v0 = COERCE_DOUBLE(pop());
v1 = COERCE_DOUBLE(pop());
return push(COERCE__INT64(v1 - v0));
}

original_code:
void sub()
{
 Datum d1, d2;
 d2 = pop();
 d1 = pop();
 d1.val -= d2.val;
 push(d1);
}

canonical_original_code:
void sub()
{
 union Datum d1; union Datum d2;
 d2 = pop();
 d1 = pop();
 d1.val -= d2.val;
 push(d1);
}


mul

decompiled_code:
_QWORD *mul()
{
double v0; // rbx
double v1; // rax

v0 = COERCE_DOUBLE(pop());
v1 = COERCE_DOUBLE(pop());
return push(COERCE__INT64(v1 * v0));
}

canonical_decompiled_code:
_QWORD *func8()
{
double v0; // rbx
double v1; // rax

v0 = COERCE_DOUBLE(pop());
v1 = COERCE_DOUBLE(pop());
return push(COERCE__INT64(v1 * v0));
}

original_code:
void mul()
{
 Datum d1, d2;
 d2 = pop();
 d1 = pop();
 d1.val *= d2.val;
 push(d1);
}

canonical_original_code:
void mul()
{
 union Datum d1; union Datum d2;
 d2 = pop();
 d1 = pop();
 d1.val *= d2.val;
 push(d1);
}


div

decompiled_code:
_QWORD *div()
{
double v0; // rbx
double v1; // rax

v0 = COERCE_DOUBLE(pop());
v1 = COERCE_DOUBLE(pop());
return push(COERCE__INT64(v1 / v0));
}

canonical_decompiled_code:
_QWORD *func9()
{
double v0; // rbx
double v1; // rax

v0 = COERCE_DOUBLE(pop());
v1 = COERCE_DOUBLE(pop());
return push(COERCE__INT64(v1 / v0));
}

original_code:
void div()
{
 Datum d1, d2;
 d2 = pop();
 d1 = pop();
 d1.val /= d2.val;
 push(d1);
}

canonical_original_code:
void div()
{
 union Datum d1; union Datum d2;
 d2 = pop();
 d1 = pop();
 d1.val /= d2.val;
 push(d1);
}


power

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

v0 = pop();
v1 = pop();
*(double *)&v2 = (double)(int)Pow(v1, v0);
return push(v2);
}

canonical_decompiled_code:
_QWORD *func10()
{
__int64 v0; // rbx
__int64 v1; // rax
__int64 v2; // xmm0_8

v0 = func1();
v1 = func1();
*(double *)&v2 = (double)(int)Pow(v1, v0);
return push(v2);
}

original_code:
void power()
{
 Datum d1, d2;
 d2 = pop();
 d1 = pop();
 d1.val = Pow(d1, d2);
 push(d1);
}

canonical_original_code:
void power()
{
 union Datum d1; union Datum d2;
 d2 = pop();
 d1 = pop();
 d1.val = Pow(d1, d2);
 push(d1);
}


negate

decompiled_code:
_QWORD *negate()
{
__int64 v0; // rax

v0 = pop();
return push(v0 ^ LC3);
}

canonical_decompiled_code:
_QWORD *func11()
{
__int64 v0; // rax

v0 = func1();
return push(v0 ^ LC3);
}

original_code:
void negate()
{
 Datum d;
 d = pop();
 d.val = (-1) * d.val;
 push(d);
}

canonical_original_code:
void negate()
{
 union Datum d;
 d = pop();
 d.val = (-1) * d.val;
 push(d);
}


positive

decompiled_code:
void positive()
{
;
}

canonical_decompiled_code:
void func12()
{
;
}

original_code:
void positive()
{
}

canonical_original_code:
void positive()
{
}


eval

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

v0 = pop();
v1 = v0;
if ( *(_WORD *)(v0 + 8) == 262 )
execerror("undefined variable", *(_QWORD *)v0);
return push(*(_QWORD *)(v1 + 16));
}

canonical_decompiled_code:
_QWORD *func13()
{
__int64 v0; // rax
__int64 v1; // rbx

v0 = func1();
v1 = v0;
if ( *(_WORD *)(v0 + 8) == 262 )
execerror("undefined variable", *(_QWORD *)v0);
return push(*(_QWORD *)(v1 + 16));
}

original_code:
void eval()
{
 Datum d;
 d = pop();
 if (d.sym->type == 262)
  execerror("undefined variable", d.sym->name);
 d.val = d.sym->u.val;
 push(d);
}

canonical_original_code:
void eval()
{
 union Datum d;
 d = pop();
 if (d.sym->type == 262)
  execerror("undefined variable", d.sym->name);
 d.val = d.sym->u.val;
 push(d);
}


assign

decompiled_code:
_QWORD *assign()
{
__int64 v0; // rbx
__int64 v1; // rbp

v0 = pop();
v1 = pop();
if ( (*(_WORD *)(v0 + 8) & 0xFFFD) != 260 )
execerror("assignment to non-variable", *(_QWORD *)v0);
*(_QWORD *)(v0 + 16) = v1;
*(_WORD *)(v0 + 8) = 260;
return push(v1);
}

canonical_decompiled_code:
_QWORD *func14()
{
__int64 v0; // rbx
__int64 v1; // rbp

v0 = func1();
v1 = func1();
if ( (*(_WORD *)(v0 + 8) & 0xFFFD) != 260 )
execerror("assignment to non-variable", *(_QWORD *)v0);
*(_QWORD *)(v0 + 16) = v1;
*(_WORD *)(v0 + 8) = 260;
return push(v1);
}

original_code:
void assign()
{
 Datum d1, d2;
 d1 = pop();
 d2 = pop();
 if (d1.sym->type != 260 && d1.sym->type != 262)
  execerror("assignment to non-variable", d1.sym->name);
 d1.sym->u.val = d2.val;
 d1.sym->type = 260;
 push(d2);
}

canonical_original_code:
void assign()
{
 union Datum d1; union Datum d2;
 d1 = pop();
 d2 = pop();
 if (d1.sym->type != 260 && d1.sym->type != 262)
  execerror("assignment to non-variable", d1.sym->name);
 d1.sym->u.val = d2.val;
 d1.sym->type = 260;
 push(d2);
}


print

decompiled_code:
int print()
{
double v0; // rax

v0 = COERCE_DOUBLE(pop());
return printf("\t%.8g\n", v0);
}

canonical_decompiled_code:
int func15()
{
double v0; // rax

v0 = COERCE_DOUBLE(pop());
return printf("\t%.8g\n", v0);
}

original_code:
void print()
{
 Datum d;
 d = pop();
 printf("\t%.8g\n", d.val);
}

canonical_original_code:
void print()
{
 union Datum d;
 d = pop();
 printf("\t%.8g\n", d.val);
}


bltin

decompiled_code:
_QWORD *bltin()
{
double v0; // rax
double (__fastcall **v1)(double); // rdx
__int64 v2; // xmm0_8

v0 = COERCE_DOUBLE(pop());
v1 = (double (__fastcall **)(double))pc;
pc += 8LL;
*(double *)&v2 = (*v1)(v0);
return push(v2);
}

canonical_decompiled_code:
_QWORD *func16()
{
double v0; // rax
double (__fastcall **v1)(double); // rdx
__int64 v2; // xmm0_8

v0 = COERCE_DOUBLE(pop());
v1 = (double (__fastcall **)(double))pc;
pc += 8LL;
*(double *)&v2 = (*v1)(v0);
return push(v2);
}

original_code:
void bltin()
{
 Datum d;
 d = pop();
 d.val = (*(double (*) ())(*pc++))(d.val);
 push(d);
}

canonical_original_code:
void bltin()
{
 union Datum d;
 d = pop();
 d.val = (*(double (*)())(*pc++))(d.val);
 push(d);
}


gt

decompiled_code:
_QWORD *gt()
{
double v0; // rbx
__int64 v1; // xmm0_8

v0 = COERCE_DOUBLE(pop());
v1 = LC7;
if ( COERCE_DOUBLE(pop()) <= v0 )
v1 = 0LL;
return push(v1);
}

canonical_decompiled_code:
_QWORD *func17()
{
double v0; // rbx
__int64 v1; // xmm0_8

v0 = COERCE_DOUBLE(pop());
v1 = LC7;
if ( COERCE_DOUBLE(pop()) <= v0 )
v1 = 0LL;
return push(v1);
}

original_code:
void gt()
{
 Datum d1, d2;
 d2 = pop();
 d1 = pop();
 d1.val = (double)(d1.val > d2.val);
 push(d1);
}

canonical_original_code:
void gt()
{
 union Datum d1; union Datum d2;
 d2 = pop();
 d1 = pop();
 d1.val = (double)(d1.val > d2.val);
 push(d1);
}


lt

decompiled_code:
_QWORD *lt()
{
double v0; // rbx
__int64 v1; // xmm0_8

v0 = COERCE_DOUBLE(pop());
v1 = LC7;
if ( v0 <= COERCE_DOUBLE(pop()) )
v1 = 0LL;
return push(v1);
}

canonical_decompiled_code:
_QWORD *func18()
{
double v0; // rbx
__int64 v1; // xmm0_8

v0 = COERCE_DOUBLE(pop());
v1 = LC7;
if ( v0 <= COERCE_DOUBLE(pop()) )
v1 = 0LL;
return push(v1);
}

original_code:
void lt()
{
 Datum d1, d2;
 d2 = pop();
 d1 = pop();
 d1.val = (double)(d1.val < d2.val);
 push(d1);
}

canonical_original_code:
void lt()
{
 union Datum d1; union Datum d2;
 d2 = pop();
 d1 = pop();
 d1.val = (double)(d1.val < d2.val);
 push(d1);
}


eq

decompiled_code:
_QWORD *eq()
{
double v0; // rbx
__int64 v1; // rdi

v0 = COERCE_DOUBLE(pop());
if ( v0 == COERCE_DOUBLE(pop()) )
v1 = LC7;
else
v1 = LC8;
return push(v1);
}

canonical_decompiled_code:
_QWORD *func19()
{
double v0; // rbx
__int64 v1; // rdi

v0 = COERCE_DOUBLE(pop());
if ( v0 == COERCE_DOUBLE(pop()) )
v1 = LC7;
else
v1 = LC8;
return push(v1);
}

original_code:
void eq()
{
        Datum d1, d2;
        d2 = pop();
        d1 = pop();
        d1.val = (double)(d1.val == d2.val);
        push(d1);
}

canonical_original_code:
void eq()
{
        union Datum d1; union Datum d2;
        d2 = pop();
        d1 = pop();
        d1.val = (double)(d1.val == d2.val);
        push(d1);
}


ge

decompiled_code:
_QWORD *ge()
{
double v0; // rbx
__int64 v1; // xmm0_8

v0 = COERCE_DOUBLE(pop());
v1 = LC7;
if ( COERCE_DOUBLE(pop()) < v0 )
v1 = 0LL;
return push(v1);
}

canonical_decompiled_code:
_QWORD *func20()
{
double v0; // rbx
__int64 v1; // xmm0_8

v0 = COERCE_DOUBLE(pop());
v1 = LC7;
if ( COERCE_DOUBLE(pop()) < v0 )
v1 = 0LL;
return push(v1);
}

original_code:
void ge()
{
        Datum d1, d2;
        d2 = pop();
        d1 = pop();
        d1.val = (double)(d1.val >= d2.val);
        push(d1);
}

canonical_original_code:
void ge()
{
        union Datum d1; union Datum d2;
        d2 = pop();
        d1 = pop();
        d1.val = (double)(d1.val >= d2.val);
        push(d1);
}


le

decompiled_code:
_QWORD *le()
{
double v0; // rbx
__int64 v1; // xmm0_8

v0 = COERCE_DOUBLE(pop());
v1 = LC7;
if ( v0 < COERCE_DOUBLE(pop()) )
v1 = 0LL;
return push(v1);
}

canonical_decompiled_code:
_QWORD *func21()
{
double v0; // rbx
__int64 v1; // xmm0_8

v0 = COERCE_DOUBLE(pop());
v1 = LC7;
if ( v0 < COERCE_DOUBLE(pop()) )
v1 = 0LL;
return push(v1);
}

original_code:
void le()
{
 Datum d1, d2;
 d2 = pop();
 d1 = pop();
 d1.val = (double)(d1.val <= d2.val);
 push(d1);
}

canonical_original_code:
void le()
{
 union Datum d1; union Datum d2;
 d2 = pop();
 d1 = pop();
 d1.val = (double)(d1.val <= d2.val);
 push(d1);
}


ne

decompiled_code:
_QWORD *ne()
{
double v0; // rbx
__int64 v1; // rdi

v0 = COERCE_DOUBLE(pop());
v1 = LC8;
if ( v0 != COERCE_DOUBLE(pop()) )
v1 = LC7;
return push(v1);
}

canonical_decompiled_code:
_QWORD *func22()
{
double v0; // rbx
__int64 v1; // rdi

v0 = COERCE_DOUBLE(pop());
v1 = LC8;
if ( v0 != COERCE_DOUBLE(pop()) )
v1 = LC7;
return push(v1);
}

original_code:
void ne()
{
        Datum d1, d2;
        d2 = pop();
        d1 = pop();
        d1.val = (double)(d1.val != d2.val);
        push(d1);
}

canonical_original_code:
void ne()
{
        union Datum d1; union Datum d2;
        d2 = pop();
        d1 = pop();
        d1.val = (double)(d1.val != d2.val);
        push(d1);
}


and

decompiled_code:
_QWORD *and()
{
double v0; // rbx
double v1; // xmm0_8
_BOOL4 v2; // eax

v0 = COERCE_DOUBLE(pop());
v1 = COERCE_DOUBLE(pop());
v2 = 0;
if ( v1 != 0.0 )
v2 = v0 != 0.0;
return push(COERCE__INT64((double)v2));
}

canonical_decompiled_code:
_QWORD *func23()
{
double v0; // rbx
double v1; // xmm0_8
_BOOL4 v2; // eax

v0 = COERCE_DOUBLE(pop());
v1 = COERCE_DOUBLE(pop());
v2 = 0;
if ( v1 != 0.0 )
v2 = v0 != 0.0;
return push(COERCE__INT64((double)v2));
}

original_code:
void and()
{
        Datum d1, d2;
        d2 = pop();
        d1 = pop();
        d1.val = (double)(d1.val && d2.val);
        push(d1);
}

canonical_original_code:
void and()
{
        union Datum d1; union Datum d2;
        d2 = pop();
        d1 = pop();
        d1.val = (double)(d1.val && d2.val);
        push(d1);
}


or

decompiled_code:
_QWORD *or()
{
double v0; // rbx
_BOOL4 v1; // eax

v0 = COERCE_DOUBLE(pop());
if ( COERCE_DOUBLE(pop()) == 0.0 )
v1 = v0 != 0.0;
else
v1 = 1;
return push(COERCE__INT64((double)v1));
}

canonical_decompiled_code:
_QWORD *func24()
{
double v0; // rbx
_BOOL4 v1; // eax

v0 = COERCE_DOUBLE(pop());
if ( COERCE_DOUBLE(pop()) == 0.0 )
v1 = v0 != 0.0;
else
v1 = 1;
return push(COERCE__INT64((double)v1));
}

original_code:
void or()
{
        Datum d1, d2;
        d2 = pop();
        d1 = pop();
        d1.val = (double)(d1.val || d2.val);
        push(d1);
}

canonical_original_code:
void or()
{
        union Datum d1; union Datum d2;
        d2 = pop();
        d1 = pop();
        d1.val = (double)(d1.val || d2.val);
        push(d1);
}


not

decompiled_code:
_QWORD *not()
{
__int64 v0; // rdi

if ( COERCE_DOUBLE(pop()) == 0.0 )
v0 = LC7;
else
v0 = LC8;
return push(v0);
}

canonical_decompiled_code:
_QWORD *func25()
{
__int64 v0; // rdi

if ( COERCE_DOUBLE(pop()) == 0.0 )
v0 = LC7;
else
v0 = LC8;
return push(v0);
}

original_code:
void not()
{
        Datum d;
        d = pop();
        d.val = (double)(!d.val);
        push(d);
}

canonical_original_code:
void not()
{
        union Datum d;
        d = pop();
        d.val = (double)(!d.val);
        push(d);
}


whilecode

decompiled_code:
__int64 whilecode()
{
__int64 v0; // rbx
__int64 (**v1)(void); // rbp
__int64 result; // rax

v0 = pc;
v1 = (__int64 (**)(void))(pc + 16);
execute((__int64 (**)(void))(pc + 16));
while ( COERCE_DOUBLE(pop()) != 0.0 )
{
execute(*(__int64 (***)(void))v0);
execute(v1);
}
result = *(_QWORD *)(v0 + 8);
pc = result;
return result;
}

original_code:
void whilecode()
{
 Datum d;
 Inst *savepc = pc;
 execute(savepc+2);
 d = pop();
 while(d.val) {
  execute(*((Inst **)(savepc)));
  execute(savepc+2);
  d = pop();
 }
 pc = *((Inst **)(savepc+1));
}

canonical_original_code:
void whilecode()
{
 union Datum d;
 int (**savepc)() = pc;
 execute(savepc+2);
 d = pop();
 while(d.val) {
  execute(*((int (***)())(savepc)));
  execute(savepc+2);
  d = pop();
 }
 pc = *((int (***)())(savepc+1));
}

variable_types:
savepc
int (**)()


ifcode

decompiled_code:
__int64 ifcode()
{
__int64 v0; // rbx
__int64 (**v1)(void); // rdi
__int64 result; // rax

v0 = pc;
execute((__int64 (**)(void))(pc + 24));
if ( COERCE_DOUBLE(pop()) == 0.0 )
{
v1 = *(__int64 (***)(void))(v0 + 8);
if ( v1 )
execute(v1);
}
else
{
execute(*(__int64 (***)(void))v0);
}
result = *(_QWORD *)(v0 + 16);
pc = result;
return result;
}

original_code:
void ifcode()
{
 Datum d;
 Inst *savepc = pc;
 execute(savepc+3);
 d = pop();
 if(d.val)
  execute(*((Inst **)(savepc)));
 else if (*((Inst **)(savepc+1)))
  execute(*((Inst **)(savepc+1)));
 pc = *((Inst **)(savepc+2));
}

canonical_original_code:
void ifcode()
{
 union Datum d;
 int (**savepc)() = pc;
 execute(savepc+3);
 d = pop();
 if(d.val)
  execute(*((int (***)())(savepc)));
 else if (*((int (***)())(savepc+1)))
  execute(*((int (***)())(savepc+1)));
 pc = *((int (***)())(savepc+2));
}


prexpr

decompiled_code:
int prexpr()
{
double v0; // rax

v0 = COERCE_DOUBLE(pop());
return printf("%.8g\n", v0);
}

canonical_decompiled_code:
int func28()
{
double v0; // rax

v0 = COERCE_DOUBLE(pop());
return printf("%.8g\n", v0);
}

original_code:
void prexpr()
{
 Datum d;
 d = pop();
 printf("%.8g\n", d.val);
}

canonical_original_code:
void prexpr()
{
 union Datum d;
 d = pop();
 printf("%.8g\n", d.val);
}


integer

decompiled_code:
double __fastcall integer(double a1)
{
return (double)(int)a1;
}

canonical_decompiled_code:
double __fastcall func0(double a1)
{
return (double)(int)a1;
}

original_code:
double integer(double x)
{
 return (double)(long)x;
}

variable_types: x double

return_type: double


errcheck

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

v1 = _errno_location();
if ( *v1 == 33 )
{
*v1 = 0;
execerror(a1, "argument out of domain");
}
else if ( *v1 == 34 )
{
*v1 = 0;
execerror(a1, "result out of range");
}
}

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

v1 = _errno_location();
if ( *v1 == 33 )
{
*v1 = 0;
execerror(a1, "argument out of domain");
}
else if ( *v1 == 34 )
{
*v1 = 0;
execerror(a1, "result out of range");
}
}

original_code:
double errcheck(double d, char *s)
{
 if ((*__errno_location ()) == 33) {
  (*__errno_location ()) = 0;
  execerror(s, "argument out of domain");
 } else if ((*__errno_location ()) == 34) {
  (*__errno_location ()) = 0;
  execerror(s, "result out of range");
 }
 return d;
}

variable_types: d double


Log

decompiled_code:
void __fastcall Log(double a1)
{
log(a1);
errcheck((__int64)"log");
}

canonical_decompiled_code:
void __fastcall func2(double a1)
{
log(a1);
func1((__int64)"log");
}

original_code:
double Log(double x)
{
 return errcheck(log(x), "log");
}


decompiled_code:
void __fastcall Log10(double a1)
{
log10(a1);
errcheck((__int64)"log10");
}

canonical_decompiled_code:
void __fastcall func3(double a1)
{
log10(a1);
func1((__int64)"log10");
}

original_code:
double Log10(double x)
{
 return errcheck(log10(x), "log10");
}


Exp

decompiled_code:
void __fastcall Exp(double a1)
{
exp(a1);
errcheck((__int64)"exp");
}

canonical_decompiled_code:
void __fastcall func4(double a1)
{
exp(a1);
func1((__int64)"exp");
}

original_code:
double Exp(double x)
{
 return errcheck(exp(x), "exp");
}


Sqrt

decompiled_code:
void __fastcall Sqrt(double a1)
{
if ( a1 < 0.0 )
sqrt(a1);
errcheck((__int64)"sqrt");
}

canonical_decompiled_code:
void __fastcall func5(double a1)
{
if ( a1 < 0.0 )
sqrt(a1);
func1((__int64)"sqrt");
}

original_code:
double Sqrt(double x)
{
 return errcheck(sqrt(x), "sqrt");
}


Pow

decompiled_code:
void __fastcall Pow(double a1, double a2)
{
pow(a1, a2);
errcheck((__int64)"exponentiation");
}

canonical_decompiled_code:
void __fastcall func6(double a1, double a2)
{
pow(a1, a2);
func1((__int64)"exponentiation");
}

original_code:
double Pow(double x, double y)
{
 return errcheck(pow(x,y), "exponentiation");
}

variable_types: y double


lookup

decompiled_code:
__int64 __fastcall lookup(char *s2)
{
__int64 i; // rbx

for ( i = symlist; i; i = *(_QWORD *)(i + 24) )
{
if ( !strcmp(*(const char **)i, s2) )
break;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s2)
{
__int64 i; // rbx

for ( i = symlist; i; i = *(_QWORD *)(i + 24) )
{
if ( !strcmp(*(const char **)i, s2) )
break;
}
return i;
}

original_code:
Symbol *lookup(char *s)
{
 Symbol *sp;
 for(sp = symlist; sp != (Symbol *) 0; sp = sp->next)
  if (strcmp(sp->name, s) == 0)
   return sp;
 return 0;
}

canonical_original_code:
struct Symbol *lookup(char *s)
{
 struct Symbol *sp;
 for(sp = symlist; sp != (struct Symbol *) 0; sp = sp->next)
  if (strcmp(sp->name, s) == 0)
   return sp;
 return 0;
}

variable_types: struct Symbol { char *name; short type; union { double val; double (*ptr)(); } u; struct Symbol *next; } *


emalloc

decompiled_code:
void *__fastcall emalloc(size_t size)
{
void *v1; // rbx

v1 = malloc((unsigned int)size);
if ( !v1 )
execerror("out of memory", 0LL);
return v1;
}

canonical_decompiled_code:
void *__fastcall func1(size_t size)
{
void *v1; // rbx

v1 = malloc((unsigned int)size);
if ( !v1 )
execerror("out of memory", 0LL);
return v1;
}

original_code:
char *emalloc(unsigned int n)
{
 char *p;
 p = (char *)malloc(n);
 if (p == 0)
  execerror("out of memory", (char *) 0);
 return p;
}

variable_types:
n
unsigned int

variable_types:
p
char *

return_type: char *