//
// sub_180042800 from 0x180042800 to 0x18004291e (286 bytes)
//
// 4 xrefs:
// > sub_180046250 @ 0x18004630d
// > sub_180046250 @ 0x180046496
// > sub_180046250 @ 0x18004656c
// > ??> @ 0x1801f804c
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 10:53:11 +0000
//
__int64 __fastcall sub_180042800(__int64 a1, _DWORD *a2, unsigned int a3)
{
unsigned int v3; // esi
int v6; // ecx
unsigned int v7; // ebx
unsigned int v8; // ebx
unsigned int v9; // eax
unsigned int v11; // [rsp+50h] [rbp+18h] BYREF
unsigned int v12; // [rsp+58h] [rbp+20h] BYREF
v3 = a3;
if ( a3 )
{
v6 = a2[6] & 7;
if ( v6 )
{
v7 = a3;
if ( 8 - v6 < a3 )
v7 = 8 - v6;
if ( !(unsigned int)sub_180041D20(a1, (__int64)a2, &v12, v7) )
return 0;
v3 -= v7;
}
v8 = v3 >> 3;
if ( v3 >> 3 )
{
while ( a2[6] )
{
if ( !(unsigned int)sub_180041D20(a1, (__int64)a2, &v11, 8u) )
return 0;
if ( !--v8 )
goto LABEL_20;
}
if ( v8 < 4 )
goto LABEL_18;
do
{
v9 = a2[5];
if ( v9 >= a2[3] )
{
if ( !(unsigned int)sub_180042A00(a1, a2) )
return 0;
}
else
{
a2[5] = v9 + 1;
v8 -= 4;
}
}
while ( v8 >= 4 );
if ( !v8 )
{
LABEL_20:
v3 &= 7u;
goto LABEL_21;
}
LABEL_18:
while ( (unsigned int)sub_180041D20(a1, (__int64)a2, &v11, 8u) )
{
if ( !--v8 )
goto LABEL_20;
}
return 0;
}
LABEL_21:
if ( v3 && !(unsigned int)sub_180041D20(a1, (__int64)a2, &v12, v3) )
return 0;
}
return 1;
}