freeDisableLists

decompiled_code:
__int64 freeDisableLists()
{
__int64 result; // rax
regex_t *v1; // rdi

LABEL_1:
result = (unsigned int)maxdisable_cmds[0];
while ( (_DWORD)result )
{
maxdisable_cmds[0] = result - 1;
gi[34](*((const char **)&disablecmds + 3 * (int)result - 3));
result = maxdisable_cmds[0];
v1 = (regex_t *)*((_QWORD *)&disablecmds + 3 * maxdisable_cmds[0] + 2);
if ( v1 )
{
regfree(v1);
gi[34](*((const char **)&disablecmds + 3 * maxdisable_cmds[0] + 2));
goto LABEL_1;
}
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 result; // rax
regex_t *v1; // rdi

LABEL_1:
result = (unsigned int)maxdisable_cmds[0];
while ( (_DWORD)result )
{
maxdisable_cmds[0] = result - 1;
gi[34](*((const char **)&disablecmds + 3 * (int)result - 3));
result = maxdisable_cmds[0];
v1 = (regex_t *)*((_QWORD *)&disablecmds + 3 * maxdisable_cmds[0] + 2);
if ( v1 )
{
regfree(v1);
gi[34](*((const char **)&disablecmds + 3 * maxdisable_cmds[0] + 2));
goto LABEL_1;
}
}
return result;
}

original_code:
void freeDisableLists(void) {
    while (maxdisable_cmds) {
        maxdisable_cmds--;
        gi.TagFree(disablecmds[maxdisable_cmds].disablecmd);
        if (disablecmds[maxdisable_cmds].r) {
            regfree(disablecmds[maxdisable_cmds].r);
            gi.TagFree(disablecmds[maxdisable_cmds].r);
        }
    }
}

canonical_original_code:
void freeDisableLists() {
    while (maxdisable_cmds) {
        maxdisable_cmds--;
        gi.TagFree(disablecmds[maxdisable_cmds].disablecmd);
        if (disablecmds[maxdisable_cmds].r) {
            regfree(disablecmds[maxdisable_cmds].r);
            gi.TagFree(disablecmds[maxdisable_cmds].r);
        }
    }
}


readDisableLists

decompiled_code:
__int64 readDisableLists()
{
int v0; // ebx
__int64 result; // rax
__int64 v2; // rax

freeDisableLists();
v0 = ReadDisableFile(*(const char **)(configfile_disable + 8LL));
Q_snprintf(&buffer, 0x10000LL, "%s/%s", (const char *)&moddir, *(const char **)(configfile_disable + 8LL));
result = v0 | (unsigned int)ReadDisableFile(&buffer);
if ( !(_DWORD)result )
{
((void (*)(_QWORD, __int64, const char *, ...))gi[2])(
0LL,
2LL,
"WARNING: %s could not be found\n",
*(const char **)(configfile_disable + 8LL));
v2 = va("%s could not be found", *(const char **)(configfile_disable + 8LL));
result = logEvent(17LL, 0LL, 0LL, v2, 17LL, 0.0);
}
return result;
}

canonical_decompiled_code:
__int64 func2()
{
int v0; // ebx
__int64 result; // rax
__int64 v2; // rax

func1();
v0 = func0(*(const char **)(configfile_disable + 8LL));
Q_snprintf(&buffer, 0x10000LL, "%s/%s", (const char *)&moddir, *(const char **)(configfile_disable + 8LL));
result = v0 | (unsigned int)func0(&buffer);
if ( !(_DWORD)result )
{
((void (*)(_QWORD, __int64, const char *, ...))gi[2])(
0LL,
2LL,
"WARNING: %s could not be found\n",
*(const char **)(configfile_disable + 8LL));
v2 = va("%s could not be found", *(const char **)(configfile_disable + 8LL));
result = logEvent(17LL, 0LL, 0LL, v2, 17LL, 0.0);
}
return result;
}

original_code:
void readDisableLists(void) {
    qboolean ret;
    freeDisableLists();
    ret = ReadDisableFile(configfile_disable->string);
    Q_snprintf(buffer, sizeof(buffer), "%s/%s", moddir, configfile_disable->string);
    if (ReadDisableFile(buffer)) {
        ret = 1;
    }
    if (!ret) {
        gi.cprintf(((void *)0), 2, "WARNING: %s could not be found\n", configfile_disable->string);
        logEvent(LT_INTERNALWARN, 0, ((void *)0), va("%s could not be found", configfile_disable->string), 17, 0.0);
    }
}

canonical_original_code:
void readDisableLists() {
    enum qboolean ret;
    freeDisableLists();
    ret = ReadDisableFile(configfile_disable->string);
    Q_snprintf(buffer, sizeof(buffer), "%s/%s", moddir, configfile_disable->string);
    if (ReadDisableFile(buffer)) {
        ret = 1;
    }
    if (!ret) {
        gi.cprintf(((void *)0), 2, "WARNING: %s could not be found\n", configfile_disable->string);
        logEvent(LT_INTERNALWARN, 0, ((void *)0), va("%s could not be found", configfile_disable->string), 17, 0.0);
    }
}

variable_types:
ret
enum qboolean { qfalse=0, qtrue=1 }

return_type: void


reloadDisableFileRun

decompiled_code:
__int64 __fastcall reloadDisableFileRun(__int64 a1, __int64 a2)
{
readDisableLists();
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(a2, 2LL, "Disbled commands reloaded.\n");
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
func2();
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(a2, 2LL, "Disbled commands reloaded.\n");
}

original_code:
void reloadDisableFileRun(int startarg, edict_t *ent, int client) {
    readDisableLists();
    gi.cprintf(ent, 2, "Disbled commands reloaded.\n");
}

canonical_original_code:
void reloadDisableFileRun(int startarg, struct edict_s *ent, int client) {
    readDisableLists();
    gi.cprintf(ent, 2, "Disbled commands reloaded.\n");
}

variable_types: startarg int

variable_types: struct edict_s { struct entity_state_s { int number; float origin[3]; float angles[3]; float old_origin[3]; int modelindex; int modelindex2; int frame; int skinnum; int effects; int renderfx; int solid; int sound; int event; } s; struct gclient_s { struct player_state_t { struct pmove_state_t { enum pmtype_t { PM_NORMAL=0, PM_SPECTATOR=1, PM_DEAD=2, PM_GIB=3, PM_FREEZE=4 } pm_type; short origin[3]; short velocity[3]; unsigned char pm_flags; unsigned char pm_time; short gravity; short delta_angles[3]; } pmove; float viewangles[3]; float viewoffset[3]; float kick_angles[3]; float gunangles[3]; float gunoffset[3]; int gunindex; int gunframe; float blend[4]; float fov; int rdflags; short stats[32]; } ps; int ping; struct client_persistant_t { char userinfo[512]; char netname[16]; int hand; enum qboolean { qfalse=0, qtrue=1 } connected; int health; int max_health; int savedFlags; int selected_item; int inventory[256]; int max_bullets; int max_shells; int max_rockets; int max_grenades; int max_cells; int max_slugs; struct gitem_s { char *classname; enum qboolean { qfalse=0, qtrue=1 } (*pickup)(struct edict_s *ent, struct edict_s *other); void (*use)(struct edict_s *ent, struct gitem_s *item); void (*drop)(struct edict_s *ent, struct gitem_s *item); void (*weaponthink)(struct edict_s *ent); char *pickup_sound; char *world_model; int world_model_flags; char *view_model; char *icon; char *pickup_name; int count_width; int quantity; char *ammo; int flags; int weapmodel; void *info; int tag; char *precaches; } *weapon; struct gitem_s *lastweapon; int power_cubes; int score; int game_helpchanged; int helpchanged; enum qboolean { qfalse=0, qtrue=1 } spectator; } pers; struct client_respawn_t { struct client_persistant_t coop_respawn; int enterframe; int score; float cmd_angles[3]; enum qboolean { qfalse=0, qtrue=1 } spectator; } resp; struct pmove_state_t old_pmove; enum qboolean { qfalse=0, qtrue=1 } showscores; enum qboolean { qfalse=0, qtrue=1 } showinventory; enum qboolean { qfalse=0, qtrue=1 } showhelp; enum qboolean { qfalse=0, qtrue=1 } showhelpicon; int ammo_index; int buttons; int oldbuttons; int latched_buttons; enum qboolean { qfalse=0, qtrue=1 } weapon_thunk; struct gitem_s *newweapon; int damage_armor; int damage_parmor; int damage_blood; int damage_knockback; float damage_from[3]; float killer_yaw; enum weaponstate_t { WEAPON_READY=0, WEAPON_ACTIVATING=1, WEAPON_DROPPING=2, WEAPON_FIRING=3 } weaponstate; float kick_angles[3]; float kick_origin[3]; float v_dmg_roll; float fall_time; float damage_alpha; float bonus_alpha; float damage_blend[3]; float v_angle[3]; float bobtime; float oldviewangles[3]; float oldvelocity[3]; float next_drown_time; int old_waterlevel; int breather_sound; int machinegun_shots; int anim_end; int anim_priority; enum qboolean { qfalse=0, qtrue=1 } anim_duck; enum qboolean { qfalse=0, qtrue=1 } anim_run; int quad_framenum; int invincible_framenum; int breather_framenum; int enviro_framenum; enum qboolean { qfalse=0, qtrue=1 } grenade_blew_up; float grenade_time; int silencer_shots; int weapon_sound; float pickup_msg_time; float flood_locktill; float flood_when[10]; int flood_whenhead; float respawn_time; struct edict_s *chase_target; enum qboolean { qfalse=0, qtrue=1 } update_chase; } *client; enum qboolean { qfalse=0, qtrue=1 } inuse; int linkcount; struct link_s { struct link_s *prev; } area; int num_clusters; int clusternums[16]; int headnode; int areanum; int svflags; float mins[3]; float absmin[3]; enum solid_t { SOLID_NOT=0, SOLID_TRIGGER=1, SOLID_BBOX=2, SOLID_BSP=3 } solid; int clipmask; struct edict_s *owner; int movetype; int flags; char *model; float freetime; char *message; char *classname; int spawnflags; float timestamp; float angle; char *target; char *targetname; char *killtarget; char *team; char *pathtarget; char *deathtarget; char *combattarget; struct edict_s *target_ent; float speed; float movedir[3]; float pos1[3]; float velocity[3]; float avelocity[3]; int mass; float air_finished; float gravity; struct edict_s *goalentity; struct edict_s *movetarget; float yaw_speed; float ideal_yaw; float nextthink; void (*prethink)(struct edict_s *ent); void (*think)(struct edict_s *self); void (*blocked)(struct edict_s *self, struct edict_s *other); void (*touch)(struct edict_s *self, struct edict_s *other, struct cplane_s { float normal[3]; float dist; unsigned char type; unsigned char signbits; unsigned char pad[2]; } *plane, struct csurface_s { char name[16]; int flags; int value; } *surf); void (*use)(struct edict_s *self, struct edict_s *other, struct edict_s *activator); void (*pain)(struct edict_s *self, struct edict_s *other, float kick, int damage); void (*die)(struct edict_s *self, struct edict_s *inflictor, struct edict_s *attacker, int damage, float point[3]); float touch_debounce_time; float pain_debounce_time; float damage_debounce_time; float fly_sound_debounce_time; float last_move_time; int health; int max_health; int gib_health; int deadflag; enum qboolean { qfalse=0, qtrue=1 } show_hostile; float powerarmor_time; char *map; int viewheight; int takedamage; int dmg; int radius_dmg; float dmg_radius; int sounds; int count; struct edict_s *chain; struct edict_s *enemy; struct edict_s *oldenemy; struct edict_s *activator; struct edict_s *groundentity; int groundentity_linkcount; struct edict_s *teamchain; struct edict_s *teammaster; struct edict_s *mynoise; struct edict_s *mynoise2; int noise_index; int noise_index2; float volume; float attenuation; float wait; float delay; float random; float teleport_time; int watertype; int waterlevel; float move_origin[3]; float move_angles[3]; int light_level; int style; struct gitem_s *item; struct moveinfo_t { float start_origin[3]; float start_angles[3]; float end_origin[3]; float end_angles[3]; int sound_start; int sound_middle; int sound_end; float accel; float speed; float decel; float distance; float wait; int state; float dir[3]; float current_speed; float move_speed; float next_speed; float remaining_distance; float decel_distance; void (*endfunc)(struct edict_s *); } moveinfo; struct monsterinfo_t { struct mmove_t { int firstframe; int lastframe; struct mframe_t { void (*aifunc)(struct edict_s *self, float dist); float dist; void (*thinkfunc)(struct edict_s *self); } *frame; void (*endfunc)(struct edict_s *self); } *currentmove; int aiflags; int nextframe; float scale; void (*stand)(struct edict_s *self); void (*idle)(struct edict_s *self); void (*search)(struct edict_s *self); void (*walk)(struct edict_s *self); void (*run)(struct edict_s *self); void (*dodge)(struct edict_s *self, struct edict_s *other, float eta); void (*attack)(struct edict_s *self); void (*melee)(struct edict_s *self); void (*sight)(struct edict_s *self, struct edict_s *other); enum qboolean { qfalse=0, qtrue=1 } (*checkattack)(struct edict_s *self); float pausetime; float attack_finished; float saved_goal[3]; float search_time; float trail_time; float last_sighting[3]; int attack_state; int lefty; float idle_time; int linkcount; int power_armor_type; int power_armor_power; } monsterinfo; } *

variable_types: client int

user_defined_types: struct edict_s { struct entity_state_s s; struct gclient_s *client; enum qboolean inuse; int linkcount; struct link_s area; int num_clusters; int clusternums[16]; int headnode; int areanum; int svflags; float mins[3]; float absmin[3]; enum solid_t solid; int clipmask; struct edict_s *owner; int movetype; int flags; char *model; float freetime; char *message; char *classname; int spawnflags; float timestamp; float angle; char *target; char *targetname; char *killtarget; char *team; char *pathtarget; char *deathtarget; char *combattarget; struct edict_s *target_ent; float speed; float movedir[3]; float pos1[3]; float velocity[3]; float avelocity[3]; int mass; float air_finished; float gravity; struct edict_s *goalentity; struct edict_s *movetarget; float yaw_speed; float ideal_yaw; float nextthink; void (*prethink)(struct edict_s *ent); void (*think)(struct edict_s *self); void (*blocked)(struct edict_s *self, struct edict_s *other); void (*touch)(struct edict_s *self, struct edict_s *other, struct cplane_s *plane, struct csurface_s *surf); void (*use)(struct edict_s *self, struct edict_s *other, struct edict_s *activator); void (*pain)(struct edict_s *self, struct edict_s *other, float kick, int damage); void (*die)(struct edict_s *self, struct edict_s *inflictor, struct edict_s *attacker, int damage, float point[3]); float touch_debounce_time; float pain_debounce_time; float damage_debounce_time; float fly_sound_debounce_time; float last_move_time; int health; int max_health; int gib_health; int deadflag; enum qboolean show_hostile; float powerarmor_time; char *map; int viewheight; int takedamage; int dmg; int radius_dmg; float dmg_radius; int sounds; int count; struct edict_s *chain; struct edict_s *enemy; struct edict_s *oldenemy; struct edict_s *activator; struct edict_s *groundentity; int groundentity_linkcount; struct edict_s *teamchain; struct edict_s *teammaster; struct edict_s *mynoise; struct edict_s *mynoise2; int noise_index; int noise_index2; float volume; float attenuation; float wait; float delay; float random; float teleport_time; int watertype; int waterlevel; float move_origin[3]; float move_angles[3]; int light_level; int style; struct gitem_s *item; struct moveinfo_t moveinfo; struct monsterinfo_t monsterinfo; }

user_defined_types: struct monsterinfo_t { struct mmove_t *currentmove; int aiflags; int nextframe; float scale; void (*stand)(struct edict_s *self); void (*idle)(struct edict_s *self); void (*search)(struct edict_s *self); void (*walk)(struct edict_s *self); void (*run)(struct edict_s *self); void (*dodge)(struct edict_s *self, struct edict_s *other, float eta); void (*attack)(struct edict_s *self); void (*melee)(struct edict_s *self); void (*sight)(struct edict_s *self, struct edict_s *other); enum qboolean (*checkattack)(struct edict_s *self); float pausetime; float attack_finished; float saved_goal[3]; float search_time; float trail_time; float last_sighting[3]; int attack_state; int lefty; float idle_time; int linkcount; int power_armor_type; int power_armor_power; }

user_defined_types: struct gclient_s { struct player_state_t ps; int ping; struct client_persistant_t pers; struct client_respawn_t resp; struct pmove_state_t old_pmove; enum qboolean showscores; enum qboolean showinventory; enum qboolean showhelp; enum qboolean showhelpicon; int ammo_index; int buttons; int oldbuttons; int latched_buttons; enum qboolean weapon_thunk; struct gitem_s *newweapon; int damage_armor; int damage_parmor; int damage_blood; int damage_knockback; float damage_from[3]; float killer_yaw; enum weaponstate_t weaponstate; float kick_angles[3]; float kick_origin[3]; float v_dmg_roll; float fall_time; float damage_alpha; float bonus_alpha; float damage_blend[3]; float v_angle[3]; float bobtime; float oldviewangles[3]; float oldvelocity[3]; float next_drown_time; int old_waterlevel; int breather_sound; int machinegun_shots; int anim_end; int anim_priority; enum qboolean anim_duck; enum qboolean anim_run; int quad_framenum; int invincible_framenum; int breather_framenum; int enviro_framenum; enum qboolean grenade_blew_up; float grenade_time; int silencer_shots; int weapon_sound; float pickup_msg_time; float flood_locktill; float flood_when[10]; int flood_whenhead; float respawn_time; struct edict_s *chase_target; enum qboolean update_chase; }

user_defined_types: struct player_state_t { struct pmove_state_t pmove; float viewangles[3]; float viewoffset[3]; float kick_angles[3]; float gunangles[3]; float gunoffset[3]; int gunindex; int gunframe; float blend[4]; float fov; int rdflags; short stats[32]; }

user_defined_types: struct client_persistant_t { char userinfo[512]; char netname[16]; int hand; enum qboolean connected; int health; int max_health; int savedFlags; int selected_item; int inventory[256]; int max_bullets; int max_shells; int max_rockets; int max_grenades; int max_cells; int max_slugs; struct gitem_s *weapon; struct gitem_s *lastweapon; int power_cubes; int score; int game_helpchanged; int helpchanged; enum qboolean spectator; }

user_defined_types: struct client_respawn_t { struct client_persistant_t coop_respawn; int enterframe; int score; float cmd_angles[3]; enum qboolean spectator; }

user_defined_types: struct mmove_t { int firstframe; int lastframe; struct mframe_t *frame; void (*endfunc)(struct edict_s *self); }

user_defined_types: struct pmove_state_t { enum pmtype_t pm_type; short origin[3]; short velocity[3]; unsigned char pm_flags; unsigned char pm_time; short gravity; short delta_angles[3]; }

user_defined_types: struct gitem_s { char *classname; enum qboolean (*pickup)(struct edict_s *ent, struct edict_s *other); void (*use)(struct edict_s *ent, struct gitem_s *item); void (*drop)(struct edict_s *ent, struct gitem_s *item); void (*weaponthink)(struct edict_s *ent); char *pickup_sound; char *world_model; int world_model_flags; char *view_model; char *icon; char *pickup_name; int count_width; int quantity; char *ammo; int flags; int weapmodel; void *info; int tag; char *precaches; }


checkfordisablecmd

decompiled_code:
__int64 __fastcall checkfordisablecmd(char *string, int a2)
{
_QWORD *v2; // rax
char v3; // dl

v2 = (_QWORD *)((char *)&disablecmds + 24 * a2);
v3 = *((_BYTE *)v2 + 8);
if ( v3 == 1 )
return (unsigned int)Q_stricmp(string, *v2) == 0;
if ( v3 == 2 )
return regexec((const regex_t *)v2[2], string, 0LL, 0LL, 0) != 1;
if ( v3 )
return 0LL;
return startContains(string, *v2);
}

canonical_decompiled_code:
__int64 __fastcall func4(char *string, int a2)
{
_QWORD *v2; // rax
char v3; // dl

v2 = (_QWORD *)((char *)&disablecmds + 24 * a2);
v3 = *((_BYTE *)v2 + 8);
if ( v3 == 1 )
return (unsigned int)Q_stricmp(string, *v2) == 0;
if ( v3 == 2 )
return regexec((const regex_t *)v2[2], string, 0LL, 0LL, 0) != 1;
if ( v3 )
return 0LL;
return startContains(string, *v2);
}

canonical_original_code:
enum qboolean checkfordisablecmd(char *cp, int disablecmd) {
    switch (disablecmds[disablecmd].type) {
        case 0:
            return startContains(cp, disablecmds[disablecmd].disablecmd);
        case 1:
            return !Q_stricmp(cp, disablecmds[disablecmd].disablecmd);
        case 2:
            return (regexec(disablecmds[disablecmd].r, cp, 0, 0, 0) != REG_NOMATCH);
    }
    return 0;
}

variable_types:
cp
char *

variable_types: disablecmd int

return_type: enum qboolean { qfalse=0, qtrue=1 }


checkDisabledCommand

decompiled_code:
__int64 __fastcall checkDisabledCommand(char *src)
{
int v1; // ebx

strncpy(&buffer, src, 0x10000uLL);
q_strupr(&buffer);
if ( !maxdisable_cmds[0] )
return 0LL;
v1 = 0;
while ( !(unsigned int)checkfordisablecmd(&buffer, v1) )
{
if ( maxdisable_cmds[0] <= (unsigned int)++v1 )
return 0LL;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func5(char *src)
{
int v1; // ebx

strncpy(&buffer, src, 0x10000uLL);
q_strupr(&buffer);
if ( !maxdisable_cmds[0] )
return 0LL;
v1 = 0;
while ( !(unsigned int)func4(&buffer, v1) )
{
if ( maxdisable_cmds[0] <= (unsigned int)++v1 )
return 0LL;
}
return 1LL;
}

canonical_original_code:
enum qboolean checkDisabledCommand(char *cmd) {
    unsigned int i;
    strncpy(buffer, cmd, sizeof(buffer));
    q_strupr(buffer);
    for (i = 0; i < maxdisable_cmds; i++) {
        if (checkfordisablecmd(buffer, i)) {
            return 1;
        }
    }
    return 0;
}

variable_types:
cmd
char *

variable_types:
i
unsigned int


listdisablesRun

decompiled_code:
__int64 __fastcall listdisablesRun(__int64 a1, __int64 a2, unsigned int a3)
{
addCmdQueue(a3, 27LL, 0LL, 0LL, 0.0);
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(a2, 2LL, "Start disbled-entities List:\n");
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2, unsigned int a3)
{
addCmdQueue(a3, 27LL, 0LL, 0LL, 0.0);
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(a2, 2LL, "Start disbled-entities List:\n");
}

original_code:
void listdisablesRun(int startarg, edict_t *ent, int client) {
    addCmdQueue(client, QCMD_DISPDISABLE, 0, 0, 0);
    gi.cprintf(ent, 2, "Start disbled-entities List:\n");
}

canonical_original_code:
void listdisablesRun(int startarg, struct edict_s *ent, int client) {
    addCmdQueue(client, QCMD_DISPDISABLE, 0, 0, 0);
    gi.cprintf(ent, 2, "Start disbled-entities List:\n");
}

user_defined_types: struct entity_state_s { int number; float origin[3]; float angles[3]; float old_origin[3]; int modelindex; int modelindex2; int frame; int skinnum; int effects; int renderfx; int solid; int sound; int event; }

user_defined_types: enum solid_t { SOLID_NOT=0, SOLID_TRIGGER=1, SOLID_BBOX=2, SOLID_BSP=3 }

user_defined_types: struct moveinfo_t { float start_origin[3]; float start_angles[3]; float end_origin[3]; float end_angles[3]; int sound_start; int sound_middle; int sound_end; float accel; float speed; float decel; float distance; float wait; int state; float dir[3]; float current_speed; float move_speed; float next_speed; float remaining_distance; float decel_distance; void (*endfunc)(struct edict_s *); }

user_defined_types: enum weaponstate_t { WEAPON_READY=0, WEAPON_ACTIVATING=1, WEAPON_DROPPING=2, WEAPON_FIRING=3 }

user_defined_types: struct cplane_s { float normal[3]; float dist; unsigned char type; unsigned char signbits; unsigned char pad[2]; }

user_defined_types: struct csurface_s { char name[16]; int flags; int value; }

user_defined_types: enum pmtype_t { PM_NORMAL=0, PM_SPECTATOR=1, PM_DEAD=2, PM_GIB=3, PM_FREEZE=4 }

user_defined_types: struct mframe_t { void (*aifunc)(struct edict_s *self, float dist); float dist; void (*thinkfunc)(struct edict_s *self); }


displayNextDisable

decompiled_code:
__int64 __fastcall displayNextDisable(__int64 a1, unsigned int a2, __int64 a3)
{
__int64 v3; // r12
const char **v4; // rax
char v5; // cl

if ( maxdisable_cmds[0] <= a3 )
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(a1, 2LL, "End disbled-entities List\n");
v3 = a3 + 1;
v4 = (const char **)((char *)&disablecmds + 24 * a3);
v5 = *((_BYTE *)v4 + 8);
switch ( v5 )
{
case 1:
((void (*)(__int64, __int64, const char *, ...))gi[2])(a1, 2LL, "%4d EX:\"%s\"\n", a3 + 1, *v4);
break;
case 2:
((void (*)(__int64, __int64, const char *, ...))gi[2])(a1, 2LL, "%4d RE:\"%s\"\n", a3 + 1, *v4);
break;
case 0:
((void (*)(__int64, __int64, const char *, ...))gi[2])(a1, 2LL, "%4d SW:\"%s\"\n", a3 + 1, *v4);
break;
}
return addCmdQueue(a2, 27LL, v3, 0LL, 0.0);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int a2, __int64 a3)
{
__int64 v3; // r12
const char **v4; // rax
char v5; // cl

if ( maxdisable_cmds[0] <= a3 )
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(a1, 2LL, "End disbled-entities List\n");
v3 = a3 + 1;
v4 = (const char **)((char *)&disablecmds + 24 * a3);
v5 = *((_BYTE *)v4 + 8);
switch ( v5 )
{
case 1:
((void (*)(__int64, __int64, const char *, ...))gi[2])(a1, 2LL, "%4d EX:\"%s\"\n", a3 + 1, *v4);
break;
case 2:
((void (*)(__int64, __int64, const char *, ...))gi[2])(a1, 2LL, "%4d RE:\"%s\"\n", a3 + 1, *v4);
break;
case 0:
((void (*)(__int64, __int64, const char *, ...))gi[2])(a1, 2LL, "%4d SW:\"%s\"\n", a3 + 1, *v4);
break;
}
return addCmdQueue(a2, 27LL, v3, 0LL, 0.0);
}

original_code:
void displayNextDisable(edict_t *ent, int client, long disablecmd) {
    if (disablecmd < maxdisable_cmds) {
        switch (disablecmds[disablecmd].type) {
            case 0:
                gi.cprintf(ent, 2, "%4d SW:\"%s\"\n", disablecmd + 1, disablecmds[disablecmd].disablecmd);
                break;
            case 1:
                gi.cprintf(ent, 2, "%4d EX:\"%s\"\n", disablecmd + 1, disablecmds[disablecmd].disablecmd);
                break;
            case 2:
                gi.cprintf(ent, 2, "%4d RE:\"%s\"\n", disablecmd + 1, disablecmds[disablecmd].disablecmd);
                break;
        }
        disablecmd++;
        addCmdQueue(client, QCMD_DISPDISABLE, 0, disablecmd, 0);
    } else {
        gi.cprintf(ent, 2, "End disbled-entities List\n");
    }
}

canonical_original_code:
void displayNextDisable(struct edict_s *ent, int client, long disablecmd) {
    if (disablecmd < maxdisable_cmds) {
        switch (disablecmds[disablecmd].type) {
            case 0:
                gi.cprintf(ent, 2, "%4d SW:\"%s\"\n", disablecmd + 1, disablecmds[disablecmd].disablecmd);
                break;
            case 1:
                gi.cprintf(ent, 2, "%4d EX:\"%s\"\n", disablecmd + 1, disablecmds[disablecmd].disablecmd);
                break;
            case 2:
                gi.cprintf(ent, 2, "%4d RE:\"%s\"\n", disablecmd + 1, disablecmds[disablecmd].disablecmd);
                break;
        }
        disablecmd++;
        addCmdQueue(client, QCMD_DISPDISABLE, 0, disablecmd, 0);
    } else {
        gi.cprintf(ent, 2, "End disbled-entities List\n");
    }
}

variable_types: disablecmd long

user_defined_types: struct edict_s { struct entity_state_s s; struct gclient_s *client; enum qboolean inuse; int linkcount; struct link_s area; int num_clusters; int clusternums[16]; int headnode; int areanum; int svflags; float mins[3]; float absmin[3]; enum solid_t solid; int clipmask; struct edict_s *owner; int movetype; int flags; char *model; float freetime; char *message; char *classname; int spawnflags; float timestamp; float angle; char *target; char *targetname; char *killtarget; char *team; char *pathtarget; char *deathtarget; char *combattarget; struct edict_s *target_ent; float speed; float movedir[3]; float pos1[3]; float velocity[3]; float avelocity[3]; int mass; float air_finished; float gravity; struct edict_s *goalentity; struct edict_s *movetarget; float yaw_speed; float ideal_yaw; float nextthink; void (*prethink)(struct edict_s *ent); void (*think)(struct edict_s *self); void (*blocked)(struct edict_s *self, struct edict_s *other); void (*touch)(struct edict_s *self, struct edict_s *other, struct cplane_s *plane, struct csurface_s *surf); void (*use)(struct edict_s *self, struct edict_s *other, struct edict_s *activator); void (*pain)(struct edict_s *self, struct edict_s *other, float kick, int damage); void (*die)(struct edict_s *self, struct edict_s *inflictor, struct edict_s *attacker, int damage, float point[3]); float touch_debounce_time; float pain_debounce_time; float damage_debounce_time; float fly_sound_debounce_time; float last_move_time; int health; int max_health; int gib_health; int deadflag; enum qboolean show_hostile; float powerarmor_time; char *map; int viewheight; int takedamage; int dmg; int radius_dmg; float dmg_radius; int sounds; int count; struct edict_s *chain; struct edict_s *enemy; struct edict_s *oldenemy; struct edict_s *activator; struct edict_s *groundentity; int groundentity_linkcount; struct edict_s *teamchain; struct edict_s *teammaster; struct edict_s *mynoise; struct edict_s *mynoise2; int noise_index; int noise_index2; float volume; float attenuation; float wait; float delay; float random; float teleport_time; int watertype; int waterlevel; float move_origin[3]; float move_angles[3]; int light_level; int style; struct gitem_s *item; struct moveinfo_t moveinfo; struct monsterinfo_t monsterinfo; }


disablecmdRun

decompiled_code:
__int64 __fastcall disablecmdRun(unsigned int a1, __int64 a2)
{
__int64 v3; // rbp
const char *v4; // rbp
int v5; // eax
__int64 v6; // r15
__int64 result; // rax
int v8; // ecx
char *v9; // rdx
char v10; // dl
__int64 v11; // rcx
const char *v12; // rdx
__int64 v13; // r8
int v14; // er15
_OWORD *v15; // rax
bool v16; // zf
char *v17; // rsi
void (*v18)(const char *, ...); // rcx
int v19; // [rsp+8h] [rbp-40h]

if ( maxdisable_cmds[0] > 49 )
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(
a2,
2LL,
"Sorry, maximum number of disbled-entitie commands has been reached.\n");
if ( ((int (*)(void))gi[39])() <= (int)(a1 + 1) )
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(
a2,
2LL,
"[sv] !disablecmd [SW/EX/RE] \"command\"\n");
v3 = ((__int64 (__fastcall *)(_QWORD))gi[40])(a1);
if ( (unsigned int)Q_stricmp(v3, "SW") )
{
if ( (unsigned int)Q_stricmp(v3, "EX") )
{
if ( (unsigned int)Q_stricmp(v3, "RE") )
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(
a2,
2LL,
"[sv] !disablecmd [SW/EX/RE] \"command\"\n");
*((_BYTE *)&disablecmds + 24 * maxdisable_cmds[0] + 8) = 2;
}
else
{
*((_BYTE *)&disablecmds + 24 * maxdisable_cmds[0] + 8) = 1;
}
}
else
{
*((_BYTE *)&disablecmds + 24 * maxdisable_cmds[0] + 8) = 0;
}
v4 = (const char *)((__int64 (__fastcall *)(_QWORD))gi[40])(a1 + 1);
if ( (unsigned int)isBlank(v4) )
return ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))gi[2])(a2, 2LL, "[sv] !disablecmd [SW/EX/RE] \"command\"\n");
v5 = strlen(v4);
v6 = maxdisable_cmds[0];
v19 = v5;
*((_QWORD *)&disablecmds + 3 * v6) = ((__int64 (__fastcall *)(_QWORD, __int64))gi[33])((unsigned int)(v5 + 20), 766LL);
processstring(*((_QWORD *)&disablecmds + 3 * maxdisable_cmds[0]), v4, (unsigned int)(v19 + 19), 0LL);
result = maxdisable_cmds[0];
v8 = maxdisable_cmds[0];
v9 = (char *)&disablecmds + 24 * maxdisable_cmds[0];
if ( v9[8] != 2 )
{
*((_QWORD *)v9 + 2) = 0LL;
v10 = v9[8];
v11 = (unsigned int)(v8 + 1);
if ( v10 != 1 )
{
LABEL_8:
if ( v10 )
{
LABEL_9:
maxdisable_cmds[0] = v11;
return result;
}
v12 = "%4d SW:\"%s\" added\n";
v13 = *((_QWORD *)&disablecmds + 3 * result);
LABEL_14:
result = ((__int64 (__fastcall *)(__int64, __int64, const char *, __int64, __int64))gi[2])(a2, 2LL, v12, v11, v13);
LODWORD(v11) = maxdisable_cmds[0] + 1;
goto LABEL_9;
}
goto LABEL_15;
}
q_strupr(v4);
v14 = maxdisable_cmds[0];
*((_QWORD *)&disablecmds + 3 * v14 + 2) = ((__int64 (__fastcall *)(__int64, __int64))gi[33])(64LL, 766LL);
v15 = (_OWORD *)*((_QWORD *)&disablecmds + 3 * maxdisable_cmds[0] + 2);
*v15 = 0LL;
v15[1] = 0LL;
v15[2] = 0LL;
v15[3] = 0LL;
v16 = regcomp(*((regex_t **)&disablecmds + 3 * maxdisable_cmds[0] + 2), v4, 0) == 0;
result = maxdisable_cmds[0];
if ( v16 )
{
v17 = (char *)&disablecmds + 24 * maxdisable_cmds[0];
v11 = (unsigned int)(maxdisable_cmds[0] + 1);
v10 = v17[8];
if ( v10 != 1 )
{
if ( v10 == 2 )
{
v13 = *(_QWORD *)v17;
v12 = "%4d RE:\"%s\" added\n";
goto LABEL_14;
}
goto LABEL_8;
}
LABEL_15:
v12 = "%4d EX:\"%s\" added\n";
v13 = *((_QWORD *)&disablecmds + 3 * result);
goto LABEL_14;
}
gi[34](*((const char **)&disablecmds + 3 * maxdisable_cmds[0]));
gi[34](*((const char **)&disablecmds + 3 * maxdisable_cmds[0] + 2));
v18 = gi[2];
*((_QWORD *)&disablecmds + 3 * maxdisable_cmds[0] + 2) = 0LL;
return ((__int64 (__fastcall *)(__int64, __int64, const char *))v18)(
a2,
2LL,
"Regular expression couldn't compile!\n");
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int a1, __int64 a2)
{
__int64 v3; // rbp
const char *v4; // rbp
int v5; // eax
__int64 v6; // r15
__int64 result; // rax
int v8; // ecx
char *v9; // rdx
char v10; // dl
__int64 v11; // rcx
const char *v12; // rdx
__int64 v13; // r8
int v14; // er15
_OWORD *v15; // rax
bool v16; // zf
char *v17; // rsi
void (*v18)(const char *, ...); // rcx
int v19; // [rsp+8h] [rbp-40h]

if ( maxdisable_cmds[0] > 49 )
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(
a2,
2LL,
"Sorry, maximum number of disbled-entitie commands has been reached.\n");
if ( ((int (*)(void))gi[39])() <= (int)(a1 + 1) )
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(
a2,
2LL,
"[sv] !disablecmd [SW/EX/RE] \"command\"\n");
v3 = ((__int64 (__fastcall *)(_QWORD))gi[40])(a1);
if ( (unsigned int)Q_stricmp(v3, "SW") )
{
if ( (unsigned int)Q_stricmp(v3, "EX") )
{
if ( (unsigned int)Q_stricmp(v3, "RE") )
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(
a2,
2LL,
"[sv] !disablecmd [SW/EX/RE] \"command\"\n");
*((_BYTE *)&disablecmds + 24 * maxdisable_cmds[0] + 8) = 2;
}
else
{
*((_BYTE *)&disablecmds + 24 * maxdisable_cmds[0] + 8) = 1;
}
}
else
{
*((_BYTE *)&disablecmds + 24 * maxdisable_cmds[0] + 8) = 0;
}
v4 = (const char *)((__int64 (__fastcall *)(_QWORD))gi[40])(a1 + 1);
if ( (unsigned int)isBlank(v4) )
return ((__int64 (__fastcall *)(_QWORD, _QWORD, _QWORD))gi[2])(a2, 2LL, "[sv] !disablecmd [SW/EX/RE] \"command\"\n");
v5 = strlen(v4);
v6 = maxdisable_cmds[0];
v19 = v5;
*((_QWORD *)&disablecmds + 3 * v6) = ((__int64 (__fastcall *)(_QWORD, __int64))gi[33])((unsigned int)(v5 + 20), 766LL);
processstring(*((_QWORD *)&disablecmds + 3 * maxdisable_cmds[0]), v4, (unsigned int)(v19 + 19), 0LL);
result = maxdisable_cmds[0];
v8 = maxdisable_cmds[0];
v9 = (char *)&disablecmds + 24 * maxdisable_cmds[0];
if ( v9[8] != 2 )
{
*((_QWORD *)v9 + 2) = 0LL;
v10 = v9[8];
v11 = (unsigned int)(v8 + 1);
if ( v10 != 1 )
{
LABEL_8:
if ( v10 )
{
LABEL_9:
maxdisable_cmds[0] = v11;
return result;
}
v12 = "%4d SW:\"%s\" added\n";
v13 = *((_QWORD *)&disablecmds + 3 * result);
LABEL_14:
result = ((__int64 (__fastcall *)(__int64, __int64, const char *, __int64, __int64))gi[2])(a2, 2LL, v12, v11, v13);
LODWORD(v11) = maxdisable_cmds[0] + 1;
goto LABEL_9;
}
goto LABEL_15;
}
q_strupr(v4);
v14 = maxdisable_cmds[0];
*((_QWORD *)&disablecmds + 3 * v14 + 2) = ((__int64 (__fastcall *)(__int64, __int64))gi[33])(64LL, 766LL);
v15 = (_OWORD *)*((_QWORD *)&disablecmds + 3 * maxdisable_cmds[0] + 2);
*v15 = 0LL;
v15[1] = 0LL;
v15[2] = 0LL;
v15[3] = 0LL;
v16 = regcomp(*((regex_t **)&disablecmds + 3 * maxdisable_cmds[0] + 2), v4, 0) == 0;
result = maxdisable_cmds[0];
if ( v16 )
{
v17 = (char *)&disablecmds + 24 * maxdisable_cmds[0];
v11 = (unsigned int)(maxdisable_cmds[0] + 1);
v10 = v17[8];
if ( v10 != 1 )
{
if ( v10 == 2 )
{
v13 = *(_QWORD *)v17;
v12 = "%4d RE:\"%s\" added\n";
goto LABEL_14;
}
goto LABEL_8;
}
LABEL_15:
v12 = "%4d EX:\"%s\" added\n";
v13 = *((_QWORD *)&disablecmds + 3 * result);
goto LABEL_14;
}
gi[34](*((const char **)&disablecmds + 3 * maxdisable_cmds[0]));
gi[34](*((const char **)&disablecmds + 3 * maxdisable_cmds[0] + 2));
v18 = gi[2];
*((_QWORD *)&disablecmds + 3 * maxdisable_cmds[0] + 2) = 0LL;
return ((__int64 (__fastcall *)(__int64, __int64, const char *))v18)(
a2,
2LL,
"Regular expression couldn't compile!\n");
}

