//
// sub_100314810 from 0x100314810 to 0x1003149f6 (486 bytes)
//
// 1 xrefs:
// > sub_100314A90 @ 0x100314ade
//
// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!
//
// 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:28:40 +0000
//
__int64 __fastcall sub_100314810(__int64 a1, int a2, _BYTE *a3, char a4)
{
__int64 v4; // r10
__int64 result; // rax
unsigned int v6; // r8d
int v7; // r9d
unsigned int v8; // ebx
unsigned int v9; // ebx
char *v10; // rcx
char v11; // di
__int64 v12; // rcx
if ( a2 )
{
v4 = 0;
if ( a4 )
{
LODWORD(result) = 0;
v6 = 0;
v7 = 0;
do
{
while ( 1 )
{
v8 = v6 | *(unsigned __int8 *)(a1 + v4);
if ( ++v7 != 3 )
break;
a3[(unsigned int)result] = aAbcdefghijklmn_6[(v6 >> 18) & 0x3F];
a3[(unsigned int)(result + 1)] = aAbcdefghijklmn_6[(v6 >> 12) & 0x3F];
a3[(unsigned int)(result + 2)] = aAbcdefghijklmn_6[(v8 >> 6) & 0x3F];
a3[(unsigned int)(result + 3)] = aAbcdefghijklmn_6[v8 & 0x3F];
LODWORD(result) = result + 4;
v7 = 0;
v6 = 0;
if ( a2 == ++v4 )
goto LABEL_13;
}
v6 = v8 << 8;
++v4;
}
while ( a2 != v4 );
}
else
{
LODWORD(result) = 0;
v6 = 0;
v7 = 0;
do
{
while ( 1 )
{
v9 = v6 | *(unsigned __int8 *)(a1 + v4);
if ( ++v7 != 3 )
break;
a3[(unsigned int)result] = aAbcdefghijklmn_7[(v6 >> 18) & 0x3F];
a3[(unsigned int)(result + 1)] = aAbcdefghijklmn_7[(v6 >> 12) & 0x3F];
a3[(unsigned int)(result + 2)] = aAbcdefghijklmn_7[(v9 >> 6) & 0x3F];
a3[(unsigned int)(result + 3)] = aAbcdefghijklmn_7[v9 & 0x3F];
LODWORD(result) = result + 4;
v7 = 0;
v6 = 0;
if ( a2 == ++v4 )
goto LABEL_13;
}
v6 = v9 << 8;
++v4;
}
while ( a2 != v4 );
}
LABEL_13:
if ( v7 )
{
if ( v7 == 1 )
v6 <<= 8;
if ( a4 )
v10 = aAbcdefghijklmn_6;
else
v10 = aAbcdefghijklmn_7;
a3[(unsigned int)result] = v10[(v6 >> 18) & 0x3F];
a3[(unsigned int)(result + 1)] = v10[(v6 >> 12) & 0x3F];
v11 = 61;
if ( v7 != 1 )
v11 = v10[(v6 >> 6) & 0x3F];
a3[(unsigned int)(result + 2)] = v11;
v12 = (unsigned int)(result + 3);
LODWORD(result) = result + 4;
a3[v12] = 61;
}
result = (unsigned int)result;
a3[(unsigned int)result] = 0;
}
else
{
*a3 = 0;
return 0;
}
return result;
}