//
// png_do_bgr from 0xbe5f3c to 0xbe606c (304 bytes)
//
// 3 xrefs:
// > png_do_read_transformations @ 0xbda4d4
// > png_do_write_transformations @ 0xbe9330
// > ??> @ 0x9a8a8
//
// 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
//
char *__fastcall png_do_bgr(char *result, char *a2)
{
int v2; // w2
int v3; // w3
char v4; // w2
char v5; // w4
char v6; // w2
char v7; // w3
char v8; // w2
char v9; // w4
char v10; // w2
char v11; // w3
v2 = (unsigned __int8)result[16];
if ( (v2 & 2) != 0 )
{
v3 = (unsigned __int8)result[17];
result = (char *)*(unsigned int *)result;
if ( v3 == 8 )
{
if ( v2 == 2 )
{
if ( (_DWORD)result )
{
result = &a2[3 * ((_DWORD)result - 1) + 3];
do
{
v8 = *a2;
a2 += 3;
*(a2 - 3) = *(a2 - 1);
*(a2 - 1) = v8;
}
while ( a2 != result );
}
}
else if ( v2 == 6 && (_DWORD)result )
{
result = &a2[4 * ((_DWORD)result - 1) + 4];
do
{
v4 = *a2;
a2 += 4;
*(a2 - 4) = *(a2 - 2);
*(a2 - 2) = v4;
}
while ( a2 != result );
}
}
else if ( v3 == 16 )
{
if ( v2 == 2 )
{
if ( (_DWORD)result )
{
result = &a2[6 * ((_DWORD)result - 1) + 6];
do
{
v9 = *a2;
a2 += 6;
v10 = *(a2 - 5);
v11 = *(a2 - 1);
*(a2 - 6) = *(a2 - 2);
*(a2 - 2) = v9;
*(a2 - 5) = v11;
*(a2 - 1) = v10;
}
while ( a2 != result );
}
}
else if ( v2 == 6 && (_DWORD)result )
{
result = &a2[8 * ((_DWORD)result - 1) + 8];
do
{
v5 = *a2;
a2 += 8;
v6 = *(a2 - 7);
v7 = *(a2 - 3);
*(a2 - 8) = *(a2 - 4);
*(a2 - 4) = v5;
*(a2 - 7) = v7;
*(a2 - 3) = v6;
}
while ( a2 != result );
}
}
}
return result;
}