//
// sub_1005DD8B8 from 0x1005dd8b8 to 0x1005ddb9c (740 bytes)
//
// 3 xrefs:
// > sub_1005DCB60 @ 0x1005dd0ec
// > sub_1005DCB60 @ 0x1005dd3ec
// > sub_1005DCB60 @ 0x1005dd5c0
//
// 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_1005DD8B8(
const void **a1,
void **a2,
size_t *a3,
size_t *a4,
__int64 a5,
unsigned int a6,
int a7,
int a8,
int a9)
{
int v13; // w23
int v14; // w8
int v15; // w9
const char *v16; // x24
const char *v17; // x9
const char *v18; // x11
__int64 v19; // x9
unsigned __int64 v20; // x14
__int64 v21; // x13
__int64 v22; // x26
int v23; // w28
int v24; // w9
int v25; // w10
int v26; // w11
int v27; // w8
int v28; // w28
int v29; // w27
bool v30; // vf
char v31; // w8
unsigned __int8 *v32; // x23
int v33; // t1
int v34; // w23
char *v35; // x23
char v36; // t1
__int64 result; // x0
int v38; // w23
_BYTE v39[26]; // [xsp+Eh] [xbp-72h] BYREF
v13 = 0;
if ( a8 >= 0 )
v14 = a8;
else
v14 = 0;
if ( (a9 & 0x40) == 0 )
{
v15 = (a9 & 2) != 0 ? 43 : (8 * a9) & 0x20;
v13 = a5 < 0 ? 45 : v15;
if ( a5 < 0 )
a5 = -a5;
}
v16 = "";
if ( (a9 & 8) != 0 )
{
v17 = "0";
if ( a6 != 8 )
v17 = "";
if ( a6 == 16 )
v16 = "0x";
else
v16 = v17;
}
v18 = "0123456789ABCDEF";
if ( (a9 & 0x20) == 0 )
v18 = "0123456789abcdef";
v19 = -1;
do
{
v20 = a5 / (unsigned __int64)a6;
v39[v19 + 1] = v18[a5 % (unsigned __int64)a6];
v21 = v19 + 2;
++v19;
if ( v21 > 25 )
break;
a5 /= (unsigned __int64)a6;
}
while ( v20 );
if ( (_DWORD)v21 != 26 )
LODWORD(v19) = v21;
v22 = (int)v19;
v39[(int)v19] = 0;
v23 = v14 - v19;
if ( v14 < (int)v19 )
v14 = v19;
v24 = a7 - (v13 != 0) - v14 - strlen(v16);
if ( v23 >= 0 )
v25 = v23;
else
v25 = 0;
if ( v24 < 0 )
v24 = 0;
if ( v25 < v24 )
v26 = v24;
else
v26 = v25;
if ( (a9 & 0x10) != 0 )
v27 = 0;
else
v27 = v24;
if ( (a9 & 0x10) != 0 )
v28 = v26;
else
v28 = v25;
if ( (a9 & 1) != 0 )
v29 = -v27;
else
v29 = v27;
if ( v29 >= 1 )
{
while ( (unsigned int)sub_1005DD7B4(a1, a2, a3, a4, 32) )
{
v30 = __OFSUB__(v29--, 1);
if ( (v29 < 0) ^ v30 | (v29 == 0) )
goto LABEL_49;
}
return 0;
}
LABEL_49:
if ( v13 && !(unsigned int)sub_1005DD7B4(a1, a2, a3, a4, v13) )
return 0;
v31 = *v16;
if ( *v16 )
{
v32 = (unsigned __int8 *)(v16 + 1);
while ( (unsigned int)sub_1005DD7B4(a1, a2, a3, a4, v31) )
{
v33 = *v32++;
v31 = v33;
if ( !v33 )
goto LABEL_55;
}
return 0;
}
LABEL_55:
if ( v28 >= 1 )
{
v34 = v28 + 1;
while ( (unsigned int)sub_1005DD7B4(a1, a2, a3, a4, 48) )
{
if ( --v34 <= 1 )
goto LABEL_59;
}
return 0;
}
LABEL_59:
v35 = &v39[(int)v22 - 1];
while ( v22 > 0 )
{
v36 = *v35--;
--v22;
if ( !(unsigned int)sub_1005DD7B4(a1, a2, a3, a4, v36) )
return 0;
}
if ( (v29 & 0x80000000) == 0 )
return 1;
v38 = v29 - 1;
while ( (unsigned int)sub_1005DD7B4(a1, a2, a3, a4, 32) )
{
++v38;
result = 1;
if ( v38 > -2 )
return result;
}
return 0;
}