SearchDirectoryForIWAD

decompiled_code:
void *__fastcall SearchDirectoryForIWAD(__int64 a1)
{
const char *v1; // rsi
__int64 i; // rbx
void *result; // rax

v1 = "doom2";
for ( i = 0LL; ; v1 = (&iwads)[2 * i] )
{
result = CheckDirectoryHasIWAD(a1, v1);
if ( result )
break;
if ( ++i == 8 )
return result;
}
gamemission = dword_1948[4 * i];
return result;
}

canonical_decompiled_code:
void *__fastcall func9(__int64 a1)
{
const char *v1; // rsi
__int64 i; // rbx
void *result; // rax

v1 = "doom2";
for ( i = 0LL; ; v1 = (&iwads)[2 * i] )
{
result = func8(a1, v1);
if ( result )
break;
if ( ++i == 8 )
return result;
}
gamemission = dword_1948[4 * i];
return result;
}

original_code:
static char *SearchDirectoryForIWAD(char *dir)
{
    for (size_t i = 0; i < (sizeof(iwads) / sizeof(*iwads)); i++)
    {
        char *filename = CheckDirectoryHasIWAD(dir, iwads[i].name);
        if (filename)
        {
            gamemission = iwads[i].mission;
            return filename;
        }
    }
    return ((void *)0);
}

canonical_original_code:
static char *SearchDirectoryForIWAD(char *dir)
{
    for (unsigned long i = 0; i < (sizeof(iwads) / sizeof(*iwads)); i++)
    {
        char *filename = CheckDirectoryHasIWAD(dir, iwads[i].name);
        if (filename)
        {
            gamemission = iwads[i].mission;
            return filename;
        }
    }
    return ((void *)0);
}


repo: bradharding/doomretro

decompiled_code:
__int64 __fastcall D_IdentifyIWADByName(char *s)
{
char *v1; // r12
char *v2; // rax
__int64 v3; // rbx
const char *v4; // rdi
void *v5; // rbp
__int64 result; // rax

v1 = s;
v2 = strrchr(s, 92);
if ( v2 || (v2 = strrchr(s, 47)) != 0LL )
v1 = v2 + 1;
gamemission = 5;
v3 = 0LL;
v4 = "doom2";
while ( 1 )
{
v5 = (void *)M_StringJoin(v4, ".WAD", 0LL);
if ( (unsigned __int8)M_StringCompare(v1, v5) )
break;
++v3;
free(v5);
v4 = (&iwads)[2 * v3];
if ( !*v4 )
goto LABEL_7;
}
gamemission = dword_1948[4 * v3];
free(v5);
LABEL_7:
result = M_StringCompare(v1, "HACX.WAD");
if ( (_BYTE)result )
{
hacx = 1;
}
else
{
result = M_StringCompare(v1, "harmony.wad");
if ( (_BYTE)result || (result = M_StringCompare(v1, "harm1.wad"), (_BYTE)result) )
harmony = 1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(char *s)
{
char *v1; // r12
char *v2; // rax
__int64 v3; // rbx
const char *v4; // rdi
void *v5; // rbp
__int64 result; // rax

v1 = s;
v2 = strrchr(s, 92);
if ( v2 || (v2 = strrchr(s, 47)) != 0LL )
v1 = v2 + 1;
gamemission = 5;
v3 = 0LL;
v4 = "doom2";
while ( 1 )
{
v5 = (void *)M_StringJoin(v4, ".WAD", 0LL);
if ( (unsigned __int8)M_StringCompare(v1, v5) )
break;
++v3;
free(v5);
v4 = (&iwads)[2 * v3];
if ( !*v4 )
goto LABEL_7;
}
gamemission = dword_1948[4 * v3];
free(v5);
LABEL_7:
result = M_StringCompare(v1, "HACX.WAD");
if ( (_BYTE)result )
{
hacx = 1;
}
else
{
result = M_StringCompare(v1, "harmony.wad");
if ( (_BYTE)result || (result = M_StringCompare(v1, "harm1.wad"), (_BYTE)result) )
harmony = 1;
}
return result;
}

original_code:
void D_IdentifyIWADByName(char *name)
{
    char *p = strrchr(name, '\\');
    if (!p)
        p = strrchr(name, '/');
    if (p)
        name = p + 1;
    gamemission = none;
    for (size_t i = 0; iwads[i].name[0]; i++)
    {
        char *iwad = M_StringJoin(iwads[i].name, ".WAD", ((void *)0));
        if (M_StringCompare(name, iwad))
        {
            gamemission = iwads[i].mission;
            free(iwad);
            break;
        }
        free(iwad);
    }
    if (M_StringCompare(name, "HACX.WAD"))
        hacx = 1;
    else if (M_StringCompare(name, "harmony.wad") || M_StringCompare(name, "harm1.wad"))
        harmony = 1;
}

canonical_original_code:
void D_IdentifyIWADByName(char *name)
{
    char *p = strrchr(name, '\\');
    if (!p)
        p = strrchr(name, '/');
    if (p)
        name = p + 1;
    gamemission = none;
    for (unsigned long i = 0; iwads[i].name[0]; i++)
    {
        char *iwad = M_StringJoin(iwads[i].name, ".WAD", ((void *)0));
        if (M_StringCompare(name, iwad))
        {
            gamemission = iwads[i].mission;
            free(iwad);
            break;
        }
        free(iwad);
    }
    if (M_StringCompare(name, "HACX.WAD"))
        hacx = 1;
    else if (M_StringCompare(name, "harmony.wad") || M_StringCompare(name, "harm1.wad"))
        harmony = 1;
}

variable_types:
name
char *

variable_types:
p
char *

variable_types:
i
unsigned long

variable_types:
iwad
char *

return_type: void


decompiled_code:
__int64 __fastcall D_FindWADByName(__int64 a1)
{
__int64 v1; // r12
void *v3; // rbp
__int64 v4; // rbx

v1 = a1;
if ( (unsigned __int8)((__int64 (*)(void))M_FileExists)() )
return v1;
v3 = (void *)M_StringJoin(a1, ".WAD", 0LL);
if ( (unsigned __int8)M_FileExists(v3) )
return (__int64)v3;
BuildIWADDirList();
if ( num_iwad_dirs <= 0 )
{
LABEL_11:
v1 = 0LL;
free(v3);
return v1;
}
v4 = 0LL;
while ( !(unsigned __int8)M_StringEndsWith(iwad_dirs[v4], a1) || !(unsigned __int8)M_FileExists(iwad_dirs[v4]) )
{
free(v3);
v3 = (void *)M_StringJoin(iwad_dirs[v4], "/", a1);
if ( (unsigned __int8)M_FileExists(v3) )
return (__int64)v3;
if ( num_iwad_dirs <= (int)++v4 )
goto LABEL_11;
}
return M_StringDuplicate(iwad_dirs[(int)v4]);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1)
{
__int64 v1; // r12
void *v3; // rbp
__int64 v4; // rbx

v1 = a1;
if ( (unsigned __int8)((__int64 (*)(void))M_FileExists)() )
return v1;
v3 = (void *)M_StringJoin(a1, ".WAD", 0LL);
if ( (unsigned __int8)M_FileExists(v3) )
return (__int64)v3;
func6();
if ( num_iwad_dirs <= 0 )
{
LABEL_11:
v1 = 0LL;
free(v3);
return v1;
}
v4 = 0LL;
while ( !(unsigned __int8)M_StringEndsWith(iwad_dirs[v4], a1) || !(unsigned __int8)M_FileExists(iwad_dirs[v4]) )
{
free(v3);
v3 = (void *)M_StringJoin(iwad_dirs[v4], "/", a1);
if ( (unsigned __int8)M_FileExists(v3) )
return (__int64)v3;
if ( num_iwad_dirs <= (int)++v4 )
goto LABEL_11;
}
return M_StringDuplicate(iwad_dirs[(int)v4]);
}

original_code:
char *D_FindWADByName(char *filename)
{
    char *path;
    if (M_FileExists(filename))
        return filename;
    path = M_StringJoin(filename, ".WAD", ((void *)0));
    if (M_FileExists(path))
        return path;
    BuildIWADDirList();
    for (int i = 0; i < num_iwad_dirs; i++)
    {
        if (M_StringEndsWith(iwad_dirs[i], filename) && M_FileExists(iwad_dirs[i]))
            return M_StringDuplicate(iwad_dirs[i]);
        free(path);
        path = M_StringJoin(iwad_dirs[i], "/", filename, ((void *)0));
        if (M_FileExists(path))
            return path;
    }
    free(path);
    return ((void *)0);
}

variable_types:
filename
char *

variable_types:
path
char *

variable_types: i int

return_type: char *


decompiled_code:
__int64 D_InitWADfolder()
{
__int64 result; // rax
__int64 v1; // rbx

BuildIWADDirList();
result = (unsigned int)num_iwad_dirs;
if ( num_iwad_dirs > 0 )
{
v1 = 0LL;
while ( 1 )
{
result = M_FolderExists(iwad_dirs[v1]);
if ( (_BYTE)result )
break;
if ( num_iwad_dirs <= (int)++v1 )
return result;
}
result = M_StringDuplicate(iwad_dirs[(int)v1]);
wadfolder = result;
}
return result;
}

canonical_decompiled_code:
__int64 func12()
{
__int64 result; // rax
__int64 v1; // rbx

func6();
result = (unsigned int)num_iwad_dirs;
if ( num_iwad_dirs > 0 )
{
v1 = 0LL;
while ( 1 )
{
result = M_FolderExists(iwad_dirs[v1]);
if ( (_BYTE)result )
break;
if ( num_iwad_dirs <= (int)++v1 )
return result;
}
result = M_StringDuplicate(iwad_dirs[(int)v1]);
wadfolder = result;
}
return result;
}

original_code:
void D_InitWADfolder(void)
{
    BuildIWADDirList();
    for (int i = 0; i < num_iwad_dirs; i++)
        if (M_FolderExists(iwad_dirs[i]))
        {
            wadfolder = M_StringDuplicate(iwad_dirs[i]);
            break;
        }
}

canonical_original_code:
void D_InitWADfolder()
{
    BuildIWADDirList();
    for (int i = 0; i < num_iwad_dirs; i++)
        if (M_FolderExists(iwad_dirs[i]))
        {
            wadfolder = M_StringDuplicate(iwad_dirs[i]);
            break;
        }
}


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

result = D_FindWADByName(a1);
if ( !result )
result = a1;
return result;
}

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

result = func11(a1);
if ( !result )
result = a1;
return result;
}

