CameraUpdate

decompiled_code:
__int64 __fastcall CameraUpdate(int a1)
{
__int64 result; // rax
__int64 v2; // rax
float v3; // xmm0_4
float v4; // xmm0_4
float v5; // xmm0_4
float v6; // xmm0_4
float v7; // xmm1_4
float v8; // xmm2_4
float v9; // xmm1_4
float v10; // xmm2_4
float v11; // xmm2_4
float v12; // xmm1_4
float v13; // xmm3_4
float v14; // xmm0_4
int v15; // xmm5_4
int v16; // xmm4_4
__int64 i; // rax
float v18; // xmm5_4
float v19; // xmm6_4
float v20; // [rsp+8h] [rbp-60h]
float v21; // [rsp+Ch] [rbp-5Ch]
float v22; // [rsp+18h] [rbp-50h] BYREF
float v23; // [rsp+1Ch] [rbp-4Ch]
float v24; // [rsp+20h] [rbp-48h]
int v25[3]; // [rsp+24h] [rbp-44h] BYREF
int v26[3]; // [rsp+30h] [rbp-38h] BYREF
char v27[12]; // [rsp+3Ch] [rbp-2Ch] BYREF
float v28; // [rsp+48h] [rbp-20h] BYREF
float v29; // [rsp+4Ch] [rbp-1Ch]
float v30; // [rsp+50h] [rbp-18h]
float v31; // [rsp+54h] [rbp-14h] BYREF
float v32; // [rsp+58h] [rbp-10h]
float v33; // [rsp+5Ch] [rbp-Ch]

result = cls[2427];
if ( !(_DWORD)result && !LODWORD(unk_9E0[148]) )
goto LABEL_3;
v5 = amf_camera_chase[8];
if ( v5 != 1.0 )
{
if ( v5 != 2.0 && (!a1 || !(LODWORD(unk_9E0[148]) | (unsigned int)result) || amf_camera_death[8] == 0.0) )
{
LABEL_3:
v2 = *(_QWORD *)&unk_9E0[331514];
v3 = unk_9E0[331516];
cameratype = 0;
camera_pos = v2;
result = *(_QWORD *)&unk_9E0[331520];
*((float *)&camera_pos + 2) = v3;
v4 = unk_9E0[331522];
camera_angles = result;
*((float *)&camera_angles + 2) = v4;
return result;
}
if ( !cameratype )
CameraRandomPoint((float *)(unsigned int)((_DWORD)unk_9E0 + 1326056));
cameratype = 2;
CL_TraceLine(&camera_pos, (unsigned int)((_DWORD)unk_9E0 + 1326056), &v28, v27);
v6 = unk_9E0[331514];
if ( v6 != v28 || (v7 = unk_9E0[331515], v7 != v29) || (v8 = unk_9E0[331516], v8 != v30) )
{
CameraRandomPoint((float *)(unsigned int)((_DWORD)unk_9E0 + 1326056));
v6 = unk_9E0[331514];
v7 = unk_9E0[331515];
v8 = unk_9E0[331516];
}
v9 = v7 - *((float *)&camera_pos + 1);
v10 = v8 - *((float *)&camera_pos + 2);
v31 = v6 - *(float *)&camera_pos;
v32 = v9;
v33 = v10;
result = vectoangles(&v31, v26);
v11 = *(float *)&camera_pos;
LODWORD(v12) = v26[0] ^ LC5;
v13 = *((float *)&camera_pos + 1);
v14 = *((float *)&camera_pos + 2);
v15 = v26[1];
v16 = v26[2];
goto LABEL_25;
}
cameratype = 1;
if ( a1 )
{
cameratype = 2;
return result;
}
v21 = amf_camera_chase_dist[8];
v20 = amf_camera_chase_height[8];
AngleVectors((unsigned int)((_DWORD)unk_9E0 + 1325992), v25, v27, v26);
for ( i = 0LL; i != 3; ++i )
*(float *)((char *)&v22 + i * 4) = (float)(*(float *)&v25[i] * v21) + r_refdef[i + 30];
v24 = v20 + v24;
result = CL_TraceLine((unsigned int)((_DWORD)r_refdef + 120), &v22, &v31, &v28);
v11 = v22;
if ( v22 == v31 )
{
v13 = v23;
v18 = v32;
v19 = v33;
if ( v23 == v32 )
{
v14 = v24;
if ( v24 == v33 )
goto LABEL_24;
}
}
else
{
v18 = v32;
v19 = v33;
}
v11 = (float)((float)(*(float *)v25 * 8.0) + v31) + (float)(v28 * 4.0);
v13 = (float)((float)(*(float *)&v25[1] * 8.0) + v18) + (float)(v29 * 4.0);
v14 = (float)((float)(8.0 * *(float *)&v25[2]) + v19) + (float)(4.0 * v30);
LABEL_24:
v12 = unk_9E0[331520];
v15 = LODWORD(unk_9E0[331521]);
v16 = LODWORD(unk_9E0[331522]);
LABEL_25:
r_refdef[30] = v11;
r_refdef[31] = v13;
r_refdef[32] = v14;
r_refdef[33] = v12;
LODWORD(r_refdef[34]) = v15;
LODWORD(r_refdef[35]) = v16;
*(float *)&camera_pos = v11;
*((float *)&camera_pos + 1) = v13;
*((float *)&camera_pos + 2) = v14;
*(float *)&camera_angles = v12;
HIDWORD(camera_angles) = v15;
*((_DWORD *)&camera_angles + 2) = v16;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
__int64 result; // rax
__int64 v2; // rax
float v3; // xmm0_4
float v4; // xmm0_4
float v5; // xmm0_4
float v6; // xmm0_4
float v7; // xmm1_4
float v8; // xmm2_4
float v9; // xmm1_4
float v10; // xmm2_4
float v11; // xmm2_4
float v12; // xmm1_4
float v13; // xmm3_4
float v14; // xmm0_4
int v15; // xmm5_4
int v16; // xmm4_4
__int64 i; // rax
float v18; // xmm5_4
float v19; // xmm6_4
float v20; // [rsp+8h] [rbp-60h]
float v21; // [rsp+Ch] [rbp-5Ch]
float v22; // [rsp+18h] [rbp-50h] BYREF
float v23; // [rsp+1Ch] [rbp-4Ch]
float v24; // [rsp+20h] [rbp-48h]
int v25[3]; // [rsp+24h] [rbp-44h] BYREF
int v26[3]; // [rsp+30h] [rbp-38h] BYREF
char v27[12]; // [rsp+3Ch] [rbp-2Ch] BYREF
float v28; // [rsp+48h] [rbp-20h] BYREF
float v29; // [rsp+4Ch] [rbp-1Ch]
float v30; // [rsp+50h] [rbp-18h]
float v31; // [rsp+54h] [rbp-14h] BYREF
float v32; // [rsp+58h] [rbp-10h]
float v33; // [rsp+5Ch] [rbp-Ch]

result = cls[2427];
if ( !(_DWORD)result && !LODWORD(unk_9E0[148]) )
goto LABEL_3;
v5 = amf_camera_chase[8];
if ( v5 != 1.0 )
{
if ( v5 != 2.0 && (!a1 || !(LODWORD(unk_9E0[148]) | (unsigned int)result) || amf_camera_death[8] == 0.0) )
{
LABEL_3:
v2 = *(_QWORD *)&unk_9E0[331514];
v3 = unk_9E0[331516];
cameratype = 0;
camera_pos = v2;
result = *(_QWORD *)&unk_9E0[331520];
*((float *)&camera_pos + 2) = v3;
v4 = unk_9E0[331522];
camera_angles = result;
*((float *)&camera_angles + 2) = v4;
return result;
}
if ( !cameratype )
func0((float *)(unsigned int)((_DWORD)unk_9E0 + 1326056));
cameratype = 2;
CL_TraceLine(&camera_pos, (unsigned int)((_DWORD)unk_9E0 + 1326056), &v28, v27);
v6 = unk_9E0[331514];
if ( v6 != v28 || (v7 = unk_9E0[331515], v7 != v29) || (v8 = unk_9E0[331516], v8 != v30) )
{
func0((float *)(unsigned int)((_DWORD)unk_9E0 + 1326056));
v6 = unk_9E0[331514];
v7 = unk_9E0[331515];
v8 = unk_9E0[331516];
}
v9 = v7 - *((float *)&camera_pos + 1);
v10 = v8 - *((float *)&camera_pos + 2);
v31 = v6 - *(float *)&camera_pos;
v32 = v9;
v33 = v10;
result = vectoangles(&v31, v26);
v11 = *(float *)&camera_pos;
LODWORD(v12) = v26[0] ^ LC5;
v13 = *((float *)&camera_pos + 1);
v14 = *((float *)&camera_pos + 2);
v15 = v26[1];
v16 = v26[2];
goto LABEL_25;
}
cameratype = 1;
if ( a1 )
{
cameratype = 2;
return result;
}
v21 = amf_camera_chase_dist[8];
v20 = amf_camera_chase_height[8];
AngleVectors((unsigned int)((_DWORD)unk_9E0 + 1325992), v25, v27, v26);
for ( i = 0LL; i != 3; ++i )
*(float *)((char *)&v22 + i * 4) = (float)(*(float *)&v25[i] * v21) + r_refdef[i + 30];
v24 = v20 + v24;
result = CL_TraceLine((unsigned int)((_DWORD)r_refdef + 120), &v22, &v31, &v28);
v11 = v22;
if ( v22 == v31 )
{
v13 = v23;
v18 = v32;
v19 = v33;
if ( v23 == v32 )
{
v14 = v24;
if ( v24 == v33 )
goto LABEL_24;
}
}
else
{
v18 = v32;
v19 = v33;
}
v11 = (float)((float)(*(float *)v25 * 8.0) + v31) + (float)(v28 * 4.0);
v13 = (float)((float)(*(float *)&v25[1] * 8.0) + v18) + (float)(v29 * 4.0);
v14 = (float)((float)(8.0 * *(float *)&v25[2]) + v19) + (float)(4.0 * v30);
LABEL_24:
v12 = unk_9E0[331520];
v15 = LODWORD(unk_9E0[331521]);
v16 = LODWORD(unk_9E0[331522]);
LABEL_25:
r_refdef[30] = v11;
r_refdef[31] = v13;
r_refdef[32] = v14;
r_refdef[33] = v12;
LODWORD(r_refdef[34]) = v15;
LODWORD(r_refdef[35]) = v16;
*(float *)&camera_pos = v11;
*((float *)&camera_pos + 1) = v13;
*((float *)&camera_pos + 2) = v14;
*(float *)&camera_angles = v12;
HIDWORD(camera_angles) = v15;
*((_DWORD *)&camera_angles + 2) = v16;
return result;
}

original_code:
void CameraUpdate (qbool dead)
{
 vec3_t dest, destangles;
 if ((cls.demoplayback || cl.spectator) && amf_camera_chase.value == 1)
  cameratype = C_CHASECAM;
 else if ((cls.demoplayback || cl.spectator) && amf_camera_chase.value == 2)
 {
  if (cameratype == C_NORMAL)
   CameraRandomPoint (cl.simorg);
  cameratype = C_EXTERNAL;
 }
 else if (dead && (cls.demoplayback || cl.spectator) && amf_camera_death.value)
 {
  if (cameratype == C_NORMAL)
   CameraRandomPoint (cl.simorg);
  cameratype = C_EXTERNAL;
 }
 else
  cameratype = C_NORMAL;
 if (cameratype == C_NORMAL)
 {
  ((camera_pos)[0] = (cl.simorg)[0], (camera_pos)[1] = (cl.simorg)[1], (camera_pos)[2] = (cl.simorg)[2]);
  ((camera_angles)[0] = (cl.simangles)[0], (camera_angles)[1] = (cl.simangles)[1], (camera_angles)[2] = (cl.simangles)[2]);
  return;
 }
 if (cameratype == C_CHASECAM)
 {
  if (!dead)
  {
   float dist = amf_camera_chase_dist.value;
   float height = amf_camera_chase_height.value;
   int i;
   vec3_t forward, up, right, normal, impact;
   AngleVectors (cl.viewangles, forward, right, up);
   for (i=0;i<3;i++)
    dest[i] = r_refdef.vieworg[i] + forward[i] * dist;
   dest[2] = dest[2] + height;
   CL_TraceLine (r_refdef.vieworg, dest, impact, normal);
   if (!((dest)[0] == (impact)[0] && (dest)[1] == (impact)[1] && (dest)[2] == (impact)[2]))
   {
    dest[0] = impact[0] + forward[0] * 8 + normal[0] * 4;
    dest[1] = impact[1] + forward[1] * 8 + normal[1] * 4;
    dest[2] = impact[2] + forward[2] * 8 + normal[2] * 4;
   }
   ((destangles)[0] = (cl.simangles)[0], (destangles)[1] = (cl.simangles)[1], (destangles)[2] = (cl.simangles)[2]);
  }
  else
  {
   cameratype = C_EXTERNAL;
   return;
  }
 }
 else if (cameratype == C_EXTERNAL)
 {
  vec3_t normal, impact, vec;
  CL_TraceLine (camera_pos, cl.simorg, impact, normal);
  if (!((cl.simorg)[0] == (impact)[0] && (cl.simorg)[1] == (impact)[1] && (cl.simorg)[2] == (impact)[2]))
   CameraRandomPoint (cl.simorg);
  ((vec)[0] = (cl.simorg)[0] - (camera_pos)[0], (vec)[1] = (cl.simorg)[1] - (camera_pos)[1], (vec)[2] = (cl.simorg)[2] - (camera_pos)[2]);
  vectoangles(vec, destangles);
  destangles[0] = -destangles[0];
  ((dest)[0] = (camera_pos)[0], (dest)[1] = (camera_pos)[1], (dest)[2] = (camera_pos)[2]);
 }
 ((r_refdef.vieworg)[0] = (dest)[0], (r_refdef.vieworg)[1] = (dest)[1], (r_refdef.vieworg)[2] = (dest)[2]);
 ((r_refdef.viewangles)[0] = (destangles)[0], (r_refdef.viewangles)[1] = (destangles)[1], (r_refdef.viewangles)[2] = (destangles)[2]);
 ((camera_pos)[0] = (dest)[0], (camera_pos)[1] = (dest)[1], (camera_pos)[2] = (dest)[2]);
 ((camera_angles)[0] = (destangles)[0], (camera_angles)[1] = (destangles)[1], (camera_angles)[2] = (destangles)[2]);
}

