//
// __cxa_thread_atexit from 0x980c34 to 0x980cfa (198 bytes)
//
// 1 xrefs:
// > sub_7B16D0 @ 0x7b1704
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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 12:06:07 +0000
//
int _cxa_thread_atexit(void (*lpfunc)(void *), void *obj, void *lpdso_handle)
{
char v6; // r0
_DWORD *v7; // r0
_DWORD *v8; // r6
int *address; // r0
int v10; // r1
if ( &__cxa_thread_atexit_impl )
return _cxa_thread_atexit_impl();
v6 = byte_D33CE4;
__dmb(0xBu);
if ( (v6 & 1) == 0 && _cxa_guard_acquire((__guard *)&byte_D33CE4) )
{
if ( pthread_key_create((pthread_key_t *)&dword_D33CE8, (void (*)(void *))sub_980D4C) )
sub_981FC8("__libcxxabi_tls_create() failed in __cxa_thread_atexit()");
_cxa_atexit((void (*)(void *))sub_980D38, &unk_D33CE0, &unk_D1E000);
_cxa_guard_release((__guard *)&byte_D33CE4);
}
if ( !*(_BYTE *)_emutls_get_address(&unk_D22928) )
{
if ( pthread_setspecific(dword_D33CE8, &dword_D33CE8) )
return -1;
*(_BYTE *)_emutls_get_address(&unk_D22928) = 1;
}
v7 = malloc(0xCu);
v8 = v7;
if ( v7 )
{
*v7 = lpfunc;
v7[1] = obj;
address = (int *)_emutls_get_address(&unk_D22938);
v10 = *address;
*address = (int)v8;
v8[2] = v10;
return 0;
}
return -1;
}