decompiled_code:
__int64 __fastcall SList_Switch(unsigned int a1, unsigned int a2)
{
__int64 v2; // rbp
__int64 result; // rax
__int64 v4; // rdx
__int64 v5; // rbx

if ( a1 > 0x1FF )
Sys_Error("SList_Switch: Bad index %d", a1);
if ( a2 > 0x1FF )
Sys_Error("SList_Switch: Bad index %d", a2);
v2 = (int)a1;
result = *(_QWORD *)&slist[v2];
v4 = *((_QWORD *)&slist[v2] + 1);
v5 = (int)a2;
slist[v2] = (__int128)_mm_load_si128((const __m128i *)&slist[v5]);
*(_QWORD *)&slist[v5] = result;
*((_QWORD *)&slist[v5] + 1) = v4;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1, unsigned int a2)
{
__int64 v2; // rbp
__int64 result; // rax
__int64 v4; // rdx
__int64 v5; // rbx

if ( a1 > 0x1FF )
Sys_Error("SList_Switch: Bad index %d", a1);
if ( a2 > 0x1FF )
Sys_Error("SList_Switch: Bad index %d", a2);
v2 = (int)a1;
result = *(_QWORD *)&slist[v2];
v4 = *((_QWORD *)&slist[v2] + 1);
v5 = (int)a2;
slist[v2] = (__int128)_mm_load_si128((const __m128i *)&slist[v5]);
*(_QWORD *)&slist[v5] = result;
*((_QWORD *)&slist[v5] + 1) = v4;
return result;
}

original_code:
void SList_Switch (int a, int b) {
 server_entry_t temp;
 if (a >= 512 || a < 0)
  Sys_Error("SList_Switch: Bad index %d", a);
 if (b >= 512 || b < 0)
  Sys_Error("SList_Switch: Bad index %d", b);
 memcpy(&temp, &slist[a], sizeof(temp));
 memcpy(&slist[a], &slist[b], sizeof(temp));
 memcpy(&slist[b], &temp, sizeof(temp));
}

canonical_original_code:
void SList_Switch(int a, int b) {
 struct server_entry_t temp;
 if (a >= 512 || a < 0)
  Sys_Error("SList_Switch: Bad index %d", a);
 if (b >= 512 || b < 0)
  Sys_Error("SList_Switch: Bad index %d", b);
 memcpy(&temp, &slist[a], sizeof(temp));
 memcpy(&slist[a], &slist[b], sizeof(temp));
 memcpy(&slist[b], &temp, sizeof(temp));
}

variable_types: a int

variable_types: b int

variable_types: struct server_entry_t { char *server; char *description; }


repo: jite/jquake

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

result = 0LL;
memset(&slist, 0, 0x2000uLL);
return result;
}

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

result = 0LL;
memset(&slist, 0, 0x2000uLL);
return result;
}

original_code:
void SList_Init(void) {
 memset(&slist, 0, sizeof(slist));
}

canonical_original_code:
void SList_Init() {
 memset(&slist, 0, sizeof(slist));
}

return_type: void


decompiled_code:
__int64 __fastcall SList_Set(unsigned int a1, __int64 a2, __int64 a3)
{
void *v5; // rdi
void *v6; // rdi
__int64 v7; // rbx
__int64 result; // rax

if ( a1 > 0x1FF )
Sys_Error("SList_Switch: Bad index %d", a1);
v5 = *(void **)&slist[a1];
if ( v5 )
{
free(v5);
*(_QWORD *)&slist[a1] = 0LL;
}
v6 = (void *)*((_QWORD *)&slist[a1] + 1);
if ( v6 )
{
free(v6);
*((_QWORD *)&slist[a1] + 1) = 0LL;
}
v7 = (int)a1;
*(_QWORD *)&slist[v7] = Q_strdup(a2);
result = Q_strdup(a3);
*((_QWORD *)&slist[v7] + 1) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1, __int64 a2, __int64 a3)
{
void *v5; // rdi
void *v6; // rdi
__int64 v7; // rbx
__int64 result; // rax

if ( a1 > 0x1FF )
Sys_Error("SList_Switch: Bad index %d", a1);
v5 = *(void **)&slist[a1];
if ( v5 )
{
free(v5);
*(_QWORD *)&slist[a1] = 0LL;
}
v6 = (void *)*((_QWORD *)&slist[a1] + 1);
if ( v6 )
{
free(v6);
*((_QWORD *)&slist[a1] + 1) = 0LL;
}
v7 = (int)a1;
*(_QWORD *)&slist[v7] = Q_strdup(a2);
result = Q_strdup(a3);
*((_QWORD *)&slist[v7] + 1) = result;
return result;
}

original_code:
void SList_Set (int i, char *addr, char *desc) {
 if (i >= 512 || i < 0)
  Sys_Error("SList_Switch: Bad index %d", i);
 if (slist[i].server)
  if(slist[i].server) { free(slist[i].server); slist[i].server = ((void *)0); };
 if (slist[i].description)
  if(slist[i].description) { free(slist[i].description); slist[i].description = ((void *)0); };
 slist[i].server = Q_strdup (addr);
 slist[i].description = Q_strdup (desc);
}

canonical_original_code:
void SList_Set(int i, char *addr, char *desc) {
 if (i >= 512 || i < 0)
  Sys_Error("SList_Switch: Bad index %d", i);
 if (slist[i].server)
  if(slist[i].server) { free(slist[i].server); slist[i].server = ((void *)0); };
 if (slist[i].description)
  if(slist[i].description) { free(slist[i].description); slist[i].description = ((void *)0); };
 slist[i].server = Q_strdup (addr);
 slist[i].description = Q_strdup (desc);
}

variable_types: i int

variable_types:
addr
char *

variable_types:
desc
char *


decompiled_code:
__int64 __fastcall SList_Reset_NoFree(unsigned int a1)
{
__int64 v1; // rbx
__int64 result; // rax

if ( a1 > 0x1FF )
result = Sys_Error("SList_Switch: Bad index %d", a1);
v1 = (int)a1;
*(_QWORD *)&slist[v1] = 0LL;
*((_QWORD *)&slist[v1] + 1) = 0LL;
return result;
}

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

if ( a1 > 0x1FF )
result = Sys_Error("SList_Switch: Bad index %d", a1);
v1 = (int)a1;
*(_QWORD *)&slist[v1] = 0LL;
*((_QWORD *)&slist[v1] + 1) = 0LL;
return result;
}

original_code:
void SList_Reset_NoFree (int i) {
 if (i >= 512 || i < 0)
  Sys_Error("SList_Switch: Bad index %d", i);
 slist[i].description = slist[i].server = ((void *)0);
}

canonical_original_code:
void SList_Reset_NoFree(int i) {
 if (i >= 512 || i < 0)
  Sys_Error("SList_Switch: Bad index %d", i);
 slist[i].description = slist[i].server = ((void *)0);
}


decompiled_code:
__int64 SList_Length()
{
__int128 *v0; // rdx
__int64 result; // rax

v0 = slist;
result = 0LL;
do
{
if ( !*(_QWORD *)v0 )
break;
result = (unsigned int)(result + 1);
++v0;
}
while ( (_DWORD)result != 512 );
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int128 *v0; // rdx
__int64 result; // rax

v0 = slist;
result = 0LL;
do
{
if ( !*(_QWORD *)v0 )
break;
result = (unsigned int)(result + 1);
++v0;
}
while ( (_DWORD)result != 512 );
return result;
}

original_code:
int SList_Length (void) {
 int count;
 for (count = 0; count < 512 && slist[count].server; count++)
  ;
 return count;
}

canonical_original_code:
int SList_Length() {
 int count;
 for (count = 0; count < 512 && slist[count].server; count++)
  ;
 return count;
}

variable_types: count int

return_type: int


