decompiled_code:
__int64 fls_main()
{
time_t v0; // rbx
__int64 result; // rax
__int64 v2; // rax
__int64 v3; // rbp
__int16 v4; // ax
__pid_t v5; // eax
time_t v6; // r8
int v7; // edx
char v8; // al
__int64 v9; // rax
unsigned __int8 v10; // al
unsigned __int8 v11; // [rsp+Fh] [rbp-39h] BYREF
time_t v12; // [rsp+10h] [rbp-38h] BYREF
time_t timer; // [rsp+18h] [rbp-30h] BYREF

time(&timer);
v0 = time(0LL);
LABEL_2:
while ( 1 )
{
result = (unsigned int)fls_switch;
if ( !fls_switch )
return result;
while ( 1 )
{
time(&v12);
v2 = read_net();
v3 = v2;
if ( !v2 )
break;
v4 = _bswap_16(*(_WORD *)(v2 + 4));
switch ( v4 )
{
case 3:
ntohpt3(v3);
if ( netpt3_check(v3) )
{
v9 = hash_search(*(unsigned __int16 *)(v3 + 68), *(unsigned int *)(v3 + 64), v12);
send_net4(v3, v9 != 0, v9);
}
break;
case 7:
if ( manage_switch )
{
ntohpt7(v3);
if ( netpt7_check(v3) )
{
v8 = *(_BYTE *)(v3 + 64);
switch ( v8 )
{
case 2:
remove_rflsl(v3 + 68);
send_net8(v3, 4LL, 3LL);
addto_log(1LL, "fls id: %d closed.", *(unsigned __int8 *)(v3 + 68));
break;
case 3:
remove_rflsl(v3 + 68);
send_net8(v3, 4LL, 3LL);
addto_log(1LL, "fls id: %d disconnected!", *(unsigned __int8 *)(v3 + 68));
break;
case 1:
if ( !(unsigned int)addto_rflsl(v3 + 68) )
run_msg("fls server is too much!");
send_net8(v3, 4LL, 2LL);
addto_log(1LL, "fls id: %d started.", *(unsigned __int8 *)(v3 + 68));
break;
}
}
}
break;
case 1:
ntohpt1(v3);
if ( netpt1_check(v3) )
{
v6 = v12;
if ( v12 == timer )
{
v7 = call_0 + 1;
}
else
{
addto_log(
2LL,
"%5d %5d %5d %5d",
(unsigned int)call_0,
(unsigned int)callow_1,
(unsigned int)crefuse_2,
(unsigned int)cfail_3);
v6 = v12;
v7 = 1;
cfail_3 = 0;
crefuse_2 = 0;
callow_1 = 0;
timer = v12;
}
call_0 = v7;
if ( !manage_switch || *(unsigned __int16 *)(v3 + 14) == rflsl[768] )
{
v10 = access_query(v3, &v11, v6);
if ( v11 == 1 )
{
if ( v10 == 1 )
++callow_1;
else
++crefuse_2;
}
else
{
++cfail_3;
}
send_net2(v3, v11, v10);
}
else
{
send_net6(v3);
++callow_1;
}
}
break;
}
if ( !_memuse_rate_switch
|| __ROR8__(0xCCCCCCCCCCCCCCCDLL * (v12 - v0) + 0x1999999999999998LL, 1) > 0x1999999999999998uLL
|| v0 == v12 )
{
break;
}
v5 = fork();
if ( v5 < 0 )
{
run_msg("In fls_main memuse_rate: fork error");
goto LABEL_2;
}
if ( !v5 )
{
memuse_rate();
exit(0);
}
result = (unsigned int)fls_switch;
v0 = v12;
if ( !fls_switch )
return result;
}
}
}

canonical_decompiled_code:
__int64 func4()
{
time_t v0; // rbx
__int64 result; // rax
__int64 v2; // rax
__int64 v3; // rbp
__int16 v4; // ax
__pid_t v5; // eax
time_t v6; // r8
int v7; // edx
char v8; // al
__int64 v9; // rax
unsigned __int8 v10; // al
unsigned __int8 v11; // [rsp+Fh] [rbp-39h] BYREF
time_t v12; // [rsp+10h] [rbp-38h] BYREF
time_t timer; // [rsp+18h] [rbp-30h] BYREF

time(&timer);
v0 = time(0LL);
LABEL_2:
while ( 1 )
{
result = (unsigned int)fls_switch;
if ( !fls_switch )
return result;
while ( 1 )
{
time(&v12);
v2 = read_net();
v3 = v2;
if ( !v2 )
break;
v4 = func0(*(_WORD *)(v2 + 4));
switch ( v4 )
{
case 3:
ntohpt3(v3);
if ( func2(v3) )
{
v9 = hash_search(*(unsigned __int16 *)(v3 + 68), *(unsigned int *)(v3 + 64), v12);
send_net4(v3, v9 != 0, v9);
}
break;
case 7:
if ( manage_switch )
{
ntohpt7(v3);
if ( func3(v3) )
{
v8 = *(_BYTE *)(v3 + 64);
switch ( v8 )
{
case 2:
remove_rflsl(v3 + 68);
send_net8(v3, 4LL, 3LL);
addto_log(1LL, "fls id: %d closed.", *(unsigned __int8 *)(v3 + 68));
break;
case 3:
remove_rflsl(v3 + 68);
send_net8(v3, 4LL, 3LL);
addto_log(1LL, "fls id: %d disconnected!", *(unsigned __int8 *)(v3 + 68));
break;
case 1:
if ( !(unsigned int)addto_rflsl(v3 + 68) )
run_msg("fls server is too much!");
send_net8(v3, 4LL, 2LL);
addto_log(1LL, "fls id: %d started.", *(unsigned __int8 *)(v3 + 68));
break;
}
}
}
break;
case 1:
ntohpt1(v3);
if ( func1(v3) )
{
v6 = v12;
if ( v12 == timer )
{
v7 = call_0 + 1;
}
else
{
addto_log(
2LL,
"%5d %5d %5d %5d",
(unsigned int)call_0,
(unsigned int)callow_1,
(unsigned int)crefuse_2,
(unsigned int)cfail_3);
v6 = v12;
v7 = 1;
cfail_3 = 0;
crefuse_2 = 0;
callow_1 = 0;
timer = v12;
}
call_0 = v7;
if ( !manage_switch || *(unsigned __int16 *)(v3 + 14) == rflsl[768] )
{
v10 = access_query(v3, &v11, v6);
if ( v11 == 1 )
{
if ( v10 == 1 )
++callow_1;
else
++crefuse_2;
}
else
{
++cfail_3;
}
send_net2(v3, v11, v10);
}
else
{
send_net6(v3);
++callow_1;
}
}
break;
}
if ( !_memuse_rate_switch
|| __ROR8__(0xCCCCCCCCCCCCCCCDLL * (v12 - v0) + 0x1999999999999998LL, 1) > 0x1999999999999998uLL
|| v0 == v12 )
{
break;
}
v5 = fork();
if ( v5 < 0 )
{
run_msg("In fls_main memuse_rate: fork error");
goto LABEL_2;
}
if ( !v5 )
{
memuse_rate();
exit(0);
}
result = (unsigned int)fls_switch;
v0 = v12;
if ( !fls_switch )
return result;
}
}
}

