//
// png_set_sCAL_s from 0x86fd9c to 0x86fe94 (248 bytes)
//
// 3 xrefs:
// > png_handle_sCAL @ 0x86e102
// > png_set_sCAL @ 0x86ff02
// > png_set_sCAL_fixed @ 0x86ff6c
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:02:57 +0000
//
void *__fastcall png_set_sCAL_s(void *result, int a2, int a3, char *a4, const char *a5)
{
bool v5; // zf
char v8; // r10
int v9; // r9
size_t v10; // r5
size_t v11; // r7
size_t v12; // r5
void *v13; // r0
size_t v14; // r7
void *v15; // r0
int v16; // r3
v5 = a2 == 0;
if ( a2 )
v5 = result == nullptr;
if ( !v5 )
{
v8 = a3;
if ( (unsigned int)(a3 - 1) > 1 )
png_error((int)result, "Invalid sCAL unit");
v9 = (int)result;
if ( !a4 || (v10 = strlen(a4)) == 0 || *a4 == 45 || !png_check_fp_string((int)a4, v10) )
png_error(v9, "Invalid sCAL width");
if ( !a5 || (v11 = strlen(a5)) == 0 || *a5 == 45 || !png_check_fp_string((int)a5, v11) )
png_error(v9, "Invalid sCAL height");
v12 = v10 + 1;
*(_BYTE *)(a2 + 252) = v8;
v13 = png_malloc_warn(v9, v12);
*(_DWORD *)(a2 + 256) = v13;
if ( v13 )
{
v14 = v11 + 1;
memcpy(v13, a4, v12);
v15 = png_malloc_warn(v9, v14);
*(_DWORD *)(a2 + 260) = v15;
if ( v15 )
{
result = memcpy(v15, a5, v14);
v16 = *(_DWORD *)(a2 + 232);
*(_DWORD *)(a2 + 8) |= 0x4000u;
*(_DWORD *)(a2 + 232) = v16 | 0x100;
}
else
{
png_free(v9, *(void **)(a2 + 256));
*(_DWORD *)(a2 + 256) = 0;
return (void *)png_warning(v9, "Memory allocation failed while processing sCAL");
}
}
else
{
return (void *)png_warning(v9, "Memory allocation failed while processing sCAL");
}
}
return result;
}