canonical_original_code:
void CameraUpdate(enum qbool dead)
{
 float dest[3]; float destangles[3];
 if ((cls.demoplayback || cl.spectator) && amf_camera_chase.value == 1)
  cameratype = C_CHASECAM;
 else if ((cls.demoplayback || cl.spectator) && amf_camera_chase.value == 2)
 {
  if (cameratype == C_NORMAL)
   CameraRandomPoint (cl.simorg);
  cameratype = C_EXTERNAL;
 }
 else if (dead && (cls.demoplayback || cl.spectator) && amf_camera_death.value)
 {
  if (cameratype == C_NORMAL)
   CameraRandomPoint (cl.simorg);
  cameratype = C_EXTERNAL;
 }
 else
  cameratype = C_NORMAL;
 if (cameratype == C_NORMAL)
 {
  ((camera_pos)[0] = (cl.simorg)[0], (camera_pos)[1] = (cl.simorg)[1], (camera_pos)[2] = (cl.simorg)[2]);
  ((camera_angles)[0] = (cl.simangles)[0], (camera_angles)[1] = (cl.simangles)[1], (camera_angles)[2] = (cl.simangles)[2]);
  return;
 }
 if (cameratype == C_CHASECAM)
 {
  if (!dead)
  {
   float dist = amf_camera_chase_dist.value;
   float height = amf_camera_chase_height.value;
   int i;
   float forward[3]; float up[3]; float right[3]; float normal[3]; float impact[3];
   AngleVectors (cl.viewangles, forward, right, up);
   for (i=0;i<3;i++)
    dest[i] = r_refdef.vieworg[i] + forward[i] * dist;
   dest[2] = dest[2] + height;
   CL_TraceLine (r_refdef.vieworg, dest, impact, normal);
   if (!((dest)[0] == (impact)[0] && (dest)[1] == (impact)[1] && (dest)[2] == (impact)[2]))
   {
    dest[0] = impact[0] + forward[0] * 8 + normal[0] * 4;
    dest[1] = impact[1] + forward[1] * 8 + normal[1] * 4;
    dest[2] = impact[2] + forward[2] * 8 + normal[2] * 4;
   }
   ((destangles)[0] = (cl.simangles)[0], (destangles)[1] = (cl.simangles)[1], (destangles)[2] = (cl.simangles)[2]);
  }
  else
  {
   cameratype = C_EXTERNAL;
   return;
  }
 }
 else if (cameratype == C_EXTERNAL)
 {
  float normal[3]; float impact[3]; float vec[3];
  CL_TraceLine (camera_pos, cl.simorg, impact, normal);
  if (!((cl.simorg)[0] == (impact)[0] && (cl.simorg)[1] == (impact)[1] && (cl.simorg)[2] == (impact)[2]))
   CameraRandomPoint (cl.simorg);
  ((vec)[0] = (cl.simorg)[0] - (camera_pos)[0], (vec)[1] = (cl.simorg)[1] - (camera_pos)[1], (vec)[2] = (cl.simorg)[2] - (camera_pos)[2]);
  vectoangles(vec, destangles);
  destangles[0] = -destangles[0];
  ((dest)[0] = (camera_pos)[0], (dest)[1] = (camera_pos)[1], (dest)[2] = (camera_pos)[2]);
 }
 ((r_refdef.vieworg)[0] = (dest)[0], (r_refdef.vieworg)[1] = (dest)[1], (r_refdef.vieworg)[2] = (dest)[2]);
 ((r_refdef.viewangles)[0] = (destangles)[0], (r_refdef.viewangles)[1] = (destangles)[1], (r_refdef.viewangles)[2] = (destangles)[2]);
 ((camera_pos)[0] = (dest)[0], (camera_pos)[1] = (dest)[1], (camera_pos)[2] = (dest)[2]);
 ((camera_angles)[0] = (destangles)[0], (camera_angles)[1] = (destangles)[1], (camera_angles)[2] = (destangles)[2]);
}

variable_types:
dead
enum qbool { false=0, true=1 }

variable_types:
destangles
float [3]

variable_types: dist float

variable_types: height float

variable_types: i int

variable_types:
impact
float [3]


repo: jite/jquake

