decompiled_code:
__int64 __fastcall VFSTAR_Tell(__int64 a1)
{
return *(_QWORD *)(a1 + 88) - *(_QWORD *)(a1 + 72);
}

original_code:
static unsigned long VFSTAR_Tell(vfsfile_t *file)
{
 vfstarfile_t *vfst = (vfstarfile_t *)file;
 return vfst->currentpos - vfst->startpos;;
}

canonical_original_code:
static unsigned long VFSTAR_Tell(struct vfsfile_s *file)
{
 struct vfstarfile_t *vfst = (vfstarfile_t *)file;
 return vfst->currentpos - vfst->startpos;;
}

variable_types: struct vfsfile_s { int (*ReadBytes)(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *err); int (*WriteBytes)(struct vfsfile_s *file, void *buffer, int bytestowrite); int (*Seek)(struct vfsfile_s *file, unsigned long pos, int whence); unsigned long (*Tell)(struct vfsfile_s *file); unsigned long (*GetLen)(struct vfsfile_s *file); void (*Close)(struct vfsfile_s *file); void (*Flush)(struct vfsfile_s *file); enum qbool { false=0, true=1 } seekingisabadplan; enum qbool { false=0, true=1 } copyprotected; } *

variable_types: struct vfstarfile_t { struct vfsfile_s { int (*ReadBytes)(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *err); int (*WriteBytes)(struct vfsfile_s *file, void *buffer, int bytestowrite); int (*Seek)(struct vfsfile_s *file, unsigned long pos, int whence); unsigned long (*Tell)(struct vfsfile_s *file); unsigned long (*GetLen)(struct vfsfile_s *file); void (*Close)(struct vfsfile_s *file); void (*Flush)(struct vfsfile_s *file); enum qbool { false=0, true=1 } seekingisabadplan; enum qbool { false=0, true=1 } copyprotected; } funcs; struct tarfile_s { char filename[64]; struct hashtable_s { int numbuckets; struct bucket_s { void *data; char *keystring; struct bucket_s *next; } **bucket; } hash; struct vfsfile_s *raw; int numfiles; struct packfile_t { char name[64]; int filepos; } *files; unsigned long filepos; int references; } *parent; unsigned long startpos; unsigned long length; unsigned long currentpos; } *

return_type: unsigned long

user_defined_types: struct vfstarfile_t { struct vfsfile_s funcs; struct tarfile_s *parent; unsigned long startpos; unsigned long length; unsigned long currentpos; }

user_defined_types: struct tarfile_s { char filename[64]; struct hashtable_s hash; struct vfsfile_s *raw; int numfiles; struct packfile_t *files; unsigned long filepos; int references; }

user_defined_types: struct hashtable_s { int numbuckets; struct bucket_s **bucket; }


repo: jite/jquake

decompiled_code:
__int64 __fastcall VFSTAR_GetLen(__int64 a1)
{
return *(_QWORD *)(a1 + 80);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return *(_QWORD *)(a1 + 80);
}

original_code:
static unsigned long VFSTAR_GetLen(vfsfile_t *file)
{
 vfstarfile_t *vfst = (vfstarfile_t *)file;
 return vfst->length;
}

canonical_original_code:
static unsigned long VFSTAR_GetLen(struct vfsfile_s *file)
{
 struct vfstarfile_t *vfst = (vfstarfile_t *)file;
 return vfst->length;
}

user_defined_types: struct vfsfile_s { int (*ReadBytes)(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t *err); int (*WriteBytes)(struct vfsfile_s *file, void *buffer, int bytestowrite); int (*Seek)(struct vfsfile_s *file, unsigned long pos, int whence); unsigned long (*Tell)(struct vfsfile_s *file); unsigned long (*GetLen)(struct vfsfile_s *file); void (*Close)(struct vfsfile_s *file); void (*Flush)(struct vfsfile_s *file); enum qbool seekingisabadplan; enum qbool copyprotected; }

user_defined_types: enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 }

user_defined_types: struct packfile_t { char name[64]; int filepos; }

user_defined_types: struct bucket_s { void *data; char *keystring; struct bucket_s *next; }


decompiled_code:
__int64 VFSTAR_Flush()
{
return Sys_Error("VFSTAR_Flush: Invalid operation\n");
}

canonical_decompiled_code:
__int64 func3()
{
return Sys_Error("VFSTAR_Flush: Invalid operation\n");
}

original_code:
static void VFSTAR_Flush(vfsfile_t *file)
{
 Sys_Error("VFSTAR_Flush: Invalid operation\n");
}

canonical_original_code:
static void VFSTAR_Flush(struct vfsfile_s *file)
{
 Sys_Error("VFSTAR_Flush: Invalid operation\n");
}

return_type: void


decompiled_code:
__int64 VFSTAR_WriteBytes()
{
Sys_Error("VFSTAR_WriteBytes: Invalid operatioin\n");
return 0LL;
}

canonical_decompiled_code:
__int64 func4()
{
Sys_Error("VFSTAR_WriteBytes: Invalid operatioin\n");
return 0LL;
}

original_code:
static int VFSTAR_WriteBytes(vfsfile_t *file, const void *buffer, int bytestowrite)
{
 Sys_Error("VFSTAR_WriteBytes: Invalid operatioin\n");
 return 0;
}

canonical_original_code:
static int VFSTAR_WriteBytes(struct vfsfile_s *file, void *buffer, int bytestowrite)
{
 Sys_Error("VFSTAR_WriteBytes: Invalid operatioin\n");
 return 0;
}

variable_types:
buffer
void *

variable_types: bytestowrite int

return_type: int


decompiled_code:
__int64 __fastcall VFSTAR_Seek(_QWORD *a1, __int64 a2, unsigned int a3)
{
unsigned int v3; // er12
unsigned __int64 v5; // rax
unsigned __int64 v6; // rdx
unsigned __int64 v7; // rsi
unsigned __int64 v8; // rax

if ( a3 == 1 )
{
v5 = a1[11] + a2;
v6 = a1[10];
a1[11] = v5;
v7 = v5;
}
else if ( a3 == 2 )
{
v6 = a1[10];
v7 = a2 + v6 + a1[9];
a1[11] = v7;
}
else
{
if ( a3 )
{
v3 = -1;
Sys_Error("VFSTAR_Seek: Unknown whence value(%d)\n", a3);
return v3;
}
v8 = a1[9] + a2;
v6 = a1[10];
a1[11] = v8;
v7 = v8;
}
v3 = 0;
if ( v7 <= v6 )
return v3;
Com_Printf("VFSTAR_Seek: Warning seeking past the file's size\n");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1, __int64 a2, unsigned int a3)
{
unsigned int v3; // er12
unsigned __int64 v5; // rax
unsigned __int64 v6; // rdx
unsigned __int64 v7; // rsi
unsigned __int64 v8; // rax

if ( a3 == 1 )
{
v5 = a1[11] + a2;
v6 = a1[10];
a1[11] = v5;
v7 = v5;
}
else if ( a3 == 2 )
{
v6 = a1[10];
v7 = a2 + v6 + a1[9];
a1[11] = v7;
}
else
{
if ( a3 )
{
v3 = -1;
Sys_Error("VFSTAR_Seek: Unknown whence value(%d)\n", a3);
return v3;
}
v8 = a1[9] + a2;
v6 = a1[10];
a1[11] = v8;
v7 = v8;
}
v3 = 0;
if ( v7 <= v6 )
return v3;
Com_Printf("VFSTAR_Seek: Warning seeking past the file's size\n");
return 0LL;
}

original_code:
static int VFSTAR_Seek(vfsfile_t *file, unsigned long offset, int whence)
{
 vfstarfile_t *vfst = (vfstarfile_t *)file;
 switch(whence) {
 case 0:
  vfst->currentpos = vfst->startpos + offset;
  break;
 case 1:
  vfst->currentpos += offset;
  break;
 case 2:
  vfst->currentpos = vfst->startpos + vfst->length + offset;
  break;
 default:
  Sys_Error("VFSTAR_Seek: Unknown whence value(%d)\n", whence);
  return -1;
 }
 if (vfst->currentpos > vfst->length) {
  Com_Printf("VFSTAR_Seek: Warning seeking past the file's size\n");
 }
 return 0;
}

canonical_original_code:
static int VFSTAR_Seek(struct vfsfile_s *file, unsigned long offset, int whence)
{
 struct vfstarfile_t *vfst = (vfstarfile_t *)file;
 switch(whence) {
 case 0:
  vfst->currentpos = vfst->startpos + offset;
  break;
 case 1:
  vfst->currentpos += offset;
  break;
 case 2:
  vfst->currentpos = vfst->startpos + vfst->length + offset;
  break;
 default:
  Sys_Error("VFSTAR_Seek: Unknown whence value(%d)\n", whence);
  return -1;
 }
 if (vfst->currentpos > vfst->length) {
  Com_Printf("VFSTAR_Seek: Warning seeking past the file's size\n");
 }
 return 0;
}

variable_types:
offset
unsigned long

variable_types: whence int


decompiled_code:
__int64 __fastcall FSTAR_PrintPath(__int64 a1)
{
int v1; // edx
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 112);
if ( v1 == 1 )
result = Com_Printf("%s\n", (const char *)a1);
else
result = Com_Printf("%s (%i)\n", (const char *)a1, (unsigned int)(v1 - 1));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
int v1; // edx
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 112);
if ( v1 == 1 )
result = Com_Printf("%s\n", (const char *)a1);
else
result = Com_Printf("%s (%i)\n", (const char *)a1, (unsigned int)(v1 - 1));
return result;
}

original_code:
static void FSTAR_PrintPath(void *handle)
{
 tarfile_t *tar = (tarfile_t *)handle;
 if (tar->references != 1)
  Com_Printf("%s (%i)\n", tar->filename, tar->references-1);
 else
  Com_Printf("%s\n", tar->filename);
}

canonical_original_code:
static void FSTAR_PrintPath(void *handle)
{
 struct tarfile_s *tar = (tarfile_t *)handle;
 if (tar->references != 1)
  Com_Printf("%s (%i)\n", tar->filename, tar->references-1);
 else
  Com_Printf("%s\n", tar->filename);
}

variable_types:
handle
void *

variable_types: struct tarfile_s { char filename[64]; struct hashtable_s { int numbuckets; struct bucket_s { void *data; char *keystring; struct bucket_s *next; } **bucket; } hash; struct vfsfile_s { int (*ReadBytes)(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *err); int (*WriteBytes)(struct vfsfile_s *file, void *buffer, int bytestowrite); int (*Seek)(struct vfsfile_s *file, unsigned long pos, int whence); unsigned long (*Tell)(struct vfsfile_s *file); unsigned long (*GetLen)(struct vfsfile_s *file); void (*Close)(struct vfsfile_s *file); void (*Flush)(struct vfsfile_s *file); enum qbool { false=0, true=1 } seekingisabadplan; enum qbool { false=0, true=1 } copyprotected; } *raw; int numfiles; struct packfile_t { char name[64]; int filepos; } *files; unsigned long filepos; int references; } *


original_code:
static int VFSTAR_ReadBytes(vfsfile_t *file, void *buffer, int bytestoread, vfserrno_t *err)
{
 vfstarfile_t *vfst = (vfstarfile_t *)file;
 int read;
 if (vfst->currentpos - vfst->startpos + bytestoread > vfst->length)
  bytestoread = vfst->length - (vfst->currentpos - vfst->startpos);
 if (bytestoread < 0)
  Sys_Error("VFSTAR_ReadBytes: bytestoread < 0");
 if (vfst->parent->filepos != vfst->currentpos) {
  VFS_SEEK(vfst->parent->raw, vfst->currentpos, 0);
 }
 read = VFS_READ(vfst->parent->raw, buffer, bytestoread, ((void *)0));
 vfst->currentpos += read;
 vfst->parent->filepos = vfst->currentpos;
 if (err)
  *err = bytestoread == 0 ? VFSERR_EOF : VFSERR_NONE;
 return read;
}

canonical_original_code:
static int VFSTAR_ReadBytes(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t *err)
{
 struct vfstarfile_t *vfst = (vfstarfile_t *)file;
 int read;
 if (vfst->currentpos - vfst->startpos + bytestoread > vfst->length)
  bytestoread = vfst->length - (vfst->currentpos - vfst->startpos);
 if (bytestoread < 0)
  Sys_Error("VFSTAR_ReadBytes: bytestoread < 0");
 if (vfst->parent->filepos != vfst->currentpos) {
  VFS_SEEK(vfst->parent->raw, vfst->currentpos, 0);
 }
 read = VFS_READ(vfst->parent->raw, buffer, bytestoread, ((void *)0));
 vfst->currentpos += read;
 vfst->parent->filepos = vfst->currentpos;
 if (err)
  *err = bytestoread == 0 ? VFSERR_EOF : VFSERR_NONE;
 return read;
}

variable_types: bytestoread int

variable_types: enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *

variable_types: read int


decompiled_code:
__int64 __fastcall FSTAR_ReadFile(__int64 a1, __int64 a2, __int64 a3)
{
int v4; // er8
__int64 result; // rax
__int64 v6; // rdx

VFS_SEEK(*(_QWORD *)(a1 + 80), *(int *)(*(_QWORD *)(a1 + 96) + 72LL * *(int *)(a2 + 8) + 64), 0LL);
v4 = VFS_READ(*(_QWORD *)(a1 + 80), a3, *(unsigned int *)(*(_QWORD *)(a1 + 96) + 72LL * *(int *)(a2 + 8) + 68), 0LL);
result = *(_QWORD *)(a1 + 96);
v6 = result + 72LL * *(int *)(a2 + 8);
if ( *(_DWORD *)(v6 + 68) != v4 )
result = Com_Printf("Can't extract file \"%s:%s\" (corrupt)\n", (const char *)a1, (const char *)v6);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, __int64 a2, __int64 a3)
{
int v4; // er8
__int64 result; // rax
__int64 v6; // rdx

VFS_SEEK(*(_QWORD *)(a1 + 80), *(int *)(*(_QWORD *)(a1 + 96) + 72LL * *(int *)(a2 + 8) + 64), 0LL);
v4 = VFS_READ(*(_QWORD *)(a1 + 80), a3, *(unsigned int *)(*(_QWORD *)(a1 + 96) + 72LL * *(int *)(a2 + 8) + 68), 0LL);
result = *(_QWORD *)(a1 + 96);
v6 = result + 72LL * *(int *)(a2 + 8);
if ( *(_DWORD *)(v6 + 68) != v4 )
result = Com_Printf("Can't extract file \"%s:%s\" (corrupt)\n", (const char *)a1, (const char *)v6);
return result;
}

