//
// sub_100708854 from 0x100708854 to 0x1007089b8 (356 bytes)
//
// 1 xrefs:
// > sub_100724540 @ 0x10072467c
//
// 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 11:12:52 +0000
//
__int64 __fastcall sub_100708854(__int64 result, char *a2, int *a3, char *__src, int a5, int a6, int a7, int a8)
{
int v8; // w19
char *v9; // x21
int *v12; // x20
__int64 v13; // x2
__int64 v14; // x8
int v15; // w26
char *v16; // x23
int v17; // w24
__int64 v18; // x8
char *v19; // x23
v8 = a5;
v9 = __src;
v12 = (int *)result;
*a3 = 0;
if ( a5 >= 1 )
{
v13 = *(unsigned int *)(result + 4);
if ( (int)v13 >= 81 )
sub_1006AE64C((char)"encode.c", 159, (int)"ctx->length <= (int)sizeof(ctx->enc_data)", (int)__src, a5, a6, a7, a8);
v14 = *(int *)result;
if ( (int)v14 + a5 >= (int)v13 )
{
if ( (_DWORD)v14 )
{
v15 = v13 - v14;
memcpy((void *)(result + 8 + v14), __src, (int)v13 - (int)v14);
v9 += v15;
v8 -= v15;
result = sub_1007089B8(a2, v12 + 2, (unsigned int)v12[1]);
*v12 = 0;
v16 = &a2[(int)result];
*(_WORD *)v16 = 10;
a2 = v16 + 1;
v17 = result + 1;
v13 = (unsigned int)v12[1];
}
else
{
v17 = 0;
}
for ( ; v8 >= (int)v13; v13 = (unsigned int)v12[1] )
{
result = sub_1007089B8(a2, v9, v13);
v18 = v12[1];
v9 += v18;
v8 -= v18;
v19 = &a2[(int)result];
*(_WORD *)v19 = 10;
a2 = v19 + 1;
v17 += result + 1;
}
if ( v8 )
result = (__int64)memcpy(v12 + 2, v9, v8);
*v12 = v8;
*a3 = v17;
}
else
{
result = (__int64)memcpy((void *)(result + v14 + 8), __src, a5);
*v12 += v8;
}
}
return result;
}