//
// sub_1005D48A8 from 0x1005d48a8 to 0x1005d4aac (516 bytes)
//
// 2 xrefs:
// > ??> @ 0x10083b490
// > ??> @ 0x10083b560
//
// 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_1005D48A8(__int64 a1, int a2)
{
int *v3; // x24
__int64 v4; // x20
_BYTE *v5; // x21
int v6; // w0
int v7; // w8
unsigned __int64 v8; // x22
int v9; // w25
__int64 v10; // x23
__int64 v11; // x0
_QWORD *v12; // x20
int v13; // w8
__int64 v14; // x0
__int64 v15; // x0
__int64 v16; // x22
int v17; // w8
int v18; // w0
_QWORD *v19; // x21
_BYTE v21[24]; // [xsp+18h] [xbp-58h] BYREF
v3 = *(int **)(a1 + 40);
switch ( v3[6] )
{
case 0:
if ( *(_QWORD *)(a1 + 56) )
{
v5 = v21;
sub_1005ED21C(v21, a1);
}
else
{
v5 = nullptr;
}
v7 = v3[2];
if ( v7 )
{
if ( v7 <= 2 )
{
v8 = *v3;
v9 = v3[3];
v10 = *((_QWORD *)v3 + 2);
v11 = sub_1005CE9A8();
v12 = (_QWORD *)v11;
if ( v11 )
{
if ( (int)v8 <= 2047 )
v13 = 160;
else
v13 = 256;
if ( v9 == -1 )
v9 = v13;
if ( !v10 )
{
if ( (int)v8 < 2048 )
v14 = sub_1005E8F04(v11);
else
v14 = sub_1005E8F1C(v11);
v10 = v14;
}
v17 = v3[2];
if ( v17 == 2 )
{
v18 = sub_1005CDE7C((__int64)v12, v8, v9, v10, nullptr, 0, -1, nullptr, nullptr, nullptr, (__int64)v5);
}
else
{
if ( v17 != 1 )
goto LABEL_36;
v18 = sub_1005CD3AC(v12, v8, v9, v10, 0, 0, nullptr, nullptr, nullptr, (__int64)v5);
}
if ( v18 > 0 )
{
v19 = sub_1005CECC4(v12);
sub_1005CEB40((__int64)v12);
if ( v19 )
{
v6 = a2;
goto LABEL_10;
}
return 0;
}
LABEL_36:
sub_1005CEB40((__int64)v12);
}
}
}
else
{
v15 = sub_1005D2B58();
v16 = v15;
if ( v15 )
{
v4 = sub_1005D2444(v15, (unsigned int)*v3, (unsigned int)v3[1], (__int64)v5);
if ( (_DWORD)v4 )
{
sub_1005E97F4(a2);
return v4;
}
sub_1005D2CEC(v16);
}
}
return 0;
case 1:
sub_1005D5004();
goto LABEL_9;
case 2:
sub_1005D5080();
goto LABEL_9;
case 3:
sub_1005D50FC();
LABEL_9:
v6 = a2;
LABEL_10:
sub_1005E97F4(v6);
return 1;
default:
return 4294967294LL;
}
}