//
// sub_C81680 from 0xc81680 to 0xc81b3c (1212 bytes)
//
// 2 xrefs:
// > sub_C83294 @ 0xc832d4
// > sub_C83294 @ 0xc832dc
//
// 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_C81680(__int64 result, __int64 a2, __int64 a3, int a4, int a5, __int64 a6)
{
int v6; // w4
__int64 v7; // x6
_BYTE *v8; // x1
_BYTE *v9; // x5
_BYTE *v10; // x9
int v11; // w10
unsigned int v12; // w6
int v13; // w7
int v14; // w13
unsigned int v15; // w8
int v16; // w14
int8x16_t *v17; // x15
unsigned int v18; // w16
int8x16_t *v19; // x6
int8x16_t *v20; // x17
int8x16_t v21; // t1
int8x16_t v22; // q0
int8x16_t v23; // t1
int v24; // w6
int v25; // w7
__int64 v26; // x6
char v27; // w7
_BYTE *v28; // x6
v6 = a4 + a5;
v7 = (int)a3 * a4;
v8 = (_BYTE *)(a6 + v7);
if ( a4 )
{
a3 = (int)a3;
v9 = &v8[-(int)a3];
}
else
{
if ( (int)result > 1 )
{
v27 = *(_BYTE *)(a6 + v7);
v28 = v8 + 1;
do
{
v27 += *v28;
*v28++ = v27;
}
while ( v28 != &v8[(unsigned int)(result - 2) + 2] );
}
a3 = (int)a3;
v9 = v8;
a4 = 1;
v8 += (int)a3;
}
if ( v6 > a4 )
{
v10 = v8 + 16;
v11 = -(int)v8;
do
{
if ( (int)result > 0 )
{
if ( v8 >= v10 && (v9 >= v10 || v8 >= v9 + 16) && (unsigned int)result > 0x13 )
{
v12 = v11 & 0xF;
if ( (unsigned int)result <= v12 )
v12 = result;
if ( v12 )
{
*v8 += *v9;
if ( v12 == 1 )
goto LABEL_47;
v8[1] += v9[1];
if ( v12 == 2 )
goto LABEL_47;
v8[2] += v9[2];
if ( v12 == 3 )
goto LABEL_47;
v8[3] += v9[3];
if ( v12 == 4 )
goto LABEL_47;
v8[4] += v9[4];
if ( v12 == 5 )
goto LABEL_47;
v8[5] += v9[5];
if ( v12 == 6 )
{
v13 = 6;
goto LABEL_26;
}
v8[6] += v9[6];
if ( v12 == 7
|| (v8[7] += v9[7], v12 == 8)
|| (v8[8] += v9[8], v12 == 9)
|| (v8[9] += v9[9], v12 == 10)
|| (v8[10] += v9[10], v12 == 11)
|| (v8[11] += v9[11], v12 == 12)
|| (v8[12] += v9[12], v12 == 13) )
{
LABEL_47:
v13 = v12;
}
else
{
v8[13] += v9[13];
if ( v12 == 15 )
{
v13 = 15;
v8[14] += v9[14];
}
else
{
v13 = 14;
}
}
}
else
{
v13 = 0;
}
LABEL_26:
v14 = result - v12;
v15 = (((unsigned int)result - v12 - 16) >> 4) + 1;
v16 = 16 * v15;
if ( (_DWORD)result - 1 - v12 <= 0xE )
goto LABEL_30;
v17 = (int8x16_t *)&v8[v12];
v18 = 0;
v19 = (int8x16_t *)&v9[v12];
v20 = v17;
do
{
v21 = *v19++;
v22 = v21;
++v18;
v23 = *v17++;
*v20++ = vaddq_s8(v22, v23);
}
while ( v18 < v15 );
v13 += v16;
if ( v14 != v16 )
{
LABEL_30:
v8[v13] += v9[v13];
if ( (int)result > v13 + 1 )
{
v8[v13 + 1] += v9[v13 + 1];
if ( (int)result > v13 + 2 )
{
v8[v13 + 2] += v9[v13 + 2];
if ( (int)result > v13 + 3 )
{
v8[v13 + 3] += v9[v13 + 3];
if ( (int)result > v13 + 4 )
{
v8[v13 + 4] += v9[v13 + 4];
if ( (int)result > v13 + 5 )
{
v8[v13 + 5] += v9[v13 + 5];
if ( (int)result > v13 + 6 )
{
v8[v13 + 6] += v9[v13 + 6];
if ( (int)result > v13 + 7 )
{
v8[v13 + 7] += v9[v13 + 7];
if ( (int)result > v13 + 8 )
{
v8[v13 + 8] += v9[v13 + 8];
if ( (int)result > v13 + 9 )
{
v8[v13 + 9] += v9[v13 + 9];
if ( (int)result > v13 + 10 )
{
v8[v13 + 10] += v9[v13 + 10];
if ( (int)result > v13 + 11 )
{
v8[v13 + 11] += v9[v13 + 11];
if ( (int)result > v13 + 12 )
{
v24 = v13 + 13;
v8[v13 + 12] += v9[v13 + 12];
if ( (int)result > v13 + 13 )
{
v25 = v13 + 14;
v8[v24] += v9[v24];
if ( (int)result > v25 )
v8[v25] += v9[v25];
}
}
}
}
}
}
}
}
}
}
}
}
}
}
goto LABEL_45;
}
v26 = 0;
do
{
v8[v26] += v9[v26];
++v26;
}
while ( (int)result > (int)v26 );
}
LABEL_45:
++a4;
v9 += a3;
v8 += a3;
v10 += a3;
LOBYTE(v11) = v11 - a3;
}
while ( a4 != v6 );
}
return result;
}