//
// png_do_bgr from 0xe5c0fc to 0xe5c22c (304 bytes)
//
// 3 xrefs:
// > png_do_read_transformations @ 0xe50694
// > png_do_write_transformations @ 0xe5f4f0
// > ??> @ 0xcbc68
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:10:21 +0000
//
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;
}