ortho

decompiled_code:
__int64 __fastcall ortho(float a1, float a2, float a3, float a4, float a5, float a6)
{
bool v6; // zf
bool v7; // zf
bool v8; // zf
__int64 result; // rax
float v12; // [rsp+24h] [rbp-54h]
float v13; // [rsp+28h] [rbp-50h]
float v14; // [rsp+2Ch] [rbp-4Ch]
int v15[18]; // [rsp+30h] [rbp-48h] BYREF

if ( vdevice )
{
v12 = a2 - a1;
v6 = (float)(a2 - a1) == 0.0;
}
else
{
verror("ortho: vogl not initialised");
}
if ( v6 )
{
verror("ortho: left clipping plane same as right one.");
}
else
{
v13 = a4 - a3;
v7 = (float)(a4 - a3) == 0.0;
}
if ( v7 )
{
verror("ortho: bottom clipping plane same as top one.");
}
else
{
v14 = a6 - a5;
v8 = (float)(a6 - a5) == 0.0;
}
if ( v8 )
{
verror("ortho: near clipping plane same as far one.");
result = ortho2();
}
else
{
identmatrix(v15);
*(float *)v15 = 2.0 / v12;
*(float *)&v15[5] = 2.0 / v13;
*(float *)&v15[10] = -2.0 / v14;
*(float *)&v15[12] = COERCE_FLOAT(COERCE_UNSIGNED_INT(a2 + a1) ^ LC1) / v12;
*(float *)&v15[13] = COERCE_FLOAT(COERCE_UNSIGNED_INT(a4 + a3) ^ LC1) / v13;
*(float *)&v15[14] = COERCE_FLOAT(COERCE_UNSIGNED_INT(a6 + a5) ^ LC1) / v14;
result = loadmatrix(v15);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(float a1, float a2, float a3, float a4, float a5, float a6)
{
bool v6; // zf
bool v7; // zf
bool v8; // zf
__int64 result; // rax
float v12; // [rsp+24h] [rbp-54h]
float v13; // [rsp+28h] [rbp-50h]
float v14; // [rsp+2Ch] [rbp-4Ch]
int v15[18]; // [rsp+30h] [rbp-48h] BYREF

if ( vdevice )
{
v12 = a2 - a1;
v6 = (float)(a2 - a1) == 0.0;
}
else
{
verror("ortho: vogl not initialised");
}
if ( v6 )
{
verror("ortho: left clipping plane same as right one.");
}
else
{
v13 = a4 - a3;
v7 = (float)(a4 - a3) == 0.0;
}
if ( v7 )
{
verror("ortho: bottom clipping plane same as top one.");
}
else
{
v14 = a6 - a5;
v8 = (float)(a6 - a5) == 0.0;
}
if ( v8 )
{
verror("ortho: near clipping plane same as far one.");
result = func6();
}
else
{
identmatrix(v15);
*(float *)v15 = 2.0 / v12;
*(float *)&v15[5] = 2.0 / v13;
*(float *)&v15[10] = -2.0 / v14;
*(float *)&v15[12] = COERCE_FLOAT(COERCE_UNSIGNED_INT(a2 + a1) ^ LC1) / v12;
*(float *)&v15[13] = COERCE_FLOAT(COERCE_UNSIGNED_INT(a4 + a3) ^ LC1) / v13;
*(float *)&v15[14] = COERCE_FLOAT(COERCE_UNSIGNED_INT(a6 + a5) ^ LC1) / v14;
result = loadmatrix(v15);
}
return result;
}

original_code:
void
ortho(Coord left, Coord right, Coord bottom, Coord top, Coord hither, Coord yon)
{
 Matrix mat;
 if (!vdevice.initialised)
  verror("ortho: vogl not initialised");
 if ((right - left) == 0.0)
  verror("ortho: left clipping plane same as right one.");
 if ((top - bottom) == 0.0)
  verror("ortho: bottom clipping plane same as top one.");
 if ((yon - hither) == 0.0)
  verror("ortho: near clipping plane same as far one.");
 identmatrix(mat);
 mat[0][0] = 2.0 / (right - left);
 mat[1][1] = 2.0 / (top - bottom);
 mat[2][2] = -2.0 / (yon - hither);
 mat[3][0] = -(right + left) / (right - left);
 mat[3][1] = -(top + bottom) / (top - bottom);
 mat[3][2] = -(yon + hither) / (yon - hither);
 loadmatrix(mat);
}

canonical_original_code:
void ortho(float left, float right, float bottom, float top, float hither, float yon)
{
 float mat[4][4];
 if (!vdevice.initialised)
  verror("ortho: vogl not initialised");
 if ((right - left) == 0.0)
  verror("ortho: left clipping plane same as right one.");
 if ((top - bottom) == 0.0)
  verror("ortho: bottom clipping plane same as top one.");
 if ((yon - hither) == 0.0)
  verror("ortho: near clipping plane same as far one.");
 identmatrix(mat);
 mat[0][0] = 2.0 / (right - left);
 mat[1][1] = 2.0 / (top - bottom);
 mat[2][2] = -2.0 / (yon - hither);
 mat[3][0] = -(right + left) / (right - left);
 mat[3][1] = -(top + bottom) / (top - bottom);
 mat[3][2] = -(yon + hither) / (yon - hither);
 loadmatrix(mat);
}


decompiled_code:
__int64 __fastcall ortho2(float a1, float a2, float a3, float a4)
{
bool v4; // zf
bool v5; // zf
float v7; // [rsp+8h] [rbp-50h]
float v8; // [rsp+Ch] [rbp-4Ch]
int v9[18]; // [rsp+10h] [rbp-48h] BYREF

v7 = a3;
v8 = a4;
if ( vdevice )
{
identmatrix(v9);
a4 = a2 - a1;
v4 = (float)(a2 - a1) == 0.0;
}
else
{
verror("ortho2: vogl not initialised");
}
if ( v4 )
{
verror("ortho2: left clipping plane same as right one.");
}
else
{
a3 = v8 - a3;
v5 = (float)(v8 - v7) == 0.0;
}
if ( v5 )
{
verror("ortho2: bottom clipping plane same as top one.");
JUMPOUT(0x88FLL);
}
*(float *)v9 = 2.0 / a4;
*(float *)&v9[5] = 2.0 / a3;
v9[10] = -1082130432;
*(float *)&v9[12] = COERCE_FLOAT(COERCE_UNSIGNED_INT(a2 + a1) ^ LC1) / a4;
*(float *)&v9[13] = COERCE_FLOAT(COERCE_UNSIGNED_INT(v8 + v7) ^ LC1) / a3;
return loadmatrix(v9);
}

canonical_decompiled_code:
__int64 __fastcall func6(float a1, float a2, float a3, float a4)
{
bool v4; // zf
bool v5; // zf
float v7; // [rsp+8h] [rbp-50h]
float v8; // [rsp+Ch] [rbp-4Ch]
int v9[18]; // [rsp+10h] [rbp-48h] BYREF

v7 = a3;
v8 = a4;
if ( vdevice )
{
identmatrix(v9);
a4 = a2 - a1;
v4 = (float)(a2 - a1) == 0.0;
}
else
{
verror("ortho2: vogl not initialised");
}
if ( v4 )
{
verror("ortho2: left clipping plane same as right one.");
}
else
{
a3 = v8 - a3;
v5 = (float)(v8 - v7) == 0.0;
}
if ( v5 )
{
verror("ortho2: bottom clipping plane same as top one.");
JUMPOUT(0x88FLL);
}
*(float *)v9 = 2.0 / a4;
*(float *)&v9[5] = 2.0 / a3;
v9[10] = -1082130432;
*(float *)&v9[12] = COERCE_FLOAT(COERCE_UNSIGNED_INT(a2 + a1) ^ LC1) / a4;
*(float *)&v9[13] = COERCE_FLOAT(COERCE_UNSIGNED_INT(v8 + v7) ^ LC1) / a3;
return loadmatrix(v9);
}

original_code:
void
ortho2(Coord left, Coord right, Coord bottom, Coord top)
{
 Matrix mat;
 if (!vdevice.initialised)
  verror("ortho2: vogl not initialised");
 identmatrix(mat);
 if ((right - left) == 0.0)
  verror("ortho2: left clipping plane same as right one.");
 if ((top - bottom) == 0.0)
  verror("ortho2: bottom clipping plane same as top one.");
 mat[0][0] = 2.0 / (right - left);
 mat[1][1] = 2.0 / (top - bottom);
 mat[2][2] = -1.0;
 mat[3][0] = -(right + left) / (right - left);
 mat[3][1] = -(top + bottom) / (top - bottom);
 loadmatrix(mat);
}

canonical_original_code:
void ortho2(float left, float right, float bottom, float top)
{
 float mat[4][4];
 if (!vdevice.initialised)
  verror("ortho2: vogl not initialised");
 identmatrix(mat);
 if ((right - left) == 0.0)
  verror("ortho2: left clipping plane same as right one.");
 if ((top - bottom) == 0.0)
  verror("ortho2: bottom clipping plane same as top one.");
 mat[0][0] = 2.0 / (right - left);
 mat[1][1] = 2.0 / (top - bottom);
 mat[2][2] = -1.0;
 mat[3][0] = -(right + left) / (right - left);
 mat[3][1] = -(top + bottom) / (top - bottom);
 loadmatrix(mat);
}

variable_types: left float

variable_types: right float

variable_types: bottom float

variable_types: top float

variable_types:
mat
float [4][4]

return_type: void


newtokens

decompiled_code:
__int64 __fastcall newtokens(int a1)
{
__int64 v2; // r12
_QWORD *v3; // rax
_QWORD *v4; // rbp
int v5; // edi
void *v6; // rax
__int64 v7; // rdx

if ( !vdevice[2] )
goto LABEL_12;
v2 = current;
if ( 100 - *(_DWORD *)current <= a1 )
{
v3 = malloc(0x18uLL);
v4 = v3;
if ( !v3 )
goto LABEL_10;
*(_QWORD *)(v2 + 16) = v3;
while ( 1 )
{
*(_DWORD *)v4 = 0;
v4[2] = 0LL;
v5 = 100;
if ( a1 >= 100 )
v5 = a1;
v6 = malloc(4LL * v5);
v4[1] = v6;
if ( v6 )
break;
while ( 1 )
{
verror("newtokens: malloc returns NULL");
LABEL_12:
v4 = malloc(0x18uLL);
if ( v4 )
break;
LABEL_10:
verror("newtokens: malloc returns NULL");
}
vdevice[2] = v4;
}
current = (__int64)v4;
}
v7 = *(_QWORD *)(current + 8) + 4LL * *(int *)current;
*(_DWORD *)current += a1;
return v7;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
__int64 v2; // r12
_QWORD *v3; // rax
_QWORD *v4; // rbp
int v5; // edi
void *v6; // rax
__int64 v7; // rdx

if ( !vdevice[2] )
goto LABEL_12;
v2 = current;
if ( 100 - *(_DWORD *)current <= a1 )
{
v3 = malloc(0x18uLL);
v4 = v3;
if ( !v3 )
goto LABEL_10;
*(_QWORD *)(v2 + 16) = v3;
while ( 1 )
{
*(_DWORD *)v4 = 0;
v4[2] = 0LL;
v5 = 100;
if ( a1 >= 100 )
v5 = a1;
v6 = malloc(4LL * v5);
v4[1] = v6;
if ( v6 )
break;
while ( 1 )
{
verror("newtokens: malloc returns NULL");
LABEL_12:
v4 = malloc(0x18uLL);
if ( v4 )
break;
LABEL_10:
verror("newtokens: malloc returns NULL");
}
vdevice[2] = v4;
}
current = (__int64)v4;
}
v7 = *(_QWORD *)(current + 8) + 4LL * *(int *)current;
*(_DWORD *)current += a1;
return v7;
}

original_code:
Token *
newtokens(int num)
{
 TokList *tl;
 Token *addr;
 int size;
 if (vdevice.tokens == (TokList *)((void *)0) || num >= 100 - current->count) {
  if ((tl = (TokList *)malloc(sizeof(TokList))) == (TokList *)((void *)0))
   verror("newtokens: malloc returns NULL");
  if (vdevice.tokens != (TokList *)((void *)0))
   current->next = tl;
  else
   vdevice.tokens = tl;
  tl->count = 0;
  tl->next = (TokList *)((void *)0);
  if (num > 100)
   size = num;
  else
   size = 100;
  if ((tl->toks = (Token *)malloc(size * sizeof(Token))) == (Token *)((void *)0))
   verror("newtokens: malloc returns NULL");
  current = tl;
 }
 addr = &current->toks[current->count];
 current->count += num;
 return(addr);
}

canonical_original_code:
union tk *newtokens(int num)
{
 struct tls *tl;
 union tk *addr;
 int size;
 if (vdevice.tokens == (struct tls *)((void *)0) || num >= 100 - current->count) {
  if ((tl = (struct tls *)malloc(sizeof(TokList))) == (struct tls *)((void *)0))
   verror("newtokens: malloc returns NULL");
  if (vdevice.tokens != (struct tls *)((void *)0))
   current->next = tl;
  else
   vdevice.tokens = tl;
  tl->count = 0;
  tl->next = (struct tls *)((void *)0);
  if (num > 100)
   size = num;
  else
   size = 100;
  if ((tl->toks = (union tk *)malloc(size * sizeof(Token))) == (union tk *)((void *)0))
   verror("newtokens: malloc returns NULL");
  current = tl;
 }
 addr = &current->toks[current->count];
 current->count += num;
 return(addr);
}

variable_types: num int

variable_types: struct tls { int count; union tk { int i; float f; } *toks; struct tls *next; } *

variable_types:
addr
union tk { int i; float f; } *

variable_types: size int

return_type: union tk { int i; float f; } *

user_defined_types: struct tls { int count; union tk *toks; struct tls *next; }


decompiled_code:
__int64 bgnpoi_()
{
return bgnpoint();
}

canonical_decompiled_code:
__int64 func1()
{
return bgnpoint();
}

original_code:
void
bgnpoi_()
{
 bgnpoint();
}

canonical_original_code:
void bgnpoi_()
{
 bgnpoint();
}


decompiled_code:
__int64 bgnlin_()
{
return bgnline();
}

canonical_decompiled_code:
__int64 func3()
{
return bgnline();
}

original_code:
void
bgnlin_()
{
 bgnline();
}

canonical_original_code:
void bgnlin_()
{
 bgnline();
}


decompiled_code:
__int64 bgnclo_()
{
return bgnclosedline();
}

canonical_decompiled_code:
__int64 func5()
{
return bgnclosedline();
}

original_code:
void
bgnclo_()
{
 bgnclosedline();
}

canonical_original_code:
void bgnclo_()
{
 bgnclosedline();
}


decompiled_code:
__int64 bgnpol_()
{
return bgnpolygon();
}

canonical_decompiled_code:
__int64 func7()
{
return bgnpolygon();
}

original_code:
void
bgnpol_()
{
 bgnpolygon();
}

canonical_original_code:
void bgnpol_()
{
 bgnpolygon();
}


decompiled_code:
__int64 endpoi_()
{
return endpoint();
}

canonical_decompiled_code:
__int64 func9()
{
return endpoint();
}

original_code:
void
endpoi_()
{
 endpoint();
}

canonical_original_code:
void endpoi_()
{
 endpoint();
}


decompiled_code:
__int64 endlin_()
{
return endline();
}

canonical_decompiled_code:
__int64 func11()
{
return endline();
}

original_code:
void
endlin_()
{
 endline();
}

canonical_original_code:
void endlin_()
{
 endline();
}


decompiled_code:
__int64 endclo_()
{
return endclosedline();
}

canonical_decompiled_code:
__int64 func13()
{
return endclosedline();
}

original_code:
void
endclo_()
{
 endclosedline();
}

canonical_original_code:
void endclo_()
{
 endclosedline();
}


decompiled_code:
__int64 endpol_()
{
return endpolygon();
}

canonical_decompiled_code:
__int64 func15()
{
return endpolygon();
}

original_code:
void
endpol_()
{
 endpolygon();
}

canonical_original_code:
void endpol_()
{
 endpolygon();
}


decompiled_code:
__int64 endtme_()
{
return endtmesh();
}

canonical_decompiled_code:
__int64 func17()
{
return endtmesh();
}

original_code:
void
endtme_()
{
        endtmesh();
}

canonical_original_code:
void endtme_()
{
        endtmesh();
}


decompiled_code:
__int64 endqst_()
{
return endqstrip();
}

canonical_decompiled_code:
__int64 func19()
{
return endqstrip();
}

original_code:
void
endqst_()
{
        endqstrip();
}

canonical_original_code:
void endqst_()
{
        endqstrip();
}


decompiled_code:
__int64 bgntme_()
{
return bgntmesh();
}

canonical_decompiled_code:
__int64 func21()
{
return bgntmesh();
}

original_code:
void
bgntme_()
{
         bgntmesh();
}

canonical_original_code:
void bgntme_()
{
         bgntmesh();
}


decompiled_code:
__int64 bgnqst_()
{
return bgnqstrip();
}

canonical_decompiled_code:
__int64 func23()
{
return bgnqstrip();
}

original_code:
void
bgnqst_()
{
         bgnqstrip();
}

canonical_original_code:
void bgnqst_()
{
         bgnqstrip();
}


decompiled_code:
__int64 swaptm_()
{
return swaptmesh();
}

canonical_decompiled_code:
__int64 func25()
{
return swaptmesh();
}

original_code:
void
swaptm_()
{
        swaptmesh();
}

canonical_original_code:
void swaptm_()
{
        swaptmesh();
}


prefposition

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

if ( a1 < 0 || a2 < 0 )
{
verror("prefposition: bad x value");
LABEL_9:
verror("prefposition: bad y value");
LABEL_10:
verror("prefposition: bad window size");
return prefsize();
}
if ( a3 < 0 || a4 < 0 )
goto LABEL_9;
px = a1;
py = a3;
v4 = a2 - a1;
pxs = v4;
pys = a4 - a3;
if ( a4 - a3 <= 0 || v4 <= 0 )
goto LABEL_10;
return result;
}

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

if ( a1 < 0 || a2 < 0 )
{
verror("prefposition: bad x value");
LABEL_9:
verror("prefposition: bad y value");
LABEL_10:
verror("prefposition: bad window size");
return func1();
}
if ( a3 < 0 || a4 < 0 )
goto LABEL_9;
px = a1;
py = a3;
v4 = a2 - a1;
pxs = v4;
pys = a4 - a3;
if ( a4 - a3 <= 0 || v4 <= 0 )
goto LABEL_10;
return result;
}

