//
// sub_749A74 from 0x749a74 to 0x749bd0 (348 bytes)
//
// 2 xrefs:
// > sub_745ED8 @ 0x745efe
// > sub_745ED8 @ 0x745f22
//
// 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
//
int *__fastcall sub_749A74(int *a1, _BYTE *a2, int a3, int a4)
{
int v8; // r3
unsigned int *v9; // r5
unsigned __int8 *v10; // r3
int v11; // r0
int v12; // r2
bool v13; // zf
int v14; // r1
bool v15; // r3
_BYTE *v16; // r10
int v17; // r2
signed int v18; // r4
_BYTE *v19; // r0
void *v20; // r0
unsigned int v21; // r1
unsigned int v22; // r0
int v23; // r2
unsigned int v25; // r2
unsigned int v26; // r0
unsigned int v27; // r3
unsigned int v28; // r1
unsigned __int8 *v29; // r3
char v30[4]; // [sp+4h] [bp-4h] BYREF
a1[1] = 0;
sub_745FB8(v30, a1, 1);
v8 = (unsigned __int8)v30[0];
if ( v30[0] )
{
v9 = *(unsigned int **)((char *)a1 + *(_DWORD *)(*a1 - 12) + 120);
v10 = (unsigned __int8 *)v9[2];
if ( (unsigned int)v10 >= v9[3] )
v11 = (*(int (__fastcall **)(_DWORD))(*v9 + 36))(*(int *)((char *)a1 + *(_DWORD *)(*a1 - 12) + 120));
else
v11 = *v10;
LABEL_4:
v12 = a1[1];
while ( 1 )
{
v13 = v11 == a4;
if ( v11 != a4 )
v13 = v11 == -1;
v14 = v12 + 1;
v15 = !v13;
v8 = v14 < a3 && v15;
if ( !v8 )
break;
v16 = (_BYTE *)v9[2];
v17 = a3 - v12 - 1;
v18 = v9[3] - (_DWORD)v16;
if ( v18 >= v17 )
v18 = v17;
if ( v18 <= 1 )
{
*a2++ = v11;
v27 = v9[2];
v28 = v9[3];
++a1[1];
if ( v27 >= v28 )
{
v11 = (*(int (__fastcall **)(unsigned int *))(*v9 + 40))(v9);
if ( v11 == -1 )
goto LABEL_4;
v29 = (unsigned __int8 *)v9[2];
v28 = v9[3];
}
else
{
v29 = (unsigned __int8 *)(v27 + 1);
v9[2] = (unsigned int)v29;
}
if ( (unsigned int)v29 >= v28 )
{
LABEL_39:
v11 = (*(int (__fastcall **)(unsigned int *))(*v9 + 36))(v9);
goto LABEL_4;
}
v11 = *v29;
v12 = a1[1];
}
else
{
v19 = memchr((const void *)v9[2], a4, v18);
if ( v19 )
v18 = v19 - v16;
v20 = a2;
a2 += v18;
memcpy(v20, v16, v18);
v21 = v9[2];
v22 = v9[3];
v23 = a1[1];
v9[2] = v21 + v18;
v12 = v23 + v18;
a1[1] = v12;
if ( v21 + v18 >= v22 )
goto LABEL_39;
v11 = *(unsigned __int8 *)(v21 + v18);
}
}
if ( v11 == -1 )
{
v8 = 2;
}
else if ( a4 == v11 )
{
v25 = v9[2];
v26 = v9[3];
a1[1] = v14;
if ( v25 >= v26 )
{
(*(void (__fastcall **)(unsigned int *))(*v9 + 40))(v9);
v8 = 0;
}
else
{
v9[2] = v25 + 1;
}
}
else
{
v8 = 4;
}
}
if ( a3 > 0 )
*a2 = 0;
if ( !a1[1] )
{
v8 |= 4u;
LABEL_26:
sub_7446A4((int *)((char *)a1 + *(_DWORD *)(*a1 - 12)), *(int *)((char *)a1 + *(_DWORD *)(*a1 - 12) + 20) | v8);
return a1;
}
if ( v8 )
goto LABEL_26;
return a1;
}