decompiled_code:
__int64 __fastcall inverted2(int *a1, double a2)
{
__int64 result; // rax

*a1 = LODWORD(a2) ^ LC1;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = HIDWORD(a2) ^ LC1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(int *a1, double a2)
{
__int64 result; // rax

*a1 = LODWORD(a2) ^ LC1;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = HIDWORD(a2) ^ LC1;
return result;
}

original_code:
inline void inverted2(vec2 * r, vec2 a) {
 r->x = -a.x;
 r->y = -a.y;
}

canonical_original_code:
inline void inverted2(struct vec2 *r, struct vec2 a) {
 r->x = -a.x;
 r->y = -a.y;
}


repo: halcy/rasterizer

decompiled_code:
void __fastcall inverted3(int *a1, double a2, float a3)
{
*a1 = LODWORD(a2) ^ LC1;
a1[1] = HIDWORD(a2) ^ LC1;
a1[2] = LODWORD(a3) ^ LC1;
}

canonical_decompiled_code:
void __fastcall func11(int *a1, double a2, float a3)
{
*a1 = LODWORD(a2) ^ LC1;
a1[1] = HIDWORD(a2) ^ LC1;
a1[2] = LODWORD(a3) ^ LC1;
}

original_code:
inline void inverted3(vec3 * r, vec3 a) {
 r->x = -a.x;
 r->y = -a.y;
 r->z = -a.z;
}

canonical_original_code:
inline void inverted3(struct vec3 *r, struct vec3 a) {
 r->x = -a.x;
 r->y = -a.y;
 r->z = -a.z;
}

variable_types: struct vec3 { float x; float y; float z; } *

variable_types:
a
struct vec3

return_type: void


decompiled_code:
void __fastcall invert2(_DWORD *a1)
{
*a1 ^= LC1;
a1[1] ^= LC1;
}

canonical_decompiled_code:
void __fastcall func12(_DWORD *a1)
{
*a1 ^= LC1;
a1[1] ^= LC1;
}

original_code:
inline void invert2(vec2 * r) {
 r->x = -r->x;
 r->y = -r->y;
}

canonical_original_code:
inline void invert2(struct vec2 *r) {
 r->x = -r->x;
 r->y = -r->y;
}

variable_types:
r
struct vec2 { float x; float y; } *


decompiled_code:
void __fastcall invert3(_DWORD *a1)
{
*a1 ^= LC1;
a1[1] ^= LC1;
a1[2] ^= LC1;
}

original_code:
inline void invert3(vec3 * r) {
 r->x = -r->x;
 r->y = -r->y;
 r->z = -r->z;
}

canonical_original_code:
inline void invert3(struct vec3 *r) {
 r->x = -r->x;
 r->y = -r->y;
 r->z = -r->z;
}

user_defined_types: struct vec3 { float x; float y; float z; }


decompiled_code:
__int64 __fastcall add2(float *a1, double a2, double a3)
{
__int64 result; // rax

*a1 = *(float *)&a2 + *(float *)&a3;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) + *((float *)&a3 + 1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(float *a1, double a2, double a3)
{
__int64 result; // rax

*a1 = *(float *)&a2 + *(float *)&a3;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) + *((float *)&a3 + 1);
return result;
}

original_code:
inline void add2(vec2 * r, vec2 a, vec2 b) {
 r->x = a.x + b.x;
 r->y = a.y + b.y;
}

canonical_original_code:
inline void add2(struct vec2 *r, struct vec2 a, struct vec2 b) {
 r->x = a.x + b.x;
 r->y = a.y + b.y;
}

variable_types:
a
struct vec2

variable_types:
b
struct vec2


decompiled_code:
void __fastcall add3(float *a1, double a2, float a3, double a4, float a5)
{
*a1 = *(float *)&a2 + *(float *)&a4;
a1[1] = *((float *)&a2 + 1) + *((float *)&a4 + 1);
a1[2] = a3 + a5;
}

canonical_decompiled_code:
void __fastcall func15(float *a1, double a2, float a3, double a4, float a5)
{
*a1 = *(float *)&a2 + *(float *)&a4;
a1[1] = *((float *)&a2 + 1) + *((float *)&a4 + 1);
a1[2] = a3 + a5;
}

original_code:
inline void add3(vec3 * r, vec3 a, vec3 b) {
 r->x = a.x + b.x;
 r->y = a.y + b.y;
 r->z = a.z + b.z;
}

canonical_original_code:
inline void add3(struct vec3 *r, struct vec3 a, struct vec3 b) {
 r->x = a.x + b.x;
 r->y = a.y + b.y;
 r->z = a.z + b.z;
}

variable_types:
b
struct vec3


decompiled_code:
__int64 __fastcall addTo2(float *a1, double a2)
{
__int64 result; // rax

*a1 = *(float *)&a2 + *a1;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) + a1[1];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(float *a1, double a2)
{
__int64 result; // rax

*a1 = *(float *)&a2 + *a1;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) + a1[1];
return result;
}

original_code:
inline void addTo2(vec2 * r, vec2 a) {
 r->x += a.x;
 r->y += a.y;
}

canonical_original_code:
inline void addTo2(struct vec2 *r, struct vec2 a) {
 r->x += a.x;
 r->y += a.y;
}


original_code:
inline void addTo3(vec3 * r, vec3 a) {
 r->x += a.x;
 r->y += a.y;
 r->z += a.z;
}

canonical_original_code:
inline void addTo3(struct vec3 *r, struct vec3 a) {
 r->x += a.x;
 r->y += a.y;
 r->z += a.z;
}


decompiled_code:
__int64 __fastcall sub2(float *a1, double a2, double a3)
{
__int64 result; // rax

*a1 = *(float *)&a2 - *(float *)&a3;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) - *((float *)&a3 + 1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func18(float *a1, double a2, double a3)
{
__int64 result; // rax

*a1 = *(float *)&a2 - *(float *)&a3;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) - *((float *)&a3 + 1);
return result;
}

original_code:
inline void sub2(vec2 * r, vec2 a, vec2 b) {
 r->x = a.x - b.x;
 r->y = a.y - b.y;
}

canonical_original_code:
inline void sub2(struct vec2 *r, struct vec2 a, struct vec2 b) {
 r->x = a.x - b.x;
 r->y = a.y - b.y;
}


decompiled_code:
void __fastcall sub3(float *a1, double a2, float a3, double a4, float a5)
{
*a1 = *(float *)&a2 - *(float *)&a4;
a1[1] = *((float *)&a2 + 1) - *((float *)&a4 + 1);
a1[2] = a3 - a5;
}

canonical_decompiled_code:
void __fastcall func19(float *a1, double a2, float a3, double a4, float a5)
{
*a1 = *(float *)&a2 - *(float *)&a4;
a1[1] = *((float *)&a2 + 1) - *((float *)&a4 + 1);
a1[2] = a3 - a5;
}

original_code:
inline void sub3(vec3 * r, vec3 a, vec3 b) {
 r->x = a.x - b.x;
 r->y = a.y - b.y;
 r->z = a.z - b.z;
}

canonical_original_code:
inline void sub3(struct vec3 *r, struct vec3 a, struct vec3 b) {
 r->x = a.x - b.x;
 r->y = a.y - b.y;
 r->z = a.z - b.z;
}