original_code:
char *D_TryFindWADByName(char *filename)
{
    char *result = D_FindWADByName(filename);
    return (result ? result : filename);
}

variable_types:
result
char *


decompiled_code:
char *D_FindIWAD()
{
int v0; // eax
const char *v1; // rbp
char *v2; // r12
char *result; // rax
__int64 v4; // rbx
__int64 v5; // rdi

v0 = M_CheckParmWithArgs("-iwad", 1LL);
if ( v0 )
{
v1 = *(const char **)(myargv + 8LL * v0 + 8);
v2 = (char *)D_FindWADByName((__int64)v1);
if ( !v2 )
I_Error("The IWAD file \"%s\" wasn't found!", v1);
D_IdentifyIWADByName(v2);
LABEL_5:
result = v2;
}
else
{
BuildIWADDirList();
v4 = 0LL;
while ( num_iwad_dirs > (int)v4 )
{
v5 = iwad_dirs[v4++];
v2 = (char *)SearchDirectoryForIWAD(v5);
if ( v2 )
goto LABEL_5;
}
result = 0LL;
}
return result;
}

canonical_decompiled_code:
char *func14()
{
int v0; // eax
const char *v1; // rbp
char *v2; // r12
char *result; // rax
__int64 v4; // rbx
__int64 v5; // rdi

v0 = M_CheckParmWithArgs("-iwad", 1LL);
if ( v0 )
{
v1 = *(const char **)(myargv + 8LL * v0 + 8);
v2 = (char *)func11((__int64)v1);
if ( !v2 )
I_Error("The IWAD file \"%s\" wasn't found!", v1);
func10(v2);
LABEL_5:
result = v2;
}
else
{
func6();
v4 = 0LL;
while ( num_iwad_dirs > (int)v4 )
{
v5 = iwad_dirs[v4++];
v2 = (char *)func9(v5);
if ( v2 )
goto LABEL_5;
}
result = 0LL;
}
return result;
}

original_code:
char *D_FindIWAD(void)
{
    char *result = ((void *)0);
    int iwadparm = M_CheckParmWithArgs("-iwad", 1);
    if (iwadparm)
    {
        char *iwadfile = myargv[iwadparm + 1];
        if (!(result = D_FindWADByName(iwadfile)))
            I_Error("The IWAD file \"%s\" wasn't found!", iwadfile);
        D_IdentifyIWADByName(result);
    }
    else
    {
        BuildIWADDirList();
        for (int i = 0; !result && i < num_iwad_dirs; i++)
            result = SearchDirectoryForIWAD(iwad_dirs[i]);
    }
    return result;
}

