//
// sub_1800929B0 from 0x1800929b0 to 0x180092b6b (443 bytes)
//
// 2 xrefs:
// > base64Decode @ 0x180092df5
// > ??> @ 0x1801b63e4
//
// 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_1800929B0(unsigned __int8 *a1, unsigned int a2, __int64 a3, unsigned int *a4, char a5)
{
unsigned int v5; // esi
unsigned int v10; // edi
int v11; // r10d
char *v12; // rbx
__int64 v13; // rax
char *v14; // rcx
__int64 v15; // rax
int v16; // ecx
int v17; // edx
unsigned int v18; // r8d
__int64 v19; // r9
int v20; // edx
__int64 v21; // rax
__int64 v22; // rdi
__int64 v23; // rdi
int v24; // ecx
int v25; // ecx
__int64 v26; // rax
__int64 v27; // rdi
__int64 v28; // rax
FILE *v29; // rax
FILE *v30; // rax
v5 = 0;
v10 = 0;
v11 = 64;
if ( a5 )
{
v14 = &aAbcdefghijklmn_0[64];
do
{
v15 = (unsigned __int8)*v14--;
byte_1801A8800[v15 + 256] = v11--;
byte_1801A8800[v15] = 1;
}
while ( v11 >= 0 );
}
else
{
v12 = &aAbcdefghijklmn[64];
do
{
v13 = (unsigned __int8)*v12--;
byte_1801A8800[v13 + 256] = v11--;
byte_1801A8800[v13] = 1;
}
while ( v11 >= 0 );
}
v16 = 0;
v17 = 0;
v18 = 0;
if ( !a2 )
{
LABEL_21:
if ( v18 >= a2 || !v16 )
goto LABEL_25;
v30 = _acrt_iob_func(2u);
sub_180092EE0(v30, "base64 encoding incomplete: at least %d bits truncated");
LABEL_24:
v5 = 1;
goto LABEL_25;
}
while ( 1 )
{
v19 = *a1;
if ( (_DWORD)v19 == 61 )
break;
if ( byte_1801A8800[v19] )
{
++v16;
v20 = (char)byte_1801A8800[v19 + 256] + v17;
if ( v16 == 4 )
{
v21 = v10;
v22 = v10 + 1;
*(_BYTE *)(v21 + a3) = BYTE2(v20);
*(_BYTE *)(v22 + a3) = BYTE1(v20);
v23 = (unsigned int)(v22 + 1);
v16 = 0;
*(_BYTE *)(v23 + a3) = v20;
v10 = v23 + 1;
v17 = 0;
}
else
{
v17 = v20 << 6;
}
}
++v18;
++a1;
if ( v18 >= a2 )
goto LABEL_21;
}
v24 = v16 - 1;
if ( !v24 )
{
v29 = _acrt_iob_func(2u);
sub_180092EE0(v29, "base64Decode: encoding incomplete: at least 2 bits missing");
goto LABEL_24;
}
v25 = v24 - 1;
if ( v25 )
{
if ( v25 == 1 )
{
v26 = v10;
v27 = v10 + 1;
*(_BYTE *)(v26 + a3) = BYTE2(v17);
*(_BYTE *)(v27 + a3) = BYTE1(v17);
v10 = v27 + 1;
}
}
else
{
v28 = v10++;
*(_BYTE *)(v28 + a3) = v17 >> 10;
}
LABEL_25:
*a4 = v10;
return v5;
}