original_code:
static void FSTAR_ReadFile(void *handle, flocation_t *loc, char *buffer)
{
 tarfile_t *tar = handle;
 int err;
 VFS_SEEK(tar->raw, tar->files[loc->index].filepos, 0);
 err = VFS_READ(tar->raw, buffer, tar->files[loc->index].filelen, ((void *)0));
 if (err!=tar->files[loc->index].filelen)
 {
  Com_Printf ("Can't extract file \"%s:%s\" (corrupt)\n", tar->filename, tar->files[loc->index].name);
  return;
 }
 return;
}

canonical_original_code:
static void FSTAR_ReadFile(void *handle, struct flocation_t *loc, char *buffer)
{
 struct tarfile_s *tar = handle;
 int err;
 VFS_SEEK(tar->raw, tar->files[loc->index].filepos, 0);
 err = VFS_READ(tar->raw, buffer, tar->files[loc->index].filelen, ((void *)0));
 if (err!=tar->files[loc->index].filelen)
 {
  Com_Printf ("Can't extract file \"%s:%s\" (corrupt)\n", tar->filename, tar->files[loc->index].name);
  return;
 }
 return;
}

variable_types: struct flocation_t { struct searchpath_s { struct searchpathfuncs_t { void (*PrintPath)(void *handle); void (*ClosePath)(void *handle); void (*BuildHash)(void *handle); enum qbool { false=0, true=1 } (*FindFile)(void *handle, struct flocation_t *loc, char *name, void *hashedresult); void (*ReadFile)(void *handle, struct flocation_t *loc, char *buffer); int (*EnumerateFiles)(void *handle, char *match, int (*func)(char *, int, void *), void *parm); void *(*OpenNew)(struct vfsfile_s { int (*ReadBytes)(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *err); int (*WriteBytes)(struct vfsfile_s *file, void *buffer, int bytestowrite); int (*Seek)(struct vfsfile_s *file, unsigned long pos, int whence); unsigned long (*Tell)(struct vfsfile_s *file); unsigned long (*GetLen)(struct vfsfile_s *file); void (*Close)(struct vfsfile_s *file); void (*Flush)(struct vfsfile_s *file); enum qbool { false=0, true=1 } seekingisabadplan; enum qbool { false=0, true=1 } copyprotected; } *file, char *desc); int (*GeneratePureCRC)(void *handle, int seed, int usepure); struct vfsfile_s *(*OpenVFS)(void *handle, struct flocation_t *loc, char *mode); } *funcs; enum qbool { false=0, true=1 } copyprotected; enum qbool { false=0, true=1 } istemporary; void *handle; int crc_check; int crc_reply; struct searchpath_s *nextpure; struct searchpath_s *next; } *search; int index; char rawname[128]; int offset; int len; } *

variable_types:
buffer
char *

variable_types: err int

user_defined_types: struct flocation_t { struct searchpath_s *search; int index; char rawname[128]; int offset; int len; }

user_defined_types: struct searchpath_s { struct searchpathfuncs_t *funcs; enum qbool copyprotected; enum qbool istemporary; void *handle; int crc_check; int crc_reply; struct searchpath_s *nextpure; struct searchpath_s *next; }

user_defined_types: struct searchpathfuncs_t { void (*PrintPath)(void *handle); void (*ClosePath)(void *handle); void (*BuildHash)(void *handle); enum qbool (*FindFile)(void *handle, struct flocation_t *loc, char *name, void *hashedresult); void (*ReadFile)(void *handle, struct flocation_t *loc, char *buffer); int (*EnumerateFiles)(void *handle, char *match, int (*func)(char *, int, void *), void *parm); void *(*OpenNew)(struct vfsfile_s *file, char *desc); int (*GeneratePureCRC)(void *handle, int seed, int usepure); struct vfsfile_s *(*OpenVFS)(void *handle, struct flocation_t *loc, char *mode); }


