//
// sub_10005FD20 from 0x10005fd20 to 0x10005fec3 (419 bytes)
//
// 1 xrefs:
// > sub_10005FC00 @ 0x10005fcd9
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:19:41 +0000
//
__int64 __fastcall sub_10005FD20(__int64 a1, FILE *a2)
{
_QWORD **v3; // r13
_QWORD *i; // r15
__int64 v5; // r12
__int64 v6; // rax
_QWORD *v7; // rcx
__int64 v8; // rcx
void *v9; // rdi
size_t v10; // r15
void *v11; // rax
char *v12; // rsi
char j; // cl
char v14; // al
v3 = (_QWORD **)(a1 + 48);
for ( i = *(_QWORD **)(a1 + 48); i; i = *v3 )
{
v6 = i[9];
*(_QWORD *)(a1 + 48) = v6;
v7 = *(_QWORD **)(a1 + 56);
if ( v7 != i )
{
v8 = i[8];
if ( !v8 )
goto LABEL_7;
LABEL_6:
*(_QWORD *)(v8 + 72) = v6;
goto LABEL_7;
}
*(_QWORD *)(a1 + 56) = v7[8];
v8 = i[8];
if ( v8 )
goto LABEL_6;
LABEL_7:
if ( v6 )
*(_QWORD *)(v6 + 64) = v8;
i[2] = 0;
v5 = i[10];
(*(void (__fastcall **)(_QWORD *))(*i + 128LL))(i);
(*(void (__fastcall **)(__int64, _QWORD *))(*(_QWORD *)v5 + 32LL))(v5, i);
}
*(_OWORD *)v3 = 0;
*(_DWORD *)(a1 + 92) = 0;
*(_OWORD *)(a1 + 104) = 0;
v9 = *(void **)(a1 + 120);
if ( v9 )
operator delete[](v9);
*(_QWORD *)(a1 + 120) = 0;
fseek(a2, 0, 2);
v10 = ftell(a2);
fseek(a2, 0, 0);
if ( !v10 )
return *(unsigned int *)(a1 + 92);
v11 = operator new[](v10 + 1);
*(_QWORD *)(a1 + 120) = v11;
if ( fread(v11, 1u, v10, a2) != v10 )
{
*(_DWORD *)(a1 + 92) = 5;
LABEL_25:
*(_OWORD *)(a1 + 104) = 0;
return *(unsigned int *)(a1 + 92);
}
*(_BYTE *)(*(_QWORD *)(a1 + 120) + v10) = 0;
v12 = *(char **)(a1 + 120);
for ( j = *v12; j >= 0; j = *++v12 )
{
if ( (_DefaultRuneLocale.__runetype[(unsigned __int8)j] & 0x4000) == 0 )
break;
}
*(_BYTE *)(a1 + 88) = 0;
v14 = *v12;
if ( *v12 != -17 )
{
LABEL_22:
if ( v14 )
goto LABEL_23;
*(_DWORD *)(a1 + 92) = 15;
goto LABEL_25;
}
if ( v12[1] == -69 && v12[2] == -65 )
{
*(_BYTE *)(a1 + 88) = 1;
v14 = v12[3];
v12 += 3;
goto LABEL_22;
}
LABEL_23:
(*(void (__fastcall **)(__int64, char *, _QWORD))(*(_QWORD *)a1 + 120LL))(a1, v12, 0);
return *(unsigned int *)(a1 + 92);
}