canonical_original_code:
char *D_FindIWAD()
{
    char *result = ((void *)0);
    int iwadparm = M_CheckParmWithArgs("-iwad", 1);
    if (iwadparm)
    {
        char *iwadfile = myargv[iwadparm + 1];
        if (!(result = D_FindWADByName(iwadfile)))
            I_Error("The IWAD file \"%s\" wasn't found!", iwadfile);
        D_IdentifyIWADByName(result);
    }
    else
    {
        BuildIWADDirList();
        for (int i = 0; !result && i < num_iwad_dirs; i++)
            result = SearchDirectoryForIWAD(iwad_dirs[i]);
    }
    return result;
}

variable_types: iwadparm int

variable_types:
iwadfile
char *


decompiled_code:
__int64 __fastcall D_SetSaveGameFolder(char a1)
{
int v1; // eax
const char *v2; // rbp
__int64 result; // rax
unsigned int v4; // eax
__int64 v5; // rdx
void *v6; // r12
void *v7; // rbp
const char *v8; // rsi
__int64 v9; // rax
void *v10; // rsi
__int64 v11; // rsi
void *v12; // rdi

v1 = M_CheckParmsWithArgs("-save", "-savedir", &unk_1759, 1LL);
if ( v1 )
{
v2 = *(const char **)(myargv + 8LL * v1 + 8);
if ( v2[strlen(v2) - 1] != 47 )
{
savegamefolder = M_StringJoin(v2, "/", 0LL);
result = M_MakeDirectory(savegamefolder);
if ( !a1 )
return result;
goto LABEL_6;
}
}
else
{
v6 = (void *)M_GetAppDataFolder();
M_MakeDirectory(v6);
v7 = (void *)M_StringJoin(v6, "/savegames/", 0LL);
M_MakeDirectory(v7);
if ( *pwadfile )
{
v9 = GetCorrectCase();
v10 = (void *)removeext(v9);
savegamefolder = M_StringJoin(v7, v10, "/");
free(v10);
}
else
{
v8 = SaveGameIWADName();
savegamefolder = M_StringJoin(v7, v8, "/");
}
free(v6);
free(v7);
}
result = M_MakeDirectory(savegamefolder);
if ( !a1 )
return result;
LABEL_6:
v4 = M_CountSaveGames();
if ( v4 )
{
v5 = savegamefolder;
if ( v4 != 1 )
return C_Output(&unk_18B0, v4, savegamefolder);
v11 = savegamefolder;
v12 = &unk_1775;
}
else
{
v11 = savegamefolder;
v12 = &unk_1888;
}
return C_Output(v12, v11, v5);
}

canonical_decompiled_code:
__int64 __fastcall func15(char a1)
{
int v1; // eax
const char *v2; // rbp
__int64 result; // rax
unsigned int v4; // eax
__int64 v5; // rdx
void *v6; // r12
void *v7; // rbp
const char *v8; // rsi
__int64 v9; // rax
void *v10; // rsi
__int64 v11; // rsi
void *v12; // rdi

v1 = M_CheckParmsWithArgs("-save", "-savedir", &unk_1759, 1LL);
if ( v1 )
{
v2 = *(const char **)(myargv + 8LL * v1 + 8);
if ( v2[strlen(v2) - 1] != 47 )
{
savegamefolder = M_StringJoin(v2, "/", 0LL);
result = M_MakeDirectory(savegamefolder);
if ( !a1 )
return result;
goto LABEL_6;
}
}
else
{
v6 = (void *)M_GetAppDataFolder();
M_MakeDirectory(v6);
v7 = (void *)M_StringJoin(v6, "/savegames/", 0LL);
M_MakeDirectory(v7);
if ( *pwadfile )
{
v9 = GetCorrectCase();
v10 = (void *)removeext(v9);
savegamefolder = M_StringJoin(v7, v10, "/");
free(v10);
}
else
{
v8 = func1();
savegamefolder = M_StringJoin(v7, v8, "/");
}
free(v6);
free(v7);
}
result = M_MakeDirectory(savegamefolder);
if ( !a1 )
return result;
LABEL_6:
v4 = M_CountSaveGames();
if ( v4 )
{
v5 = savegamefolder;
if ( v4 != 1 )
return C_Output(&unk_18B0, v4, savegamefolder);
v11 = savegamefolder;
v12 = &unk_1775;
}
else
{
v11 = savegamefolder;
v12 = &unk_1888;
}
return C_Output(v12, v11, v5);
}

original_code:
void D_SetSaveGameFolder(_Bool output)
{
    const int p = M_CheckParmsWithArgs("-save", "-savedir", "", 1);
    if (p)
    {
        if (myargv[p + 1][strlen(myargv[p + 1]) - 1] != '/')
            savegamefolder = M_StringJoin(myargv[p + 1], "/", ((void *)0));
    }
    else
    {
        char *appdatafolder = M_GetAppDataFolder();
        char *tempsavegamefolder;
        M_MakeDirectory(appdatafolder);
        tempsavegamefolder = M_StringJoin(appdatafolder,
            "/" "savegames" "/", ((void *)0));
        M_MakeDirectory(tempsavegamefolder);
        if (*pwadfile)
        {
            char *temp = removeext(GetCorrectCase(pwadfile));
            savegamefolder = M_StringJoin(tempsavegamefolder, temp, "/", ((void *)0));
            free(temp);
        }
        else
            savegamefolder = M_StringJoin(tempsavegamefolder, SaveGameIWADName(), "/", ((void *)0));
        free(appdatafolder);
        free(tempsavegamefolder);
    }
    M_MakeDirectory(savegamefolder);
    if (output)
    {
        const int numsavegames = M_CountSaveGames();
        if (!numsavegames)
            C_Output("All savegames will be placed in " "\x1A" "%s" "\x1B" ".", savegamefolder);
        else if (numsavegames == 1)
            C_Output("There is 1 savegame in " "\x1A" "%s" "\x1B" ".", savegamefolder);
        else
            C_Output("There are %i savegames in " "\x1A" "%s" "\x1B" ".", numsavegames, savegamefolder);
    }
}

canonical_original_code:
void D_SetSaveGameFolder(_Bool output)
{
    int p = M_CheckParmsWithArgs("-save", "-savedir", "", 1);
    if (p)
    {
        if (myargv[p + 1][strlen(myargv[p + 1]) - 1] != '/')
            savegamefolder = M_StringJoin(myargv[p + 1], "/", ((void *)0));
    }
    else
    {
        char *appdatafolder = M_GetAppDataFolder();
        char *tempsavegamefolder;
        M_MakeDirectory(appdatafolder);
        tempsavegamefolder = M_StringJoin(appdatafolder,
            "/" "savegames" "/", ((void *)0));
        M_MakeDirectory(tempsavegamefolder);
        if (*pwadfile)
        {
            char *temp = removeext(GetCorrectCase(pwadfile));
            savegamefolder = M_StringJoin(tempsavegamefolder, temp, "/", ((void *)0));
            free(temp);
        }
        else
            savegamefolder = M_StringJoin(tempsavegamefolder, SaveGameIWADName(), "/", ((void *)0));
        free(appdatafolder);
        free(tempsavegamefolder);
    }
    M_MakeDirectory(savegamefolder);
    if (output)
    {
        int numsavegames = M_CountSaveGames();
        if (!numsavegames)
            C_Output("All savegames will be placed in " "\x1A" "%s" "\x1B" ".", savegamefolder);
        else if (numsavegames == 1)
            C_Output("There is 1 savegame in " "\x1A" "%s" "\x1B" ".", savegamefolder);
        else
            C_Output("There are %i savegames in " "\x1A" "%s" "\x1B" ".", numsavegames, savegamefolder);
    }
}

