//
// sub_81FB28 from 0x81fb28 to 0x81fc7e (342 bytes)
//
// 4 xrefs:
// > sub_850120 @ 0x850144
// > sub_850354 @ 0x8503d6
// > sub_85106C @ 0x8510a4
// > sub_855DC4 @ 0x85605a
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:01:49 +0000
//
int __fastcall sub_81FB28(const char *a1, _DWORD *a2, size_t *a3)
{
size_t v6; // r0
int result; // r0
int v8; // r2
int v9; // r3
bool v10; // zf
const char *v11; // r1
int v12; // r3
int v13; // t1
bool v14; // zf
int v15; // r4
int v16; // r3
size_t v17; // r5
void *v18; // r3
int v19; // r2
const char *v20; // r11
_BYTE *v21; // r10
int v22; // r5
unsigned int v23; // r7
const char *v24; // r4
unsigned int v25; // lr
int v26; // r0
int v27; // t1
int v28; // r2
const char *v29; // r1
int v30; // r3
int v31; // t1
unsigned int v32; // r4
unsigned int v33; // r7
void *p; // [sp+0h] [bp-Ch]
size_t v35; // [sp+4h] [bp-8h]
*a2 = 0;
*a3 = 0;
v6 = strlen(a1);
if ( !v6 )
return 61;
v8 = v6 & 3;
if ( (v6 & 3) != 0 )
return 61;
v9 = *(unsigned __int8 *)a1;
v10 = v9 == 0;
if ( *a1 )
v10 = v9 == 61;
if ( v10 )
{
if ( v9 != 61 )
return 61;
v8 = 0;
v16 = 1;
goto LABEL_41;
}
v11 = a1;
do
{
v13 = *(unsigned __int8 *)++v11;
v12 = v13;
++v8;
v14 = v13 == 0;
if ( v13 )
v14 = v12 == 61;
v15 = !v14;
}
while ( !v14 );
if ( v12 == 61 )
{
v16 = v8 + 1;
LABEL_41:
if ( a1[v16] == 61 )
{
v8 += 2;
v15 = 2;
}
else
{
v8 = v16;
v15 = 1;
}
}
if ( v6 != v8 )
return 61;
v17 = v6 >> 2;
v35 = 3 * (v6 >> 2) - v15;
v18 = off_D200AC(v35 + 1);
p = v18;
result = 27;
if ( v18 )
{
if ( !v17 )
{
v21 = v18;
LABEL_37:
*v21 = 0;
*a2 = p;
*a3 = v35;
return 0;
}
v19 = (int)&a1[4 * v17 + 3];
v20 = a1 + 3;
v21 = v18;
v22 = v19;
while ( 2 )
{
v23 = 0;
v24 = v20 - 4;
v25 = 0;
do
{
v27 = *(unsigned __int8 *)++v24;
v26 = v27;
if ( v27 == 61 )
{
v25 <<= 6;
++v23;
}
else
{
if ( v26 == 65 )
{
v28 = 0;
}
else
{
v29 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
v28 = 0;
while ( 1 )
{
v31 = *(unsigned __int8 *)++v29;
v30 = v31;
++v28;
if ( !v31 )
break;
if ( v26 == v30 )
goto LABEL_31;
}
if ( v26 )
goto LABEL_46;
}
LABEL_31:
v25 = v28 + (v25 << 6);
}
}
while ( v24 != v20 );
if ( v23 )
{
v32 = v25 >> 8;
if ( v23 > 1 )
{
LABEL_35:
v33 = 3 - v23;
*v21 = sub_84B850(BYTE1(v32));
if ( !v33 )
{
LABEL_46:
off_D200B0(p);
return 61;
}
v20 += 4;
v21 += v33;
if ( v20 != (const char *)v22 )
continue;
goto LABEL_37;
}
}
else
{
v32 = v25 >> 8;
v21[2] = sub_84B850((unsigned __int8)v25);
}
break;
}
v21[1] = sub_84B850((unsigned __int8)v32);
goto LABEL_35;
}
return result;
}