original_code:
void fls_main(void)
{
 void * ptr;
 uint16_t cmd;
 time_t now, last_mrout, last_wlog;
 static int call = 0, callow = 0, crefuse = 0, cfail = 0;
 time(&last_wlog);
 last_mrout = time(((void *)0));
 extern int __memuse_rate_switch;
 while (fls_switch)
 {
  time(&now);
  if ((ptr = read_net()) == ((void *)0))
   continue;
  cmd = ntohs(*(uint16_t *)(((char *)ptr + 4)));
  switch (cmd)
  {
   case 1:
   {
    ntohpt1(ptr);
    if (!netpt1_check(ptr))
     break;
    if (now != last_wlog)
    {
     addto_log(2, "%5d  %5d  %5d  %5d", call, callow, crefuse, cfail);
     call = callow = crefuse = cfail = 0;
     last_wlog = now;
    }
    ++call;
    if (manage_switch && ((netpt1 *)ptr)->head.fls_num != rflsl.len)
    {
     send_net6(ptr);
     ++callow;
     break;
    }
    uint8_t stat, result;
    result = access_query(ptr, &stat, now);
    if (stat == 1)
    {
     if (result == 1)
     {
      ++callow;
     }
     else
     {
      ++crefuse;
     }
    }
    else
    {
     ++cfail;
    }
    send_net2(ptr, stat, result);
    break;
   }
   case 3:
   {
    ntohpt3(ptr);
    if (!netpt3_check(ptr))
     break;
    uint8_t stat;
    recunit *unit;
    if ((unit = hash_search(((netpt3 *)ptr)->body.sid, ((netpt3 *)ptr)->body.uid, now)) == ((void *)0))
    {
     stat = 0;
    }
    else
    {
     stat = 1;
    }
    send_net4(ptr, stat, unit);
    break;
   }
   case 7:
   {
    if (!manage_switch)
     break;
    ntohpt7(ptr);
    if (!netpt7_check(ptr))
     break;
    uint8_t stat = ((netpt7 *)ptr)->body.stat;
    switch (stat)
    {
     case 1:
     {
      if (addto_rflsl(&(((netpt7 *)ptr)->body.fls)) == 0)
      {
       run_msg("fls server is too much!");
      }
      send_net8(ptr, 4, 2);
      addto_log(1, "fls id: %d started.", ((netpt7 *)ptr)->body.fls.id);
      break;
     }
     case 2:
     {
      remove_rflsl(&(((netpt7 *)ptr)->body.fls));
      send_net8(ptr, 4, 3);
      addto_log(1, "fls id: %d closed.", ((netpt7 *)ptr)->body.fls.id);
      break;
     }
     case 3:
     {
      remove_rflsl(&(((netpt7 *)ptr)->body.fls));
      send_net8(ptr, 4, 3);
      addto_log(1, "fls id: %d disconnected!", ((netpt7 *)ptr)->body.fls.id);
      break;
     }
     default:
     {
      break;
     }
    }
   }
   default:
   {
    break;
   }
  }
  if (__memuse_rate_switch && (((now - last_mrout) % 10) == 0) && last_mrout != now)
  {
   pid_t pid;
   if ((pid = fork()) < 0)
   {
    run_msg("In fls_main memuse_rate: fork error");
   }
   else if (pid == 0)
   {
    memuse_rate();
    exit(0);
   }
   else
   {
    last_mrout = now;
   }
  }
 }
}

canonical_original_code:
void fls_main()
{
 void *ptr;
 unsigned short cmd;
 long now; long last_mrout; long last_wlog;
 static int call = 0; static int callow = 0; static int crefuse = 0; static int cfail = 0;
 time(&last_wlog);
 last_mrout = time(((void *)0));
 extern int __memuse_rate_switch;
 while (fls_switch)
 {
  time(&now);
  if ((ptr = read_net()) == ((void *)0))
   continue;
  cmd = ntohs(*(unsigned short *)(((char *)ptr + 4)));
  switch (cmd)
  {
   case 1:
   {
    ntohpt1(ptr);
    if (!netpt1_check(ptr))
     break;
    if (now != last_wlog)
    {
     addto_log(2, "%5d  %5d  %5d  %5d", call, callow, crefuse, cfail);
     call = callow = crefuse = cfail = 0;
     last_wlog = now;
    }
    ++call;
    if (manage_switch && ((struct netpt1 *)ptr)->head.fls_num != rflsl.len)
    {
     send_net6(ptr);
     ++callow;
     break;
    }
    unsigned char stat; unsigned char result;
    result = access_query(ptr, &stat, now);
    if (stat == 1)
    {
     if (result == 1)
     {
      ++callow;
     }
     else
     {
      ++crefuse;
     }
    }
    else
    {
     ++cfail;
    }
    send_net2(ptr, stat, result);
    break;
   }
   case 3:
   {
    ntohpt3(ptr);
    if (!netpt3_check(ptr))
     break;
    unsigned char stat;
    struct recunit *unit;
    if ((unit = hash_search(((struct netpt3 *)ptr)->body.sid, ((struct netpt3 *)ptr)->body.uid, now)) == ((void *)0))
    {
     stat = 0;
    }
    else
    {
     stat = 1;
    }
    send_net4(ptr, stat, unit);
    break;
   }
   case 7:
   {
    if (!manage_switch)
     break;
    ntohpt7(ptr);
    if (!netpt7_check(ptr))
     break;
    unsigned char stat = ((netpt7 *)ptr)->body.stat;
    switch (stat)
    {
     case 1:
     {
      if (addto_rflsl(&(((struct netpt7 *)ptr)->body.fls)) == 0)
      {
       run_msg("fls server is too much!");
      }
      send_net8(ptr, 4, 2);
      addto_log(1, "fls id: %d started.", ((struct netpt7 *)ptr)->body.fls.id);
      break;
     }
     case 2:
     {
      remove_rflsl(&(((struct netpt7 *)ptr)->body.fls));
      send_net8(ptr, 4, 3);
      addto_log(1, "fls id: %d closed.", ((struct netpt7 *)ptr)->body.fls.id);
      break;
     }
     case 3:
     {
      remove_rflsl(&(((struct netpt7 *)ptr)->body.fls));
      send_net8(ptr, 4, 3);
      addto_log(1, "fls id: %d disconnected!", ((struct netpt7 *)ptr)->body.fls.id);
      break;
     }
     default:
     {
      break;
     }
    }
   }
   default:
   {
    break;
   }
  }
  if (__memuse_rate_switch && (((now - last_mrout) % 10) == 0) && last_mrout != now)
  {
   int pid;
   if ((pid = fork()) < 0)
   {
    run_msg("In fls_main memuse_rate: fork error");
   }
   else if (pid == 0)
   {
    memuse_rate();
    exit(0);
   }
   else
   {
    last_mrout = now;
   }
  }
 }
}

variable_types:
ptr
void *

variable_types:
cmd
unsigned short

variable_types: now long

variable_types: call int

variable_types: callow int

variable_types: crefuse int

variable_types: cfail int

variable_types:
stat
unsigned char

variable_types:
result
unsigned char

variable_types: struct recunit { unsigned char sign; unsigned char version; unsigned short sid; unsigned int uid; long timel1; long timel2; unsigned int counterl1; unsigned int counterl2; unsigned int allowedl2; } *

variable_types: pid int

user_defined_types: struct pbody7 { unsigned char stat; char zero; unsigned short sid; struct addr fls; }

user_defined_types: struct addr { unsigned char id; unsigned char zero; unsigned short port; unsigned int ip; }


prepareMesh

repo: halcy/rasterizer

