//
// sub_100548FAC from 0x100548fac to 0x1005492a8 (764 bytes)
//
// 4 xrefs:
// > sub_10057E194 @ 0x10057e1d8
// > sub_10057E9A4 @ 0x10057ea54
// > sub_100580780 @ 0x100580c4c
// > sub_100587B1C @ 0x100587f24
//
// 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_100548FAC(const char *a1, _QWORD *a2, size_t *a3)
{
unsigned __int8 *v5; // x21
size_t v6; // x0
__int64 v7; // x8
size_t v8; // x8
unsigned __int8 *v9; // x9
int v10; // w10
int v11; // t1
bool v12; // w11
bool v13; // zf
__int64 v14; // x9
size_t v15; // x24
size_t v16; // x23
void *v17; // x0
void *v18; // x22
_BYTE *v19; // x25
size_t v20; // x26
__int64 v21; // x8
int v22; // w9
unsigned __int64 v23; // x27
int v24; // w11
int v25; // w10
int v26; // w11
int v27; // w9
int v28; // w8
__int64 v29; // x10
int v30; // w12
int v31; // w11
int v32; // w12
int v33; // w9
int v34; // w8
__int64 v35; // x10
int v36; // w12
int v37; // w11
int v38; // w12
int v39; // w9
int v40; // w23
__int64 v41; // x10
int v42; // w12
int v43; // w11
int v44; // w12
size_t v46; // [xsp+8h] [xbp-58h]
v5 = (unsigned __int8 *)a1;
*a2 = 0;
*a3 = 0;
v6 = strlen(a1);
v7 = 61;
if ( v6 && (v6 & 3) == 0 )
{
v8 = v6 + 1;
v9 = v5;
do
{
v11 = *v9++;
v10 = v11;
v12 = v11 != 61;
--v8;
}
while ( v11 && v12 );
if ( v10 == 61 )
{
v13 = *v9 == 61;
v14 = 1;
if ( v13 )
v14 = 2;
}
else
{
v14 = 0;
}
if ( v14 == v8 )
{
v15 = v6 >> 2;
v16 = 3 * (v6 >> 2) - v14;
v17 = off_10085DEB0(v16 + 1);
v18 = v17;
if ( v17 )
{
v46 = v16;
v19 = v17;
if ( v15 )
{
v20 = 0;
v19 = v17;
do
{
v21 = 0;
v22 = *v5;
if ( v22 == 61 )
{
v23 = 1;
}
else
{
LOBYTE(v24) = 65;
while ( (unsigned __int8)v24 != v22 )
{
v25 = v21 + 1;
v24 = (unsigned __int8)aAbcdefghijklmn_10[++v21];
if ( !v24 )
{
v26 = 0;
LODWORD(v21) = v25;
goto LABEL_22;
}
}
v26 = (unsigned __int8)aAbcdefghijklmn_10[v21];
LABEL_22:
if ( v26 != v22 )
{
LABEL_61:
off_10085DEB8(v18);
return 61;
}
v23 = 0;
}
v27 = v5[1];
if ( v27 == 61 )
{
v28 = (_DWORD)v21 << 6;
++v23;
}
else
{
v29 = 0;
LOBYTE(v30) = 65;
while ( (unsigned __int8)v30 != v27 )
{
v31 = v29 + 1;
v30 = (unsigned __int8)aAbcdefghijklmn_10[++v29];
if ( !v30 )
{
v32 = 0;
LODWORD(v29) = v31;
goto LABEL_31;
}
}
v32 = (unsigned __int8)aAbcdefghijklmn_10[v29];
LABEL_31:
if ( v32 != v27 )
goto LABEL_61;
v28 = v29 + ((_DWORD)v21 << 6);
}
v33 = v5[2];
if ( v33 == 61 )
{
v34 = v28 << 6;
++v23;
}
else
{
v35 = 0;
LOBYTE(v36) = 65;
while ( (unsigned __int8)v36 != v33 )
{
v37 = v35 + 1;
v36 = (unsigned __int8)aAbcdefghijklmn_10[++v35];
if ( !v36 )
{
v38 = 0;
LODWORD(v35) = v37;
goto LABEL_40;
}
}
v38 = (unsigned __int8)aAbcdefghijklmn_10[v35];
LABEL_40:
if ( v38 != v33 )
goto LABEL_61;
v34 = v35 + (v28 << 6);
}
v39 = v5[3];
if ( v39 == 61 )
{
v40 = v34 << 6;
if ( ++v23 )
goto LABEL_52;
}
else
{
v41 = 0;
LOBYTE(v42) = 65;
while ( (unsigned __int8)v42 != v39 )
{
v43 = v41 + 1;
v42 = (unsigned __int8)aAbcdefghijklmn_10[++v41];
if ( !v42 )
{
v44 = 0;
LODWORD(v41) = v43;
goto LABEL_50;
}
}
v44 = (unsigned __int8)aAbcdefghijklmn_10[v41];
LABEL_50:
if ( v44 != v39 )
goto LABEL_61;
v40 = v41 + (v34 << 6);
if ( v23 )
{
LABEL_52:
if ( v23 > 1 )
goto LABEL_56;
goto LABEL_55;
}
}
v19[2] = sub_10057BBA8((unsigned __int8)v40);
LABEL_55:
v19[1] = sub_10057BBA8(BYTE1(v40));
LABEL_56:
*v19 = sub_10057BBA8(BYTE2(v40));
if ( 3 == v23 )
goto LABEL_61;
v19 += 3 - v23;
v5 += 4;
++v20;
}
while ( v20 < v15 );
}
v7 = 0;
*v19 = 0;
*a2 = v18;
*a3 = v46;
}
else
{
return 27;
}
}
else
{
return 61;
}
}
return v7;
}