decompiled_code:
__int64 __fastcall FSTAR_EnumerateFiles(__int64 a1, __int64 a2, __int64 (__fastcall *a3)(__int64, _QWORD, __int64), __int64 a4)
{
__int64 v4; // r15
__int64 result; // rax

if ( *(int *)(a1 + 88) <= 0 )
return 1LL;
v4 = 0LL;
while ( 1 )
{
if ( (unsigned int)wildcmp(a2, 72 * v4 + *(_QWORD *)(a1 + 96)) )
{
result = a3(72 * v4 + *(_QWORD *)(a1 + 96), *(unsigned int *)(72 * v4 + *(_QWORD *)(a1 + 96) + 68), a4);
if ( !(_DWORD)result )
break;
}
if ( *(_DWORD *)(a1 + 88) <= (int)++v4 )
return 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, __int64 a2, __int64 (__fastcall *a3)(__int64, _QWORD, __int64), __int64 a4)
{
__int64 v4; // r15
__int64 result; // rax

if ( *(int *)(a1 + 88) <= 0 )
return 1LL;
v4 = 0LL;
while ( 1 )
{
if ( (unsigned int)wildcmp(a2, 72 * v4 + *(_QWORD *)(a1 + 96)) )
{
result = a3(72 * v4 + *(_QWORD *)(a1 + 96), *(unsigned int *)(72 * v4 + *(_QWORD *)(a1 + 96) + 68), a4);
if ( !(_DWORD)result )
break;
}
if ( *(_DWORD *)(a1 + 88) <= (int)++v4 )
return 1LL;
}
return result;
}

original_code:
static int FSTAR_EnumerateFiles (void *handle, char *match, int (*func)(char *, int, void *), void *parm)
{
 tarfile_t *tar = handle;
 int num;
 for (num = 0; num < tar->numfiles; num++)
 {
  if (wildcmp(match, tar->files[num].name))
  {
   if (!func(tar->files[num].name, tar->files[num].filelen, parm))
    return false;
  }
 }
 return true;
}

canonical_original_code:
static int FSTAR_EnumerateFiles(void *handle, char *match, int (*func)(char *, int, void *), void *parm)
{
 struct tarfile_s *tar = handle;
 int num;
 for (num = 0; num < tar->numfiles; num++)
 {
  if (wildcmp(match, tar->files[num].name))
  {
   if (!func(tar->files[num].name, tar->files[num].filelen, parm))
    return false;
  }
 }
 return true;
}

variable_types:
match
char *

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

variable_types:
parm
void *

variable_types: num int


original_code:
static qbool FSTAR_FLocate(void *handle, flocation_t *loc, const char *filename, void *hashedresult)
{
 packfile_t *pf = (packfile_t *) hashedresult;
 tarfile_t *tar = (tarfile_t *) handle;
 int i;
 if (pf)
 {
  if (pf < tar->files || pf > tar->files + tar->numfiles)
   return false;
 }
 else
 {
  for (i=0 ; i<tar->numfiles ; i++)
  {
   if (!strcmp (tar->files[i].name, filename))
   {
    pf = &tar->files[i];
    break;
   }
  }
 }
 if (pf)
 {
  if (loc)
  {
   loc->index = pf - tar->files;
   snprintf(loc->rawname, sizeof(loc->rawname), "%s/%s", tar->filename, filename);
   loc->offset = pf->filepos;
   loc->len = pf->filelen;
  }
  return true;
 }
 return false;
}

canonical_original_code:
static enum qbool FSTAR_FLocate(void *handle, struct flocation_t *loc, char *filename, void *hashedresult)
{
 struct packfile_t *pf = (packfile_t *) hashedresult;
 struct tarfile_s *tar = (tarfile_t *) handle;
 int i;
 if (pf)
 {
  if (pf < tar->files || pf > tar->files + tar->numfiles)
   return false;
 }
 else
 {
  for (i=0 ; i<tar->numfiles ; i++)
  {
   if (!strcmp (tar->files[i].name, filename))
   {
    pf = &tar->files[i];
    break;
   }
  }
 }
 if (pf)
 {
  if (loc)
  {
   loc->index = pf - tar->files;
   snprintf(loc->rawname, sizeof(loc->rawname), "%s/%s", tar->filename, filename);
   loc->offset = pf->filepos;
   loc->len = pf->filelen;
  }
  return true;
 }
 return false;
}

variable_types:
filename
char *

variable_types:
hashedresult
void *

variable_types: struct packfile_t { char name[64]; int filepos; } *

variable_types: i int

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


decompiled_code:
__int64 __fastcall FSTAR_BuildHash(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbx
__int64 v3; // rbp

result = *(unsigned int *)(a1 + 88);
if ( (int)result > 0 )
{
v2 = 0LL;
do
{
while ( 1 )
{
v3 = 72 * v2;
result = Hash_GetInsensitive(filesystemhash, 72 * v2 + *(_QWORD *)(a1 + 96));
if ( !result )
break;
++fs_hash_dups;
if ( *(_DWORD *)(a1 + 88) <= (int)++v2 )
return result;
}
++v2;
result = Hash_AddInsensitive(filesystemhash, v3 + *(_QWORD *)(a1 + 96), v3 + *(_QWORD *)(a1 + 96));
++fs_hash_files;
}
while ( *(_DWORD *)(a1 + 88) > (int)v2 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbx
__int64 v3; // rbp

result = *(unsigned int *)(a1 + 88);
if ( (int)result > 0 )
{
v2 = 0LL;
do
{
while ( 1 )
{
v3 = 72 * v2;
result = Hash_GetInsensitive(filesystemhash, 72 * v2 + *(_QWORD *)(a1 + 96));
if ( !result )
break;
++fs_hash_dups;
if ( *(_DWORD *)(a1 + 88) <= (int)++v2 )
return result;
}
++v2;
result = Hash_AddInsensitive(filesystemhash, v3 + *(_QWORD *)(a1 + 96), v3 + *(_QWORD *)(a1 + 96));
++fs_hash_files;
}
while ( *(_DWORD *)(a1 + 88) > (int)v2 );
}
return result;
}

original_code:
static void FSTAR_BuildHash(void *handle)
{
 tarfile_t *tar = (tarfile_t *)handle;
 int i;
 for (i = 0; i < tar->numfiles; i++)
 {
  if (!Hash_GetInsensitive(filesystemhash, tar->files[i].name))
  {
   Hash_AddInsensitive(filesystemhash, tar->files[i].name, &tar->files[i]);
   fs_hash_files++;
  }
  else
   fs_hash_dups++;
 }
}

canonical_original_code:
static void FSTAR_BuildHash(void *handle)
{
 struct tarfile_s *tar = (tarfile_t *)handle;
 int i;
 for (i = 0; i < tar->numfiles; i++)
 {
  if (!Hash_GetInsensitive(filesystemhash, tar->files[i].name))
  {
   Hash_AddInsensitive(filesystemhash, tar->files[i].name, &tar->files[i]);
   fs_hash_files++;
  }
  else
   fs_hash_dups++;
 }
}


decompiled_code:
void __fastcall FSTAR_ClosePath(void *ptr)
{
int v1; // eax
void *v3; // rdi

v1 = *((_DWORD *)ptr + 28) - 1;
*((_DWORD *)ptr + 28) = v1;
if ( v1 <= 0 )
{
VFS_CLOSE(*((_QWORD *)ptr + 10));
v3 = (void *)*((_QWORD *)ptr + 12);
if ( v3 )
free(v3);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func12(void *ptr)
{
int v1; // eax
void *v3; // rdi

v1 = *((_DWORD *)ptr + 28) - 1;
*((_DWORD *)ptr + 28) = v1;
if ( v1 <= 0 )
{
VFS_CLOSE(*((_QWORD *)ptr + 10));
v3 = (void *)*((_QWORD *)ptr + 12);
if ( v3 )
free(v3);
free(ptr);
}
}

original_code:
static void FSTAR_ClosePath(void *handle)
{
 tarfile_t *tar = (tarfile_t *)handle;
 if (--tar->references > 0)
  return;
 VFS_CLOSE(tar->raw);
 if (tar->files)
  if(tar->files) { free(tar->files); tar->files = ((void *)0); };
 if(tar) { free(tar); tar = ((void *)0); };
}

canonical_original_code:
static void FSTAR_ClosePath(void *handle)
{
 struct tarfile_s *tar = (tarfile_t *)handle;
 if (--tar->references > 0)
  return;
 VFS_CLOSE(tar->raw);
 if (tar->files)
  if(tar->files) { free(tar->files); tar->files = ((void *)0); };
 if(tar) { free(tar); tar = ((void *)0); };
}


decompiled_code:
void __fastcall VFSTAR_Close(void *ptr)
{
FSTAR_ClosePath(*((void **)ptr + 8));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func13(void *ptr)
{
func12(*((void **)ptr + 8));
free(ptr);
}

original_code:
static void VFSTAR_Close(vfsfile_t *file)
{
 vfstarfile_t *vfst = (vfstarfile_t *)file;
 FSTAR_ClosePath(vfst->parent);
 if(vfst) { free(vfst); vfst = ((void *)0); };
}

canonical_original_code:
static void VFSTAR_Close(struct vfsfile_s *file)
{
 struct vfstarfile_t *vfst = (vfstarfile_t *)file;
 FSTAR_ClosePath(vfst->parent);
 if(vfst) { free(vfst); vfst = ((void *)0); };
}

variable_types: struct vfsfile_s { int (*ReadBytes)(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *err); int (*WriteBytes)(struct vfsfile_s *file, void *buffer, int bytestowrite); int (*Seek)(struct vfsfile_s *file, unsigned long pos, int whence); unsigned long (*Tell)(struct vfsfile_s *file); unsigned long (*GetLen)(struct vfsfile_s *file); void (*Close)(struct vfsfile_s *file); void (*Flush)(struct vfsfile_s *file); enum qbool { false=0, true=1 } seekingisabadplan; enum qbool { false=0, true=1 } copyprotected; } *

variable_types: struct vfstarfile_t { struct vfsfile_s { int (*ReadBytes)(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *err); int (*WriteBytes)(struct vfsfile_s *file, void *buffer, int bytestowrite); int (*Seek)(struct vfsfile_s *file, unsigned long pos, int whence); unsigned long (*Tell)(struct vfsfile_s *file); unsigned long (*GetLen)(struct vfsfile_s *file); void (*Close)(struct vfsfile_s *file); void (*Flush)(struct vfsfile_s *file); enum qbool { false=0, true=1 } seekingisabadplan; enum qbool { false=0, true=1 } copyprotected; } funcs; struct tarfile_s { char filename[64]; struct hashtable_s { int numbuckets; struct bucket_s { void *data; char *keystring; struct bucket_s *next; } **bucket; } hash; struct vfsfile_s *raw; int numfiles; struct packfile_t { char name[64]; int filepos; } *files; unsigned long filepos; int references; } *parent; unsigned long startpos; unsigned long length; unsigned long currentpos; } *


tarOperationIndexFiles

decompiled_code:
__int64 __fastcall tarOperationIndexFiles(__int64 a1, __int64 a2)
{
int v2; // er13
unsigned int v3; // er12
int v4; // er13
__int64 v5; // r14
unsigned int v6; // eax
int v7; // er13
char v9[124]; // [rsp+0h] [rbp-428h] BYREF
unsigned __int8 v10[32]; // [rsp+7Ch] [rbp-3ACh] BYREF
unsigned __int8 v11; // [rsp+9Ch] [rbp-38Ch]
char s1[552]; // [rsp+200h] [rbp-228h] BYREF

v2 = 1;
v3 = 0;
VFS_SEEK(a1, 0LL, 0LL);
while ( 1 )
{
while ( 1 )
{
do
{
if ( (unsigned int)VFS_READ(a1, v9, 512LL, 0LL) != 512 )
{
LABEL_25:
v3 = -1;
Com_Printf("Invalid tar file\n");
return v3;
}
if ( !v9[0] )
return v3;
if ( v2 == 1 )
{
strncpy(s1, v9, 0x64uLL);
if ( s1[99] )
s1[100] = 0;
}
else if ( strncmp(s1, v9, 0x63uLL) )
{
v3 = -1;
Com_Printf("bad long name\n");
return v3;
}
v2 = 1;
}
while ( v11 == 53 );
if ( v11 > 0x35u )
break;
if ( v11 && v11 != 48 )
{
LABEL_22:
++v3;
printf(" <---> %s\n", s1);
v2 = 1;
}
else
{
v4 = getoct_constprop_0(v10);
if ( v4 == -1 )
goto LABEL_25;
if ( a2 )
{
v5 = a2 + 72LL * (int)v3;
strlcpy(v5, s1, 64LL);
*(_DWORD *)(v5 + 68) = v4;
*(_DWORD *)(v5 + 64) = VFS_TELL(a1);
}
v6 = v4;
++v3;
if ( (v4 & 0x1FF) != 0 )
v6 = v4 + ((unsigned int)(v4 >> 31) >> 23) - (((_WORD)v4 + ((unsigned int)(v4 >> 31) >> 23)) & 0x1FF) + 512;
v2 = 1;
VFS_SEEK(a1, v6, 1LL);
}
}
if ( (unsigned __int8)(v11 - 75) > 1u )
goto LABEL_22;
v7 = getoct_constprop_0(v10);
if ( (unsigned int)v7 > 0x1FF )
goto LABEL_28;
if ( (int)VFS_READ(a1, s1, 512LL, 0LL) < 0 )
break;
if ( s1[511] || v7 < (int)strlen(s1) )
{
LABEL_28:
v3 = -1;
puts("Invalid tar file");
return v3;
}
v2 = 2;
}
v3 = -1;
printf("Problem reading blocksize");
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 a2)
{
int v2; // er13
unsigned int v3; // er12
int v4; // er13
__int64 v5; // r14
unsigned int v6; // eax
int v7; // er13
char v9[124]; // [rsp+0h] [rbp-428h] BYREF
unsigned __int8 v10[32]; // [rsp+7Ch] [rbp-3ACh] BYREF
unsigned __int8 v11; // [rsp+9Ch] [rbp-38Ch]
char s1[552]; // [rsp+200h] [rbp-228h] BYREF

v2 = 1;
v3 = 0;
VFS_SEEK(a1, 0LL, 0LL);
while ( 1 )
{
while ( 1 )
{
do
{
if ( (unsigned int)VFS_READ(a1, v9, 512LL, 0LL) != 512 )
{
LABEL_25:
v3 = -1;
Com_Printf("Invalid tar file\n");
return v3;
}
if ( !v9[0] )
return v3;
if ( v2 == 1 )
{
strncpy(s1, v9, 0x64uLL);
if ( s1[99] )
s1[100] = 0;
}
else if ( strncmp(s1, v9, 0x63uLL) )
{
v3 = -1;
Com_Printf("bad long name\n");
return v3;
}
v2 = 1;
}
while ( v11 == 53 );
if ( v11 > 0x35u )
break;
if ( v11 && v11 != 48 )
{
LABEL_22:
++v3;
printf(" <---> %s\n", s1);
v2 = 1;
}
else
{
v4 = func14(v10);
if ( v4 == -1 )
goto LABEL_25;
if ( a2 )
{
v5 = a2 + 72LL * (int)v3;
strlcpy(v5, s1, 64LL);
*(_DWORD *)(v5 + 68) = v4;
*(_DWORD *)(v5 + 64) = VFS_TELL(a1);
}
v6 = v4;
++v3;
if ( (v4 & 0x1FF) != 0 )
v6 = v4 + ((unsigned int)(v4 >> 31) >> 23) - (((_WORD)v4 + ((unsigned int)(v4 >> 31) >> 23)) & 0x1FF) + 512;
v2 = 1;
VFS_SEEK(a1, v6, 1LL);
}
}
if ( (unsigned __int8)(v11 - 75) > 1u )
goto LABEL_22;
v7 = func14(v10);
if ( (unsigned int)v7 > 0x1FF )
goto LABEL_28;
if ( (int)VFS_READ(a1, s1, 512LL, 0LL) < 0 )
break;
if ( s1[511] || v7 < (int)strlen(s1) )
{
LABEL_28:
v3 = -1;
puts("Invalid tar file");
return v3;
}
v2 = 2;
}
v3 = -1;
printf("Problem reading blocksize");
return v3;
}

original_code:
static int tarOperationIndexFiles(vfsfile_t *in, packfile_t *files) {
 union tar_buffer buffer;
 int len;
 int getheader = HEADER_SHORTNAME;
 int remaining = 0;
 char fname[512];
 int numfiles = 0;
 VFS_SEEK(in, 0, 0);
 while (1)
 {
  len = VFS_READ(in, &buffer, 512, ((void *)0));
  if (len < 0 || len != 512) {
   Com_Printf("Invalid tar file\n");
   return -1;
  }
  if (len == 0 || buffer.header.name[0] == 0)
   break;
  if (getheader == HEADER_SHORTNAME)
  {
   strncpy(fname,buffer.header.name,100);
   if (fname[100 -1] != 0)
    fname[100] = 0;
  }
  else
  {
   if (strncmp(fname,buffer.header.name,100 -1) != 0) {
    Com_Printf("bad long name\n");
    return -1;
   }
   getheader = HEADER_SHORTNAME;
  }
  switch (buffer.header.typeflag)
  {
   case '5':
    break;
   case '0':
   case '\0':
    remaining = getoct(buffer.header.size,12);
    if (remaining == -1)
    {
     Com_Printf("Invalid tar file\n");
     return -1;
    }
    if (files) {
     strlcpy(files[numfiles].name, fname, sizeof(files[numfiles].name));
     files[numfiles].filelen = remaining;
     files[numfiles].filepos = VFS_TELL(in);
    }
    numfiles++;
    getheader = HEADER_NONE;
    break;
   case 'K':
   case 'L':
    remaining = getoct(buffer.header.size,12);
    if (remaining < 0 || remaining >= 512)
    {
     printf("Invalid tar file\n");
     return -1;
    }
    len = VFS_READ(in, fname, 512, ((void *)0));
    if (len < 0) {
     printf("Problem reading blocksize");
     return -1;
    }
    if (fname[512 -1] != 0 || (int)strlen(fname) > remaining)
    {
     printf("Invalid tar file\n");
     return -1;
    }
    getheader = HEADER_LONGNAME;
    break;
   default:
    printf("      <---> %s\n",fname);
    numfiles++;
    break;
  }
  if (getheader == HEADER_NONE) {
   unsigned int offset;
   if (remaining % 512) {
    offset = remaining + (512 - (remaining % 512));
   } else {
    offset = remaining;
   }
   VFS_SEEK(in, offset, 1);
   getheader = HEADER_SHORTNAME;
  }
 }
 return numfiles;
}

canonical_original_code:
static int tarOperationIndexFiles(struct vfsfile_s *in, struct packfile_t *files) {
 union tar_buffer buffer;
 int len;
 int getheader = HEADER_SHORTNAME;
 int remaining = 0;
 char fname[512];
 int numfiles = 0;
 VFS_SEEK(in, 0, 0);
 while (1)
 {
  len = VFS_READ(in, &buffer, 512, ((void *)0));
  if (len < 0 || len != 512) {
   Com_Printf("Invalid tar file\n");
   return -1;
  }
  if (len == 0 || buffer.header.name[0] == 0)
   break;
  if (getheader == HEADER_SHORTNAME)
  {
   strncpy(fname,buffer.header.name,100);
   if (fname[100 -1] != 0)
    fname[100] = 0;
  }
  else
  {
   if (strncmp(fname,buffer.header.name,100 -1) != 0) {
    Com_Printf("bad long name\n");
    return -1;
   }
   getheader = HEADER_SHORTNAME;
  }
  switch (buffer.header.typeflag)
  {
   case '5':
    break;
   case '0':
   case '\0':
    remaining = getoct(buffer.header.size,12);
    if (remaining == -1)
    {
     Com_Printf("Invalid tar file\n");
     return -1;
    }
    if (files) {
     strlcpy(files[numfiles].name, fname, sizeof(files[numfiles].name));
     files[numfiles].filelen = remaining;
     files[numfiles].filepos = VFS_TELL(in);
    }
    numfiles++;
    getheader = HEADER_NONE;
    break;
   case 'K':
   case 'L':
    remaining = getoct(buffer.header.size,12);
    if (remaining < 0 || remaining >= 512)
    {
     printf("Invalid tar file\n");
     return -1;
    }
    len = VFS_READ(in, fname, 512, ((void *)0));
    if (len < 0) {
     printf("Problem reading blocksize");
     return -1;
    }
    if (fname[512 -1] != 0 || (int)strlen(fname) > remaining)
    {
     printf("Invalid tar file\n");
     return -1;
    }
    getheader = HEADER_LONGNAME;
    break;
   default:
    printf("      <---> %s\n",fname);
    numfiles++;
    break;
  }
  if (getheader == HEADER_NONE) {
   unsigned int offset;
   if (remaining % 512) {
    offset = remaining + (512 - (remaining % 512));
   } else {
    offset = remaining;
   }
   VFS_SEEK(in, offset, 1);
   getheader = HEADER_SHORTNAME;
  }
 }
 return numfiles;
}

variable_types: union tar_buffer { char buffer[512]; struct tar_header { char name[100]; char mode[8]; char uid[8]; char gid[8]; char size[12]; char mtime[12]; char chksum[8]; char typeflag; char linkname[100]; char magic[6]; char version[2]; char uname[32]; char gname[32]; char devmajor[8]; char devminor[8]; char prefix[155]; } header; }

variable_types: len int

variable_types: getheader int

variable_types: remaining int

variable_types:
fname
char [512]

variable_types: numfiles int

variable_types:
offset
unsigned int

user_defined_types: union tar_buffer { char buffer[512]; struct tar_header header; }


decompiled_code:
__int64 __fastcall FSGZIP_OpenVFS(__int64 a1, int *a2, _BYTE *a3)
{
__int64 result; // rax
__int64 v5; // rdx
__int64 v6; // rcx
__int64 (__fastcall *v7)(); // rdx
__int64 (__fastcall *v8)(); // rdx

if ( *a3 != 114 )
return 0LL;
if ( a3[1] != 98 || a3[2] )
return 0LL;
result = Q_calloc(1LL, 96LL);
*(_QWORD *)(result + 64) = a1;
++*(_DWORD *)(a1 + 160);
v5 = a2[35];
*(_QWORD *)(result + 72) = v5;
v6 = a2[36];
*(_QWORD *)(result + 88) = v5;
*(_QWORD *)(result + 80) = v6;
if ( *a3 != 114 || a3[1] != 98 || (v7 = VFSGZIP_ReadBytes, a3[2]) )
v7 = 0LL;
*(_QWORD *)result = v7;
if ( *a3 != 119 || a3[1] != 98 || (v8 = VFSGZIP_WriteBytes, a3[2]) )
v8 = 0LL;
*(_QWORD *)(result + 8) = v8;
*(_QWORD *)(result + 16) = VFSGZIP_Seek;
*(_QWORD *)(result + 24) = VFSGZIP_Tell;
*(_QWORD *)(result + 32) = VFSGZIP_GetLen;
*(_QWORD *)(result + 40) = VFSGZIP_Close;
*(_QWORD *)(result + 48) = VFSGZIP_Flush;
if ( *(_QWORD *)a2 )
*(_DWORD *)(result + 60) = *(_DWORD *)(*(_QWORD *)a2 + 8LL);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int *a2, _BYTE *a3)
{
__int64 result; // rax
__int64 v5; // rdx
__int64 v6; // rcx
__int64 (__fastcall *v7)(); // rdx
__int64 (__fastcall *v8)(); // rdx

if ( *a3 != 114 )
return 0LL;
if ( a3[1] != 98 || a3[2] )
return 0LL;
result = Q_calloc(1LL, 96LL);
*(_QWORD *)(result + 64) = a1;
++*(_DWORD *)(a1 + 160);
v5 = a2[35];
*(_QWORD *)(result + 72) = v5;
v6 = a2[36];
*(_QWORD *)(result + 88) = v5;
*(_QWORD *)(result + 80) = v6;
if ( *a3 != 114 || a3[1] != 98 || (v7 = VFSGZIP_ReadBytes, a3[2]) )
v7 = 0LL;
*(_QWORD *)result = v7;
if ( *a3 != 119 || a3[1] != 98 || (v8 = VFSGZIP_WriteBytes, a3[2]) )
v8 = 0LL;
*(_QWORD *)(result + 8) = v8;
*(_QWORD *)(result + 16) = VFSGZIP_Seek;
*(_QWORD *)(result + 24) = VFSGZIP_Tell;
*(_QWORD *)(result + 32) = VFSGZIP_GetLen;
*(_QWORD *)(result + 40) = VFSGZIP_Close;
*(_QWORD *)(result + 48) = VFSGZIP_Flush;
if ( *(_QWORD *)a2 )
*(_DWORD *)(result + 60) = *(_DWORD *)(*(_QWORD *)a2 + 8LL);
return result;
}

original_code:
static vfsfile_t *FSGZIP_OpenVFS(void *handle, flocation_t *loc, char *mode)
{
 gzipfile_t *gzip = (gzipfile_t *)handle;
 vfsgzipfile_t *vfsgz;
 if (strcmp(mode, "rb"))
  return ((void *)0);
 vfsgz = Q_calloc(1, sizeof(*vfsgz));
 vfsgz->parent = gzip;
 gzip->references++;
 vfsgz->startpos = loc->offset;
 vfsgz->length = loc->len;
 vfsgz->currentpos = vfsgz->startpos;
 vfsgz->funcs.ReadBytes = strcmp(mode, "rb") ? ((void *)0) : VFSGZIP_ReadBytes;
 vfsgz->funcs.WriteBytes = strcmp(mode, "wb") ? ((void *)0) : VFSGZIP_WriteBytes;
 vfsgz->funcs.Seek = VFSGZIP_Seek;
 vfsgz->funcs.Tell = VFSGZIP_Tell;
 vfsgz->funcs.GetLen = VFSGZIP_GetLen;
 vfsgz->funcs.Close = VFSGZIP_Close;
 vfsgz->funcs.Flush = VFSGZIP_Flush;
 if (loc->search)
  vfsgz->funcs.copyprotected = loc->search->copyprotected;
 return (vfsfile_t *)vfsgz;
}

canonical_original_code:
static struct vfsfile_s *FSGZIP_OpenVFS(void *handle, struct flocation_t *loc, char *mode)
{
 struct gzipfile_s *gzip = (gzipfile_t *)handle;
 struct vfsgzipfile_t *vfsgz;
 if (strcmp(mode, "rb"))
  return ((void *)0);
 vfsgz = Q_calloc(1, sizeof(*vfsgz));
 vfsgz->parent = gzip;
 gzip->references++;
 vfsgz->startpos = loc->offset;
 vfsgz->length = loc->len;
 vfsgz->currentpos = vfsgz->startpos;
 vfsgz->funcs.ReadBytes = strcmp(mode, "rb") ? ((void *)0) : VFSGZIP_ReadBytes;
 vfsgz->funcs.WriteBytes = strcmp(mode, "wb") ? ((void *)0) : VFSGZIP_WriteBytes;
 vfsgz->funcs.Seek = VFSGZIP_Seek;
 vfsgz->funcs.Tell = VFSGZIP_Tell;
 vfsgz->funcs.GetLen = VFSGZIP_GetLen;
 vfsgz->funcs.Close = VFSGZIP_Close;
 vfsgz->funcs.Flush = VFSGZIP_Flush;
 if (loc->search)
  vfsgz->funcs.copyprotected = loc->search->copyprotected;
 return (struct vfsfile_s *)vfsgz;
}

variable_types:
handle
void *

variable_types: struct flocation_t { struct searchpath_s { struct searchpathfuncs_t { void (*PrintPath)(void *handle); void (*ClosePath)(void *handle); void (*BuildHash)(void *handle); enum qbool { false=0, true=1 } (*FindFile)(void *handle, struct flocation_t *loc, char *name, void *hashedresult); void (*ReadFile)(void *handle, struct flocation_t *loc, char *buffer); int (*EnumerateFiles)(void *handle, char *match, int (*func)(char *, int, void *), void *parm); void *(*OpenNew)(struct vfsfile_s *file, char *desc); int (*GeneratePureCRC)(void *handle, int seed, int usepure); struct vfsfile_s *(*OpenVFS)(void *handle, struct flocation_t *loc, char *mode); } *funcs; enum qbool { false=0, true=1 } copyprotected; enum qbool { false=0, true=1 } istemporary; void *handle; int crc_check; int crc_reply; struct searchpath_s *nextpure; struct searchpath_s *next; } *search; int index; char rawname[128]; int offset; int len; } *

variable_types:
mode
char *

variable_types: struct gzipfile_s { char filename[64]; struct vfsfile_s { int (*ReadBytes)(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *err); int (*WriteBytes)(struct vfsfile_s *file, void *buffer, int bytestowrite); int (*Seek)(struct vfsfile_s *file, unsigned long pos, int whence); unsigned long (*Tell)(struct vfsfile_s *file); unsigned long (*GetLen)(struct vfsfile_s *file); void (*Close)(struct vfsfile_s *file); void (*Flush)(struct vfsfile_s *file); enum qbool { false=0, true=1 } seekingisabadplan; enum qbool { false=0, true=1 } copyprotected; } *handle; struct packfile_t { char name[64]; int filepos; } file; unsigned long filepos; struct vfsfile_s *raw; int references; } *

variable_types: struct vfsgzipfile_t { struct vfsfile_s { int (*ReadBytes)(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *err); int (*WriteBytes)(struct vfsfile_s *file, void *buffer, int bytestowrite); int (*Seek)(struct vfsfile_s *file, unsigned long pos, int whence); unsigned long (*Tell)(struct vfsfile_s *file); unsigned long (*GetLen)(struct vfsfile_s *file); void (*Close)(struct vfsfile_s *file); void (*Flush)(struct vfsfile_s *file); enum qbool { false=0, true=1 } seekingisabadplan; enum qbool { false=0, true=1 } copyprotected; } funcs; struct gzipfile_s { char filename[64]; struct vfsfile_s *handle; struct packfile_t { char name[64]; int filepos; } file; unsigned long filepos; struct vfsfile_s *raw; int references; } *parent; unsigned long startpos; unsigned long length; unsigned long currentpos; } *

user_defined_types: struct gzipfile_s { char filename[64]; struct vfsfile_s *handle; struct packfile_t file; unsigned long filepos; struct vfsfile_s *raw; int references; }

user_defined_types: struct vfsgzipfile_t { struct vfsfile_s funcs; struct gzipfile_s *parent; unsigned long startpos; unsigned long length; unsigned long currentpos; }


decompiled_code:
__int64 __fastcall VFSGZIP_Flush(__int64 a1)
{
return gzflush(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 64LL), 2LL);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return gzflush(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 64LL), 2LL);
}

original_code:
static void VFSGZIP_Flush(vfsfile_t *file)
{
 vfsgzipfile_t *vfsgz = (vfsgzipfile_t *)file;
 (void) gzflush(vfsgz->parent->handle, 2);
}

canonical_original_code:
static void VFSGZIP_Flush(struct vfsfile_s *file)
{
 struct vfsgzipfile_t *vfsgz = (vfsgzipfile_t *)file;
 (void) gzflush(vfsgz->parent->handle, 2);
}


decompiled_code:
__int64 __fastcall VFSGZIP_Tell(__int64 a1)
{
return (int)gztell(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 64LL));
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
return (int)gztell(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 64LL));
}

original_code:
static unsigned long VFSGZIP_Tell(vfsfile_t *file)
{
 int r;
 vfsgzipfile_t *vfsgz = (vfsgzipfile_t *)file;
 r = gztell(vfsgz->parent->handle);
 return r;
}

canonical_original_code:
static unsigned long VFSGZIP_Tell(struct vfsfile_s *file)
{
 int r;
 struct vfsgzipfile_t *vfsgz = (vfsgzipfile_t *)file;
 r = gztell(vfsgz->parent->handle);
 return r;
}

variable_types: r int


decompiled_code:
__int64 __fastcall VFSGZIP_GetLen(__int64 a1)
{
int v1; // ebp
int v2; // ebx

v1 = gztell(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 64LL));
v2 = gzseek(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 64LL), 0LL, 2LL);
gzseek(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 64LL), v1, 0LL);
return v2;
}

