//
// sub_BD0318 from 0xbd0318 to 0xbd03a8 (144 bytes)
//
// 2 xrefs:
// > png_image_begin_read_from_memory @ 0xbd6370
// > png_image_begin_read_from_memory @ 0xbd6378
//
// 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
//
void *__fastcall sub_BD0318(void *result, void *a2, size_t a3)
{
__int64 v3; // x20
__int64 *v6; // x1
__int64 v7; // x3
__int64 v8; // x20
size_t v9; // x22
__int64 v10; // x21
v3 = (__int64)result;
if ( result )
{
v6 = *(__int64 **)(v3 + 320);
v7 = v3;
if ( !v6 || (v8 = *v6) == 0 )
png_error(v7, "invalid memory read");
v9 = *(_QWORD *)(v8 + 32);
v10 = *(_QWORD *)(v8 + 24);
if ( v9 < a3 || !v10 )
png_error(v7, "read beyond end of data");
result = memcpy(a2, *(const void **)(v8 + 24), a3);
*(_QWORD *)(v8 + 24) = v10 + a3;
*(_QWORD *)(v8 + 32) = v9 - a3;
}
return result;
}