//
// sub_1005103AC from 0x1005103ac to 0x100510588 (476 bytes)
//
// 1 xrefs:
// > sub_10050FDF8 @ 0x10050fdfc
//
// 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_1005103AC(__int64 a1, int a2)
{
unsigned int v3; // w1
__int64 result; // x0
__int64 v5; // x20
int v6; // w8
__int64 v7; // x1
unsigned __int64 v8; // x0
__int64 v9; // x8
int v10; // w9
int v11; // w11
int *v12; // x9
int v13; // w13
__int64 v14; // x12
__int64 v15; // x10
__int64 v16; // x9
int v17; // t1
__int64 v18; // x10
int v19; // w11
int v20; // [xsp+Ch] [xbp-14h] BYREF
if ( a2 == 128 )
{
v5 = a1 + 600;
while ( *(_QWORD *)v5 != v5 )
{
if ( !*(_QWORD *)(*(_QWORD *)v5 + 16LL) )
return 28;
result = sub_100510CE4();
if ( (_DWORD)result )
return result;
}
v9 = *(_QWORD *)(a1 + 168) + 74000LL;
if ( *(_DWORD *)(*(_QWORD *)(a1 + 168) + 74036LL) )
{
v10 = *(_DWORD *)(*(_QWORD *)(a1 + 168) + 74008LL);
if ( !v10 )
return 28;
v11 = *(_DWORD *)(a1 + 624);
v12 = (int *)(*(_QWORD *)v9 + 4LL * ((v10 - 1) & v11));
v13 = *v12;
if ( *v12 != -1 )
{
v14 = v13;
v15 = *(_QWORD *)(*(_QWORD *)(a1 + 168) + 74016LL);
if ( *(_DWORD *)(v15 + 16LL * v13) == v11 )
{
LABEL_23:
v18 = v15 + 16 * v14;
*(_QWORD *)(v18 + 8) = 0;
*v12 = *(_DWORD *)(v18 + 4);
v19 = *(_DWORD *)(v9 + 36);
*(_DWORD *)(v18 + 4) = *(_DWORD *)(v9 + 32);
*(_DWORD *)(v9 + 32) = v13;
*(_DWORD *)(v9 + 36) = v19 - 1;
}
else
{
while ( 1 )
{
v16 = v15 + 16 * v14;
v17 = *(_DWORD *)(v16 + 4);
v12 = (int *)(v16 + 4);
v13 = v17;
if ( v17 == -1 )
break;
v14 = v13;
if ( *(_DWORD *)(v15 + 16LL * v13) == v11 )
goto LABEL_23;
}
}
}
}
*(_DWORD *)(a1 + 624) = -1;
return 0;
}
if ( a2 != 1 )
return 0;
v3 = *(_DWORD *)(a1 + 592);
if ( *(_DWORD *)(a1 + 560) == v3 )
{
if ( *(_DWORD *)(a1 + 568) )
return 0;
}
*(_DWORD *)(a1 + 560) = v3;
result = sub_100442768(*(_QWORD *)(a1 + 168), v3, (_DWORD *)(a1 + 564));
if ( !(_DWORD)result )
{
result = sub_1004CF868(*(_QWORD *)(a1 + 168), &v20, nullptr);
if ( !(_DWORD)result )
{
v6 = *(_DWORD *)(a1 + 564) * v20;
*(_DWORD *)(a1 + 568) = v6;
v7 = *(_QWORD *)(a1 + 536);
if ( v7 )
{
sub_1004B2354(*((_QWORD *)off_1008524C8 + 54), v7);
v6 = *(_DWORD *)(a1 + 568);
}
v8 = sub_1004B22EC(
*((__int64 **)off_1008524C8 + 54),
8 * v6,
16,
(char)"/opt/teamcity-agent/work/570ad728b1678096/core_api/src/fmod_dsp_return.cpp",
375,
0);
*(_QWORD *)(a1 + 536) = v8;
if ( v8 )
{
*(_QWORD *)(a1 + 544) = v8;
*(_QWORD *)(a1 + 552) = v8 + 4LL * *(int *)(a1 + 568);
*(_WORD *)(a1 + 584) = 0;
return 0;
}
else
{
return 38;
}
}
}
return result;
}