original_code:
void
prefposition(long int x1, long int x2, long int y1, long int y2)
{
 if (x1 < 0 || x2 < 0)
  verror("prefposition: bad x value");
 if (y1 < 0 || y2 < 0)
  verror("prefposition: bad y value");
 px = x1;
 py = y1;
 pxs = x2 - x1;
 pys = y2 - y1;
 if (pxs <= 0 || pys <= 0)
  verror("prefposition: bad window size");
}

canonical_original_code:
void prefposition(long x1, long x2, long y1, long y2)
{
 if (x1 < 0 || x2 < 0)
  verror("prefposition: bad x value");
 if (y1 < 0 || y2 < 0)
  verror("prefposition: bad y value");
 px = x1;
 py = y1;
 pxs = x2 - x1;
 pys = y2 - y1;
 if (pxs <= 0 || pys <= 0)
  verror("prefposition: bad window size");
}


prefsize

decompiled_code:
__int64 __fastcall prefsize(__int64 a1, __int64 a2)
{
__int64 result; // rax

if ( a1 < 0 )
{
verror("prefsize: bad x value");
}
else if ( a2 >= 0 )
{
pxs = a1;
pys = a2;
return result;
}
verror("prefsize: bad y value");
return getprefposandsize();
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 result; // rax

if ( a1 < 0 )
{
verror("prefsize: bad x value");
}
else if ( a2 >= 0 )
{
pxs = a1;
pys = a2;
return result;
}
verror("prefsize: bad y value");
return func2();
}

original_code:
void
prefsize(long int x, long int y)
{
 if (x < 0)
  verror("prefsize: bad x value");
 if (y < 0)
  verror("prefsize: bad y value");
 pxs = x;
 pys = y;
}

canonical_original_code:
void prefsize(long x, long y)
{
 if (x < 0)
  verror("prefsize: bad x value");
 if (y < 0)
  verror("prefsize: bad y value");
 pxs = x;
 pys = y;
}

variable_types: x long

variable_types: y long


qdevice

decompiled_code:
__int64 __fastcall qdevice(const char *a1)
{
__int64 result; // rax
char v2; // si
__int64 i; // rax
_BYTE *v4; // rax
int v5; // edx

result = (__int64)&vdevice;
if ( !vdevice )
{
verror("qdevice: vogl not initialised\n");
goto LABEL_7;
}
if ( (unsigned __int16)a1 > 0x106u )
{
LABEL_7:
a1 = "qdevice: bad device number passed\n";
result = verror("qdevice: bad device number passed\n");
goto LABEL_8;
}
if ( (unsigned __int16)a1 <= 0x5Du )
{
if ( (unsigned __int16)a1 > 0x2Cu )
{
switch ( (__int16)a1 )
{
case '-':
*((_BYTE *)&vdevice + 527) = 1;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 5LL) |= 0x20u;
result = *((_QWORD *)&vdevice + 64);
*(_BYTE *)(result + 11) |= 0x80u;
break;
case '=':
*((_BYTE *)&vdevice + 527) = 1;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 7LL) |= 0x20u;
result = *((_QWORD *)&vdevice + 64);
*(_BYTE *)(result + 5) |= 8u;
break;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
*((_BYTE *)&vdevice + 527) = 1;
v4 = (_BYTE *)(*((_QWORD *)&vdevice + 64) + ((unsigned __int16)a1 >> 3));
v5 = 1 << ((unsigned __int8)a1 & 7);
*v4 |= v5;
result = *((_QWORD *)&vdevice + 64) + (((unsigned __int16)a1 + 32) >> 3);
*(_BYTE *)result |= v5;
break;
case '[':
*((_BYTE *)&vdevice + 527) = 1;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 11LL) |= 8u;
result = *((_QWORD *)&vdevice + 64);
*(_BYTE *)(result + 15) |= 8u;
break;
case '\\':
*((_BYTE *)&vdevice + 527) = 1;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 11LL) |= 0x10u;
result = *((_QWORD *)&vdevice + 64);
*(_BYTE *)(result + 15) |= 0x10u;
break;
case ']':
*((_BYTE *)&vdevice + 527) = 1;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 11LL) |= 0x20u;
result = *((_QWORD *)&vdevice + 64);
*(_BYTE *)(result + 15) |= 0x20u;
break;
default:
goto LABEL_24;
}
return result;
}
LABEL_24:
*((_BYTE *)&vdevice + 527) = 1;
result = *((_QWORD *)&vdevice + 64) + ((unsigned __int16)a1 >> 3);
*(_BYTE *)result |= 1 << ((unsigned __int8)a1 & 7);
return result;
}
LABEL_8:
if ( (unsigned __int16)a1 > 0x104u )
{
if ( (_WORD)a1 == 262 )
return result;
goto LABEL_24;
}
if ( (unsigned __int16)a1 > 0x101u )
{
*((_BYTE *)&vdevice + 526) = 1;
result = (unsigned int)(1 << ((unsigned __int8)a1 & 7));
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 32LL) |= result;
return result;
}
if ( (_WORD)a1 != 257 )
goto LABEL_24;
*((_BYTE *)&vdevice + 525) = 1;
*((_BYTE *)&vdevice + 527) = 1;
v2 = *(_BYTE *)(*((_QWORD *)&vdevice + 64) + 32LL) & 0x20;
for ( i = 0LL; i != 34; ++i )
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + i) = -1;
result = *((_QWORD *)&vdevice + 64);
*(_BYTE *)result &= 0xFEu;
if ( !v2 )
{
result = *((_QWORD *)&vdevice + 64);
*(_BYTE *)(result + 32) &= 0xDFu;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
__int64 result; // rax
char v2; // si
__int64 i; // rax
_BYTE *v4; // rax
int v5; // edx

result = (__int64)&vdevice;
if ( !vdevice )
{
verror("qdevice: vogl not initialised\n");
goto LABEL_7;
}
if ( (unsigned __int16)a1 > 0x106u )
{
LABEL_7:
a1 = "qdevice: bad device number passed\n";
result = verror("qdevice: bad device number passed\n");
goto LABEL_8;
}
if ( (unsigned __int16)a1 <= 0x5Du )
{
if ( (unsigned __int16)a1 > 0x2Cu )
{
switch ( (__int16)a1 )
{
case '-':
*((_BYTE *)&vdevice + 527) = 1;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 5LL) |= 0x20u;
result = *((_QWORD *)&vdevice + 64);
*(_BYTE *)(result + 11) |= 0x80u;
break;
case '=':
*((_BYTE *)&vdevice + 527) = 1;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 7LL) |= 0x20u;
result = *((_QWORD *)&vdevice + 64);
*(_BYTE *)(result + 5) |= 8u;
break;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
*((_BYTE *)&vdevice + 527) = 1;
v4 = (_BYTE *)(*((_QWORD *)&vdevice + 64) + ((unsigned __int16)a1 >> 3));
v5 = 1 << ((unsigned __int8)a1 & 7);
*v4 |= v5;
result = *((_QWORD *)&vdevice + 64) + (((unsigned __int16)a1 + 32) >> 3);
*(_BYTE *)result |= v5;
break;
case '[':
*((_BYTE *)&vdevice + 527) = 1;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 11LL) |= 8u;
result = *((_QWORD *)&vdevice + 64);
*(_BYTE *)(result + 15) |= 8u;
break;
case '\\':
*((_BYTE *)&vdevice + 527) = 1;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 11LL) |= 0x10u;
result = *((_QWORD *)&vdevice + 64);
*(_BYTE *)(result + 15) |= 0x10u;
break;
case ']':
*((_BYTE *)&vdevice + 527) = 1;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 11LL) |= 0x20u;
result = *((_QWORD *)&vdevice + 64);
*(_BYTE *)(result + 15) |= 0x20u;
break;
default:
goto LABEL_24;
}
return result;
}
LABEL_24:
*((_BYTE *)&vdevice + 527) = 1;
result = *((_QWORD *)&vdevice + 64) + ((unsigned __int16)a1 >> 3);
*(_BYTE *)result |= 1 << ((unsigned __int8)a1 & 7);
return result;
}
LABEL_8:
if ( (unsigned __int16)a1 > 0x104u )
{
if ( (_WORD)a1 == 262 )
return result;
goto LABEL_24;
}
if ( (unsigned __int16)a1 > 0x101u )
{
*((_BYTE *)&vdevice + 526) = 1;
result = (unsigned int)(1 << ((unsigned __int8)a1 & 7));
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 32LL) |= result;
return result;
}
if ( (_WORD)a1 != 257 )
goto LABEL_24;
*((_BYTE *)&vdevice + 525) = 1;
*((_BYTE *)&vdevice + 527) = 1;
v2 = *(_BYTE *)(*((_QWORD *)&vdevice + 64) + 32LL) & 0x20;
for ( i = 0LL; i != 34; ++i )
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + i) = -1;
result = *((_QWORD *)&vdevice + 64);
*(_BYTE *)result &= 0xFEu;
if ( !v2 )
{
result = *((_QWORD *)&vdevice + 64);
*(_BYTE *)(result + 32) &= 0xDFu;
}
return result;
}

original_code:
void
qdevice(Device dev)
{
 int i, redraw_enabled;
 if (!vdevice.initialised)
  verror("qdevice: vogl not initialised\n");
 if (dev > (Device)262)
  verror("qdevice: bad device number passed\n");
 switch (dev) {
 case 'A':
 case 'B':
 case 'C':
 case 'D':
 case 'E':
 case 'F':
 case 'G':
 case 'H':
 case 'I':
 case 'J':
 case 'K':
 case 'L':
 case 'M':
 case 'N':
 case 'O':
 case 'P':
 case 'Q':
 case 'R':
 case 'S':
 case 'T':
 case 'U':
 case 'V':
 case 'W':
 case 'X':
 case 'Y':
 case 'Z':
  vdevice.kbdevents = 1;
  vdevice.enabled[dev / 8] |= 1 << (dev & 0x7);
  vdevice.enabled[(int)(dev - 'A' + 'a') / 8] |= 1 << ((dev - 'A' + 'a') & 0x7);
  break;
 case 257:
  vdevice.kbdmode = 1;
  vdevice.kbdevents = 1;
  redraw_enabled = (vdevice.enabled[261 / 8] & (1 << (261 & 0x7)));
  for (i = 0; i != 34; i++)
   vdevice.enabled[i] = 0xff;
  vdevice.enabled[0] &= 0xfe;
  if (!redraw_enabled)
   vdevice.enabled[261 / 8] &= ~(1 << (261 & 0x7));
  break;
 case 258:
 case 259:
 case 260:
  vdevice.mouseevents = 1;
  vdevice.enabled[dev / 8] |= 1 << (dev & 0x7);
  break;
 case '-':
  vdevice.kbdevents = 1;
  vdevice.enabled['-' / 8] |= 1 << ('-' & 0x7);
  vdevice.enabled['_' / 8] |= 1 << ('_' & 0x7);
  break;
 case '\\':
  vdevice.kbdevents = 1;
  vdevice.enabled['\\' / 8] |= 1 << ('\\' & 0x7);
  vdevice.enabled['|' / 8] |= 1 << ('|' & 0x7);
  break;
 case '=':
  vdevice.kbdevents = 1;
  vdevice.enabled['=' / 8] |= 1 << ('=' & 0x7);
  vdevice.enabled['+' / 8] |= 1 << ('+' & 0x7);
  break;
 case '[':
  vdevice.kbdevents = 1;
  vdevice.enabled['[' / 8] |= 1 << ('[' & 0x7);
  vdevice.enabled['{' / 8] |= 1 << ('{' & 0x7);
  break;
 case ']':
  vdevice.kbdevents = 1;
  vdevice.enabled[']' / 8] |= 1 << (']' & 0x7);
  vdevice.enabled['}' / 8] |= 1 << ('}' & 0x7);
  break;
 case 262:
  break;
 case 261:
 default:
  vdevice.kbdevents = 1;
  vdevice.enabled[dev / 8] |= 1 << (dev & 0x7);
 }
}

canonical_original_code:
void qdevice(unsigned short dev)
{
 int i; int redraw_enabled;
 if (!vdevice.initialised)
  verror("qdevice: vogl not initialised\n");
 if (dev > (unsigned short)262)
  verror("qdevice: bad device number passed\n");
 switch (dev) {
 case 'A':
 case 'B':
 case 'C':
 case 'D':
 case 'E':
 case 'F':
 case 'G':
 case 'H':
 case 'I':
 case 'J':
 case 'K':
 case 'L':
 case 'M':
 case 'N':
 case 'O':
 case 'P':
 case 'Q':
 case 'R':
 case 'S':
 case 'T':
 case 'U':
 case 'V':
 case 'W':
 case 'X':
 case 'Y':
 case 'Z':
  vdevice.kbdevents = 1;
  vdevice.enabled[dev / 8] |= 1 << (dev & 0x7);
  vdevice.enabled[(int)(dev - 'A' + 'a') / 8] |= 1 << ((dev - 'A' + 'a') & 0x7);
  break;
 case 257:
  vdevice.kbdmode = 1;
  vdevice.kbdevents = 1;
  redraw_enabled = (vdevice.enabled[261 / 8] & (1 << (261 & 0x7)));
  for (i = 0; i != 34; i++)
   vdevice.enabled[i] = 0xff;
  vdevice.enabled[0] &= 0xfe;
  if (!redraw_enabled)
   vdevice.enabled[261 / 8] &= ~(1 << (261 & 0x7));
  break;
 case 258:
 case 259:
 case 260:
  vdevice.mouseevents = 1;
  vdevice.enabled[dev / 8] |= 1 << (dev & 0x7);
  break;
 case '-':
  vdevice.kbdevents = 1;
  vdevice.enabled['-' / 8] |= 1 << ('-' & 0x7);
  vdevice.enabled['_' / 8] |= 1 << ('_' & 0x7);
  break;
 case '\\':
  vdevice.kbdevents = 1;
  vdevice.enabled['\\' / 8] |= 1 << ('\\' & 0x7);
  vdevice.enabled['|' / 8] |= 1 << ('|' & 0x7);
  break;
 case '=':
  vdevice.kbdevents = 1;
  vdevice.enabled['=' / 8] |= 1 << ('=' & 0x7);
  vdevice.enabled['+' / 8] |= 1 << ('+' & 0x7);
  break;
 case '[':
  vdevice.kbdevents = 1;
  vdevice.enabled['[' / 8] |= 1 << ('[' & 0x7);
  vdevice.enabled['{' / 8] |= 1 << ('{' & 0x7);
  break;
 case ']':
  vdevice.kbdevents = 1;
  vdevice.enabled[']' / 8] |= 1 << (']' & 0x7);
  vdevice.enabled['}' / 8] |= 1 << ('}' & 0x7);
  break;
 case 262:
  break;
 case 261:
 default:
  vdevice.kbdevents = 1;
  vdevice.enabled[dev / 8] |= 1 << (dev & 0x7);
 }
}

variable_types:
dev
unsigned short

variable_types: i int


unqdevice