original_code:
static unsigned long VFSGZIP_GetLen(vfsfile_t *file)
{
 int r, currentpos;
 vfsgzipfile_t *vfsgz = (vfsgzipfile_t *)file;
 currentpos = gztell(vfsgz->parent->handle);
 r = gzseek(vfsgz->parent->handle, 0, 2);
 gzseek(vfsgz->parent->handle, currentpos, 0);
 return r;
}

canonical_original_code:
static unsigned long VFSGZIP_GetLen(struct vfsfile_s *file)
{
 int r; int currentpos;
 struct vfsgzipfile_t *vfsgz = (vfsgzipfile_t *)file;
 currentpos = gztell(vfsgz->parent->handle);
 r = gzseek(vfsgz->parent->handle, 0, 2);
 gzseek(vfsgz->parent->handle, currentpos, 0);
 return r;
}

variable_types: currentpos int


decompiled_code:
__int64 __fastcall VFSGZIP_Seek(__int64 a1, __int64 a2, __int64 a3)
{
return (unsigned int)-((unsigned int)gzseek(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 64LL), a2, a3) == -1);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2, __int64 a3)
{
return (unsigned int)-((unsigned int)gzseek(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 64LL), a2, a3) == -1);
}

original_code:
static int VFSGZIP_Seek(vfsfile_t *file, unsigned long offset, int whence)
{
 int r;
 vfsgzipfile_t *vfsgz = (vfsgzipfile_t *)file;
 r = gzseek(vfsgz->parent->handle, offset, whence);
 if (r == -1)
  return -1;
 else
  return 0;
}

canonical_original_code:
static int VFSGZIP_Seek(struct vfsfile_s *file, unsigned long offset, int whence)
{
 int r;
 struct vfsgzipfile_t *vfsgz = (vfsgzipfile_t *)file;
 r = gzseek(vfsgz->parent->handle, offset, whence);
 if (r == -1)
  return -1;
 else
  return 0;
}

variable_types:
offset
unsigned long

variable_types: whence int


decompiled_code:
__int64 __fastcall VFSGZIP_WriteBytes(__int64 a1)
{
return gzwrite(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 64LL));
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return gzwrite(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 64LL));
}

original_code:
static int VFSGZIP_WriteBytes(vfsfile_t *file, const void *buffer, int bytestowrite)
{
 int r;
 vfsgzipfile_t *vfsgz = (vfsgzipfile_t *)file;
 r = gzwrite(vfsgz->parent->handle, buffer, bytestowrite);
 return r;
}

canonical_original_code:
static int VFSGZIP_WriteBytes(struct vfsfile_s *file, void *buffer, int bytestowrite)
{
 int r;
 struct vfsgzipfile_t *vfsgz = (vfsgzipfile_t *)file;
 r = gzwrite(vfsgz->parent->handle, buffer, bytestowrite);
 return r;
}

variable_types: struct vfsfile_s { int (*ReadBytes)(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *err); int (*WriteBytes)(struct vfsfile_s *file, void *buffer, int bytestowrite); int (*Seek)(struct vfsfile_s *file, unsigned long pos, int whence); unsigned long (*Tell)(struct vfsfile_s *file); unsigned long (*GetLen)(struct vfsfile_s *file); void (*Close)(struct vfsfile_s *file); void (*Flush)(struct vfsfile_s *file); enum qbool { false=0, true=1 } seekingisabadplan; enum qbool { false=0, true=1 } copyprotected; } *

variable_types:
buffer
void *

variable_types: bytestowrite int


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

if ( a3 < 0 )
Sys_Error("VFSGZIP_ReadBytes: bytestoread < 0");
result = gzread(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 64LL), a2, (unsigned int)a3);
if ( a4 )
*a4 = (_DWORD)result == 0 && a3 > 0;
return result;
}

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

if ( a3 < 0 )
Sys_Error("VFSGZIP_ReadBytes: bytestoread < 0");
result = gzread(*(_QWORD *)(*(_QWORD *)(a1 + 64) + 64LL), a2, (unsigned int)a3);
if ( a4 )
*a4 = (_DWORD)result == 0 && a3 > 0;
return result;
}

original_code:
static int VFSGZIP_ReadBytes(vfsfile_t *file, void *buffer, int bytestoread, vfserrno_t *err)
{
 int r;
 vfsgzipfile_t *vfsgz = (vfsgzipfile_t *)file;
 if (bytestoread < 0)
          Sys_Error("VFSGZIP_ReadBytes: bytestoread < 0");
 r = gzread(vfsgz->parent->handle, buffer, bytestoread);
 if (err)
  *err = ((r || bytestoread <= 0) ? VFSERR_NONE : VFSERR_EOF);
 return r;
}

canonical_original_code:
static int VFSGZIP_ReadBytes(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t *err)
{
 int r;
 struct vfsgzipfile_t *vfsgz = (vfsgzipfile_t *)file;
 if (bytestoread < 0)
          Sys_Error("VFSGZIP_ReadBytes: bytestoread < 0");
 r = gzread(vfsgz->parent->handle, buffer, bytestoread);
 if (err)
  *err = ((r || bytestoread <= 0) ? VFSERR_NONE : VFSERR_EOF);
 return r;
}

variable_types: bytestoread int

variable_types: enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *


decompiled_code:
_BOOL8 __fastcall FSGZIP_EnumerateFiles(__int64 a1, __int64 a2, unsigned int (__fastcall *a3)(__int64, _QWORD, __int64), __int64 a4)
{
int v6; // er8
_BOOL8 result; // rax

v6 = wildcmp(a2, a1 + 72);
result = 1LL;
if ( v6 )
result = a3(a1 + 72, *(unsigned int *)(a1 + 140), a4) != 0;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func8(__int64 a1, __int64 a2, unsigned int (__fastcall *a3)(__int64, _QWORD, __int64), __int64 a4)
{
int v6; // er8
_BOOL8 result; // rax

v6 = wildcmp(a2, a1 + 72);
result = 1LL;
if ( v6 )
result = a3(a1 + 72, *(unsigned int *)(a1 + 140), a4) != 0;
return result;
}

original_code:
static int FSGZIP_EnumerateFiles (void *handle, char *match, int (*func)(char *, int, void *), void *parm)
{
 gzipfile_t *gzip = handle;
 if (wildcmp(match, gzip->file.name))
 {
  if (!func(gzip->file.name, gzip->file.filelen, parm))
   return false;
 }
 return true;
}

canonical_original_code:
static int FSGZIP_EnumerateFiles(void *handle, char *match, int (*func)(char *, int, void *), void *parm)
{
 struct gzipfile_s *gzip = handle;
 if (wildcmp(match, gzip->file.name))
 {
  if (!func(gzip->file.name, gzip->file.filelen, parm))
   return false;
 }
 return true;
}

variable_types:
match
char *

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

variable_types:
parm
void *


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

VFS_SEEK(*(_QWORD *)(a1 + 64), *(int *)(a1 + 136), 0LL);
result = VFS_READ(*(_QWORD *)(a1 + 64), a3, *(unsigned int *)(a1 + 140), 0LL);
if ( *(_DWORD *)(a1 + 140) != (_DWORD)result )
result = Com_Printf("Can't extract file \"%s:%s\" (corrupt)\n", (const char *)a1, (const char *)(a1 + 72));
return result;
}

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

VFS_SEEK(*(_QWORD *)(a1 + 64), *(int *)(a1 + 136), 0LL);
result = VFS_READ(*(_QWORD *)(a1 + 64), a3, *(unsigned int *)(a1 + 140), 0LL);
if ( *(_DWORD *)(a1 + 140) != (_DWORD)result )
result = Com_Printf("Can't extract file \"%s:%s\" (corrupt)\n", (const char *)a1, (const char *)(a1 + 72));
return result;
}

original_code:
static void FSGZIP_ReadFile(void *handle, flocation_t *loc, char *buffer)
{
 gzipfile_t *gzip = handle;
 int err;
 VFS_SEEK(gzip->handle, gzip->file.filepos, 0);
 err = VFS_READ(gzip->handle, buffer, gzip->file.filelen, ((void *)0));
 if (err!=gzip->file.filelen)
 {
  Com_Printf ("Can't extract file \"%s:%s\" (corrupt)\n", gzip->filename, gzip->file.name);
  return;
 }
 return;
}

