//
// sub_BF5814 from 0xbf5814 to 0xbf58e0 (204 bytes)
//
// 1 xrefs:
// > jinit_color_converter @ 0xbf6730
//
// 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_BF5814(__int64 result, __int64 *a2, _QWORD *a3, unsigned int a4, int a5)
{
unsigned int v5; // w10
__int64 v6; // x5
__int64 v7; // x13
__int64 v8; // x12
__int64 v9; // x11
__int64 v10; // x8
__int64 v11; // t1
__int64 v12; // x9
__int64 v13; // x16
_DWORD *v14; // x15
__int64 v15; // x14
v5 = *(_DWORD *)(result + 48);
v6 = *(_QWORD *)(*(_QWORD *)(result + 536) + 16LL);
while ( --a5 >= 0 )
{
while ( 1 )
{
result = 0;
v7 = *(_QWORD *)(*a3 + 8LL * a4);
v8 = *(_QWORD *)(a3[1] + 8LL * a4);
v9 = *(_QWORD *)(a3[2] + 8LL * a4++);
v11 = *a2++;
v10 = v11;
if ( !v5 )
break;
do
{
v12 = *(unsigned __int8 *)(v10 + 1);
v10 += 3;
v13 = v6 + 8LL * *(unsigned __int8 *)(v10 - 3);
v14 = (_DWORD *)(v6 + 8 * (v12 + 256));
v15 = v6 + 8 * (*(unsigned __int8 *)(v10 - 1) + 512LL);
*(_BYTE *)(v7 + result) = ((unsigned int)*(_QWORD *)v13 + *v14 + *(_DWORD *)v15) >> 16;
*(_BYTE *)(v8 + result) = (unsigned int)(*(_DWORD *)(v13 + 6144) + v14[1536] + *(_DWORD *)(v15 + 6144)) >> 16;
*(_BYTE *)(v9 + result++) = ((unsigned int)*(_QWORD *)(v13 + 10240)
+ v14[2560]
+ (unsigned int)*(_QWORD *)(v15 + 10240)) >> 16;
}
while ( v5 > (unsigned int)result );
if ( --a5 < 0 )
return result;
}
}
return result;
}