//
// sub_BF595C from 0xbf595c to 0xbf5a60 (260 bytes)
//
// 1 xrefs:
// > jinit_color_converter @ 0xbf678c
//
// 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_BF595C(__int64 result, __int64 *a2, _QWORD *a3, unsigned int a4, int a5)
{
unsigned int v5; // w10
__int64 v6; // x8
__int64 v7; // x6
__int64 v8; // x14
__int64 v9; // x13
__int64 v10; // x12
__int64 v11; // x11
__int64 v12; // x7
__int64 v13; // t1
int v14; // w5
int v15; // w15
__int64 v16; // x0
__int64 v17; // x18
__int64 v18; // x17
__int64 v19; // x16
__int64 v20; // x15
__int64 v21; // x5
v5 = *(_DWORD *)(result + 48);
v6 = *(_QWORD *)(*(_QWORD *)(result + 536) + 16LL);
while ( --a5 >= 0 )
{
while ( 1 )
{
v7 = 0;
result = a3[3];
v8 = *(_QWORD *)(*a3 + 8LL * a4);
v9 = *(_QWORD *)(a3[1] + 8LL * a4);
v10 = *(_QWORD *)(a3[2] + 8LL * a4);
v11 = *(_QWORD *)(result + 8LL * a4++);
v13 = *a2++;
v12 = v13;
if ( !v5 )
break;
do
{
v14 = *(unsigned __int8 *)(v12 + 1);
v12 += 4;
v15 = 255 - *(unsigned __int8 *)(v12 - 4);
v16 = 255 - *(unsigned __int8 *)(v12 - 2);
*(_BYTE *)(v11 + v7) = *(_BYTE *)(v12 - 1);
v17 = v6 + 8LL * v15;
v18 = v6 + 8 * (255 - v14 + 256LL);
v19 = v6 + 8 * (v16 + 512);
*(_BYTE *)(v8 + v7) = ((unsigned int)*(_QWORD *)v17 + *(_DWORD *)v18 + *(_DWORD *)v19) >> 16;
*(_BYTE *)(v9 + v7) = (unsigned int)(*(_DWORD *)(v17 + 6144) + *(_DWORD *)(v18 + 6144) + *(_DWORD *)(v19 + 6144)) >> 16;
v20 = *(_QWORD *)(v17 + 10240);
v21 = *(_QWORD *)(v19 + 10240);
result = (v20 + *(_QWORD *)(v18 + 10240) + v21) >> 16;
*(_BYTE *)(v10 + v7++) = (unsigned int)(v20 + *(_DWORD *)(v18 + 10240) + v21) >> 16;
}
while ( v5 > (unsigned int)v7 );
if ( --a5 < 0 )
return result;
}
}
return result;
}