//
// sub_CE0C6C from 0xce0c6c to 0xce0fe0 (884 bytes)
//
// 5 xrefs:
// > sub_CE1914 @ 0xce1ef0
// > sub_CE1914 @ 0xce1f90
// > sub_CE1914 @ 0xce1ff8
// > sub_CE1914 @ 0xce2300
// > sub_CE1914 @ 0xce23a0
//
// 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_CE0C6C(
__int64 a1,
_QWORD *a2,
__int64 a3,
__int64 a4,
__int64 a5,
int *a6,
__int64 a7,
__int64 a8,
__int64 a9,
_DWORD *a10)
{
void *v12; // x27
int v13; // w20
int v14; // w25
__int64 v15; // x20
unsigned __int64 v16; // x26
__int64 v17; // x20
unsigned __int64 v18; // x27
size_t v19; // x25
int v20; // w0
size_t v21; // x0
unsigned __int64 v22; // x2
int v23; // w27
unsigned __int64 v24; // x27
int v25; // w1
int v26; // w2
unsigned __int8 *v27; // x1
int v28; // w0
unsigned __int64 v29; // x1
int v30; // w23
size_t v31; // x20
const char *v32; // x27
size_t i; // x19
int v34; // w28
int v35; // w28
__int64 v37; // x1
unsigned __int64 v38; // x1
int v39[4]; // [xsp+0h] [xbp+0h]
int *v40; // [xsp+60h] [xbp+60h]
__int64 v41; // [xsp+68h] [xbp+68h]
_QWORD v42[2]; // [xsp+70h] [xbp+70h] BYREF
_QWORD *v43; // [xsp+80h] [xbp+80h] BYREF
__int64 v44; // [xsp+88h] [xbp+88h]
v43 = a2;
v44 = a3;
v40 = a6;
v42[0] = a4;
v42[1] = a5;
v12 = sub_CDB730(a9 + 208);
v13 = sub_CE0BE4((__int64)&v43);
if ( (v13 == -1) == ((unsigned int)sub_CE0BE4((__int64)v42) == -1) )
goto LABEL_40;
v14 = (unsigned __int8)sub_CE0BE4((__int64)&v43);
if ( !a8 )
goto LABEL_40;
v15 = 0;
v16 = 0;
do
{
while ( **(unsigned __int8 **)(a7 + 8 * v15) != v14
&& v14 != (*(unsigned __int8 (__fastcall **)(void *))(*(_QWORD *)v12 + 16LL))(v12) )
{
if ( ++v15 == a8 )
goto LABEL_8;
}
v39[v16++] = v15++;
}
while ( v15 != a8 );
LABEL_8:
v17 = 0;
if ( v16 > 1 )
{
LABEL_9:
v18 = 1;
v19 = strlen(*(const char **)(a7 + 8LL * v39[0]));
do
{
v20 = v39[v18++];
v21 = strlen(*(const char **)(a7 + 8LL * v20));
if ( v19 > v21 )
v19 = v21;
}
while ( v18 < v16 );
if ( v43 )
{
v22 = v43[2];
if ( v22 >= v43[3] )
(*(void (__fastcall **)(_QWORD *))(*v43 + 80LL))(v43);
else
v43[2] = v22 + 1;
LODWORD(v44) = -1;
}
if ( ++v17 >= v19 )
goto LABEL_40;
v23 = sub_CE0BE4((__int64)&v43);
if ( (v23 == -1) == ((unsigned int)sub_CE0BE4((__int64)v42) == -1) )
goto LABEL_40;
v24 = 0;
while ( 1 )
{
while ( 1 )
{
v26 = *(unsigned __int8 *)(*(_QWORD *)(a7 + 8LL * v39[v24]) + v17);
if ( v43 )
break;
v25 = 255;
LABEL_21:
if ( v26 != v25 )
goto LABEL_22;
LABEL_28:
if ( v16 <= ++v24 )
{
LABEL_29:
if ( v16 <= 1 )
goto LABEL_30;
goto LABEL_9;
}
}
if ( (_DWORD)v44 != -1 )
{
v25 = (unsigned __int8)v44;
goto LABEL_21;
}
v27 = (unsigned __int8 *)v43[2];
if ( (unsigned __int64)v27 < v43[3] )
{
v28 = *v27;
goto LABEL_27;
}
v37 = *v43;
v41 = *(unsigned __int8 *)(*(_QWORD *)(a7 + 8LL * v39[v24]) + v17);
v28 = (*(__int64 (__fastcall **)(_QWORD *))(v37 + 72))(v43);
v26 = v41;
if ( v28 == -1 )
{
v43 = nullptr;
v25 = 255;
goto LABEL_21;
}
LABEL_27:
LODWORD(v44) = v28;
if ( v26 == (unsigned __int8)v28 )
goto LABEL_28;
LABEL_22:
v39[v24] = v39[--v16];
if ( v16 <= v24 )
goto LABEL_29;
}
}
LABEL_30:
if ( v16 != 1 )
goto LABEL_40;
if ( v43 )
{
v29 = v43[2];
if ( v29 >= v43[3] )
sub_CD987C((__int64)v43);
else
v43[2] = v29 + 1;
LODWORD(v44) = -1;
}
v30 = v39[0];
v31 = v17 + 1;
v32 = *(const char **)(a7 + 8LL * v39[0]);
for ( i = strlen(v32); i > v31; ++v31 )
{
v34 = sub_CE0BE4((__int64)&v43);
if ( (v34 == -1) == ((unsigned int)sub_CE0BE4((__int64)v42) == -1) )
break;
v35 = (unsigned __int8)v32[v31];
if ( v35 != (unsigned __int8)sub_CE0BE4((__int64)&v43) )
break;
if ( v43 )
{
v38 = v43[2];
if ( v38 >= v43[3] )
sub_CD987C((__int64)v43);
else
v43[2] = v38 + 1;
LODWORD(v44) = -1;
}
}
if ( v31 == i )
*v40 = v30;
else
LABEL_40:
*a10 |= 4u;
return v43;
}