//
// sub_180041BB0 from 0x180041bb0 to 0x180041cc5 (277 bytes)
//
// 12 xrefs:
// > sub_180045B60 @ 0x180045ece
// > sub_180045B60 @ 0x18004600b
// > sub_180045B60 @ 0x180046092
// > sub_180046250 @ 0x180046298
// > sub_180046250 @ 0x180046413
// > sub_1800465B0 @ 0x180046670
// > sub_1800465B0 @ 0x1800466ec
// > sub_1800465B0 @ 0x1800467ed
// > sub_180046810 @ 0x180046a11
// > sub_180046A60 @ 0x180046ad9
// > sub_180046A60 @ 0x180046ba0
// > ??> @ 0x1801f7fe0
//
// 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_180041BB0(__int64 a1, __int64 a2, _BYTE *a3, unsigned int a4)
{
unsigned int v4; // edi
__int64 v9; // r8
int v10; // edx
char v11; // [rsp+48h] [rbp+20h] BYREF
v4 = a4;
if ( a4 )
{
while ( *(_DWORD *)(a2 + 24) )
{
if ( !(unsigned int)sub_180041D20(a1, a2, &v11, 8) )
return 0;
*a3++ = v11;
if ( !--v4 )
return 1;
}
if ( v4 < 4 )
goto LABEL_12;
do
{
v9 = *(unsigned int *)(a2 + 20);
if ( (unsigned int)v9 >= *(_DWORD *)(a2 + 12) )
{
if ( !(unsigned int)sub_180042A00(a1, a2) )
return 0;
}
else
{
v10 = *(_DWORD *)(*(_QWORD *)a2 + 4 * v9);
*(_DWORD *)(a2 + 20) = v9 + 1;
*a3 = HIBYTE(v10);
a3[1] = BYTE2(v10);
a3[2] = BYTE1(v10);
a3[3] = v10;
a3 += 4;
v4 -= 4;
}
}
while ( v4 >= 4 );
if ( v4 )
{
LABEL_12:
while ( (unsigned int)sub_180041D20(a1, a2, &v11, 8) )
{
*a3++ = v11;
if ( !--v4 )
return 1;
}
return 0;
}
}
return 1;
}