//
// lws_b64_encode_string from 0x646054 to 0x64612e (218 bytes)
//
// 4 xrefs:
// > sub_646258 @ 0x646270
// > lws_set_proxy @ 0x646950
// > sub_64A1FC @ 0x64a22e
// > sub_64A1FC @ 0x64a47a
//
// 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
//
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;
}