decompiled_code:
char *__fastcall unqdevice(const char *a1)
{
char *result; // rax
__int64 i; // rax
_BYTE *v3; // rax
_BYTE *v4; // rax
__int64 v5; // rcx
int v6; // edx
_BYTE *v7; // rax

result = (char *)&vdevice;
if ( !vdevice )
{
verror("qdevice: vogl not initialised\n");
goto LABEL_7;
}
if ( (unsigned __int16)a1 > 0x106u )
{
LABEL_7:
a1 = "qdevice: bad device number passed\n";
result = (char *)verror("qdevice: bad device number passed\n");
goto LABEL_8;
}
if ( (unsigned __int16)a1 <= 0x5Du )
{
if ( (unsigned __int16)a1 > 0x2Cu )
{
switch ( (__int16)a1 )
{
case '-':
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 5LL) &= 0xDFu;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 11LL) &= 0x7Fu;
break;
case '=':
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 7LL) &= 0xDFu;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 5LL) &= 0xF7u;
break;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
v3 = (_BYTE *)(*((_QWORD *)&vdevice + 64) + ((unsigned __int16)a1 >> 3));
*v3 &= ~(1 << ((unsigned __int8)a1 & 7));
v4 = (_BYTE *)(*((_QWORD *)&vdevice + 64) + (((unsigned __int16)a1 + 32) >> 3));
*v4 &= ~(1 << ((unsigned __int8)a1 & 7));
break;
case '[':
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 11LL) &= 0xF7u;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 15LL) &= 0xF7u;
break;
case '\\':
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 11LL) &= 0xEFu;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 15LL) &= 0xEFu;
break;
case ']':
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 11LL) &= 0xDFu;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 15LL) &= 0xDFu;
break;
default:
goto LABEL_24;
}
goto LABEL_17;
}
goto LABEL_24;
}
LABEL_8:
if ( (unsigned __int16)a1 <= 0x104u )
{
if ( (unsigned __int16)a1 > 0x101u )
{
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 32LL) &= ~(1 << ((unsigned __int8)a1 & 7));
LABEL_17:
*((_BYTE *)&vdevice + 527) = 0;
*((_BYTE *)&vdevice + 526) = 0;
v5 = *((_QWORD *)&vdevice + 64);
v6 = 1;
for ( result = 0LL; ; ++result )
{
if ( result[v5] )
{
if ( (int)result <= 31 )
{
*((_BYTE *)&vdevice + 527) = 1;
goto LABEL_27;
}
*((_BYTE *)&vdevice + 526) = 1;
}
if ( v6 == 34 )
return result;
LABEL_27:
++v6;
}
}
if ( (_WORD)a1 == 257 )
{
*((_BYTE *)&vdevice + 525) = 0;
for ( i = 0LL; i != 34; ++i )
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + i) = 0;
goto LABEL_17;
}
LABEL_24:
v7 = (_BYTE *)(*((_QWORD *)&vdevice + 64) + ((unsigned __int16)a1 >> 3));
*v7 &= ~(1 << ((unsigned __int8)a1 & 7));
goto LABEL_17;
}
if ( (_WORD)a1 != 262 )
goto LABEL_24;
return result;
}

canonical_decompiled_code:
char *__fastcall func1(const char *a1)
{
char *result; // rax
__int64 i; // rax
_BYTE *v3; // rax
_BYTE *v4; // rax
__int64 v5; // rcx
int v6; // edx
_BYTE *v7; // rax

result = (char *)&vdevice;
if ( !vdevice )
{
verror("qdevice: vogl not initialised\n");
goto LABEL_7;
}
if ( (unsigned __int16)a1 > 0x106u )
{
LABEL_7:
a1 = "qdevice: bad device number passed\n";
result = (char *)verror("qdevice: bad device number passed\n");
goto LABEL_8;
}
if ( (unsigned __int16)a1 <= 0x5Du )
{
if ( (unsigned __int16)a1 > 0x2Cu )
{
switch ( (__int16)a1 )
{
case '-':
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 5LL) &= 0xDFu;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 11LL) &= 0x7Fu;
break;
case '=':
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 7LL) &= 0xDFu;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 5LL) &= 0xF7u;
break;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'G':
case 'H':
case 'I':
case 'J':
case 'K':
case 'L':
case 'M':
case 'N':
case 'O':
case 'P':
case 'Q':
case 'R':
case 'S':
case 'T':
case 'U':
case 'V':
case 'W':
case 'X':
case 'Y':
case 'Z':
v3 = (_BYTE *)(*((_QWORD *)&vdevice + 64) + ((unsigned __int16)a1 >> 3));
*v3 &= ~(1 << ((unsigned __int8)a1 & 7));
v4 = (_BYTE *)(*((_QWORD *)&vdevice + 64) + (((unsigned __int16)a1 + 32) >> 3));
*v4 &= ~(1 << ((unsigned __int8)a1 & 7));
break;
case '[':
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 11LL) &= 0xF7u;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 15LL) &= 0xF7u;
break;
case '\\':
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 11LL) &= 0xEFu;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 15LL) &= 0xEFu;
break;
case ']':
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 11LL) &= 0xDFu;
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 15LL) &= 0xDFu;
break;
default:
goto LABEL_24;
}
goto LABEL_17;
}
goto LABEL_24;
}
LABEL_8:
if ( (unsigned __int16)a1 <= 0x104u )
{
if ( (unsigned __int16)a1 > 0x101u )
{
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + 32LL) &= ~(1 << ((unsigned __int8)a1 & 7));
LABEL_17:
*((_BYTE *)&vdevice + 527) = 0;
*((_BYTE *)&vdevice + 526) = 0;
v5 = *((_QWORD *)&vdevice + 64);
v6 = 1;
for ( result = 0LL; ; ++result )
{
if ( result[v5] )
{
if ( (int)result <= 31 )
{
*((_BYTE *)&vdevice + 527) = 1;
goto LABEL_27;
}
*((_BYTE *)&vdevice + 526) = 1;
}
if ( v6 == 34 )
return result;
LABEL_27:
++v6;
}
}
if ( (_WORD)a1 == 257 )
{
*((_BYTE *)&vdevice + 525) = 0;
for ( i = 0LL; i != 34; ++i )
*(_BYTE *)(*((_QWORD *)&vdevice + 64) + i) = 0;
goto LABEL_17;
}
LABEL_24:
v7 = (_BYTE *)(*((_QWORD *)&vdevice + 64) + ((unsigned __int16)a1 >> 3));
*v7 &= ~(1 << ((unsigned __int8)a1 & 7));
goto LABEL_17;
}
if ( (_WORD)a1 != 262 )
goto LABEL_24;
return result;
}

original_code:
void
unqdevice(Device dev)
{
 int i;
 if (!vdevice.initialised)
  verror("qdevice: vogl not initialised\n");
 if (dev > (Device)262)
  verror("qdevice: bad device number passed\n");
 switch (dev) {
 case 'A':
 case 'B':
 case 'C':
 case 'D':
 case 'E':
 case 'F':
 case 'G':
 case 'H':
 case 'I':
 case 'J':
 case 'K':
 case 'L':
 case 'M':
 case 'N':
 case 'O':
 case 'P':
 case 'Q':
 case 'R':
 case 'S':
 case 'T':
 case 'U':
 case 'V':
 case 'W':
 case 'X':
 case 'Y':
 case 'Z':
  vdevice.enabled[dev / 8] &= ~(1 << (dev & 0x7));
  vdevice.enabled[(int)(dev - 'A' + 'a') / 8] &= ~(1 << ((dev - 'A' + 'a') & 0x7));
  break;
 case 257:
  vdevice.kbdmode = 0;
  for (i = 0; i != 34; i++)
   vdevice.enabled[i] = 0x00;
  break;
 case 258:
 case 259:
 case 260:
  vdevice.enabled[dev / 8] &= ~(1 << (dev & 0x7));
  break;
 case '-':
  vdevice.enabled['-' / 8] &= ~(1 << ('-' & 0x7));
  vdevice.enabled['_' / 8] &= ~(1 << ('_' & 0x7));
  break;
 case '\\':
  vdevice.enabled['\\' / 8] &= ~(1 << ('\\' & 0x7));
  vdevice.enabled['|' / 8] &= ~(1 << ('|' & 0x7));
  break;
 case '=':
  vdevice.enabled['=' / 8] &= ~(1 << ('=' & 0x7));
  vdevice.enabled['+' / 8] &= ~(1 << ('+' & 0x7));
  break;
 case '[':
  vdevice.enabled['[' / 8] &= ~(1 << ('[' & 0x7));
  vdevice.enabled['{' / 8] &= ~(1 << ('{' & 0x7));
  break;
 case ']':
  vdevice.enabled[']' / 8] &= ~(1 << (']' & 0x7));
  vdevice.enabled['}' / 8] &= ~(1 << ('}' & 0x7));
  break;
 case 262:
  return;
 default:
  vdevice.enabled[dev / 8] &= ~(1 << (dev & 0x7));
 }
 vdevice.mouseevents = vdevice.kbdevents = 0;
 for (i = 0; i != 34; i++)
  if (vdevice.enabled[i] != 0) {
   if (i < 32)
    vdevice.kbdevents = 1;
   else
    vdevice.mouseevents = 1;
  }
}

canonical_original_code:
void unqdevice(unsigned short dev)
{
 int i;
 if (!vdevice.initialised)
  verror("qdevice: vogl not initialised\n");
 if (dev > (unsigned short)262)
  verror("qdevice: bad device number passed\n");
 switch (dev) {
 case 'A':
 case 'B':
 case 'C':
 case 'D':
 case 'E':
 case 'F':
 case 'G':
 case 'H':
 case 'I':
 case 'J':
 case 'K':
 case 'L':
 case 'M':
 case 'N':
 case 'O':
 case 'P':
 case 'Q':
 case 'R':
 case 'S':
 case 'T':
 case 'U':
 case 'V':
 case 'W':
 case 'X':
 case 'Y':
 case 'Z':
  vdevice.enabled[dev / 8] &= ~(1 << (dev & 0x7));
  vdevice.enabled[(int)(dev - 'A' + 'a') / 8] &= ~(1 << ((dev - 'A' + 'a') & 0x7));
  break;
 case 257:
  vdevice.kbdmode = 0;
  for (i = 0; i != 34; i++)
   vdevice.enabled[i] = 0x00;
  break;
 case 258:
 case 259:
 case 260:
  vdevice.enabled[dev / 8] &= ~(1 << (dev & 0x7));
  break;
 case '-':
  vdevice.enabled['-' / 8] &= ~(1 << ('-' & 0x7));
  vdevice.enabled['_' / 8] &= ~(1 << ('_' & 0x7));
  break;
 case '\\':
  vdevice.enabled['\\' / 8] &= ~(1 << ('\\' & 0x7));
  vdevice.enabled['|' / 8] &= ~(1 << ('|' & 0x7));
  break;
 case '=':
  vdevice.enabled['=' / 8] &= ~(1 << ('=' & 0x7));
  vdevice.enabled['+' / 8] &= ~(1 << ('+' & 0x7));
  break;
 case '[':
  vdevice.enabled['[' / 8] &= ~(1 << ('[' & 0x7));
  vdevice.enabled['{' / 8] &= ~(1 << ('{' & 0x7));
  break;
 case ']':
  vdevice.enabled[']' / 8] &= ~(1 << (']' & 0x7));
  vdevice.enabled['}' / 8] &= ~(1 << ('}' & 0x7));
  break;
 case 262:
  return;
 default:
  vdevice.enabled[dev / 8] &= ~(1 << (dev & 0x7));
 }
 vdevice.mouseevents = vdevice.kbdevents = 0;
 for (i = 0; i != 34; i++)
  if (vdevice.enabled[i] != 0) {
   if (i < 32)
    vdevice.kbdevents = 1;
   else
    vdevice.mouseevents = 1;
  }
}


qread

original_code:
long
qread(short int *ret)
{
 int a, b, c1, c2, val;
 int eventind, eventmask, retvalue;
 if (!vdevice.initialised)
  verror("qread: vogl not initialised\n");
 if (vdevice.alreadyread) {
  eventind = vdevice.devno / 8;
  eventmask = 1 << (vdevice.devno & 0x7);
  if (vdevice.enabled[eventind] & eventmask) {
   *ret = vdevice.data;
   if (!vdevice.kbdmode && vdevice.data == 1)
    vdevice.data = 0;
   else
    vdevice.alreadyread = 0;
   return(vdevice.devno);
  }
 }
 val = c1 = c2 = 0;
 eventind = 0;
 eventmask = 0;
 if (!vdevice.mouseevents && vdevice.kbdevents) {
  while (!(vdevice.enabled[eventind] & eventmask)) {
   if ((val = c1 = (*vdevice.dev.Vgetkey)()) < 0)
    return(val);
   eventind = c1 / 8;
   eventmask = 1 << (c1 & 0x7);
   *ret = c1;
   if (c1 >= 'a' && c1 <= 'z')
    retvalue = c1 - 'a' + 'A';
   else
    retvalue = c1;
  }
 } else if (vdevice.mouseevents && !vdevice.kbdevents) {
  while (!(vdevice.enabled[eventind] & eventmask)) {
   if ((c2 = (*vdevice.dev.Vlocator)(&a, &b)) < 0)
    return(c2);
   if (c2 != 0) {
    if (c2 & 0x01)
     c2 = 260;
    else if (c2 & 0x02)
     c2 = 259;
    else if (c2 & 0x04)
     c2 = 258;
    eventind = c2 / 8;
    eventmask = 1 << (c2 & 0x7);
    *ret = c2;
    retvalue = c2;
   }
  }
 } else if (vdevice.mouseevents && vdevice.kbdevents) {
  while (!(vdevice.enabled[eventind] & eventmask)) {
   while (c1 == 0 && c2 == 0) {
    val = c1 = (*vdevice.dev.Vcheckkey)();
    c2 = (*vdevice.dev.Vlocator)(&a, &b);
   }
   if (c1 < 0 && c2 < 0)
    return(-1);
   if (c1 != 0) {
    eventind = c1 / 8;
    eventmask = 1 << (c1 & 0x7);
    *ret = c1;
    if (c1 >= 'a' && c1 <= 'z')
     retvalue = c1 - 'a' + 'A';
    else
     retvalue = c1;
   } else {
    if (c2 & 0x01)
     c2 = 260;
    else if (c2 & 0x02)
     c2 = 259;
    else if (c2 & 0x04)
     c2 = 258;
    eventind = c2 / 8;
    eventmask = 1 << (c2 & 0x7);
    *ret = c2;
    retvalue = c2;
   }
   c1 = c2 = 0;
  }
 } else
  return(-1);
 if (vdevice.kbdmode && val != 0) {
  *ret = val;
  return(257);
 } else {
  *ret = 1;
  vdevice.data = 0;
  vdevice.devno = retvalue;
  vdevice.alreadyread = 1;
 }
 return(retvalue);
}

canonical_original_code:
long qread(short *ret)
{
 int a; int b; int c1; int c2; int val;
 int eventind; int eventmask; int retvalue;
 if (!vdevice.initialised)
  verror("qread: vogl not initialised\n");
 if (vdevice.alreadyread) {
  eventind = vdevice.devno / 8;
  eventmask = 1 << (vdevice.devno & 0x7);
  if (vdevice.enabled[eventind] & eventmask) {
   *ret = vdevice.data;
   if (!vdevice.kbdmode && vdevice.data == 1)
    vdevice.data = 0;
   else
    vdevice.alreadyread = 0;
   return(vdevice.devno);
  }
 }
 val = c1 = c2 = 0;
 eventind = 0;
 eventmask = 0;
 if (!vdevice.mouseevents && vdevice.kbdevents) {
  while (!(vdevice.enabled[eventind] & eventmask)) {
   if ((val = c1 = (*vdevice.dev.Vgetkey)()) < 0)
    return(val);
   eventind = c1 / 8;
   eventmask = 1 << (c1 & 0x7);
   *ret = c1;
   if (c1 >= 'a' && c1 <= 'z')
    retvalue = c1 - 'a' + 'A';
   else
    retvalue = c1;
  }
 } else if (vdevice.mouseevents && !vdevice.kbdevents) {
  while (!(vdevice.enabled[eventind] & eventmask)) {
   if ((c2 = (*vdevice.dev.Vlocator)(&a, &b)) < 0)
    return(c2);
   if (c2 != 0) {
    if (c2 & 0x01)
     c2 = 260;
    else if (c2 & 0x02)
     c2 = 259;
    else if (c2 & 0x04)
     c2 = 258;
    eventind = c2 / 8;
    eventmask = 1 << (c2 & 0x7);
    *ret = c2;
    retvalue = c2;
   }
  }
 } else if (vdevice.mouseevents && vdevice.kbdevents) {
  while (!(vdevice.enabled[eventind] & eventmask)) {
   while (c1 == 0 && c2 == 0) {
    val = c1 = (*vdevice.dev.Vcheckkey)();
    c2 = (*vdevice.dev.Vlocator)(&a, &b);
   }
   if (c1 < 0 && c2 < 0)
    return(-1);
   if (c1 != 0) {
    eventind = c1 / 8;
    eventmask = 1 << (c1 & 0x7);
    *ret = c1;
    if (c1 >= 'a' && c1 <= 'z')
     retvalue = c1 - 'a' + 'A';
    else
     retvalue = c1;
   } else {
    if (c2 & 0x01)
     c2 = 260;
    else if (c2 & 0x02)
     c2 = 259;
    else if (c2 & 0x04)
     c2 = 258;
    eventind = c2 / 8;
    eventmask = 1 << (c2 & 0x7);
    *ret = c2;
    retvalue = c2;
   }
   c1 = c2 = 0;
  }
 } else
  return(-1);
 if (vdevice.kbdmode && val != 0) {
  *ret = val;
  return(257);
 } else {
  *ret = 1;
  vdevice.data = 0;
  vdevice.devno = retvalue;
  vdevice.alreadyread = 1;
 }
 return(retvalue);
}

variable_types:
ret
short *

variable_types: a int

variable_types: b int

variable_types: val int

variable_types: eventind int

variable_types: eventmask int

variable_types: retvalue int

return_type: long


qreset

decompiled_code:
void *qreset()
{
void *result; // rax

while ( (*((unsigned int (**)(void))&vdevice + 24))() )
;
result = &vdevice;
*((_BYTE *)&vdevice + 524) = 0;
return result;
}

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