canonical_original_code:
static void FSGZIP_ReadFile(void *handle, struct flocation_t *loc, char *buffer)
{
 struct gzipfile_s *gzip = handle;
 int err;
 VFS_SEEK(gzip->handle, gzip->file.filepos, 0);
 err = VFS_READ(gzip->handle, buffer, gzip->file.filelen, ((void *)0));
 if (err!=gzip->file.filelen)
 {
  Com_Printf ("Can't extract file \"%s:%s\" (corrupt)\n", gzip->filename, gzip->file.name);
  return;
 }
 return;
}

variable_types:
handle
void *

variable_types: struct flocation_t { struct searchpath_s { struct searchpathfuncs_t { void (*PrintPath)(void *handle); void (*ClosePath)(void *handle); void (*BuildHash)(void *handle); enum qbool { false=0, true=1 } (*FindFile)(void *handle, struct flocation_t *loc, char *name, void *hashedresult); void (*ReadFile)(void *handle, struct flocation_t *loc, char *buffer); int (*EnumerateFiles)(void *handle, char *match, int (*func)(char *, int, void *), void *parm); void *(*OpenNew)(struct vfsfile_s { int (*ReadBytes)(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *err); int (*WriteBytes)(struct vfsfile_s *file, void *buffer, int bytestowrite); int (*Seek)(struct vfsfile_s *file, unsigned long pos, int whence); unsigned long (*Tell)(struct vfsfile_s *file); unsigned long (*GetLen)(struct vfsfile_s *file); void (*Close)(struct vfsfile_s *file); void (*Flush)(struct vfsfile_s *file); enum qbool { false=0, true=1 } seekingisabadplan; enum qbool { false=0, true=1 } copyprotected; } *file, char *desc); int (*GeneratePureCRC)(void *handle, int seed, int usepure); struct vfsfile_s *(*OpenVFS)(void *handle, struct flocation_t *loc, char *mode); } *funcs; enum qbool { false=0, true=1 } copyprotected; enum qbool { false=0, true=1 } istemporary; void *handle; int crc_check; int crc_reply; struct searchpath_s *nextpure; struct searchpath_s *next; } *search; int index; char rawname[128]; int offset; int len; } *

variable_types:
buffer
char *

variable_types: err int


decompiled_code:
__int64 __fastcall FSGZIP_PrintPath(__int64 a1)
{
int v1; // edx
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 160);
if ( v1 == 1 )
result = Com_Printf("%s\n", (const char *)a1);
else
result = Com_Printf("%s (%i)\n", (const char *)a1, (unsigned int)(v1 - 1));
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
int v1; // edx
__int64 result; // rax

v1 = *(_DWORD *)(a1 + 160);
if ( v1 == 1 )
result = Com_Printf("%s\n", (const char *)a1);
else
result = Com_Printf("%s (%i)\n", (const char *)a1, (unsigned int)(v1 - 1));
return result;
}

original_code:
static void FSGZIP_PrintPath(void *handle)
{
 gzipfile_t *gzip = (gzipfile_t *)handle;
 if (gzip->references != 1)
  Com_Printf("%s (%i)\n", gzip->filename, gzip->references-1);
 else
  Com_Printf("%s\n", gzip->filename);
}

canonical_original_code:
static void FSGZIP_PrintPath(void *handle)
{
 struct gzipfile_s *gzip = (gzipfile_t *)handle;
 if (gzip->references != 1)
  Com_Printf("%s (%i)\n", gzip->filename, gzip->references-1);
 else
  Com_Printf("%s\n", gzip->filename);
}

variable_types: struct gzipfile_s { char filename[64]; struct vfsfile_s { int (*ReadBytes)(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *err); int (*WriteBytes)(struct vfsfile_s *file, void *buffer, int bytestowrite); int (*Seek)(struct vfsfile_s *file, unsigned long pos, int whence); unsigned long (*Tell)(struct vfsfile_s *file); unsigned long (*GetLen)(struct vfsfile_s *file); void (*Close)(struct vfsfile_s *file); void (*Flush)(struct vfsfile_s *file); enum qbool { false=0, true=1 } seekingisabadplan; enum qbool { false=0, true=1 } copyprotected; } *handle; struct packfile_t { char name[64]; int filepos; } file; unsigned long filepos; struct vfsfile_s *raw; int references; } *


decompiled_code:
__int64 __fastcall FSGZIP_FLocate(__int64 a1, __int64 a2, const char *a3, __int64 a4)
{
unsigned int v5; // er14

if ( a4 )
{
v5 = 0;
if ( a4 != a1 + 72 )
return v5;
}
else if ( strcmp((const char *)(a1 + 72), a3) )
{
return 0LL;
}
v5 = 1;
if ( !a2 )
return v5;
*(_DWORD *)(a2 + 8) = 0;
snprintf((char *)(a2 + 12), 0x80uLL, "%s/%s", (const char *)a1, a3);
*(_DWORD *)(a2 + 140) = *(_DWORD *)(a1 + 136);
*(_DWORD *)(a2 + 144) = *(_DWORD *)(a1 + 140);
return 1LL;
}

original_code:
static qbool FSGZIP_FLocate(void *handle, flocation_t *loc, const char *filename, void *hashedresult)
{
 packfile_t *pf = hashedresult;
 gzipfile_t *gzip = (gzipfile_t *)handle;
 if (pf && pf != &(gzip->file)) {
  return false;
 } else if (!strcmp (gzip->file.name, filename)) {
  pf = &gzip->file;
 }
 if (pf)
 {
  if (loc)
  {
   loc->index = 0;
   snprintf(loc->rawname, sizeof(loc->rawname), "%s/%s", gzip->filename, filename);
   loc->offset = pf->filepos;
   loc->len = pf->filelen;
  }
  return true;
 }
 return false;
}

canonical_original_code:
static enum qbool FSGZIP_FLocate(void *handle, struct flocation_t *loc, char *filename, void *hashedresult)
{
 struct packfile_t *pf = hashedresult;
 struct gzipfile_s *gzip = (gzipfile_t *)handle;
 if (pf && pf != &(gzip->file)) {
  return false;
 } else if (!strcmp (gzip->file.name, filename)) {
  pf = &gzip->file;
 }
 if (pf)
 {
  if (loc)
  {
   loc->index = 0;
   snprintf(loc->rawname, sizeof(loc->rawname), "%s/%s", gzip->filename, filename);
   loc->offset = pf->filepos;
   loc->len = pf->filelen;
  }
  return true;
 }
 return false;
}

variable_types:
filename
char *

variable_types:
hashedresult
void *

variable_types: struct packfile_t { char name[64]; int filepos; } *


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

result = Hash_GetInsensitive(filesystemhash, a1 + 72);
if ( result )
{
++fs_hash_dups;
}
else
{
result = Hash_AddInsensitive(filesystemhash, a1 + 72, a1 + 72);
++fs_hash_files;
}
return result;
}

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

result = Hash_GetInsensitive(filesystemhash, a1 + 72);
if ( result )
{
++fs_hash_dups;
}
else
{
result = Hash_AddInsensitive(filesystemhash, a1 + 72, a1 + 72);
++fs_hash_files;
}
return result;
}

original_code:
static void FSGZIP_BuildHash(void *handle)
{
 gzipfile_t *gzip = (gzipfile_t *)handle;
 if (!Hash_GetInsensitive(filesystemhash, gzip->file.name))
 {
  Hash_AddInsensitive(filesystemhash, gzip->file.name, &gzip->file);
  fs_hash_files++;
 }
 else {
  fs_hash_dups++;
 }
}

canonical_original_code:
static void FSGZIP_BuildHash(void *handle)
{
 struct gzipfile_s *gzip = (gzipfile_t *)handle;
 if (!Hash_GetInsensitive(filesystemhash, gzip->file.name))
 {
  Hash_AddInsensitive(filesystemhash, gzip->file.name, &gzip->file);
  fs_hash_files++;
 }
 else {
  fs_hash_dups++;
 }
}