variable_types: p int

variable_types:
appdatafolder
char *

variable_types:
tempsavegamefolder
char *

variable_types:
temp
char *

variable_types: numsavegames int


decompiled_code:
void D_SetAutoloadFolder()
{
int v0; // eax
const char *v1; // rsi
void *v2; // rbp
__int64 v3; // rax
void *v4; // rbp

v0 = M_CheckParmsWithArgs("-autoload", "-autoloaddir", &unk_1759, 1LL);
if ( v0 )
{
M_StringCopy(autoloadfolder, *(_QWORD *)(myargv + 8LL * v0 + 8), 8LL);
}
else
{
v2 = (void *)M_GetAppDataFolder();
M_MakeDirectory(v2);
autoloadfolder = M_StringJoin(v2, "/autoload/", 0LL);
free(v2);
}
M_MakeDirectory(autoloadfolder);
v1 = SaveGameIWADName();
autoloadiwadsubfolder = M_StringJoin(autoloadfolder, v1, "/");
M_MakeDirectory(autoloadiwadsubfolder);
if ( *pwadfile )
{
v3 = GetCorrectCase();
v4 = (void *)removeext(v3);
autoloadpwadsubfolder = M_StringJoin(autoloadfolder, v4, "/");
M_MakeDirectory(autoloadpwadsubfolder);
free(v4);
}
}

canonical_decompiled_code:
void func16()
{
int v0; // eax
const char *v1; // rsi
void *v2; // rbp
__int64 v3; // rax
void *v4; // rbp

v0 = M_CheckParmsWithArgs("-autoload", "-autoloaddir", &unk_1759, 1LL);
if ( v0 )
{
M_StringCopy(autoloadfolder, *(_QWORD *)(myargv + 8LL * v0 + 8), 8LL);
}
else
{
v2 = (void *)M_GetAppDataFolder();
M_MakeDirectory(v2);
autoloadfolder = M_StringJoin(v2, "/autoload/", 0LL);
free(v2);
}
M_MakeDirectory(autoloadfolder);
v1 = func1();
autoloadiwadsubfolder = M_StringJoin(autoloadfolder, v1, "/");
M_MakeDirectory(autoloadiwadsubfolder);
if ( *pwadfile )
{
v3 = GetCorrectCase();
v4 = (void *)removeext(v3);
autoloadpwadsubfolder = M_StringJoin(autoloadfolder, v4, "/");
M_MakeDirectory(autoloadpwadsubfolder);
free(v4);
}
}

original_code:
void D_SetAutoloadFolder(void)
{
    const int p = M_CheckParmsWithArgs("-autoload", "-autoloaddir", "", 1);
    if (p)
        M_StringCopy(autoloadfolder, myargv[p + 1], sizeof(autoloadfolder));
    else
    {
        char *appdatafolder = M_GetAppDataFolder();
        M_MakeDirectory(appdatafolder);
        autoloadfolder = M_StringJoin(appdatafolder,
            "/" "autoload" "/", ((void *)0));
        free(appdatafolder);
    }
    M_MakeDirectory(autoloadfolder);
    autoloadiwadsubfolder = M_StringJoin(autoloadfolder, SaveGameIWADName(), "/", ((void *)0));
    M_MakeDirectory(autoloadiwadsubfolder);
    if (*pwadfile)
    {
        char *temp = removeext(GetCorrectCase(pwadfile));
        autoloadpwadsubfolder = M_StringJoin(autoloadfolder, temp, "/", ((void *)0));
        M_MakeDirectory(autoloadpwadsubfolder);
        free(temp);
    }
}

canonical_original_code:
void D_SetAutoloadFolder()
{
    int p = M_CheckParmsWithArgs("-autoload", "-autoloaddir", "", 1);
    if (p)
        M_StringCopy(autoloadfolder, myargv[p + 1], sizeof(autoloadfolder));
    else
    {
        char *appdatafolder = M_GetAppDataFolder();
        M_MakeDirectory(appdatafolder);
        autoloadfolder = M_StringJoin(appdatafolder,
            "/" "autoload" "/", ((void *)0));
        free(appdatafolder);
    }
    M_MakeDirectory(autoloadfolder);
    autoloadiwadsubfolder = M_StringJoin(autoloadfolder, SaveGameIWADName(), "/", ((void *)0));
    M_MakeDirectory(autoloadiwadsubfolder);
    if (*pwadfile)
    {
        char *temp = removeext(GetCorrectCase(pwadfile));
        autoloadpwadsubfolder = M_StringJoin(autoloadfolder, temp, "/", ((void *)0));
        M_MakeDirectory(autoloadpwadsubfolder);
        free(temp);
    }
}


decompiled_code:
__int64 D_SetScreenshotsFolder()
{
int v0; // eax
__int64 v1; // rdx
char *v3; // rbp

v0 = M_CheckParmsWithArgs("-shot", "-shotdir", &unk_1759, 1LL);
if ( v0 )
{
M_StringCopy(&screenshotfolder, *(_QWORD *)(myargv + 8LL * v0 + 8), 260LL);
}
else
{
v3 = (char *)M_GetAppDataFolder();
M_snprintf(&screenshotfolder, 260LL, "%s/screenshots/", v3);
free(v3);
}
M_MakeDirectory(&screenshotfolder);
return C_Output(&unk_18D0, &screenshotfolder, v1);
}

canonical_decompiled_code:
__int64 func17()
{
int v0; // eax
__int64 v1; // rdx
char *v3; // rbp

v0 = M_CheckParmsWithArgs("-shot", "-shotdir", &unk_1759, 1LL);
if ( v0 )
{
M_StringCopy(&screenshotfolder, *(_QWORD *)(myargv + 8LL * v0 + 8), 260LL);
}
else
{
v3 = (char *)M_GetAppDataFolder();
M_snprintf(&screenshotfolder, 260LL, "%s/screenshots/", v3);
free(v3);
}
M_MakeDirectory(&screenshotfolder);
return C_Output(&unk_18D0, &screenshotfolder, v1);
}