while ( (*((unsigned int (**)(void))&vdevice + 24))() )
;
result = &vdevice;
*((_BYTE *)&vdevice + 524) = 0;
return result;
}

original_code:
void
qreset(void)
{
 while (((*vdevice.dev.Vcheckkey)()))
  ;
 vdevice.alreadyread = 0;
}

canonical_original_code:
void qreset()
{
 while (((*vdevice.dev.Vcheckkey)()))
  ;
 vdevice.alreadyread = 0;
}


qtest

original_code:
long
qtest(void)
{
 int a, b, c1, c2, val;
 int eventind, eventmask;
 if (!vdevice.initialised)
  verror("qtest: vogl not initialised\n");
 if (vdevice.alreadyread)
  return((long)vdevice.devno);
 eventind = 0;
 eventmask = 0;
 val = c1 = (*vdevice.dev.Vcheckkey)();
 c2 = (*vdevice.dev.Vlocator)(&a, &b);
 if (c1 != 0) {
  eventind = c1 / 8;
  eventmask = 1 << (c1 & 0x7);
  if (vdevice.kbdmode) {
   vdevice.data = val;
   vdevice.devno = 257;
  } else {
   vdevice.data = 1;
   if (c1 >= 'a' && c1 <= 'z')
    vdevice.devno = c1 - 'a' + 'A';
   else
    vdevice.devno = c1;
  }
 } else {
  if (c2 & 0x01)
   c2 = 260;
  else if (c2 & 0x02)
   c2 = 259;
  else if (c2 & 0x04)
   c2 = 258;
  eventind = c2 / 8;
  eventmask = 1 << (c2 & 0x7);
  vdevice.data = 1;
  vdevice.devno = c2;
 }
 if (vdevice.enabled[eventind] & eventmask) {
  vdevice.alreadyread = 1;
  return(1L);
 }
 return(0L);
}

canonical_original_code:
long qtest()
{
 int a; int b; int c1; int c2; int val;
 int eventind; int eventmask;
 if (!vdevice.initialised)
  verror("qtest: vogl not initialised\n");
 if (vdevice.alreadyread)
  return((long)vdevice.devno);
 eventind = 0;
 eventmask = 0;
 val = c1 = (*vdevice.dev.Vcheckkey)();
 c2 = (*vdevice.dev.Vlocator)(&a, &b);
 if (c1 != 0) {
  eventind = c1 / 8;
  eventmask = 1 << (c1 & 0x7);
  if (vdevice.kbdmode) {
   vdevice.data = val;
   vdevice.devno = 257;
  } else {
   vdevice.data = 1;
   if (c1 >= 'a' && c1 <= 'z')
    vdevice.devno = c1 - 'a' + 'A';
   else
    vdevice.devno = c1;
  }
 } else {
  if (c2 & 0x01)
   c2 = 260;
  else if (c2 & 0x02)
   c2 = 259;
  else if (c2 & 0x04)
   c2 = 258;
  eventind = c2 / 8;
  eventmask = 1 << (c2 & 0x7);
  vdevice.data = 1;
  vdevice.devno = c2;
 }
 if (vdevice.enabled[eventind] & eventmask) {
  vdevice.alreadyread = 1;
  return(1L);
 }
 return(0L);
}


isqueued

decompiled_code:
unsigned __int64 __fastcall isqueued(unsigned __int16 a1)
{
return *(char *)(vdevice[64] + (a1 >> 3)) & (unsigned __int64)(1 << (a1 & 7));
}

canonical_decompiled_code:
unsigned __int64 __fastcall func5(unsigned __int16 a1)
{
return *(char *)(vdevice[64] + (a1 >> 3)) & (unsigned __int64)(1 << (a1 & 7));
}

original_code:
Boolean
isqueued(Device dev)
{
 return((long)vdevice.enabled[dev / 8] & (1 << (dev & 0x7)));
}

canonical_original_code:
long isqueued(unsigned short dev)
{
 return((long)vdevice.enabled[dev / 8] & (1 << (dev & 0x7)));
}


qenter

decompiled_code:
void qenter()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void
qenter(Device dev, short int val)
{
}

canonical_original_code:
void qenter(unsigned short dev, short val)
{
}

variable_types: val short


charstr

decompiled_code:
__int64 __fastcall charstr(char *src)
{
size_t v1; // r12
char v2; // si
int v3; // er14
int v4; // er13
int v5; // edx
int v6; // ecx
__int64 result; // rax
__int64 v8; // rax
char *v9; // rbx
char i; // di
int v11; // eax

v1 = strlen(src);
if ( !vdevice )
{
verror("charstr: vogl not initialized");
goto LABEL_11;
}
if ( *((_BYTE *)&vdevice + 2) )
{
LABEL_11:
v8 = newtokens((unsigned int)(v1 >> 2) + 2);
*(_DWORD *)v8 = 10;
return (__int64)strcpy((char *)(v8 + 4), src);
}
v2 = *((_BYTE *)&vdevice + 1);
sync = *((char *)&vdevice + 6);
if ( sync )
*((_BYTE *)&vdevice + 6) = 0;
v3 = *((_DWORD *)&vdevice + 35);
v4 = *((_DWORD *)&vdevice + 36);
v5 = sc_x;
*((_DWORD *)&vdevice + 35) = sc_x;
v6 = sc_y;
*((_DWORD *)&vdevice + 36) = sc_y;
if ( v2
|| v5 > *((_DWORD *)&vdevice + 28)
&& *((_DWORD *)&vdevice + 29) > v6 - (int)*((float *)&vdevice + 12)
&& v6 > *((_DWORD *)&vdevice + 30)
&& *((_DWORD *)&vdevice + 27) > (int)(float)((float)((int)v1 + 1) * *((float *)&vdevice + 13)) + v5 )
{
(*((void (__fastcall **)(char *))&vdevice + 38))(src);
}
else
{
v9 = src + 1;
for ( i = *src; i; i = *(v9 - 1) )
{
v11 = *((_DWORD *)&vdevice + 35);
if ( v11 > *((_DWORD *)&vdevice + 28) && v11 < *((_DWORD *)&vdevice + 27) - (int)*((float *)&vdevice + 13) )
(*((void (__fastcall **)(_QWORD))&vdevice + 23))((unsigned int)i);
*((_DWORD *)&vdevice + 35) += (int)*((float *)&vdevice + 13);
++v9;
}
}
result = (unsigned int)(int)*((float *)&vdevice + 13);
sc_x += result * v1;
*((_DWORD *)&vdevice + 35) = v3;
*((_DWORD *)&vdevice + 36) = v4;
if ( sync )
{
*((_BYTE *)&vdevice + 6) = 1;
result = (*((__int64 (**)(void))&vdevice + 41))();
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *src)
{
size_t v1; // r12
char v2; // si
int v3; // er14
int v4; // er13
int v5; // edx
int v6; // ecx
__int64 result; // rax
__int64 v8; // rax
char *v9; // rbx
char i; // di
int v11; // eax

v1 = strlen(src);
if ( !vdevice )
{
verror("charstr: vogl not initialized");
goto LABEL_11;
}
if ( *((_BYTE *)&vdevice + 2) )
{
LABEL_11:
v8 = newtokens((unsigned int)(v1 >> 2) + 2);
*(_DWORD *)v8 = 10;
return (__int64)strcpy((char *)(v8 + 4), src);
}
v2 = *((_BYTE *)&vdevice + 1);
sync = *((char *)&vdevice + 6);
if ( sync )
*((_BYTE *)&vdevice + 6) = 0;
v3 = *((_DWORD *)&vdevice + 35);
v4 = *((_DWORD *)&vdevice + 36);
v5 = sc_x;
*((_DWORD *)&vdevice + 35) = sc_x;
v6 = sc_y;
*((_DWORD *)&vdevice + 36) = sc_y;
if ( v2
|| v5 > *((_DWORD *)&vdevice + 28)
&& *((_DWORD *)&vdevice + 29) > v6 - (int)*((float *)&vdevice + 12)
&& v6 > *((_DWORD *)&vdevice + 30)
&& *((_DWORD *)&vdevice + 27) > (int)(float)((float)((int)v1 + 1) * *((float *)&vdevice + 13)) + v5 )
{
(*((void (__fastcall **)(char *))&vdevice + 38))(src);
}
else
{
v9 = src + 1;
for ( i = *src; i; i = *(v9 - 1) )
{
v11 = *((_DWORD *)&vdevice + 35);
if ( v11 > *((_DWORD *)&vdevice + 28) && v11 < *((_DWORD *)&vdevice + 27) - (int)*((float *)&vdevice + 13) )
(*((void (__fastcall **)(_QWORD))&vdevice + 23))((unsigned int)i);
*((_DWORD *)&vdevice + 35) += (int)*((float *)&vdevice + 13);
++v9;
}
}
result = (unsigned int)(int)*((float *)&vdevice + 13);
sc_x += result * v1;
*((_DWORD *)&vdevice + 35) = v3;
*((_DWORD *)&vdevice + 36) = v4;
if ( sync )
{
*((_BYTE *)&vdevice + 6) = 1;
result = (*((__int64 (**)(void))&vdevice + 41))();
}
return result;
}

original_code:
void
charstr(const char *str)
{
 int cx, cy;
 char c;
 Token *tok;
 int oldclipoff = vdevice.clipoff;
 int sl = strlen(str);
 if(!vdevice.initialised)
  verror("charstr: vogl not initialized");
 if (vdevice.inobject) {
  tok = newtokens(2 + strlen(str) / sizeof(Token));
  tok[0].i = 10;
  strcpy((char *)&tok[1], str);
  return;
 }
 if ((sync = vdevice.sync)!=0)
  vdevice.sync = 0;
 cx = vdevice.cpVx;
 cy = vdevice.cpVy;
 vdevice.cpVx = sc_x;
 vdevice.cpVy = sc_y;
 if (oldclipoff) {
  (*vdevice.dev.Vstring)(str);
 } else {
  int left_s = vdevice.cpVx;
  int bottom_s = vdevice.cpVy - (int)vdevice.hheight;
  int top_s = bottom_s + (int)vdevice.hheight;
  int right_s = left_s + (int)((sl + 1) * vdevice.hwidth);
  if (left_s > vdevice.minVx &&
      bottom_s < vdevice.maxVy &&
      top_s > vdevice.minVy &&
      right_s < vdevice.maxVx) {
   (*vdevice.dev.Vstring)(str);
  } else {
   while ((c = *str++)) {
    if (vdevice.cpVx > vdevice.minVx &&
        vdevice.cpVx < vdevice.maxVx - (int)vdevice.hwidth) {
     (*vdevice.dev.Vchar)(c);
    }
    vdevice.cpVx += (int)vdevice.hwidth;
   }
  }
 }
 sc_x += sl * (int)vdevice.hwidth;
 vdevice.cpVx = cx;
 vdevice.cpVy = cy;
 if (sync) {
  vdevice.sync = 1;
  (*vdevice.dev.Vsync)();
 }
}

canonical_original_code:
void charstr(char *str)
{
 int cx; int cy;
 char c;
 union tk *tok;
 int oldclipoff = vdevice.clipoff;
 int sl = strlen(str);
 if(!vdevice.initialised)
  verror("charstr: vogl not initialized");
 if (vdevice.inobject) {
  tok = newtokens(2 + strlen(str) / sizeof(Token));
  tok[0].i = 10;
  strcpy((char *)&tok[1], str);
  return;
 }
 if ((sync = vdevice.sync)!=0)
  vdevice.sync = 0;
 cx = vdevice.cpVx;
 cy = vdevice.cpVy;
 vdevice.cpVx = sc_x;
 vdevice.cpVy = sc_y;
 if (oldclipoff) {
  (*vdevice.dev.Vstring)(str);
 } else {
  int left_s = vdevice.cpVx;
  int bottom_s = vdevice.cpVy - (int)vdevice.hheight;
  int top_s = bottom_s + (int)vdevice.hheight;
  int right_s = left_s + (int)((sl + 1) * vdevice.hwidth);
  if (left_s > vdevice.minVx &&
      bottom_s < vdevice.maxVy &&
      top_s > vdevice.minVy &&
      right_s < vdevice.maxVx) {
   (*vdevice.dev.Vstring)(str);
  } else {
   while ((c = *str++)) {
    if (vdevice.cpVx > vdevice.minVx &&
        vdevice.cpVx < vdevice.maxVx - (int)vdevice.hwidth) {
     (*vdevice.dev.Vchar)(c);
    }
    vdevice.cpVx += (int)vdevice.hwidth;
   }
  }
 }
 sc_x += sl * (int)vdevice.hwidth;
 vdevice.cpVx = cx;
 vdevice.cpVy = cy;
 if (sync) {
  vdevice.sync = 1;
  (*vdevice.dev.Vsync)();
 }
}

variable_types:
str
char *

variable_types: cx int

variable_types: cy int

variable_types: c char

variable_types:
tok
union tk { int i; float f; } *

variable_types: oldclipoff int

variable_types: sl int


strwidth

decompiled_code:
__int64 __fastcall strwidth(const char *a1)
{
size_t v1; // rax
float v2; // xmm0_4

v1 = strlen(a1);
if ( (v1 & 0x8000000000000000LL) != 0LL )
v2 = (float)(int)(v1 & 1 | (v1 >> 1)) + (float)(int)(v1 & 1 | (v1 >> 1));
else
v2 = (float)(int)v1;
return (unsigned int)(int)(float)(v2 * vdevice[13]);
}

canonical_decompiled_code:
__int64 __fastcall func1(const char *a1)
{
size_t v1; // rax
float v2; // xmm0_4

v1 = strlen(a1);
if ( (v1 & 0x8000000000000000LL) != 0LL )
v2 = (float)(int)(v1 & 1 | (v1 >> 1)) + (float)(int)(v1 & 1 | (v1 >> 1));
else
v2 = (float)(int)v1;
return (unsigned int)(int)(float)(v2 * vdevice[13]);
}

original_code:
long
strwidth(char *s)
{
 return((long)(strlen(s) * vdevice.hwidth));
}

variable_types:
s
char *


getheight

decompiled_code:
__int64 getheight()
{
if ( LOBYTE(vdevice[0]) )
return (unsigned int)(int)vdevice[12];
verror("getheight: vogl not initialized");
return getwidth();
}

canonical_decompiled_code:
__int64 func2()
{
if ( LOBYTE(vdevice[0]) )
return (unsigned int)(int)vdevice[12];
verror("getheight: vogl not initialized");
return func3();
}

original_code:
long
getheight(void)
{
 if (!vdevice.initialised)
  verror("getheight: vogl not initialized");
 return((long)vdevice.hheight);
}

canonical_original_code:
long getheight()
{
 if (!vdevice.initialised)
  verror("getheight: vogl not initialized");
 return((long)vdevice.hheight);
}


getwidth

decompiled_code:
__int64 getwidth()
{
if ( LOBYTE(vdevice[0]) )
return (unsigned int)(int)vdevice[13];
verror("getwidth: vogl not initialised");
return getcpos();
}

canonical_decompiled_code:
__int64 func3()
{
if ( LOBYTE(vdevice[0]) )
return (unsigned int)(int)vdevice[13];
verror("getwidth: vogl not initialised");
return func4();
}

original_code:
long
getwidth(void)
{
 if (!vdevice.initialised)
  verror("getwidth: vogl not initialised");
 return((long)vdevice.hwidth);
}

canonical_original_code:
long getwidth()
{
 if (!vdevice.initialised)
  verror("getwidth: vogl not initialised");
 return((long)vdevice.hwidth);
}


pnt

decompiled_code:
__int64 __fastcall pnt(int a1, int a2, float a3, float a4, float a5)
{
__int64 result; // rax

if ( vdevice )
{
move(a1, a2);
result = draw(a3, a4, a5);
}
else
{
verror("pnt: vogl not initialised");
result = pnts();
}
return result;
}

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

if ( vdevice )
{
move(a1, a2);
result = draw(a3, a4, a5);
}
else
{
verror("pnt: vogl not initialised");
result = func1();
}
return result;
}

original_code:
void
pnt(float x, float y, float z)
{
 if(!vdevice.initialised)
  verror("pnt: vogl not initialised");
 move(x, y, z);
 draw(x, y, z);
}

variable_types: x float

variable_types: y float

variable_types: z float


pnts

decompiled_code:
__int64 __fastcall pnts(__int16 a1, __int16 a2, int a3)
{
return pnt(a1, a2, (float)a1, (float)a2, (float)a3);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int16 a1, __int16 a2, int a3)
{
return func0(a1, a2, (float)a1, (float)a2, (float)a3);
}

original_code:
void
pnts(Scoord x, Scoord y, int z)
{
 pnt((Coord)x, (Coord)y, (Coord)z);
}

canonical_original_code:
void pnts(short x, short y, int z)
{
 pnt((float)x, (float)y, (float)z);
}

variable_types: x short

variable_types: y short

variable_types: z int


pnti

decompiled_code:
__int64 __fastcall pnti(int a1, int a2, int a3)
{
return pnt(a1, a2, (float)a1, (float)a2, (float)a3);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2, int a3)
{
return func0(a1, a2, (float)a1, (float)a2, (float)a3);
}

original_code:
void
pnti(Icoord x, Icoord y, Icoord z)
{
 pnt((Coord)x, (Coord)y, (Coord)z);
}

canonical_original_code:
void pnti(long x, long y, long z)
{
 pnt((float)x, (float)y, (float)z);
}