decompiled_code:
unsigned __int64 __fastcall prepareMesh(__int64 a1)
{
__int64 v1; // rax
int v2; // ebx
unsigned __int64 result; // rax
_DWORD *v4; // rdx

v1 = *(int *)(a1 + 8);
*(_DWORD *)(a1 + 12) = 0;
v2 = v1;
result = (unsigned __int64)malloc(112 * v1);
*(_QWORD *)(a1 + 16) = result;
if ( v2 > 0 )
{
v4 = (_DWORD *)(result + 108);
LODWORD(result) = 0;
do
{
*v4 = result;
result = (unsigned int)(result + 1);
v4 += 28;
}
while ( v2 != (_DWORD)result );
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(__int64 a1)
{
__int64 v1; // rax
int v2; // ebx
unsigned __int64 result; // rax
_DWORD *v4; // rdx

v1 = *(int *)(a1 + 8);
*(_DWORD *)(a1 + 12) = 0;
v2 = v1;
result = (unsigned __int64)malloc(112 * v1);
*(_QWORD *)(a1 + 16) = result;
if ( v2 > 0 )
{
v4 = (_DWORD *)(result + 108);
LODWORD(result) = 0;
do
{
*v4 = result;
result = (unsigned int)(result + 1);
v4 += 28;
}
while ( v2 != (_DWORD)result );
}
return result;
}

original_code:
void prepareMesh(model* newModel) {
 newModel->curTriangle = 0;
 newModel->triangles = (triangle*)malloc(sizeof(triangle) * newModel->triangleCount);
 for (int i = 0; i < newModel->triangleCount; i++) {
  newModel->triangles[i].ID = i;
 }
}

canonical_original_code:
void prepareMesh(struct model *newModel) {
 newModel->curTriangle = 0;
 newModel->triangles = (struct triangle *)malloc(sizeof(triangle) * newModel->triangleCount);
 for (int i = 0; i < newModel->triangleCount; i++) {
  newModel->triangles[i].ID = i;
 }
}

variable_types: struct model { float *mesh; int triangleCount; int curTriangle; struct triangle { float vertices[3][3]; float normals[3][3]; float colors[3][3]; int ID; } *triangles; } *

variable_types: i int

return_type: void

user_defined_types: struct model { float *mesh; int triangleCount; int curTriangle; struct triangle *triangles; }


freeModel

decompiled_code:
void __fastcall freeModel(void **a1)
{
free(*a1);
free(a1[2]);
}

canonical_decompiled_code:
void __fastcall func2(void **a1)
{
free(*a1);
free(a1[2]);
}

original_code:
void freeModel(model* m) {
 free(m->mesh);
 free(m->triangles);
}

canonical_original_code:
void freeModel(struct model *m) {
 free(m->mesh);
 free(m->triangles);
}

user_defined_types: struct triangle { float vertices[3][3]; float normals[3][3]; float colors[3][3]; int ID; }


modelTrianglesLeft

decompiled_code:
_BOOL8 __fastcall modelTrianglesLeft(__int64 a1)
{
return *(_DWORD *)(a1 + 12) != *(_DWORD *)(a1 + 8);
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(__int64 a1)
{
return *(_DWORD *)(a1 + 12) != *(_DWORD *)(a1 + 8);
}

original_code:
int modelTrianglesLeft(model* m) {
 return(m->curTriangle != m->triangleCount);
}

canonical_original_code:
int modelTrianglesLeft(struct model *m) {
 return(m->curTriangle != m->triangleCount);
}

return_type: int


modelNextTriangle

original_code:
triangle* modelNextTriangle(model* m) {
 return &m->triangles[m->curTriangle++];
}

canonical_original_code:
struct triangle *modelNextTriangle(struct model *m) {
 return &m->triangles[m->curTriangle++];
}

variable_types: struct model { float *mesh; int triangleCount; int curTriangle; struct triangle *triangles; } *

return_type: struct triangle { float vertices[3][3]; float normals[3][3]; float colors[3][3]; int ID; } *


modelTriangleCount

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

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

original_code:
int modelTriangleCount(model* m) {
 return m->triangleCount;
}

canonical_original_code:
int modelTriangleCount(struct model *m) {
 return m->triangleCount;
}


applyTransforms

original_code:
void applyTransforms(model* m, matrix mvMatrixO, matrix pMatrixO) {
 vec3 triVec;
 vec3 transVec;
 vec3 projVec;
 for(int i = 0; i < m->triangleCount; i++) {
  for(int j = 0; j < 6; j++) {
   triVec = makeVec3(
    m->mesh[m->triangles[i].ID * 18 + j*3],
    m->mesh[m->triangles[i].ID * 18 + j*3 + 1],
    m->mesh[m->triangles[i].ID * 18 + j*3 + 2]
   );
   if (j % 2 == 0) {
    matrixApply(&transVec, mvMatrixO, triVec);
    matrixApplyPerspective(&projVec, pMatrixO, transVec);
    m->triangles[i].vertices[j/2][0] = projVec.x;
    m->triangles[i].vertices[j/2][1] = projVec.y;
    m->triangles[i].vertices[j/2][2] = projVec.z;
   }
   else {
    matrixApplyNormal(&transVec, mvMatrixO, triVec);
    m->triangles[i].normals[j/2][0] = transVec.x;
    m->triangles[i].normals[j/2][1] = transVec.y;
    m->triangles[i].normals[j/2][2] = transVec.z;
   }
  }
 }
 m->curTriangle = 0;
}

canonical_original_code:
void applyTransforms(struct model *m, struct matrix mvMatrixO, struct matrix pMatrixO) {
 struct vec3 triVec;
 struct vec3 transVec;
 struct vec3 projVec;
 for(int i = 0; i < m->triangleCount; i++) {
  for(int j = 0; j < 6; j++) {
   triVec = makeVec3(
    m->mesh[m->triangles[i].ID * 18 + j*3],
    m->mesh[m->triangles[i].ID * 18 + j*3 + 1],
    m->mesh[m->triangles[i].ID * 18 + j*3 + 2]
   );
   if (j % 2 == 0) {
    matrixApply(&transVec, mvMatrixO, triVec);
    matrixApplyPerspective(&projVec, pMatrixO, transVec);
    m->triangles[i].vertices[j/2][0] = projVec.x;
    m->triangles[i].vertices[j/2][1] = projVec.y;
    m->triangles[i].vertices[j/2][2] = projVec.z;
   }
   else {
    matrixApplyNormal(&transVec, mvMatrixO, triVec);
    m->triangles[i].normals[j/2][0] = transVec.x;
    m->triangles[i].normals[j/2][1] = transVec.y;
    m->triangles[i].normals[j/2][2] = transVec.z;
   }
  }
 }
 m->curTriangle = 0;
}

variable_types:
mvMatrixO
struct matrix { float v[16]; }

variable_types:
pMatrixO
struct matrix

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

variable_types: j int


shade

original_code:
void shade(model* m, float lx, float ly, float lz) {
 for(int i = 0; i != m->triangleCount; i++) {
  for(int j = 0; j < 3; j++) {
   for(int c = 0; c < 3; c++) {
    float Lx = lx - m->mesh[m->triangles[i].ID * 18 + j*6];
    float Ly = ly - m->mesh[m->triangles[i].ID * 18 + j*6 + 1];
    float Lz = lz - m->mesh[m->triangles[i].ID * 18 + j*6 + 2];
    float lenL = sqrt(Lx*Lx + Ly*Ly + Lz*Lz);
    Lx /= lenL;
    Ly /= lenL;
    Lz /= lenL;
    float NdotL =
     m->triangles[i].normals[j][0] * Lx +
     m->triangles[i].normals[j][1] * Ly +
     m->triangles[i].normals[j][2] * Lz;
    if (NdotL < 0.0f) {
     NdotL = 0.0f;
    }
    m->triangles[i].colors[j][c] = NdotL;
   }
  }
 }
}

canonical_original_code:
void shade(struct model *m, float lx, float ly, float lz) {
 for(int i = 0; i != m->triangleCount; i++) {
  for(int j = 0; j < 3; j++) {
   for(int c = 0; c < 3; c++) {
    float Lx = lx - m->mesh[m->triangles[i].ID * 18 + j*6];
    float Ly = ly - m->mesh[m->triangles[i].ID * 18 + j*6 + 1];
    float Lz = lz - m->mesh[m->triangles[i].ID * 18 + j*6 + 2];
    float lenL = sqrt(Lx*Lx + Ly*Ly + Lz*Lz);
    Lx /= lenL;
    Ly /= lenL;
    Lz /= lenL;
    float NdotL = m->triangles[i].normals[j][0] * Lx +
     m->triangles[i].normals[j][1] * Ly +
     m->triangles[i].normals[j][2] * Lz;
    if (NdotL < 0.0f) {
     NdotL = 0.0f;
    }
    m->triangles[i].colors[j][c] = NdotL;
   }
  }
 }
}

variable_types: lx float

variable_types: ly float

variable_types: lz float

variable_types: c int

variable_types: Lx float

variable_types: Ly float

variable_types: Lz float

variable_types: lenL float

variable_types: NdotL float


original_code:
void bmp_init( const char* file_name, int x_size, int y_size ) {
 bmp_header file_head;
 file_head.file_type [ 0 ] = 'B';
 file_head.file_type [ 1 ] = 'M';
 file_head.file_size = x_size * y_size * 3 + 54;
 file_head.reserved_1 = 0;
 file_head.reserved_2 = 0;
 file_head.pixel_offset = 54;
 file_head.header_size = 40;
 file_head.x_size = x_size;
 file_head.y_size = y_size;
 file_head.planes = 1;
 file_head.bpp = 24;
 file_head.compression = 0;
 file_head.image_size = 0;
 file_head.x_ppm = 0;
 file_head.y_ppm = 0;
 file_head.used_colors = 0;
 file_head.important_colors = 0;
 bmp_file = fopen( file_name, "w" );
 fwrite( (char*)(&file_head), 1, sizeof(file_head), bmp_file );
 line_max = x_size * 3;
 line_pos = 0;
}

canonical_original_code:
void bmp_init(char *file_name, int x_size, int y_size) {
 struct bmp_header file_head;
 file_head.file_type [ 0 ] = 'B';
 file_head.file_type [ 1 ] = 'M';
 file_head.file_size = x_size * y_size * 3 + 54;
 file_head.reserved_1 = 0;
 file_head.reserved_2 = 0;
 file_head.pixel_offset = 54;
 file_head.header_size = 40;
 file_head.x_size = x_size;
 file_head.y_size = y_size;
 file_head.planes = 1;
 file_head.bpp = 24;
 file_head.compression = 0;
 file_head.image_size = 0;
 file_head.x_ppm = 0;
 file_head.y_ppm = 0;
 file_head.used_colors = 0;
 file_head.important_colors = 0;
 bmp_file = fopen( file_name, "w" );
 fwrite( (char *)(&file_head), 1, sizeof(file_head), bmp_file );
 line_max = x_size * 3;
 line_pos = 0;
}

variable_types: struct bmp_header { unsigned char file_type[2]; unsigned int file_size; unsigned short reserved_1; unsigned short reserved_2; unsigned int pixel_offset; unsigned int header_size; unsigned int x_size; unsigned int y_size; unsigned short planes; unsigned short bpp; unsigned int compression; unsigned int image_size; unsigned int x_ppm; unsigned int y_ppm; unsigned int used_colors; unsigned int important_colors; }


decompiled_code:
__int64 __fastcall bmp_pixel(char a1, char a2, char a3)
{
__int64 result; // rax
char v4; // [rsp+Dh] [rbp-Bh] BYREF
char v5; // [rsp+Eh] [rbp-Ah] BYREF
char ptr[9]; // [rsp+Fh] [rbp-9h] BYREF

v4 = a1;
v5 = a2;
ptr[0] = a3;
fwrite(ptr, 1uLL, 1uLL, bmp_file);
fwrite(&v5, 1uLL, 1uLL, bmp_file);
fwrite(&v4, 1uLL, 1uLL, bmp_file);
line_pos += 3;
result = (unsigned int)line_pos;
if ( line_pos == line_max )
{
if ( line_pos < line_pos + line_pos % 4 )
{
do
{
fwrite(ptr, 1uLL, 1uLL, bmp_file);
++line_pos;
result = (unsigned int)(line_max + line_max % 4);
}
while ( line_pos < (int)result );
}
line_pos = 0;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char a1, char a2, char a3)
{
__int64 result; // rax
char v4; // [rsp+Dh] [rbp-Bh] BYREF
char v5; // [rsp+Eh] [rbp-Ah] BYREF
char ptr[9]; // [rsp+Fh] [rbp-9h] BYREF

v4 = a1;
v5 = a2;
ptr[0] = a3;
fwrite(ptr, 1uLL, 1uLL, bmp_file);
fwrite(&v5, 1uLL, 1uLL, bmp_file);
fwrite(&v4, 1uLL, 1uLL, bmp_file);
line_pos += 3;
result = (unsigned int)line_pos;
if ( line_pos == line_max )
{
if ( line_pos < line_pos + line_pos % 4 )
{
do
{
fwrite(ptr, 1uLL, 1uLL, bmp_file);
++line_pos;
result = (unsigned int)(line_max + line_max % 4);
}
while ( line_pos < (int)result );
}
line_pos = 0;
}
return result;
}

original_code:
void bmp_pixel(int r, int g, int b) {
 char tmp_r = (char)r;
 char tmp_g = (char)g;
 char tmp_b = (char)b;
 fwrite( &tmp_b, 1, 1, bmp_file );
 fwrite( &tmp_g, 1, 1, bmp_file );
 fwrite( &tmp_r, 1, 1, bmp_file );
 line_pos+=3;
 if( line_pos == line_max ) {
  while( line_pos < line_max + line_max % 4 ) {
   fwrite( &tmp_b, 1, 1, bmp_file );
   line_pos++;
  }
  line_pos = 0;
 }
}

variable_types: r int

variable_types: g int

variable_types: b int


decompiled_code:
int bmp_close()
{
fflush(bmp_file);
return fclose(bmp_file);
}

canonical_decompiled_code:
int func2()
{
fflush(bmp_file);
return fclose(bmp_file);
}

original_code:
void bmp_close() {
 fflush( bmp_file );
 fclose( bmp_file );
}


setPixel

decompiled_code:
void __fastcall setPixel(int a1, int a2, double a3, double a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, int a9, int a10, __int64 a11)
{
double *v11; // rdi

v11 = (double *)(a11 + 16LL * (a9 * a2 + a1));
*v11 = a3;
v11[1] = a4;
}

canonical_decompiled_code:
void __fastcall func5(int a1, int a2, double a3, double a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, int a9, int a10, __int64 a11)
{
double *v11; // rdi

v11 = (double *)(a11 + 16LL * (a9 * a2 + a1));
*v11 = a3;
v11[1] = a4;
}

original_code:
inline void setPixel(buffer b, int x, int y, colour c) {
 b.data[x+b.width*y] = c;
}

canonical_original_code:
inline void setPixel(struct buffer b, int x, int y, struct colour c) {
 b.data[x+b.width*y] = c;
}

variable_types: struct buffer { int width; int firstLine; int size; struct colour { float r; float b; float g; float a; } *data; }

variable_types: x int

variable_types: y int

variable_types:
c
struct colour

user_defined_types: struct buffer { int width; int firstLine; int size; struct colour *data; }


expose

original_code:
void expose(buffer b, float factor, float gamma) {
 for( int x = 0; x < b.width; x++ ) {
  for( int y = b.firstLine; y < b.size; y++ ) {
   scale( &b.data[x+b.width*y], factor );
   applyGamma( &b.data[x+b.width*y], 1.0f / gamma);
   clip( &b.data[x+b.width*y] );
  }
 }
}

canonical_original_code:
void expose(struct buffer b, float factor, float gamma) {
 for( int x = 0; x < b.width; x++ ) {
  for( int y = b.firstLine; y < b.size; y++ ) {
   scale( &b.data[x+b.width*y], factor );
   applyGamma( &b.data[x+b.width*y], 1.0f / gamma);
   clip( &b.data[x+b.width*y] );
  }
 }
}

variable_types: factor float

variable_types: gamma float

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


clear

original_code:
void clear(buffer b) {
 for( int x = 0; x < b.width; x++ ) {
  for( int y = b.firstLine; y < b.size; y++ ) {
   b.data[x+b.width*y] = (makeColour( 0.0, 0.0, 0.0 ));
  }
 }
}

canonical_original_code:
void clear(struct buffer b) {
 for( int x = 0; x < b.width; x++ ) {
  for( int y = b.firstLine; y < b.size; y++ ) {
   b.data[x+b.width*y] = (makeColour( 0.0, 0.0, 0.0 ));
  }
 }
}


writeToImage

decompiled_code:
int __fastcall writeToImage(const char *a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, int a8, __int64 a9)
{
int v9; // ebp
int v10; // er12
double *v11; // r15
double v12; // xmm1_8
double v13; // xmm0_8
double v15; // [rsp+14h] [rbp-44h]

bmp_init(a1, a7, a8);
v9 = HIDWORD(a7);
if ( SHIDWORD(a7) < a8 )
{
v10 = a7 * HIDWORD(a7);
do
{
if ( (int)a7 > 0 )
{
v11 = (double *)(a9 + 16LL * v10);
do
{
v12 = v11[1];
v13 = *v11;
v11 += 2;
v15 = getRGB(v13, v12);
bmp_pixel((int)*(float *)&v15, (int)*((float *)&v15 + 1), (int)*(float *)&v12);
}
while ( v11 != (double *)(a9 + 16 * (v10 + (unsigned __int64)(unsigned int)(a7 - 1)) + 16) );
}
++v9;
v10 += a7;
}
while ( v9 != a8 );
}
return bmp_close();
}

original_code:
void writeToImage(buffer b, const char* filename) {
 bmp_init( filename, b.width, b.size );
 for( int y = b.firstLine; y < b.size; y++ ) {
  for( int x = 0; x < b.width; x++ ) {
   vec3 c = getRGB( b.data[x+b.width*y] );
   bmp_pixel( (int)c.x, (int)c.y, (int)c.z );
  }
 }
 bmp_close();
}

canonical_original_code:
void writeToImage(struct buffer b, char *filename) {
 bmp_init( filename, b.width, b.size );
 for( int y = b.firstLine; y < b.size; y++ ) {
  for( int x = 0; x < b.width; x++ ) {
   struct vec3 c = getRGB( b.data[x+b.width*y] );
   bmp_pixel( (int)c.x, (int)c.y, (int)c.z );
  }
 }
 bmp_close();
}

variable_types:
filename
char *

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


freeBuffer

decompiled_code:
void __fastcall freeBuffer(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, void *ptr)
{
free(ptr);
}

canonical_decompiled_code:
void __fastcall func9(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, void *ptr)
{
free(ptr);
}

original_code:
void freeBuffer(buffer b) {
 free(b.data);
}

canonical_original_code:
void freeBuffer(struct buffer b) {
 free(b.data);
}


rasterize

decompiled_code:
__int64 __fastcall rasterize(__int64 a1, int *a2, __int64 a3)
{
int v4; // er13
__int64 result; // rax
float *v6; // rax
float v7; // xmm1_4
float v8; // xmm0_4
float *v9; // rcx
float *v10; // rsi
float v11; // xmm8_4
float *i; // rdx
float *v13; // rsi
int v14; // edi
float v15; // xmm3_4
__int64 v16; // rdx
float v17; // xmm3_4
float v18; // xmm2_4
float v19; // xmm0_4
float v20; // xmm1_4
float v21; // xmm0_4
unsigned int j; // esi
unsigned int v23; // edi
unsigned int v24; // edx
float v25; // xmm10_4
float v26; // xmm9_4
float v27; // xmm7_4
double v28; // xmm0_8
double v29; // xmm2_8
double v30; // xmm6_8
double v31; // xmm5_8
double v32; // xmm1_8
double v33; // xmm6_8
double v34; // xmm0_8
double v35; // xmm1_8
int v36; // er8
int v37; // er14
int v38; // edx
int v39; // er9
__int64 v40; // rcx
int v41; // er15
int v42; // er12
int v43; // er9
float *v44; // r13
int v45; // eax
int v46; // ebp
int v47; // er12
float v48; // xmm4_4
int v49; // er14
float v50; // xmm3_4
float v51; // xmm5_4
float v52; // xmm1_4
float v53; // xmm0_4
float v54; // xmm2_4
float v55; // xmm1_4
float v56; // xmm2_4
float v57; // xmm1_4
float v58; // xmm0_4
float *v59; // rdx
float v60; // xmm12_4
float v61; // [rsp+0h] [rbp-E8h]
int v62; // [rsp+4h] [rbp-E4h]
int v63; // [rsp+14h] [rbp-D4h]
int v64; // [rsp+18h] [rbp-D0h]
float v65; // [rsp+1Ch] [rbp-CCh]
__int64 v66; // [rsp+20h] [rbp-C8h]
float v67; // [rsp+30h] [rbp-B8h]
float v68; // [rsp+34h] [rbp-B4h]
float v69; // [rsp+40h] [rbp-A8h]
float v70; // [rsp+44h] [rbp-A4h]
int v71; // [rsp+4Ch] [rbp-9Ch]
__int64 v72; // [rsp+50h] [rbp-98h]
float v74; // [rsp+60h] [rbp-88h] BYREF
float v75; // [rsp+64h] [rbp-84h]
float v76; // [rsp+68h] [rbp-80h] BYREF
float v77; // [rsp+6Ch] [rbp-7Ch]
float v78; // [rsp+70h] [rbp-78h]
float v79; // [rsp+74h] [rbp-74h]
float v80; // [rsp+78h] [rbp-70h]
float v81; // [rsp+7Ch] [rbp-6Ch]
float v82; // [rsp+80h] [rbp-68h]
float v83; // [rsp+84h] [rbp-64h]
float v84; // [rsp+88h] [rbp-60h]
float v85; // [rsp+8Ch] [rbp-5Ch]
float v86; // [rsp+90h] [rbp-58h]
float v87; // [rsp+94h] [rbp-54h]
float v88; // [rsp+98h] [rbp-50h]

v4 = *a2;
v71 = a2[2];
v70 = (float)(*a2 / 2);
while ( 1 )
{
result = modelTrianglesLeft(a1);
if ( !(_DWORD)result )
break;
v6 = (float *)modelNextTriangle(a1);
v7 = *v6;
v8 = v6[1];
if ( (float)((float)((float)(v6[3] - v7) * (float)(v6[7] - v8)) + (float)((float)(v6[6] - v7) * (float)(v8 - v6[4]))) >= 0.0 )
{
v9 = &v74;
v10 = v6 + 3;
v11 = *(float *)&LC1;
for ( i = &v74; ; ++i )
{
*i = (float)(v7 + 1.0) * v70;
i[3] = (float)(v8 + 1.0) * (float)(v71 / 2);
if ( i == &v76 )
break;
v7 = *v10;
v8 = v10[1];
v10 += 3;
}
v13 = &v74;
v14 = 0;
do
{
v15 = v13[3];
++v13;
v16 = ++v14 % 3u;
v17 = v15 - *(&v77 + v16);
v18 = *(&v74 + v16) - *(v13 - 1);
v19 = (float)(v18 * v18) + (float)(v17 * v17);
v20 = 1.0 / fsqrt(v19);
v21 = (float)((float)((float)(v19 * v20) * v20) + -3.0) * (float)(v20 * -0.5);
v13[5] = v17 * v21;
v13[8] = v21 * v18;
}
while ( v14 != 3 );
for ( j = 2; j != 5; ++j )
{
++v9;
v23 = 3 * (j / 3);
v24 = j;
v9[11] = (float)((float)(*(&v74 + (int)(v24 - v23)) - *(v9 - 1)) * v9[5])
+ (float)((float)(*(&v77 + (int)(v24 - v23)) - v9[2]) * v9[8]);
}
v25 = v76;
v26 = v75;
v27 = v74;
v28 = fmin(fmin(v76, v75), v74);
v29 = (double)(int)v28;
if ( v29 > v28 )
v29 = (double)((int)v28 - 1);
v61 = v79;
v30 = fmin(fmin(v79, v78), v77);
v31 = (double)(int)v30;
if ( v31 > v30 )
v31 = (double)((int)v30 - 1);
v32 = fmax(fmax(v76, v75), v74);
v33 = (double)(int)v32;
if ( v32 > v33 )
v33 = (double)((int)v32 + 1);
v34 = fmax(fmax(v79, v78), v77);
v35 = (double)(int)v34;
if ( v34 > v35 )
v35 = (double)((int)v34 + 1);
v36 = (int)fmax(v29, 0.0);
v37 = (int)fmax(v31, 0.0);
v38 = (int)fmin(v33, (double)v4);
v39 = (int)fmin(v35, (double)v71);
if ( v36 <= v38 && v37 <= v39 )
{
v68 = v78;
v69 = v77;
if ( v37 < v39 )
{
v40 = a3;
v62 = v39;
v41 = v37;
v42 = v4 * v37;
v72 = a1;
v43 = v4;
v44 = v6;
v45 = v36;
v46 = v42;
v47 = v38;
do
{
if ( v45 < v47 )
{
v48 = v80;
v49 = v45;
v50 = (float)((float)v41 - v69) * v83;
v51 = (float)v41 - v61;
do
{
v52 = (float)v49;
v53 = (float)((float)((float)v49 - v27) * v48) + v50;
if ( v53 >= 0.0 )
{
v54 = (float)((float)(v52 - v26) * v81) + (float)(v84 * (float)((float)v41 - v68));
if ( v54 >= 0.0 )
{
v55 = (float)((float)(v52 - v25) * v82) + (float)(v85 * v51);
if ( v55 >= 0.0 )
{
v56 = v54 / v87;
v57 = v55 / v88;
v58 = v53 / v86;
v59 = (float *)(v40 + 4LL * (v49 + v46));
v60 = (float)((float)(v11 / v44[8]) * v58)
+ (float)((float)((float)(v11 / v44[2]) * v56) + (float)((float)(v11 / v44[5]) * v57));
if ( v60 > *v59 )
{
*v59 = v60;
v66 = v40;
v64 = v43;
v63 = v45;
v67 = v51;
v65 = v48;
makeColour(
(float)(v58 * v44[24]) + (float)((float)(v56 * v44[18]) + (float)(v57 * v44[21])),
(float)((float)(v44[22] * v57) + (float)(v44[19] * v56)) + (float)(v44[25] * v58),
(float)((float)(v44[20] * v56) + (float)(v44[23] * v57)) + (float)(v44[26] * v58));
setPixel((unsigned int)v49, (unsigned int)v41);
v11 = *(float *)&LC1;
v51 = v67;
v40 = v66;
v48 = v65;
v43 = v64;
v45 = v63;
}
}
}
}
++v49;
}
while ( v47 != v49 );
}
++v41;
v46 += v43;
}
while ( v62 != v41 );
a1 = v72;
v4 = v43;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int *a2, __int64 a3)
{
int v4; // er13
__int64 result; // rax
float *v6; // rax
float v7; // xmm1_4
float v8; // xmm0_4
float *v9; // rcx
float *v10; // rsi
float v11; // xmm8_4
float *i; // rdx
float *v13; // rsi
int v14; // edi
float v15; // xmm3_4
__int64 v16; // rdx
float v17; // xmm3_4
float v18; // xmm2_4
float v19; // xmm0_4
float v20; // xmm1_4
float v21; // xmm0_4
unsigned int j; // esi
unsigned int v23; // edi
unsigned int v24; // edx
float v25; // xmm10_4
float v26; // xmm9_4
float v27; // xmm7_4
double v28; // xmm0_8
double v29; // xmm2_8
double v30; // xmm6_8
double v31; // xmm5_8
double v32; // xmm1_8
double v33; // xmm6_8
double v34; // xmm0_8
double v35; // xmm1_8
int v36; // er8
int v37; // er14
int v38; // edx
int v39; // er9
__int64 v40; // rcx
int v41; // er15
int v42; // er12
int v43; // er9
float *v44; // r13
int v45; // eax
int v46; // ebp
int v47; // er12
float v48; // xmm4_4
int v49; // er14
float v50; // xmm3_4
float v51; // xmm5_4
float v52; // xmm1_4
float v53; // xmm0_4
float v54; // xmm2_4
float v55; // xmm1_4
float v56; // xmm2_4
float v57; // xmm1_4
float v58; // xmm0_4
float *v59; // rdx
float v60; // xmm12_4
float v61; // [rsp+0h] [rbp-E8h]
int v62; // [rsp+4h] [rbp-E4h]
int v63; // [rsp+14h] [rbp-D4h]
int v64; // [rsp+18h] [rbp-D0h]
float v65; // [rsp+1Ch] [rbp-CCh]
__int64 v66; // [rsp+20h] [rbp-C8h]
float v67; // [rsp+30h] [rbp-B8h]
float v68; // [rsp+34h] [rbp-B4h]
float v69; // [rsp+40h] [rbp-A8h]
float v70; // [rsp+44h] [rbp-A4h]
int v71; // [rsp+4Ch] [rbp-9Ch]
__int64 v72; // [rsp+50h] [rbp-98h]
float v74; // [rsp+60h] [rbp-88h] BYREF
float v75; // [rsp+64h] [rbp-84h]
float v76; // [rsp+68h] [rbp-80h] BYREF
float v77; // [rsp+6Ch] [rbp-7Ch]
float v78; // [rsp+70h] [rbp-78h]
float v79; // [rsp+74h] [rbp-74h]
float v80; // [rsp+78h] [rbp-70h]
float v81; // [rsp+7Ch] [rbp-6Ch]
float v82; // [rsp+80h] [rbp-68h]
float v83; // [rsp+84h] [rbp-64h]
float v84; // [rsp+88h] [rbp-60h]
float v85; // [rsp+8Ch] [rbp-5Ch]
float v86; // [rsp+90h] [rbp-58h]
float v87; // [rsp+94h] [rbp-54h]
float v88; // [rsp+98h] [rbp-50h]

v4 = *a2;
v71 = a2[2];
v70 = (float)(*a2 / 2);
while ( 1 )
{
result = modelTrianglesLeft(a1);
if ( !(_DWORD)result )
break;
v6 = (float *)modelNextTriangle(a1);
v7 = *v6;
v8 = v6[1];
if ( (float)((float)((float)(v6[3] - v7) * (float)(v6[7] - v8)) + (float)((float)(v6[6] - v7) * (float)(v8 - v6[4]))) >= 0.0 )
{
v9 = &v74;
v10 = v6 + 3;
v11 = *(float *)&LC1;
for ( i = &v74; ; ++i )
{
*i = (float)(v7 + 1.0) * v70;
i[3] = (float)(v8 + 1.0) * (float)(v71 / 2);
if ( i == &v76 )
break;
v7 = *v10;
v8 = v10[1];
v10 += 3;
}
v13 = &v74;
v14 = 0;
do
{
v15 = v13[3];
++v13;
v16 = ++v14 % 3u;
v17 = v15 - *(&v77 + v16);
v18 = *(&v74 + v16) - *(v13 - 1);
v19 = (float)(v18 * v18) + (float)(v17 * v17);
v20 = 1.0 / fsqrt(v19);
v21 = (float)((float)((float)(v19 * v20) * v20) + -3.0) * (float)(v20 * -0.5);
v13[5] = v17 * v21;
v13[8] = v21 * v18;
}
while ( v14 != 3 );
for ( j = 2; j != 5; ++j )
{
++v9;
v23 = 3 * (j / 3);
v24 = j;
v9[11] = (float)((float)(*(&v74 + (int)(v24 - v23)) - *(v9 - 1)) * v9[5])
+ (float)((float)(*(&v77 + (int)(v24 - v23)) - v9[2]) * v9[8]);
}
v25 = v76;
v26 = v75;
v27 = v74;
v28 = fmin(fmin(v76, v75), v74);
v29 = (double)(int)v28;
if ( v29 > v28 )
v29 = (double)((int)v28 - 1);
v61 = v79;
v30 = fmin(fmin(v79, v78), v77);
v31 = (double)(int)v30;
if ( v31 > v30 )
v31 = (double)((int)v30 - 1);
v32 = fmax(fmax(v76, v75), v74);
v33 = (double)(int)v32;
if ( v32 > v33 )
v33 = (double)((int)v32 + 1);
v34 = fmax(fmax(v79, v78), v77);
v35 = (double)(int)v34;
if ( v34 > v35 )
v35 = (double)((int)v34 + 1);
v36 = (int)fmax(v29, 0.0);
v37 = (int)fmax(v31, 0.0);
v38 = (int)fmin(v33, (double)v4);
v39 = (int)fmin(v35, (double)v71);
if ( v36 <= v38 && v37 <= v39 )
{
v68 = v78;
v69 = v77;
if ( v37 < v39 )
{
v40 = a3;
v62 = v39;
v41 = v37;
v42 = v4 * v37;
v72 = a1;
v43 = v4;
v44 = v6;
v45 = v36;
v46 = v42;
v47 = v38;
do
{
if ( v45 < v47 )
{
v48 = v80;
v49 = v45;
v50 = (float)((float)v41 - v69) * v83;
v51 = (float)v41 - v61;
do
{
v52 = (float)v49;
v53 = (float)((float)((float)v49 - v27) * v48) + v50;
if ( v53 >= 0.0 )
{
v54 = (float)((float)(v52 - v26) * v81) + (float)(v84 * (float)((float)v41 - v68));
if ( v54 >= 0.0 )
{
v55 = (float)((float)(v52 - v25) * v82) + (float)(v85 * v51);
if ( v55 >= 0.0 )
{
v56 = v54 / v87;
v57 = v55 / v88;
v58 = v53 / v86;
v59 = (float *)(v40 + 4LL * (v49 + v46));
v60 = (float)((float)(v11 / v44[8]) * v58)
+ (float)((float)((float)(v11 / v44[2]) * v56) + (float)((float)(v11 / v44[5]) * v57));
if ( v60 > *v59 )
{
*v59 = v60;
v66 = v40;
v64 = v43;
v63 = v45;
v67 = v51;
v65 = v48;
makeColour(
(float)(v58 * v44[24]) + (float)((float)(v56 * v44[18]) + (float)(v57 * v44[21])),
(float)((float)(v44[22] * v57) + (float)(v44[19] * v56)) + (float)(v44[25] * v58),
(float)((float)(v44[20] * v56) + (float)(v44[23] * v57)) + (float)(v44[26] * v58));
setPixel((unsigned int)v49, (unsigned int)v41);
v11 = *(float *)&LC1;
v51 = v67;
v40 = v66;
v48 = v65;
v43 = v64;
v45 = v63;
}
}
}
}
++v49;
}
while ( v47 != v49 );
}
++v41;
v46 += v43;
}
while ( v62 != v41 );
a1 = v72;
v4 = v43;
}
}
}
}
return result;
}

original_code:
void rasterize(model* m, buffer* pbuf, float* zbuf) {
 int width = pbuf->width;
 int height = pbuf->size;
 tri t;
 triangle* modelTri;
 float d1;
 float d2;
 float d3;
 float r;
 float g;
 float b;
 int x;
 int y;
 float z;
 int i;
 float l;
 while(modelTrianglesLeft(m)) {
  modelTri = modelNextTriangle(m);
  if(
   (modelTri->vertices[1][0] - modelTri->vertices[0][0]) *
   (modelTri->vertices[2][1] - modelTri->vertices[0][1]) -
   (modelTri->vertices[2][0] - modelTri->vertices[0][0]) *
   (modelTri->vertices[1][1] - modelTri->vertices[0][1])
   < 0
  ) {
   continue;
  }
  for( i = 0; i < 3; i++ ) {
   t.sx[i] = (((modelTri->vertices[i][0])+1)*((float)(width/2)));
   t.sy[i] = (((modelTri->vertices[i][1])+1)*((float)(height/2)));
  }
  for( i = 0; i < 3; i++ ) {
   t.nx[i] = -(t.sy[(i+1)%3] - t.sy[i]);
   t.ny[i] = (t.sx[(i+1)%3] - t.sx[i]);
   l = sqrt( t.nx[i] * t.nx[i] + t.ny[i] * t.ny[i] );
   t.nx[i] /= l;
   t.ny[i] /= l;
  }
  for( i = 0; i < 3; i++ ) {
   t.b[i] = t.nx[i] * ( t.sx[(i+2)%3] - t.sx[i] ) + t.ny[i] * ( t.sy[(i+2)%3] - t.sy[i] );
  }
  t.xmin = floor( fmin( fmin( t.sx[0], t.sx[1] ), t.sx[2] ) );
  t.ymin = floor( fmin( fmin( t.sy[0], t.sy[1] ), t.sy[2] ) );
  t.xmax = ceil( fmax( fmax( t.sx[0], t.sx[1] ), t.sx[2] ) );
  t.ymax = ceil( fmax( fmax( t.sy[0], t.sy[1] ), t.sy[2] ) );
  t.xmin = fmax(0, t.xmin);
  t.xmax = fmin(width, t.xmax);
  t.ymin = fmax(0, t.ymin);
  t.ymax = fmin(height, t.ymax);
  if(t.ymin > t.ymax || t.xmin > t.xmax) {
   continue;
  }
  for( y = t.ymin; y < t.ymax; y++ ) {
   for( x = t.xmin; x < t.xmax; x++ ) {
    d1 = t.nx[0] * ( x - t.sx[0] ) + t.ny[0] * ( y - t.sy[0] );
    if( d1 >= 0 ) {
     d2 = t.nx[1] * ( x - t.sx[1] ) + t.ny[1] * ( y - t.sy[1] );
     if( d2 >= 0 ) {
      d3 = t.nx[2] * ( x - t.sx[2] ) + t.ny[2] * ( y - t.sy[2] );
      if( d3 >= 0 ) {
       d1 /= t.b[0];
       d2 /= t.b[1];
       d3 /= t.b[2];
       z =
        1.0f / modelTri->vertices[0][2] * d2 +
        1.0f / modelTri->vertices[1][2] * d3 +
        1.0f / modelTri->vertices[2][2] * d1;
       if( z > zbuf[y*width+x] ) {
        zbuf[y*width+x] = z;
        r =
         modelTri->colors[0][0] * d2 +
         modelTri->colors[1][0] * d3 +
         modelTri->colors[2][0] * d1;
        g =
         modelTri->colors[0][1] * d2 +
         modelTri->colors[1][1] * d3 +
         modelTri->colors[2][1] * d1;
        b =
         modelTri->colors[0][2] * d2 +
         modelTri->colors[1][2] * d3 +
         modelTri->colors[2][2] * d1;
        setPixel(*pbuf, x, y, makeColour(r,g,b));
       }
      }
     }
    }
   }
  }
 }
}

canonical_original_code:
void rasterize(struct model *m, struct buffer *pbuf, float *zbuf) {
 int width = pbuf->width;
 int height = pbuf->size;
 struct tri t;
 struct triangle *modelTri;
 float d1;
 float d2;
 float d3;
 float r;
 float g;
 float b;
 int x;
 int y;
 float z;
 int i;
 float l;
 while(modelTrianglesLeft(m)) {
  modelTri = modelNextTriangle(m);
  if(
   (modelTri->vertices[1][0] - modelTri->vertices[0][0]) *
   (modelTri->vertices[2][1] - modelTri->vertices[0][1]) -
   (modelTri->vertices[2][0] - modelTri->vertices[0][0]) *
   (modelTri->vertices[1][1] - modelTri->vertices[0][1])
   < 0
  ) {
   continue;
  }
  for( i = 0; i < 3; i++ ) {
   t.sx[i] = (((modelTri->vertices[i][0])+1)*((float)(width/2)));
   t.sy[i] = (((modelTri->vertices[i][1])+1)*((float)(height/2)));
  }
  for( i = 0; i < 3; i++ ) {
   t.nx[i] = -(t.sy[(i+1)%3] - t.sy[i]);
   t.ny[i] = (t.sx[(i+1)%3] - t.sx[i]);
   l = sqrt( t.nx[i] * t.nx[i] + t.ny[i] * t.ny[i] );
   t.nx[i] /= l;
   t.ny[i] /= l;
  }
  for( i = 0; i < 3; i++ ) {
   t.b[i] = t.nx[i] * ( t.sx[(i+2)%3] - t.sx[i] ) + t.ny[i] * ( t.sy[(i+2)%3] - t.sy[i] );
  }
  t.xmin = floor( fmin( fmin( t.sx[0], t.sx[1] ), t.sx[2] ) );
  t.ymin = floor( fmin( fmin( t.sy[0], t.sy[1] ), t.sy[2] ) );
  t.xmax = ceil( fmax( fmax( t.sx[0], t.sx[1] ), t.sx[2] ) );
  t.ymax = ceil( fmax( fmax( t.sy[0], t.sy[1] ), t.sy[2] ) );
  t.xmin = fmax(0, t.xmin);
  t.xmax = fmin(width, t.xmax);
  t.ymin = fmax(0, t.ymin);
  t.ymax = fmin(height, t.ymax);
  if(t.ymin > t.ymax || t.xmin > t.xmax) {
   continue;
  }
  for( y = t.ymin; y < t.ymax; y++ ) {
   for( x = t.xmin; x < t.xmax; x++ ) {
    d1 = t.nx[0] * ( x - t.sx[0] ) + t.ny[0] * ( y - t.sy[0] );
    if( d1 >= 0 ) {
     d2 = t.nx[1] * ( x - t.sx[1] ) + t.ny[1] * ( y - t.sy[1] );
     if( d2 >= 0 ) {
      d3 = t.nx[2] * ( x - t.sx[2] ) + t.ny[2] * ( y - t.sy[2] );
      if( d3 >= 0 ) {
       d1 /= t.b[0];
       d2 /= t.b[1];
       d3 /= t.b[2];
       z =
        1.0f / modelTri->vertices[0][2] * d2 +
        1.0f / modelTri->vertices[1][2] * d3 +
        1.0f / modelTri->vertices[2][2] * d1;
       if( z > zbuf[y*width+x] ) {
        zbuf[y*width+x] = z;
        r =
         modelTri->colors[0][0] * d2 +
         modelTri->colors[1][0] * d3 +
         modelTri->colors[2][0] * d1;
        g =
         modelTri->colors[0][1] * d2 +
         modelTri->colors[1][1] * d3 +
         modelTri->colors[2][1] * d1;
        b =
         modelTri->colors[0][2] * d2 +
         modelTri->colors[1][2] * d3 +
         modelTri->colors[2][2] * d1;
        setPixel(*pbuf, x, y, makeColour(r,g,b));
       }
      }
     }
    }
   }
  }
 }
}

variable_types: struct model { float *mesh; int triangleCount; int curTriangle; struct triangle { float vertices[3][3]; float normals[3][3]; float colors[3][3]; int ID; } *triangles; } *

variable_types: struct buffer { int width; int firstLine; int size; struct colour { float r; float b; float g; float a; } *data; } *

variable_types:
zbuf
float *

variable_types: width int

variable_types: height int

variable_types: struct tri { float sx[3]; float sy[3]; float nx[3]; float ny[3]; float b[3]; int xmin; int xmax; int ymin; int ymax; }

variable_types: r float

variable_types: g float

variable_types: b float

variable_types: z float

variable_types: i int

variable_types: l float


decompiled_code:
double __fastcall makeVec2(__m128i a1, __m128i a2)
{
double result; // xmm0_8

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

canonical_decompiled_code:
double __fastcall func0(__m128i a1, __m128i a2)
{
double result; // xmm0_8

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

original_code:
inline vec2 makeVec2(float x, float y) {
 vec2 v;
 v.x = x;
 v.y = y;
 return v;
}

canonical_original_code:
inline struct vec2 makeVec2(float x, float y) {
 struct vec2 v;
 v.x = x;
 v.y = y;
 return v;
}

variable_types: x float

variable_types: y float

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

return_type: struct vec2 { float x; float y; }


decompiled_code:
__m128i __fastcall makeVec3(float a1, float a2)
{
__m128i v3; // [rsp+0h] [rbp-14h] BYREF

v3.m128i_i64[0] = __PAIR64__(LODWORD(a2), LODWORD(a1));
return _mm_loadl_epi64(&v3);
}

canonical_decompiled_code:
__m128i __fastcall func1(float a1, float a2)
{
__m128i v3; // [rsp+0h] [rbp-14h] BYREF

v3.m128i_i64[0] = __PAIR64__(LODWORD(a2), LODWORD(a1));
return _mm_loadl_epi64(&v3);
}

original_code:
inline vec3 makeVec3(float x, float y, float z) {
 vec3 v;
 v.x = x;
 v.y = y;
 v.z = z;
 return v;
}

canonical_original_code:
inline struct vec3 makeVec3(float x, float y, float z) {
 struct vec3 v;
 v.x = x;
 v.y = y;
 v.z = z;
 return v;
}

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


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

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

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

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

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

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

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

variable_types:
a
struct vec2

variable_types: s float


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

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

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

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

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

variable_types:
a
struct vec3


decompiled_code:
void __fastcall scale2(float *a1, float a2)
{
float v2; // xmm1_4
float v3; // xmm0_4

v2 = *a1 * a2;
v3 = a2 * a1[1];
*a1 = v2;
a1[1] = v3;
}

canonical_decompiled_code:
void __fastcall func4(float *a1, float a2)
{
float v2; // xmm1_4
float v3; // xmm0_4

v2 = *a1 * a2;
v3 = a2 * a1[1];
*a1 = v2;
a1[1] = v3;
}

original_code:
inline void scale2(vec2 * r, float s) {
 r->x *= s;
 r->y *= s;
}

canonical_original_code:
inline void scale2(struct vec2 *r, float s) {
 r->x *= s;
 r->y *= s;
}


original_code:
inline void scale3(vec3 * r, float s) {
 r->x *= s;
 r->y *= s;
 r->z *= s;
}

canonical_original_code:
inline void scale3(struct vec3 *r, float s) {
 r->x *= s;
 r->y *= s;
 r->z *= s;
}

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


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

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

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

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

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

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


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

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


decompiled_code:
void __fastcall invScale2(float *a1, float a2)
{
*a1 = *a1 / a2;
a1[1] = a1[1] / a2;
}

canonical_decompiled_code:
void __fastcall func8(float *a1, float a2)
{
*a1 = *a1 / a2;
a1[1] = a1[1] / a2;
}

original_code:
inline void invScale2(vec2 * r, float s) {
 r->x /= s;
 r->y /= s;
}

canonical_original_code:
inline void invScale2(struct vec2 *r, float s) {
 r->x /= s;
 r->y /= s;
}


original_code:
inline void invScale3(vec3 * r, float s) {
 r->x /= s;
 r->y /= s;
 r->z /= s;
}

canonical_original_code:
inline void invScale3(struct vec3 *r, float s) {
 r->x /= s;
 r->y /= s;
 r->z /= s;
}


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

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

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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = LODWORD(a2) ^ LC1;
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;
}


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

canonical_decompiled_code:
void __fastcall func11(int *a1, double a2, float a3)
{
a1[2] = LODWORD(a3) ^ LC1;
*a1 = LODWORD(a2) ^ LC1;
a1[1] = HIDWORD(a2) ^ 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;
}


decompiled_code:
void __fastcall invert2(_DWORD *a1)
{
int v1; // xmm0_4

v1 = a1[1] ^ LC1;
*a1 ^= LC1;
a1[1] = v1;
}

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


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


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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 + *(float *)&a3;
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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 + *(float *)&a3;
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:
b
struct vec2


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

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

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

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

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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 + *a1;
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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 - *(float *)&a3;
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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 - *(float *)&a3;
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[2] = a3 - a5;
*a1 = *(float *)&a2 - *(float *)&a4;
a1[1] = *((float *)&a2 + 1) - *((float *)&a4 + 1);
}

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

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

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

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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *a1 - *(float *)&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[2] = (float)(*((float *)&a4 + 1) - *((float *)&a2 + 1)) * *(float *)&a2;
a1[1] = (float)(*(float *)&a4 - *(float *)&a2) * a3;
}

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


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


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

variable_types: l float


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
double v5; // xmm4_8

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

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

v4 = func22(a3, a2);
func2(a1, v5, 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
double v6; // xmm4_8

v5 = dot3(a4, a5, a2, a3);
mult3(a1, v6, 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
double v6; // xmm4_8

v5 = func23(a4, a5, a2, a3);
func3(a1, v6, 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:
i
struct vec3

variable_types:
n
struct vec3


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

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

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

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

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)
{
double v3; // rax
float v4; // xmm0_4
double v5; // xmm4_8
double v6; // [rsp+1Ch] [rbp-Ch]
float v7; // [rsp+24h] [rbp-4h]

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

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

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

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

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


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(double a1, float a2)
{
float *v2; // r8
double v3; // [rsp+14h] [rbp-Ch] BYREF
float v4; // [rsp+1Ch] [rbp-4h]

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

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

func3((float *)&v3, a1, a2, 0.1);
func17(v2, 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 );
}


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 __int64)(unsigned int)_mm_cvtsi128_si32(a1) << 32) | (unsigned int)_mm_cvtsi128_si32(a1);
return result;
}

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

*(_QWORD *)&result = ((unsigned __int64)(unsigned int)_mm_cvtsi128_si32(a1) << 32) | (unsigned int)_mm_cvtsi128_si32(a1);
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


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 result; // rax
float v4; // xmm0_4
float v5; // xmm0_4
float v6; // xmm0_4

result = HIDWORD(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;
v6 = fmax(fmin(*(float *)&result, 1.0), 0.0);
a1[1] = v6;
return result;
}

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

result = HIDWORD(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;
v6 = fmax(fmin(*(float *)&result, 1.0), 0.0);
a1[1] = v6;
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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 + a4;
a1[2] = a3 + a4;
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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 + a4;
a1[2] = a3 + a4;
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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 - a4;
a1[2] = a3 - a4;
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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 - a4;
a1[2] = a3 - a4;
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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 * a4;
a1[2] = a3 * a4;
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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 * a4;
a1[2] = a3 * a4;
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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 * (float)(1.0 / a4);
a1[2] = a3 * (float)(1.0 / a4);
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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 * (float)(1.0 / a4);
a1[2] = a3 * (float)(1.0 / a4);
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

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

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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 * *a1;
a1[2] = a3 * a1[2];
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

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

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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 * *(float *)&a4;
a1[1] = *((float *)&a2 + 1) * *((float *)&a4 + 1);
a1[2] = a3 * a5;
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

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

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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *a1 / *(float *)&a2;
a1[2] = a1[2] / a3;
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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 / *(float *)&a4;
a1[2] = a3 / a5;
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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 / *(float *)&a4;
a1[2] = a3 / a5;
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

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

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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 + *a1;
a1[2] = a3 + a1[2];
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

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

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

result = HIDWORD(*(_QWORD *)&a2);
*a1 = *(float *)&a2 + *(float *)&a4;
a1[1] = *((float *)&a2 + 1) + *((float *)&a4 + 1);
a1[2] = a3 + a5;
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:
bool __fastcall sameColour(double a1, float a2, double a3, float a4)
{
bool result; // al

if ( *(float *)&a1 == *(float *)&a3 && a2 == a4 )
result = *((float *)&a1 + 1) == *((float *)&a3 + 1);
else
result = 0;
return result;
}

canonical_decompiled_code:
bool __fastcall func20(double a1, float a2, double a3, float a4)
{
bool result; // al

if ( *(float *)&a1 == *(float *)&a3 && a2 == a4 )
result = *((float *)&a1 + 1) == *((float *)&a3 + 1);
else
result = 0;
return result;
}

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)(*(float *)&a1 - *(float *)&a3) * (float)(*(float *)&a1 - *(float *)&a3) * 0.3
+ (float)(a2 - a4) * (float)(a2 - a4) * 0.4
+ (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)(*(float *)&a1 - *(float *)&a3) * (float)(*(float *)&a1 - *(float *)&a3) * 0.3
+ (float)(a2 - a4) * (float)(a2 - a4) * 0.4
+ (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 ) );
}


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:
__int64 __fastcall getComponentColour(int a1, double a2, __m128i a3)
{
if ( !a1 )
return makeColour(a2, (__m128i)0LL);
if ( a1 == 1 )
return makeColour(0.0, a3);
return makeColour(0.0, (__m128i)0LL);
}

canonical_decompiled_code:
__int64 __fastcall func24(int a1, double a2, __m128i a3)
{
if ( !a1 )
return func0(a2, (__m128i)0LL);
if ( a1 == 1 )
return func0(0.0, a3);
return func0(0.0, (__m128i)0LL);
}

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, __m128i a2, __m128i a3)
{
float v3; // er12
float v4; // ebp
double v5; // rcx
float v6; // ecx
float v7; // xmm4_4
float v8; // xmm2_4
float v9; // xmm0_4
float v10; // [rsp+4h] [rbp-24h]
float v11; // [rsp+8h] [rbp-20h]
float v12; // [rsp+Ch] [rbp-1Ch]

v3 = COERCE_FLOAT(_mm_cvtsi128_si32(a2));
v4 = COERCE_FLOAT(_mm_cvtsi128_si32(a3));
makeColour(COERCE_DOUBLE((unsigned __int64)LC0), (__m128i)(unsigned int)LC0);
if ( !sameColour(v5, *(float *)a3.m128i_i32, COERCE_DOUBLE((unsigned __int64)LC0), 1.0) )
{
v10 = v7;
v11 = _expf_finite((float)((float)(v6 - 1.0) * v7) * 0.99999994);
v12 = _expf_finite((float)(v10 * (float)(v4 - 1.0)) * 0.99999994);
v8 = _expf_finite((float)(v10 * (float)(*(float *)&a2.m128i_i32[1] - 1.0)) * 0.99999994);
v9 = *(float *)&a2.m128i_i32[1] * a1[1];
*a1 = (float)(v3 * *a1) * v11;
a1[2] = (float)(v4 * a1[2]) * v12;
a1[1] = v9 * v8;
}
}

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
__int64 v3; // rcx

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 )
{
v3 = (unsigned int)sep;
if ( a1 )
result = printf("%s", cgibase, man2htmlpath, v3, a1, a2, a2);
else
result = printf("%s", cgibase, man2htmlpath, v3, 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
__int64 v3; // rcx

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 )
{
v3 = (unsigned int)sep;
if ( a1 )
result = printf("%s", cgibase, man2htmlpath, v3, a1, a2, a2);
else
result = printf("%s", cgibase, man2htmlpath, v3, 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

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

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

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

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 *