decompiled_code:
__int64 __fastcall Help_DescribeCmd(_QWORD *a1)
{
__int64 v1; // rsi
__int64 v2; // rsi
__int64 result; // rax
bool v4; // zf
__int64 v5; // rbx
const char *v6; // rsi
const char *v7; // rsi

if ( a1 )
{
v1 = a1[2];
con_margin = 2;
Com_Printf("%s\n", v1);
con_margin = 0;
Com_Printf("\n", v1);
con_ormask = 128;
Com_Printf("syntax\n", v1);
v2 = a1[1];
con_ormask = 0;
con_margin = 2;
result = Com_Printf("%s %s\n", v2);
v4 = a1[4] == 0LL;
con_margin = 0;
if ( !v4 )
{
Com_Printf("\n", v2);
con_ormask = 128;
result = Com_Printf("arguments\n", v2);
v5 = a1[4];
for ( con_ormask = 0; v5; con_margin = 0 )
{
con_ormask = 128;
con_margin = 2;
Com_Printf("%s", *(const char **)v5);
v6 = *(const char **)(v5 + 8);
con_margin += 2;
con_ormask = 0;
result = Com_Printf(" - %s\n", v6);
v5 = *(_QWORD *)(v5 + 16);
}
}
if ( a1[5] )
{
Com_Printf("\n");
con_ormask = 128;
Com_Printf("remarks\n");
v7 = (const char *)a1[5];
con_ormask = 0;
con_margin = 2;
result = Com_Printf("%s\n", v7);
con_margin = 0;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1)
{
__int64 v1; // rsi
__int64 v2; // rsi
__int64 result; // rax
bool v4; // zf
__int64 v5; // rbx
const char *v6; // rsi
const char *v7; // rsi

if ( a1 )
{
v1 = a1[2];
con_margin = 2;
Com_Printf("%s\n", v1);
con_margin = 0;
Com_Printf("\n", v1);
con_ormask = 128;
Com_Printf("syntax\n", v1);
v2 = a1[1];
con_ormask = 0;
con_margin = 2;
result = Com_Printf("%s %s\n", v2);
v4 = a1[4] == 0LL;
con_margin = 0;
if ( !v4 )
{
Com_Printf("\n", v2);
con_ormask = 128;
result = Com_Printf("arguments\n", v2);
v5 = a1[4];
for ( con_ormask = 0; v5; con_margin = 0 )
{
con_ormask = 128;
con_margin = 2;
Com_Printf("%s", *(const char **)v5);
v6 = *(const char **)(v5 + 8);
con_margin += 2;
con_ormask = 0;
result = Com_Printf(" - %s\n", v6);
v5 = *(_QWORD *)(v5 + 16);
}
}
if ( a1[5] )
{
Com_Printf("\n");
con_ormask = 128;
Com_Printf("remarks\n");
v7 = (const char *)a1[5];
con_ormask = 0;
con_margin = 2;
result = Com_Printf("%s\n", v7);
con_margin = 0;
}
}
return result;
}

original_code:
void Help_DescribeCmd(xml_command_t *cmd)
{
    command_argument_t *arg;
 if (!cmd) return;
    con_margin = 2;
    Com_Printf("%s\n", cmd->description);
    con_margin = 0;
    Com_Printf("\n");
    con_ormask = 128;
    Com_Printf("syntax\n");
    con_ormask = 0;
    con_margin = 2;
    Com_Printf("%s %s\n", cmd->name, cmd->syntax);
    con_margin = 0;
    if (cmd->arguments)
    {
        Com_Printf("\n");
        con_ormask = 128;
        Com_Printf("arguments\n");
        con_ormask = 0;
        arg = cmd->arguments;
        while (arg)
        {
            con_ormask = 128;
            con_margin = 2;
            Com_Printf("%s", arg->name);
            con_ormask = 0;
            con_margin += 2;
            Com_Printf(" - %s\n", arg->description);
            con_margin = 0;
            arg = arg->next;
        }
    }
    if (cmd->remarks)
    {
        Com_Printf("\n");
        con_ormask = 128;
        Com_Printf("remarks\n");
        con_ormask = 0;
        con_margin = 2;
        Com_Printf("%s\n", cmd->remarks);
        con_margin = 0;
    }
}

canonical_original_code:
void Help_DescribeCmd(struct xml_command_s *cmd)
{
    struct command_argument_s *arg;
 if (!cmd) return;
    con_margin = 2;
    Com_Printf("%s\n", cmd->description);
    con_margin = 0;
    Com_Printf("\n");
    con_ormask = 128;
    Com_Printf("syntax\n");
    con_ormask = 0;
    con_margin = 2;
    Com_Printf("%s %s\n", cmd->name, cmd->syntax);
    con_margin = 0;
    if (cmd->arguments)
    {
        Com_Printf("\n");
        con_ormask = 128;
        Com_Printf("arguments\n");
        con_ormask = 0;
        arg = cmd->arguments;
        while (arg)
        {
            con_ormask = 128;
            con_margin = 2;
            Com_Printf("%s", arg->name);
            con_ormask = 0;
            con_margin += 2;
            Com_Printf(" - %s\n", arg->description);
            con_margin = 0;
            arg = arg->next;
        }
    }
    if (cmd->remarks)
    {
        Com_Printf("\n");
        con_ormask = 128;
        Com_Printf("remarks\n");
        con_ormask = 0;
        con_margin = 2;
        Com_Printf("%s\n", cmd->remarks);
        con_margin = 0;
    }
}

variable_types: struct xml_command_s { char *document_type; char *name; char *description; char *syntax; struct command_argument_s { char *name; char *description; struct command_argument_s *next; } *arguments; char *remarks; } *

return_type: void

user_defined_types: struct xml_command_s { char *document_type; char *name; char *description; char *syntax; struct command_argument_s *arguments; char *remarks; }


decompiled_code:
void __fastcall Help_DescribeVar(__int64 a1)
{
const char *v1; // rsi
_BYTE *v2; // rax
const char *v3; // rsi
_BYTE *v4; // rax
_BYTE *v5; // rdx
const char *v6; // rsi
const char *v7; // rsi
__int64 i; // rbp
const char *v9; // rsi

if ( a1 )
{
v1 = *(const char **)(a1 + 16);
con_margin = 2;
Com_Printf("%s\n", v1);
con_margin = 0;
Com_Printf("\n");
con_ormask = 128;
Com_Printf("value\n");
con_ormask = 0;
con_margin = 2;
switch ( *(_DWORD *)(a1 + 24) )
{
case 0:
v4 = *(_BYTE **)(a1 + 40);
if ( v4 && (v5 = *(_BYTE **)(a1 + 32)) != 0LL && (*v4 || *v5) )
{
con_ormask = 128;
Com_Printf("0");
v6 = *(const char **)(a1 + 40);
con_margin += 2;
con_ormask = 0;
Com_Printf(" - %s\n", v6);
con_margin -= 2;
con_ormask = 128;
Com_Printf("1");
v7 = *(const char **)(a1 + 32);
con_margin += 2;
con_ormask = 0;
Com_Printf(" - %s\n", v7);
}
else
{
con_margin = 4;
Com_Printf("Boolean value. Use ");
con_ormask = 128;
Com_Printf("0 or 1");
con_ormask = 0;
Com_Printf(" as a value.\n");
}
break;
case 1:
for ( i = *(_QWORD *)(a1 + 32); i; con_margin -= 2 )
{
con_ormask = 128;
Com_Printf("%s", *(const char **)i);
v9 = *(const char **)(i + 8);
con_margin += 2;
con_ormask = 0;
Com_Printf(" - %s\n", v9);
i = *(_QWORD *)(i + 16);
}
break;
case 2:
case 3:
case 4:
Com_Printf("%s\n", *(const char **)(a1 + 32));
break;
default:
break;
}
con_margin = 0;
v2 = *(_BYTE **)(a1 + 48);
if ( v2 )
{
if ( *v2 )
{
Com_Printf("\n");
con_ormask = 128;
Com_Printf("remarks\n");
v3 = *(const char **)(a1 + 48);
con_ormask = 0;
con_margin = 2;
Com_Printf("%s\n", v3);
con_margin = 0;
}
}
}
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1)
{
const char *v1; // rsi
_BYTE *v2; // rax
const char *v3; // rsi
_BYTE *v4; // rax
_BYTE *v5; // rdx
const char *v6; // rsi
const char *v7; // rsi
__int64 i; // rbp
const char *v9; // rsi

if ( a1 )
{
v1 = *(const char **)(a1 + 16);
con_margin = 2;
Com_Printf("%s\n", v1);
con_margin = 0;
Com_Printf("\n");
con_ormask = 128;
Com_Printf("value\n");
con_ormask = 0;
con_margin = 2;
switch ( *(_DWORD *)(a1 + 24) )
{
case 0:
v4 = *(_BYTE **)(a1 + 40);
if ( v4 && (v5 = *(_BYTE **)(a1 + 32)) != 0LL && (*v4 || *v5) )
{
con_ormask = 128;
Com_Printf("0");
v6 = *(const char **)(a1 + 40);
con_margin += 2;
con_ormask = 0;
Com_Printf(" - %s\n", v6);
con_margin -= 2;
con_ormask = 128;
Com_Printf("1");
v7 = *(const char **)(a1 + 32);
con_margin += 2;
con_ormask = 0;
Com_Printf(" - %s\n", v7);
}
else
{
con_margin = 4;
Com_Printf("Boolean value. Use ");
con_ormask = 128;
Com_Printf("0 or 1");
con_ormask = 0;
Com_Printf(" as a value.\n");
}
break;
case 1:
for ( i = *(_QWORD *)(a1 + 32); i; con_margin -= 2 )
{
con_ormask = 128;
Com_Printf("%s", *(const char **)i);
v9 = *(const char **)(i + 8);
con_margin += 2;
con_ormask = 0;
Com_Printf(" - %s\n", v9);
i = *(_QWORD *)(i + 16);
}
break;
case 2:
case 3:
case 4:
Com_Printf("%s\n", *(const char **)(a1 + 32));
break;
default:
break;
}
con_margin = 0;
v2 = *(_BYTE **)(a1 + 48);
if ( v2 )
{
if ( *v2 )
{
Com_Printf("\n");
con_ormask = 128;
Com_Printf("remarks\n");
v3 = *(const char **)(a1 + 48);
con_ormask = 0;
con_margin = 2;
Com_Printf("%s\n", v3);
con_margin = 0;
}
}
}
}

original_code:
void Help_DescribeVar(xml_variable_t *var)
{
 variable_enum_value_t *val;
 if (!var) return;
    con_margin = 2;
    Com_Printf("%s\n", var->description);
    con_margin = 0;
    Com_Printf("\n");
    con_ormask = 128;
    Com_Printf("value\n");
    con_ormask = 0;
    con_margin = 2;
    switch (var->value_type)
    {
    case t_string:
        Com_Printf("%s\n", var->value.string_description);
        break;
    case t_integer:
        Com_Printf("%s\n", var->value.integer_description);
        break;
    case t_float:
  Com_Printf("%s\n", var->value.float_description);
        break;
    case t_boolean:
  if (var->value.boolean_value.false_description && var->value.boolean_value.true_description
   &&
   (strlen(var->value.boolean_value.false_description) || strlen(var->value.boolean_value.true_description)))
  {
   con_ormask = 128;
   Com_Printf("0");
   con_ormask = 0;
   con_margin += 2;
   Com_Printf(" - %s\n", var->value.boolean_value.false_description);
   con_margin -= 2;
   con_ormask = 128;
   Com_Printf("1");
   con_ormask = 0;
   con_margin += 2;
   Com_Printf(" - %s\n", var->value.boolean_value.true_description);
   con_margin -= 2;
  }
  else
  {
   con_margin += 2;
   Com_Printf("Boolean value. Use ");
   con_ormask = 128;
   Com_Printf("0 or 1");
   con_ormask = 0;
   Com_Printf(" as a value.\n");
   con_margin -= 2;
  }
        break;
    case t_enum:
        val = var->value.enum_value;
        while (val)
        {
            con_ormask = 128;
            Com_Printf("%s", val->name);
            con_ormask = 0;
            con_margin += 2;
            Com_Printf(" - %s\n", val->description);
            con_margin -= 2;
            val = val->next;
        }
        break;
    }
    con_margin = 0;
 if (var->remarks && strlen(var->remarks))
    {
        Com_Printf("\n");
        con_ormask = 128;
        Com_Printf("remarks\n");
        con_ormask = 0;
        con_margin = 2;
        Com_Printf("%s\n", var->remarks);
        con_margin = 0;
    }
}

canonical_original_code:
void Help_DescribeVar(struct xml_variable_s *var)
{
 struct variable_enum_value_s *val;
 if (!var) return;
    con_margin = 2;
    Com_Printf("%s\n", var->description);
    con_margin = 0;
    Com_Printf("\n");
    con_ormask = 128;
    Com_Printf("value\n");
    con_ormask = 0;
    con_margin = 2;
    switch (var->value_type)
    {
    case t_string:
        Com_Printf("%s\n", var->value.string_description);
        break;
    case t_integer:
        Com_Printf("%s\n", var->value.integer_description);
        break;
    case t_float:
  Com_Printf("%s\n", var->value.float_description);
        break;
    case t_boolean:
  if (var->value.boolean_value.false_description && var->value.boolean_value.true_description
   &&
   (strlen(var->value.boolean_value.false_description) || strlen(var->value.boolean_value.true_description)))
  {
   con_ormask = 128;
   Com_Printf("0");
   con_ormask = 0;
   con_margin += 2;
   Com_Printf(" - %s\n", var->value.boolean_value.false_description);
   con_margin -= 2;
   con_ormask = 128;
   Com_Printf("1");
   con_ormask = 0;
   con_margin += 2;
   Com_Printf(" - %s\n", var->value.boolean_value.true_description);
   con_margin -= 2;
  }
  else
  {
   con_margin += 2;
   Com_Printf("Boolean value. Use ");
   con_ormask = 128;
   Com_Printf("0 or 1");
   con_ormask = 0;
   Com_Printf(" as a value.\n");
   con_margin -= 2;
  }
        break;
    case t_enum:
        val = var->value.enum_value;
        while (val)
        {
            con_ormask = 128;
            Com_Printf("%s", val->name);
            con_ormask = 0;
            con_margin += 2;
            Com_Printf(" - %s\n", val->description);
            con_margin -= 2;
            val = val->next;
        }
        break;
    }
    con_margin = 0;
 if (var->remarks && strlen(var->remarks))
    {
        Com_Printf("\n");
        con_ormask = 128;
        Com_Printf("remarks\n");
        con_ormask = 0;
        con_margin = 2;
        Com_Printf("%s\n", var->remarks);
        con_margin = 0;
    }
}

variable_types: struct xml_variable_s { char *document_type; char *name; char *description; enum cvartype_t { t_boolean=0, t_enum=1, t_integer=2, t_float=3, t_string=4 } value_type; union { char *string_description; char *integer_description; char *float_description; struct { char *true_description; char *false_description; } boolean_value; struct variable_enum_value_s { char *name; char *description; struct variable_enum_value_s *next; } *enum_value; } value; char *remarks; } *

user_defined_types: struct xml_variable_s { char *document_type; char *name; char *description; enum cvartype_t value_type; union { char *string_description; char *integer_description; char *float_description; struct { char *true_description; char *false_description; } boolean_value; struct variable_enum_value_s *enum_value; } value; char *remarks; }


decompiled_code:
__int64 Help_Describe_f()
{
const char *v0; // rdi
const char *v1; // r12
__int64 v2; // rax
__int64 v3; // rax
_QWORD *v4; // rbp
const char *v5; // rsi
__int64 v6; // rax
__int64 result; // rax
__int64 v8; // rbp
__int64 v9; // rax
const char *v10; // rsi

v0 = "usage: /describe <command|variable>\ne.g. /describe ignore\n";
if ( (unsigned int)Cmd_Argc() != 2 )
return Com_Printf(v0);
v1 = (const char *)Cmd_Argv(1LL);
v2 = va("help/commands/%s.xml", v1);
v3 = XSD_Command_Load(v2);
v4 = (_QWORD *)v3;
if ( !v3 )
{
v9 = va("help/variables/%s.xml", v1);
v8 = XSD_Variable_Load(v9);
if ( v8 )
{
LABEL_9:
v10 = *(const char **)(v8 + 8);
con_ormask = 128;
Com_Printf("%s is a variable\n", v10);
con_ormask = 0;
Help_DescribeVar(v8);
return XSD_Variable_Free(v8);
}
v0 = "Nothing found.\n";
return Com_Printf(v0);
}
v5 = *(const char **)(v3 + 8);
con_ormask = 128;
Com_Printf("%s is a command\n", v5);
con_ormask = 0;
Help_DescribeCmd(v4);
XSD_Command_Free(v4);
v6 = va("help/variables/%s.xml", v1);
result = XSD_Variable_Load(v6);
v8 = result;
if ( result )
{
Com_Printf("\n\n\n");
goto LABEL_9;
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
const char *v0; // rdi
const char *v1; // r12
__int64 v2; // rax
__int64 v3; // rax
_QWORD *v4; // rbp
const char *v5; // rsi
__int64 v6; // rax
__int64 result; // rax
__int64 v8; // rbp
__int64 v9; // rax
const char *v10; // rsi

v0 = "usage: /describe <command|variable>\ne.g. /describe ignore\n";
if ( (unsigned int)Cmd_Argc() != 2 )
return Com_Printf(v0);
v1 = (const char *)Cmd_Argv(1LL);
v2 = va("help/commands/%s.xml", v1);
v3 = XSD_Command_Load(v2);
v4 = (_QWORD *)v3;
if ( !v3 )
{
v9 = va("help/variables/%s.xml", v1);
v8 = XSD_Variable_Load(v9);
if ( v8 )
{
LABEL_9:
v10 = *(const char **)(v8 + 8);
con_ormask = 128;
Com_Printf("%s is a variable\n", v10);
con_ormask = 0;
func1(v8);
return XSD_Variable_Free(v8);
}
v0 = "Nothing found.\n";
return Com_Printf(v0);
}
v5 = *(const char **)(v3 + 8);
con_ormask = 128;
Com_Printf("%s is a command\n", v5);
con_ormask = 0;
func0(v4);
XSD_Command_Free(v4);
v6 = va("help/variables/%s.xml", v1);
result = XSD_Variable_Load(v6);
v8 = result;
if ( result )
{
Com_Printf("\n\n\n");
goto LABEL_9;
}
return result;
}

original_code:
void Help_Describe_f(void)
{
    qbool found = false;
    char *name;
    xml_command_t *cmd;
    xml_variable_t *var;
    if (Cmd_Argc() != 2)
    {
        Com_Printf("usage: /describe <command|variable>\ne.g. /describe ignore\n");
        return;
    }
    name = Cmd_Argv(1);
    cmd = XSD_Command_Load(va("help/commands/%s.xml", name));
    if (cmd)
    {
        found = true;
        con_ormask = 128;
        Com_Printf("%s is a command\n", cmd->name);
        con_ormask = 0;
  Help_DescribeCmd(cmd);
        XSD_Command_Free( (xml_t *)cmd );
    }
    var = XSD_Variable_Load(va("help/variables/%s.xml", name));
    if (var)
    {
        if (found)
            Com_Printf("\n\n\n");
        found = true;
        con_ormask = 128;
        Com_Printf("%s is a variable\n", var->name);
        con_ormask = 0;
  Help_DescribeVar(var);
        XSD_Variable_Free( (xml_t *)var );
    }
    if (!found)
        Com_Printf("Nothing found.\n");
}

canonical_original_code:
void Help_Describe_f()
{
    enum qbool found = false;
    char *name;
    struct xml_command_s *cmd;
    struct xml_variable_s *var;
    if (Cmd_Argc() != 2)
    {
        Com_Printf("usage: /describe <command|variable>\ne.g. /describe ignore\n");
        return;
    }
    name = Cmd_Argv(1);
    cmd = XSD_Command_Load(va("help/commands/%s.xml", name));
    if (cmd)
    {
        found = true;
        con_ormask = 128;
        Com_Printf("%s is a command\n", cmd->name);
        con_ormask = 0;
  Help_DescribeCmd(cmd);
        XSD_Command_Free( (struct xml_s *)cmd );
    }
    var = XSD_Variable_Load(va("help/variables/%s.xml", name));
    if (var)
    {
        if (found)
            Com_Printf("\n\n\n");
        found = true;
        con_ormask = 128;
        Com_Printf("%s is a variable\n", var->name);
        con_ormask = 0;
  Help_DescribeVar(var);
        XSD_Variable_Free( (struct xml_s *)var );
    }
    if (!found)
        Com_Printf("Nothing found.\n");
}

variable_types:
found
enum qbool { false=0, true=1 }

variable_types:
name
char *

user_defined_types: enum cvartype_t { t_boolean=0, t_enum=1, t_integer=2, t_float=3, t_string=4 }

user_defined_types: struct command_argument_s { char *name; char *description; struct command_argument_s *next; }

user_defined_types: struct variable_enum_value_s { char *name; char *description; struct variable_enum_value_s *next; }


decompiled_code:
void __fastcall Help_DescribeCvar(const char **a1)
{
__int64 v1; // rax
__int64 v2; // rax

v1 = va("help/variables/%s.xml", *a1);
v2 = XSD_Variable_Load(v1);
Help_DescribeVar(v2);
}

canonical_decompiled_code:
void __fastcall func3(const char **a1)
{
__int64 v1; // rax
__int64 v2; // rax

v1 = va("help/variables/%s.xml", *a1);
v2 = XSD_Variable_Load(v1);
func1(v2);
}

original_code:
void Help_DescribeCvar (cvar_t *v)
{
 xml_variable_t *var = XSD_Variable_Load(va("help/variables/%s.xml", v->name));
 Help_DescribeVar(var);
}

canonical_original_code:
void Help_DescribeCvar(struct cvar_s *v)
{
 struct xml_variable_s *var = XSD_Variable_Load(va("help/variables/%s.xml", v->name));
 Help_DescribeVar(var);
}

variable_types: struct cvar_s { char *name; char *string; int flags; void (*OnChange)(struct cvar_s *var, char *value, enum qbool { false=0, true=1 } *cancel); float value; float maxrulesetvalue; float minrulesetvalue; char *defaultvalue; char *latchedString; int integer; unsigned char color[4]; enum qbool { false=0, true=1 } modified; enum qbool { false=0, true=1 } teamplay; struct cvar_group_s { char name[65]; int count; struct cvar_s *head; struct cvar_group_s *next; } *group; struct cvar_s *next_in_group; struct cvar_s *hash_next; struct cvar_s *next; } *

user_defined_types: struct cvar_s { char *name; char *string; int flags; void (*OnChange)(struct cvar_s *var, char *value, enum qbool *cancel); float value; float maxrulesetvalue; float minrulesetvalue; char *defaultvalue; char *latchedString; int integer; unsigned char color[4]; enum qbool modified; enum qbool teamplay; struct cvar_group_s *group; struct cvar_s *next_in_group; struct cvar_s *hash_next; struct cvar_s *next; }


decompiled_code:
__int64 __fastcall Help_VarDescription(char *s, char *a2, __int64 a3)
{
__int64 v5; // rax
__int64 v6; // rbp
__int64 result; // rax
__int64 v8; // r14
__int64 v9; // rsi
size_t v10; // rbx
size_t v11; // rax
_QWORD *i; // rbx

v5 = va("help/variables/%s.xml", s);
v6 = XSD_Variable_Load(v5);
result = menu_advanced[16];
if ( (_DWORD)result && *s )
{
strlcat(a2, "Variable name: ", a3);
strlcat(a2, s, a3);
v10 = strlen(a2);
v11 = strlen(s);
CharsToBrown(a2, &a2[v10 - v11]);
result = strlcat(a2, "\n", a3);
if ( !v6 )
return result;
}
else if ( !v6 )
{
return result;
}
v8 = *(_QWORD *)(v6 + 16);
if ( v8 && strlen(*(const char **)(v6 + 16)) > 1 )
{
strlcat(a2, v8, a3);
strlcat(a2, "\n", a3);
if ( !*(_QWORD *)(v6 + 48) )
goto LABEL_8;
goto LABEL_7;
}
if ( *(_QWORD *)(v6 + 48) )
{
LABEL_7:
strlcat(a2, "remarks: ", a3);
strlcat(a2, *(_QWORD *)(v6 + 48), a3);
strlcat(a2, "\n", a3);
}
LABEL_8:
switch ( *(_DWORD *)(v6 + 24) )
{
case 0:
if ( *(_QWORD *)(v6 + 40) )
{
strlcat(a2, "0: ", a3);
strlcat(a2, *(_QWORD *)(v6 + 40), a3);
strlcat(a2, "\n", a3);
}
if ( *(_QWORD *)(v6 + 32) )
{
strlcat(a2, "1: ", a3);
v9 = *(_QWORD *)(v6 + 32);
goto LABEL_10;
}
break;
case 1:
for ( i = *(_QWORD **)(v6 + 32); i; i = (_QWORD *)i[2] )
{
if ( *i && i[1] )
{
strlcat(a2, *i, a3);
strlcat(a2, ":", a3);
strlcat(a2, i[1], a3);
strlcat(a2, "\n", a3);
}
}
break;
case 2:
case 3:
case 4:
v9 = *(_QWORD *)(v6 + 32);
if ( v9 )
{
LABEL_10:
strlcat(a2, v9, a3);
strlcat(a2, "\n", a3);
}
break;
default:
return XSD_Variable_Free(v6);
}
return XSD_Variable_Free(v6);
}

canonical_decompiled_code:
__int64 __fastcall func4(char *s, char *a2, __int64 a3)
{
__int64 v5; // rax
__int64 v6; // rbp
__int64 result; // rax
__int64 v8; // r14
__int64 v9; // rsi
size_t v10; // rbx
size_t v11; // rax
_QWORD *i; // rbx

v5 = va("help/variables/%s.xml", s);
v6 = XSD_Variable_Load(v5);
result = menu_advanced[16];
if ( (_DWORD)result && *s )
{
strlcat(a2, "Variable name: ", a3);
strlcat(a2, s, a3);
v10 = strlen(a2);
v11 = strlen(s);
CharsToBrown(a2, &a2[v10 - v11]);
result = strlcat(a2, "\n", a3);
if ( !v6 )
return result;
}
else if ( !v6 )
{
return result;
}
v8 = *(_QWORD *)(v6 + 16);
if ( v8 && strlen(*(const char **)(v6 + 16)) > 1 )
{
strlcat(a2, v8, a3);
strlcat(a2, "\n", a3);
if ( !*(_QWORD *)(v6 + 48) )
goto LABEL_8;
goto LABEL_7;
}
if ( *(_QWORD *)(v6 + 48) )
{
LABEL_7:
strlcat(a2, "remarks: ", a3);
strlcat(a2, *(_QWORD *)(v6 + 48), a3);
strlcat(a2, "\n", a3);
}
LABEL_8:
switch ( *(_DWORD *)(v6 + 24) )
{
case 0:
if ( *(_QWORD *)(v6 + 40) )
{
strlcat(a2, "0: ", a3);
strlcat(a2, *(_QWORD *)(v6 + 40), a3);
strlcat(a2, "\n", a3);
}
if ( *(_QWORD *)(v6 + 32) )
{
strlcat(a2, "1: ", a3);
v9 = *(_QWORD *)(v6 + 32);
goto LABEL_10;
}
break;
case 1:
for ( i = *(_QWORD **)(v6 + 32); i; i = (_QWORD *)i[2] )
{
if ( *i && i[1] )
{
strlcat(a2, *i, a3);
strlcat(a2, ":", a3);
strlcat(a2, i[1], a3);
strlcat(a2, "\n", a3);
}
}
break;
case 2:
case 3:
case 4:
v9 = *(_QWORD *)(v6 + 32);
if ( v9 )
{
LABEL_10:
strlcat(a2, v9, a3);
strlcat(a2, "\n", a3);
}
break;
default:
return XSD_Variable_Free(v6);
}
return XSD_Variable_Free(v6);
}

original_code:
void Help_VarDescription (const char *varname, char* buf, size_t bufsize)
{
 extern void CharsToBrown(char*, char*);
 extern cvar_t menu_advanced;
 xml_variable_t *var;
 variable_enum_value_t *cv;
 var = XSD_Variable_Load (va ("help/variables/%s.xml", varname));
 if(menu_advanced.integer && strlen(varname)){
  strlcat(buf, "Variable name: ", bufsize);
  strlcat(buf, varname, bufsize);
  CharsToBrown(buf, buf + strlen (buf) - strlen(varname));
  strlcat(buf, "\n", bufsize);
 }
 if (!var)
  return;
 if (var->description && strlen (var->description) > 1) {
  strlcat (buf, var->description, bufsize);
  strlcat (buf, "\n", bufsize);
 }
 if (var->remarks) {
  strlcat (buf, "remarks: ", bufsize);
  strlcat (buf, var->remarks, bufsize);
  strlcat (buf, "\n", bufsize);
 }
 switch (var->value_type) {
 case t_boolean:
  if (var->value.boolean_value.false_description) {
   strlcat (buf, "0: ", bufsize);
   strlcat (buf, var->value.boolean_value.false_description, bufsize);
   strlcat (buf, "\n", bufsize);
  }
  if (var->value.boolean_value.true_description) {
   strlcat (buf, "1: ", bufsize);
   strlcat (buf, var->value.boolean_value.true_description, bufsize);
   strlcat (buf, "\n", bufsize);
  }
  break;
 case t_float:
  if (var->value.float_description) {
   strlcat (buf, var->value.float_description, bufsize);
   strlcat (buf, "\n", bufsize);
  }
  break;
 case t_integer:
  if (var->value.integer_description) {
   strlcat (buf, var->value.integer_description, bufsize);
   strlcat (buf, "\n", bufsize);
  }
  break;
 case t_string:
  if (var->value.string_description) {
   strlcat (buf, var->value.string_description, bufsize);
   strlcat (buf, "\n", bufsize);
  }
  break;
 case t_enum:
  cv = var->value.enum_value;
  while(cv) {
   if (cv->name && cv->description) {
    strlcat (buf, cv->name, bufsize);
    strlcat (buf, ":", bufsize);
    strlcat (buf, cv->description, bufsize);
    strlcat (buf, "\n", bufsize);
   }
   cv = cv->next;
  }
  break;
 }
 XSD_Variable_Free ((xml_t *) var);
}

canonical_original_code:
void Help_VarDescription(char *varname, char *buf, unsigned long bufsize)
{
 extern void CharsToBrown(char *, char *);
 extern struct cvar_s menu_advanced;
 struct xml_variable_s *var;
 struct variable_enum_value_s *cv;
 var = XSD_Variable_Load (va ("help/variables/%s.xml", varname));
 if(menu_advanced.integer && strlen(varname)){
  strlcat(buf, "Variable name: ", bufsize);
  strlcat(buf, varname, bufsize);
  CharsToBrown(buf, buf + strlen (buf) - strlen(varname));
  strlcat(buf, "\n", bufsize);
 }
 if (!var)
  return;
 if (var->description && strlen (var->description) > 1) {
  strlcat (buf, var->description, bufsize);
  strlcat (buf, "\n", bufsize);
 }
 if (var->remarks) {
  strlcat (buf, "remarks: ", bufsize);
  strlcat (buf, var->remarks, bufsize);
  strlcat (buf, "\n", bufsize);
 }
 switch (var->value_type) {
 case t_boolean:
  if (var->value.boolean_value.false_description) {
   strlcat (buf, "0: ", bufsize);
   strlcat (buf, var->value.boolean_value.false_description, bufsize);
   strlcat (buf, "\n", bufsize);
  }
  if (var->value.boolean_value.true_description) {
   strlcat (buf, "1: ", bufsize);
   strlcat (buf, var->value.boolean_value.true_description, bufsize);
   strlcat (buf, "\n", bufsize);
  }
  break;
 case t_float:
  if (var->value.float_description) {
   strlcat (buf, var->value.float_description, bufsize);
   strlcat (buf, "\n", bufsize);
  }
  break;
 case t_integer:
  if (var->value.integer_description) {
   strlcat (buf, var->value.integer_description, bufsize);
   strlcat (buf, "\n", bufsize);
  }
  break;
 case t_string:
  if (var->value.string_description) {
   strlcat (buf, var->value.string_description, bufsize);
   strlcat (buf, "\n", bufsize);
  }
  break;
 case t_enum:
  cv = var->value.enum_value;
  while(cv) {
   if (cv->name && cv->description) {
    strlcat (buf, cv->name, bufsize);
    strlcat (buf, ":", bufsize);
    strlcat (buf, cv->description, bufsize);
    strlcat (buf, "\n", bufsize);
   }
   cv = cv->next;
  }
  break;
 }
 XSD_Variable_Free ((struct xml_s *) var);
}

variable_types:
varname
char *

variable_types:
buf
char *

variable_types:
bufsize
unsigned long

variable_types:
CharsToBrown
void (char *, char *)

variable_types: struct cvar_s { char *name; char *string; int flags; void (*OnChange)(struct cvar_s *var, char *value, enum qbool { false=0, true=1 } *cancel); float value; float maxrulesetvalue; float minrulesetvalue; char *defaultvalue; char *latchedString; int integer; unsigned char color[4]; enum qbool { false=0, true=1 } modified; enum qbool { false=0, true=1 } teamplay; struct cvar_group_s { char name[65]; int count; struct cvar_s *head; struct cvar_group_s *next; } *group; struct cvar_s *next_in_group; struct cvar_s *hash_next; struct cvar_s *next; }

variable_types: struct variable_enum_value_s { char *name; char *description; struct variable_enum_value_s *next; } *


decompiled_code:
__int64 Help_Init()
{
return Cmd_AddCommand("describe", Help_Describe_f);
}

canonical_decompiled_code:
__int64 func5()
{
return Cmd_AddCommand("describe", Help_Describe_f);
}

original_code:
void Help_Init(void)
{
    Cmd_AddCommand("describe", Help_Describe_f);
}

canonical_original_code:
void Help_Init()
{
    Cmd_AddCommand("describe", Help_Describe_f);
}


decompiled_code:
__int64 __fastcall IN_MouseMove(__int64 a1)
{
__int64 result; // rax
float v2; // xmm0_4
double v3; // xmm3_8
float v4; // xmm2_4
float v5; // xmm2_4
float v6; // xmm0_4
double v7; // xmm2_8
double v8; // xmm0_8
float v9; // xmm0_4
float v10; // xmm1_4
float v11; // xmm1_4
float v12; // xmm1_4
float v13; // xmm5_4
int v14; // xmm4_4
double v15; // xmm0_8
double v16; // xmm0_8
float v17; // xmm3_4
float v18; // xmm0_4

result = mouseinitialized;
if ( mouseinitialized )
{
HIDWORD(v3) = 0;
v2 = (float)mx;
*(float *)&v3 = (float)my;
if ( (unsigned int)(key_dest - 3) <= 1 )
{
v12 = cursor_sensitivity[8];
*(float *)&mouse_x = v2 * v12;
*(float *)&mouse_y = v12 * *(float *)&v3;
old_mouse_x_3 = (int)(float)(v2 * v12);
result = (unsigned int)(int)(float)(v12 * *(float *)&v3);
old_mouse_y_2 = (int)(float)(v12 * *(float *)&v3);
}
else
{
v4 = *(float *)&m_filter[4];
if ( v4 == 0.0 )
{
*(float *)&mouse_x = (float)mx;
*(float *)&mouse_y = (float)my;
}
else
{
if ( v4 < 0.0 )
{
v14 = LC1;
v13 = 0.0;
}
else
{
v13 = *(float *)&LC2;
v14 = LC2;
if ( v4 <= 1.0 )
{
v13 = 0.5 * v4;
*(float *)&v14 = 1.0 - (float)(0.5 * v4);
}
}
*(float *)&v3 = *(float *)&v3 * *(float *)&v14;
*(float *)&mouse_x = (float)(v2 * *(float *)&v14) + (float)((float)old_mouse_x_3 * v13);
*(float *)&mouse_y = (float)((float)old_mouse_y_2 * v13) + *(float *)&v3;
}
v5 = m_accel[8];
old_mouse_x_3 = mx;
old_mouse_y_2 = my;
v6 = sensitivity[8];
if ( v5 != 0.0 )
{
v15 = (double)(my * my + mx * mx);
if ( v15 < 0.0 )
{
v16 = sqrt(v15);
v5 = m_accel[8];
}
else
{
v16 = sqrt(v15);
}
v17 = cls[4];
v3 = (float)(v17 * 1000.0);
v18 = v16 / v3;
v6 = (float)(v18 * v5) + sensitivity[8];
}
*(_QWORD *)&v7 = (unsigned int)mouse_x;
*(float *)&v7 = *(float *)&mouse_x * v6;
*(float *)&mouse_x = *(float *)&mouse_x * v6;
*(float *)&mouse_y = v6 * *(float *)&mouse_y;
if ( (in_strafe[8] & 1) == 0
&& ((*(_QWORD *)&v8 = freelook[8], lookstrafe[8] == 0.0) || *(float *)&v8 == 0.0 && (in_mlook[8] & 1) == 0) )
{
*(float *)&v7 = *(float *)&v7 * m_yaw[8];
*(_QWORD *)&v3 = LODWORD(unk_BE0[331499]);
*(float *)&v3 = *(float *)&v3 - *(float *)&v7;
unk_BE0[331499] = *(float *)&v3;
}
else
{
*(float *)&v7 = (float)(*(float *)&v7 * m_side[8]) + (float)*(__int16 *)(a1 + 18);
*(_WORD *)(a1 + 18) = (int)*(float *)&v7;
*(_QWORD *)&v8 = freelook[8];
}
if ( *(float *)&v8 == 0.0 && (in_mlook[8] & 1) == 0
|| (result = V_StopPitchDrift(v8, 0.0, v7, v3), *(float *)&freelook[8] == 0.0) && (in_mlook[8] & 1) == 0
|| (in_strafe[8] & 1) != 0 )
{
result = (unsigned int)(int)(float)((float)*(__int16 *)(a1 + 16) - (float)(m_forward[8] * *(float *)&mouse_y));
*(_WORD *)(a1 + 16) = result;
}
else
{
v9 = (float)(m_pitch[8] * *(float *)&mouse_y) + unk_BE0[331498];
v10 = unk_BE0[141];
unk_BE0[331498] = v9;
if ( v9 > v10 )
{
unk_BE0[331498] = v10;
v9 = v10;
}
v11 = unk_BE0[140];
if ( v11 > v9 )
unk_BE0[331498] = v11;
}
}
my = 0;
mx = 0;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 result; // rax
float v2; // xmm0_4
double v3; // xmm3_8
float v4; // xmm2_4
float v5; // xmm2_4
float v6; // xmm0_4
double v7; // xmm2_8
double v8; // xmm0_8
float v9; // xmm0_4
float v10; // xmm1_4
float v11; // xmm1_4
float v12; // xmm1_4
float v13; // xmm5_4
int v14; // xmm4_4
double v15; // xmm0_8
double v16; // xmm0_8
float v17; // xmm3_4
float v18; // xmm0_4

result = mouseinitialized;
if ( mouseinitialized )
{
HIDWORD(v3) = 0;
v2 = (float)mx;
*(float *)&v3 = (float)my;
if ( (unsigned int)(key_dest - 3) <= 1 )
{
v12 = cursor_sensitivity[8];
*(float *)&mouse_x = v2 * v12;
*(float *)&mouse_y = v12 * *(float *)&v3;
old_mouse_x_3 = (int)(float)(v2 * v12);
result = (unsigned int)(int)(float)(v12 * *(float *)&v3);
old_mouse_y_2 = (int)(float)(v12 * *(float *)&v3);
}
else
{
v4 = *(float *)&m_filter[4];
if ( v4 == 0.0 )
{
*(float *)&mouse_x = (float)mx;
*(float *)&mouse_y = (float)my;
}
else
{
if ( v4 < 0.0 )
{
v14 = LC1;
v13 = 0.0;
}
else
{
v13 = *(float *)&LC2;
v14 = LC2;
if ( v4 <= 1.0 )
{
v13 = 0.5 * v4;
*(float *)&v14 = 1.0 - (float)(0.5 * v4);
}
}
*(float *)&v3 = *(float *)&v3 * *(float *)&v14;
*(float *)&mouse_x = (float)(v2 * *(float *)&v14) + (float)((float)old_mouse_x_3 * v13);
*(float *)&mouse_y = (float)((float)old_mouse_y_2 * v13) + *(float *)&v3;
}
v5 = m_accel[8];
old_mouse_x_3 = mx;
old_mouse_y_2 = my;
v6 = sensitivity[8];
if ( v5 != 0.0 )
{
v15 = (double)(my * my + mx * mx);
if ( v15 < 0.0 )
{
v16 = sqrt(v15);
v5 = m_accel[8];
}
else
{
v16 = sqrt(v15);
}
v17 = cls[4];
v3 = (float)(v17 * 1000.0);
v18 = v16 / v3;
v6 = (float)(v18 * v5) + sensitivity[8];
}
*(_QWORD *)&v7 = (unsigned int)mouse_x;
*(float *)&v7 = *(float *)&mouse_x * v6;
*(float *)&mouse_x = *(float *)&mouse_x * v6;
*(float *)&mouse_y = v6 * *(float *)&mouse_y;
if ( (in_strafe[8] & 1) == 0
&& ((*(_QWORD *)&v8 = freelook[8], lookstrafe[8] == 0.0) || *(float *)&v8 == 0.0 && (in_mlook[8] & 1) == 0) )
{
*(float *)&v7 = *(float *)&v7 * m_yaw[8];
*(_QWORD *)&v3 = LODWORD(unk_BE0[331499]);
*(float *)&v3 = *(float *)&v3 - *(float *)&v7;
unk_BE0[331499] = *(float *)&v3;
}
else
{
*(float *)&v7 = (float)(*(float *)&v7 * m_side[8]) + (float)*(__int16 *)(a1 + 18);
*(_WORD *)(a1 + 18) = (int)*(float *)&v7;
*(_QWORD *)&v8 = freelook[8];
}
if ( *(float *)&v8 == 0.0 && (in_mlook[8] & 1) == 0
|| (result = V_StopPitchDrift(v8, 0.0, v7, v3), *(float *)&freelook[8] == 0.0) && (in_mlook[8] & 1) == 0
|| (in_strafe[8] & 1) != 0 )
{
result = (unsigned int)(int)(float)((float)*(__int16 *)(a1 + 16) - (float)(m_forward[8] * *(float *)&mouse_y));
*(_WORD *)(a1 + 16) = result;
}
else
{
v9 = (float)(m_pitch[8] * *(float *)&mouse_y) + unk_BE0[331498];
v10 = unk_BE0[141];
unk_BE0[331498] = v9;
if ( v9 > v10 )
{
unk_BE0[331498] = v10;
v9 = v10;
}
v11 = unk_BE0[140];
if ( v11 > v9 )
unk_BE0[331498] = v11;
}
}
my = 0;
mx = 0;
}
return result;
}

original_code:
void IN_MouseMove (usercmd_t *cmd)
{
 static int old_mouse_x = 0, old_mouse_y = 0;
 if (!mouseinitialized)
  return;
 if(key_dest == key_hudeditor || key_dest == key_menu)
 {
  old_mouse_x = mouse_x = mx * cursor_sensitivity.value;
  old_mouse_y = mouse_y = my * cursor_sensitivity.value;
 }
 else
 {
  if (m_filter.value) {
   float filterfrac = ((0.0f) >= (1.0f) ? (0.0f) : (m_filter.value) < (0.0f) ? (0.0f) : (m_filter.value) > (1.0f) ? (1.0f) : (m_filter.value)) / 2.0f;
   mouse_x = (mx * (1.0f - filterfrac) + old_mouse_x * filterfrac);
   mouse_y = (my * (1.0f - filterfrac) + old_mouse_y * filterfrac);
  } else {
   mouse_x = mx;
   mouse_y = my;
  }
  old_mouse_x = mx;
  old_mouse_y = my;
  if (m_accel.value) {
   float mousespeed = (sqrt (mx * mx + my * my)) / (1000.0f * (float) cls.trueframetime);
   mouse_x *= (mousespeed * m_accel.value + sensitivity.value);
   mouse_y *= (mousespeed * m_accel.value + sensitivity.value);
  } else {
   mouse_x *= sensitivity.value;
   mouse_y *= sensitivity.value;
  }
  if ((in_strafe.state & 1) || (lookstrafe.value && (freelook.value || (in_mlook.state&1))))
   cmd->sidemove += m_side.value * mouse_x;
  else
   cl.viewangles[1] -= m_yaw.value * mouse_x;
  if ((freelook.value || (in_mlook.state&1)))
   V_StopPitchDrift ();
  if ((freelook.value || (in_mlook.state&1)) && !(in_strafe.state & 1))
  {
   cl.viewangles[0] += m_pitch.value * mouse_y;
   if (cl.viewangles[0] > cl.maxpitch)
    cl.viewangles[0] = cl.maxpitch;
   if (cl.viewangles[0] < cl.minpitch)
    cl.viewangles[0] = cl.minpitch;
  } else {
   cmd->forwardmove -= m_forward.value * mouse_y;
  }
 }
 mx = my = 0;
}

canonical_original_code:
void IN_MouseMove(struct usercmd_s *cmd)
{
 static int old_mouse_x = 0; static int old_mouse_y = 0;
 if (!mouseinitialized)
  return;
 if(key_dest == key_hudeditor || key_dest == key_menu)
 {
  old_mouse_x = mouse_x = mx * cursor_sensitivity.value;
  old_mouse_y = mouse_y = my * cursor_sensitivity.value;
 }
 else
 {
  if (m_filter.value) {
   float filterfrac = ((0.0f) >= (1.0f) ? (0.0f) : (m_filter.value) < (0.0f) ? (0.0f) : (m_filter.value) > (1.0f) ? (1.0f) : (m_filter.value)) / 2.0f;
   mouse_x = (mx * (1.0f - filterfrac) + old_mouse_x * filterfrac);
   mouse_y = (my * (1.0f - filterfrac) + old_mouse_y * filterfrac);
  } else {
   mouse_x = mx;
   mouse_y = my;
  }
  old_mouse_x = mx;
  old_mouse_y = my;
  if (m_accel.value) {
   float mousespeed = (sqrt (mx * mx + my * my)) / (1000.0f * (float) cls.trueframetime);
   mouse_x *= (mousespeed * m_accel.value + sensitivity.value);
   mouse_y *= (mousespeed * m_accel.value + sensitivity.value);
  } else {
   mouse_x *= sensitivity.value;
   mouse_y *= sensitivity.value;
  }
  if ((in_strafe.state & 1) || (lookstrafe.value && (freelook.value || (in_mlook.state&1))))
   cmd->sidemove += m_side.value * mouse_x;
  else
   cl.viewangles[1] -= m_yaw.value * mouse_x;
  if ((freelook.value || (in_mlook.state&1)))
   V_StopPitchDrift ();
  if ((freelook.value || (in_mlook.state&1)) && !(in_strafe.state & 1))
  {
   cl.viewangles[0] += m_pitch.value * mouse_y;
   if (cl.viewangles[0] > cl.maxpitch)
    cl.viewangles[0] = cl.maxpitch;
   if (cl.viewangles[0] < cl.minpitch)
    cl.viewangles[0] = cl.minpitch;
  } else {
   cmd->forwardmove -= m_forward.value * mouse_y;
  }
 }
 mx = my = 0;
}

variable_types: struct usercmd_s { unsigned char msec; float angles[3]; short forwardmove; unsigned char buttons; unsigned char impulse; } *

variable_types: filterfrac float

variable_types: mousespeed float


decompiled_code:
__int64 __fastcall IN_Move(__int64 a1)
{
__int64 v2; // rbx
__int64 v3; // rcx
__m128i v4; // xmm1
struct timeval v5; // [rsp+0h] [rbp-28h] BYREF

if ( *(float *)&m_showrate[4] == 0.0 || !(my | mx) )
return IN_MouseMove(a1);
gettimeofday(&v5, 0LL);
v2 = old_mouserate_0;
v3 = v5.tv_usec + 1000000 * (v5.tv_sec - old_tv_1) - *((_QWORD *)&old_tv_1 + 1);
if ( v3 )
v2 = 1000000 / v3;
Com_Printf("mouse rate: %4ld\n", (v2 + old_mouserate_0) / 2);
v4 = _mm_loadu_si128((const __m128i *)&v5);
old_mouserate_0 = v2;
old_tv_1 = (__int128)v4;
return IN_MouseMove(a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
__int64 v2; // rbx
__int64 v3; // rcx
__m128i v4; // xmm1
struct timeval v5; // [rsp+0h] [rbp-28h] BYREF

if ( *(float *)&m_showrate[4] == 0.0 || !(my | mx) )
return func0(a1);
gettimeofday(&v5, 0LL);
v2 = old_mouserate_0;
v3 = v5.tv_usec + 1000000 * (v5.tv_sec - old_tv_1) - *((_QWORD *)&old_tv_1 + 1);
if ( v3 )
v2 = 1000000 / v3;
Com_Printf("mouse rate: %4ld\n", (v2 + old_mouserate_0) / 2);
v4 = _mm_loadu_si128((const __m128i *)&v5);
old_mouserate_0 = v2;
old_tv_1 = (__int128)v4;
return func0(a1);
}

original_code:
void IN_Move (usercmd_t *cmd)
{
 static struct timeval old_tv = {0, 0};
 struct timeval tv;
 static long old_mouserate = 0;
 long usec, mouserate;
 if (m_showrate.value && (mx || my)) {
  gettimeofday(&tv, ((void *)0));
  usec = (tv.tv_sec - old_tv.tv_sec) * 1000000L + (tv.tv_usec - old_tv.tv_usec);
  mouserate = usec ? 1000000L / usec : old_mouserate;
  Com_Printf("mouse rate: %4ld\n", (mouserate + old_mouserate) / 2);
  old_tv = tv;
  old_mouserate = mouserate;
 }
 IN_MouseMove (cmd);
}

canonical_original_code:
void IN_Move(struct usercmd_s *cmd)
{
 static struct timeval old_tv = {0, 0};
 struct timeval tv;
 static long old_mouserate = 0;
 long usec; long mouserate;
 if (m_showrate.value && (mx || my)) {
  gettimeofday(&tv, ((void *)0));
  usec = (tv.tv_sec - old_tv.tv_sec) * 1000000L + (tv.tv_usec - old_tv.tv_usec);
  mouserate = usec ? 1000000L / usec : old_mouserate;
  Com_Printf("mouse rate: %4ld\n", (mouserate + old_mouserate) / 2);
  old_tv = tv;
  old_mouserate = mouserate;
 }
 IN_MouseMove (cmd);
}

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

variable_types: usec long

variable_types: mouserate long

user_defined_types: struct usercmd_s { unsigned char msec; float angles[3]; short forwardmove; unsigned char buttons; unsigned char impulse; }


isAltDown

decompiled_code:
__int64 isAltDown()
{
return (unsigned int)altDown;
}

canonical_decompiled_code:
__int64 func4()
{
return (unsigned int)altDown;
}

original_code: int isAltDown(void) {return altDown;}

canonical_original_code: int isAltDown() {return altDown;}

return_type: int


isCtrlDown

decompiled_code:
__int64 isCtrlDown()
{
return (unsigned int)ctrlDown;
}

canonical_decompiled_code:
__int64 func5()
{
return (unsigned int)ctrlDown;
}

original_code: int isCtrlDown(void) {return ctrlDown;}

canonical_original_code: int isCtrlDown() {return ctrlDown;}


isShiftDown

decompiled_code:
__int64 isShiftDown()
{
return (unsigned int)shiftDown;
}

canonical_decompiled_code:
__int64 func6()
{
return (unsigned int)shiftDown;
}

original_code: int isShiftDown(void) {return shiftDown;}

canonical_original_code: int isShiftDown() {return shiftDown;}


decompiled_code:
__int64 IN_Init()
{
Cvar_SetCurrentGroup("Input - Mouse");
Cvar_Register(m_filter);
Cvar_Register(m_showrate);
Cvar_Register(windowed_mouse);
Cvar_SetCurrentGroup("Input - Keyboard");
Cvar_Register(cl_keypad);
Cvar_ResetCurrentGroup();
if ( !host_initialized )
{
if ( (unsigned int)COM_CheckParm("-nomouse") )
Cvar_LatchedSetValue(&in_mouse, 0.0);
Cmd_AddCommand("in_restart", &IN_Restart_f);
}
return IN_StartupMouse();
}

canonical_decompiled_code:
__int64 func2()
{
Cvar_SetCurrentGroup("Input - Mouse");
Cvar_Register(m_filter);
Cvar_Register(m_showrate);
Cvar_Register(windowed_mouse);
Cvar_SetCurrentGroup("Input - Keyboard");
Cvar_Register(cl_keypad);
Cvar_ResetCurrentGroup();
if ( !host_initialized )
{
if ( (unsigned int)COM_CheckParm("-nomouse") )
Cvar_LatchedSetValue(&in_mouse, 0.0);
Cmd_AddCommand("in_restart", &IN_Restart_f);
}
return IN_StartupMouse();
}

original_code:
void IN_Init (void)
{
 Cvar_SetCurrentGroup ("Input - Mouse");
 Cvar_Register (&m_filter);
 Cvar_Register (&m_showrate);
 Cvar_Register (&_windowed_mouse);
 Cvar_SetCurrentGroup ("Input - Keyboard");
 Cvar_Register (&cl_keypad);
 Cvar_ResetCurrentGroup ();
 if (!host_initialized)
 {
  typedef enum {mt_none = 0, mt_normal} mousetype_t;
  extern cvar_t in_mouse;
  if (COM_CheckParm ("-nomouse"))
   Cvar_LatchedSetValue (&in_mouse, mt_none);
  Cmd_AddCommand ("in_restart", IN_Restart_f);
 }
 IN_StartupMouse ();
}

canonical_original_code:
void IN_Init()
{
 Cvar_SetCurrentGroup ("Input - Mouse");
 Cvar_Register (&m_filter);
 Cvar_Register (&m_showrate);
 Cvar_Register (&_windowed_mouse);
 Cvar_SetCurrentGroup ("Input - Keyboard");
 Cvar_Register (&cl_keypad);
 Cvar_ResetCurrentGroup ();
 if (!host_initialized)
 {
  typedef enum {mt_none = 0, mt_normal} mousetype_t;
  extern struct cvar_s in_mouse;
  if (COM_CheckParm ("-nomouse"))
   Cvar_LatchedSetValue (&in_mouse, mt_none);
  Cmd_AddCommand ("in_restart", IN_Restart_f);
 }
 IN_StartupMouse ();
}

user_defined_types: struct cvar_group_s { char name[65]; int count; struct cvar_s *head; struct cvar_group_s *next; }


decompiled_code:
__int64 IN_Shutdown()
{
__int64 result; // rax

result = IN_DeactivateMouse();
mouseinitialized = 0;
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 result; // rax

result = IN_DeactivateMouse();
mouseinitialized = 0;
return result;
}

original_code:
void IN_Shutdown(void)
{
 IN_DeactivateMouse();
 mouseinitialized = false;
}

canonical_original_code:
void IN_Shutdown()
{
 IN_DeactivateMouse();
 mouseinitialized = false;
}


GetTickCount

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

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

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

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

original_code:
static int32_t GetTickCount()
{
 struct timeval tv;
 gettimeofday(&tv,((void *)0));
 return tv.tv_usec / 1000 + tv.tv_sec * 1000;
}

canonical_original_code:
static int GetTickCount()
{
 struct timeval tv;
 gettimeofday(&tv,((void *)0));
 return tv.tv_usec / 1000 + tv.tv_sec * 1000;
}

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


decompiled_code:
__int64 Mumble_Init()
{
Cvar_SetCurrentGroup("System Settings");
Cvar_Register(mumble_enabled);
Cvar_Register(mumble_distance_ratio);
return Cvar_Register(mumble_debug);
}

canonical_decompiled_code:
__int64 func1()
{
Cvar_SetCurrentGroup("System Settings");
Cvar_Register(mumble_enabled);
Cvar_Register(mumble_distance_ratio);
return Cvar_Register(mumble_debug);
}

original_code:
void Mumble_Init(void)
{
 Cvar_SetCurrentGroup("System Settings");
 Cvar_Register (&mumble_enabled);
 Cvar_Register (&mumble_distance_ratio);
 Cvar_Register (&mumble_debug);
}

canonical_original_code:
void Mumble_Init()
{
 Cvar_SetCurrentGroup("System Settings");
 Cvar_Register (&mumble_enabled);
 Cvar_Register (&mumble_distance_ratio);
 Cvar_Register (&mumble_debug);
}


decompiled_code:
__int64 Mumble_CreateLink()
{
__int64 result; // rax
__uid_t v1; // eax
int v2; // eax
int v3; // ebp
wchar_t *v4; // rax
__int64 v5; // rax
char v6[264]; // [rsp-108h] [rbp-108h] BYREF

if ( lm )
return Com_Printf_State(4LL, "Mumble link already initialized.\n");
v1 = getuid();
snprintf(v6, 0x100uLL, "/MumbleLink.%d", v1);
v2 = shm_open(v6, 2, 0x180u);
shmfd = v2;
v3 = v2;
if ( v2 < 0 )
return Com_Printf_State(2LL, "Mumble initialization skipped. Mumble not running.\n");
v4 = (wchar_t *)mmap64(0LL, 0x42CuLL, 3, 1, v2, 0LL);
lm = v4;
if ( v4 == (wchar_t *)-1LL )
{
lm = 0LL;
close(v3);
shmfd = -1;
result = Com_Printf_State(4LL, "Mumble link initialization failed.\n");
}
else
{
mbstowcs(v4 + 11, "jQuake", 0x400uLL);
v5 = CharsToBrownStatic("Mumble link initialized.");
Com_Printf(v5);
result = Com_Printf("\n");
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
__int64 result; // rax
__uid_t v1; // eax
int v2; // eax
int v3; // ebp
wchar_t *v4; // rax
__int64 v5; // rax
char v6[264]; // [rsp-108h] [rbp-108h] BYREF

if ( lm )
return Com_Printf_State(4LL, "Mumble link already initialized.\n");
v1 = getuid();
snprintf(v6, 0x100uLL, "/MumbleLink.%d", v1);
v2 = shm_open(v6, 2, 0x180u);
shmfd = v2;
v3 = v2;
if ( v2 < 0 )
return Com_Printf_State(2LL, "Mumble initialization skipped. Mumble not running.\n");
v4 = (wchar_t *)mmap64(0LL, 0x42CuLL, 3, 1, v2, 0LL);
lm = v4;
if ( v4 == (wchar_t *)-1LL )
{
lm = 0LL;
close(v3);
shmfd = -1;
result = Com_Printf_State(4LL, "Mumble link initialization failed.\n");
}
else
{
mbstowcs(v4 + 11, "jQuake", 0x400uLL);
v5 = CharsToBrownStatic("Mumble link initialized.");
Com_Printf(v5);
result = Com_Printf("\n");
}
return result;
}

original_code:
void Mumble_CreateLink()
{
 char memname[256];
 if (lm != ((void *)0))
 {
  Com_Printf_State((1<<2),"Mumble link already initialized.\n");
  return;
 }
 snprintf(memname, 256, "/MumbleLink.%d", getuid());
 shmfd = shm_open(memname, 02, 0400 | 0200);
 if(shmfd < 0)
 {
  Com_Printf_State((1<<1),"Mumble initialization skipped. Mumble not running.\n");
  return;
 }
 lm = (struct LinkedMem *) (mmap(((void *)0), sizeof(struct LinkedMem), 0x1 | 0x2, 0x01, shmfd,0));
 if (lm == (void *) (-1))
 {
  lm = ((void *)0);
  close(shmfd);
  shmfd = -1;
  Com_Printf_State((1<<2),"Mumble link initialization failed.\n");
  return;
 }
 mbstowcs(lm->name, "jQuake", sizeof(lm->name));
 Com_Printf(CharsToBrownStatic("Mumble link initialized."));
 Com_Printf("\n");
}

variable_types:
memname
char [256]

user_defined_types: struct LinkedMem { unsigned int uiVersion; unsigned int uiTick; float fPosition[3]; float fFront[3]; float fTop[3]; int name[256]; }


decompiled_code:
__int64 Mumble_DestroyLink()
{
__int64 result; // rax

if ( lm )
{
munmap(lm, 0x42CuLL);
lm = 0LL;
close(shmfd);
shmfd = -1;
result = Com_Printf_State(2LL, "Mumble link shut down.\n");
}
else
{
result = LODWORD(mumble_debug[8]);
if ( (_DWORD)result )
result = Com_Printf_State(4LL, "Mumble link not established, unable to shut down.\n");
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
__int64 result; // rax

if ( lm )
{
munmap(lm, 0x42CuLL);
lm = 0LL;
close(shmfd);
shmfd = -1;
result = Com_Printf_State(2LL, "Mumble link shut down.\n");
}
else
{
result = LODWORD(mumble_debug[8]);
if ( (_DWORD)result )
result = Com_Printf_State(4LL, "Mumble link not established, unable to shut down.\n");
}
return result;
}

original_code:
void Mumble_DestroyLink()
{
 if (lm != ((void *)0))
 {
  munmap(lm, sizeof(struct LinkedMem));
  lm = ((void *)0);
  close(shmfd);
  shmfd = -1;
  Com_Printf_State((1<<1),"Mumble link shut down.\n");
  return;
 }
 else
 {
  if (mumble_debug.integer)
   Com_Printf_State((1<<2),"Mumble link not established, unable to shut down.\n");
 }
}


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

if ( (unsigned int)Q_atoi(a2) )
result = Mumble_CreateLink();
else
result = Mumble_DestroyLink();
return result;
}

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

if ( (unsigned int)Q_atoi(a2) )
result = func2();
else
result = func3();
return result;
}

original_code:
void OnChange_mumble_enabled(cvar_t *var, char *value, qbool *cancel)
{
 int mumble = Q_atoi (value);
 if (mumble)
  Mumble_CreateLink();
 else
  Mumble_DestroyLink();
}

canonical_original_code:
void OnChange_mumble_enabled(struct cvar_s *var, char *value, enum qbool *cancel)
{
 int mumble = Q_atoi (value);
 if (mumble)
  Mumble_CreateLink();
 else
  Mumble_DestroyLink();
}

variable_types:
value
char *

variable_types:
cancel
enum qbool { false=0, true=1 } *

variable_types: mumble int


updateMumble

decompiled_code:
void updateMumble()
{
_DWORD *v0; // rsi
float v1; // xmm2_4
char *v2; // rcx
float *v3; // rsi
float v4; // xmm1_4
float v5; // xmm3_4
_DWORD *v6; // rdi
char v7[20]; // [rsp+0h] [rbp-14h] BYREF

if ( LODWORD(mumble_enabled[8]) )
{
v0 = lm;
if ( lm )
{
if ( cls[2427] | LODWORD(unk_B60[148]) )
{
if ( mpa_report_active_0 )
{
*((_QWORD *)lm + 1) = 0LL;
v0[4] = 0;
mpa_report_active_0 = 0;
Com_Printf_State(2LL, "Mumble Position Audio reporting disabled\n");
}
}
else
{
v1 = unk_B60[331514];
v2 = (char *)lm + 32;
v3 = (float *)((char *)lm + 20);
*((float *)lm + 2) = v1;
v4 = unk_B60[331515];
*(v3 - 2) = v4;
v5 = unk_B60[331516];
*(v3 - 1) = v5;
*(v3 - 3) = v1 * *(float *)&mumble_distance_ratio[4];
*(v3 - 2) = v4 * *(float *)&mumble_distance_ratio[4];
*(v3 - 1) = COERCE_FLOAT(LODWORD(mumble_distance_ratio[4]) ^ LC12) * v5;
AngleVectors((unsigned int)((_DWORD)unk_B60 + 1325992), v3, v7, v2);
v6 = lm;
*((_DWORD *)lm + 7) ^= LC12;
v6[10] ^= LC12;
if ( LODWORD(mumble_debug[8]) )
{
Com_Printf("X=%f Y=%f Z=%f\n", *((float *)v6 + 2), *((float *)v6 + 3), *((float *)v6 + 4));
v6 = lm;
}
if ( v6[11] != 101 )
{
mbstowcs(v6 + 11, "jQuake", 0x400uLL);
v6 = lm;
}
*v6 = 1;
*((_DWORD *)lm + 1) = GetTickCount();
if ( !mpa_report_active_0 )
{
Com_Printf_State(2LL, "Mumble Position Audio reporting enabled.\n");
mpa_report_active_0 = 1;
}
}
}
}
}

canonical_decompiled_code:
void func5()
{
_DWORD *v0; // rsi
float v1; // xmm2_4
char *v2; // rcx
float *v3; // rsi
float v4; // xmm1_4
float v5; // xmm3_4
_DWORD *v6; // rdi
char v7[20]; // [rsp+0h] [rbp-14h] BYREF

if ( LODWORD(mumble_enabled[8]) )
{
v0 = lm;
if ( lm )
{
if ( cls[2427] | LODWORD(unk_B60[148]) )
{
if ( mpa_report_active_0 )
{
*((_QWORD *)lm + 1) = 0LL;
v0[4] = 0;
mpa_report_active_0 = 0;
Com_Printf_State(2LL, "Mumble Position Audio reporting disabled\n");
}
}
else
{
v1 = unk_B60[331514];
v2 = (char *)lm + 32;
v3 = (float *)((char *)lm + 20);
*((float *)lm + 2) = v1;
v4 = unk_B60[331515];
*(v3 - 2) = v4;
v5 = unk_B60[331516];
*(v3 - 1) = v5;
*(v3 - 3) = v1 * *(float *)&mumble_distance_ratio[4];
*(v3 - 2) = v4 * *(float *)&mumble_distance_ratio[4];
*(v3 - 1) = COERCE_FLOAT(LODWORD(mumble_distance_ratio[4]) ^ LC12) * v5;
AngleVectors((unsigned int)((_DWORD)unk_B60 + 1325992), v3, v7, v2);
v6 = lm;
*((_DWORD *)lm + 7) ^= LC12;
v6[10] ^= LC12;
if ( LODWORD(mumble_debug[8]) )
{
Com_Printf("X=%f Y=%f Z=%f\n", *((float *)v6 + 2), *((float *)v6 + 3), *((float *)v6 + 4));
v6 = lm;
}
if ( v6[11] != 101 )
{
mbstowcs(v6 + 11, "jQuake", 0x400uLL);
v6 = lm;
}
*v6 = 1;
*((_DWORD *)lm + 1) = func0();
if ( !mpa_report_active_0 )
{
Com_Printf_State(2LL, "Mumble Position Audio reporting enabled.\n");
mpa_report_active_0 = 1;
}
}
}
}
}

original_code:
void updateMumble()
{
 vec3_t right;
 static qbool mpa_report_active = true;
 if (!mumble_enabled.integer || !lm )
  return;
 if (cls.demoplayback || cl.spectator)
 {
  if (mpa_report_active)
  {
   ((lm->fPosition)[0] = (lm->fPosition)[1] = (lm->fPosition)[2] = 0);
   mpa_report_active = false;
   Com_Printf_State((1<<1),"Mumble Position Audio reporting disabled\n");
  }
  return ;
 }
 ((lm->fPosition)[0] = (cl.simorg)[0], (lm->fPosition)[1] = (cl.simorg)[1], (lm->fPosition)[2] = (cl.simorg)[2]);
 lm->fPosition[0] *= mumble_distance_ratio.value;
 lm->fPosition[1] *= mumble_distance_ratio.value;
 lm->fPosition[2] *= -1 * mumble_distance_ratio.value;
 AngleVectors(cl.viewangles,lm->fFront, right, lm->fTop);
 lm->fFront[2] *= -1;
 lm->fTop[2] *= -1;
 if (mumble_debug.integer)
  Com_Printf("X=%f Y=%f Z=%f\n",lm->fPosition[0],lm->fPosition[1],lm->fPosition[2]);
 if(lm->name[0] != 'e')
  mbstowcs(lm->name, "jQuake", sizeof(lm->name));
 lm->uiVersion = 1;
 lm->uiTick = GetTickCount();
 if(!mpa_report_active)
 {
  Com_Printf_State((1<<1),"Mumble Position Audio reporting enabled.\n");
  mpa_report_active = true;
 }
}

canonical_original_code:
void updateMumble()
{
 float right[3];
 static enum qbool mpa_report_active = true;
 if (!mumble_enabled.integer || !lm )
  return;
 if (cls.demoplayback || cl.spectator)
 {
  if (mpa_report_active)
  {
   ((lm->fPosition)[0] = (lm->fPosition)[1] = (lm->fPosition)[2] = 0);
   mpa_report_active = false;
   Com_Printf_State((1<<1),"Mumble Position Audio reporting disabled\n");
  }
  return ;
 }
 ((lm->fPosition)[0] = (cl.simorg)[0], (lm->fPosition)[1] = (cl.simorg)[1], (lm->fPosition)[2] = (cl.simorg)[2]);
 lm->fPosition[0] *= mumble_distance_ratio.value;
 lm->fPosition[1] *= mumble_distance_ratio.value;
 lm->fPosition[2] *= -1 * mumble_distance_ratio.value;
 AngleVectors(cl.viewangles,lm->fFront, right, lm->fTop);
 lm->fFront[2] *= -1;
 lm->fTop[2] *= -1;
 if (mumble_debug.integer)
  Com_Printf("X=%f Y=%f Z=%f\n",lm->fPosition[0],lm->fPosition[1],lm->fPosition[2]);
 if(lm->name[0] != 'e')
  mbstowcs(lm->name, "jQuake", sizeof(lm->name));
 lm->uiVersion = 1;
 lm->uiTick = GetTickCount();
 if(!mpa_report_active)
 {
  Com_Printf_State((1<<1),"Mumble Position Audio reporting enabled.\n");
  mpa_report_active = true;
 }
}

variable_types:
right
float [3]


decompiled_code:
void DSOUND_Capture_Start()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
void DSOUND_Capture_Start(void *ctx)
{
}

variable_types:
ctx
void *


decompiled_code:
void DSOUND_Capture_Stop()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void DSOUND_Capture_Stop(void *ctx)
{
}

canonical_original_code:
void DSOUND_Capture_Stop(void *ctx)
{
}


decompiled_code:
__int64 DSOUND_Capture_Update()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 0LL;
}

original_code:
unsigned int DSOUND_Capture_Update(void *ctx, unsigned char *buffer, unsigned int minbytes, unsigned int maxbytes)
{
 return 0;
}

variable_types:
buffer
unsigned char *

variable_types:
minbytes
unsigned int

variable_types:
maxbytes
unsigned int

return_type: unsigned int


decompiled_code:
__int64 __fastcall DSOUND_Capture_Init(unsigned int a1)
{
__int64 v1; // r12

Com_DPrintf("DSOUND_Capture_Init: rate %d\n", a1);
v1 = Q_malloc(1LL);
Com_DPrintf("DSOUND_Capture_Init: OK\n");
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1)
{
__int64 v1; // r12

Com_DPrintf("DSOUND_Capture_Init: rate %d\n", a1);
v1 = Q_malloc(1LL);
Com_DPrintf("DSOUND_Capture_Init: OK\n");
return v1;
}

original_code:
void *DSOUND_Capture_Init (int rate)
{
 dsndcapture_t *result;
 Com_DPrintf("DSOUND_Capture_Init: rate %d\n", rate);
 result = Q_malloc(sizeof(*result));
 Com_DPrintf("DSOUND_Capture_Init: OK\n");
 return result;
}

canonical_original_code:
void *DSOUND_Capture_Init(int rate)
{
 struct dsndcapture_t *result;
 Com_DPrintf("DSOUND_Capture_Init: rate %d\n", rate);
 result = Q_malloc(sizeof(*result));
 Com_DPrintf("DSOUND_Capture_Init: OK\n");
 return result;
}

variable_types: rate int

variable_types:
result
struct dsndcapture_t { char dummy; } *

return_type: void *


decompiled_code:
void __fastcall DSOUND_Capture_Shutdown(void *a1)
{
if ( a1 )
free(a1);
}

canonical_decompiled_code:
void __fastcall func4(void *a1)
{
if ( a1 )
free(a1);
}

original_code:
void DSOUND_Capture_Shutdown(void *ctx)
{
 if(ctx) { free(ctx); ctx = ((void *)0); };
}


decompiled_code:
__int64 SNDDMA_GetDMAPos_ALSA()
{
return *((unsigned int *)driver + 5);
}

canonical_decompiled_code:
__int64 func0()
{
return *((unsigned int *)driver + 5);
}

original_code:
int SNDDMA_GetDMAPos_ALSA (void)
{
 return driver->bufferpos;
}

canonical_original_code:
int SNDDMA_GetDMAPos_ALSA()
{
 return driver->bufferpos;
}


decompiled_code:
void SNDDMA_Shutdown_ALSA()
{
if ( driver )
{
(*((void (__fastcall **)(_QWORD))driver + 6))(*((_QWORD *)driver + 4));
dlclose(*(void **)driver);
free(driver);
}
else
{
Com_Printf("SNDDMA_Shutdown_ALSA: Error, tried to shut down sound but sound not initialized\n");
}
}

canonical_decompiled_code:
void func1()
{
if ( driver )
{
(*((void (__fastcall **)(_QWORD))driver + 6))(*((_QWORD *)driver + 4));
dlclose(*(void **)driver);
free(driver);
}
else
{
Com_Printf("SNDDMA_Shutdown_ALSA: Error, tried to shut down sound but sound not initialized\n");
}
}

original_code:
void SNDDMA_Shutdown_ALSA (void)
{
 if(driver) {
  driver->snd_pcm_close(driver->pcmhandle);
  dlclose(driver->alsasharedobject);
  free(driver);
 } else {
  Com_Printf("SNDDMA_Shutdown_ALSA: Error, tried to shut down sound but sound not initialized\n");
 }
}

canonical_original_code:
void SNDDMA_Shutdown_ALSA()
{
 if(driver) {
  driver->snd_pcm_close(driver->pcmhandle);
  dlclose(driver->alsasharedobject);
  free(driver);
 } else {
  Com_Printf("SNDDMA_Shutdown_ALSA: Error, tried to shut down sound but sound not initialized\n");
 }
}


decompiled_code:
__int64 alsa_getavail()
{
signed int v0; // eax
int v1; // edx
__int64 result; // rax

v0 = (*((__int64 (__fastcall **)(_QWORD))driver + 5))(*((_QWORD *)driver + 4));
v1 = v0;
if ( v0 >= 0
|| (alsa_tryrestart_constprop_0(v0),
v1 = (*((__int64 (__fastcall **)(_QWORD))driver + 5))(*((_QWORD *)driver + 4)),
result = 0LL,
v1 >= 0) )
{
result = (unsigned int)(2 * v1);
}
return result;
}

canonical_decompiled_code:
__int64 func4()
{
signed int v0; // eax
int v1; // edx
__int64 result; // rax

v0 = (*((__int64 (__fastcall **)(_QWORD))driver + 5))(*((_QWORD *)driver + 4));
v1 = v0;
if ( v0 >= 0
|| (func3(v0),
v1 = (*((__int64 (__fastcall **)(_QWORD))driver + 5))(*((_QWORD *)driver + 4)),
result = 0LL,
v1 >= 0) )
{
result = (unsigned int)(2 * v1);
}
return result;
}

original_code:
static int alsa_getavail(void)
{
 int ret;
 ret = driver->snd_pcm_avail_update(driver->pcmhandle);
 if(ret < 0) {
  alsa_tryrestart(ret, 1);
  ret = driver->snd_pcm_avail_update(driver->pcmhandle);
  if(ret < 0)
   return 0;
 }
 ret *= 2;
 return ret;
}

canonical_original_code:
static int alsa_getavail()
{
 int ret;
 ret = driver->snd_pcm_avail_update(driver->pcmhandle);
 if(ret < 0) {
  alsa_tryrestart(ret, 1);
  ret = driver->snd_pcm_avail_update(driver->pcmhandle);
  if(ret < 0)
   return 0;
 }
 ret *= 2;
 return ret;
}

variable_types: ret int


decompiled_code:
void __fastcall alsa_writestuff(unsigned int a1)
{
_DWORD *v1; // rdx
unsigned int v2; // er12
unsigned int v3; // ebx
__int64 v4; // rax
__int64 v5; // rcx
unsigned int v6; // ebx
unsigned int v7; // ebp

v1 = driver;
if ( a1 )
{
v2 = a1;
while ( 1 )
{
v6 = v1[4] - v1[5];
if ( v6 > v2 )
v6 = v2;
v7 = v6;
v3 = alsa_getavail();
if ( (*((unsigned int (__fastcall **)(_QWORD))driver + 11))(*((_QWORD *)driver + 4)) == 28
&& s_alsa_noworkaround[8] == 0.0 )
{
if ( (int)v3 <= 63 )
return;
v3 -= 64;
if ( v3 > v7 )
v3 = v7;
if ( !v3 )
return;
}
else
{
if ( v3 > v7 )
v3 = v7;
if ( !v3 )
return;
}
v4 = (*((__int64 (__fastcall **)(_QWORD, _QWORD, _QWORD))driver + 12))(
*((_QWORD *)driver + 4),
*((_QWORD *)driver + 1) + (unsigned int)(*((_DWORD *)driver + 5) * *((_DWORD *)driver + 6)),
v3 >> 1);
if ( v4 < 0 )
break;
if ( v4 )
{
v1 = driver;
v5 = shm;
v2 -= 2 * v4;
*((_DWORD *)driver + 5) += 2 * v4;
*(_DWORD *)(v5 + 20) += 2 * v4;
if ( v1[5] == v1[4] )
{
v1[5] = 0;
*(_DWORD *)(v5 + 20) = 0;
}
if ( v2 )
continue;
}
return;
}
alsa_tryrestart_constprop_0(v4);
}
}

canonical_decompiled_code:
void __fastcall func5(unsigned int a1)
{
_DWORD *v1; // rdx
unsigned int v2; // er12
unsigned int v3; // ebx
__int64 v4; // rax
__int64 v5; // rcx
unsigned int v6; // ebx
unsigned int v7; // ebp

v1 = driver;
if ( a1 )
{
v2 = a1;
while ( 1 )
{
v6 = v1[4] - v1[5];
if ( v6 > v2 )
v6 = v2;
v7 = v6;
v3 = func4();
if ( (*((unsigned int (__fastcall **)(_QWORD))driver + 11))(*((_QWORD *)driver + 4)) == 28
&& s_alsa_noworkaround[8] == 0.0 )
{
if ( (int)v3 <= 63 )
return;
v3 -= 64;
if ( v3 > v7 )
v3 = v7;
if ( !v3 )
return;
}
else
{
if ( v3 > v7 )
v3 = v7;
if ( !v3 )
return;
}
v4 = (*((__int64 (__fastcall **)(_QWORD, _QWORD, _QWORD))driver + 12))(
*((_QWORD *)driver + 4),
*((_QWORD *)driver + 1) + (unsigned int)(*((_DWORD *)driver + 5) * *((_DWORD *)driver + 6)),
v3 >> 1);
if ( v4 < 0 )
break;
if ( v4 )
{
v1 = driver;
v5 = shm;
v2 -= 2 * v4;
*((_DWORD *)driver + 5) += 2 * v4;
*(_DWORD *)(v5 + 20) += 2 * v4;
if ( v1[5] == v1[4] )
{
v1[5] = 0;
*(_DWORD *)(v5 + 20) = 0;
}
if ( v2 )
continue;
}
return;
}
func3(v4);
}
}

original_code:
static void alsa_writestuff(unsigned int max)
{
        unsigned int count;
        snd_pcm_sframes_t ret;
        int avail;
        while(max)
        {
                count = driver->buffersamples - driver->bufferpos;
                if (count > max)
                        count = max;
                avail = alsa_getavail();
  if((driver->snd_pcm_type(driver->pcmhandle)==SND_PCM_TYPE_IOPLUG) && !(s_alsa_noworkaround.value)) {
                 if (avail < 64)
                         break;
                 avail -= 64;
  }
                if (count > avail)
                        count = avail;
                if (count == 0)
                        break;
                ret = driver->snd_pcm_writei(driver->pcmhandle, driver->buffer + (driver->samplesize * driver->bufferpos), count/2);
  if (ret < 0)
                {
                        alsa_tryrestart(ret, 1);
                        break;
                }
                if (ret <= 0)
                        break;
                max -= ret * 2;
                driver->bufferpos += ret * 2;
  shm->samplepos += ret * 2;
                if (driver->bufferpos == driver->buffersamples) {
                        driver->bufferpos = 0;
   shm->samplepos = 0;
  }
        }
}

canonical_original_code:
static void alsa_writestuff(unsigned int max)
{
        unsigned int count;
        long ret;
        int avail;
        while(max)
        {
                count = driver->buffersamples - driver->bufferpos;
                if (count > max)
                        count = max;
                avail = alsa_getavail();
  if((driver->snd_pcm_type(driver->pcmhandle)==SND_PCM_TYPE_IOPLUG) && !(s_alsa_noworkaround.value)) {
                 if (avail < 64)
                         break;
                 avail -= 64;
  }
                if (count > avail)
                        count = avail;
                if (count == 0)
                        break;
                ret = driver->snd_pcm_writei(driver->pcmhandle, driver->buffer + (driver->samplesize * driver->bufferpos), count/2);
  if (ret < 0)
                {
                        alsa_tryrestart(ret, 1);
                        break;
                }
                if (ret <= 0)
                        break;
                max -= ret * 2;
                driver->bufferpos += ret * 2;
  shm->samplepos += ret * 2;
                if (driver->bufferpos == driver->buffersamples) {
                        driver->bufferpos = 0;
   shm->samplepos = 0;
  }
        }
}

variable_types:
max
unsigned int

variable_types:
count
unsigned int

variable_types: ret long

variable_types: avail int


decompiled_code:
// attributes: thunk
void __fastcall SNDDMA_Submit_ALSA(unsigned int a1)
{
alsa_writestuff(a1);
}

canonical_decompiled_code:
void __fastcall func6(unsigned int a1)
{
func5(a1);
}

original_code:
void SNDDMA_Submit_ALSA (unsigned int count)
{
 alsa_writestuff(count);
}

canonical_original_code:
void SNDDMA_Submit_ALSA(unsigned int count)
{
 alsa_writestuff(count);
}


decompiled_code:
__int64 __fastcall SNDDMA_Init_ALSA(_QWORD *a1)
{
unsigned int v1; // er13
unsigned int v2; // er15
unsigned int v3; // er14
unsigned int v4; // er12
const char *v5; // r8
const char *v6; // rsi
unsigned int v7; // eax

v1 = 1 - ((s_stereo[16] == 0) - 1);
if ( s_bits[8] == 0.0 )
{
v2 = 16;
}
else
{
v2 = LODWORD(s_bits[16]);
if ( ((v2 - 8) & 0xFFFFFFF7) != 0 )
{
v4 = 0;
Com_Printf("Error: invalid s_bits value \"%d\". Valid (8 or 16)\n", v2);
return v4;
}
}
v3 = SND_Rate(s_khz[16]);
v4 = alsa_init_internal(a1, *((_BYTE **)&s_alsa_device + 1), v3, v1, v2);
if ( !v4 )
{
v5 = (const char *)*((_QWORD *)&s_alsa_device + 1);
v6 = v5;
if ( strcmp(v5, "default") )
{
Com_Printf("Opening \"%s\" failed, trying \"default\"\n", v5);
v7 = alsa_init_internal(a1, "default", v3, v1, v2);
if ( v7 )
goto LABEL_18;
v6 = (const char *)*((_QWORD *)&s_alsa_device + 1);
v5 = "default";
}
if ( *v6 == 104 && v6[1] == 119 && !v6[2] )
{
LABEL_8:
if ( strcmp(v6, "plug:hw") )
{
Com_Printf("Opening \"%s\" failed, trying \"plug:hw\"\n", v5);
return alsa_init_internal(a1, "plug:hw", v3, v1, v2);
}
return v4;
}
Com_Printf("Opening \"%s\" failed, trying \"hw\"\n", v5);
v7 = alsa_init_internal(a1, "hw", v3, v1, v2);
if ( !v7 )
{
v6 = (const char *)*((_QWORD *)&s_alsa_device + 1);
v5 = "hw";
goto LABEL_8;
}
LABEL_18:
v4 = v7;
}
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func8(_QWORD *a1)
{
unsigned int v1; // er13
unsigned int v2; // er15
unsigned int v3; // er14
unsigned int v4; // er12
const char *v5; // r8
const char *v6; // rsi
unsigned int v7; // eax

v1 = 1 - ((s_stereo[16] == 0) - 1);
if ( s_bits[8] == 0.0 )
{
v2 = 16;
}
else
{
v2 = LODWORD(s_bits[16]);
if ( ((v2 - 8) & 0xFFFFFFF7) != 0 )
{
v4 = 0;
Com_Printf("Error: invalid s_bits value \"%d\". Valid (8 or 16)\n", v2);
return v4;
}
}
v3 = SND_Rate(s_khz[16]);
v4 = func7(a1, *((_BYTE **)&s_alsa_device + 1), v3, v1, v2);
if ( !v4 )
{
v5 = (const char *)*((_QWORD *)&s_alsa_device + 1);
v6 = v5;
if ( strcmp(v5, "default") )
{
Com_Printf("Opening \"%s\" failed, trying \"default\"\n", v5);
v7 = func7(a1, "default", v3, v1, v2);
if ( v7 )
goto LABEL_18;
v6 = (const char *)*((_QWORD *)&s_alsa_device + 1);
v5 = "default";
}
if ( *v6 == 104 && v6[1] == 119 && !v6[2] )
{
LABEL_8:
if ( strcmp(v6, "plug:hw") )
{
Com_Printf("Opening \"%s\" failed, trying \"plug:hw\"\n", v5);
return func7(a1, "plug:hw", v3, v1, v2);
}
return v4;
}
Com_Printf("Opening \"%s\" failed, trying \"hw\"\n", v5);
v7 = func7(a1, "hw", v3, v1, v2);
if ( !v7 )
{
v6 = (const char *)*((_QWORD *)&s_alsa_device + 1);
v5 = "hw";
goto LABEL_8;
}
LABEL_18:
v4 = v7;
}
return v4;
}

original_code:
qbool SNDDMA_Init_ALSA (qsoundhandler_t *sd)
{
 qbool ret;
 const char *prevattempt;
 int channels, bits, rate;
 channels = s_stereo.integer ? 2 : 1;
 bits = 16;
 if(s_bits.value) {
  bits = s_bits.integer;
  if(bits != 8 && bits != 16) {
   Com_Printf("Error: invalid s_bits value \"%d\". Valid (8 or 16)\n", bits);
   return false;
  }
 }
 rate = SND_Rate(s_khz.integer);
 ret = alsa_init_internal(sd, s_alsa_device.string, rate, channels, bits);
 prevattempt = s_alsa_device.string;
 if (ret == 0 && strcmp(s_alsa_device.string, "default") != 0)
        {
                Com_Printf("Opening \"%s\" failed, trying \"default\"\n", s_alsa_device.string);
                prevattempt = "default";
                ret = alsa_init_internal(sd, "default", rate, channels, bits);
        }
        if (ret == 0 && strcmp(s_alsa_device.string, "hw") != 0)
        {
                Com_Printf("Opening \"%s\" failed, trying \"hw\"\n", prevattempt);
  prevattempt = "hw";
                ret = alsa_init_internal(sd, "hw", rate, channels, bits);
        }
 if (ret == 0 && strcmp(s_alsa_device.string, "plug:hw") != 0)
        {
                Com_Printf("Opening \"%s\" failed, trying \"plug:hw\"\n", prevattempt);
                prevattempt = "plug:hw";
                ret = alsa_init_internal(sd, "plug:hw", rate, channels, bits);
        }
 return ret;
}

canonical_original_code:
enum qbool SNDDMA_Init_ALSA(struct qsoundhandler_s *sd)
{
 enum qbool ret;
 char *prevattempt;
 int channels; int bits; int rate;
 channels = s_stereo.integer ? 2 : 1;
 bits = 16;
 if(s_bits.value) {
  bits = s_bits.integer;
  if(bits != 8 && bits != 16) {
   Com_Printf("Error: invalid s_bits value \"%d\". Valid (8 or 16)\n", bits);
   return false;
  }
 }
 rate = SND_Rate(s_khz.integer);
 ret = alsa_init_internal(sd, s_alsa_device.string, rate, channels, bits);
 prevattempt = s_alsa_device.string;
 if (ret == 0 && strcmp(s_alsa_device.string, "default") != 0)
        {
                Com_Printf("Opening \"%s\" failed, trying \"default\"\n", s_alsa_device.string);
                prevattempt = "default";
                ret = alsa_init_internal(sd, "default", rate, channels, bits);
        }
        if (ret == 0 && strcmp(s_alsa_device.string, "hw") != 0)
        {
                Com_Printf("Opening \"%s\" failed, trying \"hw\"\n", prevattempt);
  prevattempt = "hw";
                ret = alsa_init_internal(sd, "hw", rate, channels, bits);
        }
 if (ret == 0 && strcmp(s_alsa_device.string, "plug:hw") != 0)
        {
                Com_Printf("Opening \"%s\" failed, trying \"plug:hw\"\n", prevattempt);
                prevattempt = "plug:hw";
                ret = alsa_init_internal(sd, "plug:hw", rate, channels, bits);
        }
 return ret;
}

variable_types: struct qsoundhandler_s { char *name; int (*GetAvail)(); int (*GetDMAPos)(); void (*Submit)(unsigned int count); void (*Shutdown)(); } *

variable_types:
ret
enum qbool { false=0, true=1 }

variable_types:
prevattempt
char *

variable_types: channels int

variable_types: bits int

return_type: enum qbool { false=0, true=1 }


CheckProxyConnection

decompiled_code:
__int64 CheckProxyConnection()
{
if ( (unsigned int)CL_ConnectedToProxy() )
return 1LL;
Com_Printf("You are not connected to a proxy.\n");
M_LeaveMenus();
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
if ( (unsigned int)CL_ConnectedToProxy() )
return 1LL;
Com_Printf("You are not connected to a proxy.\n");
M_LeaveMenus();
return 0LL;
}

original_code:
qbool CheckProxyConnection(void) {
 if (!CL_ConnectedToProxy()) {
  Com_Printf("You are not connected to a proxy.\n");
  M_LeaveMenus();
  return false;
 }
 return true;
}

canonical_original_code:
enum qbool CheckProxyConnection() {
 if (!CL_ConnectedToProxy()) {
  Com_Printf("You are not connected to a proxy.\n");
  M_LeaveMenus();
  return false;
 }
 return true;
}


decompiled_code:
__int64 Menu_Proxy_Toggle()
{
__int64 result; // rax

result = CheckProxyConnection();
if ( (_DWORD)result )
result = Cbuf_AddText("say proxy:menu\n");
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax

result = func0();
if ( (_DWORD)result )
result = Cbuf_AddText("say proxy:menu\n");
return result;
}

original_code:
void Menu_Proxy_Toggle(void)
{
 if (!CheckProxyConnection())
  return;
 Cbuf_AddText("say proxy:menu" "\n");;
}

canonical_original_code:
void Menu_Proxy_Toggle()
{
 if (!CheckProxyConnection())
  return;
 Cbuf_AddText("say proxy:menu" "\n");;
}


decompiled_code:
__int64 __fastcall Menu_Proxy_Key(int a1)
{
__int64 result; // rax

result = CheckProxyConnection();
if ( (_DWORD)result && a1 <= 200 )
{
if ( a1 <= 126 )
{
if ( a1 == 13 )
{
LABEL_9:
result = Cbuf_AddText("say proxy:menu select\n");
}
else if ( a1 == 27 )
{
Cbuf_AddText("say proxy:menu\n");
result = M_LeaveMenus();
}
}
else
{
switch ( a1 )
{
case 127:
result = Cbuf_AddText("say proxy:menu back\n");
break;
case 132:
result = Cbuf_AddText("say proxy:menu up\n");
break;
case 133:
result = Cbuf_AddText("say proxy:menu down\n");
break;
case 134:
result = Cbuf_AddText("say proxy:menu left\n");
break;
case 135:
result = Cbuf_AddText("say proxy:menu right\n");
break;
case 157:
result = Cbuf_AddText("say proxy:menu help\n");
break;
case 158:
result = Cbuf_AddText("say proxy:menu delete\n");
break;
case 159:
result = Cbuf_AddText("say proxy:menu pgdn\n");
break;
case 160:
result = Cbuf_AddText("say proxy:menu pgup\n");
break;
case 161:
result = Cbuf_AddText("say proxy:menu home\n");
break;
case 162:
result = Cbuf_AddText("say proxy:menu end\n");
break;
case 200:
goto LABEL_9;
default:
return result;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
__int64 result; // rax

result = func0();
if ( (_DWORD)result && a1 <= 200 )
{
if ( a1 <= 126 )
{
if ( a1 == 13 )
{
LABEL_9:
result = Cbuf_AddText("say proxy:menu select\n");
}
else if ( a1 == 27 )
{
Cbuf_AddText("say proxy:menu\n");
result = M_LeaveMenus();
}
}
else
{
switch ( a1 )
{
case 127:
result = Cbuf_AddText("say proxy:menu back\n");
break;
case 132:
result = Cbuf_AddText("say proxy:menu up\n");
break;
case 133:
result = Cbuf_AddText("say proxy:menu down\n");
break;
case 134:
result = Cbuf_AddText("say proxy:menu left\n");
break;
case 135:
result = Cbuf_AddText("say proxy:menu right\n");
break;
case 157:
result = Cbuf_AddText("say proxy:menu help\n");
break;
case 158:
result = Cbuf_AddText("say proxy:menu delete\n");
break;
case 159:
result = Cbuf_AddText("say proxy:menu pgdn\n");
break;
case 160:
result = Cbuf_AddText("say proxy:menu pgup\n");
break;
case 161:
result = Cbuf_AddText("say proxy:menu home\n");
break;
case 162:
result = Cbuf_AddText("say proxy:menu end\n");
break;
case 200:
goto LABEL_9;
default:
return result;
}
}
}
return result;
}

original_code:
void Menu_Proxy_Key(int key)
{
 if (!CheckProxyConnection())
  return;
 switch (key) {
 case K_ESCAPE:
  Cbuf_AddText("say proxy:menu" "\n");;
  M_LeaveMenus();
  break;
 case K_MOUSE1: case K_ENTER:
  Cbuf_AddText("say proxy:menu" " " "select" "\n"); break;
 case K_BACKSPACE: Cbuf_AddText("say proxy:menu" " " "back" "\n"); break;
 case K_UPARROW: Cbuf_AddText("say proxy:menu" " " "up" "\n"); break;
 case K_DOWNARROW: Cbuf_AddText("say proxy:menu" " " "down" "\n"); break;
 case K_LEFTARROW: Cbuf_AddText("say proxy:menu" " " "left" "\n"); break;
 case K_RIGHTARROW: Cbuf_AddText("say proxy:menu" " " "right" "\n"); break;
 case K_PGDN: Cbuf_AddText("say proxy:menu" " " "pgdn" "\n"); break;
 case K_PGUP: Cbuf_AddText("say proxy:menu" " " "pgup" "\n"); break;
 case K_HOME: Cbuf_AddText("say proxy:menu" " " "home" "\n"); break;
 case K_END: Cbuf_AddText("say proxy:menu" " " "end" "\n"); break;
 case K_DEL: Cbuf_AddText("say proxy:menu" " " "delete" "\n"); break;
 case K_INS: Cbuf_AddText("say proxy:menu" " " "help" "\n"); break;
 }
}

variable_types: key int


decompiled_code:
void Menu_Proxy_Draw()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void Menu_Proxy_Draw() {
}

canonical_original_code:
void Menu_Proxy_Draw() {
}


decompiled_code:
void __fastcall FSOS_ClosePath(void *a1)
{
if ( a1 )
free(a1);
}

canonical_decompiled_code:
void __fastcall func1(void *a1)
{
if ( a1 )
free(a1);
}

original_code:
static void FSOS_ClosePath(void *handle)
{
 if(handle) { free(handle); handle = ((void *)0); };
}

variable_types:
handle
void *


decompiled_code:
// attributes: thunk
__int64 FSOS_EnumerateFiles()
{
return Sys_EnumerateFiles();
}

canonical_decompiled_code:
__int64 func8()
{
return Sys_EnumerateFiles();
}

original_code:
static int FSOS_EnumerateFiles (void *handle, char *match, int (*func)(char *, int, void *), void *parm)
{
 return Sys_EnumerateFiles(handle, match, func, parm);
}

canonical_original_code:
static int FSOS_EnumerateFiles(void *handle, char *match, int (*func)(char *, int, void *), void *parm)
{
 return Sys_EnumerateFiles(handle, match, func, parm);
}

variable_types:
match
char *

variable_types:
func
int (*)(char *, int, void *)

variable_types:
parm
void *


decompiled_code:
__int64 __fastcall FSOS_BuildHash(__int64 a1)
{
return Sys_EnumerateFiles(a1, "*", FSOS_RebuildFSHash, a1);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
return Sys_EnumerateFiles(a1, "*", FSOS_RebuildFSHash, a1);
}

original_code:
static void FSOS_BuildHash(void *handle)
{
 Sys_EnumerateFiles(handle, "*", FSOS_RebuildFSHash, handle);
}


decompiled_code:
__int64 __fastcall FSOS_RebuildFSHash(const char *a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
char v5[280]; // [rsp+0h] [rbp-118h] BYREF

if ( a1[strlen(a1) - 1] == 47 )
{
snprintf(v5, 0x100uLL, "%s*", a1);
Sys_EnumerateFiles(a3, v5, FSOS_RebuildFSHash, a3);
result = 1LL;
}
else
{
if ( Hash_GetInsensitive(filesystemhash, a1) )
{
++fs_hash_dups;
}
else
{
Hash_AddInsensitive(filesystemhash, a1, a3);
++fs_hash_files;
}
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(const char *a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
char v5[280]; // [rsp+0h] [rbp-118h] BYREF

if ( a1[strlen(a1) - 1] == 47 )
{
snprintf(v5, 0x100uLL, "%s*", a1);
Sys_EnumerateFiles(a3, v5, FSOS_RebuildFSHash, a3);
result = 1LL;
}
else
{
if ( Hash_GetInsensitive(filesystemhash, a1) )
{
++fs_hash_dups;
}
else
{
Hash_AddInsensitive(filesystemhash, a1, a3);
++fs_hash_files;
}
result = 1LL;
}
return result;
}

original_code:
static int FSOS_RebuildFSHash(char *filename, int filesize, void *data)
{
 if (filename[strlen(filename)-1] == '/')
 {
  char childpath[256];
  snprintf(childpath, sizeof (childpath), "%s*", filename);
  Sys_EnumerateFiles((char*)data, childpath, FSOS_RebuildFSHash, data);
  return true;
 }
 if (!Hash_GetInsensitive(filesystemhash, filename))
 {
  Hash_AddInsensitive(filesystemhash, filename, data);
  fs_hash_files++;
 }
 else
  fs_hash_dups++;
 return true;
}

canonical_original_code:
static int FSOS_RebuildFSHash(char *filename, int filesize, void *data)
{
 if (filename[strlen(filename)-1] == '/')
 {
  char childpath[256];
  snprintf(childpath, sizeof (childpath), "%s*", filename);
  Sys_EnumerateFiles((char *)data, childpath, FSOS_RebuildFSHash, data);
  return true;
 }
 if (!Hash_GetInsensitive(filesystemhash, filename))
 {
  Hash_AddInsensitive(filesystemhash, filename, data);
  fs_hash_files++;
 }
 else
  fs_hash_dups++;
 return true;
}

variable_types:
filename
char *

variable_types: filesize int

variable_types:
data
void *

variable_types:
childpath
char [256]


decompiled_code:
__int64 __fastcall FSOS_PrintPath(const char *a1)
{
return Com_Printf("%s\n", a1);
}

canonical_decompiled_code:
__int64 __fastcall func12(const char *a1)
{
return Com_Printf("%s\n", a1);
}

original_code:
static void FSOS_PrintPath(void *handle)
{
 Com_Printf("%s\n", handle);
}


decompiled_code:
__int64 oss_getdmapos()
{
int v0; // eax
__int64 v1; // rcx
char v3[8]; // [rsp+4h] [rbp-14h] BYREF
unsigned int v4; // [rsp+Ch] [rbp-Ch]

v0 = ioctl(*(_DWORD *)pdriver, 0x800C5012uLL, v3);
v1 = shm;
if ( v0 == -1 )
*(_DWORD *)(shm + 20LL) = 0;
else
*(_DWORD *)(shm + 20LL) = v4 / *(_DWORD *)(shm + 4LL);
return *(unsigned int *)(v1 + 20);
}

canonical_decompiled_code:
__int64 func0()
{
int v0; // eax
__int64 v1; // rcx
char v3[8]; // [rsp+4h] [rbp-14h] BYREF
unsigned int v4; // [rsp+Ch] [rbp-Ch]

v0 = ioctl(*(_DWORD *)pdriver, 0x800C5012uLL, v3);
v1 = shm;
if ( v0 == -1 )
*(_DWORD *)(shm + 20LL) = 0;
else
*(_DWORD *)(shm + 20LL) = v4 / *(_DWORD *)(shm + 4LL);
return *(unsigned int *)(v1 + 20);
}

original_code:
static int oss_getdmapos(void)
{
 struct count_info count;
 if (ioctl(pdriver->fd, (((2U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((18)) << 0) | ((((sizeof(count_info)))) << ((0 +8)+8))), &count) != -1)
  shm->samplepos = count.ptr/(shm->format.width);
 else
  shm->samplepos = 0;
 return shm->samplepos;
}

canonical_original_code:
static int oss_getdmapos()
{
 struct count_info count;
 if (ioctl(pdriver->fd, (((2U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((18)) << 0) | ((((sizeof(count_info)))) << ((0 +8)+8))), &count) != -1)
  shm->samplepos = count.ptr/(shm->format.width);
 else
  shm->samplepos = 0;
 return shm->samplepos;
}

variable_types: struct count_info { int bytes; int blocks; int ptr; }


variable_types:
device
char *

variable_types: rate int

variable_types: i int

variable_types: capabilities int

variable_types: dspformats int

variable_types: struct audio_buf_info { int fragments; int fragstotal; int fragsize; int bytes; }

variable_types:
p
struct oss_private { int fd; } *

user_defined_types: struct qsoundhandler_s { char *name; int (*GetAvail)(); int (*GetDMAPos)(); void (*Submit)(unsigned int count); void (*Shutdown)(); }


decompiled_code:
__int64 __fastcall oss_init(_QWORD *a1, int a2, int a3, int a4)
{
__int64 result; // rax

result = oss_init_internal(a1, *((const char **)&s_oss_device + 1), a2, a3, a4);
if ( !(_DWORD)result )
{
if ( strcmp(*((const char **)&s_oss_device + 1), "/dev/dsp") )
{
Com_Printf("Opening \"%s\" failed, trying \"/dev/dsp\"\n", *((const char **)&s_oss_device + 1));
result = oss_init_internal(a1, "/dev/dsp", a2, a3, a4);
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1, int a2, int a3, int a4)
{
__int64 result; // rax

result = func1(a1, *((const char **)&s_oss_device + 1), a2, a3, a4);
if ( !(_DWORD)result )
{
if ( strcmp(*((const char **)&s_oss_device + 1), "/dev/dsp") )
{
Com_Printf("Opening \"%s\" failed, trying \"/dev/dsp\"\n", *((const char **)&s_oss_device + 1));
result = func1(a1, "/dev/dsp", a2, a3, a4);
}
}
return result;
}

original_code:
static qbool oss_init(qsoundhandler_t *sd, int rate, int channels, int bits)
{
 qbool ret;
 ret = oss_init_internal(sd, s_oss_device.string, rate, channels, bits);
 if (ret == 0 && strcmp(s_oss_device.string, "/dev/dsp") != 0)
 {
  Com_Printf("Opening \"%s\" failed, trying \"/dev/dsp\"\n", s_oss_device.string);
  ret = oss_init_internal(sd, "/dev/dsp", rate, channels, bits);
 }
 return ret;
}

canonical_original_code:
static enum qbool oss_init(struct qsoundhandler_s *sd, int rate, int channels, int bits)
{
 enum qbool ret;
 ret = oss_init_internal(sd, s_oss_device.string, rate, channels, bits);
 if (ret == 0 && strcmp(s_oss_device.string, "/dev/dsp") != 0)
 {
  Com_Printf("Opening \"%s\" failed, trying \"/dev/dsp\"\n", s_oss_device.string);
  ret = oss_init_internal(sd, "/dev/dsp", rate, channels, bits);
 }
 return ret;
}

variable_types: struct qsoundhandler_s { char *name; int (*GetAvail)(); int (*GetDMAPos)(); void (*Submit)(unsigned int count); void (*Shutdown)(); } *

variable_types: channels int

variable_types: bits int

variable_types:
ret
enum qbool { false=0, true=1 }


decompiled_code:
void oss_shutdown()
{
munmap(*(void **)(shm + 24LL), (unsigned int)(*(_DWORD *)(shm + 4LL) * *(_DWORD *)(shm + 16LL)));
close(*(_DWORD *)pdriver);
free(pdriver);
}

canonical_decompiled_code:
void func3()
{
munmap(*(void **)(shm + 24LL), (unsigned int)(*(_DWORD *)(shm + 4LL) * *(_DWORD *)(shm + 16LL)));
close(*(_DWORD *)pdriver);
free(pdriver);
}

original_code:
static void oss_shutdown(void)
{
 munmap(shm->buffer, shm->samples*(shm->format.width));
 close(pdriver->fd);
 free(pdriver);
}

canonical_original_code:
static void oss_shutdown()
{
 munmap(shm->buffer, shm->samples*(shm->format.width));
 close(pdriver->fd);
 free(pdriver);
}


decompiled_code:
__int64 __fastcall SNDDMA_Init_OSS(_QWORD *a1)
{
int v1; // er12
unsigned int v2; // er13
int v3; // eax

v1 = 1 - ((s_stereo[16] == 0) - 1);
if ( s_bits[8] == 0.0 )
{
v2 = 16;
goto LABEL_3;
}
v2 = LODWORD(s_bits[16]);
if ( ((v2 - 8) & 0xFFFFFFF7) == 0 )
{
LABEL_3:
v3 = SND_Rate(s_khz[16]);
return oss_init(a1, v3, v1, v2);
}
Com_Printf("Error: invalid s_bits value \"%d\". Valid (8 or 16)", v2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1)
{
int v1; // er12
unsigned int v2; // er13
int v3; // eax

v1 = 1 - ((s_stereo[16] == 0) - 1);
if ( s_bits[8] == 0.0 )
{
v2 = 16;
goto LABEL_3;
}
v2 = LODWORD(s_bits[16]);
if ( ((v2 - 8) & 0xFFFFFFF7) == 0 )
{
LABEL_3:
v3 = SND_Rate(s_khz[16]);
return func2(a1, v3, v1, v2);
}
Com_Printf("Error: invalid s_bits value \"%d\". Valid (8 or 16)", v2);
return 0LL;
}

original_code:
qbool SNDDMA_Init_OSS(qsoundhandler_t *sd) {
 int rate, channels, bits;
 channels = s_stereo.integer ? 2 : 1;
 bits = 16;
 if(s_bits.value) {
                bits = s_bits.integer;
                if(bits != 8 && bits != 16) {
                        Com_Printf("Error: invalid s_bits value \"%d\". Valid (8 or 16)", bits);
                        return false;
                }
        }
        rate = SND_Rate(s_khz.integer);
 return oss_init(sd, rate, channels, bits);
}

canonical_original_code:
enum qbool SNDDMA_Init_OSS(struct qsoundhandler_s *sd) {
 int rate; int channels; int bits;
 channels = s_stereo.integer ? 2 : 1;
 bits = 16;
 if(s_bits.value) {
                bits = s_bits.integer;
                if(bits != 8 && bits != 16) {
                        Com_Printf("Error: invalid s_bits value \"%d\". Valid (8 or 16)", bits);
                        return false;
                }
        }
        rate = SND_Rate(s_khz.integer);
 return oss_init(sd, rate, channels, bits);
}


decompiled_code:
__int64 CTab_New()
{
_QWORD *v0; // rax
__int64 v1; // r8

v0 = (_QWORD *)Q_malloc(1184LL);
CTab_Init(v0);
return v1;
}

canonical_decompiled_code:
__int64 func3()
{
_QWORD *v0; // rax
__int64 v1; // r8

v0 = (_QWORD *)Q_malloc(1184LL);
func1(v0);
return v1;
}

original_code:
CTab_t * CTab_New(void)
{
    CTab_t *tab = (CTab_t *) Q_malloc(sizeof(CTab_t));
    CTab_Init(tab);
    return tab;
}

canonical_original_code:
struct CTab_s *CTab_New()
{
    struct CTab_s *tab = (CTab_t *) Q_malloc(sizeof(CTab_t));
    CTab_Init(tab);
    return tab;
}

variable_types: struct CTab_s { struct CTabPage_s { char name[-1]; int id; struct CTabPage_Handlers_s { void (*draw)(int x, int y, int w, int h, struct CTab_s *, struct CTabPage_s *); int (*key)(int key, unsigned short unichar, struct CTab_s *, struct CTabPage_s *); void (*onshow)(); enum qbool { false=0, true=1 } (*mousemove)(struct mouse_state_s { double x; double y; double x_old; double y_old; enum qbool { false=0, true=1 } buttons[9]; int button_down; int button_up; } *ms); } handlers; } pages[16]; int nPages; int activePage; int lastViewedPage; int hoveredPage; int width; int height; struct { int x; } navi_boxes[16]; void *tag; } *

user_defined_types: struct CTab_s { struct CTabPage_s pages[16]; int nPages; int activePage; int lastViewedPage; int hoveredPage; int width; int height; struct { int x; } navi_boxes[16]; void *tag; }

user_defined_types: struct CTabPage_s { char name[-1]; int id; struct CTabPage_Handlers_s handlers; }

user_defined_types: struct CTabPage_Handlers_s { void (*draw)(int x, int y, int w, int h, struct CTab_s *, struct CTabPage_s *); int (*key)(int key, unsigned short unichar, struct CTab_s *, struct CTabPage_s *); void (*onshow)(); enum qbool (*mousemove)(struct mouse_state_s *ms); }

user_defined_types: struct mouse_state_s { double x; double y; double x_old; double y_old; enum qbool buttons[9]; int button_down; int button_up; }