decompiled_code:
void __fastcall FSGZIP_ClosePath(void *ptr)
{
int v1; // eax

v1 = *((_DWORD *)ptr + 40) - 1;
*((_DWORD *)ptr + 40) = v1;
if ( v1 <= 0 )
{
gzclose(*((_QWORD *)ptr + 8));
VFS_CLOSE(*((_QWORD *)ptr + 19));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func13(void *ptr)
{
int v1; // eax

v1 = *((_DWORD *)ptr + 40) - 1;
*((_DWORD *)ptr + 40) = v1;
if ( v1 <= 0 )
{
gzclose(*((_QWORD *)ptr + 8));
VFS_CLOSE(*((_QWORD *)ptr + 19));
free(ptr);
}
}

original_code:
static void FSGZIP_ClosePath(void *handle)
{
 gzipfile_t *gzip = (gzipfile_t *)handle;
 if (--gzip->references > 0)
  return;
 gzclose(gzip->handle);
 VFS_CLOSE(gzip->raw);
 if(gzip) { free(gzip); gzip = ((void *)0); };
}

canonical_original_code:
static void FSGZIP_ClosePath(void *handle)
{
 struct gzipfile_s *gzip = (gzipfile_t *)handle;
 if (--gzip->references > 0)
  return;
 gzclose(gzip->handle);
 VFS_CLOSE(gzip->raw);
 if(gzip) { free(gzip); gzip = ((void *)0); };
}


decompiled_code:
void __fastcall VFSGZIP_Close(__int64 a1)
{
FSGZIP_ClosePath(*(void **)(a1 + 64));
}

canonical_decompiled_code:
void __fastcall func14(__int64 a1)
{
func13(*(void **)(a1 + 64));
}

original_code:
static void VFSGZIP_Close(vfsfile_t *file)
{
 vfsgzipfile_t *vfsgz = (vfsgzipfile_t *)file;
 FSGZIP_ClosePath(vfsgz->parent);
}

canonical_original_code:
static void VFSGZIP_Close(struct vfsfile_s *file)
{
 struct vfsgzipfile_t *vfsgz = (vfsgzipfile_t *)file;
 FSGZIP_ClosePath(vfsgz->parent);
}

variable_types: struct vfsgzipfile_t { struct vfsfile_s { int (*ReadBytes)(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *err); int (*WriteBytes)(struct vfsfile_s *file, void *buffer, int bytestowrite); int (*Seek)(struct vfsfile_s *file, unsigned long pos, int whence); unsigned long (*Tell)(struct vfsfile_s *file); unsigned long (*GetLen)(struct vfsfile_s *file); void (*Close)(struct vfsfile_s *file); void (*Flush)(struct vfsfile_s *file); enum qbool { false=0, true=1 } seekingisabadplan; enum qbool { false=0, true=1 } copyprotected; } funcs; struct gzipfile_s { char filename[64]; struct vfsfile_s *handle; struct packfile_t { char name[64]; int filepos; } file; unsigned long filepos; struct vfsfile_s *raw; int references; } *parent; unsigned long startpos; unsigned long length; unsigned long currentpos; } *


decompiled_code:
__int64 __fastcall CRC_Block(__int64 a1, unsigned int a2)
{
__int64 v2; // rcx
unsigned int v3; // edx
__int64 v4; // rsi
char v5; // al
unsigned __int16 v7; // [rsp+Eh] [rbp-2h] BYREF

CRC_Init(&v7);
v3 = v7;
if ( a2 )
{
v4 = v2 + a2;
do
{
++v2;
v5 = BYTE1(v3);
v3 <<= 8;
LOWORD(v3) = crctable[(unsigned __int8)(*(_BYTE *)(v2 - 1) ^ v5)] ^ v3;
}
while ( v2 != v4 );
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned int a2)
{
__int64 v2; // rcx
unsigned int v3; // edx
__int64 v4; // rsi
char v5; // al
unsigned __int16 v7; // [rsp+Eh] [rbp-2h] BYREF

func0(&v7);
v3 = v7;
if ( a2 )
{
v4 = v2 + a2;
do
{
++v2;
v5 = BYTE1(v3);
v3 <<= 8;
LOWORD(v3) = crctable[(unsigned __int8)(*(_BYTE *)(v2 - 1) ^ v5)] ^ v3;
}
while ( v2 != v4 );
}
return v3;
}

original_code:
unsigned short CRC_Block (byte *start, unsigned int count)
{
 unsigned short crc;
 CRC_Init (&crc);
 while (count--)
  crc = (crc << 8) ^ crctable[(crc >> 8) ^ *start++];
 return crc;
}

canonical_original_code:
unsigned short CRC_Block(unsigned char *start, unsigned int count)
{
 unsigned short crc;
 CRC_Init (&crc);
 while (count--)
  crc = (crc << 8) ^ crctable[(crc >> 8) ^ *start++];
 return crc;
}

variable_types:
start
unsigned char *

variable_types:
count
unsigned int

variable_types:
crc
unsigned short

return_type: unsigned short


decompiled_code:
__int16 __fastcall CRC_AddBlock(_WORD *a1, char *a2, int a3)
{
__int16 result; // ax
char *v5; // r8

if ( a3 )
{
do
result = CRC_ProcessByte(a1, *a2);
while ( a2 != v5 );
}
return result;
}

canonical_decompiled_code:
__int16 __fastcall func4(_WORD *a1, char *a2, int a3)
{
__int16 result; // ax
char *v5; // r8

if ( a3 )
{
do
result = func1(a1, *a2);
while ( a2 != v5 );
}
return result;
}

original_code:
void CRC_AddBlock (unsigned short *crcvalue, byte *start, int count)
{
    while (count--)
  CRC_ProcessByte(crcvalue, *start++);
}

canonical_original_code:
void CRC_AddBlock(unsigned short *crcvalue, unsigned char *start, int count)
{
    while (count--)
  CRC_ProcessByte(crcvalue, *start++);
}

variable_types:
crcvalue
unsigned short *

variable_types: count int


decompiled_code:
__int64 __fastcall CRC_Value(unsigned int a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int a1)
{
return a1;
}

original_code:
unsigned short CRC_Value(unsigned short crcvalue)
{
 return crcvalue ^ 0x0000;
}

variable_types:
crcvalue
unsigned short


decompiled_code:
__int64 __fastcall Netchan_OutOfBand(unsigned int a1, unsigned int a2, __int64 a3)
{
__int64 result; // rax
_QWORD v5[2]; // [rsp+0h] [rbp-5F8h] BYREF
unsigned int v6; // [rsp+14h] [rbp-5E4h]
char v7[1496]; // [rsp+20h] [rbp-5D8h] BYREF

SZ_Init(v5, v7, 1458LL);
MSG_WriteLong(v5, 0xFFFFFFFFLL);
SZ_Write(v5, a3, a2);
result = cls[2427];
if ( !(_DWORD)result )
result = NET_SendPacket(a1, v6, v5[1]);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1, unsigned int a2, __int64 a3)
{
__int64 result; // rax
_QWORD v5[2]; // [rsp+0h] [rbp-5F8h] BYREF
unsigned int v6; // [rsp+14h] [rbp-5E4h]
char v7[1496]; // [rsp+20h] [rbp-5D8h] BYREF

SZ_Init(v5, v7, 1458LL);
MSG_WriteLong(v5, 0xFFFFFFFFLL);
SZ_Write(v5, a3, a2);
result = cls[2427];
if ( !(_DWORD)result )
result = NET_SendPacket(a1, v6, v5[1]);
return result;
}

original_code:
void Netchan_OutOfBand (netsrc_t sock, netadr_t adr, int length, byte *data)
{
 sizebuf_t send;
 byte send_buf[1450 + 8];
 SZ_Init (&send, send_buf, sizeof(send_buf));
 MSG_WriteLong (&send, -1);
 SZ_Write (&send, data, length);
 if (!cls.demoplayback)
  NET_SendPacket (sock, send.cursize, send.data, adr);
}

canonical_original_code:
void Netchan_OutOfBand(enum netsrc_t sock, struct netadr_t adr, int length, unsigned char *data)
{
 struct sizebuf_s send;
 unsigned char send_buf[-1];
 SZ_Init (&send, send_buf, sizeof(send_buf));
 MSG_WriteLong (&send, -1);
 SZ_Write (&send, data, length);
 if (!cls.demoplayback)
  NET_SendPacket (sock, send.cursize, send.data, adr);
}

variable_types: enum netsrc_t { NS_CLIENT=0, NS_SERVER=1 }

variable_types: struct netadr_t { enum netadrtype_t { NA_INVALID=0, NA_LOOPBACK=1, NA_IPv4=2, NA_IPv6=3 } type; union { unsigned char ip[4]; unsigned char ip6[16]; } address; unsigned short port; }

variable_types: length int

variable_types:
data
unsigned char *

variable_types: struct sizebuf_s { enum qbool { false=0, true=1 } allowoverflow; enum qbool { false=0, true=1 } overflowed; unsigned char *data; int maxsize; int cursize; }

user_defined_types: struct netadr_t { enum netadrtype_t type; union { unsigned char ip[4]; unsigned char ip6[16]; } address; unsigned short port; }

user_defined_types: struct sizebuf_s { enum qbool allowoverflow; enum qbool overflowed; unsigned char *data; int maxsize; int cursize; }


decompiled_code:
__int64 Netchan_OutOfBandPrint(unsigned int a1, const char *a2, __int64 a3, __int64 a4, __int64 a5, ...)
{
unsigned int v5; // eax
gcc_va_list arg; // [rsp+8h] [rbp-20D0h] BYREF
char s[8192]; // [rsp+20h] [rbp-20B8h] BYREF

va_start(arg, a5);
vsnprintf(s, 0x2000uLL, a2, arg);
v5 = strlen(s);
return Netchan_OutOfBand(a1, v5, (__int64)s);
}

canonical_decompiled_code:
__int64 func2(unsigned int a1, const char *a2, __int64 a3, __int64 a4, __int64 a5, ...)
{
unsigned int v5; // eax
gcc_va_list arg; // [rsp+8h] [rbp-20D0h] BYREF
char s[8192]; // [rsp+20h] [rbp-20B8h] BYREF

va_start(arg, a5);
vsnprintf(s, 0x2000uLL, a2, arg);
v5 = strlen(s);
return func1(a1, v5, (__int64)s);
}

original_code:
void Netchan_OutOfBandPrint (netsrc_t sock, netadr_t adr, char *format, ...)
{
 va_list argptr;
 char string[8192];
 __builtin_va_start(argptr,format);
 vsnprintf (string, sizeof(string), format,argptr);
 __builtin_va_end(argptr);
 Netchan_OutOfBand (sock, adr, strlen(string), (byte *)string);
}

canonical_original_code:
void Netchan_OutOfBandPrint(enum netsrc_t sock, struct netadr_t adr, char *format, ...)
{
 __builtin_va_list argptr;
 char string[8192];
 __builtin_va_start(argptr,format);
 vsnprintf (string, sizeof(string), format,argptr);
 __builtin_va_end(argptr);
 Netchan_OutOfBand (sock, adr, strlen(string), (unsigned char *)string);
}

variable_types:
format
char *

variable_types:
string
char [8192]

user_defined_types: enum netsrc_t { NS_CLIENT=0, NS_SERVER=1 }

user_defined_types: enum netadrtype_t { NA_INVALID=0, NA_LOOPBACK=1, NA_IPv4=2, NA_IPv6=3 }


original_code:
void Netchan_Setup (netsrc_t sock, netchan_t *chan, netadr_t adr, int qport)
{
 memset (chan, 0, sizeof(*chan));
 chan->sock = sock;
 chan->remote_address = adr;
 chan->qport = qport;
 chan->last_received = curtime;
 SZ_Init (&chan->message, chan->message_buf, sizeof(chan->message_buf));
 chan->message.allowoverflow = true;
 chan->rate = 1.0/2500;
}

canonical_original_code:
void Netchan_Setup(enum netsrc_t sock, struct netchan_t *chan, struct netadr_t adr, int qport)
{
 memset (chan, 0, sizeof(*chan));
 chan->sock = sock;
 chan->remote_address = adr;
 chan->qport = qport;
 chan->last_received = curtime;
 SZ_Init (&chan->message, chan->message_buf, sizeof(chan->message_buf));
 chan->message.allowoverflow = true;
 chan->rate = 1.0/2500;
}

variable_types: struct netchan_t { enum qbool { false=0, true=1 } fatal_error; enum netsrc_t { NS_CLIENT=0, NS_SERVER=1 } sock; int dropped; float last_received; float frame_latency; float frame_rate; int drop_count; int good_count; struct netadr_t { enum netadrtype_t { NA_INVALID=0, NA_LOOPBACK=1, NA_IPv4=2, NA_IPv6=3 } type; union { unsigned char ip[4]; unsigned char ip6[16]; } address; unsigned short port; } remote_address; int qport; double cleartime; double rate; int incoming_sequence; int incoming_acknowledged; int incoming_reliable_acknowledged; int incoming_reliable_sequence; int outgoing_sequence; int reliable_sequence; int last_reliable_sequence; struct sizebuf_s { enum qbool { false=0, true=1 } allowoverflow; enum qbool { false=0, true=1 } overflowed; unsigned char *data; int maxsize; int cursize; } message; unsigned char message_buf[1450]; int reliable_length; unsigned char reliable_buf[1450]; int outgoing_size[32]; double outgoing_time[32]; } *

variable_types:
adr
struct netadr_t

variable_types: qport int

user_defined_types: struct netchan_t { enum qbool fatal_error; enum netsrc_t sock; int dropped; float last_received; float frame_latency; float frame_rate; int drop_count; int good_count; struct netadr_t remote_address; int qport; double cleartime; double rate; int incoming_sequence; int incoming_acknowledged; int incoming_reliable_acknowledged; int incoming_reliable_sequence; int outgoing_sequence; int reliable_sequence; int last_reliable_sequence; struct sizebuf_s message; unsigned char message_buf[1450]; int reliable_length; unsigned char reliable_buf[1450]; int outgoing_size[32]; double outgoing_time[32]; }


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

result = *(unsigned int *)(a1 + 32);
if ( (_DWORD)result != 1 )
result = 200.0 * *(double *)(a1 + 72) + curtime > *(double *)(a1 + 64);
return result;
}

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

result = *(unsigned int *)(a1 + 32);
if ( (_DWORD)result != 1 )
result = 200.0 * *(double *)(a1 + 72) + curtime > *(double *)(a1 + 64);
return result;
}

original_code:
qbool Netchan_CanPacket (netchan_t *chan)
{
 if (chan->remote_address.type == NA_LOOPBACK)
  return true;
 if (chan->cleartime < curtime + 200 * chan->rate)
  return true;
 return false;
}

canonical_original_code:
enum qbool Netchan_CanPacket(struct netchan_t *chan)
{
 if (chan->remote_address.type == NA_LOOPBACK)
  return true;
 if (chan->cleartime < curtime + 200 * chan->rate)
  return true;
 return false;
}


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

if ( *(_DWORD *)(a1 + 1588) )
result = 0LL;
else
result = Netchan_CanPacket(a1);
return result;
}

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

if ( *(_DWORD *)(a1 + 1588) )
result = 0LL;
else
result = func4(a1);
return result;
}

original_code:
qbool Netchan_CanReliable (netchan_t *chan)
{
 if (chan->reliable_length)
  return false;
 return Netchan_CanPacket (chan);
}

canonical_original_code:
enum qbool Netchan_CanReliable(struct netchan_t *chan)
{
 if (chan->reliable_length)
  return false;
 return Netchan_CanPacket (chan);
}


original_code:
void Netchan_Transmit (netchan_t *chan, int length, byte *data)
{
 sizebuf_t send;
 byte send_buf[1450 + 8];
 qbool send_reliable;
 unsigned w1, w2;
 int i;
 static double last_error_time = 0;
 double current_time;
 current_time = Sys_DoubleTime();
 if (chan->message.overflowed) {
  chan->fatal_error = true;
  if (last_error_time - current_time > 5 || developer.value) {
   Com_Printf ("%s:Outgoing message overflow\n", NET_AdrToString (chan->remote_address));
   last_error_time = current_time;
  }
  return;
 }
 send_reliable = false;
 if (chan->incoming_acknowledged > chan->last_reliable_sequence && chan->incoming_reliable_acknowledged != chan->reliable_sequence)
  send_reliable = true;
 if (!chan->reliable_length && chan->message.cursize) {
  memcpy (chan->reliable_buf, chan->message_buf, chan->message.cursize);
  chan->reliable_length = chan->message.cursize;
  chan->message.cursize = 0;
  chan->reliable_sequence ^= 1;
  send_reliable = true;
 }
 SZ_Init (&send, send_buf, sizeof(send_buf));
 w1 = chan->outgoing_sequence | (send_reliable<<31);
 w2 = chan->incoming_sequence | (chan->incoming_reliable_sequence<<31);
 chan->outgoing_sequence++;
 MSG_WriteLong (&send, w1);
 MSG_WriteLong (&send, w2);
 if (chan->sock == NS_CLIENT)
  MSG_WriteShort (&send, chan->qport);
 if (send_reliable) {
  SZ_Write (&send, chan->reliable_buf, chan->reliable_length);
  chan->last_reliable_sequence = chan->outgoing_sequence;
 }
 if (send.maxsize - send.cursize >= length)
  SZ_Write (&send, data, length);
 i = chan->outgoing_sequence & (32 -1);
 chan->outgoing_size[i] = send.cursize;
 chan->outgoing_time[i] = curtime;
 if (!cls.demoplayback)
  NET_SendPacket (chan->sock, send.cursize, send.data, chan->remote_address);
 if (chan->cleartime < curtime)
  chan->cleartime = curtime + send.cursize * chan->rate;
 else
  chan->cleartime += send.cursize * chan->rate;
 if (showpackets.value) {
  Print_flags[Print_current] |= 4;
  Com_Printf ("--> s=%i(%i) a=%i(%i) %i\n"
              , chan->outgoing_sequence
              , send_reliable
              , chan->incoming_sequence
              , chan->incoming_reliable_sequence
              , send.cursize);
 }
}

canonical_original_code:
void Netchan_Transmit(struct netchan_t *chan, int length, unsigned char *data)
{
 struct sizebuf_s send;
 unsigned char send_buf[-1];
 enum qbool send_reliable;
 unsigned int w1; unsigned int w2;
 int i;
 static double last_error_time = 0;
 double current_time;
 current_time = Sys_DoubleTime();
 if (chan->message.overflowed) {
  chan->fatal_error = true;
  if (last_error_time - current_time > 5 || developer.value) {
   Com_Printf ("%s:Outgoing message overflow\n", NET_AdrToString (chan->remote_address));
   last_error_time = current_time;
  }
  return;
 }
 send_reliable = false;
 if (chan->incoming_acknowledged > chan->last_reliable_sequence && chan->incoming_reliable_acknowledged != chan->reliable_sequence)
  send_reliable = true;
 if (!chan->reliable_length && chan->message.cursize) {
  memcpy (chan->reliable_buf, chan->message_buf, chan->message.cursize);
  chan->reliable_length = chan->message.cursize;
  chan->message.cursize = 0;
  chan->reliable_sequence ^= 1;
  send_reliable = true;
 }
 SZ_Init (&send, send_buf, sizeof(send_buf));
 w1 = chan->outgoing_sequence | (send_reliable<<31);
 w2 = chan->incoming_sequence | (chan->incoming_reliable_sequence<<31);
 chan->outgoing_sequence++;
 MSG_WriteLong (&send, w1);
 MSG_WriteLong (&send, w2);
 if (chan->sock == NS_CLIENT)
  MSG_WriteShort (&send, chan->qport);
 if (send_reliable) {
  SZ_Write (&send, chan->reliable_buf, chan->reliable_length);
  chan->last_reliable_sequence = chan->outgoing_sequence;
 }
 if (send.maxsize - send.cursize >= length)
  SZ_Write (&send, data, length);
 i = chan->outgoing_sequence & (32 -1);
 chan->outgoing_size[i] = send.cursize;
 chan->outgoing_time[i] = curtime;
 if (!cls.demoplayback)
  NET_SendPacket (chan->sock, send.cursize, send.data, chan->remote_address);
 if (chan->cleartime < curtime)
  chan->cleartime = curtime + send.cursize * chan->rate;
 else
  chan->cleartime += send.cursize * chan->rate;
 if (showpackets.value) {
  Print_flags[Print_current] |= 4;
  Com_Printf ("--> s=%i(%i) a=%i(%i) %i\n"
              , chan->outgoing_sequence
              , send_reliable
              , chan->incoming_sequence
              , chan->incoming_reliable_sequence
              , send.cursize);
 }
}

variable_types: i int


