//
// sub_C10058 from 0xc10058 to 0xc10170 (280 bytes)
//
// 4 xrefs:
// > sub_C10B20 @ 0xc10e90
// > jinit_marker_reader @ 0xc12e20
// > jinit_marker_reader @ 0xc12e30
// > jpeg_save_markers @ 0xc12f4c
//
// 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 sub_C10058(_QWORD *a1)
{
unsigned __int8 **v1; // x23
unsigned __int8 *v2; // x1
unsigned __int8 *v4; // x22
unsigned __int8 v5; // w19
unsigned __int8 *v6; // x20
unsigned __int8 *v7; // x22
unsigned __int64 v8; // x19
__int64 v9; // x2
unsigned int v10; // t1
__int64 v11; // x19
v1 = (unsigned __int8 **)a1[5];
v2 = v1[1];
v4 = *v1;
if ( !v2 )
{
if ( !((unsigned int (*)(void))v1[3])() )
return 0;
v4 = *v1;
v2 = v1[1];
}
v5 = *v4;
v6 = v2 - 1;
v7 = v4 + 1;
v8 = (unsigned __int64)v5 << 8;
if ( v2 == (_BYTE *)&dword_0 + 1 )
{
if ( ((unsigned int (__fastcall *)(_QWORD *))v1[3])(a1) )
{
v7 = *v1;
v6 = v1[1];
goto LABEL_5;
}
return 0;
}
LABEL_5:
v9 = *a1;
v10 = *v7;
*(_DWORD *)(v9 + 44) = *((_DWORD *)a1 + 143);
*(_DWORD *)(v9 + 40) = 93;
v11 = v10 + v8 - 2;
*(_DWORD *)(*a1 + 48LL) = v11;
(*(void (__fastcall **)(_QWORD *, __int64))(*a1 + 8LL))(a1, 1);
*v1 = v7 + 1;
v1[1] = v6 - 1;
if ( v11 > 0 )
(*(void (__fastcall **)(_QWORD *, __int64))(a1[5] + 32LL))(a1, v11);
return 1;
}