decompiled_code:
__int64 __fastcall UI_Print3(__int64 a1, __int64 a2, unsigned __int8 *a3, __int64 a4, __int64 a5, int a6)
{
unsigned int v6; // ebp
unsigned __int8 *v7; // rbx
unsigned __int8 v8; // dl
__int64 result; // rax

v6 = a1;
v7 = a3;
if ( !a6 )
return Draw_ColoredString3(a1, a2, a3, a4, a5, 0LL);
v8 = *a3;
if ( v8 )
{
do
{
result = UI_DrawCharacter(v6, (unsigned int)a2, v8 | 0x80u);
++v7;
v6 += 8;
v8 = *v7;
}
while ( *v7 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, unsigned __int8 *a3, __int64 a4, __int64 a5, int a6)
{
unsigned int v6; // ebp
unsigned __int8 *v7; // rbx
unsigned __int8 v8; // dl
__int64 result; // rax

v6 = a1;
v7 = a3;
if ( !a6 )
return Draw_ColoredString3(a1, a2, a3, a4, a5, 0LL);
v8 = *a3;
if ( v8 )
{
do
{
result = func0(v6, (unsigned int)a2, v8 | 0x80u);
++v7;
v6 += 8;
v8 = *v7;
}
while ( *v7 );
}
return result;
}

original_code:
void UI_Print3 (int cx, int cy, const char *str, clrinfo_t *clr, int clr_cnt, int red)
{
 if (red)
 {
  while (*str)
  {
   UI_DrawCharacter (cx, cy, (*str) | (red ? 128 : 0));
   str++;
   cx += 8;
  }
 }
 else
 {
  Draw_ColoredString3 (cx, cy, str, clr, clr_cnt, red);
 }
}

canonical_original_code:
void UI_Print3(int cx, int cy, char *str, struct clrinfo_s *clr, int clr_cnt, int red)
{
 if (red)
 {
  while (*str)
  {
   UI_DrawCharacter (cx, cy, (*str) | (red ? 128 : 0));
   str++;
   cx += 8;
  }
 }
 else
 {
  Draw_ColoredString3 (cx, cy, str, clr, clr_cnt, red);
 }
}

variable_types: cx int

variable_types: cy int

variable_types:
str
char *

variable_types:
clr
struct clrinfo_s { int c; int i; } *

variable_types: red int


decompiled_code:
__int64 __fastcall UI_Print_Center3(int a1, unsigned int a2, int a3, char *a4, __int64 a5, unsigned int a6, int a7)
{
int v11; // eax

v11 = strlen(a4);
return UI_Print3((unsigned int)(a1 + (a3 - 8 * v11) / 2), a2, (unsigned __int8 *)a4, a5, a6, a7);
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, unsigned int a2, int a3, char *a4, __int64 a5, unsigned int a6, int a7)
{
int v11; // eax

v11 = strlen(a4);
return func4((unsigned int)(a1 + (a3 - 8 * v11) / 2), a2, (unsigned __int8 *)a4, a5, a6, a7);
}

original_code:
void UI_Print_Center3 (int cx, int cy, int w, char *str, clrinfo_t *clr, int clr_cnt, int red)
{
 int text_length = strlen(str);
 UI_Print3(cx + (w - 8 * text_length) / 2, cy, str, clr, clr_cnt, red);
}

canonical_original_code:
void UI_Print_Center3(int cx, int cy, int w, char *str, struct clrinfo_s *clr, int clr_cnt, int red)
{
 int text_length = strlen(str);
 UI_Print3(cx + (w - 8 * text_length) / 2, cy, str, clr, clr_cnt, red);
}

variable_types: w int


decompiled_code:
__int64 UI_DrawColoredAlphaBox()
{
return Draw_AlphaFillRGB();
}

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

original_code:
void UI_DrawColoredAlphaBox(int x, int y, int w, int h, color_t color)
{
 Draw_AlphaFillRGB(x, y, w, h, color);
}

canonical_original_code:
void UI_DrawColoredAlphaBox(int x, int y, int w, int h, int color)
{
 Draw_AlphaFillRGB(x, y, w, h, color);
}

variable_types: x int

variable_types: y int

variable_types: h int

variable_types: color int


decompiled_code:
__int64 __fastcall UI_DrawGrayBox(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4)
{
unsigned int v6; // ebx
float v7; // er15
float v8; // xmm0_4
unsigned int v9; // eax
double v11; // xmm0_8
float v12; // xmm1_4

v6 = HIDWORD(menu_marked_bgcolor[8]);
v7 = *(float *)&menu_marked_fade[4];
v8 = *(float *)&LC0;
if ( v7 != 0.0 )
{
v11 = Sys_DoubleTime(1.0);
v12 = (sin(v7 * v11) + 1.0) * 0.5;
v8 = v12 * 0.5 + 0.5;
if ( v8 < 0.0 )
{
v8 = 0.0;
}
else if ( v8 > 1.0 )
{
v8 = *(float *)&LC0;
}
}
v9 = RGBA_TO_COLOR(
(unsigned __int8)(int)(float)(v8 * (float)(unsigned __int8)v6),
(unsigned __int8)(int)(float)((float)BYTE1(v6) * v8),
(unsigned __int8)(int)(float)((float)BYTE2(v6) * v8),
HIBYTE(v6));
return UI_DrawColoredAlphaBox(a1, a2, a3, a4, v9);
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned int a1, unsigned int a2, unsigned int a3, unsigned int a4)
{
unsigned int v6; // ebx
float v7; // er15
float v8; // xmm0_4
unsigned int v9; // eax
double v11; // xmm0_8
float v12; // xmm1_4

v6 = HIDWORD(menu_marked_bgcolor[8]);
v7 = *(float *)&menu_marked_fade[4];
v8 = *(float *)&LC0;
if ( v7 != 0.0 )
{
v11 = Sys_DoubleTime(1.0);
v12 = (sin(v7 * v11) + 1.0) * 0.5;
v8 = v12 * 0.5 + 0.5;
if ( v8 < 0.0 )
{
v8 = 0.0;
}
else if ( v8 > 1.0 )
{
v8 = *(float *)&LC0;
}
}
v9 = RGBA_TO_COLOR(
(unsigned __int8)(int)(float)(v8 * (float)(unsigned __int8)v6),
(unsigned __int8)(int)(float)((float)BYTE1(v6) * v8),
(unsigned __int8)(int)(float)((float)BYTE2(v6) * v8),
HIBYTE(v6));
return func9(a1, a2, a3, a4, v9);
}

original_code:
void UI_DrawGrayBox(int x, int y, int w, int h)
{
 byte c[4];
 float fade = 1;
 memcpy(c, menu_marked_bgcolor.color, sizeof(byte) * 4);
 if (menu_marked_fade.value)
 {
  fade = 0.5 * (1.0 + sin(menu_marked_fade.value * Sys_DoubleTime()));
  fade = 0.5 + (1.0 - 0.5) * fade ;
  fade = ((0) >= (1) ? (0) : (fade) < (0) ? (0) : (fade) > (1) ? (1) : (fade));
 }
 UI_DrawColoredAlphaBox(x, y, w, h, RGBA_TO_COLOR((fade * c[0]), (fade * c[1]), (fade * c[2]), c[3]));
}

canonical_original_code:
void UI_DrawGrayBox(int x, int y, int w, int h)
{
 unsigned char c[4];
 float fade = 1;
 memcpy(c, menu_marked_bgcolor.color, sizeof(byte) * 4);
 if (menu_marked_fade.value)
 {
  fade = 0.5 * (1.0 + sin(menu_marked_fade.value * Sys_DoubleTime()));
  fade = 0.5 + (1.0 - 0.5) * fade ;
  fade = ((0) >= (1) ? (0) : (fade) < (0) ? (0) : (fade) > (1) ? (1) : (fade));
 }
 UI_DrawColoredAlphaBox(x, y, w, h, RGBA_TO_COLOR((fade * c[0]), (fade * c[1]), (fade * c[2]), c[3]));
}

variable_types:
c
unsigned char [4]

variable_types: fade float


original_code:
qbool UI_PrintTextBlock(int x, int y, int w, int h, const char* text, qbool red)
{
 int letters_per_line = w / 8;
 int lines = h / 8;
 int linelen = 0;
 int linecount = 0;
 char buf[1024];
 const char *start = text, *end, *wordend;
 while (*start && linecount < lines)
 {
  wordend = start;
  end = wordend;
  linelen = 0;
  while (linelen < letters_per_line && *wordend)
  {
   end = wordend;
   do
   {
    wordend++;
    linelen++;
   }
   while (*wordend && *wordend != ' ' && *wordend != '\n');
   if(linelen >= letters_per_line)
   {
    do
    {
     wordend--;
     linelen--;
    }
    while(*wordend && *wordend != ' ' && linelen > 0);
    end = (linelen == 0) ? (end + letters_per_line - 1) : wordend;
    break;
   }
   if (*wordend == '\n')
   {
    end = wordend;
    break;
   }
  }
  if (!*wordend && linelen < letters_per_line)
  {
   end = wordend;
  }
  while (*end && *end == ' ')
  {
   end++;
  }
  if(*start && *start == '\n')
  {
   start++;
  }
  strlcpy(buf, start, end - start + 1);
  UI_Print(x, y + (linecount * 8), buf, red);
  linecount++;
  start = end;
 }
 return !(*start);
}

canonical_original_code:
enum qbool UI_PrintTextBlock(int x, int y, int w, int h, char *text, enum qbool red)
{
 int letters_per_line = w / 8;
 int lines = h / 8;
 int linelen = 0;
 int linecount = 0;
 char buf[1024];
 char *start = text; char *end; char *wordend;
 while (*start && linecount < lines)
 {
  wordend = start;
  end = wordend;
  linelen = 0;
  while (linelen < letters_per_line && *wordend)
  {
   end = wordend;
   do
   {
    wordend++;
    linelen++;
   }
   while (*wordend && *wordend != ' ' && *wordend != '\n');
   if(linelen >= letters_per_line)
   {
    do
    {
     wordend--;
     linelen--;
    }
    while(*wordend && *wordend != ' ' && linelen > 0);
    end = (linelen == 0) ? (end + letters_per_line - 1) : wordend;
    break;
   }
   if (*wordend == '\n')
   {
    end = wordend;
    break;
   }
  }
  if (!*wordend && linelen < letters_per_line)
  {
   end = wordend;
  }
  while (*end && *end == ' ')
  {
   end++;
  }
  if(*start && *start == '\n')
  {
   start++;
  }
  strlcpy(buf, start, end - start + 1);
  UI_Print(x, y + (linecount * 8), buf, red);
  linecount++;
  start = end;
 }
 return !(*start);
}

variable_types:
text
char *

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

variable_types: lines int

variable_types: linelen int

variable_types: linecount int

variable_types:
buf
char [1024]

variable_types:
start
char *

variable_types:
end
char *

variable_types:
wordend
char *

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


decompiled_code:
__int64 UI_DrawCharacter()
{
return Draw_Character();
}

canonical_decompiled_code:
__int64 func0()
{
return Draw_Character();
}

original_code:
void UI_DrawCharacter (int cx, int line, int num)
{
 Draw_Character ( cx, line, num);
}

canonical_original_code:
void UI_DrawCharacter(int cx, int line, int num)
{
 Draw_Character ( cx, line, num);
}

variable_types: cx int

variable_types: line int

variable_types: num int


decompiled_code:
__int64 __fastcall UI_Print(__int64 a1, __int64 a2, unsigned __int8 *a3, int a4)
{
unsigned int v4; // ebp
unsigned __int8 *v5; // rbx
unsigned __int8 v6; // dl
__int64 result; // rax

v4 = a1;
v5 = a3;
if ( !a4 )
return Draw_ColoredString(a1, a2, a3, 0LL);
v6 = *a3;
if ( v6 )
{
do
{
result = UI_DrawCharacter(v4, (unsigned int)a2, v6 | 0x80u);
++v5;
v4 += 8;
v6 = *v5;
}
while ( *v5 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, unsigned __int8 *a3, int a4)
{
unsigned int v4; // ebp
unsigned __int8 *v5; // rbx
unsigned __int8 v6; // dl
__int64 result; // rax

v4 = a1;
v5 = a3;
if ( !a4 )
return Draw_ColoredString(a1, a2, a3, 0LL);
v6 = *a3;
if ( v6 )
{
do
{
result = func0(v4, (unsigned int)a2, v6 | 0x80u);
++v5;
v4 += 8;
v6 = *v5;
}
while ( *v5 );
}
return result;
}

original_code:
void UI_Print (int cx, int cy, const char *str, int red)
{
 if (red)
 {
  while (*str)
  {
   UI_DrawCharacter (cx, cy, (*str) | (red ? 128 : 0));
   str++;
   cx += 8;
  }
 }
 else
 {
  Draw_ColoredString (cx, cy, str, red);
 }
}

canonical_original_code:
void UI_Print(int cx, int cy, char *str, int red)
{
 if (red)
 {
  while (*str)
  {
   UI_DrawCharacter (cx, cy, (*str) | (red ? 128 : 0));
   str++;
   cx += 8;
  }
 }
 else
 {
  Draw_ColoredString (cx, cy, str, red);
 }
}

variable_types: cy int

variable_types:
str
char *

variable_types: red int


decompiled_code:
__int64 __fastcall UI_DrawSlider(int a1, unsigned int a2, __m128i a3)
{
float v3; // er14
unsigned int v4; // ebx

v3 = COERCE_FLOAT(_mm_cvtsi128_si32(a3));
if ( v3 < 0.0 )
{
v3 = *(float *)&LC1;
}
else if ( v3 > 1.0 )
{
v3 = *(float *)&LC0;
}
UI_DrawCharacter((unsigned int)(a1 - 8), a2, 128LL);
v4 = a1;
do
{
UI_DrawCharacter(v4, a2, 129LL);
v4 += 8;
}
while ( v4 != a1 + 96 );
UI_DrawCharacter((unsigned int)(a1 + 96), a2, 130LL);
UI_DrawCharacter((unsigned int)(int)(float)((float)(v3 * 88.0) + (float)a1), a2, 131LL);
return (unsigned int)(a1 + 104);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, unsigned int a2, __m128i a3)
{
float v3; // er14
unsigned int v4; // ebx

v3 = COERCE_FLOAT(_mm_cvtsi128_si32(a3));
if ( v3 < 0.0 )
{
v3 = *(float *)&LC1;
}
else if ( v3 > 1.0 )
{
v3 = *(float *)&LC0;
}
func0((unsigned int)(a1 - 8), a2, 128LL);
v4 = a1;
do
{
func0(v4, a2, 129LL);
v4 += 8;
}
while ( v4 != a1 + 96 );
func0((unsigned int)(a1 + 96), a2, 130LL);
func0((unsigned int)(int)(float)((float)(v3 * 88.0) + (float)a1), a2, 131LL);
return (unsigned int)(a1 + 104);
}

original_code:
int UI_DrawSlider (int x, int y, float range) {
 int i;
 range = ((0) >= (1) ? (0) : (range) < (0) ? (0) : (range) > (1) ? (1) : (range));
 UI_DrawCharacter (x-8, y, 128);
 for (i=0 ; i<12 ; i++)
  UI_DrawCharacter (x + i*8, y, 129);
 UI_DrawCharacter (x+i*8, y, 130);
 UI_DrawCharacter (x + (12 -1)*8 * range, y, 131);
 return x+(i+1)*8;
}

canonical_original_code:
int UI_DrawSlider(int x, int y, float range) {
 int i;
 range = ((0) >= (1) ? (0) : (range) < (0) ? (0) : (range) > (1) ? (1) : (range));
 UI_DrawCharacter (x-8, y, 128);
 for (i=0 ; i<12 ; i++)
  UI_DrawCharacter (x + i*8, y, 129);
 UI_DrawCharacter (x+i*8, y, 130);
 UI_DrawCharacter (x + (12 -1)*8 * range, y, 131);
 return x+(i+1)*8;
}

variable_types: x int

variable_types: y int

variable_types: range float

variable_types: i int


decompiled_code:
__int64 UI_SliderWidth()
{
return 104LL;
}

canonical_decompiled_code:
__int64 func3()
{
return 104LL;
}

original_code: int UI_SliderWidth(void) { return (12 +1)*8; }

canonical_original_code: int UI_SliderWidth() { return (12 +1)*8; }


decompiled_code:
__int64 __fastcall UI_Print_Center(int a1, unsigned int a2, int a3, char *a4, int a5)
{
int v8; // eax

v8 = strlen(a4);
return UI_Print((unsigned int)(a1 + (a3 - 8 * v8) / 2), a2, (unsigned __int8 *)a4, a5);
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1, unsigned int a2, int a3, char *a4, int a5)
{
int v8; // eax

v8 = strlen(a4);
return func1((unsigned int)(a1 + (a3 - 8 * v8) / 2), a2, (unsigned __int8 *)a4, a5);
}

original_code:
void UI_Print_Center (int cx, int cy, int w, const char *str, int red)
{
 int text_length = strlen(str);
 UI_Print(cx + (w - 8 * text_length) / 2, cy, str, red);
}

canonical_original_code:
void UI_Print_Center(int cx, int cy, int w, char *str, int red)
{
 int text_length = strlen(str);
 UI_Print(cx + (w - 8 * text_length) / 2, cy, str, red);
}

variable_types: w int


decompiled_code:
__int64 __fastcall UI_DrawBox(__int64 a1, __int64 a2, int a3, int a4)
{
int v6; // ecx

v6 = a4 + 7;
if ( a4 >= 0 )
v6 = a4;
return Draw_TextBox(a1, a2, (unsigned int)(a3 / 8 - 1), (unsigned int)((v6 >> 3) - 1));
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2, int a3, int a4)
{
int v6; // ecx

v6 = a4 + 7;
if ( a4 >= 0 )
v6 = a4;
return Draw_TextBox(a1, a2, (unsigned int)(a3 / 8 - 1), (unsigned int)((v6 >> 3) - 1));
}

original_code:
void UI_DrawBox(int x, int y, int w, int h)
{
 Draw_TextBox(x, y, w / 8 - 1, h / 8 - 1);
}

variable_types: h int


decompiled_code:
void __noreturn Host_Error(char *format, ...)
{
char v1[1032]; // [rsp+0h] [rbp-4D8h] BYREF
gcc_va_list arg; // [rsp+408h] [rbp-D0h] BYREF

if ( inerror_2 )
Sys_Error("Host_Error: recursively entered");
inerror_2 = 1;
va_start(arg, format);
vsnprintf(v1, 0x400uLL, format, arg);
Com_Printf("\n===========================\n");
Com_Printf("Host_Error: %s\n", v1);
Com_Printf("===========================\n\n");
CL_Disconnect();
if ( !host_initialized )
Sys_Error("Host_Error: %s", v1);
inerror_2 = 0;
Host_Abort();
}

canonical_decompiled_code:
void __noreturn func5(char *format, ...)
{
char v1[1032]; // [rsp+0h] [rbp-4D8h] BYREF
gcc_va_list arg; // [rsp+408h] [rbp-D0h] BYREF

if ( inerror_2 )
Sys_Error("Host_Error: recursively entered");
inerror_2 = 1;
va_start(arg, format);
vsnprintf(v1, 0x400uLL, format, arg);
Com_Printf("\n===========================\n");
Com_Printf("Host_Error: %s\n", v1);
Com_Printf("===========================\n\n");
CL_Disconnect();
if ( !host_initialized )
Sys_Error("Host_Error: %s", v1);
inerror_2 = 0;
func3();
}

original_code:
void Host_Error (char *error, ...)
{
 va_list argptr;
 char string[1024];
 static qbool inerror = false;
 if (inerror)
  Sys_Error ("Host_Error: recursively entered");
 inerror = true;
 __builtin_va_start(argptr,error);
 vsnprintf (string, sizeof(string), error, argptr);
 __builtin_va_end(argptr);
 Com_Printf ("\n===========================\n");
 Com_Printf ("Host_Error: %s\n",string);
 Com_Printf ("===========================\n\n");
 CL_Disconnect ();
 if (!host_initialized)
  Sys_Error ("Host_Error: %s", string);
 inerror = false;
 Host_Abort ();
}

canonical_original_code:
void Host_Error(char *error, ...)
{
 __builtin_va_list argptr;
 char string[1024];
 static enum qbool inerror = false;
 if (inerror)
  Sys_Error ("Host_Error: recursively entered");
 inerror = true;
 __builtin_va_start(argptr,error);
 vsnprintf (string, sizeof(string), error, argptr);
 __builtin_va_end(argptr);
 Com_Printf ("\n===========================\n");
 Com_Printf ("Host_Error: %s\n",string);
 Com_Printf ("===========================\n\n");
 CL_Disconnect ();
 if (!host_initialized)
  Sys_Error ("Host_Error: %s", string);
 inerror = false;
 Host_Abort ();
}

variable_types:
error
char *

variable_types:
string
char [1024]

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


decompiled_code:
char Startup_Place()
{
const char *v0; // rsi
bool v1; // zf
char result; // al
__int64 v3; // rax
__int64 v4; // rax

v0 = (const char *)cl_startupdemo[1];
if ( *v0 )
{
v4 = va("playdemo %s\n", v0);
result = Cbuf_AddText(v4);
key_dest = 6;
}
else if ( !strcmp(*((const char **)&cl_onload + 1), "menu") )
{
result = Cbuf_AddText("togglemenu\n");
}
else if ( !strcmp(*((const char **)&cl_onload + 1), "browser") )
{
result = Cbuf_AddText("menu_slist\n");
}
else
{
v1 = strcmp(*((const char **)&cl_onload + 1), "console") == 0;
result = !v1;
if ( !v1 )
{
v3 = va("%s\n", *((const char **)&cl_onload + 1));
result = Cbuf_AddText(v3);
}
}
return result;
}

canonical_decompiled_code:
char func10()
{
const char *v0; // rsi
bool v1; // zf
char result; // al
__int64 v3; // rax
__int64 v4; // rax

v0 = (const char *)cl_startupdemo[1];
if ( *v0 )
{
v4 = va("playdemo %s\n", v0);
result = Cbuf_AddText(v4);
key_dest = 6;
}
else if ( !strcmp(*((const char **)&cl_onload + 1), "menu") )
{
result = Cbuf_AddText("togglemenu\n");
}
else if ( !strcmp(*((const char **)&cl_onload + 1), "browser") )
{
result = Cbuf_AddText("menu_slist\n");
}
else
{
v1 = strcmp(*((const char **)&cl_onload + 1), "console") == 0;
result = !v1;
if ( !v1 )
{
v3 = va("%s\n", *((const char **)&cl_onload + 1));
result = Cbuf_AddText(v3);
}
}
return result;
}

original_code:
void Startup_Place(void)
{
    extern cvar_t cl_onload;
 extern cvar_t cl_startupdemo;
 if (cl_startupdemo.string[0]) {
  Cbuf_AddText(va("playdemo %s\n", cl_startupdemo.string));
  key_dest = key_startupdemo;
 }
 else
 {
  if (!strcmp(cl_onload.string, "menu"))
   Cbuf_AddText("togglemenu\n");
  else if (!strcmp(cl_onload.string, "browser"))
   Cbuf_AddText("menu_slist\n");
  else if (!strcmp(cl_onload.string, "console"))
   ;
  else Cbuf_AddText(va("%s\n", cl_onload.string));
 }
}

canonical_original_code:
void Startup_Place()
{
    extern struct cvar_s cl_onload;
 extern struct cvar_s cl_startupdemo;
 if (cl_startupdemo.string[0]) {
  Cbuf_AddText(va("playdemo %s\n", cl_startupdemo.string));
  key_dest = key_startupdemo;
 }
 else
 {
  if (!strcmp(cl_onload.string, "menu"))
   Cbuf_AddText("togglemenu\n");
  else if (!strcmp(cl_onload.string, "browser"))
   Cbuf_AddText("menu_slist\n");
  else if (!strcmp(cl_onload.string, "console"))
   ;
  else Cbuf_AddText(va("%s\n", cl_onload.string));
 }
}

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:
int Host_Shutdown()
{
if ( isdown_0 )
return puts("recursive shutdown");
isdown_0 = 1;
S_StopAllSounds(1LL);
S_Update(&vec3_origin, &vec3_origin, &vec3_origin);
CL_Shutdown();
NET_Shutdown();
Con_Shutdown();
return TCL_Shutdown();
}

canonical_decompiled_code:
int func12()
{
if ( isdown_0 )
return puts("recursive shutdown");
isdown_0 = 1;
S_StopAllSounds(1LL);
S_Update(&vec3_origin, &vec3_origin, &vec3_origin);
CL_Shutdown();
NET_Shutdown();
Con_Shutdown();
return TCL_Shutdown();
}

original_code:
void Host_Shutdown (void)
{
 static qbool isdown = false;
 if (isdown) {
  printf ("recursive shutdown\n");
  return;
 }
 isdown = true;
 S_StopAllSounds (true);
 S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
 CL_Shutdown ();
 NET_Shutdown ();
 Con_Shutdown();
 TCL_Shutdown ();
}

canonical_original_code:
void Host_Shutdown()
{
 static enum qbool isdown = false;
 if (isdown) {
  printf ("recursive shutdown\n");
  return;
 }
 isdown = true;
 S_StopAllSounds (true);
 S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
 CL_Shutdown ();
 NET_Shutdown ();
 Con_Shutdown();
 TCL_Shutdown ();
}

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


decompiled_code:
char *__fastcall XSD_DetectType_OnStartElement(char *a1, const char *a2)
{
char *result; // rax

if ( !*a1 )
result = strcpy(a1, a2);
return result;
}

canonical_decompiled_code:
char *__fastcall func0(char *a1, const char *a2)
{
char *result; // rax

if ( !*a1 )
result = strcpy(a1, a2);
return result;
}

original_code:
static void XSD_DetectType_OnStartElement(void *userData, const XML_Char *name, const XML_Char **atts)
{
    char *type = (char *) userData;
    if (type[0] == 0)
        strcpy(type, name);
}

canonical_original_code:
static void XSD_DetectType_OnStartElement(void *userData, char *name, char **atts)
{
    char *type = (char *) userData;
    if (type[0] == 0)
        strcpy(type, name);
}

variable_types:
userData
void *

variable_types:
name
char *

variable_types:
atts
char **

variable_types:
type
char *


decompiled_code:
char *__fastcall XSD_AddText(void *ptr, void *src, int a3)
{
size_t v4; // r13
char *v5; // rbp
size_t v6; // rax

if ( ptr )
{
v4 = strlen((const char *)ptr) + a3 + 1;
v5 = (char *)Q_malloc(v4);
strlcpy(v5, ptr, v4);
v6 = strlen(v5);
memcpy(&v5[v6], src, a3);
v5[a3 + strlen((const char *)ptr)] = 0;
free(ptr);
}
else
{
v5 = (char *)Q_malloc(a3 + 1);
memcpy(v5, src, a3);
v5[a3] = 0;
}
return v5;
}

canonical_decompiled_code:
char *__fastcall func2(void *ptr, void *src, int a3)
{
size_t v4; // r13
char *v5; // rbp
size_t v6; // rax

if ( ptr )
{
v4 = strlen((const char *)ptr) + a3 + 1;
v5 = (char *)Q_malloc(v4);
strlcpy(v5, ptr, v4);
v6 = strlen(v5);
memcpy(&v5[v6], src, a3);
v5[a3 + strlen((const char *)ptr)] = 0;
free(ptr);
}
else
{
v5 = (char *)Q_malloc(a3 + 1);
memcpy(v5, src, a3);
v5[a3] = 0;
}
return v5;
}

original_code:
char *XSD_AddText(char *dst, const char *src, int src_len)
{
    char *buf;
 size_t len;
    if (dst == ((void *)0))
    {
        buf = (char *) Q_malloc(src_len + 1);
        memcpy(buf, src, src_len);
        buf[src_len] = 0;
    }
    else
    {
  len = 1 + src_len + strlen(dst);
        buf = (char *) Q_malloc(len);
        strlcpy (buf, dst, len);
        memcpy(buf+strlen(buf), src, src_len);
        buf[src_len+strlen(dst)] = 0;
        if(dst) { free(dst); dst = ((void *)0); };
    }
    return buf;
}

canonical_original_code:
char *XSD_AddText(char *dst, char *src, int src_len)
{
    char *buf;
 unsigned long len;
    if (dst == ((void *)0))
    {
        buf = (char *) Q_malloc(src_len + 1);
        memcpy(buf, src, src_len);
        buf[src_len] = 0;
    }
    else
    {
  len = 1 + src_len + strlen(dst);
        buf = (char *) Q_malloc(len);
        strlcpy (buf, dst, len);
        memcpy(buf+strlen(buf), src, src_len);
        buf[src_len+strlen(dst)] = 0;
        if(dst) { free(dst); dst = ((void *)0); };
    }
    return buf;
}

variable_types:
dst
char *

variable_types:
src
char *

variable_types:
buf
char *

variable_types:
len
unsigned long

return_type: char *


decompiled_code:
__int64 __fastcall XSD_IsIn(char *s1, char *s2)
{
size_t v2; // rbx
size_t v3; // rdx
__int64 result; // rax
int v5; // edx

v2 = strlen(s2);
v3 = strlen(s1);
result = 0LL;
if ( v3 >= v2 )
{
v5 = strncmp(s1, s2, v2);
result = 0LL;
if ( !v5 )
result = (s1[v2] == 47) | (unsigned __int8)(s1[v2] == 0);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *s1, char *s2)
{
size_t v2; // rbx
size_t v3; // rdx
__int64 result; // rax
int v5; // edx

v2 = strlen(s2);
v3 = strlen(s1);
result = 0LL;
if ( v3 >= v2 )
{
v5 = strncmp(s1, s2, v2);
result = 0LL;
if ( !v5 )
result = (s1[v2] == 47) | (unsigned __int8)(s1[v2] == 0);
}
return result;
}

original_code:
int XSD_IsIn(char *path, char *subPath)
{
    size_t sublen = strlen(subPath);
    if (strlen(path) < sublen)
        return 0;
    if (!strncmp(path, subPath, sublen) &&
        (path[sublen] == 0 || path[sublen] == '/'))
    {
        return 1;
    }
    return 0;
}

canonical_original_code:
int XSD_IsIn(char *path, char *subPath)
{
    unsigned long sublen = strlen(subPath);
    if (strlen(path) < sublen)
        return 0;
    if (!strncmp(path, subPath, sublen) &&
        (path[sublen] == 0 || path[sublen] == '/'))
    {
        return 1;
    }
    return 0;
}

variable_types:
path
char *

variable_types:
subPath
char *

variable_types:
sublen
unsigned long


decompiled_code:
void __fastcall XSD_FreeDocument(const char **a1)
{
const char *v2; // rdi
const char *v3; // rbp
__int64 v4; // rbx

v2 = xsd_mappings;
if ( xsd_mappings )
{
v3 = *a1;
v4 = 0LL;
while ( strcmp(v2, v3) )
{
++v4;
v2 = (&xsd_mappings)[4 * v4];
if ( !v2 )
return;
}
((void (__fastcall *)(const char **, const char *))(&xsd_mappings)[4 * (int)v4 + 2])(a1, v3);
}
}

canonical_decompiled_code:
void __fastcall func11(const char **a1)
{
const char *v2; // rdi
const char *v3; // rbp
__int64 v4; // rbx

v2 = xsd_mappings;
if ( xsd_mappings )
{
v3 = *a1;
v4 = 0LL;
while ( strcmp(v2, v3) )
{
++v4;
v2 = (&xsd_mappings)[4 * v4];
if ( !v2 )
return;
}
((void (__fastcall *)(const char **, const char *))(&xsd_mappings)[4 * (int)v4 + 2])(a1, v3);
}
}

original_code:
void XSD_FreeDocument(xml_t *document)
{
    int i = 0;
    while (xsd_mappings[i].document_type != ((void *)0))
    {
        if (!strcmp(xsd_mappings[i].document_type, document->document_type))
        {
            xsd_mappings[i].free_function(document);
            return;
        }
        i++;
    }
}

canonical_original_code:
void XSD_FreeDocument(struct xml_s *document)
{
    int i = 0;
    while (xsd_mappings[i].document_type != ((void *)0))
    {
        if (!strcmp(xsd_mappings[i].document_type, document->document_type))
        {
            xsd_mappings[i].free_function(document);
            return;
        }
        i++;
    }
}

variable_types:
document
struct xml_s { char *document_type; } *

variable_types: i int


decompiled_code:
const char *__fastcall XSD_XslConvert(const char **a1)
{
const char *v2; // rdi
const char *v3; // rbp
__int64 v4; // rbx
char *v6; // rax

v2 = xsd_mappings;
if ( xsd_mappings )
{
v3 = *a1;
v4 = 0LL;
while ( strcmp(v2, v3) )
{
++v4;
v2 = (&xsd_mappings)[4 * v4];
if ( !v2 )
return v2;
}
v6 = (&xsd_mappings)[4 * (int)v4 + 3];
if ( v6 )
v2 = (const char *)((__int64 (__fastcall *)(const char **))v6)(a1);
else
v2 = 0LL;
}
return v2;
}

canonical_decompiled_code:
const char *__fastcall func12(const char **a1)
{
const char *v2; // rdi
const char *v3; // rbp
__int64 v4; // rbx
char *v6; // rax

v2 = xsd_mappings;
if ( xsd_mappings )
{
v3 = *a1;
v4 = 0LL;
while ( strcmp(v2, v3) )
{
++v4;
v2 = (&xsd_mappings)[4 * v4];
if ( !v2 )
return v2;
}
v6 = (&xsd_mappings)[4 * (int)v4 + 3];
if ( v6 )
v2 = (const char *)((__int64 (__fastcall *)(const char **))v6)(a1);
else
v2 = 0LL;
}
return v2;
}

original_code:
xml_document_t * XSD_XslConvert(xml_t *doc)
{
    int i = 0;
    while (xsd_mappings[i].document_type != ((void *)0))
    {
        if (!strcmp(xsd_mappings[i].document_type, doc->document_type))
        {
            if (xsd_mappings[i].convert_function)
                return (xml_document_t *)xsd_mappings[i].convert_function(doc);
            else
                return ((void *)0);
        }
        i++;
    }
    return ((void *)0);
}

canonical_original_code:
struct xml_document_s *XSD_XslConvert(struct xml_s *doc)
{
    int i = 0;
    while (xsd_mappings[i].document_type != ((void *)0))
    {
        if (!strcmp(xsd_mappings[i].document_type, doc->document_type))
        {
            if (xsd_mappings[i].convert_function)
                return (struct xml_document_s *)xsd_mappings[i].convert_function(doc);
            else
                return ((void *)0);
        }
        i++;
    }
    return ((void *)0);
}

variable_types:
doc
struct xml_s { char *document_type; } *

return_type: struct xml_document_s { char *document_type; char *title; char *date; struct xml_document_author_s { enum document_tag_type_t { tag_text=0, tag_section=1, tag_p=2, tag_list=3, tag_dict=4, tag_hr=5, tag_h=6, tag_pre=7, tag_em=8, tag_a=9, tag_img=10, tag_color=11, tag_br=12, tag_sp=13, tag_li=14, tag_di=15 } type; struct xml_document_author_s *next; char *name; char *email; char *im; } *authors; struct document_tag_s { enum document_tag_type_t { tag_text=0, tag_section=1, tag_p=2, tag_list=3, tag_dict=4, tag_hr=5, tag_h=6, tag_pre=7, tag_em=8, tag_a=9, tag_img=10, tag_color=11, tag_br=12, tag_sp=13, tag_li=14, tag_di=15 } type; struct document_tag_s *next; } *content; } *

user_defined_types: struct xml_document_s { char *document_type; char *title; char *date; struct xml_document_author_s *authors; struct document_tag_s *content; }

user_defined_types: struct xml_document_author_s { enum document_tag_type_t type; struct xml_document_author_s *next; char *name; char *email; char *im; }

user_defined_types: struct document_tag_s { enum document_tag_type_t type; struct document_tag_s *next; }


decompiled_code:
const char **__fastcall XSD_LoadDocumentWithXsl(__int64 a1)
{
const char **v1; // rax
const char **v2; // rbx
const char *v4; // rbp

v1 = (const char **)XSD_LoadDocument(a1);
v2 = v1;
if ( v1 && strcmp(*v1, "document") )
{
v4 = XSD_XslConvert(v1);
XSD_FreeDocument(v2);
v2 = (const char **)v4;
}
return v2;
}

canonical_decompiled_code:
const char **__fastcall func13(__int64 a1)
{
const char **v1; // rax
const char **v2; // rbx
const char *v4; // rbp

v1 = (const char **)func10(a1);
v2 = v1;
if ( v1 && strcmp(*v1, "document") )
{
v4 = func12(v1);
func11(v2);
v2 = (const char **)v4;
}
return v2;
}

original_code:
xml_document_t * XSD_LoadDocumentWithXsl(char *filename)
{
    xml_t *doc;
    xml_document_t *document;
    doc = XSD_LoadDocument(filename);
    if (doc == ((void *)0))
        return ((void *)0);
    if (!strcmp(doc->document_type, "document"))
        return (xml_document_t *) doc;
    document = XSD_XslConvert(doc);
    XSD_FreeDocument(doc);
    return document;
}

canonical_original_code:
struct xml_document_s *XSD_LoadDocumentWithXsl(char *filename)
{
    struct xml_s *doc;
    struct xml_document_s *document;
    doc = XSD_LoadDocument(filename);
    if (doc == ((void *)0))
        return ((void *)0);
    if (!strcmp(doc->document_type, "document"))
        return (struct xml_document_s *) doc;
    document = XSD_XslConvert(doc);
    XSD_FreeDocument(doc);
    return document;
}

variable_types:
filename
char *

variable_types: struct xml_document_s { char *document_type; char *title; char *date; struct xml_document_author_s { enum document_tag_type_t { tag_text=0, tag_section=1, tag_p=2, tag_list=3, tag_dict=4, tag_hr=5, tag_h=6, tag_pre=7, tag_em=8, tag_a=9, tag_img=10, tag_color=11, tag_br=12, tag_sp=13, tag_li=14, tag_di=15 } type; struct xml_document_author_s *next; char *name; char *email; char *im; } *authors; struct document_tag_s { enum document_tag_type_t { tag_text=0, tag_section=1, tag_p=2, tag_list=3, tag_dict=4, tag_hr=5, tag_h=6, tag_pre=7, tag_em=8, tag_a=9, tag_img=10, tag_color=11, tag_br=12, tag_sp=13, tag_li=14, tag_di=15 } type; struct document_tag_s *next; } *content; } *


decompiled_code:
const char *__fastcall XSD_GetAttribute(const char **a1, const char *a2)
{
const char **v2; // rbx
const char *v3; // rdi

v2 = a1;
v3 = *a1;
if ( v3 )
{
while ( strcmp(v3, a2) )
{
v2 += 2;
v3 = *v2;
if ( !*v2 )
return v3;
}
v3 = v2[1];
}
return v3;
}

canonical_decompiled_code:
const char *__fastcall func1(const char **a1, const char *a2)
{
const char **v2; // rbx
const char *v3; // rdi

v2 = a1;
v3 = *a1;
if ( v3 )
{
while ( strcmp(v3, a2) )
{
v2 += 2;
v3 = *v2;
if ( !*v2 )
return v3;
}
v3 = v2[1];
}
return v3;
}

original_code:
const char *XSD_GetAttribute(const char **atts, const char *name)
{
    while (*atts)
    {
        if (!strcmp(*atts, name))
            return *(atts+1);
        atts += 2;
    }
    return ((void *)0);
}

canonical_original_code:
char *XSD_GetAttribute(char **atts, char *name)
{
    while (*atts)
    {
        if (!strcmp(*atts, name))
            return *(atts+1);
        atts += 2;
    }
    return ((void *)0);
}


decompiled_code:
__int64 __fastcall XSD_IsSpace(unsigned __int8 a1)
{
char v1; // al

v1 = 1;
if ( a1 <= 0x20u )
v1 = ((0x100002600uLL >> a1) ^ 1) & 1;
return (unsigned __int8)v1 ^ 1u;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned __int8 a1)
{
char v1; // al

v1 = 1;
if ( a1 <= 0x20u )
v1 = ((0x100002600uLL >> a1) ^ 1) & 1;
return (unsigned __int8)v1 ^ 1u;
}

original_code:
int XSD_IsSpace(char c)
{
    if (c == ' ' || c == '\t' || c == '\n' || c == '\r')
        return 1;
    return 0;
}

variable_types: c char


decompiled_code:
void *__fastcall XSD_StripSpaces(void *ptr)
{
void *v1; // rbx
size_t v2; // rax
_BYTE *v3; // r14
int v4; // ebx
unsigned int i; // er12
unsigned __int8 v6; // r13

v1 = ptr;
if ( ptr )
{
v2 = strlen((const char *)ptr);
v3 = (_BYTE *)Q_malloc(v2 + 1);
v4 = 0;
for ( i = 0; i < strlen((const char *)ptr); ++i )
{
v6 = *((_BYTE *)ptr + i);
if ( (unsigned int)XSD_IsSpace(v6) )
{
if ( v4 )
{
if ( !(unsigned int)XSD_IsSpace(v3[v4 - 1]) )
v3[v4++] = 32;
}
}
else
{
v3[v4++] = v6;
}
}
while ( v4 && (unsigned int)XSD_IsSpace(v3[v4 - 1]) )
--v4;
v3[v4] = 0;
v1 = (void *)Q_strdup(v3);
if ( v3 )
free(v3);
free(ptr);
}
return v1;
}

canonical_decompiled_code:
void *__fastcall func4(void *ptr)
{
void *v1; // rbx
size_t v2; // rax
_BYTE *v3; // r14
int v4; // ebx
unsigned int i; // er12
unsigned __int8 v6; // r13

v1 = ptr;
if ( ptr )
{
v2 = strlen((const char *)ptr);
v3 = (_BYTE *)Q_malloc(v2 + 1);
v4 = 0;
for ( i = 0; i < strlen((const char *)ptr); ++i )
{
v6 = *((_BYTE *)ptr + i);
if ( (unsigned int)func3(v6) )
{
if ( v4 )
{
if ( !(unsigned int)func3(v3[v4 - 1]) )
v3[v4++] = 32;
}
}
else
{
v3[v4++] = v6;
}
}
while ( v4 && (unsigned int)func3(v3[v4 - 1]) )
--v4;
v3[v4] = 0;
v1 = (void *)Q_strdup(v3);
if ( v3 )
free(v3);
free(ptr);
}
return v1;
}

original_code:
char *XSD_StripSpaces (char *str)
{
    char *buf, *ret;
    unsigned int p = 0, q = 0;
    if (str == ((void *)0))
        return str;
    buf = (char *) Q_malloc(strlen(str)+1);
    for (p=0; p < strlen(str); p++)
    {
        if (XSD_IsSpace(str[p]))
        {
            if (q == 0 || XSD_IsSpace(buf[q-1]))
                ;
            else
                buf[q++] = ' ';
        }
        else
            buf[q++] = str[p];
    }
    while (q > 0 && XSD_IsSpace(buf[q-1]))
        q--;
    buf[q] = 0;
    ret = (char *) Q_strdup(buf);
    if(buf) { free(buf); buf = ((void *)0); };
    if(str) { free(str); str = ((void *)0); };
    return ret;
}

canonical_original_code:
char *XSD_StripSpaces(char *str)
{
    char *buf; char *ret;
    unsigned int p = 0; unsigned int q = 0;
    if (str == ((void *)0))
        return str;
    buf = (char *) Q_malloc(strlen(str)+1);
    for (p=0; p < strlen(str); p++)
    {
        if (XSD_IsSpace(str[p]))
        {
            if (q == 0 || XSD_IsSpace(buf[q-1]))
                ;
            else
                buf[q++] = ' ';
        }
        else
            buf[q++] = str[p];
    }
    while (q > 0 && XSD_IsSpace(buf[q-1]))
        q--;
    buf[q] = 0;
    ret = (char *) Q_strdup(buf);
    if(buf) { free(buf); buf = ((void *)0); };
    if(str) { free(str); str = ((void *)0); };
    return ret;
}

variable_types:
str
char *

variable_types:
ret
char *

variable_types:
p
unsigned int

variable_types:
q
unsigned int


decompiled_code:
__int64 SNDDMA_GetDMAPos_OSS_Legacy()
{
__int64 result; // rax
const char *v1; // rbx
__int64 v2; // rcx
char v3[8]; // [rsp+0h] [rbp-14h] BYREF
unsigned int v4; // [rsp+8h] [rbp-Ch]

result = 0LL;
if ( shm )
{
v1 = (const char *)Cvar_String("s_oss_device");
if ( ioctl(audio_fd, 0x800C5012uLL, v3) == -1 )
{
perror(v1);
Com_Printf("Uh, sound dead.\n");
close(audio_fd);
result = 0LL;
}
else
{
v2 = shm;
*(_DWORD *)(shm + 20LL) = v4 / *(_DWORD *)(shm + 4LL);
result = *(unsigned int *)(v2 + 20);
}
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax
const char *v1; // rbx
__int64 v2; // rcx
char v3[8]; // [rsp+0h] [rbp-14h] BYREF
unsigned int v4; // [rsp+8h] [rbp-Ch]

result = 0LL;
if ( shm )
{
v1 = (const char *)Cvar_String("s_oss_device");
if ( ioctl(audio_fd, 0x800C5012uLL, v3) == -1 )
{
perror(v1);
Com_Printf("Uh, sound dead.\n");
close(audio_fd);
result = 0LL;
}
else
{
v2 = shm;
*(_DWORD *)(shm + 20LL) = v4 / *(_DWORD *)(shm + 4LL);
result = *(unsigned int *)(v2 + 20);
}
}
return result;
}

original_code:
int SNDDMA_GetDMAPos_OSS_Legacy(void)
{
 struct count_info count;
 char *snd_dev = ((void *)0);
 if (!shm)
  return 0;
 snd_dev = Cvar_String("s_oss_device");
 if (ioctl(audio_fd, (((2U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((18)) << 0) | ((((sizeof(count_info)))) << ((0 +8)+8))), &count) == -1) {
  perror(snd_dev);
  Com_Printf("Uh, sound dead.\n");
  close(audio_fd);
  return 0;
 }
 shm->samplepos = count.ptr / shm->format.width;
 return shm->samplepos;
}

canonical_original_code:
int SNDDMA_GetDMAPos_OSS_Legacy()
{
 struct count_info count;
 char *snd_dev = ((void *)0);
 if (!shm)
  return 0;
 snd_dev = Cvar_String("s_oss_device");
 if (ioctl(audio_fd, (((2U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((18)) << 0) | ((((sizeof(count_info)))) << ((0 +8)+8))), &count) == -1) {
  perror(snd_dev);
  Com_Printf("Uh, sound dead.\n");
  close(audio_fd);
  return 0;
 }
 shm->samplepos = count.ptr / shm->format.width;
 return shm->samplepos;
}

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


decompiled_code:
int SNDDMA_Shutdown_OSS_Legacy()
{
int result; // eax
int v1; // ebx
int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

v2[0] = 0;
result = shm;
if ( *(_QWORD *)(shm + 24LL) )
result = munmap(*(void **)(shm + 24LL), *(int *)(shm + 32LL));
v1 = audio_fd;
if ( audio_fd )
{
ioctl(audio_fd, 0x40045010uLL, v2);
ioctl(v1, 0x5000uLL, 0LL);
result = close(v1);
}
audio_fd = -1;
return result;
}

canonical_decompiled_code:
int func1()
{
int result; // eax
int v1; // ebx
int v2[3]; // [rsp+Ch] [rbp-Ch] BYREF

v2[0] = 0;
result = shm;
if ( *(_QWORD *)(shm + 24LL) )
result = munmap(*(void **)(shm + 24LL), *(int *)(shm + 32LL));
v1 = audio_fd;
if ( audio_fd )
{
ioctl(audio_fd, 0x40045010uLL, v2);
ioctl(v1, 0x5000uLL, 0LL);
result = close(v1);
}
audio_fd = -1;
return result;
}

variable_types: tmp int


decompiled_code:
__int64 __fastcall SNDDMA_Init_OSS_Legacy(_QWORD *a1)
{
const char *v1; // rbp
int v2; // eax
int v3; // ebx
__int64 result; // rax
__int64 v5; // rdx
int v6; // ebx
int v7; // ecx
__int64 v8; // r13
__int64 v9; // [rsp+0h] [rbp-48h] BYREF
int v10; // [rsp+8h] [rbp-40h]
int v11; // [rsp+10h] [rbp-38h] BYREF
int v12; // [rsp+14h] [rbp-34h] BYREF
int v13; // [rsp+18h] [rbp-30h] BYREF
int v14[11]; // [rsp+1Ch] [rbp-2Ch] BYREF

v1 = (const char *)Cvar_String("s_oss_device");
v2 = open(v1, 2050);
audio_fd = v2;
if ( v2 < 0 )
{
perror(v1);
Com_Printf("Could not open %s\n", v1);
return 0LL;
}
v3 = v2;
v14[0] = ioctl(v2, 0x5000uLL, 0LL);
if ( v14[0] < 0 )
{
perror(v1);
Com_Printf("Could not reset %s\n", v1);
close(audio_fd);
return 0LL;
}
if ( ioctl(v3, 0x8004500FuLL, &v11) == -1 )
{
perror(v1);
Com_Printf("Sound driver too old\n");
close(audio_fd);
return 0LL;
}
if ( (v11 & 0x3000) != 12288 )
{
Com_Printf("Sorry but your soundcard can't do this\n");
close(audio_fd);
return 0LL;
}
*(_DWORD *)(shm + 4LL) = (int)(float)(0.125 * s_bits[8]);
*shm = SND_Rate((unsigned int)(int)s_khz[8]);
v5 = shm;
*(_DWORD *)(shm + 8LL) = 1 - (((int)s_stereo[8] == 0) - 1);
if ( *(_DWORD *)(v5 + 4) != 2 && *(_DWORD *)(v5 + 4) != 1 )
{
ioctl(audio_fd, 0x8004500BuLL, &v13);
if ( (v13 & 0x10) != 0 )
{
*(_DWORD *)(shm + 4LL) = 2;
}
else if ( (v13 & 8) != 0 )
{
*(_DWORD *)(shm + 4LL) = 1;
}
}
v12 = *(_DWORD *)(shm + 8LL) == 2;
v6 = audio_fd;
v14[0] = ioctl(audio_fd, 0xC0045003uLL, &v12);
if ( v14[0] < 0 )
{
perror(v1);
Com_Printf("Could not set %s to stereo", v1);
close(audio_fd);
return 0LL;
}
v14[0] = ioctl(v6, 0xC0045002uLL, shm);
if ( v14[0] < 0 )
{
perror(v1);
Com_Printf("Could not set %s speed to %d", v1, (unsigned int)*shm);
close(audio_fd);
return 0LL;
}
if ( *(_DWORD *)(shm + 4LL) == 2 )
{
v14[0] = 16;
v14[0] = ioctl(v6, 0xC0045005uLL, v14);
if ( v14[0] < 0 )
{
perror(v1);
Com_Printf("Could not support 16-bit data. Try 8-bit.\n");
close(audio_fd);
return 0LL;
}
}
else
{
if ( *(_DWORD *)(shm + 4LL) != 1 )
{
perror(v1);
Com_Printf("%d-bit sound not supported.", (unsigned int)(8 * *(_DWORD *)(shm + 4LL)));
close(audio_fd);
return 0LL;
}
v14[0] = 8;
v14[0] = ioctl(v6, 0xC0045005uLL, v14);
if ( v14[0] < 0 )
{
perror(v1);
Com_Printf("Could not support 8-bit data.\n");
close(audio_fd);
return 0LL;
}
}
if ( ioctl(v6, 0x8010500CuLL, &v9) == -1 )
{
perror("GETOSPACE");
Com_Printf("Um, can't do GETOSPACE?\n");
close(audio_fd);
result = 0LL;
}
else
{
v7 = v10 * HIDWORD(v9);
v8 = shm;
*(_DWORD *)(shm + 12LL) = (unsigned int)(v10 * HIDWORD(v9)) / *(_DWORD *)(shm + 4LL) / *(_DWORD *)(shm + 8LL);
*(_DWORD *)(v8 + 16) = *(_DWORD *)(v8 + 8) * *(_DWORD *)(v8 + 12);
*(_DWORD *)(v8 + 32) = v7;
*(_QWORD *)(v8 + 24) = mmap(0LL, *(int *)(v8 + 32), 2, 1, v6, 0LL);
if ( !*(_QWORD *)(shm + 24LL) || *(_QWORD *)(shm + 24LL) == -1LL )
{
perror(v1);
Com_Printf("Could not mmap %s\n", v1);
close(audio_fd);
result = 0LL;
}
else
{
v12 = 0;
v14[0] = ioctl(v6, 0x40045010uLL, &v12);
if ( v14[0] < 0 || (v12 = 2, v14[0] = ioctl(v6, 0x40045010uLL, &v12), v14[0] < 0) )
{
perror(v1);
Com_Printf("Could not toggle.\n");
close(audio_fd);
result = 0LL;
}
else
{
*(_DWORD *)(shm + 20LL) = 0;
a1[2] = SNDDMA_GetDMAPos_OSS_Legacy;
a1[1] = 0LL;
a1[3] = 0LL;
a1[4] = SNDDMA_Shutdown_OSS_Legacy;
*a1 = "snd_oss (legacy)";
result = 1LL;
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1)
{
const char *v1; // rbp
int v2; // eax
int v3; // ebx
__int64 result; // rax
__int64 v5; // rdx
int v6; // ebx
int v7; // ecx
__int64 v8; // r13
__int64 v9; // [rsp+0h] [rbp-48h] BYREF
int v10; // [rsp+8h] [rbp-40h]
int v11; // [rsp+10h] [rbp-38h] BYREF
int v12; // [rsp+14h] [rbp-34h] BYREF
int v13; // [rsp+18h] [rbp-30h] BYREF
int v14[11]; // [rsp+1Ch] [rbp-2Ch] BYREF

v1 = (const char *)Cvar_String("s_oss_device");
v2 = open(v1, 2050);
audio_fd = v2;
if ( v2 < 0 )
{
perror(v1);
Com_Printf("Could not open %s\n", v1);
return 0LL;
}
v3 = v2;
v14[0] = ioctl(v2, 0x5000uLL, 0LL);
if ( v14[0] < 0 )
{
perror(v1);
Com_Printf("Could not reset %s\n", v1);
close(audio_fd);
return 0LL;
}
if ( ioctl(v3, 0x8004500FuLL, &v11) == -1 )
{
perror(v1);
Com_Printf("Sound driver too old\n");
close(audio_fd);
return 0LL;
}
if ( (v11 & 0x3000) != 12288 )
{
Com_Printf("Sorry but your soundcard can't do this\n");
close(audio_fd);
return 0LL;
}
*(_DWORD *)(shm + 4LL) = (int)(float)(0.125 * s_bits[8]);
*shm = SND_Rate((unsigned int)(int)s_khz[8]);
v5 = shm;
*(_DWORD *)(shm + 8LL) = 1 - (((int)s_stereo[8] == 0) - 1);
if ( *(_DWORD *)(v5 + 4) != 2 && *(_DWORD *)(v5 + 4) != 1 )
{
ioctl(audio_fd, 0x8004500BuLL, &v13);
if ( (v13 & 0x10) != 0 )
{
*(_DWORD *)(shm + 4LL) = 2;
}
else if ( (v13 & 8) != 0 )
{
*(_DWORD *)(shm + 4LL) = 1;
}
}
v12 = *(_DWORD *)(shm + 8LL) == 2;
v6 = audio_fd;
v14[0] = ioctl(audio_fd, 0xC0045003uLL, &v12);
if ( v14[0] < 0 )
{
perror(v1);
Com_Printf("Could not set %s to stereo", v1);
close(audio_fd);
return 0LL;
}
v14[0] = ioctl(v6, 0xC0045002uLL, shm);
if ( v14[0] < 0 )
{
perror(v1);
Com_Printf("Could not set %s speed to %d", v1, (unsigned int)*shm);
close(audio_fd);
return 0LL;
}
if ( *(_DWORD *)(shm + 4LL) == 2 )
{
v14[0] = 16;
v14[0] = ioctl(v6, 0xC0045005uLL, v14);
if ( v14[0] < 0 )
{
perror(v1);
Com_Printf("Could not support 16-bit data. Try 8-bit.\n");
close(audio_fd);
return 0LL;
}
}
else
{
if ( *(_DWORD *)(shm + 4LL) != 1 )
{
perror(v1);
Com_Printf("%d-bit sound not supported.", (unsigned int)(8 * *(_DWORD *)(shm + 4LL)));
close(audio_fd);
return 0LL;
}
v14[0] = 8;
v14[0] = ioctl(v6, 0xC0045005uLL, v14);
if ( v14[0] < 0 )
{
perror(v1);
Com_Printf("Could not support 8-bit data.\n");
close(audio_fd);
return 0LL;
}
}
if ( ioctl(v6, 0x8010500CuLL, &v9) == -1 )
{
perror("GETOSPACE");
Com_Printf("Um, can't do GETOSPACE?\n");
close(audio_fd);
result = 0LL;
}
else
{
v7 = v10 * HIDWORD(v9);
v8 = shm;
*(_DWORD *)(shm + 12LL) = (unsigned int)(v10 * HIDWORD(v9)) / *(_DWORD *)(shm + 4LL) / *(_DWORD *)(shm + 8LL);
*(_DWORD *)(v8 + 16) = *(_DWORD *)(v8 + 8) * *(_DWORD *)(v8 + 12);
*(_DWORD *)(v8 + 32) = v7;
*(_QWORD *)(v8 + 24) = mmap(0LL, *(int *)(v8 + 32), 2, 1, v6, 0LL);
if ( !*(_QWORD *)(shm + 24LL) || *(_QWORD *)(shm + 24LL) == -1LL )
{
perror(v1);
Com_Printf("Could not mmap %s\n", v1);
close(audio_fd);
result = 0LL;
}
else
{
v12 = 0;
v14[0] = ioctl(v6, 0x40045010uLL, &v12);
if ( v14[0] < 0 || (v12 = 2, v14[0] = ioctl(v6, 0x40045010uLL, &v12), v14[0] < 0) )
{
perror(v1);
Com_Printf("Could not toggle.\n");
close(audio_fd);
result = 0LL;
}
else
{
*(_DWORD *)(shm + 20LL) = 0;
a1[2] = SNDDMA_GetDMAPos_OSS_Legacy;
a1[1] = 0LL;
a1[3] = 0LL;
a1[4] = SNDDMA_Shutdown_OSS_Legacy;
*a1 = "snd_oss (legacy)";
result = 1LL;
}
}
}
return result;
}

original_code:
qbool SNDDMA_Init_OSS_Legacy(qsoundhandler_t *sd)
{
 int rc, fmt, tmp, caps;
 char *snd_dev = ((void *)0);
 struct audio_buf_info info;
 snd_dev = Cvar_String("s_oss_device");
 if ((audio_fd = open(snd_dev, 02 | 04000)) < 0) {
  perror(snd_dev);
  Com_Printf("Could not open %s\n", snd_dev);
  return 0;
 }
 if ((rc = ioctl(audio_fd, (((0U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((0)) << 0) | ((0) << ((0 +8)+8))), 0)) < 0) {
  perror(snd_dev);
  Com_Printf("Could not reset %s\n", snd_dev);
  close(audio_fd);
  return 0;
 }
 if (ioctl(audio_fd, (((2U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((15)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &caps) == -1) {
  perror(snd_dev);
  Com_Printf("Sound driver too old\n");
  close(audio_fd);
  return 0;
 }
 if (!(caps & 0x00001000) || !(caps & 0x00002000)) {
  Com_Printf("Sorry but your soundcard can't do this\n");
  close(audio_fd);
  return 0;
 }
 shm->format.width = (int) (s_bits.value / 8);
 shm->format.speed = SND_Rate((int)s_khz.value);
 shm->format.channels = ((int) s_stereo.value == 0) ? 1 : 2;
 if (shm->format.width != 2 && shm->format.width != 1) {
  ioctl(audio_fd, (((2U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((11)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &fmt);
  if (fmt & 0x00000010)
   shm->format.width = 2;
  else if (fmt & 0x00000008)
   shm->format.width = 1;
 }
 tmp = (shm->format.channels == 2);
 if ((rc = ioctl(audio_fd, (((2U|1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((3)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &tmp)) < 0) {
  perror(snd_dev);
  Com_Printf ("Could not set %s to stereo", snd_dev);
  close(audio_fd);
  return 0;
 }
 if ((rc = ioctl(audio_fd, (((2U|1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((2)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &shm->format.speed)) < 0) {
  perror(snd_dev);
  Com_Printf("Could not set %s speed to %d", snd_dev, shm->format.speed);
  close(audio_fd);
  return 0;
 }
 if (shm->format.width == 2) {
  rc = 0x00000010;
  rc = ioctl(audio_fd, (((2U|1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((5)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &rc);
  if (rc < 0) {
   perror(snd_dev);
   Com_Printf("Could not support 16-bit data.  Try 8-bit.\n");
   close(audio_fd);
   return 0;
  }
 } else if (shm->format.width == 1) {
  rc = 0x00000008;
  rc = ioctl(audio_fd, (((2U|1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((5)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &rc);
  if (rc < 0) {
   perror(snd_dev);
   Com_Printf("Could not support 8-bit data.\n");
   close(audio_fd);
   return 0;
  }
 } else {
  perror(snd_dev);
  Com_Printf("%d-bit sound not supported.", shm->format.width * 8);
   close(audio_fd);
   return 0;
  }
 if (ioctl(audio_fd, (((2U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((12)) << 0) | ((((sizeof(audio_buf_info)))) << ((0 +8)+8))), &info) == -1) {
  perror("GETOSPACE");
  Com_Printf ("Um, can't do GETOSPACE?\n");
  close(audio_fd);
  return 0;
     }
 shm->sampleframes = info.fragstotal * info.fragsize / shm->format.width / shm->format.channels;
 shm->samples = shm->sampleframes * shm->format.channels;
 shm->bufferlength = info.fragstotal * info.fragsize;
 shm->buffer = (unsigned char *) mmap(((void *)0), shm->bufferlength, 0x2, 0|0x01, audio_fd, 0);
 if (!shm->buffer || shm->buffer == (unsigned char *)-1) {
  perror(snd_dev);
  Com_Printf ("Could not mmap %s\n", snd_dev);
  close(audio_fd);
  return 0;
 }
 tmp = 0;
 rc = ioctl(audio_fd, (((1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((16)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &tmp);
 if (rc < 0) {
  perror(snd_dev);
  Com_Printf("Could not toggle.\n");
  close(audio_fd);
  return 0;
 }
 tmp = 0x00000002;
 rc = ioctl(audio_fd, (((1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((16)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &tmp);
 if (rc < 0) {
  perror(snd_dev);
  Com_Printf("Could not toggle.\n");
  close(audio_fd);
  return 0;
 }
 shm->samplepos = 0;
 sd->GetDMAPos = SNDDMA_GetDMAPos_OSS_Legacy;
 sd->GetAvail = ((void *)0);
 sd->Submit = ((void *)0);
 sd->Shutdown = SNDDMA_Shutdown_OSS_Legacy;
 sd->name = "snd_oss (legacy)";
 return 1;
}

canonical_original_code:
enum qbool SNDDMA_Init_OSS_Legacy(struct qsoundhandler_s *sd)
{
 int rc; int fmt; int tmp; int caps;
 char *snd_dev = ((void *)0);
 struct audio_buf_info info;
 snd_dev = Cvar_String("s_oss_device");
 if ((audio_fd = open(snd_dev, 02 | 04000)) < 0) {
  perror(snd_dev);
  Com_Printf("Could not open %s\n", snd_dev);
  return 0;
 }
 if ((rc = ioctl(audio_fd, (((0U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((0)) << 0) | ((0) << ((0 +8)+8))), 0)) < 0) {
  perror(snd_dev);
  Com_Printf("Could not reset %s\n", snd_dev);
  close(audio_fd);
  return 0;
 }
 if (ioctl(audio_fd, (((2U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((15)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &caps) == -1) {
  perror(snd_dev);
  Com_Printf("Sound driver too old\n");
  close(audio_fd);
  return 0;
 }
 if (!(caps & 0x00001000) || !(caps & 0x00002000)) {
  Com_Printf("Sorry but your soundcard can't do this\n");
  close(audio_fd);
  return 0;
 }
 shm->format.width = (int) (s_bits.value / 8);
 shm->format.speed = SND_Rate((int)s_khz.value);
 shm->format.channels = ((int) s_stereo.value == 0) ? 1 : 2;
 if (shm->format.width != 2 && shm->format.width != 1) {
  ioctl(audio_fd, (((2U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((11)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &fmt);
  if (fmt & 0x00000010)
   shm->format.width = 2;
  else if (fmt & 0x00000008)
   shm->format.width = 1;
 }
 tmp = (shm->format.channels == 2);
 if ((rc = ioctl(audio_fd, (((2U|1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((3)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &tmp)) < 0) {
  perror(snd_dev);
  Com_Printf ("Could not set %s to stereo", snd_dev);
  close(audio_fd);
  return 0;
 }
 if ((rc = ioctl(audio_fd, (((2U|1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((2)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &shm->format.speed)) < 0) {
  perror(snd_dev);
  Com_Printf("Could not set %s speed to %d", snd_dev, shm->format.speed);
  close(audio_fd);
  return 0;
 }
 if (shm->format.width == 2) {
  rc = 0x00000010;
  rc = ioctl(audio_fd, (((2U|1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((5)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &rc);
  if (rc < 0) {
   perror(snd_dev);
   Com_Printf("Could not support 16-bit data.  Try 8-bit.\n");
   close(audio_fd);
   return 0;
  }
 } else if (shm->format.width == 1) {
  rc = 0x00000008;
  rc = ioctl(audio_fd, (((2U|1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((5)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &rc);
  if (rc < 0) {
   perror(snd_dev);
   Com_Printf("Could not support 8-bit data.\n");
   close(audio_fd);
   return 0;
  }
 } else {
  perror(snd_dev);
  Com_Printf("%d-bit sound not supported.", shm->format.width * 8);
   close(audio_fd);
   return 0;
  }
 if (ioctl(audio_fd, (((2U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((12)) << 0) | ((((sizeof(audio_buf_info)))) << ((0 +8)+8))), &info) == -1) {
  perror("GETOSPACE");
  Com_Printf ("Um, can't do GETOSPACE?\n");
  close(audio_fd);
  return 0;
     }
 shm->sampleframes = info.fragstotal * info.fragsize / shm->format.width / shm->format.channels;
 shm->samples = shm->sampleframes * shm->format.channels;
 shm->bufferlength = info.fragstotal * info.fragsize;
 shm->buffer = (unsigned char *) mmap(((void *)0), shm->bufferlength, 0x2, 0|0x01, audio_fd, 0);
 if (!shm->buffer || shm->buffer == (unsigned char *)-1) {
  perror(snd_dev);
  Com_Printf ("Could not mmap %s\n", snd_dev);
  close(audio_fd);
  return 0;
 }
 tmp = 0;
 rc = ioctl(audio_fd, (((1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((16)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &tmp);
 if (rc < 0) {
  perror(snd_dev);
  Com_Printf("Could not toggle.\n");
  close(audio_fd);
  return 0;
 }
 tmp = 0x00000002;
 rc = ioctl(audio_fd, (((1U) << (((0 +8)+8)+14)) | ((('P')) << (0 +8)) | (((16)) << 0) | ((((sizeof(int)))) << ((0 +8)+8))), &tmp);
 if (rc < 0) {
  perror(snd_dev);
  Com_Printf("Could not toggle.\n");
  close(audio_fd);
  return 0;
 }
 shm->samplepos = 0;
 sd->GetDMAPos = SNDDMA_GetDMAPos_OSS_Legacy;
 sd->GetAvail = ((void *)0);
 sd->Submit = ((void *)0);
 sd->Shutdown = SNDDMA_Shutdown_OSS_Legacy;
 sd->name = "snd_oss (legacy)";
 return 1;
}

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

variable_types: rc int

variable_types: fmt int

variable_types: caps int

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


AngleMod

decompiled_code:
float __fastcall AngleMod(float result)
{
if ( result > 180.0 )
result = result - 360.0;
if ( result <= -180.0 )
result = result + 360.0;
return result;
}

canonical_decompiled_code:
float __fastcall func0(float result)
{
if ( result > 180.0 )
result = result - 360.0;
if ( result <= -180.0 )
result = result + 360.0;
return result;
}

original_code:
static float AngleMod (float a)
{
 if (a > 180)
  a -= 360;
 if (a <= - 180)
  a += 360;
 return a;
}

canonical_original_code:
static float AngleMod(float a)
{
 if (a > 180)
  a -= 360;
 if (a <= - 180)
  a += 360;
 return a;
}

variable_types: a float

return_type: float


Accelerate

decompiled_code:
void __fastcall Accelerate(float *a1, float *a2, float a3)
{
float v3; // xmm2_4
float v4; // xmm2_4
__int64 i; // rax

v3 = a3 - (float)((float)((float)(*a2 * *a1) + (float)(a2[1] * a1[1])) + (float)(a2[2] * a1[2]));
if ( v3 > 0.0 )
{
v4 = fminf(v3, (float)(a3 * movevars[4]) * *(float *)&pm_frametime);
for ( i = 0LL; i != 3; ++i )
a2[i] = (float)(v4 * a1[i]) + a2[i];
}
}

canonical_decompiled_code:
void __fastcall func2(float *a1, float *a2, float a3)
{
float v3; // xmm2_4
float v4; // xmm2_4
__int64 i; // rax

v3 = a3 - (float)((float)((float)(*a2 * *a1) + (float)(a2[1] * a1[1])) + (float)(a2[2] * a1[2]));
if ( v3 > 0.0 )
{
v4 = fminf(v3, (float)(a3 * movevars[4]) * *(float *)&pm_frametime);
for ( i = 0LL; i != 3; ++i )
a2[i] = (float)(v4 * a1[i]) + a2[i];
}
}

original_code:
static void Accelerate (vec3_t wishdir, float wishspd, vec3_t velocity)
{
 int i;
 float addspeed, accelspeed, currentspeed;
 float wishspd_orig = wishspd;
 currentspeed = ((velocity)[0] * (wishdir)[0] + (velocity)[1] * (wishdir)[1] + (velocity)[2] * (wishdir)[2]);
 addspeed = wishspd - currentspeed;
 if (addspeed <= 0)
  return;
 accelspeed = movevars.accelerate * wishspd_orig * pm_frametime;
 if (accelspeed > addspeed)
  accelspeed = addspeed;
 for (i=0 ; i<3 ; i++)
  velocity[i] += accelspeed*wishdir[i];
}

canonical_original_code:
static void Accelerate(float wishdir[3], float wishspd, float velocity[3])
{
 int i;
 float addspeed; float accelspeed; float currentspeed;
 float wishspd_orig = wishspd;
 currentspeed = ((velocity)[0] * (wishdir)[0] + (velocity)[1] * (wishdir)[1] + (velocity)[2] * (wishdir)[2]);
 addspeed = wishspd - currentspeed;
 if (addspeed <= 0)
  return;
 accelspeed = movevars.accelerate * wishspd_orig * pm_frametime;
 if (accelspeed > addspeed)
  accelspeed = addspeed;
 for (i=0 ; i<3 ; i++)
  velocity[i] += accelspeed*wishdir[i];
}

variable_types:
wishdir
float [3]

variable_types: wishspd float

variable_types:
velocity
float [3]

variable_types: i int

variable_types: addspeed float

variable_types: accelspeed float

variable_types: currentspeed float


Autohop

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

result = *(unsigned __int8 *)(a1 + 22);
if ( (result & 2) != 0 )
{
if ( *(float *)&cl_autohop[4] != 0.0 )
{
if ( unk_F08[331519] <= 0.0 && *(float *)&oldzvel_0 > 0.0 )
{
result = (unsigned int)result & 0xFFFFFFFD;
*(_BYTE *)(a1 + 22) = result;
}
oldzvel_0 = LODWORD(unk_F08[331519]);
}
}
else
{
oldzvel_0 = LODWORD(unk_F08[331519]);
}
return result;
}

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

result = *(unsigned __int8 *)(a1 + 22);
if ( (result & 2) != 0 )
{
if ( *(float *)&cl_autohop[4] != 0.0 )
{
if ( unk_F08[331519] <= 0.0 && *(float *)&oldzvel_0 > 0.0 )
{
result = (unsigned int)result & 0xFFFFFFFD;
*(_BYTE *)(a1 + 22) = result;
}
oldzvel_0 = LODWORD(unk_F08[331519]);
}
}
else
{
oldzvel_0 = LODWORD(unk_F08[331519]);
}
return result;
}

original_code:
static void Autohop (usercmd_t *cmd)
{
 static float oldzvel;
 if (!(cmd->buttons & 2))
 {
  oldzvel = cl.simvel[2];
  return;
 }
 if (!cl_autohop.value)
  return;
 if (cl.simvel[2] <= 0 && oldzvel > 0)
  cmd->buttons &= ~2;
 oldzvel = cl.simvel[2];
}

canonical_original_code:
static void Autohop(struct usercmd_s *cmd)
{
 static float oldzvel;
 if (!(cmd->buttons & 2))
 {
  oldzvel = cl.simvel[2];
  return;
 }
 if (!cl_autohop.value)
  return;
 if (cl.simvel[2] <= 0 && oldzvel > 0)
  cmd->buttons &= ~2;
 oldzvel = cl.simvel[2];
}

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

variable_types: oldzvel float


Friction

decompiled_code:
void __fastcall Friction(__int64 a1)
{
double v1; // xmm0_8
float v2; // xmm1_4
float v3; // xmm0_4
float v4; // xmm0_4

v1 = VectorLength();
v2 = *(float *)&v1;
if ( *(float *)&v1 < 1.0 )
{
*(_DWORD *)a1 = 0;
*(_DWORD *)(a1 + 4) = 0;
}
else
{
v3 = *(float *)&v1 - (float)((float)(fmaxf(movevars[1], *(float *)&v1) * movevars[7]) * *(float *)&pm_frametime);
if ( v3 < 0.0 )
v3 = 0.0;
v4 = v3 / v2;
*(float *)a1 = v4 * *(float *)a1;
*(float *)(a1 + 4) = v4 * *(float *)(a1 + 4);
*(float *)(a1 + 8) = v4 * *(float *)(a1 + 8);
}
}

original_code:
static void Friction (vec3_t velocity)
{
 float speed, newspeed, control;
 float friction;
 float drop;
 speed = VectorLength(velocity);
 if (speed < 1)
 {
  velocity[0] = 0;
  velocity[1] = 0;
  return;
 }
 friction = movevars.friction;
 control = speed < movevars.stopspeed ? movevars.stopspeed : speed;
 drop = control*friction*pm_frametime;
 newspeed = speed - drop;
 if (newspeed < 0)
  newspeed = 0;
 do { float scale = (newspeed / speed); (velocity)[0] = (velocity)[0] * (scale); (velocity)[1] = (velocity)[1] * (scale); (velocity)[2] = (velocity)[2] * (scale); } while (0);;
}

canonical_original_code:
static void Friction(float velocity[3])
{
 float speed; float newspeed; float control;
 float friction;
 float drop;
 speed = VectorLength(velocity);
 if (speed < 1)
 {
  velocity[0] = 0;
  velocity[1] = 0;
  return;
 }
 friction = movevars.friction;
 control = speed < movevars.stopspeed ? movevars.stopspeed : speed;
 drop = control*friction*pm_frametime;
 newspeed = speed - drop;
 if (newspeed < 0)
  newspeed = 0;
 do { float scale = (newspeed / speed); (velocity)[0] = (velocity)[0] * (scale); (velocity)[1] = (velocity)[1] * (scale); (velocity)[2] = (velocity)[2] * (scale); } while (0);;
}

variable_types: speed float

variable_types: newspeed float

variable_types: control float

variable_types: friction float

variable_types: drop float

variable_types: scale float


RankAngle

decompiled_code:
__m128 __fastcall RankAngle(float a1)
{
float v1; // xmm0_4
int v2; // xmm0_4
__m128 v3; // xmm0
double v5; // [rsp+0h] [rbp-48h] BYREF
double sinx; // [rsp+8h] [rbp-40h] BYREF
int v7[3]; // [rsp+10h] [rbp-38h] BYREF
char v8[4]; // [rsp+1Ch] [rbp-2Ch] BYREF
float v9; // [rsp+20h] [rbp-28h]
char v10[4]; // [rsp+28h] [rbp-20h] BYREF
float v11; // [rsp+2Ch] [rbp-1Ch]
int v12[5]; // [rsp+34h] [rbp-14h] BYREF

sincos((float)(a1 / 180.0) * 3.141592653589793, &sinx, &v5);
v1 = v5;
*(float *)v12 = v1;
*(float *)&v2 = sinx;
v12[1] = v2;
v12[2] = 0;
v7[0] = ra_curvel;
v7[1] = dword_D0C;
v7[2] = dword_D10;
Friction((__int64)v7);
Accelerate((float *)v12, (float *)v7, movevars[2]);
vectoangles(v7, v10);
vectoangles(&ra_intentions, v8);
v3 = (__m128)LODWORD(v9);
v3.m128_f32[0] = AngleMod(v9 - v11);
return _mm_or_ps(v3, (__m128)LC11);
}

canonical_decompiled_code:
__m128 __fastcall func6(float a1)
{
float v1; // xmm0_4
int v2; // xmm0_4
__m128 v3; // xmm0
double v5; // [rsp+0h] [rbp-48h] BYREF
double sinx; // [rsp+8h] [rbp-40h] BYREF
int v7[3]; // [rsp+10h] [rbp-38h] BYREF
char v8[4]; // [rsp+1Ch] [rbp-2Ch] BYREF
float v9; // [rsp+20h] [rbp-28h]
char v10[4]; // [rsp+28h] [rbp-20h] BYREF
float v11; // [rsp+2Ch] [rbp-1Ch]
int v12[5]; // [rsp+34h] [rbp-14h] BYREF

sincos((float)(a1 / 180.0) * 3.141592653589793, &sinx, &v5);
v1 = v5;
*(float *)v12 = v1;
*(float *)&v2 = sinx;
v12[1] = v2;
v12[2] = 0;
v7[0] = ra_curvel;
v7[1] = dword_D0C;
v7[2] = dword_D10;
func5((__int64)v7);
func2((float *)v12, (float *)v7, movevars[2]);
vectoangles(v7, v10);
vectoangles(&ra_intentions, v8);
v3 = (__m128)LODWORD(v9);
v3.m128_f32[0] = func0(v9 - v11);
return _mm_or_ps(v3, (__m128)LC11);
}

original_code:
static float RankAngle (float a)
{
 vec3_t wishdir;
 float delta;
 vec3_t ang1, ang2;
 vec3_t newvel;
 wishdir[0] = cos(a / 180 * 3.14159265358979323846);
 wishdir[1] = sin(a / 180 * 3.14159265358979323846);
 wishdir[2] = 0;
 ((newvel)[0] = (ra_curvel)[0], (newvel)[1] = (ra_curvel)[1], (newvel)[2] = (ra_curvel)[2]);
 Friction (newvel);
 Accelerate (wishdir, movevars.maxspeed, newvel);
 vectoangles (newvel, ang1);
 vectoangles (ra_intentions, ang2);
 delta = AngleMod(ang2[1] - ang1[1]);
 return -fabs(delta);
}

canonical_original_code:
static float RankAngle(float a)
{
 float wishdir[3];
 float delta;
 float ang1[3]; float ang2[3];
 float newvel[3];
 wishdir[0] = cos(a / 180 * 3.14159265358979323846);
 wishdir[1] = sin(a / 180 * 3.14159265358979323846);
 wishdir[2] = 0;
 ((newvel)[0] = (ra_curvel)[0], (newvel)[1] = (ra_curvel)[1], (newvel)[2] = (ra_curvel)[2]);
 Friction (newvel);
 Accelerate (wishdir, movevars.maxspeed, newvel);
 vectoangles (newvel, ang1);
 vectoangles (ra_intentions, ang2);
 delta = AngleMod(ang2[1] - ang1[1]);
 return -fabs(delta);
}

variable_types: delta float

variable_types:
newvel
float [3]


ZeroAngle

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

if ( a1 == 0.0 )
result = 0.0;
else
result = acos((float)(30.0 / a1)) / 3.141592653589793 * 180.0;
return result;
}

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

if ( a1 == 0.0 )
result = 0.0;
else
result = acos((float)(30.0 / a1)) / 3.141592653589793 * 180.0;
return result;
}

original_code:
static float ZeroAngle (float speed)
{
 if (!speed)
  return 0;
 return acos(30/speed)/3.14159265358979323846*180;
}

canonical_original_code:
static float ZeroAngle(float speed)
{
 if (!speed)
  return 0;
 return acos(30/speed)/3.14159265358979323846*180;
}


TweakMovement

original_code:
static void TweakMovement (usercmd_t *cmd)
{
 vec3_t fw, rt;
 vec3_t movevec;
 vec3_t v1, ang;
 float a;
 float delta;
 vec3_t intentions;
 vec3_t intentions_a;
 vec3_t cmd_ang;
 qbool onground;
 static qbool locked = false;
 static double startlock = -1;
 static float olddelta;
 static qbool olddelta_valid = false;
 static short oldmove[2];
 if (!cl_easymove.value || cl.waterlevel)
  return;
 if (!cmd->forwardmove && !cmd->sidemove)
 {
  oldmove[0] = oldmove[1] = 0;
  return;
 }
 onground = (cl.onground && !((cmd->buttons & (1 << 1)) && !em_jump_held));
 ((cmd_ang)[0] = (cmd->angles)[0], (cmd_ang)[1] = (cmd->angles)[1], (cmd_ang)[2] = (cmd->angles)[2]);
 cmd_ang[0] = 0;
 cmd_ang[2] = 0;
 AngleVectors (cmd_ang, fw, rt, ((void *)0));
 do { float scale = (cmd->forwardmove); (intentions)[0] = (fw)[0] * (scale); (intentions)[1] = (fw)[1] * (scale); (intentions)[2] = (fw)[2] * (scale); } while (0);;
 do { _mathlib_temp_float1 = (cmd->sidemove); (intentions)[0] = (intentions)[0] + _mathlib_temp_float1 * (rt)[0]; (intentions)[1] = (intentions)[1] + _mathlib_temp_float1 * (rt)[1]; (intentions)[2] = (intentions)[2] + _mathlib_temp_float1 * (rt)[2]; } while(0);;
 vectoangles (intentions, intentions_a);
 ((v1)[0] = (cl.simvel)[0], (v1)[1] = (cl.simvel)[1], (v1)[2] = (cl.simvel)[2]);
 v1[2] = 0;
 if (VectorLength(v1) < 30)
  return;
 vectoangles (v1, ang);
 delta = AngleMod(intentions_a[1] - ang[1]);
 if (!locked && startlock == -1)
  startlock = curtime;
 if ((cmd->forwardmove != oldmove[0] || cmd->sidemove != oldmove[1])
 && (!onground || (oldmove[0] || oldmove[1]))) {
  locked = false;
  olddelta_valid = false;
  startlock = curtime;
 }
 oldmove[0] = cmd->forwardmove;
 oldmove[1] = cmd->sidemove;
 if (fabs(delta) < 0.5 || (olddelta_valid && (
  (olddelta >= 0 && delta <= 0) || (olddelta <= 0 && delta >= 0)
  || fabs(delta) > fabs(olddelta) + 0.1)) ) {
   locked = true;
 }
 olddelta = delta;
 olddelta_valid = true;
 if (curtime - startlock > (onground ? 0.1 : 0.3))
  locked = true;
 if (fabs(delta) > 95) {
  locked = true;
  return;
 }
 if (!locked || em_touch_wall)
  return;
 if (onground)
 {
  if (fabs(delta) < 0.5)
   return;
  a = BestAngle (v1, intentions, onground);
 }
 else
 {
  a = intentions_a[1] + (delta > 0 ? 1 : -1)*ZeroAngle(VectorLength(v1));
 }
 ((ang)[0] = (ang)[1] = (ang)[2] = 0);
 ang[1] = a;
 AngleVectors (ang, movevec, ((void *)0), ((void *)0));
 cmd->forwardmove = ((movevec)[0] * (fw)[0] + (movevec)[1] * (fw)[1] + (movevec)[2] * (fw)[2]) * 500;
 cmd->sidemove = ((movevec)[0] * (rt)[0] + (movevec)[1] * (rt)[1] + (movevec)[2] * (rt)[2]) * 500;
}

canonical_original_code:
static void TweakMovement(struct usercmd_s *cmd)
{
 float fw[3]; float rt[3];
 float movevec[3];
 float v1[3]; float ang[3];
 float a;
 float delta;
 float intentions[3];
 float intentions_a[3];
 float cmd_ang[3];
 enum qbool onground;
 static enum qbool locked = false;
 static double startlock = -1;
 static float olddelta;
 static enum qbool olddelta_valid = false;
 static short oldmove[2];
 if (!cl_easymove.value || cl.waterlevel)
  return;
 if (!cmd->forwardmove && !cmd->sidemove)
 {
  oldmove[0] = oldmove[1] = 0;
  return;
 }
 onground = (cl.onground && !((cmd->buttons & (1 << 1)) && !em_jump_held));
 ((cmd_ang)[0] = (cmd->angles)[0], (cmd_ang)[1] = (cmd->angles)[1], (cmd_ang)[2] = (cmd->angles)[2]);
 cmd_ang[0] = 0;
 cmd_ang[2] = 0;
 AngleVectors (cmd_ang, fw, rt, ((void *)0));
 do { float scale = (cmd->forwardmove); (intentions)[0] = (fw)[0] * (scale); (intentions)[1] = (fw)[1] * (scale); (intentions)[2] = (fw)[2] * (scale); } while (0);;
 do { _mathlib_temp_float1 = (cmd->sidemove); (intentions)[0] = (intentions)[0] + _mathlib_temp_float1 * (rt)[0]; (intentions)[1] = (intentions)[1] + _mathlib_temp_float1 * (rt)[1]; (intentions)[2] = (intentions)[2] + _mathlib_temp_float1 * (rt)[2]; } while(0);;
 vectoangles (intentions, intentions_a);
 ((v1)[0] = (cl.simvel)[0], (v1)[1] = (cl.simvel)[1], (v1)[2] = (cl.simvel)[2]);
 v1[2] = 0;
 if (VectorLength(v1) < 30)
  return;
 vectoangles (v1, ang);
 delta = AngleMod(intentions_a[1] - ang[1]);
 if (!locked && startlock == -1)
  startlock = curtime;
 if ((cmd->forwardmove != oldmove[0] || cmd->sidemove != oldmove[1])
 && (!onground || (oldmove[0] || oldmove[1]))) {
  locked = false;
  olddelta_valid = false;
  startlock = curtime;
 }
 oldmove[0] = cmd->forwardmove;
 oldmove[1] = cmd->sidemove;
 if (fabs(delta) < 0.5 || (olddelta_valid && (
  (olddelta >= 0 && delta <= 0) || (olddelta <= 0 && delta >= 0)
  || fabs(delta) > fabs(olddelta) + 0.1)) ) {
   locked = true;
 }
 olddelta = delta;
 olddelta_valid = true;
 if (curtime - startlock > (onground ? 0.1 : 0.3))
  locked = true;
 if (fabs(delta) > 95) {
  locked = true;
  return;
 }
 if (!locked || em_touch_wall)
  return;
 if (onground)
 {
  if (fabs(delta) < 0.5)
   return;
  a = BestAngle (v1, intentions, onground);
 }
 else
 {
  a = intentions_a[1] + (delta > 0 ? 1 : -1)*ZeroAngle(VectorLength(v1));
 }
 ((ang)[0] = (ang)[1] = (ang)[2] = 0);
 ang[1] = a;
 AngleVectors (ang, movevec, ((void *)0), ((void *)0));
 cmd->forwardmove = ((movevec)[0] * (fw)[0] + (movevec)[1] * (fw)[1] + (movevec)[2] * (fw)[2]) * 500;
 cmd->sidemove = ((movevec)[0] * (rt)[0] + (movevec)[1] * (rt)[1] + (movevec)[2] * (rt)[2]) * 500;
}

variable_types:
fw
float [3]

variable_types:
rt
float [3]

variable_types:
movevec
float [3]

variable_types:
ang
float [3]

variable_types: a float

variable_types:
intentions
float [3]

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

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

variable_types: startlock double

variable_types: olddelta float

variable_types:
oldmove
short [2]

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


decompiled_code:
__int64 __fastcall CL_EasyMove(unsigned __int8 *a1)
{
__int64 result; // rax
int v2; // xmm0_4

result = (unsigned int)(LODWORD(unk_F08[331534]) | LODWORD(unk_F08[148]));
if ( !(LODWORD(unk_F08[331534]) | LODWORD(unk_F08[148])) && unk_F08[331416] >= 0.0 )
{
*(float *)&v2 = (double)*a1 * 0.001;
pm_frametime = v2;
TweakMovement((__int64)a1);
result = Autohop((__int64)a1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned __int8 *a1)
{
__int64 result; // rax
int v2; // xmm0_4

result = (unsigned int)(LODWORD(unk_F08[331534]) | LODWORD(unk_F08[148]));
if ( !(LODWORD(unk_F08[331534]) | LODWORD(unk_F08[148])) && unk_F08[331416] >= 0.0 )
{
*(float *)&v2 = (double)*a1 * 0.001;
pm_frametime = v2;
func8((__int64)a1);
result = func3((__int64)a1);
}
return result;
}

original_code:
void CL_EasyMove (usercmd_t *cmd)
{
 if (cl.spectator || cl.intermission || cl.stats[0] < 0)
  return;
 pm_frametime = cmd->msec * 0.001;
 TweakMovement (cmd);
 Autohop (cmd);
}

canonical_original_code:
void CL_EasyMove(struct usercmd_s *cmd)
{
 if (cl.spectator || cl.intermission || cl.stats[0] < 0)
  return;
 pm_frametime = cmd->msec * 0.001;
 TweakMovement (cmd);
 Autohop (cmd);
}

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


decompiled_code:
void MP3_Init()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code: void MP3_Init(void) {}

canonical_original_code: void MP3_Init() {}


decompiled_code:
void MP3_Shutdown()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code: void MP3_Shutdown(void) {}

canonical_original_code: void MP3_Shutdown() {}


original_code:
void R_RemoveEfrags (entity_t *ent) {
 efrag_t *ef, *old, *walk, **prev;
 ef = ent->efrag;
 while (ef) {
  prev = &ef->leaf->efrags;
  while (1) {
   walk = *prev;
   if (!walk)
    break;
   if (walk == ef) {
    *prev = ef->leafnext;
    break;
   } else {
    prev = &walk->leafnext;
   }
  }
  old = ef;
  ef = ef->entnext;
  old->entnext = cl.free_efrags;
  cl.free_efrags = old;
 }
 ent->efrag = ((void *)0);
}

canonical_original_code:
void R_RemoveEfrags(struct entity_s *ent) {
 struct efrag_s *ef; struct efrag_s *old; struct efrag_s *walk; struct efrag_s **prev;
 ef = ent->efrag;
 while (ef) {
  prev = &ef->leaf->efrags;
  while (1) {
   walk = *prev;
   if (!walk)
    break;
   if (walk == ef) {
    *prev = ef->leafnext;
    break;
   } else {
    prev = &walk->leafnext;
   }
  }
  old = ef;
  ef = ef->entnext;
  old->entnext = cl.free_efrags;
  cl.free_efrags = old;
 }
 ent->efrag = ((void *)0);
}

variable_types: struct entity_s { float origin[3]; float angles[3]; struct model_s { char name[64]; enum qbool { false=0, true=1 } needload; unsigned short crc; int simpletexture[5]; enum modhint_t { MOD_NORMAL=0, MOD_PLAYER=1, MOD_EYES=2, MOD_FLAME=3, MOD_THUNDERBOLT=4, MOD_BACKPACK=5, MOD_FLAG=6, MOD_SPIKE=7, MOD_TF_TRAIL=8, MOD_GRENADE=9, MOD_TESLA=10, MOD_SENTRYGUN=11, MOD_DETPACK=12, MOD_LASER=13, MOD_DEMON=14, MOD_SOLDIER=15, MOD_OGRE=16, MOD_ENFORCER=17, MOD_VOORSPIKE=18, MOD_LAVABALL=19, MOD_RAIL=20, MOD_RAIL2=21, MOD_BUILDINGGIBS=22, MOD_CLUSTER=23, MOD_SHAMBLER=24, MOD_TELEPORTDESTINATION=25, MOD_GIB=26, MOD_VMODEL=27 } modhint; enum modtype_t { mod_brush=0, mod_sprite=1, mod_spr32=2, mod_alias=3, mod_alias3=4 } type; int numframes; enum synctype_t { ST_SYNC=0, ST_RAND=1 } synctype; int flags; float mins[3]; float radius; int firstmodelsurface; int numsubmodels; struct dmodel_t { float mins[3]; float origin[3]; int headnode[4]; int visleafs; int firstface; } *submodels; int numplanes; struct mplane_s { float normal[3]; float dist; unsigned char type; unsigned char signbits; unsigned char pad[2]; } *planes; int numleafs; struct mleaf_s { int contents; int visframe; float minmaxs[6]; struct mnode_s { int contents; int visframe; float minmaxs[6]; struct mnode_s *parent; struct mplane_s *plane; struct mnode_s *children[2]; unsigned short firstsurface; unsigned short numsurfaces; } *parent; unsigned char *compressed_vis; struct efrag_s { struct mleaf_s *leaf; struct efrag_s *leafnext; struct entity_s *entity; struct efrag_s *entnext; } *efrags; struct msurface_s { int visframe; struct mplane_s *plane; int flags; int firstedge; int numedges; short texturemins[2]; short extents[2]; int light_s; struct glpoly_s { struct glpoly_s *next; struct glpoly_s *chain; struct glpoly_s *fb_chain; struct glpoly_s *luma_chain; struct glpoly_s *caustics_chain; struct glpoly_s *detail_chain; int numverts; float verts[4][9]; } *polys; struct msurface_s *texturechain; struct mtexinfo_s { float vecs[2][4]; struct texture_s { char name[16]; unsigned int width; int gl_texturenum; int fb_texturenum; struct msurface_s *texturechain[2]; struct msurface_s **texturechain_tail[2]; int anim_total; int anim_min; struct texture_s *anim_next; struct texture_s *alternate_anims; unsigned int offsets[4]; unsigned int flatcolor3ub; enum qbool { false=0, true=1 } loaded; int isLumaTexture; } *texture; int flags; } *texinfo; int dlightframe; int dlightbits; int lightmaptexturenum; unsigned char styles[4]; int cached_light[4]; enum qbool { false=0, true=1 } cached_dlight; unsigned char *samples; } **firstmarksurface; int nummarksurfaces; } *leafs; int numvertexes; struct mvertex_s { float position[3]; } *vertexes; int numedges; struct medge_s { unsigned short v[2]; unsigned int cachededgeoffset; } *edges; int numnodes; int firstnode; struct mnode_s *nodes; int numtexinfo; struct mtexinfo_s *texinfo; int numsurfaces; struct msurface_s *surfaces; int numsurfedges; int *surfedges; int nummarksurfaces; struct msurface_s **marksurfaces; int numtextures; struct texture_s **textures; unsigned char *visdata; unsigned char *lightdata; int bspversion; enum qbool { false=0, true=1 } isworldmodel; struct cache_user_s { void *data; } cache; } *model; unsigned char *colormap; int skinnum; struct player_info_s { int userid; char userinfo[1024]; char name[16]; float entertime; int frags; int ping; unsigned char pl; int topcolor; int bottomcolor; int _topcolor; int _bottomcolor; int real_topcolor; int real_bottomcolor; char team[1024]; char _team[1024]; int fps_msec; int last_fps; int fps; int fps_frames; double fps_measure_time; enum qbool { false=0, true=1 } isnear; int spectator; unsigned char translations[-1]; struct skin_t { char name[16]; enum qbool { false=0, true=1 } failedload; enum qbool { false=0, true=1 } warned; int width; int bpp; int texnum; struct cache_user_s cache; } *skin; int stats[32]; enum qbool { false=0, true=1 } skin_refresh; enum qbool { false=0, true=1 } ignored; enum qbool { false=0, true=1 } validated; char f_server[16]; enum qbool { false=0, true=1 } dead; } *scoreboard; int renderfx; int effects; int oldframe; int frame; float framelerp; struct efrag_s *efrag; int visframe; int dlightframe; int dlightbits; float alpha; int trivial_accept; struct mnode_s *topnode; } *

variable_types: struct efrag_s { struct mleaf_s { int contents; int visframe; float minmaxs[6]; struct mnode_s { int contents; int visframe; float minmaxs[6]; struct mnode_s *parent; struct mplane_s { float normal[3]; float dist; unsigned char type; unsigned char signbits; unsigned char pad[2]; } *plane; struct mnode_s *children[2]; unsigned short firstsurface; unsigned short numsurfaces; } *parent; unsigned char *compressed_vis; struct efrag_s *efrags; struct msurface_s { int visframe; struct mplane_s *plane; int flags; int firstedge; int numedges; short texturemins[2]; short extents[2]; int light_s; struct glpoly_s { struct glpoly_s *next; struct glpoly_s *chain; struct glpoly_s *fb_chain; struct glpoly_s *luma_chain; struct glpoly_s *caustics_chain; struct glpoly_s *detail_chain; int numverts; float verts[4][9]; } *polys; struct msurface_s *texturechain; struct mtexinfo_s { float vecs[2][4]; struct texture_s { char name[16]; unsigned int width; int gl_texturenum; int fb_texturenum; struct msurface_s *texturechain[2]; struct msurface_s **texturechain_tail[2]; int anim_total; int anim_min; struct texture_s *anim_next; struct texture_s *alternate_anims; unsigned int offsets[4]; unsigned int flatcolor3ub; enum qbool { false=0, true=1 } loaded; int isLumaTexture; } *texture; int flags; } *texinfo; int dlightframe; int dlightbits; int lightmaptexturenum; unsigned char styles[4]; int cached_light[4]; enum qbool { false=0, true=1 } cached_dlight; unsigned char *samples; } **firstmarksurface; int nummarksurfaces; } *leaf; struct efrag_s *leafnext; struct entity_s { float origin[3]; float angles[3]; struct model_s { char name[64]; enum qbool { false=0, true=1 } needload; unsigned short crc; int simpletexture[5]; enum modhint_t { MOD_NORMAL=0, MOD_PLAYER=1, MOD_EYES=2, MOD_FLAME=3, MOD_THUNDERBOLT=4, MOD_BACKPACK=5, MOD_FLAG=6, MOD_SPIKE=7, MOD_TF_TRAIL=8, MOD_GRENADE=9, MOD_TESLA=10, MOD_SENTRYGUN=11, MOD_DETPACK=12, MOD_LASER=13, MOD_DEMON=14, MOD_SOLDIER=15, MOD_OGRE=16, MOD_ENFORCER=17, MOD_VOORSPIKE=18, MOD_LAVABALL=19, MOD_RAIL=20, MOD_RAIL2=21, MOD_BUILDINGGIBS=22, MOD_CLUSTER=23, MOD_SHAMBLER=24, MOD_TELEPORTDESTINATION=25, MOD_GIB=26, MOD_VMODEL=27 } modhint; enum modtype_t { mod_brush=0, mod_sprite=1, mod_spr32=2, mod_alias=3, mod_alias3=4 } type; int numframes; enum synctype_t { ST_SYNC=0, ST_RAND=1 } synctype; int flags; float mins[3]; float radius; int firstmodelsurface; int numsubmodels; struct dmodel_t { float mins[3]; float origin[3]; int headnode[4]; int visleafs; int firstface; } *submodels; int numplanes; struct mplane_s *planes; int numleafs; struct mleaf_s *leafs; int numvertexes; struct mvertex_s { float position[3]; } *vertexes; int numedges; struct medge_s { unsigned short v[2]; unsigned int cachededgeoffset; } *edges; int numnodes; int firstnode; struct mnode_s *nodes; int numtexinfo; struct mtexinfo_s *texinfo; int numsurfaces; struct msurface_s *surfaces; int numsurfedges; int *surfedges; int nummarksurfaces; struct msurface_s **marksurfaces; int numtextures; struct texture_s **textures; unsigned char *visdata; unsigned char *lightdata; int bspversion; enum qbool { false=0, true=1 } isworldmodel; struct cache_user_s { void *data; } cache; } *model; unsigned char *colormap; int skinnum; struct player_info_s { int userid; char userinfo[1024]; char name[16]; float entertime; int frags; int ping; unsigned char pl; int topcolor; int bottomcolor; int _topcolor; int _bottomcolor; int real_topcolor; int real_bottomcolor; char team[1024]; char _team[1024]; int fps_msec; int last_fps; int fps; int fps_frames; double fps_measure_time; enum qbool { false=0, true=1 } isnear; int spectator; unsigned char translations[-1]; struct skin_t { char name[16]; enum qbool { false=0, true=1 } failedload; enum qbool { false=0, true=1 } warned; int width; int bpp; int texnum; struct cache_user_s cache; } *skin; int stats[32]; enum qbool { false=0, true=1 } skin_refresh; enum qbool { false=0, true=1 } ignored; enum qbool { false=0, true=1 } validated; char f_server[16]; enum qbool { false=0, true=1 } dead; } *scoreboard; int renderfx; int effects; int oldframe; int frame; float framelerp; struct efrag_s *efrag; int visframe; int dlightframe; int dlightbits; float alpha; int trivial_accept; struct mnode_s *topnode; } *entity; struct efrag_s *entnext; } **

user_defined_types: struct entity_s { float origin[3]; float angles[3]; struct model_s *model; unsigned char *colormap; int skinnum; struct player_info_s *scoreboard; int renderfx; int effects; int oldframe; int frame; float framelerp; struct efrag_s *efrag; int visframe; int dlightframe; int dlightbits; float alpha; int trivial_accept; struct mnode_s *topnode; }

user_defined_types: struct model_s { char name[64]; enum qbool needload; unsigned short crc; int simpletexture[5]; enum modhint_t modhint; enum modtype_t type; int numframes; enum synctype_t synctype; int flags; float mins[3]; float radius; int firstmodelsurface; int numsubmodels; struct dmodel_t *submodels; int numplanes; struct mplane_s *planes; int numleafs; struct mleaf_s *leafs; int numvertexes; struct mvertex_s *vertexes; int numedges; struct medge_s *edges; int numnodes; int firstnode; struct mnode_s *nodes; int numtexinfo; struct mtexinfo_s *texinfo; int numsurfaces; struct msurface_s *surfaces; int numsurfedges; int *surfedges; int nummarksurfaces; struct msurface_s **marksurfaces; int numtextures; struct texture_s **textures; unsigned char *visdata; unsigned char *lightdata; int bspversion; enum qbool isworldmodel; struct cache_user_s cache; }

user_defined_types: struct player_info_s { int userid; char userinfo[1024]; char name[16]; float entertime; int frags; int ping; unsigned char pl; int topcolor; int bottomcolor; int _topcolor; int _bottomcolor; int real_topcolor; int real_bottomcolor; char team[1024]; char _team[1024]; int fps_msec; int last_fps; int fps; int fps_frames; double fps_measure_time; enum qbool isnear; int spectator; unsigned char translations[-1]; struct skin_t *skin; int stats[32]; enum qbool skin_refresh; enum qbool ignored; enum qbool validated; char f_server[16]; enum qbool dead; }

user_defined_types: struct mleaf_s { int contents; int visframe; float minmaxs[6]; struct mnode_s *parent; unsigned char *compressed_vis; struct efrag_s *efrags; struct msurface_s **firstmarksurface; int nummarksurfaces; }

user_defined_types: struct skin_t { char name[16]; enum qbool failedload; enum qbool warned; int width; int bpp; int texnum; struct cache_user_s cache; }

user_defined_types: struct msurface_s { int visframe; struct mplane_s *plane; int flags; int firstedge; int numedges; short texturemins[2]; short extents[2]; int light_s; struct glpoly_s *polys; struct msurface_s *texturechain; struct mtexinfo_s *texinfo; int dlightframe; int dlightbits; int lightmaptexturenum; unsigned char styles[4]; int cached_light[4]; enum qbool cached_dlight; unsigned char *samples; }

user_defined_types: struct mtexinfo_s { float vecs[2][4]; struct texture_s *texture; int flags; }

user_defined_types: struct texture_s { char name[16]; unsigned int width; int gl_texturenum; int fb_texturenum; struct msurface_s *texturechain[2]; struct msurface_s **texturechain_tail[2]; int anim_total; int anim_min; struct texture_s *anim_next; struct texture_s *alternate_anims; unsigned int offsets[4]; unsigned int flatcolor3ub; enum qbool loaded; int isLumaTexture; }