//
// sub_CE6708 from 0xce6708 to 0xce6af0 (1000 bytes)
//
// 1 xrefs:
// > ??> @ 0x111def0
//
// 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
//
_QWORD *__fastcall sub_CE6708(
__int64 a1,
_QWORD *a2,
__int64 a3,
_QWORD *a4,
__int64 a5,
__int64 a6,
_DWORD *a7,
_BYTE *a8)
{
int v8; // w9
int v11; // w1
int v12; // w19
unsigned int v13; // w24
unsigned __int64 v14; // x23
_QWORD *v15; // x27
unsigned int v16; // w25
unsigned int v17; // w20
unsigned int v18; // w19
int v19; // w1
_QWORD *v20; // x0
int v21; // w26
int v22; // w1
unsigned __int64 v23; // x1
int v24; // w0
unsigned __int8 *v26; // x1
int v27; // w0
unsigned __int8 *v28; // x1
int v29; // w1
unsigned __int8 *v30; // x1
int v31; // w0
_QWORD *v32; // [xsp+70h] [xbp+70h] BYREF
__int64 v33; // [xsp+78h] [xbp+78h]
_QWORD *v34; // [xsp+80h] [xbp+80h] BYREF
__int64 v35; // [xsp+88h] [xbp+88h]
unsigned __int64 v36; // [xsp+98h] [xbp+98h] BYREF
v8 = *(_DWORD *)(a6 + 24);
v34 = a2;
v35 = a3;
v32 = a4;
v33 = a5;
if ( (v8 & 1) == 0 )
{
v36 = -1;
v34 = sub_CE5D58(a1, a2, a3, a4, a5, a6, a7, &v36);
LODWORD(v35) = v11;
if ( v36 <= 1 )
{
*a8 = v36 & 1;
}
else
{
*a8 = 1;
*a7 = 4;
v12 = sub_CE0BE4((__int64)&v34);
if ( (v12 == -1) == ((unsigned int)sub_CE0BE4((__int64)&v32) == -1) )
*a7 |= 2u;
}
return v34;
}
v13 = 1;
v14 = 0;
v15 = (_QWORD *)sub_CE0B00((__int64)&v36, (_QWORD *)(a6 + 208));
v16 = 1;
v17 = v15[8] == 0;
v18 = v15[6] == 0;
LABEL_6:
if ( v17 > (v18 ^ 1) )
{
LABEL_30:
v24 = 0;
if ( v16 )
{
LABEL_31:
if ( v15[8] == v14 && v14 )
{
*a8 = 0;
if ( !v13 || v15[6] != v14 )
{
*a7 = 2 * v24;
return v34;
}
goto LABEL_68;
}
}
LABEL_48:
if ( v13 && v15[6] == v14 && v14 )
{
*a8 = 1;
*a7 = 2 * v24;
return v34;
}
*a8 = 0;
if ( v24 )
{
*a7 = 6;
return v34;
}
LABEL_68:
*a7 = 4;
return v34;
}
while ( 1 )
{
if ( !v34 )
goto LABEL_54;
LOBYTE(v19) = v35;
if ( (_DWORD)v35 != -1 )
{
v20 = v32;
v21 = 0;
if ( !v32 )
goto LABEL_14;
goto LABEL_10;
}
v28 = (unsigned __int8 *)v34[2];
if ( (unsigned __int64)v28 >= v34[3] )
{
v29 = (*(__int64 (__fastcall **)(_QWORD *))(*v34 + 72LL))(v34);
if ( v29 == -1 )
{
v34 = nullptr;
LABEL_54:
v20 = v32;
if ( !v32 )
{
LABEL_47:
v24 = 1;
if ( v16 )
goto LABEL_31;
goto LABEL_48;
}
v21 = 1;
LABEL_10:
v22 = 0;
if ( (_DWORD)v33 != -1 )
goto LABEL_11;
goto LABEL_44;
}
}
else
{
v29 = *v28;
}
v20 = v32;
v21 = 0;
LODWORD(v35) = v29;
if ( !v32 )
goto LABEL_12;
v22 = 0;
if ( (_DWORD)v33 != -1 )
goto LABEL_11;
LABEL_44:
v30 = (unsigned __int8 *)v20[2];
if ( (unsigned __int64)v30 >= v20[3] )
{
v31 = (*(__int64 (__fastcall **)(_QWORD *))(*v20 + 72LL))(v20);
if ( v31 == -1 )
{
v32 = nullptr;
v22 = 1;
LABEL_11:
if ( v22 == v21 )
goto LABEL_47;
goto LABEL_12;
}
}
else
{
v31 = *v30;
}
LODWORD(v33) = v31;
if ( !v21 )
goto LABEL_47;
LABEL_12:
if ( v34 )
{
LOBYTE(v19) = v35;
if ( (_DWORD)v35 != -1 )
{
LABEL_14:
v19 = (unsigned __int8)v19;
goto LABEL_15;
}
v26 = (unsigned __int8 *)v34[2];
if ( (unsigned __int64)v26 < v34[3] )
{
v27 = *v26;
LABEL_39:
LODWORD(v35) = v27;
v19 = (unsigned __int8)v27;
goto LABEL_15;
}
v27 = (*(__int64 (__fastcall **)(_QWORD *))(*v34 + 72LL))(v34);
if ( v27 != -1 )
goto LABEL_39;
v34 = nullptr;
}
v19 = 255;
LABEL_15:
if ( !v17 )
v16 = *(unsigned __int8 *)(v15[7] + v14) == v19;
if ( v16 < v18 )
goto LABEL_30;
if ( !v18 )
v13 = *(unsigned __int8 *)(v15[5] + v14) == v19;
if ( v13 < v17 || v13 < (v16 ^ 1) )
break;
++v14;
if ( v34 )
{
v23 = v34[2];
if ( v23 >= v34[3] )
(*(void (__fastcall **)(_QWORD *))(*v34 + 80LL))(v34);
else
v34[2] = v23 + 1;
LODWORD(v35) = -1;
}
v17 = 1;
if ( v16 )
v17 = v14 >= v15[8];
v18 = 1;
if ( !v13 )
goto LABEL_6;
v18 = v14 >= v15[6];
if ( v17 > (v14 < v15[6]) )
goto LABEL_30;
}
if ( !v16 || v15[8] != v14 || !v14 )
{
*a8 = 0;
goto LABEL_68;
}
*a8 = 0;
*a7 = 0;
return v34;
}