original_code:
void disablecmdRun(int startarg, edict_t *ent, int client) {
    char *cmd;
    int len;
    if (maxdisable_cmds >= 50) {
        gi.cprintf(ent, 2, "Sorry, maximum number of disbled-entitie commands has been reached.\n");
        return;
    }
    if (gi.argc() <= startarg + 1) {
        gi.cprintf(ent, 2, "[sv] !disablecmd [SW/EX/RE] \"command\"\n");
        return;
    }
    cmd = gi.argv(startarg);
    if (Q_stricmp(cmd, "SW") == 0) {
        disablecmds[maxdisable_cmds].type = 0;
    } else if (Q_stricmp(cmd, "EX") == 0) {
        disablecmds[maxdisable_cmds].type = 1;
    } else if (Q_stricmp(cmd, "RE") == 0) {
        disablecmds[maxdisable_cmds].type = 2;
    } else {
        gi.cprintf(ent, 2, "[sv] !disablecmd [SW/EX/RE] \"command\"\n");
        return;
    }
    cmd = gi.argv(startarg + 1);
    if (isBlank(cmd)) {
        gi.cprintf(ent, 2, "[sv] !disablecmd [SW/EX/RE] \"command\"\n");
        return;
    }
    len = strlen(cmd) + 20;
    disablecmds[maxdisable_cmds].disablecmd = gi.TagMalloc(len, 766);
    processstring(disablecmds[maxdisable_cmds].disablecmd, cmd, len - 1, 0);
    if (disablecmds[maxdisable_cmds].type == 2) {
        q_strupr(cmd);
        disablecmds[maxdisable_cmds].r = gi.TagMalloc(sizeof (*disablecmds[maxdisable_cmds].r), 766);
        memset(disablecmds[maxdisable_cmds].r, 0x0, sizeof (*disablecmds[maxdisable_cmds].r));
        if (regcomp(disablecmds[maxdisable_cmds].r, cmd, 0)) {
            gi.TagFree(disablecmds[maxdisable_cmds].disablecmd);
            gi.TagFree(disablecmds[maxdisable_cmds].r);
            disablecmds[maxdisable_cmds].r = 0;
            gi.cprintf(ent, 2, "Regular expression couldn't compile!\n");
            return;
        }
    } else {
        disablecmds[maxdisable_cmds].r = 0;
    }
    switch (disablecmds[maxdisable_cmds].type) {
        case 0:
            gi.cprintf(ent, 2, "%4d SW:\"%s\" added\n", maxdisable_cmds + 1, disablecmds[maxdisable_cmds].disablecmd);
            break;
        case 1:
            gi.cprintf(ent, 2, "%4d EX:\"%s\" added\n", maxdisable_cmds + 1, disablecmds[maxdisable_cmds].disablecmd);
            break;
        case 2:
            gi.cprintf(ent, 2, "%4d RE:\"%s\" added\n", maxdisable_cmds + 1, disablecmds[maxdisable_cmds].disablecmd);
            break;
    }
    maxdisable_cmds++;
}

