//
// lws_b64_encode_string from 0x8560d4 to 0x8561ae (218 bytes)
//
// 4 xrefs:
// > sub_8562D8 @ 0x8562f0
// > lws_set_proxy @ 0x8569d0
// > sub_85A27C @ 0x85a2ae
// > sub_85A27C @ 0x85a4fa
//
// 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_encode_string(unsigned __int8 *a1, int a2, _BYTE *a3, int a4)
{
_BYTE *v4; // r4
int v5; // lr
int v6; // r8
unsigned int v7; // r6
unsigned int v8; // r7
_BYTE *v9; // r10
char v10; // r5
int v11; // r6
char v12; // r2
unsigned int v13; // r2
int v15; // r1
if ( a2 )
{
v4 = a3 + 4;
v5 = 0;
while ( 1 )
{
v13 = *a1;
if ( a2 == 1 )
{
++a1;
v6 = 1;
v7 = 0;
}
else
{
v7 = a1[1];
if ( a2 != 2 )
{
v5 += 4;
v8 = a1[2];
a2 -= 3;
a1 += 3;
v6 = 3;
if ( v5 >= a4 )
return -1;
goto LABEL_5;
}
a1 += 2;
v6 = 2;
}
v5 += 4;
v8 = 0;
a2 = 0;
if ( v5 >= a4 )
return -1;
LABEL_5:
v9 = v4;
v10 = aAbcdefghijklmn_6[(16 * (v13 & 3)) | (v7 >> 4)];
*(v4 - 4) = aAbcdefghijklmn_6[v13 >> 2];
*(v4 - 3) = v10;
if ( v6 == 1 )
{
*(v4 - 2) = 61;
v4 += 4;
*(v4 - 5) = 61;
if ( !a2 )
goto LABEL_17;
}
else
{
v4 += 4;
v11 = (v8 >> 6) | (4 * (v7 & 0xF));
if ( v6 == 3 )
v8 &= 0x3Fu;
*(v4 - 6) = aAbcdefghijklmn_6[v11];
if ( v6 == 3 )
v12 = aAbcdefghijklmn_6[v8];
else
v12 = 61;
*(v4 - 5) = v12;
if ( !a2 )
{
LABEL_17:
v15 = v5 + 1;
a3 = v9;
goto LABEL_18;
}
}
}
}
v5 = 0;
v15 = 1;
LABEL_18:
if ( a4 <= v15 )
return -1;
*a3 = 0;
return v5;
}