original_code:
void D_SetScreenshotsFolder(void)
{
    const int p = M_CheckParmsWithArgs("-shot", "-shotdir", "", 1);
    if (p)
        M_StringCopy(screenshotfolder, myargv[p + 1], sizeof(screenshotfolder));
    else
    {
        char *appdatafolder = M_GetAppDataFolder();
        M_snprintf(screenshotfolder, sizeof(screenshotfolder),
            "%s" "/" "screenshots" "/", appdatafolder);
        free(appdatafolder);
    }
    M_MakeDirectory(screenshotfolder);
    C_Output("All screenshots taken will be placed in " "\x1A" "%s" "\x1B" ".", screenshotfolder);
}

canonical_original_code:
void D_SetScreenshotsFolder()
{
    int p = M_CheckParmsWithArgs("-shot", "-shotdir", "", 1);
    if (p)
        M_StringCopy(screenshotfolder, myargv[p + 1], sizeof(screenshotfolder));
    else
    {
        char *appdatafolder = M_GetAppDataFolder();
        M_snprintf(screenshotfolder, sizeof(screenshotfolder),
            "%s" "/" "screenshots" "/", appdatafolder);
        free(appdatafolder);
    }
    M_MakeDirectory(screenshotfolder);
    C_Output("All screenshots taken will be placed in " "\x1A" "%s" "\x1B" ".", screenshotfolder);
}


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

result = gamemission;
if ( gamemission == 5 )
{
result = W_CheckNumForName("MAP01");
if ( (int)result >= 0 )
{
gamemission = 1;
goto LABEL_3;
}
if ( (int)W_CheckNumForName("E1M1") >= 0 )
{
gamemission = 0;
goto LABEL_7;
}
I_Error("Unknown or invalid IWAD file.");
result = gamemission;
}
if ( (_DWORD)result )
{
LABEL_3:
gamemode = 2;
return result;
}
LABEL_7:
result = W_CheckNumForName("E4M1");
if ( (int)result < 0 )
{
result = (int)W_CheckNumForName("E3M1") >= 0;
gamemode = result;
}
else
{
gamemode = 3;
}
return result;
}

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

result = gamemission;
if ( gamemission == 5 )
{
result = W_CheckNumForName("MAP01");
if ( (int)result >= 0 )
{
gamemission = 1;
goto LABEL_3;
}
if ( (int)W_CheckNumForName("E1M1") >= 0 )
{
gamemission = 0;
goto LABEL_7;
}
I_Error("Unknown or invalid IWAD file.");
result = gamemission;
}
if ( (_DWORD)result )
{
LABEL_3:
gamemode = 2;
return result;
}
LABEL_7:
result = W_CheckNumForName("E4M1");
if ( (int)result < 0 )
{
result = (int)W_CheckNumForName("E3M1") >= 0;
gamemode = result;
}
else
{
gamemode = 3;
}
return result;
}

original_code:
void D_IdentifyVersion(void)
{
    if (gamemission == none)
    {
        if (W_CheckNumForName("MAP01") >= 0)
            gamemission = doom2;
        else if (W_CheckNumForName("E1M1") >= 0)
            gamemission = doom;
        else
            I_Error("Unknown or invalid IWAD file.");
    }
    if (gamemission == doom)
    {
        if (W_CheckNumForName("E4M1") >= 0)
            gamemode = retail;
        else if (W_CheckNumForName("E3M1") >= 0)
            gamemode = registered;
        else
            gamemode = shareware;
    }
    else
        gamemode = commercial;
}

canonical_original_code:
void D_IdentifyVersion()
{
    if (gamemission == none)
    {
        if (W_CheckNumForName("MAP01") >= 0)
            gamemission = doom2;
        else if (W_CheckNumForName("E1M1") >= 0)
            gamemission = doom;
        else
            I_Error("Unknown or invalid IWAD file.");
    }
    if (gamemission == doom)
    {
        if (W_CheckNumForName("E4M1") >= 0)
            gamemode = retail;
        else if (W_CheckNumForName("E3M1") >= 0)
            gamemode = registered;
        else
            gamemode = shareware;
    }
    else
        gamemode = commercial;
}