canonical_original_code:
void disablecmdRun(int startarg, struct edict_s *ent, int client) {
    char *cmd;
    int len;
    if (maxdisable_cmds >= 50) {
        gi.cprintf(ent, 2, "Sorry, maximum number of disbled-entitie commands has been reached.\n");
        return;
    }
    if (gi.argc() <= startarg + 1) {
        gi.cprintf(ent, 2, "[sv] !disablecmd [SW/EX/RE] \"command\"\n");
        return;
    }
    cmd = gi.argv(startarg);
    if (Q_stricmp(cmd, "SW") == 0) {
        disablecmds[maxdisable_cmds].type = 0;
    } else if (Q_stricmp(cmd, "EX") == 0) {
        disablecmds[maxdisable_cmds].type = 1;
    } else if (Q_stricmp(cmd, "RE") == 0) {
        disablecmds[maxdisable_cmds].type = 2;
    } else {
        gi.cprintf(ent, 2, "[sv] !disablecmd [SW/EX/RE] \"command\"\n");
        return;
    }
    cmd = gi.argv(startarg + 1);
    if (isBlank(cmd)) {
        gi.cprintf(ent, 2, "[sv] !disablecmd [SW/EX/RE] \"command\"\n");
        return;
    }
    len = strlen(cmd) + 20;
    disablecmds[maxdisable_cmds].disablecmd = gi.TagMalloc(len, 766);
    processstring(disablecmds[maxdisable_cmds].disablecmd, cmd, len - 1, 0);
    if (disablecmds[maxdisable_cmds].type == 2) {
        q_strupr(cmd);
        disablecmds[maxdisable_cmds].r = gi.TagMalloc(sizeof (*disablecmds[maxdisable_cmds].r), 766);
        memset(disablecmds[maxdisable_cmds].r, 0x0, sizeof (*disablecmds[maxdisable_cmds].r));
        if (regcomp(disablecmds[maxdisable_cmds].r, cmd, 0)) {
            gi.TagFree(disablecmds[maxdisable_cmds].disablecmd);
            gi.TagFree(disablecmds[maxdisable_cmds].r);
            disablecmds[maxdisable_cmds].r = 0;
            gi.cprintf(ent, 2, "Regular expression couldn't compile!\n");
            return;
        }
    } else {
        disablecmds[maxdisable_cmds].r = 0;
    }
    switch (disablecmds[maxdisable_cmds].type) {
        case 0:
            gi.cprintf(ent, 2, "%4d SW:\"%s\" added\n", maxdisable_cmds + 1, disablecmds[maxdisable_cmds].disablecmd);
            break;
        case 1:
            gi.cprintf(ent, 2, "%4d EX:\"%s\" added\n", maxdisable_cmds + 1, disablecmds[maxdisable_cmds].disablecmd);
            break;
        case 2:
            gi.cprintf(ent, 2, "%4d RE:\"%s\" added\n", maxdisable_cmds + 1, disablecmds[maxdisable_cmds].disablecmd);
            break;
    }
    maxdisable_cmds++;
}

