//
// sub_10005C810 from 0x10005c810 to 0x10005cafc (748 bytes)
//
// 3 xrefs:
// > sub_10005EF60 @ 0x10005f087
// > ??> @ 0x100ab7a48
// > ??> @ 0x100ab7d68
//
// 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:40 +0000
//
char *__fastcall sub_10005C810(__int64 *a1, char *a2, __int64 a3)
{
const char *v4; // rax
__int64 v5; // r15
__int64 v6; // rbx
int v7; // r12d
__int64 v8; // rax
int v9; // eax
int *v10; // r12
char *v11; // rbx
char *v12; // rax
char v13; // dl
__int64 v14; // rcx
__int64 v15; // rbx
__int64 v16; // rax
__int64 v17; // rax
__int64 *v18; // rcx
__int64 v19; // rbx
__int64 v20; // rax
__int64 v21; // rbx
char *v24; // [rsp+10h] [rbp-50h]
__int64 v25; // [rsp+18h] [rbp-48h] BYREF
int v26; // [rsp+20h] [rbp-40h] BYREF
__int128 __p; // [rsp+28h] [rbp-38h]
while ( a2 )
{
if ( !*a2 )
break;
v25 = 0;
v4 = sub_10005B5E0(a1[1], a2, &v25);
if ( !v4 )
break;
v5 = v25;
if ( !v25 )
break;
v26 = 0;
__p = 0;
a2 = (char *)(*(__int64 (__fastcall **)(__int64, const char *, int *))(*(_QWORD *)v25 + 120LL))(v25, v4, &v26);
if ( !a2 )
{
v15 = *(_QWORD *)(v5 + 80);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v5 + 128LL))(v5);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v15 + 32LL))(v15, v5);
v16 = a1[1];
v7 = 3;
if ( *(_DWORD *)(v16 + 92) )
{
a2 = nullptr;
if ( (v26 & 0x200) != 0 )
goto LABEL_36;
}
else
{
*(_DWORD *)(v16 + 92) = 17;
*(_OWORD *)(v16 + 104) = 0;
a2 = nullptr;
if ( (v26 & 0x200) != 0 )
goto LABEL_36;
}
goto LABEL_2;
}
if ( (**(__int64 (__fastcall ***)(__int64))v5)(v5)
&& *(_DWORD *)((**(__int64 (__fastcall ***)(__int64))v5)(v5) + 88) == 2 )
{
if ( a3 )
{
*(_QWORD *)(a3 + 16) = *(_QWORD *)(v5 + 40);
*(_OWORD *)a3 = *(_OWORD *)(v5 + 24);
}
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(v5 + 80) + 40LL))(*(_QWORD *)(v5 + 80));
v6 = *(_QWORD *)(v5 + 80);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v5 + 128LL))(v5);
v7 = 1;
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v6 + 32LL))(v6, v5);
v24 = a2;
goto LABEL_35;
}
v8 = (**(__int64 (__fastcall ***)(__int64))v5)(v5);
if ( !v8 )
goto LABEL_32;
v9 = *(_DWORD *)(v8 + 88);
if ( (_QWORD)__p == *((_QWORD *)&__p + 1) )
{
if ( v9 )
{
LABEL_32:
v17 = a1[7];
v18 = (__int64 *)(v17 + 72);
if ( !v17 )
v18 = a1 + 6;
*v18 = v5;
a1[7] = v5;
*(_QWORD *)(v5 + 64) = v17;
*(_QWORD *)(v5 + 72) = 0;
*(_QWORD *)(v5 + 16) = a1;
v7 = 0;
(*(void (__fastcall **)(_QWORD))(**(_QWORD **)(v5 + 80) + 40LL))(*(_QWORD *)(v5 + 80));
LABEL_35:
if ( (v26 & 0x200) != 0 )
goto LABEL_36;
goto LABEL_2;
}
v10 = (int *)(v5 + 24);
}
else
{
v10 = (int *)(v5 + 24);
if ( !v9 )
{
v11 = (char *)sub_10005AD20(&v26);
v12 = (char *)sub_10005AD20((int *)(v5 + 24));
if ( v11 == v12 )
goto LABEL_32;
v13 = *v11;
if ( *v11 )
{
v14 = 0;
while ( v13 == v12[v14] && (_DWORD)v14 != 0x7FFFFFFF )
{
v13 = v11[++v14];
if ( !v13 )
{
if ( (_DWORD)v14 == 0x7FFFFFFF )
goto LABEL_32;
v12 += v14;
goto LABEL_24;
}
}
if ( (_DWORD)v14 == 0x7FFFFFFF )
goto LABEL_32;
}
else
{
LABEL_24:
if ( !*v12 )
goto LABEL_32;
}
}
}
v19 = a1[1];
v20 = sub_10005AD20(v10);
*(_DWORD *)(v19 + 92) = 16;
*(_QWORD *)(v19 + 104) = v20;
*(_QWORD *)(v19 + 112) = 0;
v21 = *(_QWORD *)(v5 + 80);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v5 + 128LL))(v5);
(*(void (__fastcall **)(__int64, __int64))(*(_QWORD *)v21 + 32LL))(v21, v5);
v7 = 0;
a2 = nullptr;
if ( (v26 & 0x200) != 0 )
{
LABEL_36:
if ( (_QWORD)__p )
operator delete[]((void *)__p);
}
LABEL_2:
if ( v7 )
{
if ( v7 == 1 )
return v24;
return nullptr;
}
}
return nullptr;
}