//
// sub_1001ACD44 from 0x1001acd44 to 0x1001acef0 (428 bytes)
//
// 1 xrefs:
// > sub_1001ACEF0 @ 0x1001acf50
//
// 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_1001ACD44(
unsigned __int8 **a1,
unsigned __int64 a2,
unsigned int **a3,
unsigned __int64 a4,
int a5)
{
unsigned __int8 *v6; // x21
unsigned int *v7; // x27
__int64 v11; // x22
int v12; // w19
__int64 v13; // x28
unsigned int v14; // w26
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
bool v27; // zf
v6 = *a1;
v7 = *a3;
if ( (unsigned __int64)*a1 < a2 )
{
v11 = 0;
while ( 1 )
{
v12 = *v6;
if ( (__int64)(a2 - (_QWORD)v6) <= (unsigned __int16)byte_10063993B[*v6] )
{
v11 = 1;
goto LABEL_34;
}
v13 = (unsigned __int16)byte_10063993B[*v6];
v14 = (unsigned __int16)byte_10063993B[*v6] + 1;
if ( !sub_1001ACA10(v6, v14) )
{
LABEL_33:
v11 = 3;
goto LABEL_34;
}
v15 = 0;
v16 = (unsigned __int8)v13;
if ( (unsigned __int8)v13 > 2u )
break;
if ( !(_BYTE)v13 )
goto LABEL_18;
if ( (unsigned __int8)v13 == 1 )
goto LABEL_17;
if ( (unsigned __int8)v13 == 2 )
goto LABEL_16;
LABEL_19:
if ( (unsigned __int64)v7 >= a4 )
{
v6 -= v14;
v11 = 2;
goto LABEL_34;
}
v26 = v15 - dword_100639A3C[v13];
if ( HIWORD(v26) > 0x10u )
{
v11 = 3;
v26 = 65533;
}
else
{
if ( (v26 & 0x1FF800) == 0xD800 )
{
v26 = 65533;
v27 = a5 == 0;
}
else
{
v27 = 0;
}
if ( v27 )
{
v6 -= v14;
goto LABEL_33;
}
}
*v7++ = v26;
if ( (unsigned __int64)v6 >= a2 )
goto LABEL_34;
}
if ( (unsigned __int8)v13 != 3 )
{
if ( (unsigned __int8)v13 != 4 )
{
if ( (unsigned __int8)v13 != 5 )
goto LABEL_19;
v15 = v12 << 6;
v17 = *++v6;
v12 = v17;
}
v18 = v15 + v12;
v19 = *++v6;
v12 = v19;
v15 = v18 << 6;
}
v20 = v15 + v12;
v21 = *++v6;
v12 = v21;
v15 = v20 << 6;
LABEL_16:
v22 = v15 + v12;
v23 = *++v6;
v12 = v23;
v15 = v22 << 6;
LABEL_17:
v24 = v15 + v12;
v25 = *++v6;
v12 = v25;
v16 = v24 << 6;
LABEL_18:
++v6;
v15 = v16 + v12;
goto LABEL_19;
}
v11 = 0;
LABEL_34:
*a1 = v6;
*a3 = v7;
return v11;
}