//
// sub_10059E3BC from 0x10059e3bc to 0x10059e530 (372 bytes)
//
// 2 xrefs:
// > sub_1005E54F8 @ 0x1005e5550
// > sub_1005E54F8 @ 0x1005e5574
//
// 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
//
unsigned __int8 *__fastcall sub_10059E3BC(unsigned __int8 *result, int *a2)
{
int v2; // w8
int v3; // w9
int v4; // w9
int v5; // w9
int v6; // w9
int v7; // w9
int v8; // w9
int v9; // w9
int v10; // w9
_DWORD *v11; // x9
unsigned int v12; // w10
unsigned int v13; // w11
unsigned int v14; // w12
unsigned int v15; // w13
unsigned int v16; // w14
unsigned int v17; // w15
unsigned int v18; // w11
unsigned int v19; // w12
v2 = 0;
v3 = *result;
*a2 = v3 << 8;
*a2 = result[1] | ((unsigned __int8)v3 << 8);
v4 = result[2];
a2[1] = v4 << 8;
a2[1] = result[3] | ((unsigned __int8)v4 << 8);
v5 = result[4];
a2[2] = v5 << 8;
a2[2] = result[5] | ((unsigned __int8)v5 << 8);
v6 = result[6];
a2[3] = v6 << 8;
a2[3] = result[7] | ((unsigned __int8)v6 << 8);
v7 = result[8];
a2[4] = v7 << 8;
a2[4] = result[9] | ((unsigned __int8)v7 << 8);
v8 = result[10];
a2[5] = v8 << 8;
a2[5] = result[11] | ((unsigned __int8)v8 << 8);
v9 = result[12];
a2[6] = v9 << 8;
a2[6] = result[13] | ((unsigned __int8)v9 << 8);
v10 = result[14];
a2[7] = v10 << 8;
a2[7] = result[15] | ((unsigned __int8)v10 << 8);
v11 = a2 + 8;
do
{
v12 = *(v11 - 7);
v13 = *(v11 - 6);
v14 = *(v11 - 5);
v15 = *(v11 - 4);
v16 = *(v11 - 3);
v17 = *(v11 - 2);
*v11 = (unsigned __int16)((v13 >> 7) | ((_WORD)v12 << 9));
v11[1] = (unsigned __int16)((v14 >> 7) | ((_WORD)v13 << 9));
v11[2] = (unsigned __int16)((v15 >> 7) | ((_WORD)v14 << 9));
v11[3] = (unsigned __int16)((v16 >> 7) | ((_WORD)v15 << 9));
v11[4] = (unsigned __int16)((v17 >> 7) | ((_WORD)v16 << 9));
v18 = *(v11 - 1);
v11[5] = (unsigned __int16)((v18 >> 7) | ((_WORD)v17 << 9));
if ( v2 >= 5 )
break;
v19 = *(v11 - 8);
v11[6] = (unsigned __int16)((v19 >> 7) | ((_WORD)v18 << 9));
v11[7] = (unsigned __int16)(((_WORD)v19 << 9) | (v12 >> 7));
v11 += 8;
++v2;
}
while ( v2 <= 5 );
return result;
}