//
// png_write_sBIT from 0xbec614 to 0xbec7c0 (428 bytes)
//
// 2 xrefs:
// > png_write_info_before_PLTE @ 0xbe6d00
// > ??> @ 0xc33c0
//
// 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 png_write_sBIT(__int64 a1, unsigned __int8 *a2, int a3)
{
unsigned int v4; // w3
unsigned int v5; // w4
unsigned int v6; // w6
int v7; // w5
int v8; // w3
__int64 v9; // x22
__int64 v10; // x0
unsigned int v11; // w1
_BYTE v13[8]; // [xsp+48h] [xbp+48h] BYREF
_BYTE v14[4]; // [xsp+50h] [xbp+50h] BYREF
_BYTE v15[4]; // [xsp+54h] [xbp+54h] BYREF
if ( (a3 & 2) != 0 )
{
if ( a3 == 3 )
v4 = 8;
else
v4 = *(unsigned __int8 *)(a1 + 689);
if ( v4 < *a2 )
goto LABEL_18;
if ( !*a2 )
goto LABEL_18;
v5 = a2[1];
if ( v4 < v5 )
goto LABEL_18;
if ( !a2[1] )
goto LABEL_18;
v6 = a2[2];
if ( v4 < v6 || !a2[2] )
goto LABEL_18;
v13[0] = *a2;
v7 = 3;
v13[1] = v5;
v8 = 4;
v13[2] = v6;
v9 = 4;
v10 = 3;
}
else
{
if ( !a2[3] || *(unsigned __int8 *)(a1 + 689) < (unsigned int)a2[3] )
goto LABEL_18;
v13[0] = a2[3];
v7 = 1;
v8 = 2;
v9 = 2;
v10 = 1;
}
if ( (a3 & 4) == 0 )
{
if ( !a1 )
return _stack_chk_guard;
v8 = v7;
v9 = v10;
goto LABEL_15;
}
v11 = a2[4];
if ( !v11 || *(unsigned __int8 *)(a1 + 689) < v11 )
{
LABEL_18:
png_warning(a1, "Invalid sBIT depth specified");
return _stack_chk_guard;
}
v13[v10] = v11;
LABEL_15:
*(_DWORD *)(a1 + 1252) = 34;
png_save_uint_32(v14, v8);
png_save_uint_32(v15, 1933723988);
png_write_data(a1);
*(_DWORD *)(a1 + 592) = 1933723988;
png_reset_crc(a1);
png_calculate_crc((_DWORD *)a1, (__int64)v15, 4);
*(_DWORD *)(a1 + 1252) = 66;
png_write_chunk_data(a1, (__int64)v13, v9);
png_write_chunk_end(a1);
return _stack_chk_guard;
}