variable_types: len int

user_defined_types: struct monsterinfo_t { struct mmove_t *currentmove; int aiflags; int nextframe; float scale; void (*stand)(struct edict_s *self); void (*idle)(struct edict_s *self); void (*search)(struct edict_s *self); void (*walk)(struct edict_s *self); void (*run)(struct edict_s *self); void (*dodge)(struct edict_s *self, struct edict_s *other, float eta); void (*attack)(struct edict_s *self); void (*melee)(struct edict_s *self); void (*sight)(struct edict_s *self, struct edict_s *other); enum qboolean (*checkattack)(struct edict_s *self); float pausetime; float attack_finished; float saved_goal[3]; float search_time; float trail_time; float last_sighting[3]; int attack_state; int lefty; float idle_time; int linkcount; int power_armor_type; int power_armor_power; }


disableDelRun

decompiled_code:
__int64 __fastcall disableDelRun(int a1, __int64 a2)
{
const char *v2; // rax
int v3; // eax
__int64 v4; // rbp
int v5; // er15
const char **v6; // r14
regex_t *v7; // rdi
int v8; // ecx
int v10; // [rsp+Ch] [rbp-3Ch]

if ( ((int (*)(void))gi[39])() <= a1 )
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(a2, 2LL, "[sv] !disabledel disablenum\n");
v2 = (const char *)((__int64 (__fastcall *)(_QWORD))gi[40])((unsigned int)a1);
v3 = atoi(v2);
v4 = v3;
if ( v3 <= 0 || maxdisable_cmds[0] < v3 )
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(a2, 2LL, "[sv] !disabledel disablenum\n");
v5 = v3 - 1;
v6 = (const char **)((char *)&disablecmds + 24 * v3 - 24);
gi[34](*v6);
v7 = (regex_t *)v6[2];
if ( v7 )
{
regfree(v7);
gi[34](v6[2]);
}
v8 = maxdisable_cmds[0];
if ( maxdisable_cmds[0] > (int)v4 )
{
v10 = maxdisable_cmds[0];
memmove((char *)&disablecmds + 24 * v4 - 24, (char *)&disablecmds + 24 * v4, 24LL * (maxdisable_cmds[0] - v5));
v8 = v10;
}
maxdisable_cmds[0] = v8 - 1;
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(a2, 2LL, "Disbled command deleted\n");
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1, __int64 a2)
{
const char *v2; // rax
int v3; // eax
__int64 v4; // rbp
int v5; // er15
const char **v6; // r14
regex_t *v7; // rdi
int v8; // ecx
int v10; // [rsp+Ch] [rbp-3Ch]

if ( ((int (*)(void))gi[39])() <= a1 )
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(a2, 2LL, "[sv] !disabledel disablenum\n");
v2 = (const char *)((__int64 (__fastcall *)(_QWORD))gi[40])((unsigned int)a1);
v3 = atoi(v2);
v4 = v3;
if ( v3 <= 0 || maxdisable_cmds[0] < v3 )
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(a2, 2LL, "[sv] !disabledel disablenum\n");
v5 = v3 - 1;
v6 = (const char **)((char *)&disablecmds + 24 * v3 - 24);
gi[34](*v6);
v7 = (regex_t *)v6[2];
if ( v7 )
{
regfree(v7);
gi[34](v6[2]);
}
v8 = maxdisable_cmds[0];
if ( maxdisable_cmds[0] > (int)v4 )
{
v10 = maxdisable_cmds[0];
memmove((char *)&disablecmds + 24 * v4 - 24, (char *)&disablecmds + 24 * v4, 24LL * (maxdisable_cmds[0] - v5));
v8 = v10;
}
maxdisable_cmds[0] = v8 - 1;
return ((__int64 (__fastcall *)(__int64, __int64, const char *))gi[2])(a2, 2LL, "Disbled command deleted\n");
}

original_code:
void disableDelRun(int startarg, edict_t *ent, int client) {
    int disable;
    if (gi.argc() <= startarg) {
        gi.cprintf(ent, 2, "[sv] !disabledel disablenum\n");
        return;
    }
    disable = atoi(gi.argv(startarg));
    if (disable < 1 || disable > maxdisable_cmds) {
        gi.cprintf(ent, 2, "[sv] !disabledel disablenum\n");
        return;
    }
    disable--;
    gi.TagFree(disablecmds[disable].disablecmd);
    if (disablecmds[disable].r) {
        regfree(disablecmds[disable].r);
        gi.TagFree(disablecmds[disable].r);
    }
    if (disable + 1 < maxdisable_cmds) {
        memmove((disablecmds + disable), (disablecmds + disable + 1), sizeof (disablecmd_t) * (maxdisable_cmds - disable));
    }
    maxdisable_cmds--;
    gi.cprintf(ent, 2, "Disbled command deleted\n");
}

canonical_original_code:
void disableDelRun(int startarg, struct edict_s *ent, int client) {
    int disable;
    if (gi.argc() <= startarg) {
        gi.cprintf(ent, 2, "[sv] !disabledel disablenum\n");
        return;
    }
    disable = atoi(gi.argv(startarg));
    if (disable < 1 || disable > maxdisable_cmds) {
        gi.cprintf(ent, 2, "[sv] !disabledel disablenum\n");
        return;
    }
    disable--;
    gi.TagFree(disablecmds[disable].disablecmd);
    if (disablecmds[disable].r) {
        regfree(disablecmds[disable].r);
        gi.TagFree(disablecmds[disable].r);
    }
    if (disable + 1 < maxdisable_cmds) {
        memmove((disablecmds + disable), (disablecmds + disable + 1), sizeof (disablecmd_t) * (maxdisable_cmds - disable));
    }
    maxdisable_cmds--;
    gi.cprintf(ent, 2, "Disbled command deleted\n");
}

variable_types: disable int

user_defined_types: struct gclient_s { struct player_state_t ps; int ping; struct client_persistant_t pers; struct client_respawn_t resp; struct pmove_state_t old_pmove; enum qboolean showscores; enum qboolean showinventory; enum qboolean showhelp; enum qboolean showhelpicon; int ammo_index; int buttons; int oldbuttons; int latched_buttons; enum qboolean weapon_thunk; struct gitem_s *newweapon; int damage_armor; int damage_parmor; int damage_blood; int damage_knockback; float damage_from[3]; float killer_yaw; enum weaponstate_t weaponstate; float kick_angles[3]; float kick_origin[3]; float v_dmg_roll; float fall_time; float damage_alpha; float bonus_alpha; float damage_blend[3]; float v_angle[3]; float bobtime; float oldviewangles[3]; float oldvelocity[3]; float next_drown_time; int old_waterlevel; int breather_sound; int machinegun_shots; int anim_end; int anim_priority; enum qboolean anim_duck; enum qboolean anim_run; int quad_framenum; int invincible_framenum; int breather_framenum; int enviro_framenum; enum qboolean grenade_blew_up; float grenade_time; int silencer_shots; int weapon_sound; float pickup_msg_time; float flood_locktill; float flood_when[10]; int flood_whenhead; float respawn_time; struct edict_s *chase_target; enum qboolean update_chase; }


writefunc

decompiled_code:
size_t __fastcall writefunc(void *src, __int64 a2, __int64 a3, __int64 a4)
{
size_t v4; // r12
__int64 v6; // rbp
char *v7; // rax
size_t result; // rax

v4 = a3 * a2;
v6 = a3 * a2 + *(_QWORD *)(a4 + 8);
v7 = (char *)realloc(*(void **)a4, v6 + 1);
*(_QWORD *)a4 = v7;
memcpy(&v7[*(_QWORD *)(a4 + 8)], src, v4);
*(_BYTE *)(*(_QWORD *)a4 + v6) = 0;
result = v4;
*(_QWORD *)(a4 + 8) = v6;
return result;
}

canonical_decompiled_code:
size_t __fastcall func2(void *src, __int64 a2, __int64 a3, __int64 a4)
{
size_t v4; // r12
__int64 v6; // rbp
char *v7; // rax
size_t result; // rax

v4 = a3 * a2;
v6 = a3 * a2 + *(_QWORD *)(a4 + 8);
v7 = (char *)realloc(*(void **)a4, v6 + 1);
*(_QWORD *)a4 = v7;
memcpy(&v7[*(_QWORD *)(a4 + 8)], src, v4);
*(_BYTE *)(*(_QWORD *)a4 + v6) = 0;
result = v4;
*(_QWORD *)(a4 + 8) = v6;
return result;
}

original_code:
size_t writefunc(void *ptr, size_t size, size_t nmemb, struct url_contents *s) {
 size_t new_len = s->len + size * nmemb;
 s->ptr = realloc(s->ptr, new_len + 1);
 if (s->ptr == ((void *)0)) {
 }
 memcpy(s->ptr+s->len, ptr, size * nmemb);
 s->ptr[new_len] = '\0';
 s->len = new_len;
 return size * nmemb;
}

canonical_original_code:
unsigned long writefunc(void *ptr, unsigned long size, unsigned long nmemb, struct url_contents *s) {
 unsigned long new_len = s->len + size * nmemb;
 s->ptr = realloc(s->ptr, new_len + 1);
 if (s->ptr == ((void *)0)) {
 }
 memcpy(s->ptr+s->len, ptr, size * nmemb);
 s->ptr[new_len] = '\0';
 s->len = new_len;
 return size * nmemb;
}

variable_types:
ptr
void *

variable_types:
size
unsigned long

variable_types:
nmemb
unsigned long

variable_types: struct url_contents { char *ptr; unsigned long len; } *

return_type: unsigned long


decompiled_code:
__int64 __fastcall CURL_Debug(__int64 a1, int a2, const char *a3, unsigned __int64 a4)
{
size_t v5; // rbx
char v6[4120]; // [rsp+0h] [rbp-1018h] BYREF

if ( a2 )
return 0LL;
v5 = 4095LL;
if ( a4 <= 0xFFF )
v5 = a4;
strncpy(v6, a3, v5);
v6[v5] = 0;
((void (*)(const char *, ...))gi[1])(" HTTP DEBUG: %s", v6);
if ( !strchr(v6, 10) )
gi[1]("\n");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2, const char *a3, unsigned __int64 a4)
{
size_t v5; // rbx
char v6[4120]; // [rsp+0h] [rbp-1018h] BYREF

if ( a2 )
return 0LL;
v5 = 4095LL;
if ( a4 <= 0xFFF )
v5 = a4;
strncpy(v6, a3, v5);
v6[v5] = 0;
((void (*)(const char *, ...))gi[1])(" HTTP DEBUG: %s", v6);
if ( !strchr(v6, 10) )
gi[1]("\n");
return 0LL;
}

