//
// sub_595654 from 0x595654 to 0x595870 (540 bytes)
//
// 2 xrefs:
// > CCTextInputNode::onTextFieldDetachWithIME @ 0x5a3f64
// > CCTextInputNode::onTextFieldDetachWithIME @ 0x5a4038
//
// 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
//
__int64 __usercall sub_595654@(char *a1@, char *a2@, char *a3@, __int64 a4@)
{
__int64 v7; // x19
void *v8; // x0
char *v9; // x0
unsigned int *v11; // x1
int v12; // w2
unsigned int *v13; // x1
int v14; // w2
char *v15; // [xsp+48h] [xbp+48h] BYREF
__int64 v16; // [xsp+50h] [xbp+50h] BYREF
sub_D153B8(a4, a1);
sub_D153B8((int)&v15, a2);
sub_D153B8((int)&v16, a3);
while ( 1 )
{
v7 = sub_D1641C(a4, v15);
if ( v7 == -1 )
break;
sub_D1861C(a4, v7, *((_QWORD *)v15 - 3), v16, *(_QWORD *)(v16 - 24));
}
v8 = (void *)(v16 - 24);
if ( (__int64 *)(v16 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v11 = (unsigned int *)(v16 - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
}
else
{
v12 = *(_DWORD *)(v16 - 8);
*(_DWORD *)(v16 - 8) = v12 - 1;
}
if ( v12 <= 0 )
operator delete(v8);
}
v9 = v15 - 24;
if ( v15 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v13 = (unsigned int *)(v15 - 8);
do
v14 = __ldaxr(v13);
while ( __stlxr(v14 - 1, v13) );
}
else
{
v14 = *((_DWORD *)v15 - 2);
*((_DWORD *)v15 - 2) = v14 - 1;
}
if ( v14 <= 0 )
operator delete(v9);
}
return a4;
}