//
// sub_1005F345C from 0x1005f345c to 0x1005f3620 (452 bytes)
//
// 1 xrefs:
// > ??> @ 0x10083e6d0
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall sub_1005F345C(void **a1, const void **a2, __int64 a3)
{
_BYTE *v5; // x22
__int64 result; // x0
void **v7; // x21
void *v8; // x0
int v9; // w0
__int64 v10; // x21
int v11; // w8
_QWORD *v12; // x0
int v13; // w22
unsigned int *v14; // x23
int v15; // w24
__int64 v16; // x0
int v17; // w8
__int64 v18; // [xsp+8h] [xbp-48h] BYREF
void *v19; // [xsp+10h] [xbp-40h] BYREF
_BYTE *v20; // [xsp+18h] [xbp-38h] BYREF
v5 = *a2;
v19 = nullptr;
v20 = v5;
v18 = 0;
result = sub_1005F6E94(&v19, &v20, a3, &unk_10083E678);
if ( (int)result >= 1 )
{
v7 = (void **)*a1;
if ( *a1 )
{
sub_1005D9DF8(v7[2]);
sub_1005DE9D0(*v7, (void (*)(void))sub_1005F3328);
v8 = v7[3];
if ( v8 )
sub_100588C44(v8);
sub_100588C44(v7);
*a1 = nullptr;
}
v9 = sub_1005F3348(&v18);
v10 = v18;
if ( v9 && (unsigned int)sub_1005D9E40(*(unsigned __int64 **)(v18 + 16), v20 - v5) )
{
memcpy(*(void **)(*(_QWORD *)(v10 + 16) + 8LL), v5, v20 - v5);
v11 = sub_1005DEA4C((unsigned int *)v19);
v12 = v19;
if ( v11 >= 1 )
{
v13 = 0;
while ( 1 )
{
v14 = (unsigned int *)sub_1005DEA60((__int64)v12, v13);
if ( (int)sub_1005DEA4C(v14) > 0 )
break;
LABEL_14:
sub_1005DE314(v14);
++v13;
v17 = sub_1005DEA4C((unsigned int *)v19);
v12 = v19;
if ( v13 >= v17 )
goto LABEL_15;
}
v15 = 0;
while ( 1 )
{
v16 = sub_1005DEA60((__int64)v14, v15);
*(_DWORD *)(v16 + 16) = v13;
if ( !(unsigned int)sub_1005DE80C(*(void ***)v10, v16) )
goto LABEL_18;
if ( ++v15 >= (int)sub_1005DEA4C(v14) )
goto LABEL_14;
}
}
LABEL_15:
sub_1005DE314(v12);
result = sub_1005F385C(v10);
if ( (_DWORD)result )
{
*(_DWORD *)(v10 + 8) = 0;
*a1 = (void *)v10;
*a2 = v20;
return result;
}
}
if ( !v10 )
{
LABEL_19:
sub_1005E0E48(13, 158, 58, (__int64)"x_name.c", 236);
return 0;
}
LABEL_18:
sub_1005F5B94(v10, &unk_10083E6E8);
goto LABEL_19;
}
return result;
}