//
// __cxa_thread_atexit from 0xf89c90 to 0xf89dd0 (320 bytes)
//
// 2 xrefs:
// > sub_D1CD80 @ 0xd1cdec
// > ??> @ 0x103e40
//
// 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:55 +0000
//
int _cxa_thread_atexit(void (*lpfunc)(void *), void *obj, void *lpdso_handle)
{
unsigned __int8 v6; // w8
int v7; // w1
int v8; // w2
int v9; // w3
int v10; // w4
int v11; // w5
int v12; // w6
int v13; // w7
_QWORD *v14; // x21
__int64 *address; // x8
__int64 v16; // x9
char v17; // [xsp+0h] [xbp-20h]
if ( &_cxa_thread_atexit_impl )
return __cxa_thread_atexit_impl();
v6 = atomic_load((unsigned __int8 *)&byte_1565F20);
if ( (v6 & 1) == 0 && _cxa_guard_acquire((__guard *)&byte_1565F20) )
{
if ( pthread_key_create((pthread_key_t *)&dword_1565F28, (void (*)(void *))sub_F89E54) )
sub_F8BF98("__libcxxabi_tls_create() failed in __cxa_thread_atexit()", v7, v8, v9, v10, v11, v12, v13, v17);
__cxa_atexit((void (*)(void *))sub_F89DD4, &unk_1565F18, &unk_1548000);
_cxa_guard_release((__guard *)&byte_1565F20);
}
if ( (*(_BYTE *)_emutls_get_address(&unk_154D290) & 1) == 0 )
{
if ( pthread_setspecific(dword_1565F28, &dword_1565F28) )
return -1;
*(_BYTE *)_emutls_get_address(&unk_154D290) = 1;
}
v14 = malloc(0x18u);
if ( v14 )
{
*v14 = lpfunc;
v14[1] = obj;
address = (__int64 *)_emutls_get_address(&unk_154D2B0);
v16 = *address;
*address = (__int64)v14;
v14[2] = v16;
return 0;
}
return -1;
}