//
// sub_601BE6 from 0x601be6 to 0x601c38 (82 bytes)
//
// 2 xrefs:
// > sub_607BBC @ 0x607c46
// > sub_607BBC @ 0x60884a
//
// 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_601BE6(int a1, void *a2, int a3, int a4)
{
int *v6; // r1
size_t v7; // r8
int v8; // r9
int v9; // r6
unsigned int v10; // r5
int v11; // r5
int *v12; // r0
void *result; // r0
v6 = *(int **)(a1 + 4);
v7 = a3 - (_DWORD)a2;
v8 = *(_DWORD *)(a1 + 8) - (_DWORD)v6;
v9 = *(_DWORD *)(a1 + 12) - (_DWORD)v6;
v10 = (v8 >> 3) + ((a3 - (int)a2) >> 3);
if ( v10 > v9 >> 3 )
{
v11 = 2 * v10;
v12 = sub_601B48(a4, v6, v9, v11 * 4);
*(_DWORD *)(a1 + 4) = v12;
*(_DWORD *)(a1 + 8) = (char *)v12 + v8;
*(_DWORD *)(a1 + 12) = &v12[v11];
}
result = memcpy(*(void **)(a1 + 8), a2, v7);
*(_DWORD *)(a1 + 8) += v7;
return result;
}