//
// sub_1001ACB84 from 0x1001acb84 to 0x1001acd44 (448 bytes)
//
// 1 xrefs:
// > sub_1001ACEF0 @ 0x1001acf8c
//
// 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_1001ACB84(unsigned __int8 **a1, unsigned __int64 a2, _WORD **a3, unsigned __int64 a4, int a5)
{
unsigned __int8 *v7; // x21
_WORD *v8; // x26
int v12; // w27
__int64 v13; // x28
unsigned int v14; // w25
int v15; // w8
int v16; // w9
int v17; // t1
int v18; // w8
int v19; // t1
int v20; // w8
int v21; // t1
int v22; // w8
int v23; // t1
int v24; // w8
int v25; // t1
unsigned int v26; // w8
__int64 result; // x0
v7 = *a1;
v8 = *a3;
if ( (unsigned __int64)*a1 >= a2 )
{
LABEL_29:
result = 0;
goto LABEL_34;
}
while ( 1 )
{
v12 = *v7;
if ( (__int64)(a2 - (_QWORD)v7) <= (unsigned __int16)byte_10063993B[*v7] )
{
result = 1;
goto LABEL_34;
}
v13 = (unsigned __int16)byte_10063993B[*v7];
v14 = (unsigned __int16)byte_10063993B[*v7] + 1;
if ( !sub_1001ACA10(v7, v14) )
goto LABEL_33;
v15 = 0;
v16 = (unsigned __int8)v13;
if ( (unsigned __int8)v13 > 2u )
{
if ( (unsigned __int8)v13 != 3 )
{
if ( (unsigned __int8)v13 != 4 )
{
if ( (unsigned __int8)v13 != 5 )
goto LABEL_18;
v15 = v12 << 6;
v17 = *++v7;
v12 = v17;
}
v18 = v15 + v12;
v19 = *++v7;
v12 = v19;
v15 = v18 << 6;
}
v20 = v15 + v12;
v21 = *++v7;
v12 = v21;
v15 = v20 << 6;
LABEL_15:
v22 = v15 + v12;
v23 = *++v7;
v12 = v23;
v15 = v22 << 6;
LABEL_16:
v24 = v15 + v12;
v25 = *++v7;
v12 = v25;
v16 = v24 << 6;
LABEL_17:
++v7;
v15 = v16 + v12;
goto LABEL_18;
}
if ( !(_BYTE)v13 )
goto LABEL_17;
if ( (unsigned __int8)v13 == 1 )
goto LABEL_16;
if ( (unsigned __int8)v13 == 2 )
goto LABEL_15;
LABEL_18:
if ( (unsigned __int64)v8 >= a4 )
goto LABEL_30;
v26 = v15 - dword_100639A3C[v13];
if ( !HIWORD(v26) )
break;
if ( v26 >= 0x110000 )
goto LABEL_23;
if ( (unsigned __int64)(v8 + 1) >= a4 )
{
LABEL_30:
v7 -= v14;
result = 2;
goto LABEL_34;
}
*v8 = ((v26 + 67043328) >> 10) - 10240;
v8[1] = v26 & 0x3FF | 0xDC00;
v8 += 2;
LABEL_28:
if ( (unsigned __int64)v7 >= a2 )
goto LABEL_29;
}
if ( (v26 & 0xF800) != 0xD800 )
goto LABEL_25;
LABEL_23:
if ( a5 )
{
LOWORD(v26) = -3;
LABEL_25:
*v8++ = v26;
goto LABEL_28;
}
v7 -= v14;
LABEL_33:
result = 3;
LABEL_34:
*a1 = v7;
*a3 = v8;
return result;
}