decompiled_code:
__int64 D_SetGameDescription()
{
char v0; // bl
const char *v1; // rdx
const char *v2; // rsi
size_t v4; // rax
const char *v5; // rsi
const char *v6; // rdx
__int64 v7; // rsi
__int64 v8; // rax
__int64 v9; // [rsp-10h] [rbp-18h]

v0 = M_StringCompare(playername, "you");
if ( chex1 )
{
M_StringCopy(&gamedescription, s_CAPTION_CHEX, 255LL);
goto LABEL_27;
}
if ( chex2 )
{
M_StringCopy(&gamedescription, s_CAPTION_CHEX2, 255LL);
goto LABEL_27;
}
if ( hacx )
{
M_StringCopy(&gamedescription, s_CAPTION_HACX, 255LL);
goto LABEL_27;
}
if ( BTSXE1 )
{
M_StringCopy(&gamedescription, s_CAPTION_BTSXE1, 255LL);
goto LABEL_27;
}
if ( BTSXE2 )
{
M_StringCopy(&gamedescription, s_CAPTION_BTSXE2, 255LL);
goto LABEL_27;
}
if ( BTSXE3 )
{
M_StringCopy(&gamedescription, s_CAPTION_BTSXE3, 255LL);
goto LABEL_27;
}
if ( REKKRSL )
{
M_StringCopy(&gamedescription, s_CAPTION_REKKRSL, 255LL);
goto LABEL_27;
}
if ( REKKR )
{
M_StringCopy(&gamedescription, s_CAPTION_REKKR, 255LL);
goto LABEL_27;
}
if ( anomalyreport )
{
M_StringCopy(&gamedescription, s_CAPTION_ANOMALYREPORT, 255LL);
goto LABEL_27;
}
if ( arrival )
{
M_StringCopy(&gamedescription, s_CAPTION_ARRIVAL, 255LL);
goto LABEL_27;
}
if ( dbimpact )
{
M_StringCopy(&gamedescription, s_CAPTION_DBIMPACT, 255LL);
goto LABEL_27;
}
if ( deathless )
{
M_StringCopy(&gamedescription, s_CAPTION_DEATHLESS, 255LL);
goto LABEL_27;
}
if ( doomzero )
{
M_StringCopy(&gamedescription, s_CAPTION_DOOMZERO, 255LL);
goto LABEL_27;
}
if ( earthless )
{
M_StringCopy(&gamedescription, s_CAPTION_EARTHLESS, 255LL);
goto LABEL_27;
}
if ( ganymede )
{
M_StringCopy(&gamedescription, s_CAPTION_GANYMEDE, 255LL);
goto LABEL_27;
}
if ( harmony )
{
M_StringCopy(&gamedescription, s_CAPTION_HARMONY, 255LL);
goto LABEL_27;
}
if ( KDIKDIZD )
{
M_StringCopy(&gamedescription, s_CAPTION_KDIKDIZD, 255LL);
goto LABEL_27;
}
if ( neis )
{
M_StringCopy(&gamedescription, s_CAPTION_NEIS, 255LL);
goto LABEL_27;
}
if ( revolution )
{
M_StringCopy(&gamedescription, s_CAPTION_REVOLUTION, 255LL);
goto LABEL_27;
}
if ( syringe )
{
M_StringCopy(&gamedescription, s_CAPTION_SYRINGE, 255LL);
goto LABEL_27;
}
if ( !gamemission )
{
if ( !modifiedgame || !*pwadfile )
{
if ( FREEDOOM )
M_StringCopy(&gamedescription, s_CAPTION_FREEDOOM1, 255LL);
else
M_StringCopy(&gamedescription, s_CAPTION_DOOM, 255LL);
goto LABEL_27;
}
LABEL_69:
v8 = GetCorrectCase();
return M_StringCopy(&gamedescription, v8, 255LL);
}
if ( modifiedgame && *pwadfile )
{
if ( !(unsigned __int8)M_StringCompare(pwadfile, "nerve.wad") )
goto LABEL_69;
goto LABEL_68;
}
if ( FREEDOOM )
{
v7 = s_CAPTION_FREEDOOM2;
if ( FREEDM )
v7 = s_CAPTION_FREEDM;
M_StringCopy(&gamedescription, v7, 255LL);
goto LABEL_27;
}
if ( nerve )
{
LABEL_68:
M_StringCopy(&gamedescription, s_CAPTION_DOOM2, 255LL);
goto LABEL_27;
}
switch ( gamemission )
{
case 1:
M_snprintf(&gamedescription, 255LL, "%s: %s", s_CAPTION_DOOM2, s_CAPTION_HELLONEARTH);
break;
case 3:
M_StringCopy(&gamedescription, s_CAPTION_PLUTONIA, 255LL);
break;
case 2:
M_StringCopy(&gamedescription, s_CAPTION_TNT, 255LL);
break;
default:
goto LABEL_32;
}
LABEL_27:
if ( nerve )
{
if ( v0 )
{
v1 = "are";
v2 = "You";
}
else
{
v2 = (const char *)playername;
v1 = "is";
}
v9 = s_CAPTION_NERVE;
C_Output(&unk_1900, v2, v1);
return v9;
}
LABEL_32:
v4 = strlen(&gamedescription);
ispunctuation((unsigned int)*(&gamedescription + v4 - 1));
if ( v0 )
{
v6 = "are";
v5 = "You";
}
else
{
v5 = (const char *)playername;
v6 = "is";
}
return C_Output(&unk_1828, v5, v6);
}

canonical_decompiled_code:
__int64 func19()
{
char v0; // bl
const char *v1; // rdx
const char *v2; // rsi
size_t v4; // rax
const char *v5; // rsi
const char *v6; // rdx
__int64 v7; // rsi
__int64 v8; // rax
__int64 v9; // [rsp-10h] [rbp-18h]

v0 = M_StringCompare(playername, "you");
if ( chex1 )
{
M_StringCopy(&gamedescription, s_CAPTION_CHEX, 255LL);
goto LABEL_27;
}
if ( chex2 )
{
M_StringCopy(&gamedescription, s_CAPTION_CHEX2, 255LL);
goto LABEL_27;
}
if ( hacx )
{
M_StringCopy(&gamedescription, s_CAPTION_HACX, 255LL);
goto LABEL_27;
}
if ( BTSXE1 )
{
M_StringCopy(&gamedescription, s_CAPTION_BTSXE1, 255LL);
goto LABEL_27;
}
if ( BTSXE2 )
{
M_StringCopy(&gamedescription, s_CAPTION_BTSXE2, 255LL);
goto LABEL_27;
}
if ( BTSXE3 )
{
M_StringCopy(&gamedescription, s_CAPTION_BTSXE3, 255LL);
goto LABEL_27;
}
if ( REKKRSL )
{
M_StringCopy(&gamedescription, s_CAPTION_REKKRSL, 255LL);
goto LABEL_27;
}
if ( REKKR )
{
M_StringCopy(&gamedescription, s_CAPTION_REKKR, 255LL);
goto LABEL_27;
}
if ( anomalyreport )
{
M_StringCopy(&gamedescription, s_CAPTION_ANOMALYREPORT, 255LL);
goto LABEL_27;
}
if ( arrival )
{
M_StringCopy(&gamedescription, s_CAPTION_ARRIVAL, 255LL);
goto LABEL_27;
}
if ( dbimpact )
{
M_StringCopy(&gamedescription, s_CAPTION_DBIMPACT, 255LL);
goto LABEL_27;
}
if ( deathless )
{
M_StringCopy(&gamedescription, s_CAPTION_DEATHLESS, 255LL);
goto LABEL_27;
}
if ( doomzero )
{
M_StringCopy(&gamedescription, s_CAPTION_DOOMZERO, 255LL);
goto LABEL_27;
}
if ( earthless )
{
M_StringCopy(&gamedescription, s_CAPTION_EARTHLESS, 255LL);
goto LABEL_27;
}
if ( ganymede )
{
M_StringCopy(&gamedescription, s_CAPTION_GANYMEDE, 255LL);
goto LABEL_27;
}
if ( harmony )
{
M_StringCopy(&gamedescription, s_CAPTION_HARMONY, 255LL);
goto LABEL_27;
}
if ( KDIKDIZD )
{
M_StringCopy(&gamedescription, s_CAPTION_KDIKDIZD, 255LL);
goto LABEL_27;
}
if ( neis )
{
M_StringCopy(&gamedescription, s_CAPTION_NEIS, 255LL);
goto LABEL_27;
}
if ( revolution )
{
M_StringCopy(&gamedescription, s_CAPTION_REVOLUTION, 255LL);
goto LABEL_27;
}
if ( syringe )
{
M_StringCopy(&gamedescription, s_CAPTION_SYRINGE, 255LL);
goto LABEL_27;
}
if ( !gamemission )
{
if ( !modifiedgame || !*pwadfile )
{
if ( FREEDOOM )
M_StringCopy(&gamedescription, s_CAPTION_FREEDOOM1, 255LL);
else
M_StringCopy(&gamedescription, s_CAPTION_DOOM, 255LL);
goto LABEL_27;
}
LABEL_69:
v8 = GetCorrectCase();
return M_StringCopy(&gamedescription, v8, 255LL);
}
if ( modifiedgame && *pwadfile )
{
if ( !(unsigned __int8)M_StringCompare(pwadfile, "nerve.wad") )
goto LABEL_69;
goto LABEL_68;
}
if ( FREEDOOM )
{
v7 = s_CAPTION_FREEDOOM2;
if ( FREEDM )
v7 = s_CAPTION_FREEDM;
M_StringCopy(&gamedescription, v7, 255LL);
goto LABEL_27;
}
if ( nerve )
{
LABEL_68:
M_StringCopy(&gamedescription, s_CAPTION_DOOM2, 255LL);
goto LABEL_27;
}
switch ( gamemission )
{
case 1:
M_snprintf(&gamedescription, 255LL, "%s: %s", s_CAPTION_DOOM2, s_CAPTION_HELLONEARTH);
break;
case 3:
M_StringCopy(&gamedescription, s_CAPTION_PLUTONIA, 255LL);
break;
case 2:
M_StringCopy(&gamedescription, s_CAPTION_TNT, 255LL);
break;
default:
goto LABEL_32;
}
LABEL_27:
if ( nerve )
{
if ( v0 )
{
v1 = "are";
v2 = "You";
}
else
{
v2 = (const char *)playername;
v1 = "is";
}
v9 = s_CAPTION_NERVE;
C_Output(&unk_1900, v2, v1);
return v9;
}
LABEL_32:
v4 = strlen(&gamedescription);
ispunctuation((unsigned int)*(&gamedescription + v4 - 1));
if ( v0 )
{
v6 = "are";
v5 = "You";
}
else
{
v5 = (const char *)playername;
v6 = "is";
}
return C_Output(&unk_1828, v5, v6);
}