original_code:
int CURL_Debug(CURL *c, curl_infotype type, char *data, size_t size, void * ptr)
{
    if (type == CURLINFO_TEXT) {
        char buff[4096];
        if (size > sizeof(buff)-1) {
            size = sizeof(buff)-1;
        }
        do { strncpy ((buff), (data), (size)); (buff)[(size)] = 0; } while (0);
        gi.dprintf("  HTTP DEBUG: %s", buff);
        if (!strchr(buff, '\n')) {
            gi.dprintf ("\n");
        }
    }
    return 0;
}

canonical_original_code:
int CURL_Debug(void *c, enum curl_infotype type, char *data, unsigned long size, void *ptr)
{
    if (type == CURLINFO_TEXT) {
        char buff[4096];
        if (size > sizeof(buff)-1) {
            size = sizeof(buff)-1;
        }
        do { strncpy ((buff), (data), (size)); (buff)[(size)] = 0; } while (0);
        gi.dprintf("  HTTP DEBUG: %s", buff);
        if (!strchr(buff, '\n')) {
            gi.dprintf ("\n");
        }
    }
    return 0;
}

variable_types:
c
void *

variable_types: enum curl_infotype { CURLINFO_TEXT=0, CURLINFO_HEADER_IN=1, CURLINFO_HEADER_OUT=2, CURLINFO_DATA_IN=3, CURLINFO_DATA_OUT=4, CURLINFO_SSL_DATA_IN=5, CURLINFO_SSL_DATA_OUT=6, CURLINFO_END=7 }

variable_types:
data
char *

variable_types:
buff
char [4096]

return_type: int


original_code:
static size_t HTTP_Recv(void *ptr, size_t size, size_t nmemb, void *stream)
{
    dlhandle_t *dl;
    size_t new_size, bytes;
    dl = (dlhandle_t *)stream;
    if (!nmemb) {
        return 0;
    }
    if (size > (18446744073709551615UL) / nmemb) {
        goto oversize;
    }
    if (dl->position > 0x100000) {
        goto oversize;
    }
    bytes = size * nmemb;
    if (bytes >= 0x100000 - dl->position) {
        goto oversize;
    }
    new_size = (dl->position + bytes + 0x8000) & ~(0x8000 - 1);
    if (new_size > dl->fileSize) {
        char *tmp;
        tmp = dl->tempBuffer;
        dl->tempBuffer = gi.TagMalloc((int)new_size, 765);
        if (tmp) {
            memcpy(dl->tempBuffer, tmp, dl->fileSize);
            gi.TagFree(tmp);
        }
        dl->fileSize = new_size;
    }
    memcpy(dl->tempBuffer + dl->position, ptr, bytes);
    dl->position += bytes;
    dl->tempBuffer[dl->position] = 0;
    return bytes;
oversize:
    gi.dprintf("Suspiciously large file while trying to download %s!\n", dl->URL);
    return 0;
}

canonical_original_code:
static unsigned long HTTP_Recv(void *ptr, unsigned long size, unsigned long nmemb, void *stream)
{
    struct dlhandle_s *dl;
    unsigned long new_size; unsigned long bytes;
    dl = (struct dlhandle_s *)stream;
    if (!nmemb) {
        return 0;
    }
    if (size > (18446744073709551615UL) / nmemb) {
        goto oversize;
    }
    if (dl->position > 0x100000) {
        goto oversize;
    }
    bytes = size * nmemb;
    if (bytes >= 0x100000 - dl->position) {
        goto oversize;
    }
    new_size = (dl->position + bytes + 0x8000) & ~(0x8000 - 1);
    if (new_size > dl->fileSize) {
        char *tmp;
        tmp = dl->tempBuffer;
        dl->tempBuffer = gi.TagMalloc((int)new_size, 765);
        if (tmp) {
            memcpy(dl->tempBuffer, tmp, dl->fileSize);
            gi.TagFree(tmp);
        }
        dl->fileSize = new_size;
    }
    memcpy(dl->tempBuffer + dl->position, ptr, bytes);
    dl->position += bytes;
    dl->tempBuffer[dl->position] = 0;
    return bytes;
oversize:
    gi.dprintf("Suspiciously large file while trying to download %s!\n", dl->URL);
    return 0;
}

variable_types:
stream
void *

variable_types: struct dlhandle_s { void *curl; unsigned long fileSize; unsigned long position; double speed; char filePath[1024]; char URL[2048]; char *tempBuffer; enum qboolean { qfalse=0, qtrue=1 } inuse; struct download_s { struct edict_s { struct entity_state_s { int number; float origin[3]; float angles[3]; float old_origin[3]; int modelindex; int modelindex2; int frame; int skinnum; int effects; int renderfx; int solid; int sound; int event; } s; struct gclient_s { struct player_state_t { struct pmove_state_t { enum pmtype_t { PM_NORMAL=0, PM_SPECTATOR=1, PM_DEAD=2, PM_GIB=3, PM_FREEZE=4 } pm_type; short origin[3]; short velocity[3]; unsigned char pm_flags; unsigned char pm_time; short gravity; short delta_angles[3]; } pmove; float viewangles[3]; float viewoffset[3]; float kick_angles[3]; float gunangles[3]; float gunoffset[3]; int gunindex; int gunframe; float blend[4]; float fov; int rdflags; short stats[32]; } ps; int ping; struct client_persistant_t { char userinfo[512]; char netname[16]; int hand; enum qboolean { qfalse=0, qtrue=1 } connected; int health; int max_health; int savedFlags; int selected_item; int inventory[256]; int max_bullets; int max_shells; int max_rockets; int max_grenades; int max_cells; int max_slugs; struct gitem_s { char *classname; enum qboolean { qfalse=0, qtrue=1 } (*pickup)(struct edict_s *ent, struct edict_s *other); void (*use)(struct edict_s *ent, struct gitem_s *item); void (*drop)(struct edict_s *ent, struct gitem_s *item); void (*weaponthink)(struct edict_s *ent); char *pickup_sound; char *world_model; int world_model_flags; char *view_model; char *icon; char *pickup_name; int count_width; int quantity; char *ammo; int flags; int weapmodel; void *info; int tag; char *precaches; } *weapon; struct gitem_s *lastweapon; int power_cubes; int score; int game_helpchanged; int helpchanged; enum qboolean { qfalse=0, qtrue=1 } spectator; } pers; struct client_respawn_t { struct client_persistant_t coop_respawn; int enterframe; int score; float cmd_angles[3]; enum qboolean { qfalse=0, qtrue=1 } spectator; } resp; struct pmove_state_t old_pmove; enum qboolean { qfalse=0, qtrue=1 } showscores; enum qboolean { qfalse=0, qtrue=1 } showinventory; enum qboolean { qfalse=0, qtrue=1 } showhelp; enum qboolean { qfalse=0, qtrue=1 } showhelpicon; int ammo_index; int buttons; int oldbuttons; int latched_buttons; enum qboolean { qfalse=0, qtrue=1 } weapon_thunk; struct gitem_s *newweapon; int damage_armor; int damage_parmor; int damage_blood; int damage_knockback; float damage_from[3]; float killer_yaw; enum weaponstate_t { WEAPON_READY=0, WEAPON_ACTIVATING=1, WEAPON_DROPPING=2, WEAPON_FIRING=3 } weaponstate; float kick_angles[3]; float kick_origin[3]; float v_dmg_roll; float fall_time; float damage_alpha; float bonus_alpha; float damage_blend[3]; float v_angle[3]; float bobtime; float oldviewangles[3]; float oldvelocity[3]; float next_drown_time; int old_waterlevel; int breather_sound; int machinegun_shots; int anim_end; int anim_priority; enum qboolean { qfalse=0, qtrue=1 } anim_duck; enum qboolean { qfalse=0, qtrue=1 } anim_run; int quad_framenum; int invincible_framenum; int breather_framenum; int enviro_framenum; enum qboolean { qfalse=0, qtrue=1 } grenade_blew_up; float grenade_time; int silencer_shots; int weapon_sound; float pickup_msg_time; float flood_locktill; float flood_when[10]; int flood_whenhead; float respawn_time; struct edict_s *chase_target; enum qboolean { qfalse=0, qtrue=1 } update_chase; } *client; enum qboolean { qfalse=0, qtrue=1 } inuse; int linkcount; struct link_s { struct link_s *prev; } area; int num_clusters; int clusternums[16]; int headnode; int areanum; int svflags; float mins[3]; float absmin[3]; enum solid_t { SOLID_NOT=0, SOLID_TRIGGER=1, SOLID_BBOX=2, SOLID_BSP=3 } solid; int clipmask; struct edict_s *owner; int movetype; int flags; char *model; float freetime; char *message; char *classname; int spawnflags; float timestamp; float angle; char *target; char *targetname; char *killtarget; char *team; char *pathtarget; char *deathtarget; char *combattarget; struct edict_s *target_ent; float speed; float movedir[3]; float pos1[3]; float velocity[3]; float avelocity[3]; int mass; float air_finished; float gravity; struct edict_s *goalentity; struct edict_s *movetarget; float yaw_speed; float ideal_yaw; float nextthink; void (*prethink)(struct edict_s *ent); void (*think)(struct edict_s *self); void (*blocked)(struct edict_s *self, struct edict_s *other); void (*touch)(struct edict_s *self, struct edict_s *other, struct cplane_s { float normal[3]; float dist; unsigned char type; unsigned char signbits; unsigned char pad[2]; } *plane, struct csurface_s { char name[16]; int flags; int value; } *surf); void (*use)(struct edict_s *self, struct edict_s *other, struct edict_s *activator); void (*pain)(struct edict_s *self, struct edict_s *other, float kick, int damage); void (*die)(struct edict_s *self, struct edict_s *inflictor, struct edict_s *attacker, int damage, float point[3]); float touch_debounce_time; float pain_debounce_time; float damage_debounce_time; float fly_sound_debounce_time; float last_move_time; int health; int max_health; int gib_health; int deadflag; enum qboolean { qfalse=0, qtrue=1 } show_hostile; float powerarmor_time; char *map; int viewheight; int takedamage; int dmg; int radius_dmg; float dmg_radius; int sounds; int count; struct edict_s *chain; struct edict_s *enemy; struct edict_s *oldenemy; struct edict_s *activator; struct edict_s *groundentity; int groundentity_linkcount; struct edict_s *teamchain; struct edict_s *teammaster; struct edict_s *mynoise; struct edict_s *mynoise2; int noise_index; int noise_index2; float volume; float attenuation; float wait; float delay; float random; float teleport_time; int watertype; int waterlevel; float move_origin[3]; float move_angles[3]; int light_level; int style; struct gitem_s *item; struct moveinfo_t { float start_origin[3]; float start_angles[3]; float end_origin[3]; float end_angles[3]; int sound_start; int sound_middle; int sound_end; float accel; float speed; float decel; float distance; float wait; int state; float dir[3]; float current_speed; float move_speed; float next_speed; float remaining_distance; float decel_distance; void (*endfunc)(struct edict_s *); } moveinfo; struct monsterinfo_t { struct mmove_t { int firstframe; int lastframe; struct mframe_t { void (*aifunc)(struct edict_s *self, float dist); float dist; void (*thinkfunc)(struct edict_s *self); } *frame; void (*endfunc)(struct edict_s *self); } *currentmove; int aiflags; int nextframe; float scale; void (*stand)(struct edict_s *self); void (*idle)(struct edict_s *self); void (*search)(struct edict_s *self); void (*walk)(struct edict_s *self); void (*run)(struct edict_s *self); void (*dodge)(struct edict_s *self, struct edict_s *other, float eta); void (*attack)(struct edict_s *self); void (*melee)(struct edict_s *self); void (*sight)(struct edict_s *self, struct edict_s *other); enum qboolean { qfalse=0, qtrue=1 } (*checkattack)(struct edict_s *self); float pausetime; float attack_finished; float saved_goal[3]; float search_time; float trail_time; float last_sighting[3]; int attack_state; int lefty; float idle_time; int linkcount; int power_armor_type; int power_armor_power; } monsterinfo; } *initiator; enum dltype_t { DL_NONE=0, DL_VPNAPI=1 } type; char path[1024]; void (*onFinish)(struct download_s *, int, unsigned char *, int); } *handle; } *

variable_types:
bytes
unsigned long

variable_types:
tmp
char *

user_defined_types: struct dlhandle_s { void *curl; unsigned long fileSize; unsigned long position; double speed; char filePath[1024]; char URL[2048]; char *tempBuffer; enum qboolean inuse; struct download_s *handle; }

user_defined_types: struct download_s { struct edict_s *initiator; enum dltype_t type; char path[1024]; void (*onFinish)(struct download_s *, int, unsigned char *, int); }

user_defined_types: struct player_state_t { struct pmove_state_t pmove; float viewangles[3]; float viewoffset[3]; float kick_angles[3]; float gunangles[3]; float gunoffset[3]; int gunindex; int gunframe; float blend[4]; float fov; int rdflags; short stats[32]; }


HandleDownload

