//
// sub_10052677C from 0x10052677c to 0x100526994 (536 bytes)
//
// 2 xrefs:
// > sub_100521AE0 @ 0x100521e3c
// > sub_100538A48 @ 0x100538ce4
//
// 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_10052677C(__int64 a1)
{
__int64 result; // x0
__int64 v3; // x4
unsigned __int8 *v4; // x22
__int64 v5; // x23
unsigned __int8 v6; // w24
unsigned __int8 v7; // w25
__int64 v8; // x26
size_t v9; // x20
__int64 v10; // x21
__int64 v11; // x0
int v12; // w8
void (*v13)(void); // x8
void *v14; // x0
void *v15; // x0
unsigned __int8 *v16; // x21
void *v17; // x0
__int64 v18; // x8
__int64 v19; // x19
__int64 v20; // x22
__int64 v21; // x0
int v22; // [xsp+Ch] [xbp-44h]
result = (*(__int64 (**)(void))(*(_QWORD *)(a1 + 8) + 96LL))();
if ( v22 )
{
if ( result <= 5 )
{
v3 = 2255;
LABEL_11:
sub_1005E0E48(20, 283, 159, "s3_clnt.c", v3);
LABEL_12:
sub_10052C058(a1, 2);
LABEL_13:
*(_DWORD *)(a1 + 72) = 5;
return 0xFFFFFFFFLL;
}
v4 = *(unsigned __int8 **)(a1 + 88);
v5 = *v4;
v6 = v4[1];
v7 = v4[2];
v8 = v4[3];
v9 = v4[5] | (v4[4] << 8);
if ( (_DWORD)v9 + 6 != result )
{
v3 = 2266;
goto LABEL_11;
}
if ( (_DWORD)v9 )
{
v10 = *(_QWORD *)(a1 + 304);
if ( *(_DWORD *)(v10 + 68) )
{
v11 = *(_QWORD *)(a1 + 624);
v12 = *(_DWORD *)(v11 + 64);
if ( (v12 & 1) != 0 )
{
if ( (v12 & 0x200) != 0 )
{
v13 = *(void (**)(void))(v11 + 88);
if ( v13 )
v13();
}
else
{
sub_100542EB4();
}
}
v10 = sub_100542110(*(_QWORD *)(a1 + 304), 0);
if ( !v10 )
{
sub_1005E0E48(20, 283, 65, "s3_clnt.c", 2297);
goto LABEL_12;
}
sub_1005422E0(*(_QWORD *)(a1 + 304));
*(_QWORD *)(a1 + 304) = v10;
}
v14 = *(void **)(v10 + 320);
if ( v14 )
{
sub_100588C44(v14);
*(_QWORD *)(*(_QWORD *)(a1 + 304) + 328LL) = 0;
}
v15 = (void *)sub_100588710(v9, "s3_clnt.c", 2309);
*(_QWORD *)(*(_QWORD *)(a1 + 304) + 320LL) = v15;
if ( !v15 )
{
sub_1005E0E48(20, 283, 65, "s3_clnt.c", 2311);
goto LABEL_13;
}
v16 = v4 + 6;
v17 = memcpy(v15, v4 + 6, v9);
v18 = *(_QWORD *)(a1 + 304);
*(_QWORD *)(v18 + 328) = v9;
*(_QWORD *)(v18 + 336) = (v5 << 24) | ((unsigned __int64)v6 << 16) | ((unsigned __int64)v7 << 8) | v8;
v19 = v18 + 72;
v20 = v18 + 68;
v21 = sub_1005E8F1C(v17);
sub_1005E33FC(v16, v9, v19, v20, v21, 0);
}
return 1;
}
return result;
}