original_code:
void D_SetGameDescription(void)
{
    _Bool defaultname = M_StringCompare(playername, "you");
    if (chex1)
        M_StringCopy(gamedescription, s_CAPTION_CHEX, sizeof(gamedescription));
    else if (chex2)
        M_StringCopy(gamedescription, s_CAPTION_CHEX2, sizeof(gamedescription));
    else if (hacx)
        M_StringCopy(gamedescription, s_CAPTION_HACX, sizeof(gamedescription));
    else if (BTSXE1)
        M_StringCopy(gamedescription, s_CAPTION_BTSXE1, sizeof(gamedescription));
    else if (BTSXE2)
        M_StringCopy(gamedescription, s_CAPTION_BTSXE2, sizeof(gamedescription));
    else if (BTSXE3)
        M_StringCopy(gamedescription, s_CAPTION_BTSXE3, sizeof(gamedescription));
    else if (REKKRSL)
        M_StringCopy(gamedescription, s_CAPTION_REKKRSL, sizeof(gamedescription));
    else if (REKKR)
        M_StringCopy(gamedescription, s_CAPTION_REKKR, sizeof(gamedescription));
    else if (anomalyreport)
        M_StringCopy(gamedescription, s_CAPTION_ANOMALYREPORT, sizeof(gamedescription));
    else if (arrival)
        M_StringCopy(gamedescription, s_CAPTION_ARRIVAL, sizeof(gamedescription));
    else if (dbimpact)
        M_StringCopy(gamedescription, s_CAPTION_DBIMPACT, sizeof(gamedescription));
    else if (deathless)
        M_StringCopy(gamedescription, s_CAPTION_DEATHLESS, sizeof(gamedescription));
    else if (doomzero)
        M_StringCopy(gamedescription, s_CAPTION_DOOMZERO, sizeof(gamedescription));
    else if (earthless)
        M_StringCopy(gamedescription, s_CAPTION_EARTHLESS, sizeof(gamedescription));
    else if (ganymede)
        M_StringCopy(gamedescription, s_CAPTION_GANYMEDE, sizeof(gamedescription));
    else if (harmony)
        M_StringCopy(gamedescription, s_CAPTION_HARMONY, sizeof(gamedescription));
    else if (KDIKDIZD)
        M_StringCopy(gamedescription, s_CAPTION_KDIKDIZD, sizeof(gamedescription));
    else if (neis)
        M_StringCopy(gamedescription, s_CAPTION_NEIS, sizeof(gamedescription));
    else if (revolution)
        M_StringCopy(gamedescription, s_CAPTION_REVOLUTION, sizeof(gamedescription));
    else if (syringe)
        M_StringCopy(gamedescription, s_CAPTION_SYRINGE, sizeof(gamedescription));
    else if (gamemission == doom)
    {
        if (modifiedgame && *pwadfile)
        {
            M_StringCopy(gamedescription, GetCorrectCase(pwadfile), sizeof(gamedescription));
            return;
        }
        else if (FREEDOOM)
            M_StringCopy(gamedescription, s_CAPTION_FREEDOOM1, sizeof(gamedescription));
        else
            M_StringCopy(gamedescription, s_CAPTION_DOOM, sizeof(gamedescription));
    }
    else
    {
        if (modifiedgame && *pwadfile)
        {
            if (M_StringCompare(pwadfile, "nerve.wad"))
                M_StringCopy(gamedescription, s_CAPTION_DOOM2, sizeof(gamedescription));
            else
            {
                M_StringCopy(gamedescription, GetCorrectCase(pwadfile), sizeof(gamedescription));
                return;
            }
        }
        else if (FREEDOOM)
            M_StringCopy(gamedescription, (FREEDM ? s_CAPTION_FREEDM : s_CAPTION_FREEDOOM2), sizeof(gamedescription));
        else if (nerve)
            M_StringCopy(gamedescription, s_CAPTION_DOOM2, sizeof(gamedescription));
        else if (gamemission == doom2)
            M_snprintf(gamedescription, sizeof(gamedescription), "%s: %s", s_CAPTION_DOOM2, s_CAPTION_HELLONEARTH);
        else if (gamemission == pack_plut)
            M_StringCopy(gamedescription, s_CAPTION_PLUTONIA, sizeof(gamedescription));
        else if (gamemission == pack_tnt)
            M_StringCopy(gamedescription, s_CAPTION_TNT, sizeof(gamedescription));
    }
    if (nerve)
        C_Output("%s %s playing " "\x1C" "%s: %s" "\x1D" " and " "\x1C" "%s: %s." "\x1D",
            (defaultname ? "You" : playername), (defaultname ? "are" : "is"),
            s_CAPTION_DOOM2, s_CAPTION_HELLONEARTH, s_CAPTION_DOOM2, s_CAPTION_NERVE);
    else
        C_Output("%s %s playing " "\x1C" "%s%s" "\x1D",
            (defaultname ? "You" : playername), (defaultname ? "are" : "is"),
            gamedescription, (ispunctuation(gamedescription[strlen(gamedescription) - 1]) ? "" : "."));
}