decompiled_code:
__int64 __fastcall HandleDownload(__int64 a1, __int64 a2, unsigned int a3, unsigned int a4)
{
if ( !*(_QWORD *)a1 )
gi[1]("HandleDownload: NULL initiator");
return (*(__int64 (__fastcall **)(__int64, _QWORD, __int64, _QWORD))(a1 + 1040))(a1, a4, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, unsigned int a3, unsigned int a4)
{
if ( !*(_QWORD *)a1 )
gi[1]("HandleDownload: NULL initiator");
return (*(__int64 (__fastcall **)(__int64, _QWORD, __int64, _QWORD))(a1 + 1040))(a1, a4, a2, a3);
}

original_code:
void HandleDownload (download_t *download, char *buff, int len, int code)
{
    if (!download->initiator) {
        gi.dprintf("HandleDownload: NULL initiator");
    }
    download->onFinish(download, code, (byte *)buff, len);
}

canonical_original_code:
void HandleDownload(struct download_s *download, char *buff, int len, int code)
{
    if (!download->initiator) {
        gi.dprintf("HandleDownload: NULL initiator");
    }
    download->onFinish(download, code, (unsigned char *)buff, len);
}

variable_types: struct download_s { struct edict_s { struct entity_state_s { int number; float origin[3]; float angles[3]; float old_origin[3]; int modelindex; int modelindex2; int frame; int skinnum; int effects; int renderfx; int solid; int sound; int event; } s; struct gclient_s { struct player_state_t { struct pmove_state_t { enum pmtype_t { PM_NORMAL=0, PM_SPECTATOR=1, PM_DEAD=2, PM_GIB=3, PM_FREEZE=4 } pm_type; short origin[3]; short velocity[3]; unsigned char pm_flags; unsigned char pm_time; short gravity; short delta_angles[3]; } pmove; float viewangles[3]; float viewoffset[3]; float kick_angles[3]; float gunangles[3]; float gunoffset[3]; int gunindex; int gunframe; float blend[4]; float fov; int rdflags; short stats[32]; } ps; int ping; struct client_persistant_t { char userinfo[512]; char netname[16]; int hand; enum qboolean { qfalse=0, qtrue=1 } connected; int health; int max_health; int savedFlags; int selected_item; int inventory[256]; int max_bullets; int max_shells; int max_rockets; int max_grenades; int max_cells; int max_slugs; struct gitem_s { char *classname; enum qboolean { qfalse=0, qtrue=1 } (*pickup)(struct edict_s *ent, struct edict_s *other); void (*use)(struct edict_s *ent, struct gitem_s *item); void (*drop)(struct edict_s *ent, struct gitem_s *item); void (*weaponthink)(struct edict_s *ent); char *pickup_sound; char *world_model; int world_model_flags; char *view_model; char *icon; char *pickup_name; int count_width; int quantity; char *ammo; int flags; int weapmodel; void *info; int tag; char *precaches; } *weapon; struct gitem_s *lastweapon; int power_cubes; int score; int game_helpchanged; int helpchanged; enum qboolean { qfalse=0, qtrue=1 } spectator; } pers; struct client_respawn_t { struct client_persistant_t coop_respawn; int enterframe; int score; float cmd_angles[3]; enum qboolean { qfalse=0, qtrue=1 } spectator; } resp; struct pmove_state_t old_pmove; enum qboolean { qfalse=0, qtrue=1 } showscores; enum qboolean { qfalse=0, qtrue=1 } showinventory; enum qboolean { qfalse=0, qtrue=1 } showhelp; enum qboolean { qfalse=0, qtrue=1 } showhelpicon; int ammo_index; int buttons; int oldbuttons; int latched_buttons; enum qboolean { qfalse=0, qtrue=1 } weapon_thunk; struct gitem_s *newweapon; int damage_armor; int damage_parmor; int damage_blood; int damage_knockback; float damage_from[3]; float killer_yaw; enum weaponstate_t { WEAPON_READY=0, WEAPON_ACTIVATING=1, WEAPON_DROPPING=2, WEAPON_FIRING=3 } weaponstate; float kick_angles[3]; float kick_origin[3]; float v_dmg_roll; float fall_time; float damage_alpha; float bonus_alpha; float damage_blend[3]; float v_angle[3]; float bobtime; float oldviewangles[3]; float oldvelocity[3]; float next_drown_time; int old_waterlevel; int breather_sound; int machinegun_shots; int anim_end; int anim_priority; enum qboolean { qfalse=0, qtrue=1 } anim_duck; enum qboolean { qfalse=0, qtrue=1 } anim_run; int quad_framenum; int invincible_framenum; int breather_framenum; int enviro_framenum; enum qboolean { qfalse=0, qtrue=1 } grenade_blew_up; float grenade_time; int silencer_shots; int weapon_sound; float pickup_msg_time; float flood_locktill; float flood_when[10]; int flood_whenhead; float respawn_time; struct edict_s *chase_target; enum qboolean { qfalse=0, qtrue=1 } update_chase; } *client; enum qboolean { qfalse=0, qtrue=1 } inuse; int linkcount; struct link_s { struct link_s *prev; } area; int num_clusters; int clusternums[16]; int headnode; int areanum; int svflags; float mins[3]; float absmin[3]; enum solid_t { SOLID_NOT=0, SOLID_TRIGGER=1, SOLID_BBOX=2, SOLID_BSP=3 } solid; int clipmask; struct edict_s *owner; int movetype; int flags; char *model; float freetime; char *message; char *classname; int spawnflags; float timestamp; float angle; char *target; char *targetname; char *killtarget; char *team; char *pathtarget; char *deathtarget; char *combattarget; struct edict_s *target_ent; float speed; float movedir[3]; float pos1[3]; float velocity[3]; float avelocity[3]; int mass; float air_finished; float gravity; struct edict_s *goalentity; struct edict_s *movetarget; float yaw_speed; float ideal_yaw; float nextthink; void (*prethink)(struct edict_s *ent); void (*think)(struct edict_s *self); void (*blocked)(struct edict_s *self, struct edict_s *other); void (*touch)(struct edict_s *self, struct edict_s *other, struct cplane_s { float normal[3]; float dist; unsigned char type; unsigned char signbits; unsigned char pad[2]; } *plane, struct csurface_s { char name[16]; int flags; int value; } *surf); void (*use)(struct edict_s *self, struct edict_s *other, struct edict_s *activator); void (*pain)(struct edict_s *self, struct edict_s *other, float kick, int damage); void (*die)(struct edict_s *self, struct edict_s *inflictor, struct edict_s *attacker, int damage, float point[3]); float touch_debounce_time; float pain_debounce_time; float damage_debounce_time; float fly_sound_debounce_time; float last_move_time; int health; int max_health; int gib_health; int deadflag; enum qboolean { qfalse=0, qtrue=1 } show_hostile; float powerarmor_time; char *map; int viewheight; int takedamage; int dmg; int radius_dmg; float dmg_radius; int sounds; int count; struct edict_s *chain; struct edict_s *enemy; struct edict_s *oldenemy; struct edict_s *activator; struct edict_s *groundentity; int groundentity_linkcount; struct edict_s *teamchain; struct edict_s *teammaster; struct edict_s *mynoise; struct edict_s *mynoise2; int noise_index; int noise_index2; float volume; float attenuation; float wait; float delay; float random; float teleport_time; int watertype; int waterlevel; float move_origin[3]; float move_angles[3]; int light_level; int style; struct gitem_s *item; struct moveinfo_t { float start_origin[3]; float start_angles[3]; float end_origin[3]; float end_angles[3]; int sound_start; int sound_middle; int sound_end; float accel; float speed; float decel; float distance; float wait; int state; float dir[3]; float current_speed; float move_speed; float next_speed; float remaining_distance; float decel_distance; void (*endfunc)(struct edict_s *); } moveinfo; struct monsterinfo_t { struct mmove_t { int firstframe; int lastframe; struct mframe_t { void (*aifunc)(struct edict_s *self, float dist); float dist; void (*thinkfunc)(struct edict_s *self); } *frame; void (*endfunc)(struct edict_s *self); } *currentmove; int aiflags; int nextframe; float scale; void (*stand)(struct edict_s *self); void (*idle)(struct edict_s *self); void (*search)(struct edict_s *self); void (*walk)(struct edict_s *self); void (*run)(struct edict_s *self); void (*dodge)(struct edict_s *self, struct edict_s *other, float eta); void (*attack)(struct edict_s *self); void (*melee)(struct edict_s *self); void (*sight)(struct edict_s *self, struct edict_s *other); enum qboolean { qfalse=0, qtrue=1 } (*checkattack)(struct edict_s *self); float pausetime; float attack_finished; float saved_goal[3]; float search_time; float trail_time; float last_sighting[3]; int attack_state; int lefty; float idle_time; int linkcount; int power_armor_type; int power_armor_power; } monsterinfo; } *initiator; enum dltype_t { DL_NONE=0, DL_VPNAPI=1 } type; char path[1024]; void (*onFinish)(struct download_s *, int, unsigned char *, int); } *

variable_types:
buff
char *

variable_types: code int

user_defined_types: struct client_persistant_t { char userinfo[512]; char netname[16]; int hand; enum qboolean connected; int health; int max_health; int savedFlags; int selected_item; int inventory[256]; int max_bullets; int max_shells; int max_rockets; int max_grenades; int max_cells; int max_slugs; struct gitem_s *weapon; struct gitem_s *lastweapon; int power_cubes; int score; int game_helpchanged; int helpchanged; enum qboolean spectator; }

user_defined_types: struct client_respawn_t { struct client_persistant_t coop_respawn; int enterframe; int score; float cmd_angles[3]; enum qboolean spectator; }

user_defined_types: struct mmove_t { int firstframe; int lastframe; struct mframe_t *frame; void (*endfunc)(struct edict_s *self); }


decompiled_code:
time_t HTTP_ResolveVPNServer()
{
time_t result; // rax
struct hostent *v1; // rbx
char *v2; // rax
void (__fastcall *v3)(const char *); // r8
__int64 (*v4)(const char *, ...); // rdx

result = http_enable;
if ( http_enable )
{
result = time(0LL) - last_dns_lookup;
if ( result > 86400 )
{
((void (*)(_QWORD, __int64, const char *, ...))gi[2])(0LL, 2LL, "Resolving VPN API server %s -> ", &vpn_host);
v1 = gethostbyname(&vpn_host);
if ( v1 )
{
time(&last_dns_lookup);
v2 = inet_ntoa((struct in_addr)(*(struct in_addr **)v1->h_addr_list)->s_addr);
strncpy(&otdm_api_ip, v2, 0xFuLL);
v3 = gi[2];
byte_CE6F = 0;
result = ((__int64 (*)(_QWORD, __int64, const char *, ...))v3)(0LL, 2LL, "%s\n", &otdm_api_ip);
}
else
{
v4 = (__int64 (*)(const char *, ...))gi[1];
otdm_api_ip = 0;
result = v4("WARNING: Could not resolve VPN API server '%s'. HTTP functions unavailable.\n", &vpn_host);
}
}
}
return result;
}

canonical_decompiled_code:
time_t func4()
{
time_t result; // rax
struct hostent *v1; // rbx
char *v2; // rax
void (__fastcall *v3)(const char *); // r8
__int64 (*v4)(const char *, ...); // rdx

result = http_enable;
if ( http_enable )
{
result = time(0LL) - last_dns_lookup;
if ( result > 86400 )
{
((void (*)(_QWORD, __int64, const char *, ...))gi[2])(0LL, 2LL, "Resolving VPN API server %s -> ", &vpn_host);
v1 = gethostbyname(&vpn_host);
if ( v1 )
{
time(&last_dns_lookup);
v2 = inet_ntoa((struct in_addr)(*(struct in_addr **)v1->h_addr_list)->s_addr);
strncpy(&otdm_api_ip, v2, 0xFuLL);
v3 = gi[2];
byte_CE6F = 0;
result = ((__int64 (*)(_QWORD, __int64, const char *, ...))v3)(0LL, 2LL, "%s\n", &otdm_api_ip);
}
else
{
v4 = (__int64 (*)(const char *, ...))gi[1];
otdm_api_ip = 0;
result = v4("WARNING: Could not resolve VPN API server '%s'. HTTP functions unavailable.\n", &vpn_host);
}
}
}
return result;
}

original_code:
void HTTP_ResolveVPNServer(void)
{
    if (!http_enable) {
        return;
    }
    if (time(((void *)0)) - last_dns_lookup > 86400)
    {
        gi.cprintf(((void *)0), 2, "Resolving VPN API server %s -> ", vpn_host);
        struct hostent *h;
        h = gethostbyname(vpn_host);
        if (!h) {
            otdm_api_ip[0] = '\0';
            gi.dprintf ("WARNING: Could not resolve VPN API server '%s'. HTTP functions unavailable.\n", vpn_host);
            return;
        }
        time(&last_dns_lookup);
        do { strncpy ((otdm_api_ip), (inet_ntoa (*(struct in_addr *)h->h_addr_list[0])), (sizeof(otdm_api_ip)-1)); (otdm_api_ip)[(sizeof(otdm_api_ip)-1)] = 0; } while (0);
        gi.cprintf(((void *)0), 2, "%s\n", otdm_api_ip);
    }
}

canonical_original_code:
void HTTP_ResolveVPNServer()
{
    if (!http_enable) {
        return;
    }
    if (time(((void *)0)) - last_dns_lookup > 86400)
    {
        gi.cprintf(((void *)0), 2, "Resolving VPN API server %s -> ", vpn_host);
        struct hostent *h;
        h = gethostbyname(vpn_host);
        if (!h) {
            otdm_api_ip[0] = '\0';
            gi.dprintf ("WARNING: Could not resolve VPN API server '%s'. HTTP functions unavailable.\n", vpn_host);
            return;
        }
        time(&last_dns_lookup);
        do { strncpy ((otdm_api_ip), (inet_ntoa (*(struct in_addr *)h->h_addr_list[0])), (sizeof(otdm_api_ip)-1)); (otdm_api_ip)[(sizeof(otdm_api_ip)-1)] = 0; } while (0);
        gi.cprintf(((void *)0), 2, "%s\n", otdm_api_ip);
    }
}

variable_types: struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char **h_addr_list; } *


decompiled_code:
__int64 HTTP_Init()
{
__int64 (*v0)(const char *, ...); // rbx
const char *v1; // rax

curl_global_init(0LL);
multi = curl_multi_init();
snprintf(hostHeader, 0x40uLL, "Host: %s", &vpn_host);
http_header_slist = curl_slist_append(http_header_slist, hostHeader);
v0 = (__int64 (*)(const char *, ...))gi[1];
v1 = (const char *)curl_version();
return v0("%s initialized.\n", v1);
}

canonical_decompiled_code:
__int64 func6()
{
__int64 (*v0)(const char *, ...); // rbx
const char *v1; // rax

curl_global_init(0LL);
multi = curl_multi_init();
snprintf(hostHeader, 0x40uLL, "Host: %s", &vpn_host);
http_header_slist = curl_slist_append(http_header_slist, hostHeader);
v0 = (__int64 (*)(const char *, ...))gi[1];
v1 = (const char *)curl_version();
return v0("%s initialized.\n", v1);
}

original_code:
void HTTP_Init(void)
{
    curl_global_init(0);
    multi = curl_multi_init();
    snprintf(hostHeader, sizeof(hostHeader), "Host: %s", vpn_host);
    http_header_slist = curl_slist_append(http_header_slist, hostHeader);
    gi.dprintf("%s initialized.\n", curl_version());
}

