//
// __cxa_allocate_exception from 0x779644 to 0x7796d2 (142 bytes)
//
// 30 xrefs:
// > __cxa_guard_acquire @ 0x743c06
// > operator new @ 0x743e2c
// > sub_756274 @ 0x756278
// > sub_756A4C @ 0x756b00
// > sub_756FA8 @ 0x756fac
// > sub_772F84 @ 0x772f8a
// > sub_772FB4 @ 0x772fba
// > sub_772FE4 @ 0x772fea
// > sub_773014 @ 0x77301a
// > sub_773044 @ 0x773054
// > sub_7730C4 @ 0x7730d4
// > sub_773144 @ 0x773154
// > sub_7731C4 @ 0x7731d4
// > sub_773244 @ 0x773254
// > sub_7732C4 @ 0x773302
// > sub_77336C @ 0x77337c
// > sub_7733EC @ 0x7733fc
// > sub_77346C @ 0x77347c
// > sub_7734EC @ 0x7734fc
// > sub_77356C @ 0x77357a
// > sub_7735D4 @ 0x7735e4
// > sub_77366C @ 0x77367c
// > sub_773708 @ 0x77370e
// > sub_773738 @ 0x773740
// > sub_776A9C @ 0x776b48
// > __cxa_bad_cast @ 0x7798cc
// > __cxa_bad_typeid @ 0x7798fc
// > __cxa_throw_bad_array_new_length @ 0x77992c
// > __cxa_throw_bad_array_length @ 0x77995c
// > ??> @ 0x779ab6
//
// 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 *_cxa_allocate_exception(size_t thrown_size)
{
size_t v1; // r5
char *v2; // r4
int v4; // r3
unsigned int v5; // r2
v1 = thrown_size + 128;
v2 = (char *)malloc(thrown_size + 128);
if ( !v2 )
{
if ( &pthread_create && pthread_mutex_lock((pthread_mutex_t *)&dword_ACECC0) )
sub_756FA8();
if ( v1 > 0x200 )
LABEL_7:
std::terminate();
v4 = 0;
v5 = dword_ACECC4;
while ( (v5 & 1) != 0 )
{
++v4;
v5 >>= 1;
if ( v4 == 32 )
goto LABEL_7;
}
v2 = (char *)&unk_ACECC8 + 512 * v4;
dword_ACECC4 |= 1 << v4;
if ( &pthread_create && pthread_mutex_unlock((pthread_mutex_t *)&dword_ACECC0) )
sub_756274();
}
memset(v2, 0, 0x80u);
return v2 + 128;
}