//
// std::vector>::_M_fill_insert from 0x36fe78 to 0x3700ee (630 bytes)
//
// 3 xrefs:
// > std::vector>::resize @ 0x370166
// > GJBaseGameLayer::addToSection @ 0x482e72
// > GJBigSprite::init @ 0x50f462
//
// 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 std::vector::_M_fill_insert(const void **a1, char *a2, int a3, unsigned int a4, ...)
{
int v6; // r6
unsigned int v7; // r0
int v8; // r1
int v9; // r2
char *v10; // r11
int v11; // r7
char *v12; // r3
int v13; // r9
int v14; // r6
int v15; // r2
int v16; // r12
_BOOL4 v17; // r0
signed int v18; // r5
int v19; // r2
int v20; // r3
int v21; // r6
unsigned int v22; // r3
unsigned int v23; // r6
char *v24; // r0
int v25; // r8
unsigned int v26; // r7
char *v27; // r9
_BOOL4 v28; // r0
_BYTE *v29; // r10
const void *v30; // r8
int v31; // r5
_BOOL4 v32; // r0
void *v33; // r0
int v34; // [sp+Ch] [bp-68h]
char *v35; // [sp+10h] [bp-64h]
int v36; // [sp+14h] [bp-60h]
char *v37; // [sp+18h] [bp-5Ch] BYREF
int v38; // [sp+1Ch] [bp-58h]
char *v39; // [sp+24h] [bp-50h] BYREF
int v40; // [sp+28h] [bp-4Ch]
_DWORD *v41[2]; // [sp+2Ch] [bp-48h] BYREF
int v42[2]; // [sp+34h] [bp-40h] BYREF
char *v43; // [sp+3Ch] [bp-38h] BYREF
int v44; // [sp+40h] [bp-34h]
char *v45; // [sp+44h] [bp-30h] BYREF
int v46; // [sp+48h] [bp-2Ch]
char *v47; // [sp+4Ch] [bp-28h] BYREF
int v48; // [sp+50h] [bp-24h]
char *v49; // [sp+54h] [bp-20h] BYREF
int v50; // [sp+58h] [bp-1Ch]
char *v51; // [sp+5Ch] [bp-18h] BYREF
int v52; // [sp+60h] [bp-14h]
char *v53; // [sp+64h] [bp-10h] BYREF
int v54; // [sp+68h] [bp-Ch]
va_list va; // [sp+98h] [bp+24h] BYREF
va_start(va, a4);
v37 = a2;
v38 = a3;
if ( a4 )
{
v6 = 8 * ((_BYTE *)a1[4] - (_BYTE *)*a1) - (_DWORD)a1[1];
v7 = std::vector::size(a1);
if ( v6 - v7 < a4 )
{
v21 = 2147483616;
if ( 2147483616 - v7 < a4 )
sub_7731C4("vector::_M_fill_insert", v8, v9);
if ( v7 < a4 )
v22 = v7 + a4;
else
v22 = 2 * v7;
if ( v22 >= v7 && v22 <= 0x7FFFFFE0 )
v21 = v22;
v23 = 4 * ((unsigned int)(v21 + 31) >> 5);
v24 = (char *)operator new(v23);
v25 = v38;
v26 = v37 - (_BYTE *)*a1;
v27 = v24;
if ( v26 >> 2 )
memmove(v24, *a1, v37 - (_BYTE *)*a1);
v45 = &v27[v26];
v43 = v37;
v44 = 0;
v46 = 0;
while ( v25 > 0 )
{
--v25;
v51 = v45;
v52 = 1 << v46;
v53 = v43;
v54 = 1 << v44;
v28 = std::_Bit_reference::operator bool((int)&v53);
std::_Bit_reference::operator=((int)&v51, v28);
std::_Bit_iterator_base::_M_bump_up(&v43);
std::_Bit_iterator_base::_M_bump_up(&v45);
}
v39 = v45;
v40 = v46;
std::_Bit_iterator::operator+((int *)v41, &v39, a4);
std::fill(v39, v40, v41[0], (int)v41[1], (unsigned __int8 *)va);
v29 = a1[2];
v30 = a1[3];
std::_Bit_iterator::operator+(v42, &v39, a4);
v47 = v37;
v49 = (char *)v42[0];
v31 = (int)v30 + 8 * (v29 - v37) - v38;
v48 = v38;
v50 = v42[1];
while ( v31 > 0 )
{
--v31;
v53 = v49;
v54 = 1 << v50;
v51 = v47;
v52 = 1 << v48;
v32 = std::_Bit_reference::operator bool((int)&v51);
std::_Bit_reference::operator=((int)&v53, v32);
std::_Bit_iterator_base::_M_bump_up(&v47);
std::_Bit_iterator_base::_M_bump_up(&v49);
}
v33 = (void *)*a1;
a1[2] = v49;
a1[3] = (const void *)v50;
if ( v33 )
operator delete(v33);
a1[4] = &v27[v23];
*a1 = v27;
a1[1] = nullptr;
}
else
{
v10 = (char *)a1[2];
v11 = (int)a1[3];
std::_Bit_iterator::operator+((int *)&v39, a1 + 2, a4);
v12 = v39;
v13 = v40;
v14 = v11 - v38 + 8 * (v10 - v37);
v15 = 1;
v16 = 1;
while ( v14 > 0 )
{
if ( v13 )
{
--v13;
}
else
{
v12 -= 4;
v13 = 31;
}
v53 = v12;
v54 = v15 << v13;
if ( v11 )
{
--v11;
}
else
{
v10 -= 4;
v11 = 31;
}
v36 = v15;
--v14;
v35 = v12;
v34 = v16;
v52 = v16 << v11;
v51 = v10;
v17 = std::_Bit_reference::operator bool((int)&v51);
std::_Bit_reference::operator=((int)&v53, v17);
v15 = v36;
v12 = v35;
v16 = v34;
}
std::_Bit_iterator::operator+((int *)&v53, &v37, a4);
std::fill(v37, v38, v53, v54, (unsigned __int8 *)va);
v18 = (signed int)a1[3] + a4;
v19 = (int)a1[2] + 4 * (v18 / 32);
v20 = v18 % 32;
if ( v18 % 32 < 0 )
{
v20 += 32;
v19 -= 4;
}
a1[3] = (const void *)v20;
a1[2] = (const void *)v19;
}
}
}