//
// SetupRandAdvTriggerPopup::onAddChance from 0x9b07c4 to 0x9b092c (360 bytes)
//
// 3 xrefs:
// > ??> @ 0x6ade8
// > SetupRandAdvTriggerPopup::init @ 0x9b0044
// > ??> @ 0x122b7d8
//
// 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 SetupRandAdvTriggerPopup::onAddChance(SetupRandAdvTriggerPopup *a1, cocos2d::CCObject *a2)
{
char *v3; // x22
int v4; // w24
char *v5; // x0
char *v6; // x22
int v7; // w2
char *v8; // x0
unsigned int *v9; // x22
int v10; // w1
unsigned int *v11; // x22
int v12; // w1
int v13; // [xsp+48h] [xbp+48h]
char *v14; // [xsp+60h] [xbp+60h] BYREF
CCTextInputNode::getString(a1->m_groupIDInput, (__int64)&v14);
v3 = v14;
v4 = atoi(v14);
v5 = v3 - 24;
if ( v3 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v11 = (unsigned int *)(v3 - 8);
do
v12 = __ldaxr(v11);
while ( __stlxr(v12 - 1, v11) );
}
else
{
v12 = *((_DWORD *)v3 - 2);
*((_DWORD *)v3 - 2) = v12 - 1;
}
if ( v12 <= 0 )
operator delete(v5);
}
CCTextInputNode::getString(a1->m_chanceInput, (__int64)&v14);
v6 = v14;
v7 = atoi(v14);
v8 = v6 - 24;
if ( v6 - 24 != (char *)&qword_124B6B0 )
{
if ( &pthread_create )
{
v9 = (unsigned int *)(v6 - 8);
do
v10 = __ldaxr(v9);
while ( __stlxr(v10 - 1, v9) );
}
else
{
v10 = *((_DWORD *)v6 - 2);
*((_DWORD *)v6 - 2) = v10 - 1;
}
if ( v10 <= 0 )
{
v13 = v7;
operator delete(v8);
v7 = v13;
}
}
if ( v7 > 0 && v4 > 0 )
{
SetupRandAdvTriggerPopup::addChance(a1, v4, v7);
SetupRandAdvTriggerPopup::updateGroupIDButtons(a1);
}
}