canonical_original_code:
void HTTP_Init()
{
    curl_global_init(0);
    multi = curl_multi_init();
    snprintf(hostHeader, sizeof(hostHeader), "Host: %s", vpn_host);
    http_header_slist = curl_slist_append(http_header_slist, hostHeader);
    gi.dprintf("%s initialized.\n", curl_version());
}


decompiled_code:
__int64 HTTP_Shutdown()
{
if ( multi )
{
curl_multi_cleanup();
multi = 0LL;
}
curl_slist_free_all(http_header_slist);
return curl_global_cleanup();
}

canonical_decompiled_code:
__int64 func7()
{
if ( multi )
{
curl_multi_cleanup();
multi = 0LL;
}
curl_slist_free_all(http_header_slist);
return curl_global_cleanup();
}

original_code:
void HTTP_Shutdown(void)
{
    if (multi) {
        curl_multi_cleanup(multi);
        multi = ((void *)0);
    }
    curl_slist_free_all(http_header_slist);
    curl_global_cleanup();
}

canonical_original_code:
void HTTP_Shutdown()
{
    if (multi) {
        curl_multi_cleanup(multi);
        multi = ((void *)0);
    }
    curl_slist_free_all(http_header_slist);
    curl_global_cleanup();
}


decompiled_code:
__int64 __fastcall HTTP_QueueDownload(__int64 a1)
{
unsigned int v1; // er12
__int64 v2; // rax
_DWORD *i; // rdx
__int64 result; // rax
char *v5; // r12

if ( handleCount == 16 )
{
gi[1]("Another download is already pending, please try again later.\n");
result = 0LL;
}
else
{
v1 = http_enable;
if ( http_enable )
{
v2 = 0LL;
for ( i = (_DWORD *)((char *)&downloads + 3112); *i; i += 782 )
{
v2 = (unsigned int)(v2 + 1);
if ( (_DWORD)v2 == 16 )
{
gi[1]("The server is too busy to download configs right now.\n");
return 0LL;
}
}
v5 = (char *)&downloads + 3128 * v2;
*((_QWORD *)v5 + 390) = a1;
*((_DWORD *)v5 + 778) = 1;
strncpy(v5 + 32, (const char *)(a1 + 12), 0x3FFuLL);
v5[1055] = 0;
HTTP_StartDownload(v5);
result = 1LL;
}
else
{
gi[1]("HTTP functions are disabled on this server.\n");
result = v1;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
unsigned int v1; // er12
__int64 v2; // rax
_DWORD *i; // rdx
__int64 result; // rax
char *v5; // r12

if ( handleCount == 16 )
{
gi[1]("Another download is already pending, please try again later.\n");
result = 0LL;
}
else
{
v1 = http_enable;
if ( http_enable )
{
v2 = 0LL;
for ( i = (_DWORD *)((char *)&downloads + 3112); *i; i += 782 )
{
v2 = (unsigned int)(v2 + 1);
if ( (_DWORD)v2 == 16 )
{
gi[1]("The server is too busy to download configs right now.\n");
return 0LL;
}
}
v5 = (char *)&downloads + 3128 * v2;
*((_QWORD *)v5 + 390) = a1;
*((_DWORD *)v5 + 778) = 1;
strncpy(v5 + 32, (const char *)(a1 + 12), 0x3FFuLL);
v5[1055] = 0;
func5(v5);
result = 1LL;
}
else
{
gi[1]("HTTP functions are disabled on this server.\n");
result = v1;
}
}
return result;
}

original_code:
qboolean HTTP_QueueDownload(download_t *d)
{
    unsigned i;
    if (handleCount == 16) {
        gi.dprintf("Another download is already pending, please try again later.\n");
        return qfalse;
    }
    if (!http_enable) {
        gi.dprintf("HTTP functions are disabled on this server.\n");
        return qfalse;
    }
    for (i = 0; i < 16; i++) {
        if (!downloads[i].inuse) {
            break;
        }
    }
    if (i == 16) {
        gi.dprintf("The server is too busy to download configs right now.\n");
        return qfalse;
    }
    downloads[i].handle = d;
    downloads[i].inuse = qtrue;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
    do { strncpy ((downloads[i].filePath), (d->path), (sizeof(downloads[i].filePath)-1)); (downloads[i].filePath)[(sizeof(downloads[i].filePath)-1)] = 0; } while (0);
#pragma GCC diagnostic pop
    HTTP_StartDownload(&downloads[i]);
    return qtrue;
}

canonical_original_code:
enum qboolean HTTP_QueueDownload(struct download_s *d)
{
    unsigned int i;
    if (handleCount == 16) {
        gi.dprintf("Another download is already pending, please try again later.\n");
        return qfalse;
    }
    if (!http_enable) {
        gi.dprintf("HTTP functions are disabled on this server.\n");
        return qfalse;
    }
    for (i = 0; i < 16; i++) {
        if (!downloads[i].inuse) {
            break;
        }
    }
    if (i == 16) {
        gi.dprintf("The server is too busy to download configs right now.\n");
        return qfalse;
    }
    downloads[i].handle = d;
    downloads[i].inuse = qtrue;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
    do { strncpy ((downloads[i].filePath), (d->path), (sizeof(downloads[i].filePath)-1)); (downloads[i].filePath)[(sizeof(downloads[i].filePath)-1)] = 0; } while (0);
#pragma GCC diagnostic pop
    HTTP_StartDownload(&downloads[i]);
    return qtrue;
}

variable_types:
i
unsigned int

user_defined_types: enum dltype_t { DL_NONE=0, DL_VPNAPI=1 }

user_defined_types: struct entity_state_s { int number; float origin[3]; float angles[3]; float old_origin[3]; int modelindex; int modelindex2; int frame; int skinnum; int effects; int renderfx; int solid; int sound; int event; }

user_defined_types: struct pmove_state_t { enum pmtype_t pm_type; short origin[3]; short velocity[3]; unsigned char pm_flags; unsigned char pm_time; short gravity; short delta_angles[3]; }

user_defined_types: struct gitem_s { char *classname; enum qboolean (*pickup)(struct edict_s *ent, struct edict_s *other); void (*use)(struct edict_s *ent, struct gitem_s *item); void (*drop)(struct edict_s *ent, struct gitem_s *item); void (*weaponthink)(struct edict_s *ent); char *pickup_sound; char *world_model; int world_model_flags; char *view_model; char *icon; char *pickup_name; int count_width; int quantity; char *ammo; int flags; int weapmodel; void *info; int tag; char *precaches; }


decompiled_code:
__int64 HTTP_RunDownloads()
{
__int64 result; // rax
int v1; // ebx
unsigned int v2[7]; // [rsp+0h] [rbp-1Ch] BYREF

result = (unsigned int)handleCount;
if ( handleCount )
{
do
{
while ( 1 )
{
v1 = curl_multi_perform(multi, v2);
result = (unsigned int)handleCount;
if ( v2[0] < handleCount )
break;
if ( v1 != -1 )
goto LABEL_6;
}
HTTP_FinishDownload();
result = v2[0];
handleCount = v2[0];
}
while ( v1 == -1 );
LABEL_6:
if ( v1 )
result = ((__int64 (__fastcall *)(const char *))gi[1])("HTTP_RunDownloads: curl_multi_perform error.\n");
}
return result;
}

canonical_decompiled_code:
__int64 func9()
{
__int64 result; // rax
int v1; // ebx
unsigned int v2[7]; // [rsp+0h] [rbp-1Ch] BYREF

result = (unsigned int)handleCount;
if ( handleCount )
{
do
{
while ( 1 )
{
v1 = curl_multi_perform(multi, v2);
result = (unsigned int)handleCount;
if ( v2[0] < handleCount )
break;
if ( v1 != -1 )
goto LABEL_6;
}
func3();
result = v2[0];
handleCount = v2[0];
}
while ( v1 == -1 );
LABEL_6:
if ( v1 )
result = ((__int64 (__fastcall *)(const char *))gi[1])("HTTP_RunDownloads: curl_multi_perform error.\n");
}
return result;
}

original_code:
void HTTP_RunDownloads (void)
{
    int newHandleCount;
    CURLMcode ret;
    if (!handleCount) {
        return;
    }
    do {
        ret = curl_multi_perform(multi, &newHandleCount);
        if (newHandleCount < handleCount) {
            HTTP_FinishDownload();
            handleCount = newHandleCount;
        }
    } while (ret == CURLM_CALL_MULTI_PERFORM);
    if (ret != CURLM_OK) {
        gi.dprintf("HTTP_RunDownloads: curl_multi_perform error.\n");
    }
}

canonical_original_code:
void HTTP_RunDownloads()
{
    int newHandleCount;
    enum CURLMcode ret;
    if (!handleCount) {
        return;
    }
    do {
        ret = curl_multi_perform(multi, &newHandleCount);
        if (newHandleCount < handleCount) {
            HTTP_FinishDownload();
            handleCount = newHandleCount;
        }
    } while (ret == CURLM_CALL_MULTI_PERFORM);
    if (ret != CURLM_OK) {
        gi.dprintf("HTTP_RunDownloads: curl_multi_perform error.\n");
    }
}

variable_types: newHandleCount int

variable_types: enum CURLMcode { CURLM_CALL_MULTI_PERFORM=-1, CURLM_OK=0, CURLM_BAD_HANDLE=1, CURLM_BAD_EASY_HANDLE=2, CURLM_OUT_OF_MEMORY=3, CURLM_INTERNAL_ERROR=4, CURLM_BAD_SOCKET=5, CURLM_UNKNOWN_OPTION=6, CURLM_ADDED_ALREADY=7, CURLM_RECURSIVE_API_CALL=8, CURLM_WAKEUP_FAILURE=9, CURLM_BAD_FUNCTION_ARGUMENT=10, CURLM_ABORTED_BY_CALLBACK=11, CURLM_UNRECOVERABLE_POLL=12, CURLM_LAST=13 }


getEscape

decompiled_code:
__int64 __fastcall getEscape(char a1)
{
__int64 v1; // rax
char i; // dl

v1 = 0LL;
for ( i = 34; i != a1; i = pair_2[2 * v1] )
{
if ( ++v1 == 8 )
return 0LL;
}
return pair_2[2 * (unsigned int)v1 + 1];
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1)
{
__int64 v1; // rax
char i; // dl

v1 = 0LL;
for ( i = 34; i != a1; i = pair_2[2 * v1] )
{
if ( ++v1 == 8 )
return 0LL;
}
return pair_2[2 * (unsigned int)v1 + 1];
}

original_code:
static char getEscape( char ch ) {
    static struct { char ch; char code; } const pair[] = {
        { '\"', '\"' }, { '\\', '\\' },
        { '/', '/' }, { 'b', '\b' },
        { 'f', '\f' }, { 'n', '\n' },
        { 'r', '\r' }, { 't', '\t' },
    };
    unsigned int i;
    for( i = 0; i < sizeof pair / sizeof *pair; ++i )
        if ( pair[i].ch == ch )
            return pair[i].code;
    return '\0';
}

canonical_original_code:
static char getEscape(char ch) {
    static struct { char ch; char code; } pair[] = {
        { '\"', '\"' }, { '\\', '\\' },
        { '/', '/' }, { 'b', '\b' },
        { 'f', '\f' }, { 'n', '\n' },
        { 'r', '\r' }, { 't', '\t' },
    };
    unsigned int i;
    for( i = 0; i < sizeof pair / sizeof *pair; ++i )
        if ( pair[i].ch == ch )
            return pair[i].code;
    return '\0';
}

variable_types: ch char

variable_types:
pair
struct { char ch; char code; } []

return_type: char


checkStr

decompiled_code:
__int64 __fastcall checkStr(__int64 a1, char *a2)
{
__int64 result; // rax
char v3; // dl

result = a1;
while ( 1 )
{
v3 = *a2;
if ( !*a2 )
break;
++result;
++a2;
if ( *(_BYTE *)(result - 1) != v3 )
return 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, char *a2)
{
__int64 result; // rax
char v3; // dl

result = a1;
while ( 1 )
{
v3 = *a2;
if ( !*a2 )
break;
++result;
++a2;
if ( *(_BYTE *)(result - 1) != v3 )
return 0LL;
}
return result;
}

original_code:
static char* checkStr( char* ptr, char const* str ) {
    while( *str )
        if ( *ptr++ != *str++ )
            return 0;
    return ptr;
}

canonical_original_code:
static char *checkStr(char *ptr, char *str) {
    while( *str )
        if ( *ptr++ != *str++ )
            return 0;
    return ptr;
}

variable_types:
ptr
char *

variable_types:
str
char *

return_type: char *


poolInit

decompiled_code:
__int64 __fastcall poolInit(__int64 a1)
{
*(_DWORD *)(a1 - 4) = 1;
return *(_QWORD *)(a1 - 16);
}

original_code:
static json_t* poolInit( jsonPool_t* pool ) {
    jsonStaticPool_t *spool = ((jsonStaticPool_t*)( (char*)pool - __builtin_offsetof (jsonStaticPool_t, pool) ));
    spool->nextFree = 1;
    return spool->mem;
}

canonical_original_code:
static struct json_s *poolInit(struct jsonPool_s *pool) {
    struct jsonStaticPool_s *spool = ((jsonStaticPool_t*)( (char*)pool - __builtin_offsetof (jsonStaticPool_t, pool) ));
    spool->nextFree = 1;
    return spool->mem;
}

variable_types: struct jsonPool_s { struct json_s *(*init)(struct jsonPool_s *pool); struct json_s *(*alloc)(struct jsonPool_s *pool); } *

variable_types: struct jsonStaticPool_s { struct json_s { struct json_s *sibling; char *name; union { char *value; struct { struct json_s *child; struct json_s *last_child; } c; } u; enum jsonType_t { JSON_OBJ=0, JSON_ARRAY=1, JSON_TEXT=2, JSON_BOOLEAN=3, JSON_INTEGER=4, JSON_REAL=5, JSON_NULL=6 } type; } *mem; unsigned int qty; unsigned int nextFree; struct jsonPool_s { struct json_s *(*init)(struct jsonPool_s *pool); struct json_s *(*alloc)(struct jsonPool_s *pool); } pool; } *

user_defined_types: struct jsonStaticPool_s { struct json_s *mem; unsigned int qty; unsigned int nextFree; struct jsonPool_s pool; }

user_defined_types: struct json_s { struct json_s *sibling; char *name; union { char *value; struct { struct json_s *child; struct json_s *last_child; } c; } u; enum jsonType_t type; }


poolAlloc

decompiled_code:
__int64 __fastcall poolAlloc(__int64 a1)
{
__int64 v1; // rax

v1 = *(unsigned int *)(a1 - 4);
if ( (unsigned int)v1 >= *(_DWORD *)(a1 - 8) )
return 0LL;
*(_DWORD *)(a1 - 4) = v1 + 1;
return *(_QWORD *)(a1 - 16) + 40 * v1;
}

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

v1 = *(unsigned int *)(a1 - 4);
if ( (unsigned int)v1 >= *(_DWORD *)(a1 - 8) )
return 0LL;
*(_DWORD *)(a1 - 4) = v1 + 1;
return *(_QWORD *)(a1 - 16) + 40 * v1;
}

original_code:
static json_t* poolAlloc( jsonPool_t* pool ) {
    jsonStaticPool_t *spool = ((jsonStaticPool_t*)( (char*)pool - __builtin_offsetof (jsonStaticPool_t, pool) ));
    if ( spool->nextFree >= spool->qty ) return 0;
    return spool->mem + spool->nextFree++;
}

canonical_original_code:
static struct json_s *poolAlloc(struct jsonPool_s *pool) {
    struct jsonStaticPool_s *spool = ((jsonStaticPool_t*)( (char*)pool - __builtin_offsetof (jsonStaticPool_t, pool) ));
    if ( spool->nextFree >= spool->qty ) return 0;
    return spool->mem + spool->nextFree++;
}

return_type: struct json_s { struct json_s *sibling; char *name; union { char *value; struct { struct json_s *child; struct json_s *last_child; } c; } u; enum jsonType_t { JSON_OBJ=0, JSON_ARRAY=1, JSON_TEXT=2, JSON_BOOLEAN=3, JSON_INTEGER=4, JSON_REAL=5, JSON_NULL=6 } type; } *

user_defined_types: struct jsonPool_s { struct json_s *(*init)(struct jsonPool_s *pool); struct json_s *(*alloc)(struct jsonPool_s *pool); }


isOneOfThem

decompiled_code:
__int64 __fastcall isOneOfThem(char a1, unsigned __int8 *a2)
{
__int64 result; // rax

while ( 1 )
{
result = *a2;
if ( !(_BYTE)result )
break;
++a2;
if ( (_BYTE)result == a1 )
return 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(char a1, unsigned __int8 *a2)
{
__int64 result; // rax

while ( 1 )
{
result = *a2;
if ( !(_BYTE)result )
break;
++a2;
if ( (_BYTE)result == a1 )
return 1LL;
}
return result;
}

original_code:
static _Bool isOneOfThem( char ch, char const* set ) {
    while( *set != '\0' )
        if ( ch == *set++ )
            return 1;
    return 0;
}

canonical_original_code:
static _Bool isOneOfThem(char ch, char *set) {
    while( *set != '\0' )
        if ( ch == *set++ )
            return 1;
    return 0;
}

variable_types:
set
char *


isEndOfPrimitive

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

result = 1LL;
if ( a1 != 44 )
{
result = isOneOfThem(a1, LC1);
if ( !(_BYTE)result )
result = isOneOfThem(a1, LC0);
}
return result;
}

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

result = 1LL;
if ( a1 != 44 )
{
result = func4(a1, LC1);
if ( !(_BYTE)result )
result = func4(a1, LC0);
}
return result;
}

original_code:
static _Bool isEndOfPrimitive( char ch ) {
    return ch == ',' || isOneOfThem( ch, blank ) || isOneOfThem( ch, endofblock );
}

canonical_original_code:
static _Bool isEndOfPrimitive(char ch) {
    return ch == ',' || isOneOfThem( ch, blank ) || isOneOfThem( ch, endofblock );
}


primitiveValue

decompiled_code:
char *__fastcall primitiveValue(__int64 a1, __int64 a2, char *a3)
{
char *v3; // rax
char *v4; // r8
char *v5; // r8
_BYTE *v6; // rax
int v7; // ecx
__int64 v8; // r9

v3 = (char *)checkStr(a1, a3);
v4 = v3;
if ( !v3 )
return v4;
if ( (unsigned __int8)isEndOfPrimitive(*v3) )
{
v6 = setToNull(v5);
*(_DWORD *)(v8 + 32) = v7;
return v6;
}
return 0LL;
}

canonical_decompiled_code:
char *__fastcall func6(__int64 a1, __int64 a2, char *a3)
{
char *v3; // rax
char *v4; // r8
char *v5; // r8
_BYTE *v6; // rax
int v7; // ecx
__int64 v8; // r9

v3 = (char *)func1(a1, a3);
v4 = v3;
if ( !v3 )
return v4;
if ( (unsigned __int8)func5(*v3) )
{
v6 = setToNull(v5);
*(_DWORD *)(v8 + 32) = v7;
return v6;
}
return 0LL;
}

original_code:
static char* primitiveValue( char* ptr, json_t* property, char const* value, jsonType_t type ) {
    ptr = checkStr( ptr, value );
    if ( !ptr || !isEndOfPrimitive( *ptr ) ) return 0;
    ptr = setToNull( ptr );
    property->type = type;
    return ptr;
}

canonical_original_code:
static char *primitiveValue(char *ptr, struct json_s *property, char *value, enum jsonType_t type) {
    ptr = checkStr( ptr, value );
    if ( !ptr || !isEndOfPrimitive( *ptr ) ) return 0;
    ptr = setToNull( ptr );
    property->type = type;
    return ptr;
}

variable_types: struct json_s { struct json_s *sibling; char *name; union { char *value; struct { struct json_s *child; struct json_s *last_child; } c; } u; enum jsonType_t { JSON_OBJ=0, JSON_ARRAY=1, JSON_TEXT=2, JSON_BOOLEAN=3, JSON_INTEGER=4, JSON_REAL=5, JSON_NULL=6 } type; } *

variable_types:
value
char *


trueValue

decompiled_code:
char *__fastcall trueValue(__int64 a1, __int64 a2)
{
return primitiveValue(a1, a2, "true");
}

canonical_decompiled_code:
char *__fastcall func7(__int64 a1, __int64 a2)
{
return func6(a1, a2, "true");
}

original_code:
static char* trueValue( char* ptr, json_t* property ) {
    return primitiveValue( ptr, property, "true", JSON_BOOLEAN );
}

canonical_original_code:
static char *trueValue(char *ptr, struct json_s *property) {
    return primitiveValue( ptr, property, "true", JSON_BOOLEAN );
}

user_defined_types: enum jsonType_t { JSON_OBJ=0, JSON_ARRAY=1, JSON_TEXT=2, JSON_BOOLEAN=3, JSON_INTEGER=4, JSON_REAL=5, JSON_NULL=6 }


falseValue

decompiled_code:
char *__fastcall falseValue(__int64 a1, __int64 a2)
{
return primitiveValue(a1, a2, "false");
}

canonical_decompiled_code:
char *__fastcall func8(__int64 a1, __int64 a2)
{
return func6(a1, a2, "false");
}

original_code:
static char* falseValue( char* ptr, json_t* property ) {
    return primitiveValue( ptr, property, "false", JSON_BOOLEAN );
}

canonical_original_code:
static char *falseValue(char *ptr, struct json_s *property) {
    return primitiveValue( ptr, property, "false", JSON_BOOLEAN );
}


nullValue

decompiled_code:
char *__fastcall nullValue(__int64 a1, __int64 a2)
{
return primitiveValue(a1, a2, "null");
}

canonical_decompiled_code:
char *__fastcall func9(__int64 a1, __int64 a2)
{
return func6(a1, a2, "null");
}

original_code:
static char* nullValue( char* ptr, json_t* property ) {
    return primitiveValue( ptr, property, "null", JSON_NULL );
}

canonical_original_code:
static char *nullValue(char *ptr, struct json_s *property) {
    return primitiveValue( ptr, property, "null", JSON_NULL );
}


getCharFromUnicode

decompiled_code:
__int64 __fastcall getCharFromUnicode(unsigned __int8 *a1)
{
const unsigned __int16 **v1; // rax
unsigned __int8 *v2; // rcx

v1 = _ctype_b_loc();
v2 = a1 + 4;
while ( ((*v1)[*a1] & 0x1000) != 0 )
{
if ( v2 == ++a1 )
return 63LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(unsigned __int8 *a1)
{
const unsigned __int16 **v1; // rax
unsigned __int8 *v2; // rcx

v1 = _ctype_b_loc();
v2 = a1 + 4;
while ( ((*v1)[*a1] & 0x1000) != 0 )
{
if ( v2 == ++a1 )
return 63LL;
}
return 0LL;
}

original_code:
static unsigned char getCharFromUnicode( unsigned char const* str ) {
    unsigned int i;
    for( i = 0; i < 4; ++i )
        if ( !((*__ctype_b_loc ())[(int) ((str[i]))] & (unsigned short int) _ISxdigit) )
            return '\0';
    return '?';
}

canonical_original_code:
static unsigned char getCharFromUnicode(unsigned char *str) {
    unsigned int i;
    for( i = 0; i < 4; ++i )
        if ( !((*__ctype_b_loc ())[(int) ((str[i]))] & (unsigned short) _ISxdigit) )
            return '\0';
    return '?';
}

variable_types:
str
unsigned char *

return_type: unsigned char


goBlank

decompiled_code:
// attributes: thunk
__int64 __fastcall goBlank(char *a1)
{
return goWhile_constprop_0(a1);
}

canonical_decompiled_code:
__int64 __fastcall func15(char *a1)
{
return func14(a1);
}

original_code:
static char* goBlank( char* str ) {
    return goWhile( str, blank );
}

canonical_original_code:
static char *goBlank(char *str) {
    return goWhile( str, blank );
}


propertyName

decompiled_code:
__int64 __fastcall propertyName(__int64 a1, __int64 a2)
{
_BYTE *v2; // rdi
char *v3; // rax
_BYTE *v4; // rax
__int64 result; // rax

v2 = (_BYTE *)(a1 + 1);
*(_QWORD *)(a2 + 8) = v2;
v3 = parseString(v2);
if ( v3 && (v4 = (_BYTE *)goBlank(v3)) != 0LL && *v4 == 58 )
result = goBlank(v4 + 1);
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, __int64 a2)
{
_BYTE *v2; // rdi
char *v3; // rax
_BYTE *v4; // rax
__int64 result; // rax

v2 = (_BYTE *)(a1 + 1);
*(_QWORD *)(a2 + 8) = v2;
v3 = parseString(v2);
if ( v3 && (v4 = (_BYTE *)func15(v3)) != 0LL && *v4 == 58 )
result = func15(v4 + 1);
else
result = 0LL;
return result;
}

original_code:
static char* propertyName( char* ptr, json_t* property ) {
    property->name = ++ptr;
    ptr = parseString( ptr );
    if ( !ptr ) return 0;
    ptr = goBlank( ptr );
    if ( !ptr ) return 0;
    if ( *ptr++ != ':' ) return 0;
    return goBlank( ptr );
}

canonical_original_code:
static char *propertyName(char *ptr, struct json_s *property) {
    property->name = ++ptr;
    ptr = parseString( ptr );
    if ( !ptr ) return 0;
    ptr = goBlank( ptr );
    if ( !ptr ) return 0;
    if ( *ptr++ != ':' ) return 0;
    return goBlank( ptr );
}


decompiled_code:
__int64 __fastcall json_getPropertyValue(__int64 a1, const char *a2)
{
_QWORD *v2; // rax
__int64 v3; // rdx
__int64 result; // rax

v2 = json_getProperty(a1, a2);
if ( v2 && (unsigned int)json_getType_isra_0(*((_DWORD *)v2 + 8)) > 1 )
result = json_getValue_isra_0(*(_QWORD *)(v3 + 16));
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func20(__int64 a1, const char *a2)
{
_QWORD *v2; // rax
__int64 v3; // rdx
__int64 result; // rax

v2 = json_getProperty(a1, a2);
if ( v2 && (unsigned int)func18(*((_DWORD *)v2 + 8)) > 1 )
result = func19(*(_QWORD *)(v3 + 16));
else
result = 0LL;
return result;
}

original_code:
char const* json_getPropertyValue( json_t const* obj, char const* property ) {
 json_t const* field = json_getProperty( obj, property );
 if ( !field ) return 0;
        jsonType_t type = json_getType( field );
        if ( JSON_ARRAY >= type ) return 0;
 return json_getValue( field );
}

canonical_original_code:
char *json_getPropertyValue(struct json_s *obj, char *property) {
 struct json_s *field = json_getProperty( obj, property );
 if ( !field ) return 0;
        enum jsonType_t type = json_getType( field );
        if ( JSON_ARRAY >= type ) return 0;
 return json_getValue( field );
}

variable_types:
property
char *

variable_types: enum jsonType_t { JSON_OBJ=0, JSON_ARRAY=1, JSON_TEXT=2, JSON_BOOLEAN=3, JSON_INTEGER=4, JSON_REAL=5, JSON_NULL=6 }


decompiled_code:
__int64 G_RSAError()
{
__int64 result; // rax
unsigned int v1; // ebx

OPENSSL_init_crypto(2LL, 0LL);
while ( 1 )
{
result = ERR_get_error();
v1 = result;
if ( !(_DWORD)result )
break;
ERR_error_string((int)result, 0LL);
printf("Error (%d): %s\n", v1, 0LL);
}
return result;
}

canonical_decompiled_code:
__int64 func5()
{
__int64 result; // rax
unsigned int v1; // ebx

OPENSSL_init_crypto(2LL, 0LL);
while ( 1 )
{
result = ERR_get_error();
v1 = result;
if ( !(_DWORD)result )
break;
ERR_error_string((int)result, 0LL);
printf("Error (%d): %s\n", v1, 0LL);
}
return result;
}

original_code:
void G_RSAError()
{
    int error = 0;
    char *msg;
    OPENSSL_init_crypto(0x00000002L, ((void *)0));
    while ((error = ERR_get_error()) != 0) {
        ERR_error_string(error, msg);
        printf("Error (%d): %s\n", error, msg);
    }
}

variable_types: error int

variable_types:
msg
char *