//
// sub_180046C10 from 0x180046c10 to 0x180046ecd (701 bytes)
//
// 5 xrefs:
// > sub_180047260 @ 0x18004743f
// > sub_1800474C0 @ 0x1800477a5
// > ??> @ 0x180181028
// > ??> @ 0x180181064
// > ??> @ 0x1801f822c
//
// 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_180046C10(
__int64 a1,
__int64 a2,
unsigned int a3,
unsigned int a4,
_QWORD *a5,
__int64 a6,
unsigned int a7)
{
__int64 v7; // r10
int v10; // r15d
unsigned int v11; // esi
int v12; // ebp
int v13; // edi
unsigned int v14; // esi
int v16; // edx
int v17; // edx
_QWORD *v18; // rbx
unsigned int v19; // edx
__int64 v20; // rdi
unsigned int v21; // ebp
__int64 v22; // r15
unsigned int v23; // ebx
unsigned int v24; // ebx
unsigned int v25; // [rsp+30h] [rbp-48h]
unsigned int v26; // [rsp+34h] [rbp-44h]
int v27; // [rsp+38h] [rbp-40h] BYREF
unsigned int v28; // [rsp+3Ch] [rbp-3Ch]
v7 = *(_QWORD *)(a2 + 8);
v10 = 1 << a4;
v11 = *(_DWORD *)(v7 + 1368);
v28 = 1 << a4;
if ( a4 )
{
v12 = 4;
v13 = 15;
v14 = v11 >> a4;
if ( a7 )
{
v12 = 5;
v13 = 31;
}
v25 = v12;
v26 = v13;
if ( v14 < a3 )
{
if ( !*(_DWORD *)(v7 + 4112) )
(*(void (__fastcall **)(__int64, _QWORD, _QWORD))(v7 + 56))(a2, 0, *(_QWORD *)(v7 + 104));
**(_DWORD **)a2 = 2;
return 1;
}
}
else
{
v16 = 4;
if ( a7 )
v16 = 5;
v25 = v16;
v17 = 15;
if ( a7 )
v17 = 31;
v26 = v17;
if ( v11 < a3 )
{
if ( !*(_DWORD *)(v7 + 4112) )
(*(void (__fastcall **)(__int64, _QWORD, _QWORD))(v7 + 56))(a2, 0, *(_QWORD *)(v7 + 104));
**(_DWORD **)a2 = 2;
return 1;
}
v14 = v11 - a3;
}
v18 = a5;
v19 = a4;
if ( a4 < 6 )
v19 = 6;
if ( (unsigned int)sub_180042E20((__int64)a5, v19) )
{
v20 = 0;
v21 = 0;
if ( v10 )
{
v22 = 0;
while ( (unsigned int)sub_180041D20(a1, *(_QWORD *)(*(_QWORD *)(a2 + 8) + 120LL), &a7, v25) )
{
*(_DWORD *)(v22 + *v18) = a7;
if ( a7 >= v26 )
{
if ( !(unsigned int)sub_180041D20(a1, *(_QWORD *)(*(_QWORD *)(a2 + 8) + 120LL), &a7, 5u) )
return 0;
*(_DWORD *)(v22 + v18[1]) = a7;
if ( !a4 || v21 )
v24 = 0;
else
v24 = a3;
if ( v24 < v14 )
{
while ( (unsigned int)sub_180041CD0(a1, *(_QWORD *)(*(_QWORD *)(a2 + 8) + 120LL), &v27, a7) )
{
++v24;
*(_DWORD *)(a6 + 4 * v20) = v27;
v20 = (unsigned int)(v20 + 1);
if ( v24 >= v14 )
goto LABEL_39;
}
return 0;
}
}
else
{
*(_DWORD *)(v22 + v18[1]) = 0;
if ( !a4 || v21 )
v23 = v14;
else
v23 = v14 - a3;
if ( !(*(unsigned int (__fastcall **)(__int64, _QWORD, __int64, _QWORD, unsigned int))(*(_QWORD *)(a2 + 8)
+ 96LL))(
a1,
*(_QWORD *)(*(_QWORD *)(a2 + 8) + 120LL),
a6 + 4 * v20,
v23,
a7) )
return 0;
v20 = v23 + (unsigned int)v20;
}
LABEL_39:
v18 = a5;
++v21;
v22 += 4;
if ( v21 >= v28 )
return 1;
}
return 0;
}
else
{
return 1;
}
}
else
{
**(_DWORD **)a2 = 8;
return 0;
}
}