//
// lws_b64_decode_string from 0x8561b4 to 0x8562d2 (286 bytes)
//
// 1 xrefs:
// > sub_8562D8 @ 0x856314
//
// 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:02:36 +0000
//
int __fastcall lws_b64_decode_string(_BYTE *a1, _BYTE *a2, int a3)
{
int v3; // r3
int v4; // r10
unsigned __int8 *v5; // lr
int v6; // r12
_BYTE *v7; // r4
char *v8; // r5
int v9; // r7
bool v10; // zf
bool v11; // r5
int v12; // r5
int v13; // r3
int v14; // r4
int result; // r0
int v16; // r3
int v17; // r5
unsigned __int8 v18; // [sp+Ch] [bp-8h] BYREF
unsigned __int8 v19; // [sp+Dh] [bp-7h]
unsigned __int8 v20; // [sp+Eh] [bp-6h]
char v21; // [sp+Fh] [bp-5h]
char v22; // [sp+10h] [bp-4h] BYREF
v3 = (unsigned __int8)*a1;
if ( *a1 )
{
v4 = 0;
LABEL_3:
v5 = &v18;
v6 = 0;
while ( 1 )
{
v7 = a1 + 1;
while ( 1 )
{
while ( 1 )
{
v8 = &aAbcdefghijklmn_6[v3];
a1 = v7;
if ( (unsigned __int8)(v3 - 43) <= 0x4Fu )
{
v9 = (unsigned __int8)v8[25];
v10 = v9 == 0;
if ( v8[25] )
v10 = v9 == 36;
if ( !v10 )
break;
}
v3 = (unsigned __int8)*v7;
v11 = 1;
if ( !*v7 )
goto LABEL_29;
++v6;
LABEL_36:
++v7;
}
v3 = (unsigned __int8)*v7;
v11 = (unsigned __int8)(v9 - 61) == 0;
if ( *v7 )
break;
LABEL_29:
if ( v3 )
v17 = v11;
else
v17 = 0;
*v5 = 0;
++v7;
v3 = 0;
if ( !v17 )
goto LABEL_12;
}
++v6;
if ( (_BYTE)v9 == 61 )
goto LABEL_36;
*v5 = v9 - 62;
LABEL_12:
if ( ++v5 == (unsigned __int8 *)&v22 || !v3 )
{
if ( v4 + v6 - 1 <= a3 )
{
if ( v6 > 1 )
{
v12 = v19;
v13 = (v19 >> 4) | (4 * v18);
*a2 = v13;
if ( v6 == 2 )
{
++a2;
v3 = (unsigned __int8)*a1;
}
else
{
if ( v6 != 3 )
LOBYTE(v13) = v21 | (v20 << 6);
v14 = (v20 >> 2) | (16 * v12);
if ( v6 != 3 )
a2[2] = v13;
a2[1] = v14;
if ( v6 == 3 )
a2 += 2;
else
a2 += 3;
v3 = (unsigned __int8)*a1;
}
}
v4 += v6 - 1;
if ( !v3 )
{
result = v4;
v16 = v4 + 1;
goto LABEL_27;
}
goto LABEL_3;
}
return -1;
}
}
}
result = (unsigned __int8)*a1;
v16 = 1;
LABEL_27:
if ( a3 <= v16 )
return -1;
*a2 = 0;
return result;
}