canonical_original_code:
void D_SetGameDescription()
{
    _Bool defaultname = M_StringCompare(playername, "you");
    if (chex1)
        M_StringCopy(gamedescription, s_CAPTION_CHEX, sizeof(gamedescription));
    else if (chex2)
        M_StringCopy(gamedescription, s_CAPTION_CHEX2, sizeof(gamedescription));
    else if (hacx)
        M_StringCopy(gamedescription, s_CAPTION_HACX, sizeof(gamedescription));
    else if (BTSXE1)
        M_StringCopy(gamedescription, s_CAPTION_BTSXE1, sizeof(gamedescription));
    else if (BTSXE2)
        M_StringCopy(gamedescription, s_CAPTION_BTSXE2, sizeof(gamedescription));
    else if (BTSXE3)
        M_StringCopy(gamedescription, s_CAPTION_BTSXE3, sizeof(gamedescription));
    else if (REKKRSL)
        M_StringCopy(gamedescription, s_CAPTION_REKKRSL, sizeof(gamedescription));
    else if (REKKR)
        M_StringCopy(gamedescription, s_CAPTION_REKKR, sizeof(gamedescription));
    else if (anomalyreport)
        M_StringCopy(gamedescription, s_CAPTION_ANOMALYREPORT, sizeof(gamedescription));
    else if (arrival)
        M_StringCopy(gamedescription, s_CAPTION_ARRIVAL, sizeof(gamedescription));
    else if (dbimpact)
        M_StringCopy(gamedescription, s_CAPTION_DBIMPACT, sizeof(gamedescription));
    else if (deathless)
        M_StringCopy(gamedescription, s_CAPTION_DEATHLESS, sizeof(gamedescription));
    else if (doomzero)
        M_StringCopy(gamedescription, s_CAPTION_DOOMZERO, sizeof(gamedescription));
    else if (earthless)
        M_StringCopy(gamedescription, s_CAPTION_EARTHLESS, sizeof(gamedescription));
    else if (ganymede)
        M_StringCopy(gamedescription, s_CAPTION_GANYMEDE, sizeof(gamedescription));
    else if (harmony)
        M_StringCopy(gamedescription, s_CAPTION_HARMONY, sizeof(gamedescription));
    else if (KDIKDIZD)
        M_StringCopy(gamedescription, s_CAPTION_KDIKDIZD, sizeof(gamedescription));
    else if (neis)
        M_StringCopy(gamedescription, s_CAPTION_NEIS, sizeof(gamedescription));
    else if (revolution)
        M_StringCopy(gamedescription, s_CAPTION_REVOLUTION, sizeof(gamedescription));
    else if (syringe)
        M_StringCopy(gamedescription, s_CAPTION_SYRINGE, sizeof(gamedescription));
    else if (gamemission == doom)
    {
        if (modifiedgame && *pwadfile)
        {
            M_StringCopy(gamedescription, GetCorrectCase(pwadfile), sizeof(gamedescription));
            return;
        }
        else if (FREEDOOM)
            M_StringCopy(gamedescription, s_CAPTION_FREEDOOM1, sizeof(gamedescription));
        else
            M_StringCopy(gamedescription, s_CAPTION_DOOM, sizeof(gamedescription));
    }
    else
    {
        if (modifiedgame && *pwadfile)
        {
            if (M_StringCompare(pwadfile, "nerve.wad"))
                M_StringCopy(gamedescription, s_CAPTION_DOOM2, sizeof(gamedescription));
            else
            {
                M_StringCopy(gamedescription, GetCorrectCase(pwadfile), sizeof(gamedescription));
                return;
            }
        }
        else if (FREEDOOM)
            M_StringCopy(gamedescription, (FREEDM ? s_CAPTION_FREEDM : s_CAPTION_FREEDOOM2), sizeof(gamedescription));
        else if (nerve)
            M_StringCopy(gamedescription, s_CAPTION_DOOM2, sizeof(gamedescription));
        else if (gamemission == doom2)
            M_snprintf(gamedescription, sizeof(gamedescription), "%s: %s", s_CAPTION_DOOM2, s_CAPTION_HELLONEARTH);
        else if (gamemission == pack_plut)
            M_StringCopy(gamedescription, s_CAPTION_PLUTONIA, sizeof(gamedescription));
        else if (gamemission == pack_tnt)
            M_StringCopy(gamedescription, s_CAPTION_TNT, sizeof(gamedescription));
    }
    if (nerve)
        C_Output("%s %s playing " "\x1C" "%s: %s" "\x1D" " and " "\x1C" "%s: %s." "\x1D",
            (defaultname ? "You" : playername), (defaultname ? "are" : "is"),
            s_CAPTION_DOOM2, s_CAPTION_HELLONEARTH, s_CAPTION_DOOM2, s_CAPTION_NERVE);
    else
        C_Output("%s %s playing " "\x1C" "%s%s" "\x1D",
            (defaultname ? "You" : playername), (defaultname ? "are" : "is"),
            gamedescription, (ispunctuation(gamedescription[strlen(gamedescription) - 1]) ? "" : "."));
}


ABS

decompiled_code:
__int64 __fastcall ABS(int a1)
{
return abs32(a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return abs32(a1);
}

original_code:
__attribute__((const)) static inline int ABS(int a)
{
    return (a < 0 ? -a : a);
}

variable_types: a int

return_type: int


FixedDiv

decompiled_code:
__int64 __fastcall FixedDiv(int a1, int a2)
{
int v2; // eax
int v3; // ecx
int v4; // er8
__int64 result; // rax

ABS(a1);
v2 = ABS(a2);
if ( v4 >> 15 < v2 )
result = ((__int64)v3 << 16) / a2;
else
result = ((a2 ^ v3) >> 31) ^ 0x7FFFFFFFu;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, int a2)
{
int v2; // eax
int v3; // ecx
int v4; // er8
__int64 result; // rax

func0(a1);
v2 = func0(a2);
if ( v4 >> 15 < v2 )
result = ((__int64)v3 << 16) / a2;
else
result = ((a2 ^ v3) >> 31) ^ 0x7FFFFFFFu;
return result;
}

original_code:
__attribute__((const)) static inline fixed_t FixedDiv(fixed_t a, fixed_t b)
{
    return (((int64_t)ABS(a) >> 15) >= ABS(b) ? (((int64_t)(a ^ b) >> 31) ^ (2147483647)) : (((int64_t)a << 16) / b));
}

canonical_original_code:
static inline int FixedDiv(int a, int b)
{
    return (((long)ABS(a) >> 15) >= ABS(b) ? (((long)(a ^ b) >> 31) ^ (2147483647)) : (((long)a << 16) / b));
}

variable_types: b int