decompiled_code:
__int64 __fastcall subFrom2(float *a1, double a2)
{
__int64 result; // rax

*a1 = *a1 - *(float *)&a2;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = a1[1] - *((float *)&a2 + 1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func20(float *a1, double a2)
{
__int64 result; // rax

*a1 = *a1 - *(float *)&a2;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = a1[1] - *((float *)&a2 + 1);
return result;
}

original_code:
inline void subFrom2(vec2 * r, vec2 a) {
 r->x -= a.x;
 r->y -= a.y;
}

canonical_original_code:
inline void subFrom2(struct vec2 *r, struct vec2 a) {
 r->x -= a.x;
 r->y -= a.y;
}


original_code:
inline void subFrom3(vec3 * r, vec3 a) {
 r->x -= a.x;
 r->y -= a.y;
 r->z -= a.z;
}

canonical_original_code:
inline void subFrom3(struct vec3 *r, struct vec3 a) {
 r->x -= a.x;
 r->y -= a.y;
 r->z -= a.z;
}


decompiled_code:
float __fastcall dot2(double a1, double a2)
{
return (float)(*((float *)&a1 + 1) * *((float *)&a2 + 1)) + (float)(*(float *)&a1 * *(float *)&a2);
}

canonical_decompiled_code:
float __fastcall func22(double a1, double a2)
{
return (float)(*((float *)&a1 + 1) * *((float *)&a2 + 1)) + (float)(*(float *)&a1 * *(float *)&a2);
}

original_code:
inline float dot2(vec2 a, vec2 b) {
 return( a.x*b.x + a.y*b.y );
}

canonical_original_code:
inline float dot2(struct vec2 a, struct vec2 b) {
 return( a.x*b.x + a.y*b.y );
}

variable_types:
a
struct vec2 { float x; float y; }

return_type: float


decompiled_code:
float __fastcall dot3(double a1, float a2, double a3, float a4)
{
return (float)((float)(*(float *)&a1 * *(float *)&a3) + (float)(*((float *)&a1 + 1) * *((float *)&a3 + 1)))
+ (float)(a2 * a4);
}

canonical_decompiled_code:
float __fastcall func23(double a1, float a2, double a3, float a4)
{
return (float)((float)(*(float *)&a1 * *(float *)&a3) + (float)(*((float *)&a1 + 1) * *((float *)&a3 + 1)))
+ (float)(a2 * a4);
}

original_code:
inline float dot3(vec3 a, vec3 b) {
 return( a.x*b.x + a.y*b.y + a.z*b.z );
}

canonical_original_code:
inline float dot3(struct vec3 a, struct vec3 b) {
 return( a.x*b.x + a.y*b.y + a.z*b.z );
}

variable_types: struct vec3 { float x; float y; float z; }


cross

decompiled_code:
void __fastcall cross(float *a1, double a2, float a3, double a4, float a5)
{
*a1 = (float)(a5 * *((float *)&a2 + 1)) - (float)(a3 * *((float *)&a4 + 1));
a1[1] = (float)(*(float *)&a4 - *(float *)&a2) * a3;
a1[2] = (float)(*((float *)&a4 + 1) - *((float *)&a2 + 1)) * *(float *)&a2;
}

original_code:
inline void cross(vec3 * r, vec3 a, vec3 b) {
 r->x = a.y * b.z - a.z * b.y;
 r->y = a.z * b.x - a.x * a.z;
 r->z = a.x * b.y - a.y * a.x;
}

canonical_original_code:
inline void cross(struct vec3 *r, struct vec3 a, struct vec3 b) {
 r->x = a.y * b.z - a.z * b.y;
 r->y = a.z * b.x - a.x * a.z;
 r->z = a.x * b.y - a.y * a.x;
}


decompiled_code:
float __fastcall length2(double a1)
{
return fsqrt((float)(*((float *)&a1 + 1) * *((float *)&a1 + 1)) + (float)(*(float *)&a1 * *(float *)&a1));
}

canonical_decompiled_code:
float __fastcall func25(double a1)
{
return fsqrt((float)(*((float *)&a1 + 1) * *((float *)&a1 + 1)) + (float)(*(float *)&a1 * *(float *)&a1));
}

original_code:
inline float length2(vec2 v) {
 return( sqrt( v.x * v.x + v.y * v.y ) );
}

canonical_original_code:
inline float length2(struct vec2 v) {
 return( sqrt( v.x * v.x + v.y * v.y ) );
}

variable_types:
v
struct vec2 { float x; float y; }


decompiled_code:
float __fastcall length3(double a1, float a2)
{
return fsqrt(
(float)((float)(*(float *)&a1 * *(float *)&a1) + (float)(*((float *)&a1 + 1) * *((float *)&a1 + 1)))
+ (float)(a2 * a2));
}

canonical_decompiled_code:
float __fastcall func26(double a1, float a2)
{
return fsqrt(
(float)((float)(*(float *)&a1 * *(float *)&a1) + (float)(*((float *)&a1 + 1) * *((float *)&a1 + 1)))
+ (float)(a2 * a2));
}

original_code:
inline float length3(vec3 v) {
 return( sqrt( v.x * v.x + v.y * v.y + + v.z * v.z ) );
}

canonical_original_code:
inline float length3(struct vec3 v) {
 return( sqrt( v.x * v.x + v.y * v.y + + v.z * v.z ) );
}


decompiled_code:
float __fastcall dist2(double a1, double a2)
{
return fsqrt(
(float)((float)(*((float *)&a1 + 1) - *((float *)&a2 + 1))
* (float)(*((float *)&a1 + 1) - *((float *)&a2 + 1)))
+ (float)((float)(*(float *)&a1 - *(float *)&a2) * (float)(*(float *)&a1 - *(float *)&a2)));
}

canonical_decompiled_code:
float __fastcall func27(double a1, double a2)
{
return fsqrt(
(float)((float)(*((float *)&a1 + 1) - *((float *)&a2 + 1))
* (float)(*((float *)&a1 + 1) - *((float *)&a2 + 1)))
+ (float)((float)(*(float *)&a1 - *(float *)&a2) * (float)(*(float *)&a1 - *(float *)&a2)));
}

original_code:
inline float dist2(vec2 a, vec2 b) {
 float xd = a.x - b.x;
 float yd = a.y - b.y;
 return( sqrt( xd * xd + yd * yd ) );
}

canonical_original_code:
inline float dist2(struct vec2 a, struct vec2 b) {
 float xd = a.x - b.x;
 float yd = a.y - b.y;
 return( sqrt( xd * xd + yd * yd ) );
}

variable_types: xd float

variable_types: yd float


decompiled_code:
float __fastcall dist3(double a1, double a2, double a3)
{
return fsqrt(
(float)((float)((float)(*((float *)&a1 + 1) - *((float *)&a3 + 1))
* (float)(*((float *)&a1 + 1) - *((float *)&a3 + 1)))
+ (float)((float)(*((float *)&a1 + 1) - *((float *)&a3 + 1))
* (float)(*((float *)&a1 + 1) - *((float *)&a3 + 1))))
+ (float)((float)(*(float *)&a1 - *(float *)&a3) * (float)(*(float *)&a1 - *(float *)&a3)));
}

canonical_decompiled_code:
float __fastcall func28(double a1, double a2, double a3)
{
return fsqrt(
(float)((float)((float)(*((float *)&a1 + 1) - *((float *)&a3 + 1))
* (float)(*((float *)&a1 + 1) - *((float *)&a3 + 1)))
+ (float)((float)(*((float *)&a1 + 1) - *((float *)&a3 + 1))
* (float)(*((float *)&a1 + 1) - *((float *)&a3 + 1))))
+ (float)((float)(*(float *)&a1 - *(float *)&a3) * (float)(*(float *)&a1 - *(float *)&a3)));
}

original_code:
inline float dist3(vec3 a, vec3 b) {
 float xd = a.x - b.x;
 float yd = a.y - b.y;
 float zd = a.y - b.y;
 return( sqrt( xd * xd + yd * yd + zd * zd ) );
}

canonical_original_code:
inline float dist3(struct vec3 a, struct vec3 b) {
 float xd = a.x - b.x;
 float yd = a.y - b.y;
 float zd = a.y - b.y;
 return( sqrt( xd * xd + yd * yd + zd * zd ) );
}

variable_types: zd float


decompiled_code:
__int64 __fastcall normalized2(float *a1, double a2)
{
float v3; // xmm1_4

v3 = length2(a2);
return div2(a1, a2, v3);
}

canonical_decompiled_code:
__int64 __fastcall func29(float *a1, double a2)
{
float v3; // xmm1_4

v3 = func25(a2);
return func6(a1, a2, v3);
}

original_code:
inline void normalized2(vec2 * r, vec2 v) {
 float l = length2( v );
 div2( r, v, l );
}

canonical_original_code:
inline void normalized2(struct vec2 *r, struct vec2 v) {
 float l = length2( v );
 div2( r, v, l );
}

variable_types:
v
struct vec2

variable_types: l float


decompiled_code:
void __fastcall normalized3(float *a1, double a2, float a3)
{
float v4; // xmm2_4

v4 = length3(a2, a3);
div3(a1, a2, a3, v4);
}

canonical_decompiled_code:
void __fastcall func30(float *a1, double a2, float a3)
{
float v4; // xmm2_4

v4 = func26(a2, a3);
func7(a1, a2, a3, v4);
}

original_code:
inline void normalized3(vec3 * r, vec3 v) {
 float l = length3( v );
 div3( r, v, l );
}

canonical_original_code:
inline void normalized3(struct vec3 *r, struct vec3 v) {
 float l = length3( v );
 div3( r, v, l );
}

variable_types:
v
struct vec3


decompiled_code:
void __fastcall normalize2(double *a1)
{
float v1; // xmm0_4

v1 = length2(*a1);
invScale2((float *)a1, v1);
}

canonical_decompiled_code:
void __fastcall func31(double *a1)
{
float v1; // xmm0_4

v1 = func25(*a1);
func8((float *)a1, v1);
}

original_code:
inline void normalize2(vec2 * r) {
 float l = length2( *r );
 invScale2( r, l );
}

canonical_original_code:
inline void normalize2(struct vec2 *r) {
 float l = length2( *r );
 invScale2( r, l );
}


decompiled_code:
void __fastcall normalize3(__int64 a1)
{
float v1; // xmm0_4

v1 = length3(*(double *)a1, *(float *)(a1 + 8));
invScale3((float *)a1, v1);
}

canonical_decompiled_code:
void __fastcall func32(__int64 a1)
{
float v1; // xmm0_4

v1 = func26(*(double *)a1, *(float *)(a1 + 8));
func9((float *)a1, v1);
}

original_code:
inline void normalize3(vec3 * r) {
 float l = length3( *r );
 invScale3( r, l );
}

canonical_original_code:
inline void normalize3(struct vec3 *r) {
 float l = length3( *r );
 invScale3( r, l );
}


decompiled_code:
__int64 __fastcall reflected2(float *a1, double a2, double a3)
{
float v4; // xmm0_4

v4 = dot2(a3, a2);
mult2(a1, a3, v4 + v4);
return subFrom2(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func33(float *a1, double a2, double a3)
{
float v4; // xmm0_4

v4 = func22(a3, a2);
func2(a1, a3, v4 + v4);
return func20(a1, a2);
}

original_code:
inline void reflected2(vec2 * r, vec2 i, vec2 n) {
 mult2( r, n, dot2( n, i ) * ((float)2) );
 subFrom2( r, i );
}

canonical_original_code:
inline void reflected2(struct vec2 *r, struct vec2 i, struct vec2 n) {
 mult2( r, n, dot2( n, i ) * ((float)2) );
 subFrom2( r, i );
}

variable_types:
i
struct vec2

variable_types:
n
struct vec2


decompiled_code:
void __fastcall reflected3(float *a1, double a2, float a3, double a4, float a5)
{
float v5; // xmm0_4

v5 = dot3(a4, a5, a2, a3);
mult3(a1, a4, a5, v5 + v5);
subFrom3(a1, a2, a3);
}

canonical_decompiled_code:
void __fastcall func34(float *a1, double a2, float a3, double a4, float a5)
{
float v5; // xmm0_4

v5 = func23(a4, a5, a2, a3);
func3(a1, a4, a5, v5 + v5);
func21(a1, a2, a3);
}

original_code:
inline void reflected3(vec3 * r, vec3 i, vec3 n) {
 mult3( r, n, dot3( n, i ) * ((float)2) );
 subFrom3( r, i );
}

canonical_original_code:
inline void reflected3(struct vec3 *r, struct vec3 i, struct vec3 n) {
 mult3( r, n, dot3( n, i ) * ((float)2) );
 subFrom3( r, i );
}

variable_types: struct vec3 { float x; float y; float z; } *

variable_types:
i
struct vec3

variable_types:
n
struct vec3


decompiled_code:
__int64 __fastcall reflect2(double *a1, double a2)
{
double v3; // r12
float v4; // xmm0_4

v3 = *a1;
v4 = dot2(a2, *a1);
mult2((float *)a1, a2, v4 + v4);
return subFrom2((float *)a1, v3);
}

canonical_decompiled_code:
__int64 __fastcall func35(double *a1, double a2)
{
double v3; // r12
float v4; // xmm0_4

v3 = *a1;
v4 = func22(a2, *a1);
func2((float *)a1, a2, v4 + v4);
return func20((float *)a1, v3);
}

original_code:
inline void reflect2(vec2 * r, vec2 n) {
 vec2 i = *r;
 mult2( r, n, dot2( n, i ) * ((float)2) );
 subFrom2( r, i );
}

canonical_original_code:
inline void reflect2(struct vec2 *r, struct vec2 n) {
 struct vec2 i = *r;
 mult2( r, n, dot2( n, i ) * ((float)2) );
 subFrom2( r, i );
}

variable_types:
r
struct vec2 { float x; float y; } *

variable_types:
i
struct vec2 { float x; float y; }


decompiled_code:
void __fastcall reflect3(__int64 a1, double a2, float a3)
{
float v4; // xmm0_4
double v5; // [rsp+1Ch] [rbp-1Ch]
float v6; // [rsp+24h] [rbp-14h]

v5 = *(double *)a1;
v6 = *(float *)(a1 + 8);
v4 = dot3(a2, a3, v5, v6);
mult3((float *)a1, a2, a3, v4 + v4);
subFrom3((float *)a1, v5, v6);
}

canonical_decompiled_code:
void __fastcall func36(__int64 a1, double a2, float a3)
{
float v4; // xmm0_4
double v5; // [rsp+1Ch] [rbp-1Ch]
float v6; // [rsp+24h] [rbp-14h]

v5 = *(double *)a1;
v6 = *(float *)(a1 + 8);
v4 = func23(a2, a3, v5, v6);
func3((float *)a1, a2, a3, v4 + v4);
func21((float *)a1, v5, v6);
}

original_code:
inline void reflect3(vec3 * r, vec3 n) {
 vec3 i = *r;
 mult3( r, n, dot3( n, i ) * ((float)2) );
 subFrom3( r, i );
}

canonical_original_code:
inline void reflect3(struct vec3 *r, struct vec3 n) {
 struct vec3 i = *r;
 mult3( r, n, dot3( n, i ) * ((float)2) );
 subFrom3( r, i );
}


vecAtan

decompiled_code:
float __fastcall vecAtan(__m128i a1)
{
return _atan2_finite(COERCE_FLOAT(_mm_cvtsi128_si32(a1)), *(float *)&a1.m128i_i32[1]);
}

canonical_decompiled_code:
float __fastcall func37(__m128i a1)
{
return _atan2_finite(COERCE_FLOAT(_mm_cvtsi128_si32(a1)), *(float *)&a1.m128i_i32[1]);
}

original_code:
inline float vecAtan(vec2 c) {
 return (atan2((c.x),(c.y)));
}

canonical_original_code:
inline float vecAtan(struct vec2 c) {
 return (atan2((c.x),(c.y)));
}

variable_types:
c
struct vec2 { float x; float y; }


extendTo

decompiled_code:
void __fastcall extendTo(float *a1, double a2, float a3)
{
double v3; // [rsp+14h] [rbp-14h] BYREF
float v4; // [rsp+1Ch] [rbp-Ch]

mult3((float *)&v3, a2, a3, 0.1);
addTo3(a1, v3, v4);
}

canonical_decompiled_code:
void __fastcall func38(float *a1, double a2, float a3)
{
double v3; // [rsp+14h] [rbp-14h] BYREF
float v4; // [rsp+1Ch] [rbp-Ch]

func3((float *)&v3, a2, a3, 0.1);
func17(a1, v3, v4);
}

original_code:
inline void extendTo(vec3 * r, vec3 d) {
 vec3 ext;
 mult3( &ext, d, 0.1 );
 addTo3( r, ext );
}

canonical_original_code:
inline void extendTo(struct vec3 *r, struct vec3 d) {
 struct vec3 ext;
 mult3( &ext, d, 0.1 );
 addTo3( r, ext );
}

variable_types:
d
struct vec3


decompiled_code:
int __fastcall vecPrintf3(double a1, float a2)
{
return printf("%f, %f, %f\n", *(float *)&a1, *((float *)&a1 + 1), a2);
}

canonical_decompiled_code:
int __fastcall func39(double a1, float a2)
{
return printf("%f, %f, %f\n", *(float *)&a1, *((float *)&a1 + 1), a2);
}

original_code:
void vecPrintf3(vec3 v) {
 printf( "%f, %f, %f\n", v.x, v.y, v.z );
}

canonical_original_code:
void vecPrintf3(struct vec3 v) {
 printf( "%f, %f, %f\n", v.x, v.y, v.z );
}

variable_types: struct vec3 { float x; float y; float z; }


makeColour

decompiled_code:
__int64 __fastcall makeColour(double a1, __m128i a2)
{
return (unsigned int)_mm_cvtsi128_si32(a2) | 0x3F80000000000000LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(double a1, __m128i a2)
{
return (unsigned int)_mm_cvtsi128_si32(a2) | 0x3F80000000000000LL;
}

original_code:
inline colour makeColour(float r, float g, float b) {
 colour c;
 c.r = r;
 c.g = g;
 c.b = b;
 c.a = ((float)1);
 return c;
}

canonical_original_code:
inline struct colour makeColour(float r, float g, float b) {
 struct colour c;
 c.r = r;
 c.g = g;
 c.b = b;
 c.a = ((float)1);
 return c;
}

variable_types: r float

variable_types: g float

variable_types: b float

variable_types: struct colour { float r; float b; float g; float a; }


makeColourA

decompiled_code:
unsigned __int64 __fastcall makeColourA(double a1, __m128i a2, double a3, __m128i a4)
{
return ((unsigned __int64)(unsigned int)_mm_cvtsi128_si32(a4) << 32) | (unsigned int)_mm_cvtsi128_si32(a2);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(double a1, __m128i a2, double a3, __m128i a4)
{
return ((unsigned __int64)(unsigned int)_mm_cvtsi128_si32(a4) << 32) | (unsigned int)_mm_cvtsi128_si32(a2);
}

original_code:
inline colour makeColourA(float r, float g, float b, float a) {
 colour c;
 c.r = r;
 c.g = g;
 c.b = b;
 c.a = a;
 return c;
}

canonical_original_code:
inline struct colour makeColourA(float r, float g, float b, float a) {
 struct colour c;
 c.r = r;
 c.g = g;
 c.b = b;
 c.a = a;
 return c;
}

variable_types: a float

return_type: struct colour { float r; float b; float g; float a; }


grey

decompiled_code:
double __fastcall grey(__m128i a1)
{
double result; // xmm0_8

*(_QWORD *)&result = (unsigned int)_mm_cvtsi128_si32(a1) | ((unsigned __int64)(unsigned int)_mm_cvtsi128_si32(a1) << 32);
return result;
}

canonical_decompiled_code:
double __fastcall func2(__m128i a1)
{
double result; // xmm0_8

*(_QWORD *)&result = (unsigned int)_mm_cvtsi128_si32(a1) | ((unsigned __int64)(unsigned int)_mm_cvtsi128_si32(a1) << 32);
return result;
}

original_code:
inline colour grey(float v) {
 colour c;
 c.r = v;
 c.g = v;
 c.b = v;
 c.a = ((float)1);
 return c;
}

canonical_original_code:
inline struct colour grey(float v) {
 struct colour c;
 c.r = v;
 c.g = v;
 c.b = v;
 c.a = ((float)1);
 return c;
}

variable_types: v float

user_defined_types: struct colour { float r; float b; float g; float a; }


clip

variable_types: struct colour { float r; float b; float g; float a; } *


clipped

decompiled_code:
unsigned __int64 __fastcall clipped(float *a1, __m128i a2, float a3)
{
unsigned __int64 v3; // rax
float v4; // xmm0_4
float v5; // xmm0_4
unsigned __int64 result; // rax
float v7; // xmm0_4

v3 = a2.m128i_i64[0];
v4 = fmax(fmin(COERCE_FLOAT(_mm_cvtsi128_si32(a2)), 1.0), 0.0);
*a1 = v4;
v5 = fmax(fmin(a3, 1.0), 0.0);
a1[2] = v5;
result = HIDWORD(v3);
v7 = fmax(fmin(*(float *)&result, 1.0), 0.0);
a1[1] = v7;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func4(float *a1, __m128i a2, float a3)
{
unsigned __int64 v3; // rax
float v4; // xmm0_4
float v5; // xmm0_4
unsigned __int64 result; // rax
float v7; // xmm0_4

v3 = a2.m128i_i64[0];
v4 = fmax(fmin(COERCE_FLOAT(_mm_cvtsi128_si32(a2)), 1.0), 0.0);
*a1 = v4;
v5 = fmax(fmin(a3, 1.0), 0.0);
a1[2] = v5;
result = HIDWORD(v3);
v7 = fmax(fmin(*(float *)&result, 1.0), 0.0);
a1[1] = v7;
return result;
}

variable_types:
c
struct colour


makePositive

canonical_original_code:
inline void makePositive(struct colour *c) {
 c->r = (fmin((c->r),(1.0)));
 c->g = (fmin((c->g),(1.0)));
 c->b = (fmin((c->b),(1.0)));
}


applyGamma

decompiled_code:
void __fastcall applyGamma(float *a1, double a2)
{
int v2; // [rsp+Ch] [rbp-Ch]

v2 = LODWORD(a2);
*a1 = _powf_finite(*a1, a2);
a1[2] = _powf_finite(a1[2], COERCE_DOUBLE((unsigned __int64)v2));
a1[1] = _powf_finite(a1[1], COERCE_DOUBLE((unsigned __int64)v2));
}

canonical_decompiled_code:
void __fastcall func6(float *a1, double a2)
{
int v2; // [rsp+Ch] [rbp-Ch]

v2 = LODWORD(a2);
*a1 = _powf_finite(*a1, a2);
a1[2] = _powf_finite(a1[2], COERCE_DOUBLE((unsigned __int64)v2));
a1[1] = _powf_finite(a1[1], COERCE_DOUBLE((unsigned __int64)v2));
}

original_code:
inline void applyGamma(colour * r, float gamma) {
 r->r = (powf((r->r),(gamma)));
 r->g = (powf((r->g),(gamma)));
 r->b = (powf((r->b),(gamma)));
}

canonical_original_code:
inline void applyGamma(struct colour *r, float gamma) {
 r->r = (powf((r->r),(gamma)));
 r->g = (powf((r->g),(gamma)));
 r->b = (powf((r->b),(gamma)));
}

variable_types: gamma float


brighten

original_code:
inline void brighten(colour * c, float f) {
 c->r = c->r + f;
 c->g = c->g + f;
 c->b = c->b + f;
}

canonical_original_code:
inline void brighten(struct colour *c, float f) {
 c->r = c->r + f;
 c->g = c->g + f;
 c->b = c->b + f;
}

variable_types: f float


brightened

decompiled_code:
__int64 __fastcall brightened(float *a1, double a2, float a3, float a4)
{
__int64 result; // rax

*a1 = *(float *)&a2 + a4;
a1[2] = a3 + a4;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = a4 + *((float *)&a2 + 1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(float *a1, double a2, float a3, float a4)
{
__int64 result; // rax

*a1 = *(float *)&a2 + a4;
a1[2] = a3 + a4;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = a4 + *((float *)&a2 + 1);
return result;
}

original_code:
inline void brightened(colour * r, colour c, float f) {
 r->r = c.r + f;
 r->g = c.g + f;
 r->b = c.b + f;
}

canonical_original_code:
inline void brightened(struct colour *r, struct colour c, float f) {
 r->r = c.r + f;
 r->g = c.g + f;
 r->b = c.b + f;
}


darken

original_code:
inline void darken(colour * c, float f) {
 c->r = c->r - f;
 c->g = c->g - f;
 c->b = c->b - f;
}

canonical_original_code:
inline void darken(struct colour *c, float f) {
 c->r = c->r - f;
 c->g = c->g - f;
 c->b = c->b - f;
}


darkened

decompiled_code:
__int64 __fastcall darkened(float *a1, double a2, float a3, float a4)
{
__int64 result; // rax

*a1 = *(float *)&a2 - a4;
a1[2] = a3 - a4;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) - a4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(float *a1, double a2, float a3, float a4)
{
__int64 result; // rax

*a1 = *(float *)&a2 - a4;
a1[2] = a3 - a4;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) - a4;
return result;
}

original_code:
inline void darkened(colour * r, colour c, float f) {
 r->r = c.r - f;
 r->g = c.g - f;
 r->b = c.b - f;
}

canonical_original_code:
inline void darkened(struct colour *r, struct colour c, float f) {
 r->r = c.r - f;
 r->g = c.g - f;
 r->b = c.b - f;
}


scale

original_code:
inline void scale(colour * c, float f) {
 c->r = c->r * f;
 c->g = c->g * f;
 c->b = c->b * f;
}

canonical_original_code:
inline void scale(struct colour *c, float f) {
 c->r = c->r * f;
 c->g = c->g * f;
 c->b = c->b * f;
}


scaled

decompiled_code:
__int64 __fastcall scaled(float *a1, double a2, float a3, float a4)
{
__int64 result; // rax

*a1 = *(float *)&a2 * a4;
a1[2] = a3 * a4;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = a4 * *((float *)&a2 + 1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(float *a1, double a2, float a3, float a4)
{
__int64 result; // rax

*a1 = *(float *)&a2 * a4;
a1[2] = a3 * a4;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = a4 * *((float *)&a2 + 1);
return result;
}

original_code:
inline void scaled(colour * r, colour c, float f) {
 r->r = c.r * f;
 r->g = c.g * f;
 r->b = c.b * f;
}

canonical_original_code:
inline void scaled(struct colour *r, struct colour c, float f) {
 r->r = c.r * f;
 r->g = c.g * f;
 r->b = c.b * f;
}


scaledDown

decompiled_code:
__int64 __fastcall scaledDown(float *a1, double a2, float a3, float a4)
{
__int64 result; // rax

*a1 = *(float *)&a2 * (float)(1.0 / a4);
a1[2] = a3 * (float)(1.0 / a4);
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = (float)(1.0 / a4) * *((float *)&a2 + 1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(float *a1, double a2, float a3, float a4)
{
__int64 result; // rax

*a1 = *(float *)&a2 * (float)(1.0 / a4);
a1[2] = a3 * (float)(1.0 / a4);
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = (float)(1.0 / a4) * *((float *)&a2 + 1);
return result;
}

original_code:
inline void scaledDown(colour * r, colour c, float f) {
 r->r = c.r / f;
 r->g = c.g / f;
 r->b = c.b / f;
}

canonical_original_code:
inline void scaledDown(struct colour *r, struct colour c, float f) {
 r->r = c.r / f;
 r->g = c.g / f;
 r->b = c.b / f;
}


mult

decompiled_code:
__int64 __fastcall mult(float *a1, double a2, float a3)
{
__int64 result; // rax

*a1 = *(float *)&a2 * *a1;
a1[2] = a3 * a1[2];
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) * a1[1];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(float *a1, double a2, float a3)
{
__int64 result; // rax

*a1 = *(float *)&a2 * *a1;
a1[2] = a3 * a1[2];
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) * a1[1];
return result;
}

original_code:
inline void mult(colour * c, colour a) {
 c->r = c->r * a.r;
 c->g = c->g * a.g;
 c->b = c->b * a.b;
}

canonical_original_code:
inline void mult(struct colour *c, struct colour a) {
 c->r = c->r * a.r;
 c->g = c->g * a.g;
 c->b = c->b * a.b;
}

variable_types:
a
struct colour


multiplied

decompiled_code:
__int64 __fastcall multiplied(float *a1, double a2, float a3, double a4, float a5)
{
__int64 result; // rax

*a1 = *(float *)&a2 * *(float *)&a4;
a1[2] = a3 * a5;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) * *((float *)&a4 + 1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(float *a1, double a2, float a3, double a4, float a5)
{
__int64 result; // rax

*a1 = *(float *)&a2 * *(float *)&a4;
a1[2] = a3 * a5;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) * *((float *)&a4 + 1);
return result;
}

original_code:
inline void multiplied(colour * r, colour a, colour b) {
 r->r = a.r * b.r;
 r->g = a.g * b.g;
 r->b = a.b * b.b;
}

canonical_original_code:
inline void multiplied(struct colour *r, struct colour a, struct colour b) {
 r->r = a.r * b.r;
 r->g = a.g * b.g;
 r->b = a.b * b.b;
}

variable_types:
b
struct colour


divide

decompiled_code:
__int64 __fastcall divide(float *a1, double a2, float a3)
{
__int64 result; // rax

*a1 = *a1 / *(float *)&a2;
a1[2] = a1[2] / a3;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = a1[1] / *((float *)&a2 + 1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(float *a1, double a2, float a3)
{
__int64 result; // rax

*a1 = *a1 / *(float *)&a2;
a1[2] = a1[2] / a3;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = a1[1] / *((float *)&a2 + 1);
return result;
}

original_code:
inline void divide(colour * c, colour a) {
 c->r = c->r / a.r;
 c->g = c->g / a.g;
 c->b = c->b / a.b;
}

canonical_original_code:
inline void divide(struct colour *c, struct colour a) {
 c->r = c->r / a.r;
 c->g = c->g / a.g;
 c->b = c->b / a.b;
}


divided

decompiled_code:
__int64 __fastcall divided(float *a1, double a2, float a3, double a4, float a5)
{
__int64 result; // rax

*a1 = *(float *)&a2 / *(float *)&a4;
a1[2] = a3 / a5;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) / *((float *)&a4 + 1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(float *a1, double a2, float a3, double a4, float a5)
{
__int64 result; // rax

*a1 = *(float *)&a2 / *(float *)&a4;
a1[2] = a3 / a5;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) / *((float *)&a4 + 1);
return result;
}

original_code:
inline void divided(colour * r, colour a, colour b) {
 r->r = a.r / b.r;
 r->g = a.g / b.g;
 r->b = a.b / b.b;
}

canonical_original_code:
inline void divided(struct colour *r, struct colour a, struct colour b) {
 r->r = a.r / b.r;
 r->g = a.g / b.g;
 r->b = a.b / b.b;
}


additiveMix

decompiled_code:
__int64 __fastcall additiveMix(float *a1, double a2, float a3)
{
__int64 result; // rax

*a1 = *(float *)&a2 + *a1;
a1[2] = a3 + a1[2];
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) + a1[1];
return result;
}

canonical_decompiled_code:
__int64 __fastcall func18(float *a1, double a2, float a3)
{
__int64 result; // rax

*a1 = *(float *)&a2 + *a1;
a1[2] = a3 + a1[2];
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) + a1[1];
return result;
}

original_code:
inline void additiveMix(colour * c, colour a) {
 c->r = c->r + a.r;
 c->g = c->g + a.g;
 c->b = c->b + a.b;
}

canonical_original_code:
inline void additiveMix(struct colour *c, struct colour a) {
 c->r = c->r + a.r;
 c->g = c->g + a.g;
 c->b = c->b + a.b;
}


additiveMixed

decompiled_code:
__int64 __fastcall additiveMixed(float *a1, double a2, float a3, double a4, float a5)
{
__int64 result; // rax

*a1 = *(float *)&a2 + *(float *)&a4;
a1[2] = a3 + a5;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) + *((float *)&a4 + 1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func19(float *a1, double a2, float a3, double a4, float a5)
{
__int64 result; // rax

*a1 = *(float *)&a2 + *(float *)&a4;
a1[2] = a3 + a5;
result = HIDWORD(*(_QWORD *)&a2);
a1[1] = *((float *)&a2 + 1) + *((float *)&a4 + 1);
return result;
}

original_code:
inline void additiveMixed(colour * r, colour a, colour b) {
 r->r = a.r + b.r;
 r->g = a.g + b.g;
 r->b = a.b + b.b;
}

canonical_original_code:
inline void additiveMixed(struct colour *r, struct colour a, struct colour b) {
 r->r = a.r + b.r;
 r->g = a.g + b.g;
 r->b = a.b + b.b;
}


sameColour

decompiled_code:
_BOOL8 __fastcall sameColour(double a1, float a2, double a3, float a4)
{
if ( *(float *)&a1 != *(float *)&a3 )
return 0;
if ( a2 == a4 )
return *((float *)&a1 + 1) == *((float *)&a3 + 1);
return 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func20(double a1, float a2, double a3, float a4)
{
if ( *(float *)&a1 != *(float *)&a3 )
return 0;
if ( a2 == a4 )
return *((float *)&a1 + 1) == *((float *)&a3 + 1);
return 0;
}

original_code:
inline _Bool sameColour(colour a, colour b) {
 return( a.r == b.r && a.g == b.g && a.b == b.b );
}

canonical_original_code:
inline _Bool sameColour(struct colour a, struct colour b) {
 return( a.r == b.r && a.g == b.g && a.b == b.b );
}


colourDist

decompiled_code:
float __fastcall colourDist(double a1, float a2, double a3, float a4)
{
return (float)(a2 - a4) * (float)(a2 - a4) * 0.4
+ (float)(*(float *)&a1 - *(float *)&a3) * (float)(*(float *)&a1 - *(float *)&a3) * 0.3
+ (float)(*((float *)&a1 + 1) - *((float *)&a3 + 1)) * (float)(*((float *)&a1 + 1) - *((float *)&a3 + 1)) * 0.2;
}

canonical_decompiled_code:
float __fastcall func21(double a1, float a2, double a3, float a4)
{
return (float)(a2 - a4) * (float)(a2 - a4) * 0.4
+ (float)(*(float *)&a1 - *(float *)&a3) * (float)(*(float *)&a1 - *(float *)&a3) * 0.3
+ (float)(*((float *)&a1 + 1) - *((float *)&a3 + 1)) * (float)(*((float *)&a1 + 1) - *((float *)&a3 + 1)) * 0.2;
}

original_code:
inline float colourDist(colour a, colour b) {
 return(
  0.3 * (a.r - b.r) * (a.r - b.r) +
  0.4 * (a.g - b.g) * (a.g - b.g) +
  0.2 * (a.b - b.b) * (a.b - b.b)
 );
}

canonical_original_code:
inline float colourDist(struct colour a, struct colour b) {
 return(
  0.3 * (a.r - b.r) * (a.r - b.r) +
  0.4 * (a.g - b.g) * (a.g - b.g) +
  0.2 * (a.b - b.b) * (a.b - b.b)
 );
}


getRGB

decompiled_code:
__int64 __fastcall getRGB(double a1, float a2)
{
return makeVec3(*(float *)&a1 * 255.0, 255.0 * a2, *((float *)&a1 + 1) * 255.0);
}

original_code:
vec3 getRGB(colour c) {
 return( makeVec3( c.r*255.0f, c.g*255.0f, c.b*255.0f ) );
}

canonical_original_code:
struct vec3 getRGB(struct colour c) {
 return( makeVec3( c.r*255.0f, c.g*255.0f, c.b*255.0f ) );
}

return_type: struct vec3 { float x; float y; float z; }


getComponentWaveLength

decompiled_code:
float __fastcall getComponentWaveLength(int a1)
{
float result; // xmm0_4

result = 0.0;
if ( a1 <= 2 )
result = wavelengths[a1];
return result;
}

canonical_decompiled_code:
float __fastcall func23(int a1)
{
float result; // xmm0_4

result = 0.0;
if ( a1 <= 2 )
result = wavelengths[a1];
return result;
}

original_code:
float getComponentWaveLength(colour c, int component) {
 return( component < 3 ? wavelengths[component] : 0 );
}

canonical_original_code:
float getComponentWaveLength(struct colour c, int component) {
 return( component < 3 ? wavelengths[component] : 0 );
}

variable_types: component int


getComponentColour

decompiled_code:
unsigned __int64 __fastcall getComponentColour(int a1, double a2, __m128i a3)
{
unsigned __int64 result; // rax

if ( a1 )
{
if ( a1 == 1 )
{
makeColour(0.0, a3);
result = a3.m128i_i64[0];
}
else
{
makeColour(0.0, (__m128i)0LL);
result = 0LL;
}
}
else
{
makeColour(a2, (__m128i)0LL);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func24(int a1, double a2, __m128i a3)
{
unsigned __int64 result; // rax

if ( a1 )
{
if ( a1 == 1 )
{
func0(0.0, a3);
result = a3.m128i_i64[0];
}
else
{
func0(0.0, (__m128i)0LL);
result = 0LL;
}
}
else
{
func0(a2, (__m128i)0LL);
result = 0LL;
}
return result;
}

original_code:
colour getComponentColour(colour c, int component) {
 if( component == 0 ) {
  return makeColour( c.r, 0, 0 );
 }
 else if( component == 1 ) {
  return makeColour( 0, c.g, 0 );
 }
 else if( component == 2 ) {
  return makeColour( 0, 0, c.b );
 }
 return (makeColour( 0.0, 0.0, 0.0 ));
}

canonical_original_code:
struct colour getComponentColour(struct colour c, int component) {
 if( component == 0 ) {
  return makeColour( c.r, 0, 0 );
 }
 else if( component == 1 ) {
  return makeColour( 0, c.g, 0 );
 }
 else if( component == 2 ) {
  return makeColour( 0, 0, c.b );
 }
 return (makeColour( 0.0, 0.0, 0.0 ));
}


multComponent

decompiled_code:
void __fastcall multComponent(float *a1, int a2, float a3)
{
if ( a2 )
{
if ( a2 == 1 )
{
a1[2] = a3 * a1[2];
}
else if ( a2 == 2 )
{
a1[1] = a3 * a1[1];
}
}
else
{
*a1 = a3 * *a1;
}
}

original_code:
void multComponent(colour* c, int component, float s) {
 if( component == 0 ) {
  c->r *= s;
 }
 else if( component == 1 ) {
  c->g *= s;
 }
 else if( component == 2 ) {
  c->b *= s;
 }
}

canonical_original_code:
void multComponent(struct colour *c, int component, float s) {
 if( component == 0 ) {
  c->r *= s;
 }
 else if( component == 1 ) {
  c->g *= s;
 }
 else if( component == 2 ) {
  c->b *= s;
 }
}

variable_types: s float


decay

decompiled_code:
void __fastcall decay(float *a1, double a2, float a3, float a4)
{
float v4; // ebp
float v5; // xmm2_4
float v6; // [rsp+8h] [rbp-30h]
float v7; // [rsp+Ch] [rbp-2Ch]

v4 = *(float *)&a2;
makeColour(COERCE_DOUBLE((unsigned __int64)LC0), (__m128i)(unsigned int)LC0);
if ( !sameColour(a2, a3, COERCE_DOUBLE((unsigned __int64)LC0), 1.0) )
{
v6 = _expf_finite((float)((float)(*(float *)&a2 - 1.0) * a4) * 0.99999994);
v7 = _expf_finite((float)((float)(a3 - 1.0) * a4) * 0.99999994);
v5 = _expf_finite((float)((float)(*((float *)&a2 + 1) - 1.0) * a4) * 0.99999994);
*a1 = (float)(v4 * *a1) * v6;
a1[2] = (float)(a3 * a1[2]) * v7;
a1[1] = (float)(*((float *)&a2 + 1) * a1[1]) * v5;
}
}

canonical_decompiled_code:
void __fastcall func26(float *a1, double a2, float a3, float a4)
{
float v4; // ebp
float v5; // xmm2_4
float v6; // [rsp+8h] [rbp-30h]
float v7; // [rsp+Ch] [rbp-2Ch]

v4 = *(float *)&a2;
func0(COERCE_DOUBLE((unsigned __int64)LC0), (__m128i)(unsigned int)LC0);
if ( !func20(a2, a3, COERCE_DOUBLE((unsigned __int64)LC0), 1.0) )
{
v6 = _expf_finite((float)((float)(*(float *)&a2 - 1.0) * a4) * 0.99999994);
v7 = _expf_finite((float)((float)(a3 - 1.0) * a4) * 0.99999994);
v5 = _expf_finite((float)((float)(*((float *)&a2 + 1) - 1.0) * a4) * 0.99999994);
*a1 = (float)(v4 * *a1) * v6;
a1[2] = (float)(a3 * a1[2]) * v7;
a1[1] = (float)(*((float *)&a2 + 1) * a1[1]) * v5;
}
}

variable_types:
f
struct colour

variable_types: x float


colPrintf

decompiled_code:
int __fastcall colPrintf(__m128i a1, __m128i a2)
{
return printf(
"%f, %f, %f\n",
COERCE_FLOAT(_mm_cvtsi128_si32(a1)),
COERCE_FLOAT(_mm_cvtsi128_si32(a2)),
*(float *)&a1.m128i_i32[1]);
}

canonical_decompiled_code:
int __fastcall func27(__m128i a1, __m128i a2)
{
return printf(
"%f, %f, %f\n",
COERCE_FLOAT(_mm_cvtsi128_si32(a1)),
COERCE_FLOAT(_mm_cvtsi128_si32(a2)),
*(float *)&a1.m128i_i32[1]);
}

original_code:
void colPrintf(colour c) {
 printf( "%f, %f, %f\n", c.r, c.g, c.b );
}

canonical_original_code:
void colPrintf(struct colour c) {
 printf( "%f, %f, %f\n", c.r, c.g, c.b );
}


nextScalar

decompiled_code:
float __fastcall nextScalar(float a1)
{
return a1 + 0.0001;
}

canonical_decompiled_code:
float __fastcall func0(float a1)
{
return a1 + 0.0001;
}

original_code:
inline float nextScalar(float s) {
 return( s + 0.0001 );
}


prevScalar

decompiled_code:
float __fastcall prevScalar(float a1)
{
return a1 - 0.0001;
}

canonical_decompiled_code:
float __fastcall func1(float a1)
{
return a1 - 0.0001;
}

original_code:
inline float prevScalar(float s) {
 return( s - 0.0001 );
}


scalarRand

decompiled_code:
float scalarRand()
{
return (float)rand() * 4.6566129e-10;
}

canonical_decompiled_code:
float func2()
{
return (float)rand() * 4.6566129e-10;
}

original_code:
inline float scalarRand() {
 return (((float)rand()) / ((float)2147483647));
}


getPolyArray

decompiled_code:
void *__fastcall getPolyArray(int a1)
{
return malloc(164LL * a1);
}

canonical_decompiled_code:
void *__fastcall func0(int a1)
{
return malloc(164LL * a1);
}

original_code:
POLYNOMIAL *getPolyArray(int size) {
    POLYNOMIAL *polynomials = (POLYNOMIAL *)malloc(sizeof(POLYNOMIAL) * size);
    return polynomials;
}

canonical_original_code:
struct polynomial *getPolyArray(int size) {
    struct polynomial *polynomials = (POLYNOMIAL *)malloc(sizeof(POLYNOMIAL) * size);
    return polynomials;
}

variable_types: size int

variable_types: struct polynomial { int size; struct term { int coeff; int expo; } terms[20]; } *

user_defined_types: struct polynomial { int size; struct term terms[20]; }


decompiled_code:
void __fastcall set_separator(char a1)
{
sep = a1;
}

canonical_decompiled_code:
void __fastcall func0(char a1)
{
sep = a1;
}

original_code:
void
set_separator(char s) {
     sep = s;
}

canonical_original_code:
void set_separator(char s) {
     sep = s;
}

variable_types: s char


decompiled_code:
int __fastcall set_lynxcgibase(const char *a1)
{
int v1; // eax
char *v2; // rbx
int result; // eax

v1 = strlen(a1);
v2 = (char *)xmalloc(v1 + 10);
result = sprintf(v2, "lynxcgi:%s", a1);
cgibase = v2;
return result;
}

canonical_decompiled_code:
int __fastcall func1(const char *a1)
{
int v1; // eax
char *v2; // rbx
int result; // eax

v1 = strlen(a1);
v2 = (char *)xmalloc(v1 + 10);
result = sprintf(v2, "lynxcgi:%s", a1);
cgibase = v2;
return result;
}

original_code:
void
set_lynxcgibase(char *s) {
     int n = strlen(cgibase_ll_format) + strlen(s);
     char *t = (char *) xmalloc(n);
     sprintf(t, cgibase_ll_format, s);
     cgibase = t;
}

variable_types:
s
char *

variable_types: n int

variable_types:
t
char *


decompiled_code:
int __fastcall set_cgibase(const char *a1)
{
int v1; // eax
char *v2; // rbx
int result; // eax

v1 = strlen(a1);
v2 = (char *)xmalloc(v1 + 9);
result = sprintf(v2, "http://%s", a1);
cgibase = v2;
return result;
}

canonical_decompiled_code:
int __fastcall func2(const char *a1)
{
int v1; // eax
char *v2; // rbx
int result; // eax

v1 = strlen(a1);
v2 = (char *)xmalloc(v1 + 9);
result = sprintf(v2, "http://%s", a1);
cgibase = v2;
return result;
}

original_code:
void
set_cgibase(char *s) {
     int n = strlen(cgibase_format) + strlen(s);
     char *t = (char *) xmalloc(n);
     sprintf(t, cgibase_format, s);
     cgibase = t;
}


decompiled_code:
char *set_man2htmlpath()
{
char *result; // rax

result = (char *)xstrdup();
man2htmlpath = result;
return result;
}

canonical_decompiled_code:
char *func3()
{
char *result; // rax

result = (char *)xstrdup();
man2htmlpath = result;
return result;
}

original_code:
void
set_man2htmlpath(char *s) {
     man2htmlpath = xstrdup(s);
}


decompiled_code:
void set_relative_html_links()
{
relat_html_style = 1;
}

canonical_decompiled_code:
void func4()
{
relat_html_style = 1;
}

original_code:
void
set_relative_html_links(void) {
     relat_html_style = 1;
}


decompiled_code:
void set_current_html_links()
{
current_html_style = 1;
}

canonical_decompiled_code:
void func5()
{
current_html_style = 1;
}

original_code:
void
set_current_html_links(void) {
     current_html_style = 1;
}


decompiled_code:
int print_sig()
{
struct tm *v0; // rax
time_t timer; // [rsp+8h] [rbp-210h] BYREF
char v3[520]; // [rsp+10h] [rbp-208h] BYREF

strcpy(v3, "Time: ");
timer = time(0LL);
v0 = gmtime(&timer);
strftime(&v3[6], 0x1EEuLL, "%T GMT, %B %d, %Y", v0);
v3[499] = 0;
return printf(
"
\n"
"This document was created by\n"
"man2html,\n"
"using the manual pages.
\n"
"%s\n",
v3);
}

canonical_decompiled_code:
int func6()
{
struct tm *v0; // rax
time_t timer; // [rsp+8h] [rbp-210h] BYREF
char v3[520]; // [rsp+10h] [rbp-208h] BYREF

strcpy(v3, "Time: ");
timer = time(0LL);
v0 = gmtime(&timer);
strftime(&v3[6], 0x1EEuLL, "%T GMT, %B %d, %Y", v0);
v3[499] = 0;
return printf(
"
\n"
"This document was created by\n"
"man2html,\n"
"using the manual pages.
\n"
"%s\n",
v3);
}

original_code:
void print_sig()
{
    char timebuf[500];
    struct tm *timetm;
    time_t clock;
    timebuf[0] = 0;
    sprintf(timebuf, "Time: ");
    clock=time(((void *)0));
    timetm=gmtime(&clock);
    strftime(timebuf+6, 500 -6, "%T GMT, %B %d, %Y", timetm);
    timebuf[500 -1] = 0;
    printf(signature, timebuf);
}

canonical_original_code:
void print_sig()
{
    char timebuf[500];
    struct tm *timetm;
    long clock;
    timebuf[0] = 0;
    sprintf(timebuf, "Time: ");
    clock=time(((void *)0));
    timetm=gmtime(&clock);
    strftime(timebuf+6, 500 -6, "%T GMT, %B %d, %Y", timetm);
    timebuf[500 -1] = 0;
    printf(signature, timebuf);
}

variable_types:
timebuf
char [500]

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; } *

variable_types: clock long


decompiled_code:
int __fastcall include_file_html(const char *a1)
{
return printf("%s>", a1, a1);
}

canonical_decompiled_code:
int __fastcall func7(const char *a1)
{
return printf("%s>", a1, a1);
}

original_code:
void
include_file_html(char *g) {
     printf("%s>", g,g);
}

variable_types:
g
char *


decompiled_code:
int __fastcall man_page_html(const char *a1, const char *a2)
{
int result; // eax

if ( current_html_style )
{
if ( a2 )
result = printf("%s", a2, a2);
else
result = printf("Return to Main Contents");
}
else if ( relat_html_style )
{
if ( a2 )
result = printf("%s", a1, a2, a1, a2);
else
result = printf("Return to Main Contents");
}
else if ( a2 )
{
if ( a1 )
result = printf("%s", cgibase, man2htmlpath, (unsigned int)sep, a1, a2, a2);
else
result = printf("%s", cgibase, man2htmlpath, (unsigned int)sep, a2, a2);
}
else
{
result = printf("Return to Main Contents", cgibase, man2htmlpath);
}
return result;
}

canonical_decompiled_code:
int __fastcall func8(const char *a1, const char *a2)
{
int result; // eax

if ( current_html_style )
{
if ( a2 )
result = printf("%s", a2, a2);
else
result = printf("Return to Main Contents");
}
else if ( relat_html_style )
{
if ( a2 )
result = printf("%s", a1, a2, a1, a2);
else
result = printf("Return to Main Contents");
}
else if ( a2 )
{
if ( a1 )
result = printf("%s", cgibase, man2htmlpath, (unsigned int)sep, a1, a2, a2);
else
result = printf("%s", cgibase, man2htmlpath, (unsigned int)sep, a2, a2);
}
else
{
result = printf("Return to Main Contents", cgibase, man2htmlpath);
}
return result;
}

original_code:
void
man_page_html(char *sec, char *h) {
 if (current_html_style) {
  if (!h)
   printf(""
          "Return to Main Contents");
  else
   printf("%s",
          h, h);
 } else if (relat_html_style) {
  if (!h)
   printf(""
          "Return to Main Contents");
  else
   printf("%s",
          sec, h, sec, h);
 } else {
  if (!h)
   printf("Return to Main Contents",
          cgibase, man2htmlpath);
  else if (!sec)
   printf("%s",
          cgibase, man2htmlpath, sep, h, h);
  else
   printf("%s",
          cgibase, man2htmlpath, sep, sec, h, h);
 }
}

variable_types:
sec
char *

variable_types:
h
char *


decompiled_code:
int __fastcall ftp_html(const char *a1)
{
return printf("%s", a1, a1);
}

canonical_decompiled_code:
int __fastcall func9(const char *a1)
{
return printf("%s", a1, a1);
}

original_code:
void
ftp_html(char *f) {
     printf("%s", f, f);
}

variable_types:
f
char *


decompiled_code:
int __fastcall www_html(const char *a1)
{
return printf("%s", a1, a1);
}

canonical_decompiled_code:
int __fastcall func10(const char *a1)
{
return printf("%s", a1, a1);
}

original_code:
void
www_html(char *f) {
     printf("%s", f, f);
}


decompiled_code:
int __fastcall mailto_html(const char *a1)
{
return printf("%s", a1, a1);
}

canonical_decompiled_code:
int __fastcall func11(const char *a1)
{
return printf("%s", a1, a1);
}

original_code:
void
mailto_html(char *g) {
     printf("%s", g, g);
}


decompiled_code:
int __fastcall url_html(const char *a1)
{
return printf("%s", a1, a1);
}

canonical_decompiled_code:
int __fastcall func12(const char *a1)
{
return printf("%s", a1, a1);
}

original_code:
void
url_html(char *g) {
     printf("%s", g, g);
}


decompiled_code:
char *__fastcall lookup_abbrev(char *s1)
{
const char *v1; // rsi
__int64 v2; // rbx
char *result; // rax

if ( !s1 )
return (char *)&unk_311;
v1 = abbrev_list;
v2 = 0LL;
result = s1;
if ( abbrev_list )
{
while ( strcmp(s1, v1) )
{
v2 += 2LL;
v1 = (&abbrev_list)[v2];
if ( !v1 )
return s1;
}
result = (&abbrev_list)[(int)v2 + 1];
}
return result;
}

canonical_decompiled_code:
char *__fastcall func0(char *s1)
{
const char *v1; // rsi
__int64 v2; // rbx
char *result; // rax

if ( !s1 )
return (char *)&unk_311;
v1 = abbrev_list;
v2 = 0LL;
result = s1;
if ( abbrev_list )
{
while ( strcmp(s1, v1) )
{
v2 += 2LL;
v1 = (&abbrev_list)[v2];
if ( !v1 )
return s1;
}
result = (&abbrev_list)[(int)v2 + 1];
}
return result;
}

original_code:
char *lookup_abbrev (char *s)
{
    int i=0;
    if (!s)
  return "";
    while (abbrev_list[i] && strcmp(s, abbrev_list[i]))
  i = i+2;
    return abbrev_list[i] ? abbrev_list[i+1] : s;
}

canonical_original_code:
char *lookup_abbrev(char *s)
{
    int i = 0;
    if (!s)
  return "";
    while (abbrev_list[i] && strcmp(s, abbrev_list[i]))
  i = i+2;
    return abbrev_list[i] ? abbrev_list[i+1] : s;
}

variable_types: i int

return_type: char *


stdinit

decompiled_code:
void stdinit()
{
int *v0; // rbx
int *i; // rbp
int *v2; // rax
int *v3; // rbx
int *j; // rbp
int *v5; // rax
int v6; // edx
int *v7; // rax
int *v8; // rcx

if ( standardchar )
{
v0 = &standardchar;
for ( i = &standardchar; ; i = v2 )
{
if ( *((_QWORD *)i + 1) )
*((_QWORD *)i + 1) = xstrdup();
v2 = v0;
*((_QWORD *)i + 2) = v0;
v0 += 6;
if ( !*(v0 - 6) )
break;
}
}
chardef = (__int64)&standardchar;
if ( standardstring )
{
v3 = &standardstring;
for ( j = &standardstring; ; j = v5 )
{
if ( *((_QWORD *)j + 1) )
*((_QWORD *)j + 1) = xstrdup();
v5 = v3;
*((_QWORD *)j + 2) = v3;
v3 += 6;
if ( !*(v3 - 6) )
break;
}
}
strdef = (__int64)&standardstring;
intdef = (__int64)&standardint;
v6 = standardint;
if ( standardint )
{
v7 = &standardint;
v8 = &standardint;
do
{
if ( v6 == -666 )
{
*v8 = nroff;
}
else if ( v6 == -667 )
{
*v8 = nroff == 0;
}
v8 = v7;
*(_QWORD *)(intdef + 16) = v7;
intdef = (__int64)v7;
v7 += 6;
v6 = *(v7 - 6);
}
while ( v6 );
}
intdef = (__int64)&standardint;
defdef = 0LL;
}

canonical_decompiled_code:
void func0()
{
int *v0; // rbx
int *i; // rbp
int *v2; // rax
int *v3; // rbx
int *j; // rbp
int *v5; // rax
int v6; // edx
int *v7; // rax
int *v8; // rcx

if ( standardchar )
{
v0 = &standardchar;
for ( i = &standardchar; ; i = v2 )
{
if ( *((_QWORD *)i + 1) )
*((_QWORD *)i + 1) = xstrdup();
v2 = v0;
*((_QWORD *)i + 2) = v0;
v0 += 6;
if ( !*(v0 - 6) )
break;
}
}
chardef = (__int64)&standardchar;
if ( standardstring )
{
v3 = &standardstring;
for ( j = &standardstring; ; j = v5 )
{
if ( *((_QWORD *)j + 1) )
*((_QWORD *)j + 1) = xstrdup();
v5 = v3;
*((_QWORD *)j + 2) = v3;
v3 += 6;
if ( !*(v3 - 6) )
break;
}
}
strdef = (__int64)&standardstring;
intdef = (__int64)&standardint;
v6 = standardint;
if ( standardint )
{
v7 = &standardint;
v8 = &standardint;
do
{
if ( v6 == -666 )
{
*v8 = nroff;
}
else if ( v6 == -667 )
{
*v8 = nroff == 0;
}
v8 = v7;
*(_QWORD *)(intdef + 16) = v7;
intdef = (__int64)v7;
v7 += 6;
v6 = *(v7 - 6);
}
while ( v6 );
}
intdef = (__int64)&standardint;
defdef = 0LL;
}

original_code:
void stdinit(void) {
    STRDEF *stdf;
    int i;
    stdf = &standardchar[0];
    i = 0;
    while (stdf->nr) {
 if (stdf->st) stdf->st = xstrdup(stdf->st);
 stdf->next = &standardchar[i];
 stdf = stdf->next;
 i++;
    }
    chardef=&standardchar[0];
    stdf=&standardstring[0];
    i=0;
    while (stdf->nr) {
 if (stdf->st) stdf->st = xstrdup(stdf->st);
 stdf->next = &standardstring[i];
 stdf = stdf->next;
 i++;
    }
    strdef=&standardstring[0];
    intdef=&standardint[0];
    i=0;
    while (intdef->nr) {
 if (intdef->nr == (-666)) intdef->nr = nroff; else
 if (intdef->nr == (-667)) intdef->nr = !nroff;
 intdef->next = &standardint[i];
 intdef = intdef->next;
 i++;
    }
    intdef = &standardint[0];
    defdef = ((void *) 0);
}

canonical_original_code:
void stdinit() {
    struct STRDEF *stdf;
    int i;
    stdf = &standardchar[0];
    i = 0;
    while (stdf->nr) {
 if (stdf->st) stdf->st = xstrdup(stdf->st);
 stdf->next = &standardchar[i];
 stdf = stdf->next;
 i++;
    }
    chardef=&standardchar[0];
    stdf=&standardstring[0];
    i=0;
    while (stdf->nr) {
 if (stdf->st) stdf->st = xstrdup(stdf->st);
 stdf->next = &standardstring[i];
 stdf = stdf->next;
 i++;
    }
    strdef=&standardstring[0];
    intdef=&standardint[0];
    i=0;
    while (intdef->nr) {
 if (intdef->nr == (-666)) intdef->nr = nroff; else
 if (intdef->nr == (-667)) intdef->nr = !nroff;
 intdef->next = &standardint[i];
 intdef = intdef->next;
 i++;
    }
    intdef = &standardint[0];
    defdef = ((void *) 0);
}

variable_types: struct STRDEF { int nr; char *st; struct STRDEF *next; } *


usage

repo: hancyxhx/Shuffle

decompiled_code:
void __noreturn usage()
{
puts("Usage: shuffle [FILE]");
puts("try `shuffle -h' for more information.");
exit(-1);
}

canonical_decompiled_code:
void __noreturn func7()
{
puts("Usage: shuffle [FILE]");
puts("try `shuffle -h' for more information.");
exit(-1);
}

original_code:
void usage(){
    printf("Usage: shuffle [FILE]\n");
    printf("try `shuffle -h' for more information.\n");
    exit(-1);
}


man

decompiled_code:
void __noreturn man()
{
puts("NAME");
puts("\tshuffle - shuffle lines of text file");
puts("SYNOPSIS");
puts("\tshuffle [OPTION] [FILE]");
puts("AUTHOR");
puts("\tWritten by hancy hush");
puts("REPORTING BUGS");
puts("\tReport bugs to <hancyxhx@gmail.com>");
exit(0);
}

canonical_decompiled_code:
void __noreturn func8()
{
puts("NAME");
puts("\tshuffle - shuffle lines of text file");
puts("SYNOPSIS");
puts("\tshuffle [OPTION] [FILE]");
puts("AUTHOR");
puts("\tWritten by hancy hush");
puts("REPORTING BUGS");
puts("\tReport bugs to <hancyxhx@gmail.com>");
exit(0);
}

original_code:
void man(){
    printf("NAME\n");
    printf("\tshuffle - shuffle lines of text file\n");
    printf("SYNOPSIS\n");
    printf("\tshuffle [OPTION] [FILE]\n");
    printf("AUTHOR\n");
    printf("\tWritten by hancy hush\n");
    printf("REPORTING BUGS\n");
    printf("\tReport bugs to <hancyxhx@gmail.com>\n");
    exit(0);
}


decompiled_code:
int __fastcall show_deck(const char **a1)
{
const char *v1; // rsi
const char **v2; // rbx
int result; // eax

v1 = *a1;
if ( *a1 )
{
v2 = a1 + 1;
do
{
result = printf("%s", v1);
v1 = *v2++;
}
while ( v1 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func10(const char **a1)
{
const char *v1; // rsi
const char **v2; // rbx
int result; // eax

v1 = *a1;
if ( *a1 )
{
v2 = a1 + 1;
do
{
result = printf("%s", v1);
v1 = *v2++;
}
while ( v1 );
}
return result;
}

original_code:
void show_deck(Poker deck[]){
    int i;
    for (i=0; deck[i] != ((void *)0); i++)
 printf("%s",deck[i]);
}

canonical_original_code:
void show_deck(char *deck[]){
    int i;
    for (i=0; deck[i] != ((void *)0); i++)
 printf("%s",deck[i]);
}

variable_types:
deck
char *[]


main

canonical_name: main

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

parse_arg(argc, (char **)argv);
v3 = (const char **)shuffle(global_args);
show_deck(v3);
return 0;
}

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

parse_arg(argc, (char **)argv);
v3 = (const char **)shuffle(global_args);
func10(v3);
return 0;
}

original_code:
int main (int argc, char *argv[] ){
    parse_arg(argc, argv);
    Poker *shuffle_deck;
    shuffle_deck = shuffle(global_args.draw_deck);
    show_deck(shuffle_deck);
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[]){
    parse_arg(argc, argv);
    char **shuffle_deck;
    shuffle_deck = shuffle(global_args.draw_deck);
    show_deck(shuffle_deck);
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

return_type: int


decompiled_code:
int __fastcall show_tank(int a1, int a2, __int64 a3)
{
mvwprintw(
stdscr,
a1,
a2,
"(%d,%d)(dir:%d)=%d=(cm:%d)=%p=%p",
*(unsigned int *)(a3 + 4),
*(unsigned int *)(a3 + 8),
*(unsigned int *)(a3 + 20),
*(unsigned int *)(a3 + 32),
*(unsigned int *)(a3 + 36),
(const void *)a3,
*(const void **)(a3 + 40));
return wrefresh(stdscr);
}

canonical_decompiled_code:
int __fastcall func0(int a1, int a2, __int64 a3)
{
mvwprintw(
stdscr,
a1,
a2,
"(%d,%d)(dir:%d)=%d=(cm:%d)=%p=%p",
*(unsigned int *)(a3 + 4),
*(unsigned int *)(a3 + 8),
*(unsigned int *)(a3 + 20),
*(unsigned int *)(a3 + 32),
*(unsigned int *)(a3 + 36),
(const void *)a3,
*(const void **)(a3 + 40));
return wrefresh(stdscr);
}

original_code:
void show_tank(int y, int x, const object_type_t *tank)
{
 const object_type_t *tk=tank;
 mvwprintw(stdscr,y,x,"(%d,%d)(dir:%d)=%d=(cm:%d)=%p=%p",tk->coordinate.y, tk->coordinate.x,tk->dir,tk->number,tk->canmove,tk,tk->next);
 wrefresh(stdscr);
}

canonical_original_code:
void show_tank(int y, int x, struct object_type *tank)
{
 struct object_type *tk = tank;
 mvwprintw(stdscr,y,x,"(%d,%d)(dir:%d)=%d=(cm:%d)=%p=%p",tk->coordinate.y, tk->coordinate.x,tk->dir,tk->number,tk->canmove,tk,tk->next);
 wrefresh(stdscr);
}

variable_types: y int

variable_types: x int

variable_types: struct object_type { enum object { OBJECT_TANK=0, OBJECT_BULLET=1, OBJECT_BARRIER=2 } object; struct coordinate { int y; int x; } coordinate; struct size { int h; int w; } size; enum dir { DIR_UP=0, DIR_RIGHT=1, DIR_DOWN=2, DIR_LEFT=3, DIR_NONE=4 } dir; enum standpoint { STANDPOINT_WHITE=0, STANDPOINT_GREEN=1, STANDPOINT_BLUE=2 } standpoint; int hp; int number; int canmove; struct object_type *next; } *

user_defined_types: struct object_type { enum object object; struct coordinate coordinate; struct size size; enum dir dir; enum standpoint standpoint; int hp; int number; int canmove; struct object_type *next; }


original_code:
object_type_t *object_type_copy(object_type_t *dest,const object_type_t *src)
{
 if(((void *)0)==dest||((void *)0)==src){
  return ((void *)0);
 }
 dest->object=src->object;
 coordinate_copy(&dest->coordinate,&src->coordinate);
 size_copy(&dest->size,&src->size);
 dest->dir=src->dir;
 dest->standpoint=src->standpoint;
 dest->hp=src->hp;
 dest->number=src->number;
 dest->canmove=src->canmove;
 dest->next=src->next;
 return dest;
}

canonical_original_code:
struct object_type *object_type_copy(struct object_type *dest, struct object_type *src)
{
 if(((void *)0)==dest||((void *)0)==src){
  return ((void *)0);
 }
 dest->object=src->object;
 coordinate_copy(&dest->coordinate,&src->coordinate);
 size_copy(&dest->size,&src->size);
 dest->dir=src->dir;
 dest->standpoint=src->standpoint;
 dest->hp=src->hp;
 dest->number=src->number;
 dest->canmove=src->canmove;
 dest->next=src->next;
 return dest;
}

variable_types:
dest
struct object_type *

variable_types:
src
struct object_type *

return_type: struct object_type { enum object { OBJECT_TANK=0, OBJECT_BULLET=1, OBJECT_BARRIER=2 } object; struct coordinate { int y; int x; } coordinate; struct size { int h; int w; } size; enum dir { DIR_UP=0, DIR_RIGHT=1, DIR_DOWN=2, DIR_LEFT=3, DIR_NONE=4 } dir; enum standpoint { STANDPOINT_WHITE=0, STANDPOINT_GREEN=1, STANDPOINT_BLUE=2 } standpoint; int hp; int number; int canmove; struct object_type *next; } *


decompiled_code:
void __fastcall open_colors(int a1, int a2, int a3)
{
if ( a1 == 1 )
{
if ( a2 == 1 )
{
switch ( a3 )
{
case -2:
if ( has_colors() )
wattr_on(stdscr, 0x200A00uLL, 0LL);
break;
case -1:
if ( has_colors() )
wattr_on(stdscr, 0x200900uLL, 0LL);
break;
case -4:
if ( has_colors() )
wattr_on(stdscr, 0x200B00uLL, 0LL);
break;
default:
if ( has_colors() )
wattr_on(stdscr, 0x200800uLL, 0LL);
break;
}
}
else if ( a2 == 2 && has_colors() )
{
wattr_on(stdscr, 0x200700uLL, 0LL);
}
}
else if ( a1 == 2 )
{
if ( !a2 && has_colors() )
wattr_on(stdscr, 0x200C00uLL, 0LL);
}
else
{
if ( a1 )
return;
if ( a2 != 1 )
{
if ( a2 != 2 )
return;
if ( a3 != -2 )
{
if ( a3 != -1 )
{
if ( a3 != -4 )
{
if ( has_colors() )
wattr_on(stdscr, 0x200200uLL, 0LL);
return;
}
if ( !has_colors() )
return;
LABEL_17:
wattr_on(stdscr, 0x200600uLL, 0LL);
return;
}
if ( !has_colors() )
return;
LABEL_13:
wattr_on(stdscr, 0x200400uLL, 0LL);
return;
}
if ( !has_colors() )
return;
LABEL_15:
wattr_on(stdscr, 0x200500uLL, 0LL);
return;
}
switch ( a3 )
{
case -2:
if ( !has_colors() )
return;
goto LABEL_15;
case -1:
if ( !has_colors() )
return;
goto LABEL_13;
case -4:
if ( !has_colors() )
return;
goto LABEL_17;
}
if ( has_colors() )
wattr_on(stdscr, 0x200300uLL, 0LL);
}
}

canonical_decompiled_code:
void __fastcall func1(int a1, int a2, int a3)
{
if ( a1 == 1 )
{
if ( a2 == 1 )
{
switch ( a3 )
{
case -2:
if ( has_colors() )
wattr_on(stdscr, 0x200A00uLL, 0LL);
break;
case -1:
if ( has_colors() )
wattr_on(stdscr, 0x200900uLL, 0LL);
break;
case -4:
if ( has_colors() )
wattr_on(stdscr, 0x200B00uLL, 0LL);
break;
default:
if ( has_colors() )
wattr_on(stdscr, 0x200800uLL, 0LL);
break;
}
}
else if ( a2 == 2 && has_colors() )
{
wattr_on(stdscr, 0x200700uLL, 0LL);
}
}
else if ( a1 == 2 )
{
if ( !a2 && has_colors() )
wattr_on(stdscr, 0x200C00uLL, 0LL);
}
else
{
if ( a1 )
return;
if ( a2 != 1 )
{
if ( a2 != 2 )
return;
if ( a3 != -2 )
{
if ( a3 != -1 )
{
if ( a3 != -4 )
{
if ( has_colors() )
wattr_on(stdscr, 0x200200uLL, 0LL);
return;
}
if ( !has_colors() )
return;
LABEL_17:
wattr_on(stdscr, 0x200600uLL, 0LL);
return;
}
if ( !has_colors() )
return;
LABEL_13:
wattr_on(stdscr, 0x200400uLL, 0LL);
return;
}
if ( !has_colors() )
return;
LABEL_15:
wattr_on(stdscr, 0x200500uLL, 0LL);
return;
}
switch ( a3 )
{
case -2:
if ( !has_colors() )
return;
goto LABEL_15;
case -1:
if ( !has_colors() )
return;
goto LABEL_13;
case -4:
if ( !has_colors() )
return;
goto LABEL_17;
}
if ( has_colors() )
wattr_on(stdscr, 0x200300uLL, 0LL);
}
}

variable_types: enum object { OBJECT_TANK=0, OBJECT_BULLET=1, OBJECT_BARRIER=2 }

variable_types: enum standpoint { STANDPOINT_WHITE=0, STANDPOINT_GREEN=1, STANDPOINT_BLUE=2 }

variable_types: number int


decompiled_code:
void __fastcall close_colors(int a1, int a2, int a3)
{
if ( a1 == 1 )
{
if ( a2 == 1 )
{
switch ( a3 )
{
case -2:
if ( has_colors() )
wattr_off(stdscr, 0x200A00uLL, 0LL);
return;
case -1:
if ( has_colors() )
wattr_off(stdscr, 0x200900uLL, 0LL);
return;
case -4:
if ( has_colors() )
wattr_off(stdscr, 0x200B00uLL, 0LL);
return;
}
if ( !has_colors() )
return;
}
else if ( a2 != 2 || !has_colors() )
{
return;
}
wattr_off(stdscr, 0x200700uLL, 0LL);
return;
}
if ( a1 == 2 )
{
if ( !a2 && has_colors() )
wattr_off(stdscr, 0x200C00uLL, 0LL);
return;
}
if ( a1 )
return;
if ( a2 == 1 )
{
if ( a3 != -2 )
{
if ( a3 != -1 )
{
if ( a3 != -4 )
{
if ( has_colors() )
goto LABEL_11;
return;
}
if ( !has_colors() )
return;
LABEL_17:
wattr_off(stdscr, 0x200600uLL, 0LL);
return;
}
if ( !has_colors() )
return;
LABEL_13:
wattr_off(stdscr, 0x200400uLL, 0LL);
return;
}
if ( !has_colors() )
return;
LABEL_15:
wattr_off(stdscr, 0x200500uLL, 0LL);
return;
}
if ( a2 != 2 )
return;
switch ( a3 )
{
case -2:
if ( !has_colors() )
return;
goto LABEL_15;
case -1:
if ( !has_colors() )
return;
goto LABEL_13;
case -4:
if ( !has_colors() )
return;
goto LABEL_17;
}
if ( has_colors() )
LABEL_11:
wattr_off(stdscr, 0x200300uLL, 0LL);
}

canonical_decompiled_code:
void __fastcall func2(int a1, int a2, int a3)
{
if ( a1 == 1 )
{
if ( a2 == 1 )
{
switch ( a3 )
{
case -2:
if ( has_colors() )
wattr_off(stdscr, 0x200A00uLL, 0LL);
return;
case -1:
if ( has_colors() )
wattr_off(stdscr, 0x200900uLL, 0LL);
return;
case -4:
if ( has_colors() )
wattr_off(stdscr, 0x200B00uLL, 0LL);
return;
}
if ( !has_colors() )
return;
}
else if ( a2 != 2 || !has_colors() )
{
return;
}
wattr_off(stdscr, 0x200700uLL, 0LL);
return;
}
if ( a1 == 2 )
{
if ( !a2 && has_colors() )
wattr_off(stdscr, 0x200C00uLL, 0LL);
return;
}
if ( a1 )
return;
if ( a2 == 1 )
{
if ( a3 != -2 )
{
if ( a3 != -1 )
{
if ( a3 != -4 )
{
if ( has_colors() )
goto LABEL_11;
return;
}
if ( !has_colors() )
return;
LABEL_17:
wattr_off(stdscr, 0x200600uLL, 0LL);
return;
}
if ( !has_colors() )
return;
LABEL_13:
wattr_off(stdscr, 0x200400uLL, 0LL);
return;
}
if ( !has_colors() )
return;
LABEL_15:
wattr_off(stdscr, 0x200500uLL, 0LL);
return;
}
if ( a2 != 2 )
return;
switch ( a3 )
{
case -2:
if ( !has_colors() )
return;
goto LABEL_15;
case -1:
if ( !has_colors() )
return;
goto LABEL_13;
case -4:
if ( !has_colors() )
return;
goto LABEL_17;
}
if ( has_colors() )
LABEL_11:
wattr_off(stdscr, 0x200300uLL, 0LL);
}

user_defined_types: enum object { OBJECT_TANK=0, OBJECT_BULLET=1, OBJECT_BARRIER=2 }

user_defined_types: enum standpoint { STANDPOINT_WHITE=0, STANDPOINT_GREEN=1, STANDPOINT_BLUE=2 }


repo: handsomezhou/tetris

original_code:
static int init_grid(grid_t (*pgrid)[10])
{
 grid_t (*pg)[10]=pgrid;
 int y,x;
 if(((void *)0)==pg){
  return -1;
 }
 for(y=0; y<20; y++){
  for(x=0; x<10; x++){
   pg[y][x].y=y;
   pg[y][x].x=x;
   pg[y][x].type=BLOCK_TYPE_NONE;
   pg[y][x].value='0';
  }
 }
 return 0;
}

canonical_original_code:
static int init_grid(struct grid (*pgrid)[10])
{
 grid_t (*pg)[10]=pgrid;
 int y; int x;
 if(((void *)0)==pg){
  return -1;
 }
 for(y=0; y<20; y++){
  for(x=0; x<10; x++){
   pg[y][x].y=y;
   pg[y][x].x=x;
   pg[y][x].type=BLOCK_TYPE_NONE;
   pg[y][x].value='0';
  }
 }
 return 0;
}

variable_types: struct grid { int y; int x; enum block_type { BLOCK_I=0, BLOCK_J=1, BLOCK_L=2, BLOCK_O=3, BLOCK_S=4, BLOCK_Z=5, BLOCK_T=6, BLOCK_TYPE_NONE=7 } type; char value; } (*)[10]

user_defined_types: struct grid { int y; int x; enum block_type type; char value; }


original_code:
static void exit_prompt(prompt_t *prompt)
{
 prompt_t *ppt=prompt;
 if(((void *)0)==ppt){
  return;
 }
 if(((void *)0)!=ppt->level_show){
  free(ppt->level_show);
  ppt->level_show=((void *)0);
 }
 if(((void *)0)!=ppt->lines_show){
  free(ppt->lines_show);
  ppt->lines_show=((void *)0);
 }
 if(((void *)0)!=ppt->score_show){
  free(ppt->score_show);
  ppt->score_show=((void *)0);
 }
 return;
}

canonical_original_code:
static void exit_prompt(struct prompt *prompt)
{
 struct prompt *ppt = prompt;
 if(((void *)0)==ppt){
  return;
 }
 if(((void *)0)!=ppt->level_show){
  free(ppt->level_show);
  ppt->level_show=((void *)0);
 }
 if(((void *)0)!=ppt->lines_show){
  free(ppt->lines_show);
  ppt->lines_show=((void *)0);
 }
 if(((void *)0)!=ppt->score_show){
  free(ppt->score_show);
  ppt->score_show=((void *)0);
 }
 return;
}

variable_types: struct prompt { char level_key[-1]; int level_value; char *level_show; char lines_key[-1]; int lines_value; char *lines_show; char score_key[-1]; int score_value; char *score_show; char start[-1]; char pause[-1]; char quit[-1]; char title[-1]; } *


decompiled_code:
__int64 __fastcall init_prompt(__int64 a1)
{
int v2; // er12
int v3; // ebp
char *v4; // rdi
char *v5; // rdi
char *v6; // rdi
__int64 result; // rax
size_t v8; // rax
size_t v9; // rax
size_t v10; // rax
char v11[48]; // [rsp+0h] [rbp-B8h] BYREF
char v12[48]; // [rsp+30h] [rbp-88h] BYREF
char s[88]; // [rsp+60h] [rbp-58h] BYREF

strcpy(s, "Failed to allocate space for level_show");
strcpy(v12, "Failed to allocate space for lines_show");
strcpy(v11, "Failed to allocate space for score_show");
if ( stdscr )
{
v2 = stdscr->_maxy + 1;
v3 = stdscr->_maxx + 1;
}
else
{
v2 = -1;
v3 = -1;
}
if ( !a1 )
return 0xFFFFFFFFLL;
if ( *(_QWORD *)(a1 + 16) || *(_QWORD *)(a1 + 40) || *(_QWORD *)(a1 + 64) )
{
exit_prompt((_QWORD *)a1);
*(_QWORD *)(a1 + 40) = 0LL;
*(_QWORD *)(a1 + 64) = 0LL;
}
strcpy((char *)a1, "Level");
*(_DWORD *)(a1 + 8) = 0;
v4 = (char *)malloc(0xBuLL);
*(_QWORD *)(a1 + 16) = v4;
if ( v4 )
{
snprintf(v4, 0xBuLL, "%s%5d", (const char *)a1, 0LL);
strcpy((char *)(a1 + 24), "Lines");
*(_DWORD *)(a1 + 32) = 0;
v5 = (char *)malloc(0xBuLL);
*(_QWORD *)(a1 + 40) = v5;
if ( v5 )
{
snprintf(v5, 0xBuLL, "%s%5d", (const char *)(a1 + 24), 0LL);
strcpy((char *)(a1 + 48), "Score");
*(_DWORD *)(a1 + 56) = 0;
v6 = (char *)malloc(0xBuLL);
*(_QWORD *)(a1 + 64) = v6;
if ( v6 )
{
snprintf(v6, 0xBuLL, "%s%5d", (const char *)(a1 + 48), 0LL);
strcpy((char *)(a1 + 72), "BEGIN");
strcpy((char *)(a1 + 78), "PAUSE");
strcpy((char *)(a1 + 84), "QUIT");
strcpy((char *)(a1 + 89), "Tetris");
result = 0LL;
}
else
{
if ( has_colors() )
wattr_on(stdscr, 0x900uLL, 0LL);
v10 = strlen(v11);
mvwprintw(stdscr, v2 / 2, (v3 - v10) >> 1, "%s", v11);
if ( has_colors() )
wattr_off(stdscr, 0x900uLL, 0LL);
nodelay(stdscr, 0);
wgetch(stdscr);
nodelay(stdscr, 1);
result = 0xFFFFFFFFLL;
}
}
else
{
if ( has_colors() )
wattr_on(stdscr, 0x900uLL, 0LL);
v9 = strlen(v12);
mvwprintw(stdscr, v2 / 2, (v3 - v9) >> 1, "%s", v12);
if ( has_colors() )
wattr_off(stdscr, 0x900uLL, 0LL);
nodelay(stdscr, 0);
wgetch(stdscr);
nodelay(stdscr, 1);
result = 0xFFFFFFFFLL;
}
}
else
{
if ( has_colors() )
wattr_on(stdscr, 0x900uLL, 0LL);
v8 = strlen(s);
mvwprintw(stdscr, v2 / 2, (v3 - v8) >> 1, "%s", s);
if ( has_colors() )
wattr_off(stdscr, 0x900uLL, 0LL);
nodelay(stdscr, 0);
wgetch(stdscr);
nodelay(stdscr, 1);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
int v2; // er12
int v3; // ebp
char *v4; // rdi
char *v5; // rdi
char *v6; // rdi
__int64 result; // rax
size_t v8; // rax
size_t v9; // rax
size_t v10; // rax
char v11[48]; // [rsp+0h] [rbp-B8h] BYREF
char v12[48]; // [rsp+30h] [rbp-88h] BYREF
char s[88]; // [rsp+60h] [rbp-58h] BYREF

strcpy(s, "Failed to allocate space for level_show");
strcpy(v12, "Failed to allocate space for lines_show");
strcpy(v11, "Failed to allocate space for score_show");
if ( stdscr )
{
v2 = stdscr->_maxy + 1;
v3 = stdscr->_maxx + 1;
}
else
{
v2 = -1;
v3 = -1;
}
if ( !a1 )
return 0xFFFFFFFFLL;
if ( *(_QWORD *)(a1 + 16) || *(_QWORD *)(a1 + 40) || *(_QWORD *)(a1 + 64) )
{
func2((_QWORD *)a1);
*(_QWORD *)(a1 + 40) = 0LL;
*(_QWORD *)(a1 + 64) = 0LL;
}
strcpy((char *)a1, "Level");
*(_DWORD *)(a1 + 8) = 0;
v4 = (char *)malloc(0xBuLL);
*(_QWORD *)(a1 + 16) = v4;
if ( v4 )
{
snprintf(v4, 0xBuLL, "%s%5d", (const char *)a1, 0LL);
strcpy((char *)(a1 + 24), "Lines");
*(_DWORD *)(a1 + 32) = 0;
v5 = (char *)malloc(0xBuLL);
*(_QWORD *)(a1 + 40) = v5;
if ( v5 )
{
snprintf(v5, 0xBuLL, "%s%5d", (const char *)(a1 + 24), 0LL);
strcpy((char *)(a1 + 48), "Score");
*(_DWORD *)(a1 + 56) = 0;
v6 = (char *)malloc(0xBuLL);
*(_QWORD *)(a1 + 64) = v6;
if ( v6 )
{
snprintf(v6, 0xBuLL, "%s%5d", (const char *)(a1 + 48), 0LL);
strcpy((char *)(a1 + 72), "BEGIN");
strcpy((char *)(a1 + 78), "PAUSE");
strcpy((char *)(a1 + 84), "QUIT");
strcpy((char *)(a1 + 89), "Tetris");
result = 0LL;
}
else
{
if ( has_colors() )
wattr_on(stdscr, 0x900uLL, 0LL);
v10 = strlen(v11);
mvwprintw(stdscr, v2 / 2, (v3 - v10) >> 1, "%s", v11);
if ( has_colors() )
wattr_off(stdscr, 0x900uLL, 0LL);
nodelay(stdscr, 0);
wgetch(stdscr);
nodelay(stdscr, 1);
result = 0xFFFFFFFFLL;
}
}
else
{
if ( has_colors() )
wattr_on(stdscr, 0x900uLL, 0LL);
v9 = strlen(v12);
mvwprintw(stdscr, v2 / 2, (v3 - v9) >> 1, "%s", v12);
if ( has_colors() )
wattr_off(stdscr, 0x900uLL, 0LL);
nodelay(stdscr, 0);
wgetch(stdscr);
nodelay(stdscr, 1);
result = 0xFFFFFFFFLL;
}
}
else
{
if ( has_colors() )
wattr_on(stdscr, 0x900uLL, 0LL);
v8 = strlen(s);
mvwprintw(stdscr, v2 / 2, (v3 - v8) >> 1, "%s", s);
if ( has_colors() )
wattr_off(stdscr, 0x900uLL, 0LL);
nodelay(stdscr, 0);
wgetch(stdscr);
nodelay(stdscr, 1);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
static int init_prompt(prompt_t *prompt)
{
 prompt_t *ppt=prompt;
 char level_prompt[]="Failed to allocate space for level_show";
 char lines_prompt[]="Failed to allocate space for lines_show";
 char score_prompt[]="Failed to allocate space for score_show";
 int scr_y,scr_x;
 (scr_y = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), scr_x = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
 if(((void *)0)==ppt){
  return -1;
 }
 if(((void *)0)!=ppt->level_show||((void *)0)!=ppt->lines_show||((void *)0)!=ppt->score_show){
  exit_prompt(ppt);
  ppt->level_show=((void *)0);
  ppt->lines_show=((void *)0);
  ppt->score_show=((void *)0);
 }
 memset(ppt->level_key,0,(sizeof("Level")));
 strncpy(ppt->level_key,"Level",(sizeof("Level")));
 ppt->level_value=0;
 ppt->level_show=malloc((10*sizeof(char)+1));
 if(((void *)0)==ppt->level_show){
  if(has_colors()){wattr_on(stdscr, (attr_t)(((((chtype)(((COLOR_ERROR_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))))), ((void *)0));}
  mvwprintw(stdscr,scr_y/2,(scr_x-strlen(level_prompt))/2,"%s",level_prompt);
  if(has_colors()){wattr_off(stdscr, (attr_t)(((((chtype)(((COLOR_ERROR_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))))), ((void *)0));}
  nodelay(stdscr,0);
  wgetch(stdscr);
  nodelay(stdscr,1);
  return -1;
 }
 snprintf(ppt->level_show,(10*sizeof(char)+1),"%s%5d",ppt->level_key,ppt->level_value);
 memset(ppt->lines_key,0,(sizeof("Lines")));
 strncpy(ppt->lines_key,"Lines",(sizeof("Lines")));
 ppt->lines_value=0;
 ppt->lines_show=malloc((10*sizeof(char)+1));
 if(((void *)0)==ppt->lines_show){
  if(has_colors()){wattr_on(stdscr, (attr_t)(((((chtype)(((COLOR_ERROR_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))))), ((void *)0));}
  mvwprintw(stdscr,scr_y/2,(scr_x-strlen(lines_prompt))/2,"%s",lines_prompt);
  if(has_colors()){wattr_off(stdscr, (attr_t)(((((chtype)(((COLOR_ERROR_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))))), ((void *)0));}
  nodelay(stdscr,0);
  wgetch(stdscr);
  nodelay(stdscr,1);
  return -1;
 }
 snprintf(ppt->lines_show,(10*sizeof(char)+1),"%s%5d",ppt->lines_key,ppt->lines_value);
 memset(ppt->score_key,0,(sizeof("Score")));
 strncpy(ppt->score_key,"Score",(sizeof("Score")));
 ppt->score_value=0;
 ppt->score_show=malloc((10*sizeof(char)+1));
 if(((void *)0)==ppt->score_show){
  if(has_colors()){wattr_on(stdscr, (attr_t)(((((chtype)(((COLOR_ERROR_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))))), ((void *)0));}
  mvwprintw(stdscr,scr_y/2,(scr_x-strlen(score_prompt))/2,"%s",score_prompt);
  if(has_colors()){wattr_off(stdscr, (attr_t)(((((chtype)(((COLOR_ERROR_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))))), ((void *)0));}
  nodelay(stdscr,0);
  wgetch(stdscr);
  nodelay(stdscr,1);
  return -1;
 }
 snprintf(ppt->score_show,(10*sizeof(char)+1),"%s%5d",ppt->score_key,ppt->score_value);
 memset(ppt->start,0,sizeof("BEGIN"));
 strncpy(ppt->start,"BEGIN",sizeof("BEGIN"));
 memset(ppt->pause,0,sizeof("PAUSE"));
 strncpy(ppt->pause,"PAUSE",sizeof("PAUSE"));
 memset(ppt->quit,0,sizeof("QUIT"));
 strncpy(ppt->quit,"QUIT",sizeof("QUIT"));
 memset(ppt->title,0,sizeof("Tetris"));
 strncpy(ppt->title,"Tetris",sizeof("Tetris"));
 return 0;
}

canonical_original_code:
static int init_prompt(struct prompt *prompt)
{
 struct prompt *ppt = prompt;
 char level_prompt[] = "Failed to allocate space for level_show";
 char lines_prompt[] = "Failed to allocate space for lines_show";
 char score_prompt[] = "Failed to allocate space for score_show";
 int scr_y; int scr_x;
 (scr_y = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), scr_x = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
 if(((void *)0)==ppt){
  return -1;
 }
 if(((void *)0)!=ppt->level_show||((void *)0)!=ppt->lines_show||((void *)0)!=ppt->score_show){
  exit_prompt(ppt);
  ppt->level_show=((void *)0);
  ppt->lines_show=((void *)0);
  ppt->score_show=((void *)0);
 }
 memset(ppt->level_key,0,(sizeof("Level")));
 strncpy(ppt->level_key,"Level",(sizeof("Level")));
 ppt->level_value=0;
 ppt->level_show=malloc((10*sizeof(char)+1));
 if(((void *)0)==ppt->level_show){
  if(has_colors()){wattr_on(stdscr, (attr_t)(((((chtype)(((COLOR_ERROR_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))))), ((void *)0));}
  mvwprintw(stdscr,scr_y/2,(scr_x-strlen(level_prompt))/2,"%s",level_prompt);
  if(has_colors()){wattr_off(stdscr, (attr_t)(((((chtype)(((COLOR_ERROR_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))))), ((void *)0));}
  nodelay(stdscr,0);
  wgetch(stdscr);
  nodelay(stdscr,1);
  return -1;
 }
 snprintf(ppt->level_show,(10*sizeof(char)+1),"%s%5d",ppt->level_key,ppt->level_value);
 memset(ppt->lines_key,0,(sizeof("Lines")));
 strncpy(ppt->lines_key,"Lines",(sizeof("Lines")));
 ppt->lines_value=0;
 ppt->lines_show=malloc((10*sizeof(char)+1));
 if(((void *)0)==ppt->lines_show){
  if(has_colors()){wattr_on(stdscr, (attr_t)(((((chtype)(((COLOR_ERROR_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))))), ((void *)0));}
  mvwprintw(stdscr,scr_y/2,(scr_x-strlen(lines_prompt))/2,"%s",lines_prompt);
  if(has_colors()){wattr_off(stdscr, (attr_t)(((((chtype)(((COLOR_ERROR_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))))), ((void *)0));}
  nodelay(stdscr,0);
  wgetch(stdscr);
  nodelay(stdscr,1);
  return -1;
 }
 snprintf(ppt->lines_show,(10*sizeof(char)+1),"%s%5d",ppt->lines_key,ppt->lines_value);
 memset(ppt->score_key,0,(sizeof("Score")));
 strncpy(ppt->score_key,"Score",(sizeof("Score")));
 ppt->score_value=0;
 ppt->score_show=malloc((10*sizeof(char)+1));
 if(((void *)0)==ppt->score_show){
  if(has_colors()){wattr_on(stdscr, (attr_t)(((((chtype)(((COLOR_ERROR_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))))), ((void *)0));}
  mvwprintw(stdscr,scr_y/2,(scr_x-strlen(score_prompt))/2,"%s",score_prompt);
  if(has_colors()){wattr_off(stdscr, (attr_t)(((((chtype)(((COLOR_ERROR_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))))), ((void *)0));}
  nodelay(stdscr,0);
  wgetch(stdscr);
  nodelay(stdscr,1);
  return -1;
 }
 snprintf(ppt->score_show,(10*sizeof(char)+1),"%s%5d",ppt->score_key,ppt->score_value);
 memset(ppt->start,0,sizeof("BEGIN"));
 strncpy(ppt->start,"BEGIN",sizeof("BEGIN"));
 memset(ppt->pause,0,sizeof("PAUSE"));
 strncpy(ppt->pause,"PAUSE",sizeof("PAUSE"));
 memset(ppt->quit,0,sizeof("QUIT"));
 strncpy(ppt->quit,"QUIT",sizeof("QUIT"));
 memset(ppt->title,0,sizeof("Tetris"));
 strncpy(ppt->title,"Tetris",sizeof("Tetris"));
 return 0;
}

user_defined_types: struct prompt { char level_key[-1]; int level_value; char *level_show; char lines_key[-1]; int lines_value; char *lines_show; char score_key[-1]; int score_value; char *score_show; char start[-1]; char pause[-1]; char quit[-1]; char title[-1]; }


decompiled_code:
void __fastcall open_colors(int a1)
{
switch ( a1 )
{
case 0:
if ( has_colors() )
wattr_on(stdscr, 0x200100uLL, 0LL);
break;
case 1:
if ( has_colors() )
wattr_on(stdscr, 0x200200uLL, 0LL);
break;
case 2:
if ( has_colors() )
wattr_on(stdscr, 0x200300uLL, 0LL);
break;
case 3:
if ( has_colors() )
wattr_on(stdscr, 0x200400uLL, 0LL);
break;
case 4:
if ( has_colors() )
wattr_on(stdscr, 0x200500uLL, 0LL);
break;
case 5:
if ( has_colors() )
wattr_on(stdscr, 0x200600uLL, 0LL);
break;
case 6:
if ( has_colors() )
wattr_on(stdscr, 0x200700uLL, 0LL);
break;
default:
return;
}
}

canonical_decompiled_code:
void __fastcall func1(int a1)
{
switch ( a1 )
{
case 0:
if ( has_colors() )
wattr_on(stdscr, 0x200100uLL, 0LL);
break;
case 1:
if ( has_colors() )
wattr_on(stdscr, 0x200200uLL, 0LL);
break;
case 2:
if ( has_colors() )
wattr_on(stdscr, 0x200300uLL, 0LL);
break;
case 3:
if ( has_colors() )
wattr_on(stdscr, 0x200400uLL, 0LL);
break;
case 4:
if ( has_colors() )
wattr_on(stdscr, 0x200500uLL, 0LL);
break;
case 5:
if ( has_colors() )
wattr_on(stdscr, 0x200600uLL, 0LL);
break;
case 6:
if ( has_colors() )
wattr_on(stdscr, 0x200700uLL, 0LL);
break;
default:
return;
}
}

variable_types: enum block_type { BLOCK_I=0, BLOCK_J=1, BLOCK_L=2, BLOCK_O=3, BLOCK_S=4, BLOCK_Z=5, BLOCK_T=6, BLOCK_TYPE_NONE=7 }


decompiled_code:
void __fastcall close_colors(int a1)
{
switch ( a1 )
{
case 0:
if ( has_colors() )
wattr_off(stdscr, 0x200100uLL, 0LL);
break;
case 1:
if ( has_colors() )
wattr_off(stdscr, 0x200200uLL, 0LL);
break;
case 2:
if ( has_colors() )
wattr_off(stdscr, 0x200300uLL, 0LL);
break;
case 3:
if ( has_colors() )
wattr_off(stdscr, 0x200400uLL, 0LL);
break;
case 4:
if ( has_colors() )
wattr_off(stdscr, 0x200500uLL, 0LL);
break;
case 5:
if ( has_colors() )
wattr_off(stdscr, 0x200600uLL, 0LL);
break;
case 6:
if ( has_colors() )
wattr_off(stdscr, 0x200700uLL, 0LL);
break;
default:
return;
}
}

canonical_decompiled_code:
void __fastcall func2(int a1)
{
switch ( a1 )
{
case 0:
if ( has_colors() )
wattr_off(stdscr, 0x200100uLL, 0LL);
break;
case 1:
if ( has_colors() )
wattr_off(stdscr, 0x200200uLL, 0LL);
break;
case 2:
if ( has_colors() )
wattr_off(stdscr, 0x200300uLL, 0LL);
break;
case 3:
if ( has_colors() )
wattr_off(stdscr, 0x200400uLL, 0LL);
break;
case 4:
if ( has_colors() )
wattr_off(stdscr, 0x200500uLL, 0LL);
break;
case 5:
if ( has_colors() )
wattr_off(stdscr, 0x200600uLL, 0LL);
break;
case 6:
if ( has_colors() )
wattr_off(stdscr, 0x200700uLL, 0LL);
break;
default:
return;
}
}

user_defined_types: enum block_type { BLOCK_I=0, BLOCK_J=1, BLOCK_L=2, BLOCK_O=3, BLOCK_S=4, BLOCK_Z=5, BLOCK_T=6, BLOCK_TYPE_NONE=7 }


decompiled_code:
int draw_confirm_exit()
{
int v0; // er12
__int64 v1; // rbp
size_t v2; // rax
int v3; // edx
unsigned __int64 v4; // rbp
int v5; // edx
char v7[32]; // [rsp+0h] [rbp-78h] BYREF
char s[88]; // [rsp+20h] [rbp-58h] BYREF

strcpy(s, "Please press key 'y' or 'Y' to confirm exit the program,");
strcpy(v7, "press others key to continue!");
if ( stdscr )
{
v0 = stdscr->_maxy + 1;
LODWORD(v1) = stdscr->_maxx + 1;
if ( !has_colors() )
goto LABEL_3;
goto LABEL_11;
}
if ( has_colors() )
{
LODWORD(v1) = -1;
v0 = -1;
LABEL_11:
wattr_on(stdscr, 0x200A00uLL, 0LL);
LABEL_3:
v1 = (int)v1;
v2 = (int)v1 - strlen(s);
v3 = 1;
if ( v2 <= 1 )
goto LABEL_5;
goto LABEL_4;
}
v2 = ~strlen(s);
v0 = -1;
v1 = -1LL;
LABEL_4:
v3 = v2 >> 1;
LABEL_5:
mvwprintw(stdscr, v0 / 2, v3, "%s", s);
v4 = v1 - strlen(v7);
v5 = 1;
if ( v4 > 1 )
v5 = v4 >> 1;
mvwprintw(stdscr, v0 / 2 + 1, v5, "%s", v7);
if ( has_colors() )
wattr_off(stdscr, 0x200A00uLL, 0LL);
return wrefresh(stdscr);
}

canonical_decompiled_code:
int func9()
{
int v0; // er12
__int64 v1; // rbp
size_t v2; // rax
int v3; // edx
unsigned __int64 v4; // rbp
int v5; // edx
char v7[32]; // [rsp+0h] [rbp-78h] BYREF
char s[88]; // [rsp+20h] [rbp-58h] BYREF

strcpy(s, "Please press key 'y' or 'Y' to confirm exit the program,");
strcpy(v7, "press others key to continue!");
if ( stdscr )
{
v0 = stdscr->_maxy + 1;
LODWORD(v1) = stdscr->_maxx + 1;
if ( !has_colors() )
goto LABEL_3;
goto LABEL_11;
}
if ( has_colors() )
{
LODWORD(v1) = -1;
v0 = -1;
LABEL_11:
wattr_on(stdscr, 0x200A00uLL, 0LL);
LABEL_3:
v1 = (int)v1;
v2 = (int)v1 - strlen(s);
v3 = 1;
if ( v2 <= 1 )
goto LABEL_5;
goto LABEL_4;
}
v2 = ~strlen(s);
v0 = -1;
v1 = -1LL;
LABEL_4:
v3 = v2 >> 1;
LABEL_5:
mvwprintw(stdscr, v0 / 2, v3, "%s", s);
v4 = v1 - strlen(v7);
v5 = 1;
if ( v4 > 1 )
v5 = v4 >> 1;
mvwprintw(stdscr, v0 / 2 + 1, v5, "%s", v7);
if ( has_colors() )
wattr_off(stdscr, 0x200A00uLL, 0LL);
return wrefresh(stdscr);
}

original_code:
void draw_confirm_exit()
{
  char confirm_quit[]="Please press key 'y' or 'Y' to confirm exit the program,";
  char confirm_continue[]="press others key to continue!";
  int scr_y,scr_x;
  (scr_y = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), scr_x = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
  if(has_colors()){wattr_on(stdscr, (attr_t)(((((chtype)(((COLOR_NORMAL_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8)))|((chtype)((1U)) << ((13) + 8)))), ((void *)0));}
  mvwprintw(stdscr,scr_y/2,((scr_x-strlen(confirm_quit))/2>0)?((scr_x-strlen(confirm_quit))/2):(1),"%s",confirm_quit);
  mvwprintw(stdscr,scr_y/2+1,((scr_x-strlen(confirm_continue))/2>0)?((scr_x-strlen(confirm_continue))/2):(1),"%s",confirm_continue);
  if(has_colors()){wattr_off(stdscr, (attr_t)(((((chtype)(((COLOR_NORMAL_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8)))|((chtype)((1U)) << ((13) + 8)))), ((void *)0));}
  wrefresh(stdscr);
}

canonical_original_code:
void draw_confirm_exit()
{
  char confirm_quit[] = "Please press key 'y' or 'Y' to confirm exit the program,";
  char confirm_continue[] = "press others key to continue!";
  int scr_y; int scr_x;
  (scr_y = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), scr_x = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
  if(has_colors()){wattr_on(stdscr, (attr_t)(((((chtype)(((COLOR_NORMAL_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8)))|((chtype)((1U)) << ((13) + 8)))), ((void *)0));}
  mvwprintw(stdscr,scr_y/2,((scr_x-strlen(confirm_quit))/2>0)?((scr_x-strlen(confirm_quit))/2):(1),"%s",confirm_quit);
  mvwprintw(stdscr,scr_y/2+1,((scr_x-strlen(confirm_continue))/2>0)?((scr_x-strlen(confirm_continue))/2):(1),"%s",confirm_continue);
  if(has_colors()){wattr_off(stdscr, (attr_t)(((((chtype)(((COLOR_NORMAL_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8)))|((chtype)((1U)) << ((13) + 8)))), ((void *)0));}
  wrefresh(stdscr);
}


decompiled_code:
int draw_help_info()
{
int v0; // er12
int v1; // ebx
int v2; // ebx
int result; // eax
size_t v4; // rax
size_t v5; // rdx
int v6; // esi
char v7[49]; // [rsp+0h] [rbp-178h] BYREF
char v8[47]; // [rsp+31h] [rbp-147h] BYREF
char v9[33]; // [rsp+60h] [rbp-118h] BYREF
char v10[63]; // [rsp+81h] [rbp-F7h] BYREF
char v11[48]; // [rsp+C0h] [rbp-B8h] BYREF
char v12[48]; // [rsp+F0h] [rbp-88h] BYREF
char v13[52]; // [rsp+120h] [rbp-58h] BYREF
char s[36]; // [rsp+154h] [rbp-24h] BYREF

strcpy(s, "Tetris help");
strcpy(v13, "Rotate:[W] [w] [I] [i] [Arrow keys UP] ");
strcpy(v12, "Right :[D] [d] [L] [l] [Arrow keys Right]");
strcpy(v11, "Down :[S] [s] [K] [k] [Arrow keys Down]");
strcpy(&v10[15], "Left :[A] [a] [J] [j] [Arrow keys Left]");
strcpy(v10, "begin :[B] [b]");
strcpy(v9, "Pause :[P] [p] [Spacebar]");
strcpy(&v8[15], "Quit :[Q] [q] [Esc]");
strcpy(v8, "Help :[H] [h]");
strcpy(v7, "Press any key or click mouse to continue!");
nodelay(stdscr, 1);
werase(stdscr);
do
{
if ( stdscr )
{
v0 = stdscr->_maxy + 1;
v1 = stdscr->_maxx + 1;
}
else
{
v0 = -1;
v1 = -1;
}
wclear(stdscr);
if ( has_colors() )
wattr_on(stdscr, 0x200A00uLL, 0LL);
v4 = strlen(s);
mvwprintw(stdscr, 1, (v1 - v4) >> 1, "%s", s);
mvwprintw(stdscr, 3, 1, "%s", v13);
mvwprintw(stdscr, 4, 1, "%s", v12);
mvwprintw(stdscr, 5, 1, "%s", v11);
mvwprintw(stdscr, 6, 1, "%s", &v10[15]);
mvwprintw(stdscr, 7, 1, "%s", v10);
mvwprintw(stdscr, 8, 1, "%s", v9);
mvwprintw(stdscr, 9, 1, "%s", &v8[15]);
mvwprintw(stdscr, 10, 1, "%s", v8);
wborder(stdscr, 0LL, 0LL, 0LL, 0LL, 0LL, 0LL, 0LL, 0LL);
if ( has_colors() )
wattr_off(stdscr, 0x200A00uLL, 0LL);
if ( has_colors() )
wattr_on(stdscr, 0x200B00uLL, 0LL);
v5 = (v1 - strlen(v7)) >> 1;
v6 = v0 / 2;
if ( (int)(v0 + ((unsigned int)v0 >> 31)) <= 21 )
v6 = 11;
mvwprintw(stdscr, v6, v5, "%s", v7);
if ( has_colors() )
wattr_off(stdscr, 0x200B00uLL, 0LL);
v2 = wgetch(stdscr);
wrefresh(stdscr);
result = usleep(0x30D40u);
}
while ( v2 == -1 );
return result;
}

canonical_decompiled_code:
int func11()
{
int v0; // er12
int v1; // ebx
int v2; // ebx
int result; // eax
size_t v4; // rax
size_t v5; // rdx
int v6; // esi
char v7[49]; // [rsp+0h] [rbp-178h] BYREF
char v8[47]; // [rsp+31h] [rbp-147h] BYREF
char v9[33]; // [rsp+60h] [rbp-118h] BYREF
char v10[63]; // [rsp+81h] [rbp-F7h] BYREF
char v11[48]; // [rsp+C0h] [rbp-B8h] BYREF
char v12[48]; // [rsp+F0h] [rbp-88h] BYREF
char v13[52]; // [rsp+120h] [rbp-58h] BYREF
char s[36]; // [rsp+154h] [rbp-24h] BYREF

strcpy(s, "Tetris help");
strcpy(v13, "Rotate:[W] [w] [I] [i] [Arrow keys UP] ");
strcpy(v12, "Right :[D] [d] [L] [l] [Arrow keys Right]");
strcpy(v11, "Down :[S] [s] [K] [k] [Arrow keys Down]");
strcpy(&v10[15], "Left :[A] [a] [J] [j] [Arrow keys Left]");
strcpy(v10, "begin :[B] [b]");
strcpy(v9, "Pause :[P] [p] [Spacebar]");
strcpy(&v8[15], "Quit :[Q] [q] [Esc]");
strcpy(v8, "Help :[H] [h]");
strcpy(v7, "Press any key or click mouse to continue!");
nodelay(stdscr, 1);
werase(stdscr);
do
{
if ( stdscr )
{
v0 = stdscr->_maxy + 1;
v1 = stdscr->_maxx + 1;
}
else
{
v0 = -1;
v1 = -1;
}
wclear(stdscr);
if ( has_colors() )
wattr_on(stdscr, 0x200A00uLL, 0LL);
v4 = strlen(s);
mvwprintw(stdscr, 1, (v1 - v4) >> 1, "%s", s);
mvwprintw(stdscr, 3, 1, "%s", v13);
mvwprintw(stdscr, 4, 1, "%s", v12);
mvwprintw(stdscr, 5, 1, "%s", v11);
mvwprintw(stdscr, 6, 1, "%s", &v10[15]);
mvwprintw(stdscr, 7, 1, "%s", v10);
mvwprintw(stdscr, 8, 1, "%s", v9);
mvwprintw(stdscr, 9, 1, "%s", &v8[15]);
mvwprintw(stdscr, 10, 1, "%s", v8);
wborder(stdscr, 0LL, 0LL, 0LL, 0LL, 0LL, 0LL, 0LL, 0LL);
if ( has_colors() )
wattr_off(stdscr, 0x200A00uLL, 0LL);
if ( has_colors() )
wattr_on(stdscr, 0x200B00uLL, 0LL);
v5 = (v1 - strlen(v7)) >> 1;
v6 = v0 / 2;
if ( (int)(v0 + ((unsigned int)v0 >> 31)) <= 21 )
v6 = 11;
mvwprintw(stdscr, v6, v5, "%s", v7);
if ( has_colors() )
wattr_off(stdscr, 0x200B00uLL, 0LL);
v2 = wgetch(stdscr);
wrefresh(stdscr);
result = usleep(0x30D40u);
}
while ( v2 == -1 );
return result;
}

original_code:
void draw_help_info()
{
 char ttrs_title[]="Tetris help";
 char ttrs_rotate[]="Rotate:[W] [w] [I] [i] [Arrow keys UP] ";
 char ttrs_right[] ="Right :[D] [d] [L] [l] [Arrow keys Right]";
 char ttrs_down[] ="Down  :[S] [s] [K] [k] [Arrow keys Down]";
 char ttrs_left[] ="Left  :[A] [a] [J] [j] [Arrow keys Left]";
 char ttrs_begin[] ="begin :[B] [b]";
 char ttrs_pause[] ="Pause :[P] [p] [Spacebar]";
 char ttrs_quit[] ="Quit  :[Q] [q] [Esc]";
 char ttrs_help[] ="Help  :[H] [h]";
 char ttrs_continue[]="Press any key or click mouse to continue!";
 int y=0;
 int x=1;
 int scr_y;
 int scr_x;
 int ch=(-1);
 nodelay(stdscr,1);
 werase(stdscr);
 while(ch==(-1)){
  y=0;
  (scr_y = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), scr_x = ((0 != (const void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
  wclear(stdscr);
  if(has_colors()){wattr_on(stdscr, (attr_t)(((((chtype)(((COLOR_NORMAL_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8)))|((chtype)((1U)) << ((13) + 8)))), ((void *)0));}
  mvwprintw(stdscr,++y,(scr_x-strlen(ttrs_title))/2,"%s",ttrs_title);
  y++;
  mvwprintw(stdscr,++y,x,"%s",ttrs_rotate);
  mvwprintw(stdscr,++y,x,"%s",ttrs_right);
  mvwprintw(stdscr,++y,x,"%s",ttrs_down);
  mvwprintw(stdscr,++y,x,"%s",ttrs_left);
  mvwprintw(stdscr,++y,x,"%s",ttrs_begin);
  mvwprintw(stdscr,++y,x,"%s",ttrs_pause);
  mvwprintw(stdscr,++y,x,"%s",ttrs_quit);
  mvwprintw(stdscr,++y,x,"%s",ttrs_help);
  wborder(stdscr, 0, 0, 0, 0, 0, 0, 0, 0);
  if(has_colors()){wattr_off(stdscr, (attr_t)(((((chtype)(((COLOR_NORMAL_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8)))|((chtype)((1U)) << ((13) + 8)))), ((void *)0));}
  y++;
  if(has_colors()){wattr_on(stdscr, (attr_t)(((((chtype)(((COLOR_BUTTON))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8)))|((chtype)((1U)) << ((13) + 8)))), ((void *)0));}
  mvwprintw(stdscr,((scr_y/2)>y)?(scr_y/2):(y),(scr_x-strlen(ttrs_continue))/2,"%s",ttrs_continue);
  if(has_colors()){wattr_off(stdscr, (attr_t)(((((chtype)(((COLOR_BUTTON))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8)))|((chtype)((1U)) << ((13) + 8)))), ((void *)0));}
  ch=wgetch(stdscr);
  wrefresh(stdscr);
  usleep(100000*2);
 }
 return;
}

canonical_original_code:
void draw_help_info()
{
 char ttrs_title[] = "Tetris help";
 char ttrs_rotate[] = "Rotate:[W] [w] [I] [i] [Arrow keys UP] ";
 char ttrs_right[] = "Right :[D] [d] [L] [l] [Arrow keys Right]";
 char ttrs_down[] = "Down  :[S] [s] [K] [k] [Arrow keys Down]";
 char ttrs_left[] = "Left  :[A] [a] [J] [j] [Arrow keys Left]";
 char ttrs_begin[] = "begin :[B] [b]";
 char ttrs_pause[] = "Pause :[P] [p] [Spacebar]";
 char ttrs_quit[] = "Quit  :[Q] [q] [Esc]";
 char ttrs_help[] = "Help  :[H] [h]";
 char ttrs_continue[] = "Press any key or click mouse to continue!";
 int y = 0;
 int x = 1;
 int scr_y;
 int scr_x;
 int ch = (-1);
 nodelay(stdscr,1);
 werase(stdscr);
 while(ch==(-1)){
  y=0;
  (scr_y = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxy + 1) : (-1)), scr_x = ((0 != (void *)((stdscr))) ? ((stdscr)->_maxx + 1) : (-1)));
  wclear(stdscr);
  if(has_colors()){wattr_on(stdscr, (attr_t)(((((chtype)(((COLOR_NORMAL_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8)))|((chtype)((1U)) << ((13) + 8)))), ((void *)0));}
  mvwprintw(stdscr,++y,(scr_x-strlen(ttrs_title))/2,"%s",ttrs_title);
  y++;
  mvwprintw(stdscr,++y,x,"%s",ttrs_rotate);
  mvwprintw(stdscr,++y,x,"%s",ttrs_right);
  mvwprintw(stdscr,++y,x,"%s",ttrs_down);
  mvwprintw(stdscr,++y,x,"%s",ttrs_left);
  mvwprintw(stdscr,++y,x,"%s",ttrs_begin);
  mvwprintw(stdscr,++y,x,"%s",ttrs_pause);
  mvwprintw(stdscr,++y,x,"%s",ttrs_quit);
  mvwprintw(stdscr,++y,x,"%s",ttrs_help);
  wborder(stdscr, 0, 0, 0, 0, 0, 0, 0, 0);
  if(has_colors()){wattr_off(stdscr, (attr_t)(((((chtype)(((COLOR_NORMAL_PROMPT))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8)))|((chtype)((1U)) << ((13) + 8)))), ((void *)0));}
  y++;
  if(has_colors()){wattr_on(stdscr, (attr_t)(((((chtype)(((COLOR_BUTTON))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8)))|((chtype)((1U)) << ((13) + 8)))), ((void *)0));}
  mvwprintw(stdscr,((scr_y/2)>y)?(scr_y/2):(y),(scr_x-strlen(ttrs_continue))/2,"%s",ttrs_continue);
  if(has_colors()){wattr_off(stdscr, (attr_t)(((((chtype)(((COLOR_BUTTON))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8)))|((chtype)((1U)) << ((13) + 8)))), ((void *)0));}
  ch=wgetch(stdscr);
  wrefresh(stdscr);
  usleep(100000*2);
 }
 return;
}

variable_types: ch int


repo: haneefmubarak/snippets

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int i; // ebx

for ( i = 310; i != 1114422; i += 17 )
printf("%u\n", i % 0xB);
return 0;
}

variable_types:
x
unsigned int


usage

decompiled_code:
void __noreturn usage()
{
const char *v0; // [rsp+0h] [rbp-10h]

fprintf(
stderr,
"set the environment variable %s to a valid destination.\n"
"\n"
"examples:\n"
"\ttcp mode:\n"
"\t\t%s %s=tcp:wii\n"
"\t\t%s %s=tcp:192.168.0.30\n"
"\n"
"usage:\n"
"\t%s <filename> <application arguments>\n"
"\n",
"PS3LOAD",
"export",
"PS3LOAD",
"export",
"PS3LOAD",
v0);
exit(1);
}

canonical_decompiled_code:
void __noreturn func7()
{
const char *v0; // [rsp+0h] [rbp-10h]

fprintf(
stderr,
"set the environment variable %s to a valid destination.\n"
"\n"
"examples:\n"
"\ttcp mode:\n"
"\t\t%s %s=tcp:wii\n"
"\t\t%s %s=tcp:192.168.0.30\n"
"\n"
"usage:\n"
"\t%s <filename> <application arguments>\n"
"\n",
"PS3LOAD",
"export",
"PS3LOAD",
"export",
"PS3LOAD",
v0);
exit(1);
}

original_code:
static void usage (const char *argv0) {
 fprintf (stderr, "set the environment variable %s to a valid "
    "destination.\n\n"
    "examples:\n"
    "\ttcp mode:\n"
    "\t\t%s %s=tcp:wii\n"
    "\t\t%s %s=tcp:192.168.0.30\n\n"
    "usage:\n"
    "\t%s <filename> <application arguments>\n\n",
    envvar,
    desc_export, envvar,
    desc_export, envvar,
    argv0);
 exit (1);
}

canonical_original_code:
static void usage(char *argv0) {
 fprintf (stderr, "set the environment variable %s to a valid "
    "destination.\n\n"
    "examples:\n"
    "\ttcp mode:\n"
    "\t\t%s %s=tcp:wii\n"
    "\t\t%s %s=tcp:192.168.0.30\n\n"
    "usage:\n"
    "\t%s <filename> <application arguments>\n\n",
    envvar,
    desc_export, envvar,
    desc_export, envvar,
    argv0);
 exit (1);
}


repo: hanmouse/test

decompiled_code:
__int64 __fastcall init_queue(__int64 a1, __int64 a2)
{
void *v2; // rax
int *v4; // rbp
char *v5; // rax

*(_QWORD *)a1 = a2 + 1;
*(_DWORD *)(a1 + 12) = 0;
*(_DWORD *)(a1 + 8) = 0;
v2 = calloc(a2 + 1, 0x40uLL);
*(_QWORD *)(a1 + 16) = v2;
if ( v2 )
return 0LL;
v4 = __errno_location();
v5 = strerror(*v4);
fprintf(stderr, "calloc() failed: size=%zu, E=%d[ %s ]\n", *(_QWORD *)a1 << 6, (unsigned int)*v4, v5);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2)
{
void *v2; // rax
int *v4; // rbp
char *v5; // rax

*(_QWORD *)a1 = a2 + 1;
*(_DWORD *)(a1 + 12) = 0;
*(_DWORD *)(a1 + 8) = 0;
v2 = calloc(a2 + 1, 0x40uLL);
*(_QWORD *)(a1 + 16) = v2;
if ( v2 )
return 0LL;
v4 = __errno_location();
v5 = strerror(*v4);
fprintf(stderr, "calloc() failed: size=%zu, E=%d[ %s ]\n", *(_QWORD *)a1 << 6, (unsigned int)*v4, v5);
return 0xFFFFFFFFLL;
}

original_code:
int init_queue( queue_t *queue, size_t size)
{
 queue->size = size + 1;
 queue->front = queue->rear = 0;
 queue->data = calloc( queue->size, 64);
 if (queue->data == ((void *)0)) {
  fprintf( stderr, "calloc() failed: size=%zu, E=%d[ %s ]\n", queue->size * 64, (*__errno_location ()), strerror( (*__errno_location ())));
  return -1;
 }
 return 0;
}

canonical_original_code:
int init_queue(struct queue_s *queue, unsigned long size)
{
 queue->size = size + 1;
 queue->front = queue->rear = 0;
 queue->data = calloc( queue->size, 64);
 if (queue->data == ((void *)0)) {
  fprintf( stderr, "calloc() failed: size=%zu, E=%d[ %s ]\n", queue->size * 64, (*__errno_location ()), strerror( (*__errno_location ())));
  return -1;
 }
 return 0;
}

variable_types: struct queue_s { unsigned long size; int front; int rear; unsigned char *data; unsigned long data_size[128]; } *

variable_types:
size
unsigned long