//
// __cxa_rethrow_primary_exception from 0xf88884 to 0xf8899c (280 bytes)
//
// 2 xrefs:
// > std::rethrow_exception @ 0xf42040
// > ??> @ 0xc9658
//
// 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 13:13:54 +0000
//
__int64 __fastcall _cxa_rethrow_primary_exception(__int64 result)
{
__int64 v1; // x20
__int64 v2; // x0
__int64 v3; // x19
unsigned __int64 *v4; // x21
unsigned __int64 v5; // x8
__int64 terminate; // x0
__int64 globals; // x0
__int64 v8; // x0
__int64 v9; // x20
int v10; // w8
v1 = result;
if ( result )
{
v2 = sub_F89F18(120);
v3 = v2;
if ( !v2 )
std::terminate();
v4 = (unsigned __int64 *)(v1 - 120);
memset((void *)(v2 + 8), 0, 0x70u);
*(_QWORD *)v3 = v1;
do
v5 = __ldaxr(v4);
while ( __stlxr(v5 + 1, v4) );
*(_QWORD *)(v3 + 8) = *(_QWORD *)(v1 - 112);
*(_QWORD *)(v3 + 24) = std::get_unexpected();
terminate = std::get_terminate();
*(_QWORD *)(v3 + 32) = terminate;
*(_QWORD *)(v3 + 88) = 0x434C4E47432B2B01LL;
globals = _cxa_get_globals(terminate);
++*(_DWORD *)(globals + 8);
*(_QWORD *)(v3 + 96) = sub_F889A0;
v8 = Unwind_RaiseException(v3 + 88);
v9 = *(_QWORD *)(v3 + 88);
result = _cxa_get_globals(v8);
if ( (v9 & 0xFFFFFFFFFFFFFF00LL) == 0x434C4E47432B2B00LL )
{
v10 = *(_DWORD *)(v3 + 48);
if ( v10 < 0 )
v10 = -v10;
*(_DWORD *)(v3 + 48) = v10 + 1;
if ( v3 != *(_QWORD *)result )
{
*(_QWORD *)(v3 + 40) = *(_QWORD *)result;
*(_QWORD *)result = v3;
}
--*(_DWORD *)(result + 8);
}
else
{
if ( *(_QWORD *)result )
std::terminate();
*(_QWORD *)result = v3;
}
}
return result;
}