//
// sub_180042530 from 0x180042530 to 0x18004266d (317 bytes)
//
// 2 xrefs:
// > sub_1800453A0 @ 0x18004573c
// > ??> @ 0x1801f8034
//
// 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_180042530(__int64 a1, __int64 a2, int *a3, __int64 a4, _DWORD *a5)
{
int v9; // ebx
int v10; // ebp
char v11; // dl
unsigned int v13[10]; // [rsp+20h] [rbp-28h] BYREF
if ( (unsigned int)sub_180041D20(a1, a2, v13, 8u) )
{
v9 = v13[0];
if ( a4 )
*(_BYTE *)((unsigned int)(*a5)++ + a4) = v13[0];
if ( (v9 & 0x80u) == 0 )
{
LABEL_25:
*a3 = v9;
return 1;
}
if ( (v9 & 0xC0) != 0 && (v9 & 0x20) == 0 )
{
v9 &= 0x1Fu;
v10 = 1;
goto LABEL_20;
}
if ( (v9 & 0xE0) != 0 && (v9 & 0x10) == 0 )
{
v9 &= 0xFu;
v10 = 2;
goto LABEL_20;
}
if ( (v9 & 0xF0) != 0 && (v9 & 8) == 0 )
{
v9 &= 7u;
v10 = 3;
goto LABEL_20;
}
if ( (v9 & 0xF8) != 0 && (v9 & 4) == 0 )
{
v9 &= 3u;
v10 = 4;
goto LABEL_20;
}
if ( (v9 & 0xFC) == 0 || (v9 & 2) != 0 )
{
LABEL_26:
*a3 = -1;
return 1;
}
v9 &= 1u;
v10 = 5;
LABEL_20:
while ( (unsigned int)sub_180041D20(a1, a2, v13, 8u) )
{
v11 = v13[0];
if ( a4 )
*(_BYTE *)((unsigned int)(*a5)++ + a4) = v13[0];
if ( (v11 & 0xC0) != 0x80 )
goto LABEL_26;
v9 = (v9 << 6) | v11 & 0x3F;
if ( !--v10 )
goto LABEL_25;
}
}
return 0;
}