variable_types: x long

variable_types: y long

variable_types: z long


decompiled_code:
__int64 __fastcall pnt2(int a1, int a2, float a3, float a4)
{
move(a1, a2);
return draw(a3, a4, 0.0);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, int a2, float a3, float a4)
{
move(a1, a2);
return draw(a3, a4, 0.0);
}

original_code:
void
pnt2(Coord x, Coord y)
{
 move(x, y, 0.0);
 draw(x, y, 0.0);
}

canonical_original_code:
void pnt2(float x, float y)
{
 move(x, y, 0.0);
 draw(x, y, 0.0);
}


decompiled_code:
__int64 __fastcall pnt2s(__int16 a1, __int16 a2)
{
return pnt2(a1, a2, (float)a1, (float)a2);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int16 a1, __int16 a2)
{
return func3(a1, a2, (float)a1, (float)a2);
}

original_code:
void
pnt2s(Scoord x, Scoord y)
{
 pnt2((Coord)x, (Coord)y);
}

canonical_original_code:
void pnt2s(short x, short y)
{
 pnt2((float)x, (float)y);
}


decompiled_code:
__int64 __fastcall pnt2i(int a1, int a2)
{
return pnt2(a1, a2, (float)a1, (float)a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1, int a2)
{
return func3(a1, a2, (float)a1, (float)a2);
}

original_code:
void
pnt2i(Icoord x, Icoord y)
{
 pnt2((Coord)x, (Coord)y);
}

canonical_original_code:
void pnt2i(long x, long y)
{
 pnt2((float)x, (float)y);
}


bgnpoint

decompiled_code:
void *bgnpoint()
{
void *result; // rax

if ( *((_BYTE *)&vdevice + 348) )
{
verror("vogl: bgnpoint mode already belongs to some other bgn routine");
result = (void *)endpoint();
}
else
{
result = &vdevice;
*((_BYTE *)&vdevice + 348) = 1;
*((_DWORD *)&vdevice + 88) = 0;
}
return result;
}

canonical_decompiled_code:
void *func6()
{
void *result; // rax

if ( *((_BYTE *)&vdevice + 348) )
{
verror("vogl: bgnpoint mode already belongs to some other bgn routine");
result = (void *)func7();
}
else
{
result = &vdevice;
*((_BYTE *)&vdevice + 348) = 1;
*((_DWORD *)&vdevice + 88) = 0;
}
return result;
}

original_code:
void
bgnpoint(void)
{
 if (vdevice.bgnmode != 0)
  verror("vogl: bgnpoint mode already belongs to some other bgn routine");
 vdevice.bgnmode = 1;
 vdevice.save = 0;
}

canonical_original_code:
void bgnpoint()
{
 if (vdevice.bgnmode != 0)
  verror("vogl: bgnpoint mode already belongs to some other bgn routine");
 vdevice.bgnmode = 1;
 vdevice.save = 0;
}


endpoint

decompiled_code:
void *endpoint()
{
void *result; // rax

result = &vdevice;
*((_BYTE *)&vdevice + 348) = 0;
*((_DWORD *)&vdevice + 88) = 0;
return result;
}

canonical_decompiled_code:
void *func7()
{
void *result; // rax

result = &vdevice;
*((_BYTE *)&vdevice + 348) = 0;
*((_DWORD *)&vdevice + 88) = 0;
return result;
}

original_code:
void
endpoint(void)
{
 vdevice.bgnmode = 0;
 vdevice.save = 0;
}

canonical_original_code:
void endpoint()
{
 vdevice.bgnmode = 0;
 vdevice.save = 0;
}


decompiled_code:
float hgetfontheight_()
{
return (float)(int)hgetfontheight();
}

canonical_decompiled_code:
float func15()
{
return (float)(int)hgetfontheight();
}

original_code:
float
hgetfontheight_()
{
 return(hgetfontheight());
}

return_type: float


decompiled_code:
float hgetfh_()
{
return (float)(int)hgetfontheight();
}

canonical_decompiled_code:
float func16()
{
return (float)(int)hgetfontheight();
}

original_code:
float
hgetfh_()
{
 return(hgetfontheight());
}


decompiled_code:
float hgetfontwidth_()
{
return (float)(int)hgetfontwidth();
}

canonical_decompiled_code:
float func17()
{
return (float)(int)hgetfontwidth();
}

original_code:
float
hgetfontwidth_()
{
 return(hgetfontwidth());
}


decompiled_code:
float hgetfw_()
{
return (float)(int)hgetfontwidth();
}

canonical_decompiled_code:
float func18()
{
return (float)(int)hgetfontwidth();
}

original_code:
float
hgetfw_()
{
 return(hgetfontwidth());
}


decompiled_code:
float hgetdecender_()
{
return (float)(int)hgetdecender();
}

canonical_decompiled_code:
float func19()
{
return (float)(int)hgetdecender();
}

original_code:
float
hgetdecender_()
{
 return(hgetdecender());
}


decompiled_code:
float hgetde_()
{
return (float)(int)hgetdecender();
}

canonical_decompiled_code:
float func20()
{
return (float)(int)hgetdecender();
}

original_code:
float
hgetde_()
{
 return(hgetdecender());
}


decompiled_code:
float hgetascender_()
{
return (float)(int)hgetascender();
}

canonical_decompiled_code:
float func21()
{
return (float)(int)hgetascender();
}

original_code:
float
hgetascender_()
{
 return(hgetascender());
}


decompiled_code:
float hgetas_()
{
return (float)(int)hgetascender();
}

canonical_decompiled_code:
float func22()
{
return (float)(int)hgetascender();
}

original_code:
float
hgetas_()
{
 return(hgetascender());
}


decompiled_code:
__int64 hnumchars_()
{
return hnumchars();
}

canonical_decompiled_code:
__int64 func35()
{
return hnumchars();
}

original_code:
int
hnumchars_()
{
 return(hnumchars());
}

return_type: int


decompiled_code:
__int64 hnumch_()
{
return hnumchars();
}

canonical_decompiled_code:
__int64 func36()
{
return hnumchars();
}

original_code:
int
hnumch_()
{
 return(hnumchars());
}

canonical_original_code:
int hnumch_()
{
 return(hnumchars());
}


curvebasis

decompiled_code:
__int64 __fastcall curvebasis(__int16 a1)
{
if ( vdevice )
return copymatrix((char *)&vdevice + 376, *((_QWORD *)&vdevice + 63) + ((__int64)a1 << 6));
verror("curvebasis: vogl not initialised");
return curveprecision();
}

canonical_decompiled_code:
__int64 __fastcall func0(__int16 a1)
{
if ( vdevice )
return copymatrix((char *)&vdevice + 376, *((_QWORD *)&vdevice + 63) + ((__int64)a1 << 6));
verror("curvebasis: vogl not initialised");
return func1();
}

original_code:
void
curvebasis(short int id)
{
 if(!vdevice.initialised)
  verror("curvebasis: vogl not initialised");
 copymatrix(vdevice.tbasis, vdevice.bases[id]);
}

canonical_original_code:
void curvebasis(short id)
{
 if(!vdevice.initialised)
  verror("curvebasis: vogl not initialised");
 copymatrix(vdevice.tbasis, vdevice.bases[id]);
}

variable_types: id short


curveprecision

decompiled_code:
__int64 __fastcall curveprecision(__int16 a1)
{
__int64 result; // rax
float v2; // xmm2_4
float v3; // xmm4_4

if ( a1 <= 0 )
{
verror("curveprecision: number of segments <= 0");
result = drcurve();
}
else
{
nsegs = a1;
identmatrix(&e);
result = (unsigned int)nsegs;
v2 = (float)(result * result);
v3 = (float)nsegs * v2;
dword_5FC = 0;
dword_5E8 = 0;
e = 0;
*(float *)&dword_5D0 = 1.0 / v3;
*(float *)&dword_5D4 = 1.0 / v2;
*(float *)&dword_5F0 = 6.0 / v3;
*(float *)&dword_5E0 = 6.0 / v3;
*(float *)&dword_5E4 = 2.0 / v2;
*(float *)&dword_5D8 = 1.0 / (float)nsegs;
dword_5CC = LC2;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int16 a1)
{
__int64 result; // rax
float v2; // xmm2_4
float v3; // xmm4_4

if ( a1 <= 0 )
{
verror("curveprecision: number of segments <= 0");
result = func2();
}
else
{
nsegs = a1;
identmatrix(&e);
result = (unsigned int)nsegs;
v2 = (float)(result * result);
v3 = (float)nsegs * v2;
dword_5FC = 0;
dword_5E8 = 0;
e = 0;
*(float *)&dword_5D0 = 1.0 / v3;
*(float *)&dword_5D4 = 1.0 / v2;
*(float *)&dword_5F0 = 6.0 / v3;
*(float *)&dword_5E0 = 6.0 / v3;
*(float *)&dword_5E4 = 2.0 / v2;
*(float *)&dword_5D8 = 1.0 / (float)nsegs;
dword_5CC = LC2;
}
return result;
}

original_code:
void
curveprecision(short int nsegments)
{
 float n2, n3;
 if (nsegments > 0)
  nsegs = nsegments;
 else
  verror("curveprecision: number of segments <= 0");
 identmatrix(e);
 n2 = (float)(nsegs * nsegs);
 n3 = (float)(nsegs * n2);
 e[0][0] = e[2][2] = e[3][3] = 0.0;
 e[1][0] = 1.0 / n3;
 e[1][1] = 1.0 / n2;
 e[2][0] = e[3][0] = 6.0 / n3;
 e[2][1] = 2.0 / n2;
 e[1][2] = 1.0 / (float)nsegs;
 e[0][3] = 1.0;
}

canonical_original_code:
void curveprecision(short nsegments)
{
 float n2; float n3;
 if (nsegments > 0)
  nsegs = nsegments;
 else
  verror("curveprecision: number of segments <= 0");
 identmatrix(e);
 n2 = (float)(nsegs * nsegs);
 n3 = (float)(nsegs * n2);
 e[0][0] = e[2][2] = e[3][3] = 0.0;
 e[1][0] = 1.0 / n3;
 e[1][1] = 1.0 / n2;
 e[2][0] = e[3][0] = 6.0 / n3;
 e[2][1] = 2.0 / n2;
 e[1][2] = 1.0 / (float)nsegs;
 e[0][3] = 1.0;
}

variable_types: nsegments short


drcurve

original_code:
void
drcurve(int n, float (*r)[4])
{
 int it, vx, vy, sync;
 if ((sync = vdevice.sync)!=0)
  vdevice.sync = 0;
 vdevice.cpVvalid = 0;
 if (vdevice.clipoff) {
  vdevice.cpVx = WtoVx(r[0]);
  vdevice.cpVy = WtoVy(r[0]);
 }
 for (it = 0; it < n; it++) {
  vdevice.cpWtrans[0] = r[0][0];
  vdevice.cpWtrans[1] = r[0][1];
  vdevice.cpWtrans[2] = r[0][2];
  vdevice.cpWtrans[3] = r[0][3];
  r[0][0] += r[1][0];
  r[1][0] += r[2][0];
  r[2][0] += r[3][0];
  r[0][1] += r[1][1];
  r[1][1] += r[2][1];
  r[2][1] += r[3][1];
  r[0][2] += r[1][2];
  r[1][2] += r[2][2];
  r[2][2] += r[3][2];
  r[0][3] += r[1][3];
  r[1][3] += r[2][3];
  r[2][3] += r[3][3];
  if (vdevice.clipoff) {
   vx = WtoVx(r[0]);
   vy = WtoVy(r[0]);
   (*vdevice.dev.Vdraw)(vx, vy);
   vdevice.cpVx = vx;
   vdevice.cpVy = vy;
   vdevice.cpVvalid = 0;
  } else {
   if (vdevice.cpVvalid)
    quickclip(vdevice.cpWtrans, r[0]);
   else
    clip(vdevice.cpWtrans, r[0]);
  }
 }
 vdevice.cpWtrans[0] = r[0][0];
 vdevice.cpWtrans[1] = r[0][1];
 vdevice.cpWtrans[2] = r[0][2];
 vdevice.cpWtrans[3] = r[0][3];
 if (sync) {
  vdevice.sync = 1;
  (*vdevice.dev.Vsync)();
 }
}

canonical_original_code:
void drcurve(int n, float (*r)[4])
{
 int it; int vx; int vy; int sync;
 if ((sync = vdevice.sync)!=0)
  vdevice.sync = 0;
 vdevice.cpVvalid = 0;
 if (vdevice.clipoff) {
  vdevice.cpVx = WtoVx(r[0]);
  vdevice.cpVy = WtoVy(r[0]);
 }
 for (it = 0; it < n; it++) {
  vdevice.cpWtrans[0] = r[0][0];
  vdevice.cpWtrans[1] = r[0][1];
  vdevice.cpWtrans[2] = r[0][2];
  vdevice.cpWtrans[3] = r[0][3];
  r[0][0] += r[1][0];
  r[1][0] += r[2][0];
  r[2][0] += r[3][0];
  r[0][1] += r[1][1];
  r[1][1] += r[2][1];
  r[2][1] += r[3][1];
  r[0][2] += r[1][2];
  r[1][2] += r[2][2];
  r[2][2] += r[3][2];
  r[0][3] += r[1][3];
  r[1][3] += r[2][3];
  r[2][3] += r[3][3];
  if (vdevice.clipoff) {
   vx = WtoVx(r[0]);
   vy = WtoVy(r[0]);
   (*vdevice.dev.Vdraw)(vx, vy);
   vdevice.cpVx = vx;
   vdevice.cpVy = vy;
   vdevice.cpVvalid = 0;
  } else {
   if (vdevice.cpVvalid)
    quickclip(vdevice.cpWtrans, r[0]);
   else
    clip(vdevice.cpWtrans, r[0]);
  }
 }
 vdevice.cpWtrans[0] = r[0][0];
 vdevice.cpWtrans[1] = r[0][1];
 vdevice.cpWtrans[2] = r[0][2];
 vdevice.cpWtrans[3] = r[0][3];
 if (sync) {
  vdevice.sync = 1;
  (*vdevice.dev.Vsync)();
 }
}

variable_types: n int

variable_types:
r
float (*)[4]

variable_types: it int

variable_types: vx int

variable_types: vy int

variable_types: sync int


rcrv

original_code:
void
rcrv(Coord (*geom)[4])
{
 Matrix d, tmp;
 float *m, xlast, ylast, zlast;
 Token *tok;
 int i;
 if (!vdevice.initialised)
  verror("rcrv: vogl not initialised");
 mult4x4(d, vdevice.tbasis, geom);
 xlast = d[0][0] + d[1][0] + d[2][0] + d[3][0];
 ylast = d[0][1] + d[1][1] + d[2][1] + d[3][1];
 zlast = d[0][2] + d[1][2] + d[2][2] + d[3][2];
 mult4x4(tmp, e, d);
 if (vdevice.inobject) {
  tok = newtokens(21);
  tok[0].i = 28;
  (++tok)->i = nsegs;
  (++tok)->f = xlast;
  (++tok)->f = ylast;
  (++tok)->f = zlast;
  m = (float *)tmp;
  for (i = 0; i < 16; i++)
   (++tok)->f = *m++;
  return;
 }
 mult4x4(d, tmp, vdevice.transmat->m);
 drcurve(nsegs, d);
 vdevice.cpW[0] = xlast;
 vdevice.cpW[1] = ylast;
 vdevice.cpW[2] = zlast;
}

canonical_original_code:
void rcrv(float (*geom)[4])
{
 float d[4][4]; float tmp[4][4];
 float *m; float xlast; float ylast; float zlast;
 union tk *tok;
 int i;
 if (!vdevice.initialised)
  verror("rcrv: vogl not initialised");
 mult4x4(d, vdevice.tbasis, geom);
 xlast = d[0][0] + d[1][0] + d[2][0] + d[3][0];
 ylast = d[0][1] + d[1][1] + d[2][1] + d[3][1];
 zlast = d[0][2] + d[1][2] + d[2][2] + d[3][2];
 mult4x4(tmp, e, d);
 if (vdevice.inobject) {
  tok = newtokens(21);
  tok[0].i = 28;
  (++tok)->i = nsegs;
  (++tok)->f = xlast;
  (++tok)->f = ylast;
  (++tok)->f = zlast;
  m = (float *)tmp;
  for (i = 0; i < 16; i++)
   (++tok)->f = *m++;
  return;
 }
 mult4x4(d, tmp, vdevice.transmat->m);
 drcurve(nsegs, d);
 vdevice.cpW[0] = xlast;
 vdevice.cpW[1] = ylast;
 vdevice.cpW[2] = zlast;
}

variable_types:
geom
float (*)[4]

variable_types:
d
float [4][4]

variable_types:
tmp
float [4][4]

variable_types:
m
float *

variable_types: xlast float

variable_types: ylast float

variable_types: zlast float

variable_types:
tok
union tk { int i; float f; } *

variable_types: i int


crv

decompiled_code:
float *__fastcall crv(_DWORD *a1)
{
char *v1; // rax
float *result; // rax
_BYTE v3[64]; // [rsp+0h] [rbp-48h] BYREF
char v4; // [rsp+40h] [rbp-8h] BYREF

if ( vdevice )
{
v1 = v3;
do
{
*((_DWORD *)v1 + 3) = LC2;
*(_DWORD *)v1 = *a1;
*((_DWORD *)v1 + 1) = a1[1];
*((_DWORD *)v1 + 2) = a1[2];
v1 += 16;
a1 += 3;
}
while ( &v4 != v1 );
result = rcrv((__int64)v3);
}
else
{
verror("crv: vogl not initialised");
result = (float *)crvn();
}
return result;
}

canonical_decompiled_code:
float *__fastcall func4(_DWORD *a1)
{
char *v1; // rax
float *result; // rax
_BYTE v3[64]; // [rsp+0h] [rbp-48h] BYREF
char v4; // [rsp+40h] [rbp-8h] BYREF

if ( vdevice )
{
v1 = v3;
do
{
*((_DWORD *)v1 + 3) = LC2;
*(_DWORD *)v1 = *a1;
*((_DWORD *)v1 + 1) = a1[1];
*((_DWORD *)v1 + 2) = a1[2];
v1 += 16;
a1 += 3;
}
while ( &v4 != v1 );
result = func3((__int64)v3);
}
else
{
verror("crv: vogl not initialised");
result = (float *)func5();
}
return result;
}

original_code:
void
crv(Coord (*geom)[3])
{
 Matrix tmp;
 int i, j;
 if (!vdevice.initialised)
  verror("crv: vogl not initialised");
 for (i = 0; i < 4; i++) {
  tmp[i][3] = 1.0;
  for (j = 0; j < 3; j++)
   tmp[i][j] = geom[i][j];
 }
 rcrv(tmp);
}

canonical_original_code:
void crv(float (*geom)[3])
{
 float tmp[4][4];
 int i; int j;
 if (!vdevice.initialised)
  verror("crv: vogl not initialised");
 for (i = 0; i < 4; i++) {
  tmp[i][3] = 1.0;
  for (j = 0; j < 3; j++)
   tmp[i][j] = geom[i][j];
 }
 rcrv(tmp);
}

variable_types:
geom
float (*)[3]

variable_types: j int


crvn

decompiled_code:
float *__fastcall crvn(__int64 a1, _DWORD *a2)
{
__int64 v3; // rbp
float *result; // rax

if ( !vdevice )
{
verror("crvn: vogl not initialised");
goto LABEL_7;
}
if ( a1 <= 3 )
{
LABEL_7:
verror("crvn: not enough points in geometry matrix");
return (float *)rcrvn();
}
v3 = 0LL;
do
{
result = crv(a2);
++v3;
a2 += 3;
}
while ( a1 - 3 != v3 );
return result;
}

canonical_decompiled_code:
float *__fastcall func5(__int64 a1, _DWORD *a2)
{
__int64 v3; // rbp
float *result; // rax

if ( !vdevice )
{
verror("crvn: vogl not initialised");
goto LABEL_7;
}
if ( a1 <= 3 )
{
LABEL_7:
verror("crvn: not enough points in geometry matrix");
return (float *)func6();
}
v3 = 0LL;
do
{
result = func4(a2);
++v3;
a2 += 3;
}
while ( a1 - 3 != v3 );
return result;
}

original_code:
void
crvn(long int n, Coord (*geom)[3])
{
 int i;
 if (!vdevice.initialised)
  verror("crvn: vogl not initialised");
 if (n < 4)
  verror("crvn: not enough points in geometry matrix");
 for (i = 0; i <= n - 4; i++)
  crv(&geom[i]);
}

canonical_original_code:
void crvn(long n, float (*geom)[3])
{
 int i;
 if (!vdevice.initialised)
  verror("crvn: vogl not initialised");
 if (n < 4)
  verror("crvn: not enough points in geometry matrix");
 for (i = 0; i <= n - 4; i++)
  crv(&geom[i]);
}

variable_types: n long


rcrvn

decompiled_code:
float *__fastcall rcrvn(__int64 a1, __int64 a2)
{
__int64 v3; // rbp
float *result; // rax

if ( !vdevice )
{
verror("rcrvn: vogl not initialised");
goto LABEL_7;
}
if ( a1 <= 3 )
{
LABEL_7:
verror("rcrvn: not enough points in geometry matrix");
return (float *)curveit();
}
v3 = 0LL;
do
{
result = rcrv(a2);
++v3;
a2 += 16LL;
}
while ( a1 - 3 != v3 );
return result;
}

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

if ( !vdevice )
{
verror("rcrvn: vogl not initialised");
goto LABEL_7;
}
if ( a1 <= 3 )
{
LABEL_7:
verror("rcrvn: not enough points in geometry matrix");
return (float *)func7();
}
v3 = 0LL;
do
{
result = func3(a2);
++v3;
a2 += 16LL;
}
while ( a1 - 3 != v3 );
return result;
}

original_code:
void
rcrvn(long int n, Coord (*geom)[4])
{
 int i;
 if (!vdevice.initialised)
  verror("rcrvn: vogl not initialised");
 if (n < 4)
  verror("rcrvn: not enough points in geometry matrix");
 for (i = 0; i <= n - 4; i++)
  rcrv(&geom[i]);
}

canonical_original_code:
void rcrvn(long n, float (*geom)[4])
{
 int i;
 if (!vdevice.initialised)
  verror("rcrvn: vogl not initialised");
 if (n < 4)
  verror("rcrvn: not enough points in geometry matrix");
 for (i = 0; i <= n - 4; i++)
  rcrv(&geom[i]);
}


curveit

decompiled_code:
void *__fastcall curveit(__int16 a1)
{
return drcurve(a1, vdevice[3]);
}

canonical_decompiled_code:
void *__fastcall func7(__int16 a1)
{
return func2(a1, vdevice[3]);
}

original_code:
void
curveit(short int n)
{
 drcurve((int)n, vdevice.transmat->m);
}

canonical_original_code:
void curveit(short n)
{
 drcurve((int)n, vdevice.transmat->m);
}

variable_types: n short


clip

decompiled_code:
int *__fastcall clip(float *a1, float *a2)
{
int v2; // er12
int *result; // rax
double v4; // xmm1_8
double v5; // xmm3_8
float v6; // xmm5_4
double v7; // xmm2_8
double v8; // xmm0_8
float v9; // xmm2_4
double v10; // xmm4_8
double v11; // xmm2_8
double v12; // xmm6_8
double v13; // xmm0_8
double v14; // xmm5_8
double v15; // xmm4_8
double v16; // xmm5_8
unsigned int v17; // er13
__int64 v18; // rbx

v2 = MakeEdgeCoords(0, a1);
result = (int *)MakeEdgeCoords(1, a2);
if ( ((unsigned int)result & v2) != 0 )
return result;
result = wc;
*(_QWORD *)&v4 = (unsigned int)LC1;
v5 = 0.0;
do
{
*(_QWORD *)&v8 = (unsigned int)*result;
if ( *(float *)&v8 < 0.0 )
{
*(float *)&v8 = *(float *)&v8 / (float)(*(float *)&v8 - *((float *)result + 6));
v7 = v8;
}
else
{
v9 = *((float *)result + 6);
if ( v9 >= 0.0 )
goto LABEL_5;
v6 = *(float *)&v8 - v9;
*(_QWORD *)&v7 = (unsigned int)*result;
*(float *)&v7 = *(float *)&v8 / v6;
if ( *(float *)&v8 >= 0.0 )
{
*(float *)&v7 = fminf(*(float *)&v7, *(float *)&v4);
v4 = v7;
goto LABEL_5;
}
}
*(float *)&v7 = fmaxf(*(float *)&v7, *(float *)&v5);
v5 = v7;
LABEL_5:
++result;
}
while ( result != &wc[6] );
if ( *(float *)&v4 >= *(float *)&v5 )
{
*((_BYTE *)&vdevice + 5) = 1;
*(_QWORD *)&v10 = *(unsigned int *)a1;
*(_QWORD *)&v11 = *(unsigned int *)a2;
*(float *)&v11 = *(float *)&v11 - *(float *)&v10;
*(_QWORD *)&v12 = *((unsigned int *)a2 + 1);
*(float *)&v12 = *(float *)&v12 - a1[1];
*(_QWORD *)&v13 = *((unsigned int *)a2 + 2);
*(float *)&v13 = *(float *)&v13 - a1[2];
*(_QWORD *)&v14 = *((unsigned int *)a2 + 3);
*(float *)&v14 = *(float *)&v14 - a1[3];
if ( *(float *)&v4 != 1.0 )
{
*a2 = *(float *)&v10 + (float)(*(float *)&v4 * *(float *)&v11);
a2[1] = (float)(*(float *)&v4 * *(float *)&v12) + a1[1];
HIDWORD(v10) = HIDWORD(v4);
*(float *)&v10 = (float)(*(float *)&v4 * *(float *)&v13) + a1[2];
a2[2] = *(float *)&v10;
*(float *)&v4 = (float)(*(float *)&v4 * *(float *)&v14) + a1[3];
a2[3] = *(float *)&v4;
*((_BYTE *)&vdevice + 5) = 0;
}
if ( *(float *)&v5 != 0.0 )
{
*(float *)&v11 = (float)(*(float *)&v11 * *(float *)&v5) + *a1;
*a1 = *(float *)&v11;
*(float *)&v12 = *(float *)&v12 * *(float *)&v5;
HIDWORD(v4) = HIDWORD(v12);
*(float *)&v4 = *(float *)&v12 + a1[1];
a1[1] = *(float *)&v4;
*(float *)&v13 = (float)(*(float *)&v13 * *(float *)&v5) + a1[2];
a1[2] = *(float *)&v13;
*(float *)&v5 = (float)(*(float *)&v5 * *(float *)&v14) + a1[3];
a1[3] = *(float *)&v5;
}
*((_DWORD *)&vdevice + 35) = WtoVx(a1, v13, v4, v11, v5, v10, v14, v12);
*((_DWORD *)&vdevice + 36) = WtoVy(a1);
v17 = WtoVx(a2, v13, v4, v11, v5, v15, v16, v12);
v18 = (unsigned int)WtoVy(a2);
result = (int *)(*((__int64 (__fastcall **)(_QWORD, __int64))&vdevice + 27))(v17, v18);
*((_DWORD *)&vdevice + 35) = v17;
*((_DWORD *)&vdevice + 36) = v18;
}
return result;
}

canonical_decompiled_code:
int *__fastcall func1(float *a1, float *a2)
{
int v2; // er12
int *result; // rax
double v4; // xmm1_8
double v5; // xmm3_8
float v6; // xmm5_4
double v7; // xmm2_8
double v8; // xmm0_8
float v9; // xmm2_4
double v10; // xmm4_8
double v11; // xmm2_8
double v12; // xmm6_8
double v13; // xmm0_8
double v14; // xmm5_8
double v15; // xmm4_8
double v16; // xmm5_8
unsigned int v17; // er13
__int64 v18; // rbx

v2 = func0(0, a1);
result = (int *)func0(1, a2);
if ( ((unsigned int)result & v2) != 0 )
return result;
result = wc;
*(_QWORD *)&v4 = (unsigned int)LC1;
v5 = 0.0;
do
{
*(_QWORD *)&v8 = (unsigned int)*result;
if ( *(float *)&v8 < 0.0 )
{
*(float *)&v8 = *(float *)&v8 / (float)(*(float *)&v8 - *((float *)result + 6));
v7 = v8;
}
else
{
v9 = *((float *)result + 6);
if ( v9 >= 0.0 )
goto LABEL_5;
v6 = *(float *)&v8 - v9;
*(_QWORD *)&v7 = (unsigned int)*result;
*(float *)&v7 = *(float *)&v8 / v6;
if ( *(float *)&v8 >= 0.0 )
{
*(float *)&v7 = fminf(*(float *)&v7, *(float *)&v4);
v4 = v7;
goto LABEL_5;
}
}
*(float *)&v7 = fmaxf(*(float *)&v7, *(float *)&v5);
v5 = v7;
LABEL_5:
++result;
}
while ( result != &wc[6] );
if ( *(float *)&v4 >= *(float *)&v5 )
{
*((_BYTE *)&vdevice + 5) = 1;
*(_QWORD *)&v10 = *(unsigned int *)a1;
*(_QWORD *)&v11 = *(unsigned int *)a2;
*(float *)&v11 = *(float *)&v11 - *(float *)&v10;
*(_QWORD *)&v12 = *((unsigned int *)a2 + 1);
*(float *)&v12 = *(float *)&v12 - a1[1];
*(_QWORD *)&v13 = *((unsigned int *)a2 + 2);
*(float *)&v13 = *(float *)&v13 - a1[2];
*(_QWORD *)&v14 = *((unsigned int *)a2 + 3);
*(float *)&v14 = *(float *)&v14 - a1[3];
if ( *(float *)&v4 != 1.0 )
{
*a2 = *(float *)&v10 + (float)(*(float *)&v4 * *(float *)&v11);
a2[1] = (float)(*(float *)&v4 * *(float *)&v12) + a1[1];
HIDWORD(v10) = HIDWORD(v4);
*(float *)&v10 = (float)(*(float *)&v4 * *(float *)&v13) + a1[2];
a2[2] = *(float *)&v10;
*(float *)&v4 = (float)(*(float *)&v4 * *(float *)&v14) + a1[3];
a2[3] = *(float *)&v4;
*((_BYTE *)&vdevice + 5) = 0;
}
if ( *(float *)&v5 != 0.0 )
{
*(float *)&v11 = (float)(*(float *)&v11 * *(float *)&v5) + *a1;
*a1 = *(float *)&v11;
*(float *)&v12 = *(float *)&v12 * *(float *)&v5;
HIDWORD(v4) = HIDWORD(v12);
*(float *)&v4 = *(float *)&v12 + a1[1];
a1[1] = *(float *)&v4;
*(float *)&v13 = (float)(*(float *)&v13 * *(float *)&v5) + a1[2];
a1[2] = *(float *)&v13;
*(float *)&v5 = (float)(*(float *)&v5 * *(float *)&v14) + a1[3];
a1[3] = *(float *)&v5;
}
*((_DWORD *)&vdevice + 35) = WtoVx(a1, v13, v4, v11, v5, v10, v14, v12);
*((_DWORD *)&vdevice + 36) = WtoVy(a1);
v17 = WtoVx(a2, v13, v4, v11, v5, v15, v16, v12);
v18 = (unsigned int)WtoVy(a2);
result = (int *)(*((__int64 (__fastcall **)(_QWORD, __int64))&vdevice + 27))(v17, v18);
*((_DWORD *)&vdevice + 35) = v17;
*((_DWORD *)&vdevice + 36) = v18;
}
return result;
}

variable_types: t float

variable_types: dx float

variable_types: dy float

variable_types: dz float

variable_types: dw float


decompiled_code:
__int64 swapbu_()
{
return swapbuffers();
}

canonical_decompiled_code:
__int64 func5()
{
return swapbuffers();
}

original_code:
void
swapbu_()
{
 swapbuffers();
}

canonical_original_code:
void swapbu_()
{
 swapbuffers();
}


decompiled_code:
__int64 double_()
{
return doublebuffer();
}

canonical_decompiled_code:
__int64 func7()
{
return doublebuffer();
}

original_code:
void
double_()
{
 doublebuffer();
}

canonical_original_code:
void double_()
{
 doublebuffer();
}


decompiled_code:
__int64 single_()
{
return singlebuffer();
}

canonical_decompiled_code:
__int64 func9()
{
return singlebuffer();
}

original_code:
void
single_()
{
 singlebuffer();
}

canonical_original_code:
void single_()
{
 singlebuffer();
}


vcall

decompiled_code:
int __fastcall vcall(unsigned int *a1, int a2)
{
unsigned int v2; // ebp
unsigned int v3; // er12
unsigned int v4; // ebx
int v5; // eax
void *v6; // rax
__int64 v7; // rsi
__int64 v8; // rcx
__int64 v9; // rsi

v2 = *a1;
v3 = a1[1];
if ( a2 == 3 )
{
v4 = a1[2];
}
else
{
v4 = LC0;
if ( a2 == 4 )
v4 = a1[2];
}
v5 = *((_DWORD *)&vdevice + 88);
if ( v5 )
{
*((_DWORD *)&vdevice + 84) = v2;
*((_DWORD *)&vdevice + 85) = v3;
*((_DWORD *)&vdevice + 86) = v4;
switch ( *((_BYTE *)&vdevice + 348) )
{
case 1:
goto LABEL_8;
case 2:
goto LABEL_10;
case 3:
goto LABEL_9;
case 4:
goto LABEL_12;
case 5:
goto LABEL_15;
case 6:
if ( v5 <= 2 )
goto LABEL_22;
if ( (v5 & 1) != 0 )
{
pmv(*(float *)qstrip_0, *(float *)&dword_624, *(float *)&dword_628);
pdr(*(float *)&dword_62C, *(float *)&dword_630, *(float *)&dword_634);
pdr(*(float *)&v2, *(float *)&v3, *(float *)&v4);
pdr(*(float *)&dword_638, *(float *)&dword_63C, *(float *)&dword_640);
pclos();
qstrip_0[0] = dword_638;
dword_624 = dword_63C;
dword_628 = dword_640;
dword_62C = v2;
dword_630 = v3;
dword_634 = v4;
}
else
{
dword_638 = v2;
dword_63C = v3;
dword_640 = v4;
}
break;
default:
goto LABEL_25;
}
LABEL_23:
v6 = &vdevice;
++*((_DWORD *)&vdevice + 88);
}
else
{
switch ( *((_BYTE *)&vdevice + 348) )
{
case 1:
LABEL_8:
LODWORD(v6) = pnt(
*(double *)_mm_cvtsi32_si128(v2).m128i_i64,
*(double *)_mm_cvtsi32_si128(v3).m128i_i64,
*(double *)_mm_cvtsi32_si128(v4).m128i_i64);
return (int)v6;
case 2:
goto LABEL_7;
case 3:
LABEL_9:
if ( v5 )
{
LABEL_10:
*((_DWORD *)&vdevice + 88) = 0;
LODWORD(v6) = move((int)a1, a2);
}
else
{
LABEL_7:
LODWORD(v6) = draw(
*(double *)_mm_cvtsi32_si128(v2).m128i_i64,
*(double *)_mm_cvtsi32_si128(v3).m128i_i64,
*(double *)_mm_cvtsi32_si128(v4).m128i_i64);
}
break;
case 4:
LABEL_12:
if ( v5 )
{
*((_DWORD *)&vdevice + 88) = 0;
LODWORD(v6) = pmv(*(float *)&v2, *(float *)&v3, *(float *)&v4);
}
else
{
LODWORD(v6) = pdr(*(float *)&v2, *(float *)&v3, *(float *)&v4);
}
break;
case 5:
LABEL_15:
if ( v5 > 1 )
{
pmv(*(float *)tmesh_1, *(float *)&dword_654, *(float *)&dword_658);
pdr(*(float *)&dword_65C, *(float *)&dword_660, *(float *)&dword_664);
pdr(*(float *)&v2, *(float *)&v3, *(float *)&v4);
pclos();
v8 = 3LL * (*((_DWORD *)&vdevice + 88) % 2);
tmesh_1[v8] = v2;
tmesh_1[v8 + 1] = v3;
tmesh_1[v8 + 2] = v4;
}
else
{
v7 = 3LL * v5;
tmesh_1[v7] = v2;
tmesh_1[v7 + 1] = v3;
tmesh_1[v7 + 2] = v4;
}
v6 = &vdevice;
++*((_DWORD *)&vdevice + 88);
break;
case 6:
LABEL_22:
v9 = 3LL * v5;
qstrip_0[v9] = v2;
qstrip_0[v9 + 1] = v3;
qstrip_0[v9 + 2] = v4;
goto LABEL_23;
default:
LABEL_25:
LODWORD(v6) = move((int)a1, a2);
break;
}
}
return (int)v6;
}

canonical_decompiled_code:
int __fastcall func0(unsigned int *a1, int a2)
{
unsigned int v2; // ebp
unsigned int v3; // er12
unsigned int v4; // ebx
int v5; // eax
void *v6; // rax
__int64 v7; // rsi
__int64 v8; // rcx
__int64 v9; // rsi

v2 = *a1;
v3 = a1[1];
if ( a2 == 3 )
{
v4 = a1[2];
}
else
{
v4 = LC0;
if ( a2 == 4 )
v4 = a1[2];
}
v5 = *((_DWORD *)&vdevice + 88);
if ( v5 )
{
*((_DWORD *)&vdevice + 84) = v2;
*((_DWORD *)&vdevice + 85) = v3;
*((_DWORD *)&vdevice + 86) = v4;
switch ( *((_BYTE *)&vdevice + 348) )
{
case 1:
goto LABEL_8;
case 2:
goto LABEL_10;
case 3:
goto LABEL_9;
case 4:
goto LABEL_12;
case 5:
goto LABEL_15;
case 6:
if ( v5 <= 2 )
goto LABEL_22;
if ( (v5 & 1) != 0 )
{
pmv(*(float *)qstrip_0, *(float *)&dword_624, *(float *)&dword_628);
pdr(*(float *)&dword_62C, *(float *)&dword_630, *(float *)&dword_634);
pdr(*(float *)&v2, *(float *)&v3, *(float *)&v4);
pdr(*(float *)&dword_638, *(float *)&dword_63C, *(float *)&dword_640);
pclos();
qstrip_0[0] = dword_638;
dword_624 = dword_63C;
dword_628 = dword_640;
dword_62C = v2;
dword_630 = v3;
dword_634 = v4;
}
else
{
dword_638 = v2;
dword_63C = v3;
dword_640 = v4;
}
break;
default:
goto LABEL_25;
}
LABEL_23:
v6 = &vdevice;
++*((_DWORD *)&vdevice + 88);
}
else
{
switch ( *((_BYTE *)&vdevice + 348) )
{
case 1:
LABEL_8:
LODWORD(v6) = pnt(
*(double *)_mm_cvtsi32_si128(v2).m128i_i64,
*(double *)_mm_cvtsi32_si128(v3).m128i_i64,
*(double *)_mm_cvtsi32_si128(v4).m128i_i64);
return (int)v6;
case 2:
goto LABEL_7;
case 3:
LABEL_9:
if ( v5 )
{
LABEL_10:
*((_DWORD *)&vdevice + 88) = 0;
LODWORD(v6) = move((int)a1, a2);
}
else
{
LABEL_7:
LODWORD(v6) = draw(
*(double *)_mm_cvtsi32_si128(v2).m128i_i64,
*(double *)_mm_cvtsi32_si128(v3).m128i_i64,
*(double *)_mm_cvtsi32_si128(v4).m128i_i64);
}
break;
case 4:
LABEL_12:
if ( v5 )
{
*((_DWORD *)&vdevice + 88) = 0;
LODWORD(v6) = pmv(*(float *)&v2, *(float *)&v3, *(float *)&v4);
}
else
{
LODWORD(v6) = pdr(*(float *)&v2, *(float *)&v3, *(float *)&v4);
}
break;
case 5:
LABEL_15:
if ( v5 > 1 )
{
pmv(*(float *)tmesh_1, *(float *)&dword_654, *(float *)&dword_658);
pdr(*(float *)&dword_65C, *(float *)&dword_660, *(float *)&dword_664);
pdr(*(float *)&v2, *(float *)&v3, *(float *)&v4);
pclos();
v8 = 3LL * (*((_DWORD *)&vdevice + 88) % 2);
tmesh_1[v8] = v2;
tmesh_1[v8 + 1] = v3;
tmesh_1[v8 + 2] = v4;
}
else
{
v7 = 3LL * v5;
tmesh_1[v7] = v2;
tmesh_1[v7 + 1] = v3;
tmesh_1[v7 + 2] = v4;
}
v6 = &vdevice;
++*((_DWORD *)&vdevice + 88);
break;
case 6:
LABEL_22:
v9 = 3LL * v5;
qstrip_0[v9] = v2;
qstrip_0[v9 + 1] = v3;
qstrip_0[v9 + 2] = v4;
goto LABEL_23;
default:
LABEL_25:
LODWORD(v6) = move((int)a1, a2);
break;
}
}
return (int)v6;
}

original_code:
static void
vcall(float *vector, int len)
{
 Vector vec;
 static Coord tmesh[2][3];
        static Coord qstrip[3][3];
        int sjm;
 vec[0] = vector[0];
 vec[1] = vector[1];
 vec[2] = 0.0;
 vec[3] = 1.0;
 if (len == 3) {
  vec[2] = vector[2];
  vec[3] = 1.0;
 } else if (len == 4) {
  vec[2] = vector[2];
  vec[3] = vector[3];
 }
 if (vdevice.save) {
  vdevice.savex = vec[0];
  vdevice.savey = vec[1];
  vdevice.savez = vec[2];
 }
 switch (vdevice.bgnmode) {
 case 2:
  if (vdevice.save) {
   vdevice.save = 0;
   move(vec[0], vec[1], vec[2]);
   break;
  }
  draw(vec[0], vec[1], vec[2]);
  break;
 case 1:
  pnt(vec[0], vec[1], vec[2]);
  break;
 case 3:
  if (vdevice.save) {
   vdevice.save = 0;
   move(vec[0], vec[1], vec[2]);
   break;
  }
  draw(vec[0], vec[1], vec[2]);
  break;
 case 4:
  if (vdevice.save) {
   vdevice.save = 0;
   pmv(vec[0], vec[1], vec[2]);
   break;
  }
  pdr(vec[0], vec[1], vec[2]);
  break;
 case 5:
  if( vdevice.save < 2 ) {
   tmesh[vdevice.save][0] = vec[0];
   tmesh[vdevice.save][1] = vec[1];
   tmesh[vdevice.save][2] = vec[2];
  } else {
   pmv(tmesh[0][0], tmesh[0][1], tmesh[0][2]);
   pdr(tmesh[1][0], tmesh[1][1], tmesh[1][2]);
   pdr( vec[0], vec[1], vec[2]);
   pclos();
   sjm = vdevice.save % 2;
   tmesh[sjm][0] = vec[0];
   tmesh[sjm][1] = vec[1];
   tmesh[sjm][2] = vec[2];
  }
  vdevice.save++;
  break;
 case 6:
  if( vdevice.save < 3 ) {
   qstrip[vdevice.save][0] = vec[0];
   qstrip[vdevice.save][1] = vec[1];
   qstrip[vdevice.save][2] = vec[2];
  } else {
   sjm = vdevice.save % 2;
   if (sjm) {
    pmv(qstrip[0][0], qstrip[0][1], qstrip[0][2]);
    pdr(qstrip[1][0], qstrip[1][1], qstrip[1][2]);
    pdr( vec[0], vec[1], vec[2]);
    pdr(qstrip[2][0], qstrip[2][1], qstrip[2][2]);
    pclos();
    qstrip[0][0] = qstrip[2][0];
    qstrip[0][1] = qstrip[2][1];
    qstrip[0][2] = qstrip[2][2];
    qstrip[1][0] = vec[0];
    qstrip[1][1] = vec[1];
    qstrip[1][2] = vec[2];
   } else {
    qstrip[2][0] = vec[0];
    qstrip[2][1] = vec[1];
    qstrip[2][2] = vec[2];
   }
  }
  vdevice.save++;
  break;
 default:
  move(vec[0], vec[1], vec[2]);
 }
}

canonical_original_code:
static void vcall(float *vector, int len)
{
 float vec[4];
 static float tmesh[2][3];
        static float qstrip[3][3];
        int sjm;
 vec[0] = vector[0];
 vec[1] = vector[1];
 vec[2] = 0.0;
 vec[3] = 1.0;
 if (len == 3) {
  vec[2] = vector[2];
  vec[3] = 1.0;
 } else if (len == 4) {
  vec[2] = vector[2];
  vec[3] = vector[3];
 }
 if (vdevice.save) {
  vdevice.savex = vec[0];
  vdevice.savey = vec[1];
  vdevice.savez = vec[2];
 }
 switch (vdevice.bgnmode) {
 case 2:
  if (vdevice.save) {
   vdevice.save = 0;
   move(vec[0], vec[1], vec[2]);
   break;
  }
  draw(vec[0], vec[1], vec[2]);
  break;
 case 1:
  pnt(vec[0], vec[1], vec[2]);
  break;
 case 3:
  if (vdevice.save) {
   vdevice.save = 0;
   move(vec[0], vec[1], vec[2]);
   break;
  }
  draw(vec[0], vec[1], vec[2]);
  break;
 case 4:
  if (vdevice.save) {
   vdevice.save = 0;
   pmv(vec[0], vec[1], vec[2]);
   break;
  }
  pdr(vec[0], vec[1], vec[2]);
  break;
 case 5:
  if( vdevice.save < 2 ) {
   tmesh[vdevice.save][0] = vec[0];
   tmesh[vdevice.save][1] = vec[1];
   tmesh[vdevice.save][2] = vec[2];
  } else {
   pmv(tmesh[0][0], tmesh[0][1], tmesh[0][2]);
   pdr(tmesh[1][0], tmesh[1][1], tmesh[1][2]);
   pdr( vec[0], vec[1], vec[2]);
   pclos();
   sjm = vdevice.save % 2;
   tmesh[sjm][0] = vec[0];
   tmesh[sjm][1] = vec[1];
   tmesh[sjm][2] = vec[2];
  }
  vdevice.save++;
  break;
 case 6:
  if( vdevice.save < 3 ) {
   qstrip[vdevice.save][0] = vec[0];
   qstrip[vdevice.save][1] = vec[1];
   qstrip[vdevice.save][2] = vec[2];
  } else {
   sjm = vdevice.save % 2;
   if (sjm) {
    pmv(qstrip[0][0], qstrip[0][1], qstrip[0][2]);
    pdr(qstrip[1][0], qstrip[1][1], qstrip[1][2]);
    pdr( vec[0], vec[1], vec[2]);
    pdr(qstrip[2][0], qstrip[2][1], qstrip[2][2]);
    pclos();
    qstrip[0][0] = qstrip[2][0];
    qstrip[0][1] = qstrip[2][1];
    qstrip[0][2] = qstrip[2][2];
    qstrip[1][0] = vec[0];
    qstrip[1][1] = vec[1];
    qstrip[1][2] = vec[2];
   } else {
    qstrip[2][0] = vec[0];
    qstrip[2][1] = vec[1];
    qstrip[2][2] = vec[2];
   }
  }
  vdevice.save++;
  break;
 default:
  move(vec[0], vec[1], vec[2]);
 }
}

variable_types:
vector
float *

variable_types: len int

variable_types:
vec
float [4]

variable_types:
tmesh
float [2][3]

variable_types:
qstrip
float [3][3]

variable_types: sjm int


decompiled_code:
int __fastcall v4f(unsigned int *a1)
{
return vcall(a1, 4);
}

canonical_decompiled_code:
int __fastcall func1(unsigned int *a1)
{
return func0(a1, 4);
}

original_code:
void
v4f(float *vec)
{
 vcall(vec, 4);
}

canonical_original_code:
void v4f(float *vec)
{
 vcall(vec, 4);
}

variable_types:
vec
float *


decompiled_code:
int __fastcall v3f(unsigned int *a1)
{
return vcall(a1, 3);
}

canonical_decompiled_code:
int __fastcall func2(unsigned int *a1)
{
return func0(a1, 3);
}

original_code:
void
v3f(float *vec)
{
 vcall(vec, 3);
}

canonical_original_code:
void v3f(float *vec)
{
 vcall(vec, 3);
}


decompiled_code:
int __fastcall v2f(unsigned int *a1)
{
return vcall(a1, 2);
}

canonical_decompiled_code:
int __fastcall func3(unsigned int *a1)
{
return func0(a1, 2);
}

original_code:
void
v2f(float *vec)
{
 vcall(vec, 2);
}

canonical_original_code:
void v2f(float *vec)
{
 vcall(vec, 2);
}


decompiled_code:
int __fastcall v4d(double *a1)
{
float v1; // xmm0_4
unsigned int v2; // xmm0_4
unsigned int v3; // xmm0_4
unsigned int v4; // xmm0_4
unsigned int v6[6]; // [rsp+0h] [rbp-18h] BYREF

v1 = *a1;
*(float *)v6 = v1;
*(float *)&v2 = a1[1];
v6[1] = v2;
*(float *)&v3 = a1[2];
v6[2] = v3;
*(float *)&v4 = a1[3];
v6[3] = v4;
return vcall(v6, 4);
}

canonical_decompiled_code:
int __fastcall func4(double *a1)
{
float v1; // xmm0_4
unsigned int v2; // xmm0_4
unsigned int v3; // xmm0_4
unsigned int v4; // xmm0_4
unsigned int v6[6]; // [rsp+0h] [rbp-18h] BYREF

v1 = *a1;
*(float *)v6 = v1;
*(float *)&v2 = a1[1];
v6[1] = v2;
*(float *)&v3 = a1[2];
v6[2] = v3;
*(float *)&v4 = a1[3];
v6[3] = v4;
return func0(v6, 4);
}

variable_types:
vec
double *

variable_types:
v
float [4]


decompiled_code:
int __fastcall v3d(double *a1)
{
float v1; // xmm0_4
unsigned int v2; // xmm0_4
unsigned int v3; // xmm0_4
unsigned int v5[5]; // [rsp+4h] [rbp-14h] BYREF

v1 = *a1;
*(float *)v5 = v1;
*(float *)&v2 = a1[1];
v5[1] = v2;
*(float *)&v3 = a1[2];
v5[2] = v3;
return vcall(v5, 3);
}

canonical_decompiled_code:
int __fastcall func5(double *a1)
{
float v1; // xmm0_4
unsigned int v2; // xmm0_4
unsigned int v3; // xmm0_4
unsigned int v5[5]; // [rsp+4h] [rbp-14h] BYREF

v1 = *a1;
*(float *)v5 = v1;
*(float *)&v2 = a1[1];
v5[1] = v2;
*(float *)&v3 = a1[2];
v5[2] = v3;
return func0(v5, 3);
}

original_code:
void
v3d(double *vec)
{
 float v[3];
 v[0] = vec[0];
 v[1] = vec[1];
 v[2] = vec[2];
 vcall(v, 3);
}

variable_types:
v
float [3]


decompiled_code:
int __fastcall v2d(double *a1)
{
float v1; // xmm0_4
unsigned int v2; // xmm0_4
unsigned int v4[4]; // [rsp+8h] [rbp-10h] BYREF

v1 = *a1;
*(float *)v4 = v1;
*(float *)&v2 = a1[1];
v4[1] = v2;
return vcall(v4, 2);
}

canonical_decompiled_code:
int __fastcall func6(double *a1)
{
float v1; // xmm0_4
unsigned int v2; // xmm0_4
unsigned int v4[4]; // [rsp+8h] [rbp-10h] BYREF

v1 = *a1;
*(float *)v4 = v1;
*(float *)&v2 = a1[1];
v4[1] = v2;
return func0(v4, 2);
}

original_code:
void
v2d(double *vec)
{
 float v[2];
 v[0] = vec[0];
 v[1] = vec[1];
 vcall(v, 2);
}

variable_types:
v
float [2]


decompiled_code:
int __fastcall v4i(_QWORD *a1)
{
unsigned int v2[6]; // [rsp+0h] [rbp-18h] BYREF

*(float *)v2 = (float)(int)*a1;
*(float *)&v2[1] = (float)(int)a1[1];
*(float *)&v2[2] = (float)(int)a1[2];
*(float *)&v2[3] = (float)(int)a1[3];
return vcall(v2, 4);
}

canonical_decompiled_code:
int __fastcall func7(_QWORD *a1)
{
unsigned int v2[6]; // [rsp+0h] [rbp-18h] BYREF

*(float *)v2 = (float)(int)*a1;
*(float *)&v2[1] = (float)(int)a1[1];
*(float *)&v2[2] = (float)(int)a1[2];
*(float *)&v2[3] = (float)(int)a1[3];
return func0(v2, 4);
}

variable_types:
vec
long *


decompiled_code:
int __fastcall v3i(_QWORD *a1)
{
unsigned int v2[5]; // [rsp+4h] [rbp-14h] BYREF

*(float *)v2 = (float)(int)*a1;
*(float *)&v2[1] = (float)(int)a1[1];
*(float *)&v2[2] = (float)(int)a1[2];
return vcall(v2, 3);
}

canonical_decompiled_code:
int __fastcall func8(_QWORD *a1)
{
unsigned int v2[5]; // [rsp+4h] [rbp-14h] BYREF

*(float *)v2 = (float)(int)*a1;
*(float *)&v2[1] = (float)(int)a1[1];
*(float *)&v2[2] = (float)(int)a1[2];
return func0(v2, 3);
}

original_code:
void
v3i(long int *vec)
{
 float v[3];
 v[0] = vec[0];
 v[1] = vec[1];
 v[2] = vec[2];
 vcall(v, 3);
}


decompiled_code:
int __fastcall v2i(_QWORD *a1)
{
unsigned int v2[4]; // [rsp+8h] [rbp-10h] BYREF

*(float *)v2 = (float)(int)*a1;
*(float *)&v2[1] = (float)(int)a1[1];
return vcall(v2, 2);
}

canonical_decompiled_code:
int __fastcall func9(_QWORD *a1)
{
unsigned int v2[4]; // [rsp+8h] [rbp-10h] BYREF

*(float *)v2 = (float)(int)*a1;
*(float *)&v2[1] = (float)(int)a1[1];
return func0(v2, 2);
}

original_code:
void
v2i(long int *vec)
{
 float v[2];
 v[0] = vec[0];
 v[1] = vec[1];
 vcall(v, 2);
}

canonical_original_code:
void v2i(long *vec)
{
 float v[2];
 v[0] = vec[0];
 v[1] = vec[1];
 vcall(v, 2);
}


decompiled_code:
int __fastcall v4s(__int16 *a1)
{
unsigned int v2[6]; // [rsp+0h] [rbp-18h] BYREF

*(float *)v2 = (float)*a1;
*(float *)&v2[1] = (float)a1[1];
*(float *)&v2[2] = (float)a1[2];
*(float *)&v2[3] = (float)a1[3];
return vcall(v2, 4);
}

canonical_decompiled_code:
int __fastcall func10(__int16 *a1)
{
unsigned int v2[6]; // [rsp+0h] [rbp-18h] BYREF

*(float *)v2 = (float)*a1;
*(float *)&v2[1] = (float)a1[1];
*(float *)&v2[2] = (float)a1[2];
*(float *)&v2[3] = (float)a1[3];
return func0(v2, 4);
}

variable_types:
vec
short *


decompiled_code:
int __fastcall v3s(__int16 *a1)
{
unsigned int v2[5]; // [rsp+4h] [rbp-14h] BYREF

*(float *)v2 = (float)*a1;
*(float *)&v2[1] = (float)a1[1];
*(float *)&v2[2] = (float)a1[2];
return vcall(v2, 3);
}

canonical_decompiled_code:
int __fastcall func11(__int16 *a1)
{
unsigned int v2[5]; // [rsp+4h] [rbp-14h] BYREF

*(float *)v2 = (float)*a1;
*(float *)&v2[1] = (float)a1[1];
*(float *)&v2[2] = (float)a1[2];
return func0(v2, 3);
}

original_code:
void
v3s(short int *vec)
{
 float v[3];
 v[0] = vec[0];
 v[1] = vec[1];
 v[2] = vec[2];
 vcall(v, 3);
}


decompiled_code:
int __fastcall v2s(__int16 *a1)
{
unsigned int v2[4]; // [rsp+8h] [rbp-10h] BYREF

*(float *)v2 = (float)*a1;
*(float *)&v2[1] = (float)a1[1];
return vcall(v2, 2);
}

canonical_decompiled_code:
int __fastcall func12(__int16 *a1)
{
unsigned int v2[4]; // [rsp+8h] [rbp-10h] BYREF

*(float *)v2 = (float)*a1;
*(float *)&v2[1] = (float)a1[1];
return func0(v2, 2);
}

original_code:
void
v2s(short int *vec)
{
 float v[2];
 v[0] = vec[0];
 v[1] = vec[1];
 vcall(v, 2);
}

canonical_original_code:
void v2s(short *vec)
{
 float v[2];
 v[0] = vec[0];
 v[1] = vec[1];
 vcall(v, 2);
}


original_code:
static void
out_bytes(int x, int y)
{
 int HiY, LoY, HiX, LoX;
 if (x < 0)
  x = 0;
 if (y < 0)
  y = 0;
 if (x > 1023)
  x = 1023;
 if (y > 1023)
  y = 1023;
 HiY = y / 32 + 32;
 LoY = y % 32 + 96;
 HiX = x / 32 + 32;
 LoX = x % 32 + 64;
 if (HiYold != HiY) {
  fprintf(fp, "%c", HiY);
  HiYold = HiY;
 }
 if ((LoYold != LoY) || (HiXold != HiX)) {
  fprintf(fp, "%c", LoY);
  LoYold = LoY;
  if (HiXold != HiX) {
   fprintf(fp, "%c", HiX);
   HiXold = HiX;
  }
 }
 fprintf(fp, "%c", LoX);
}

canonical_original_code:
static void out_bytes(int x, int y)
{
 int HiY; int LoY; int HiX; int LoX;
 if (x < 0)
  x = 0;
 if (y < 0)
  y = 0;
 if (x > 1023)
  x = 1023;
 if (y > 1023)
  y = 1023;
 HiY = y / 32 + 32;
 LoY = y % 32 + 96;
 HiX = x / 32 + 32;
 LoX = x % 32 + 64;
 if (HiYold != HiY) {
  fprintf(fp, "%c", HiY);
  HiYold = HiY;
 }
 if ((LoYold != LoY) || (HiXold != HiX)) {
  fprintf(fp, "%c", LoY);
  LoYold = LoY;
  if (HiXold != HiX) {
   fprintf(fp, "%c", HiX);
   HiXold = HiX;
  }
 }
 fprintf(fp, "%c", LoX);
}

variable_types: x int

variable_types: y int

variable_types: HiY int

variable_types: LoY int

variable_types: HiX int

variable_types: LoX int


decompiled_code:
__int64 __fastcall TEK_string(char *s)
{
if ( vdevice[35] != tlstx || vdevice[36] != tlsty )
{
fputc(29, fp);
HiXold = -1;
HiYold = -1;
LoYold = -1;
out_bytes(vdevice[35], vdevice[36]);
}
fputc(31, fp);
fputs(s, fp);
tlsty = -1;
tlstx = -1;
fflush(fp);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(char *s)
{
if ( vdevice[35] != tlstx || vdevice[36] != tlsty )
{
fputc(29, fp);
HiXold = -1;
HiYold = -1;
LoYold = -1;
func1(vdevice[35], vdevice[36]);
}
fputc(31, fp);
fputs(s, fp);
tlsty = -1;
tlstx = -1;
fflush(fp);
return 0LL;
}

original_code:
static int
TEK_string(const char *s)
{
 if (tlstx != vdevice.cpVx || tlsty != vdevice.cpVy) {
  fputc('\035', fp);
  LoYold = HiYold = HiXold = -1;
  out_bytes(vdevice.cpVx, vdevice.cpVy);
 }
 fputc('\037', fp);
 fputs(s, fp);
 tlstx = tlsty = -1;
 fflush(fp);
 return(0);
}

canonical_original_code:
static int TEK_string(char *s)
{
 if (tlstx != vdevice.cpVx || tlsty != vdevice.cpVy) {
  fputc('\035', fp);
  LoYold = HiYold = HiXold = -1;
  out_bytes(vdevice.cpVx, vdevice.cpVy);
 }
 fputc('\037', fp);
 fputs(s, fp);
 tlstx = tlsty = -1;
 fflush(fp);
 return(0);
}

variable_types:
s
char *


decompiled_code:
__int64 __fastcall TEK_fill(int a1, int *a2, int *a3)
{
__int64 i; // rbx
__int64 v5; // r13
int v6; // eax
int v7; // eax

if ( *a2 != tlstx || *a3 != tlsty )
{
fputc(29, fp);
HiXold = -1;
HiYold = -1;
LoYold = -1;
out_bytes(*a2, *a3);
}
if ( a1 > 1 )
{
for ( i = 1LL; i != a1; ++i )
out_bytes(a2[i], a3[i]);
}
out_bytes(*a2, *a3);
fflush(fp);
v5 = a1;
v6 = a2[v5 - 1];
vdevice[35] = v6;
tlstx = v6;
v7 = a3[v5 - 1];
vdevice[36] = v7;
tlsty = v7;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1, int *a2, int *a3)
{
__int64 i; // rbx
__int64 v5; // r13
int v6; // eax
int v7; // eax

if ( *a2 != tlstx || *a3 != tlsty )
{
fputc(29, fp);
HiXold = -1;
HiYold = -1;
LoYold = -1;
func1(*a2, *a3);
}
if ( a1 > 1 )
{
for ( i = 1LL; i != a1; ++i )
func1(a2[i], a3[i]);
}
func1(*a2, *a3);
fflush(fp);
v5 = a1;
v6 = a2[v5 - 1];
vdevice[35] = v6;
tlstx = v6;
v7 = a3[v5 - 1];
vdevice[36] = v7;
tlsty = v7;
return 0LL;
}

original_code:
static int
TEK_fill(int n, int *x, int *y)
{
 int i;
 if (tlstx != x[0] || tlsty != y[0]) {
  fputc('\035', fp);
  LoYold = HiYold = HiXold = -1;
  out_bytes(x[0], y[0]);
 }
 for (i = 1; i < n; i++)
  out_bytes(x[i], y[i]);
 out_bytes(x[0], y[0]);
 fflush(fp);
 tlstx = vdevice.cpVx = x[n - 1];
 tlsty = vdevice.cpVy = y[n - 1];
 return(0);
}

variable_types: n int

variable_types:
x
int *

variable_types:
y
int *

variable_types: i int


decompiled_code:
__int64 __fastcall TEK_draw(int a1, int a2)
{
if ( vdevice[35] != tlstx || vdevice[36] != tlsty )
{
fputc(29, fp);
HiXold = -1;
HiYold = -1;
LoYold = -1;
out_bytes(vdevice[35], vdevice[36]);
}
out_bytes(a1, a2);
tlstx = a1;
tlsty = a2;
fflush(fp);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1, int a2)
{
if ( vdevice[35] != tlstx || vdevice[36] != tlsty )
{
fputc(29, fp);
HiXold = -1;
HiYold = -1;
LoYold = -1;
func1(vdevice[35], vdevice[36]);
}
func1(a1, a2);
tlstx = a1;
tlsty = a2;
fflush(fp);
return 0LL;
}

original_code:
static int
TEK_draw(int x, int y)
{
 if (tlstx != vdevice.cpVx || tlsty != vdevice.cpVy) {
  fputc('\035', fp);
  LoYold = HiYold = HiXold = -1;
  out_bytes(vdevice.cpVx, vdevice.cpVy);
 }
 out_bytes(x, y);
 tlstx = x;
 tlsty = y;
 fflush(fp);
 return(0);
}


decompiled_code:
__int64 __fastcall TEK_char(char a1)
{
if ( vdevice[35] != tlstx || vdevice[36] != tlsty )
{
fputc(29, fp);
HiXold = -1;
HiYold = -1;
LoYold = -1;
out_bytes(vdevice[35], vdevice[36]);
}
fputc(31, fp);
fputc(a1, fp);
tlsty = -1;
tlstx = -1;
fflush(fp);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(char a1)
{
if ( vdevice[35] != tlstx || vdevice[36] != tlsty )
{
fputc(29, fp);
HiXold = -1;
HiYold = -1;
LoYold = -1;
func1(vdevice[35], vdevice[36]);
}
fputc(31, fp);
fputc(a1, fp);
tlsty = -1;
tlstx = -1;
fflush(fp);
return 0LL;
}

original_code:
static int
TEK_char(char c)
{
 if (tlstx != vdevice.cpVx || tlsty != vdevice.cpVy) {
  fputc('\035', fp);
  LoYold = HiYold = HiXold = -1;
  out_bytes(vdevice.cpVx, vdevice.cpVy);
 }
 fputc('\037', fp);
 fputc(c, fp);
 tlstx = tlsty = -1;
 fflush(fp);
 return(0);
}

variable_types: c char


original_code:
static int
TEK_locator(int *x, int *y)
{
 char buf[5];
 int i;
 struct termio oldtty, newtty;
 if (click) {
  click = 0;
  return(0);
 }
 click = 1;
 if (fp == stdout) {
  ioctl(0, 0x5405, &oldtty);
  newtty = oldtty;
  newtty.c_iflag = 0000002 | 0002000 | 0000040;
  newtty.c_lflag = 0;
  newtty.c_cc[4] = 1;
  ioctl(0, 0x5406, &newtty);
 } else
  return(0);
 fputs("\037\033\032", fp);
 fflush(fp);
 for (i = 0; i < 5; i++)
  buf[i] = getchar();
 ioctl(0, 0x540B, (char *)((void *)0));
 *x = ((buf[1] & 037) << 5) | (buf[2] & 037);
 *y = ((buf[3] & 037) << 5) | (buf[4] & 037);
 ioctl(0, 0x5406, &oldtty);
 tlstx = tlsty = -1;
 return(1 << ((int)buf[0] - '1'));
}

canonical_original_code:
static int TEK_locator(int *x, int *y)
{
 char buf[5];
 int i;
 struct termio oldtty; struct termio newtty;
 if (click) {
  click = 0;
  return(0);
 }
 click = 1;
 if (fp == stdout) {
  ioctl(0, 0x5405, &oldtty);
  newtty = oldtty;
  newtty.c_iflag = 0000002 | 0002000 | 0000040;
  newtty.c_lflag = 0;
  newtty.c_cc[4] = 1;
  ioctl(0, 0x5406, &newtty);
 } else
  return(0);
 fputs("\037\033\032", fp);
 fflush(fp);
 for (i = 0; i < 5; i++)
  buf[i] = getchar();
 ioctl(0, 0x540B, (char *)((void *)0));
 *x = ((buf[1] & 037) << 5) | (buf[2] & 037);
 *y = ((buf[3] & 037) << 5) | (buf[4] & 037);
 ioctl(0, 0x5406, &oldtty);
 tlstx = tlsty = -1;
 return(1 << ((int)buf[0] - '1'));
}

variable_types:
buf
char [5]

variable_types: struct termio { unsigned short c_iflag; unsigned short c_oflag; unsigned short c_cflag; unsigned short c_lflag; unsigned char c_line; unsigned char c_cc[8]; }


decompiled_code:
__int64 TEK_init()
{
vdevice[26] = 1;
fp = (FILE *)voutfile();
fputc(29, fp);
vdevice[32] = 767;
vdevice[31] = 767;
vdevice[33] = 1023;
vdevice[34] = 767;
tlsty = -1;
tlstx = -1;
return 1LL;
}

canonical_decompiled_code:
__int64 func7()
{
vdevice[26] = 1;
fp = (FILE *)voutfile();
fputc(29, fp);
vdevice[32] = 767;
vdevice[31] = 767;
vdevice[33] = 1023;
vdevice[34] = 767;
tlsty = -1;
tlstx = -1;
return 1LL;
}

original_code:
static int
TEK_init(void)
{
 vdevice.depth = 1;
 fp = _voutfile();
 fputc('\035', fp);
 vdevice.sizeX = vdevice.sizeY = 767;
 vdevice.sizeSx = 1023;
 vdevice.sizeSy = 767;
 tlstx = tlsty = -1;
        return(1);
}

canonical_original_code:
static int TEK_init()
{
 vdevice.depth = 1;
 fp = _voutfile();
 fputc('\035', fp);
 vdevice.sizeX = vdevice.sizeY = 767;
 vdevice.sizeSx = 1023;
 vdevice.sizeSy = 767;
 tlstx = tlsty = -1;
        return(1);
}