//
// sub_ED7D0 from 0xed7d0 to 0xed8e4 (276 bytes)
//
// 1 xrefs:
// > sub_F13AC @ 0xf170c
//
// 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
//
// positive sp value has been detected, the output may be wrong!
__int64 __fastcall sub_ED7D0(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
int *v5; // x19
_DWORD *v6; // x20
__int64 v7; // x21
__int64 v8; // x30
__int64 v9; // x0
__int64 result; // x0
int v11; // w24
__int64 v12; // x8
char v13; // w8
int v14; // w25
int v15; // [xsp-44h] [xbp-44h]
v9 = ((__int64 (__fastcall *)(__int64, __int64, __int64, __int64, __int64, __int64))sub_EDB18)(a1, a2, a3, a4, a5, v8);
result = ((__int64 (__fastcall *)(__int64))sub_EDA44)(v9);
if ( (_DWORD)result )
{
v11 = v15;
if ( v7 )
{
v12 = (unsigned int)*v6;
*v6 = v12 + 1;
*(_BYTE *)(v7 + v12) = v15;
}
if ( (v15 & 0x80) == 0 )
{
LABEL_11:
*v5 = v11;
return 1;
}
if ( (v15 & 0xC0) != 0 && (v15 & 0x20) == 0 )
{
v11 = v15 & 0x1F;
v14 = 1;
goto LABEL_6;
}
if ( (v15 & 0xE0) != 0 && (v15 & 0x10) == 0 )
{
v11 = v15 & 0xF;
v14 = 2;
goto LABEL_6;
}
if ( (v15 & 0xF0) != 0 && (v15 & 8) == 0 )
{
v11 = v15 & 7;
v14 = 3;
goto LABEL_6;
}
if ( (v15 & 0xF8) != 0 && (v15 & 4) == 0 )
{
v11 = v15 & 3;
v14 = 4;
goto LABEL_6;
}
if ( (v15 & 0xFC) == 0 || (v15 & 2) != 0 )
{
LABEL_27:
*v5 = -1;
return 1;
}
v11 = v15 & 1;
v14 = 5;
LABEL_6:
while ( 1 )
{
result = ((__int64 (*)(void))sub_EDA6C)();
if ( !(_DWORD)result )
break;
v13 = v15;
if ( v7 )
sub_EDA10();
if ( (v13 & 0xC0) != 0x80 )
goto LABEL_27;
--v14;
v11 = v13 & 0x3F | (v11 << 6);
if ( !v14 )
goto LABEL_11;
}
}
return result;
}