decompiled_code:
__int64 __fastcall Netchan_Process(const char *a1, __int64 a2)
{
const char *v2; // rbx
unsigned int v3; // er12
__int64 v4; // rdx
unsigned int v5; // ebp
unsigned int v6; // er13
unsigned int v7; // er12
unsigned int v8; // er13
unsigned int v9; // er14
unsigned int v10; // ebp
unsigned int v11; // eax
int v12; // eax
int v13; // eax
double v14; // xmm1_8
__int64 result; // rax
double v16; // xmm3_8
double v17; // xmm0_8
unsigned int v18; // er13
const char *v19; // rax
__int64 v20; // r9
unsigned int v21; // er15
const char *v22; // rax

v2 = a1;
MSG_BeginReading();
v3 = MSG_ReadLong();
v5 = MSG_ReadLong();
if ( *((_DWORD *)a1 + 1) == 1 )
MSG_ReadShort();
v6 = v3;
v7 = v3 & 0x7FFFFFFF;
v8 = v6 >> 31;
v9 = v5 >> 31;
v10 = v5 & 0x7FFFFFFF;
if ( *(float *)&showpackets[4] != 0.0 )
{
v20 = net_message[5];
a2 = v7;
a1 = "<-- s=%i(%i) a=%i(%i) %i\n";
*((_DWORD *)&Print_flags + Print_current) |= 4u;
Com_Printf("<-- s=%i(%i) a=%i(%i) %i\n", v7, v8, v10, v9, v20);
}
v11 = *((_DWORD *)v2 + 20);
if ( v11 < v7 )
{
v12 = v7 + ~v11;
*((_DWORD *)v2 + 2) = v12;
if ( v12 <= 0 || (++*((_DWORD *)v2 + 6), *(float *)&showdrop[4] == 0.0) )
{
if ( *((_DWORD *)v2 + 25) != v9 )
goto LABEL_9;
}
else
{
*((_DWORD *)&Print_flags + Print_current) |= 4u;
v21 = *((_DWORD *)v2 + 2);
v22 = (const char *)NET_AdrToString(a1, a2, v4);
Com_Printf("%s:Dropped %i packets at %i\n", v22, v21, v7);
if ( *((_DWORD *)v2 + 25) != v9 )
{
LABEL_9:
*((_DWORD *)v2 + 20) = v7;
*((_DWORD *)v2 + 21) = v10;
*((_DWORD *)v2 + 22) = v9;
if ( !v8 )
{
LABEL_10:
v13 = *((_DWORD *)v2 + 24);
++*((_DWORD *)v2 + 7);
v14 = (double)(int)(v13 - v10);
result = 1LL;
v16 = *((float *)v2 + 3);
*(float *)&v14 = v14 * 0.01000000000000001 + *((float *)v2 + 4) * 0.99;
*((_DWORD *)v2 + 4) = LODWORD(v14);
v17 = curtime;
*(float *)&v14 = curtime;
*((_DWORD *)v2 + 3) = LODWORD(v14);
*(float *)&v17 = (v17 - v16) * 0.01000000000000001 + *((float *)v2 + 5) * 0.99;
*((_DWORD *)v2 + 5) = LODWORD(v17);
return result;
}
LABEL_12:
*((_DWORD *)v2 + 23) ^= 1u;
goto LABEL_10;
}
}
*((_DWORD *)v2 + 397) = 0;
*((_DWORD *)v2 + 20) = v7;
*((_DWORD *)v2 + 21) = v10;
*((_DWORD *)v2 + 22) = v9;
if ( !v8 )
goto LABEL_10;
goto LABEL_12;
}
result = 0LL;
if ( *(float *)&showdrop[4] != 0.0 )
{
*((_DWORD *)&Print_flags + Print_current) |= 4u;
v18 = *((_DWORD *)v2 + 20);
v19 = (const char *)NET_AdrToString(a1, a2, v4);
Com_Printf("%s:Out of order packet %i at %i\n", v19, v7, v18);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(const char *a1, __int64 a2)
{
const char *v2; // rbx
unsigned int v3; // er12
__int64 v4; // rdx
unsigned int v5; // ebp
unsigned int v6; // er13
unsigned int v7; // er12
unsigned int v8; // er13
unsigned int v9; // er14
unsigned int v10; // ebp
unsigned int v11; // eax
int v12; // eax
int v13; // eax
double v14; // xmm1_8
__int64 result; // rax
double v16; // xmm3_8
double v17; // xmm0_8
unsigned int v18; // er13
const char *v19; // rax
__int64 v20; // r9
unsigned int v21; // er15
const char *v22; // rax

v2 = a1;
MSG_BeginReading();
v3 = MSG_ReadLong();
v5 = MSG_ReadLong();
if ( *((_DWORD *)a1 + 1) == 1 )
MSG_ReadShort();
v6 = v3;
v7 = v3 & 0x7FFFFFFF;
v8 = v6 >> 31;
v9 = v5 >> 31;
v10 = v5 & 0x7FFFFFFF;
if ( *(float *)&showpackets[4] != 0.0 )
{
v20 = net_message[5];
a2 = v7;
a1 = "<-- s=%i(%i) a=%i(%i) %i\n";
*((_DWORD *)&Print_flags + Print_current) |= 4u;
Com_Printf("<-- s=%i(%i) a=%i(%i) %i\n", v7, v8, v10, v9, v20);
}
v11 = *((_DWORD *)v2 + 20);
if ( v11 < v7 )
{
v12 = v7 + ~v11;
*((_DWORD *)v2 + 2) = v12;
if ( v12 <= 0 || (++*((_DWORD *)v2 + 6), *(float *)&showdrop[4] == 0.0) )
{
if ( *((_DWORD *)v2 + 25) != v9 )
goto LABEL_9;
}
else
{
*((_DWORD *)&Print_flags + Print_current) |= 4u;
v21 = *((_DWORD *)v2 + 2);
v22 = (const char *)NET_AdrToString(a1, a2, v4);
Com_Printf("%s:Dropped %i packets at %i\n", v22, v21, v7);
if ( *((_DWORD *)v2 + 25) != v9 )
{
LABEL_9:
*((_DWORD *)v2 + 20) = v7;
*((_DWORD *)v2 + 21) = v10;
*((_DWORD *)v2 + 22) = v9;
if ( !v8 )
{
LABEL_10:
v13 = *((_DWORD *)v2 + 24);
++*((_DWORD *)v2 + 7);
v14 = (double)(int)(v13 - v10);
result = 1LL;
v16 = *((float *)v2 + 3);
*(float *)&v14 = v14 * 0.01000000000000001 + *((float *)v2 + 4) * 0.99;
*((_DWORD *)v2 + 4) = LODWORD(v14);
v17 = curtime;
*(float *)&v14 = curtime;
*((_DWORD *)v2 + 3) = LODWORD(v14);
*(float *)&v17 = (v17 - v16) * 0.01000000000000001 + *((float *)v2 + 5) * 0.99;
*((_DWORD *)v2 + 5) = LODWORD(v17);
return result;
}
LABEL_12:
*((_DWORD *)v2 + 23) ^= 1u;
goto LABEL_10;
}
}
*((_DWORD *)v2 + 397) = 0;
*((_DWORD *)v2 + 20) = v7;
*((_DWORD *)v2 + 21) = v10;
*((_DWORD *)v2 + 22) = v9;
if ( !v8 )
goto LABEL_10;
goto LABEL_12;
}
result = 0LL;
if ( *(float *)&showdrop[4] != 0.0 )
{
*((_DWORD *)&Print_flags + Print_current) |= 4u;
v18 = *((_DWORD *)v2 + 20);
v19 = (const char *)NET_AdrToString(a1, a2, v4);
Com_Printf("%s:Out of order packet %i at %i\n", v19, v7, v18);
result = 0LL;
}
return result;
}

original_code:
qbool Netchan_Process (netchan_t *chan)
{
 unsigned sequence, sequence_ack, reliable_ack, reliable_message;
 MSG_BeginReading ();
 sequence = MSG_ReadLong ();
 sequence_ack = MSG_ReadLong ();
 if (chan->sock == NS_SERVER)
  MSG_ReadShort ();
 reliable_message = sequence >> 31;
 reliable_ack = sequence_ack >> 31;
 sequence &= ~(1 << 31);
 sequence_ack &= ~(1 << 31);
 if (showpackets.value) {
  Print_flags[Print_current] |= 4;
  Com_Printf ("<-- s=%i(%i) a=%i(%i) %i\n"
              , sequence
              , reliable_message
              , sequence_ack
              , reliable_ack
              , net_message.cursize);
 }
 if (sequence <= (unsigned)chan->incoming_sequence) {
  if (showdrop.value) {
   Print_flags[Print_current] |= 4;
   Com_Printf ("%s:Out of order packet %i at %i\n"
               , NET_AdrToString (chan->remote_address)
               , sequence
               , chan->incoming_sequence);
  }
  return false;
 }
 chan->dropped = sequence - (chan->incoming_sequence+1);
 if (chan->dropped > 0) {
  chan->drop_count += 1;
  if (showdrop.value) {
   Print_flags[Print_current] |= 4;
   Com_Printf ("%s:Dropped %i packets at %i\n"
               , NET_AdrToString (chan->remote_address)
               , chan->dropped
               , sequence);
  }
 }
 if (reliable_ack == (unsigned)chan->reliable_sequence)
  chan->reliable_length = 0;
 chan->incoming_sequence = sequence;
 chan->incoming_acknowledged = sequence_ack;
 chan->incoming_reliable_acknowledged = reliable_ack;
 if (reliable_message)
  chan->incoming_reliable_sequence ^= 1;
 chan->frame_latency = chan->frame_latency*0.99
                       + (chan->outgoing_sequence-sequence_ack)*(1.0-0.99);
 chan->frame_rate = chan->frame_rate*0.99
                    + (curtime - chan->last_received)*(1.0-0.99);
 chan->good_count += 1;
 chan->last_received = curtime;
 return true;
}

canonical_original_code:
enum qbool Netchan_Process(struct netchan_t *chan)
{
 unsigned int sequence; unsigned int sequence_ack; unsigned int reliable_ack; unsigned int reliable_message;
 MSG_BeginReading ();
 sequence = MSG_ReadLong ();
 sequence_ack = MSG_ReadLong ();
 if (chan->sock == NS_SERVER)
  MSG_ReadShort ();
 reliable_message = sequence >> 31;
 reliable_ack = sequence_ack >> 31;
 sequence &= ~(1 << 31);
 sequence_ack &= ~(1 << 31);
 if (showpackets.value) {
  Print_flags[Print_current] |= 4;
  Com_Printf ("<-- s=%i(%i) a=%i(%i) %i\n"
              , sequence
              , reliable_message
              , sequence_ack
              , reliable_ack
              , net_message.cursize);
 }
 if (sequence <= (unsigned int)chan->incoming_sequence) {
  if (showdrop.value) {
   Print_flags[Print_current] |= 4;
   Com_Printf ("%s:Out of order packet %i at %i\n"
               , NET_AdrToString (chan->remote_address)
               , sequence
               , chan->incoming_sequence);
  }
  return false;
 }
 chan->dropped = sequence - (chan->incoming_sequence+1);
 if (chan->dropped > 0) {
  chan->drop_count += 1;
  if (showdrop.value) {
   Print_flags[Print_current] |= 4;
   Com_Printf ("%s:Dropped %i packets at %i\n"
               , NET_AdrToString (chan->remote_address)
               , chan->dropped
               , sequence);
  }
 }
 if (reliable_ack == (unsigned int)chan->reliable_sequence)
  chan->reliable_length = 0;
 chan->incoming_sequence = sequence;
 chan->incoming_acknowledged = sequence_ack;
 chan->incoming_reliable_acknowledged = reliable_ack;
 if (reliable_message)
  chan->incoming_reliable_sequence ^= 1;
 chan->frame_latency = chan->frame_latency*0.99
                       + (chan->outgoing_sequence-sequence_ack)*(1.0-0.99);
 chan->frame_rate = chan->frame_rate*0.99
                    + (curtime - chan->last_received)*(1.0-0.99);
 chan->good_count += 1;
 chan->last_received = curtime;
 return true;
}

variable_types:
sequence
unsigned int


decompiled_code:
__int64 Netchan_Init()
{
unsigned int v0; // eax
unsigned __int16 v1; // bx

v0 = time(0LL);
srand(v0);
v1 = rand();
Cvar_SetCurrentGroup("Screen Settings");
Cvar_Register(showpackets);
Cvar_Register(showdrop);
Cvar_SetCurrentGroup("#No Group#");
Cvar_Register(qport);
Cvar_ResetCurrentGroup();
return Cvar_SetValue(qport, (float)v1);
}

canonical_decompiled_code:
__int64 func0()
{
unsigned int v0; // eax
unsigned __int16 v1; // bx

v0 = time(0LL);
srand(v0);
v1 = rand();
Cvar_SetCurrentGroup("Screen Settings");
Cvar_Register(showpackets);
Cvar_Register(showdrop);
Cvar_SetCurrentGroup("#No Group#");
Cvar_Register(qport);
Cvar_ResetCurrentGroup();
return Cvar_SetValue(qport, (float)v1);
}

original_code:
void Netchan_Init (void)
{
 int port = 0xffff;
 srand((unsigned)time(((void *)0)));
 port &= rand();
 Cvar_SetCurrentGroup("Screen Settings");
 Cvar_Register (&showpackets);
 Cvar_Register (&showdrop);
 Cvar_SetCurrentGroup("#No Group#");
 Cvar_Register (&qport);
 Cvar_ResetCurrentGroup();
 Cvar_SetValue (&qport, port);
}

canonical_original_code:
void Netchan_Init()
{
 int port = 0xffff;
 srand((unsigned int)time(((void *)0)));
 port &= rand();
 Cvar_SetCurrentGroup("Screen Settings");
 Cvar_Register (&showpackets);
 Cvar_Register (&showdrop);
 Cvar_SetCurrentGroup("#No Group#");
 Cvar_Register (&qport);
 Cvar_ResetCurrentGroup();
 Cvar_SetValue (&qport, port);
}

variable_types: port int


decompiled_code:
__int64 __fastcall VFSMMAP_Tell(__int64 a1)
{
return *(_QWORD *)(a1 + 72);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
return *(_QWORD *)(a1 + 72);
}

original_code:
static unsigned long VFSMMAP_Tell(vfsfile_t *file)
{
 vfsmmapfile_t *intfile = (vfsmmapfile_t *)file;
 return intfile->position;
}

canonical_original_code:
static unsigned long VFSMMAP_Tell(struct vfsfile_s *file)
{
 struct vfsmmapfile_t *intfile = (vfsmmapfile_t *)file;
 return intfile->position;
}

variable_types: struct vfsfile_s { int (*ReadBytes)(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *err); int (*WriteBytes)(struct vfsfile_s *file, void *buffer, int bytestowrite); int (*Seek)(struct vfsfile_s *file, unsigned long pos, int whence); unsigned long (*Tell)(struct vfsfile_s *file); unsigned long (*GetLen)(struct vfsfile_s *file); void (*Close)(struct vfsfile_s *file); void (*Flush)(struct vfsfile_s *file); enum qbool { false=0, true=1 } seekingisabadplan; enum qbool { false=0, true=1 } copyprotected; } *

variable_types: struct vfsmmapfile_t { struct vfsfile_s { int (*ReadBytes)(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *err); int (*WriteBytes)(struct vfsfile_s *file, void *buffer, int bytestowrite); int (*Seek)(struct vfsfile_s *file, unsigned long pos, int whence); unsigned long (*Tell)(struct vfsfile_s *file); unsigned long (*GetLen)(struct vfsfile_s *file); void (*Close)(struct vfsfile_s *file); void (*Flush)(struct vfsfile_s *file); enum qbool { false=0, true=1 } seekingisabadplan; enum qbool { false=0, true=1 } copyprotected; } funcs; unsigned char *handle; unsigned long position; unsigned long len; } *

user_defined_types: struct vfsmmapfile_t { struct vfsfile_s funcs; unsigned char *handle; unsigned long position; unsigned long len; }


decompiled_code:
__int64 __fastcall VFSMMAP_GetLen(__int64 a1)
{
return *(_QWORD *)(a1 + 80);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return *(_QWORD *)(a1 + 80);
}

original_code:
static unsigned long VFSMMAP_GetLen(vfsfile_t *file)
{
 vfsmmapfile_t *intfile = (vfsmmapfile_t *)file;
 return intfile->len;
}

canonical_original_code:
static unsigned long VFSMMAP_GetLen(struct vfsfile_s *file)
{
 struct vfsmmapfile_t *intfile = (vfsmmapfile_t *)file;
 return intfile->len;
}


decompiled_code:
__int64 VFSMMAP_Flush()
{
return Sys_Error("VFSMMAP_Flush: Invalid operation\n");
}

canonical_decompiled_code:
__int64 func2()
{
return Sys_Error("VFSMMAP_Flush: Invalid operation\n");
}

original_code:
static void VFSMMAP_Flush(vfsfile_t *file)
{
 vfsmmapfile_t *intfile = (vfsmmapfile_t *)file;
 (void)intfile;
 Sys_Error("VFSMMAP_Flush: Invalid operation\n");
}

canonical_original_code:
static void VFSMMAP_Flush(struct vfsfile_s *file)
{
 struct vfsmmapfile_t *intfile = (vfsmmapfile_t *)file;
 (void)intfile;
 Sys_Error("VFSMMAP_Flush: Invalid operation\n");
}


decompiled_code:
__int64 __fastcall VFSMMAP_Seek(__int64 a1, unsigned __int64 a2, unsigned int a3)
{
unsigned __int64 v3; // rax
unsigned __int64 v5; // rdx

v3 = a2;
if ( a3 == 1 )
{
v3 = *(_QWORD *)(a1 + 72) + a2;
LABEL_6:
*(_QWORD *)(a1 + 72) = v3;
v5 = *(_QWORD *)(a1 + 80);
goto LABEL_7;
}
if ( a3 != 2 )
{
if ( a3 )
{
Sys_Error("VFSMMAP_Seek: Unknown whence value(%d)\n", a3);
return 0xFFFFFFFFLL;
}
goto LABEL_6;
}
v5 = *(_QWORD *)(a1 + 80);
v3 = v5 + a2;
*(_QWORD *)(a1 + 72) = v5 + a2;
LABEL_7:
if ( v5 >= v3 )
return 0LL;
*(_QWORD *)(a1 + 72) = v5;
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned __int64 a2, unsigned int a3)
{
unsigned __int64 v3; // rax
unsigned __int64 v5; // rdx

v3 = a2;
if ( a3 == 1 )
{
v3 = *(_QWORD *)(a1 + 72) + a2;
LABEL_6:
*(_QWORD *)(a1 + 72) = v3;
v5 = *(_QWORD *)(a1 + 80);
goto LABEL_7;
}
if ( a3 != 2 )
{
if ( a3 )
{
Sys_Error("VFSMMAP_Seek: Unknown whence value(%d)\n", a3);
return 0xFFFFFFFFLL;
}
goto LABEL_6;
}
v5 = *(_QWORD *)(a1 + 80);
v3 = v5 + a2;
*(_QWORD *)(a1 + 72) = v5 + a2;
LABEL_7:
if ( v5 >= v3 )
return 0LL;
*(_QWORD *)(a1 + 72) = v5;
return 0xFFFFFFFFLL;
}

original_code:
static int VFSMMAP_Seek(vfsfile_t *file, unsigned long offset, int whence)
{
 vfsmmapfile_t *intfile = (vfsmmapfile_t *)file;
 switch(whence)
 {
  case 0:
   intfile->position = offset;
   break;
  case 1:
   intfile->position += offset;
   break;
  case 2:
   intfile->position = intfile->len + offset;
   break;
  default:
   Sys_Error("VFSMMAP_Seek: Unknown whence value(%d)\n", whence);
   return -1;
 }
 if ((intfile->position < 0) || (intfile->position > intfile->len))
 {
  (intfile->position = ((((intfile->position) > (0) ? (intfile->position) : (0))) < (intfile->len) ? (((intfile->position) > (0) ? (intfile->position) : (0))) : (intfile->len)));
  return -1;
 }
 return 0;
}

canonical_original_code:
static int VFSMMAP_Seek(struct vfsfile_s *file, unsigned long offset, int whence)
{
 struct vfsmmapfile_t *intfile = (vfsmmapfile_t *)file;
 switch(whence)
 {
  case 0:
   intfile->position = offset;
   break;
  case 1:
   intfile->position += offset;
   break;
  case 2:
   intfile->position = intfile->len + offset;
   break;
  default:
   Sys_Error("VFSMMAP_Seek: Unknown whence value(%d)\n", whence);
   return -1;
 }
 if ((intfile->position < 0) || (intfile->position > intfile->len))
 {
  (intfile->position = ((((intfile->position) > (0) ? (intfile->position) : (0))) < (intfile->len) ? (((intfile->position) > (0) ? (intfile->position) : (0))) : (intfile->len)));
  return -1;
 }
 return 0;
}

variable_types:
offset
unsigned long

variable_types: whence int


decompiled_code:
void __fastcall VFSMMAP_Close(void *ptr)
{
free(*((void **)ptr + 8));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
free(*((void **)ptr + 8));
free(ptr);
}

original_code:
static void VFSMMAP_Close(vfsfile_t *file)
{
 vfsmmapfile_t *intfile = (vfsmmapfile_t *)file;
 free(intfile->handle);
 free(intfile);
}

canonical_original_code:
static void VFSMMAP_Close(struct vfsfile_s *file)
{
 struct vfsmmapfile_t *intfile = (vfsmmapfile_t *)file;
 free(intfile->handle);
 free(intfile);
}


decompiled_code:
__int64 __fastcall VFSMMAP_WriteBytes(_QWORD *a1, const void *a2, unsigned int a3)
{
size_t v3; // r13
__int64 v7; // rax
char *v8; // rdi
size_t v9; // rsi
char *v10; // rax

v3 = (int)a3;
v7 = a1[9];
v8 = (char *)a1[8];
v9 = (int)a3 + v7;
if ( v9 <= a1[10] )
goto LABEL_4;
v10 = (char *)realloc(v8, v9);
v8 = v10;
if ( v10 )
{
a1[8] = v10;
v7 = a1[9];
LABEL_4:
memcpy(&v8[v7], a2, v3);
a1[9] += v3;
return a3;
}
Com_Printf("VFSMMAP_WriteBytes: Unable to write to file, memory full\n");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(_QWORD *a1, const void *a2, unsigned int a3)
{
size_t v3; // r13
__int64 v7; // rax
char *v8; // rdi
size_t v9; // rsi
char *v10; // rax

v3 = (int)a3;
v7 = a1[9];
v8 = (char *)a1[8];
v9 = (int)a3 + v7;
if ( v9 <= a1[10] )
goto LABEL_4;
v10 = (char *)realloc(v8, v9);
v8 = v10;
if ( v10 )
{
a1[8] = v10;
v7 = a1[9];
LABEL_4:
memcpy(&v8[v7], a2, v3);
a1[9] += v3;
return a3;
}
Com_Printf("VFSMMAP_WriteBytes: Unable to write to file, memory full\n");
return 0LL;
}

original_code:
static int VFSMMAP_WriteBytes(vfsfile_t *file, const void *buffer, int bytestowrite)
{
 vfsmmapfile_t *intfile = (vfsmmapfile_t *)file;
 if (bytestowrite + intfile->position > intfile->len) {
  size_t newlen = bytestowrite + intfile->position;
  void *p = realloc(intfile->handle, newlen);
  if (!p) {
   Com_Printf("VFSMMAP_WriteBytes: Unable to write to file, memory full\n");
   return 0;
  }
  intfile->handle = p;
 }
 memcpy(intfile->handle + intfile->position, buffer, bytestowrite);
 intfile->position += bytestowrite;
 return bytestowrite;
}

canonical_original_code:
static int VFSMMAP_WriteBytes(struct vfsfile_s *file, void *buffer, int bytestowrite)
{
 struct vfsmmapfile_t *intfile = (vfsmmapfile_t *)file;
 if (bytestowrite + intfile->position > intfile->len) {
  unsigned long newlen = bytestowrite + intfile->position;
  void *p = realloc(intfile->handle, newlen);
  if (!p) {
   Com_Printf("VFSMMAP_WriteBytes: Unable to write to file, memory full\n");
   return 0;
  }
  intfile->handle = p;
 }
 memcpy(intfile->handle + intfile->position, buffer, bytestowrite);
 intfile->position += bytestowrite;
 return bytestowrite;
}

variable_types:
buffer
void *

variable_types: bytestowrite int

variable_types:
newlen
unsigned long

variable_types:
p
void *


decompiled_code:
__int64 __fastcall VFSMMAP_ReadBytes(_QWORD *a1, void *a2, int a3, _DWORD *a4)
{
int v5; // er12
__int64 v7; // rsi
size_t v8; // r13
unsigned __int64 v9; // rax

v5 = a3;
if ( a3 < 0 )
Sys_Error("VFSMMAP_ReadBytes: bytestoread < 0");
v7 = a1[9];
v8 = v5;
v9 = a1[10];
if ( v5 + v7 > v9 )
{
v5 = v9 - v7;
v8 = (int)v9 - (int)v7;
}
memcpy(a2, (const void *)(a1[8] + v7), v8);
a1[9] += v8;
if ( a4 )
*a4 = v5 == 0;
return (unsigned int)v5;
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1, void *a2, int a3, _DWORD *a4)
{
int v5; // er12
__int64 v7; // rsi
size_t v8; // r13
unsigned __int64 v9; // rax

v5 = a3;
if ( a3 < 0 )
Sys_Error("VFSMMAP_ReadBytes: bytestoread < 0");
v7 = a1[9];
v8 = v5;
v9 = a1[10];
if ( v5 + v7 > v9 )
{
v5 = v9 - v7;
v8 = (int)v9 - (int)v7;
}
memcpy(a2, (const void *)(a1[8] + v7), v8);
a1[9] += v8;
if ( a4 )
*a4 = v5 == 0;
return (unsigned int)v5;
}

original_code:
static int VFSMMAP_ReadBytes(vfsfile_t *file, void *buffer, int bytestoread, vfserrno_t *err)
{
 vfsmmapfile_t *intfile = (vfsmmapfile_t *)file;
 if (bytestoread < 0)
  Sys_Error("VFSMMAP_ReadBytes: bytestoread < 0");
 if ((bytestoread + intfile->position) > intfile->len) {
  bytestoread = ((0) > (intfile->len - intfile->position) ? (0) : (intfile->len - intfile->position));
 }
 memcpy(buffer, intfile->handle + intfile->position, bytestoread);
 intfile->position += bytestoread;
 if (err)
  *err = (bytestoread == 0) ? VFSERR_EOF : VFSERR_NONE;
 return bytestoread;
}

canonical_original_code:
static int VFSMMAP_ReadBytes(struct vfsfile_s *file, void *buffer, int bytestoread, enum vfserrno_t *err)
{
 struct vfsmmapfile_t *intfile = (vfsmmapfile_t *)file;
 if (bytestoread < 0)
  Sys_Error("VFSMMAP_ReadBytes: bytestoread < 0");
 if ((bytestoread + intfile->position) > intfile->len) {
  bytestoread = ((0) > (intfile->len - intfile->position) ? (0) : (intfile->len - intfile->position));
 }
 memcpy(buffer, intfile->handle + intfile->position, bytestoread);
 intfile->position += bytestoread;
 if (err)
  *err = (bytestoread == 0) ? VFSERR_EOF : VFSERR_NONE;
 return bytestoread;
}

variable_types: bytestoread int

variable_types: enum vfserrno_t { VFSERR_NONE=0, VFSERR_EOF=1 } *


CameraRandomPoint

original_code:
void CameraRandomPoint (vec3_t org)
{
 vec3_t stop, normal, dest, forward, right, up, vec;
 dest[0] = org[0] + (rand() % 500 - 250);
 dest[1] = org[1] + (rand() % 500 - 250);
 dest[2] = org[2] + (rand() % 100 + 50);
 CL_TraceLine (org, dest, stop, normal);
 ((vec)[0] = (org)[0] - (stop)[0], (vec)[1] = (org)[1] - (stop)[1], (vec)[2] = (org)[2] - (stop)[2]);
 AngleVectors (vec, forward, right, up);
 if (!((dest)[0] == (stop)[0] && (dest)[1] == (stop)[1] && (dest)[2] == (stop)[2])) {
  dest[0] = stop[0] + forward[0] * 15 + normal[0] * 15;
  dest[1] = stop[1] + forward[1] * 15 + normal[1] * 15;
  dest[2] = stop[2] + forward[2] * 15 + normal[2] * 15;
 }
 ((camera_pos)[0] = (dest)[0], (camera_pos)[1] = (dest)[1], (camera_pos)[2] = (dest)[2]);
}

canonical_original_code:
void CameraRandomPoint(float org[3])
{
 float stop[3]; float normal[3]; float dest[3]; float forward[3]; float right[3]; float up[3]; float vec[3];
 dest[0] = org[0] + (rand() % 500 - 250);
 dest[1] = org[1] + (rand() % 500 - 250);
 dest[2] = org[2] + (rand() % 100 + 50);
 CL_TraceLine (org, dest, stop, normal);
 ((vec)[0] = (org)[0] - (stop)[0], (vec)[1] = (org)[1] - (stop)[1], (vec)[2] = (org)[2] - (stop)[2]);
 AngleVectors (vec, forward, right, up);
 if (!((dest)[0] == (stop)[0] && (dest)[1] == (stop)[1] && (dest)[2] == (stop)[2])) {
  dest[0] = stop[0] + forward[0] * 15 + normal[0] * 15;
  dest[1] = stop[1] + forward[1] * 15 + normal[1] * 15;
  dest[2] = stop[2] + forward[2] * 15 + normal[2] * 15;
 }
 ((camera_pos)[0] = (dest)[0], (camera_pos)[1] = (dest)[1], (camera_pos)[2] = (dest)[2]);
}

variable_types:
org
float [3]

variable_types:
stop
float [3]

variable_types:
normal
float [3]

variable_types:
dest
float [3]

variable_types:
forward
float [3]

variable_types:
right
float [3]

variable_types:
up
float [3]

variable_types:
vec
float [3]