//
// SetupItemCompareTriggerPopup::updateFormulaLabel from 0x100582200 to 0x100582a53 (2131 bytes)
//
// 4 xrefs:
// > SetupItemCompareTriggerPopup::init @ 0x100581d10
// > SetupItemCompareTriggerPopup::onOpButton @ 0x100581f98
// > SetupItemCompareTriggerPopup::onCustomToggleTriggerValue @ 0x100582ca2
// > SetupItemCompareTriggerPopup::valueDidChange @ 0x100582cd9
//
// 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 __fastcall SetupItemCompareTriggerPopup::updateFormulaLabel(SetupItemCompareTriggerPopup *a1)
{
double v1; // xmm0_8
int v3; // r13d
int v4; // r15d
__int64 v5; // r14
int v6; // r12d
int v7; // r14d
int v8; // esi
std::string *v9; // rax
int v10; // r13d
_BYTE *v11; // r15
int v12; // r14d
std::string::size_type v13; // rdx
_BYTE *v14; // rax
int v15; // r12d
_BYTE *v16; // rax
std::string::size_type v17; // rdx
const std::string::value_type *data; // rsi
std::string::size_type size; // rdx
_BYTE *v20; // rax
std::string::size_type v21; // rdx
cocos2d::CCString *v22; // rax
const char *CString; // rax
_BYTE *v24; // rax
std::string::size_type v25; // rdx
int v26; // r12d
std::string::size_type v27; // rdx
int v28; // r15d
_BYTE *v29; // rax
std::string::size_type v30; // rdx
const std::string::value_type *v31; // rsi
std::string::size_type v32; // rdx
_BYTE *v33; // rax
std::string::size_type v34; // rdx
cocos2d::CCString *v35; // rax
const char *v36; // rax
cocos2d::CCLabelBMFont *m_formulaLabel; // rdi
std::string::pointer v38; // rsi
std::string v39; // [rsp+0h] [rbp-B0h] BYREF
std::string v40; // [rsp+18h] [rbp-98h] BYREF
__int64 v41; // [rsp+30h] [rbp-80h]
float v42; // [rsp+38h] [rbp-78h]
float v43; // [rsp+3Ch] [rbp-74h]
float v44; // [rsp+40h] [rbp-70h]
float v45; // [rsp+44h] [rbp-6Ch]
float v46; // [rsp+48h] [rbp-68h]
int v47; // [rsp+4Ch] [rbp-64h]
std::string v48; // [rsp+50h] [rbp-60h] BYREF
int v49; // [rsp+68h] [rbp-48h]
float v50; // [rsp+6Ch] [rbp-44h]
int __s; // [rsp+70h] [rbp-40h] BYREF
_BYTE v52[12]; // [rsp+74h] [rbp-3Ch] BYREF
void *__p; // [rsp+80h] [rbp-30h]
v49 = (int)((float (__fastcall *)(SetupItemCompareTriggerPopup *, __int64))a1->getValue)(a1, 80);
LODWORD(v50) = (int)((float (__fastcall *)(SetupItemCompareTriggerPopup *, __int64))a1->getValue)(a1, 95);
v3 = (int)((float (__fastcall *)(SetupItemCompareTriggerPopup *, __int64))a1->getValue)(a1, 476);
v4 = (int)((float (__fastcall *)(SetupItemCompareTriggerPopup *, __int64))a1->getValue)(a1, 477);
v5 = (unsigned int)(int)((float (__fastcall *)(SetupItemCompareTriggerPopup *, __int64))a1->getValue)(a1, 480);
v6 = (int)((float (__fastcall *)(SetupItemCompareTriggerPopup *, __int64))a1->getValue)(a1, 481);
v44 = ((float (__fastcall *)(SetupItemCompareTriggerPopup *, __int64))a1->getValue)(a1, 482);
if ( (int)v5 <= 0 )
v5 = 3;
v41 = v5;
v7 = LODWORD(v50);
if ( v6 <= 0 )
v6 = 3;
v43 = ((float (__fastcall *)(SetupItemCompareTriggerPopup *, __int64))a1->getValue)(a1, 485);
v46 = ((float (__fastcall *)(SetupItemCompareTriggerPopup *, __int64))a1->getValue)(a1, 486);
v42 = ((float (__fastcall *)(SetupItemCompareTriggerPopup *, __int64))a1->getValue)(a1, 578);
*(float *)&v1 = ((float (__fastcall *)(SetupItemCompareTriggerPopup *, __int64))a1->getValue)(a1, 579);
v45 = *(float *)&v1;
v8 = 1;
if ( v3 >= 2 )
v8 = v3;
sub_100580580(&v39, v8, v49, v1);
v9 = sub_100580580(&v40, v4, v7, v1);
if ( v4 )
{
LOBYTE(v9) = 1;
v47 = (int)v9;
v10 = v6;
if ( v7 <= 0 )
{
LOBYTE(v9) = (unsigned int)(v4 - 3) < 3;
v47 = (int)v9;
}
}
else
{
v47 = 0;
v10 = v6;
}
*(float *)&v49 = ((float (__fastcall *)(SetupItemCompareTriggerPopup *, __int64))a1->getValue)(a1, 479);
v50 = ((float (__fastcall *)(SetupItemCompareTriggerPopup *, __int64))a1->getValue)(a1, 483);
v11 = v52;
v12 = (int)v42;
*(_WORD *)&v48.__r_.__value_.__l.0 = 0;
if ( (int)v42 <= 0 )
goto LABEL_21;
if ( v12 == 2 )
{
LOBYTE(__s) = 6;
qmemcpy((char *)&__s + 1, "neg", 3);
}
else
{
if ( v12 != 1 )
{
v14 = (char *)&__s + 2;
LOWORD(__s) = 16130;
v13 = 1;
goto LABEL_18;
}
LOBYTE(__s) = 6;
qmemcpy((char *)&__s + 1, "abs", 3);
}
v13 = 3;
v14 = v52;
LABEL_18:
*v14 = 0;
std::string::append(&v48, (const std::string::value_type *)&__s + 1, v13);
if ( (__s & 1) != 0 )
operator delete(__p);
std::string::append(&v48, "(");
LABEL_21:
v15 = (int)v43;
if ( (int)v43 > 0 )
{
v16 = v52;
switch ( v15 )
{
case 3:
LOBYTE(__s) = 6;
qmemcpy((char *)&__s + 1, "cei", 3);
v17 = 3;
break;
case 2:
LOBYTE(__s) = 6;
qmemcpy((char *)&__s + 1, "flr", 3);
v17 = 3;
break;
case 1:
LOBYTE(__s) = 6;
qmemcpy((char *)&__s + 1, "rnd", 3);
v17 = 3;
break;
default:
v16 = (char *)&__s + 2;
LOWORD(__s) = 16130;
v17 = 1;
break;
}
*v16 = 0;
std::string::append(&v48, (const std::string::value_type *)&__s + 1, v17);
if ( (__s & 1) != 0 )
operator delete(__p);
std::string::append(&v48, "(");
}
if ( (*(_BYTE *)&v39.__r_.__value_.__s.0 & 1) != 0 )
{
data = v39.__r_.__value_.__l.__data_;
size = v39.__r_.__value_.__l.__size_;
}
else
{
size = *(_BYTE *)&v39.__r_.__value_.__l.0 >> 1;
data = v39.__r_.__value_.__s.__data_;
}
std::string::append(&v48, data, size);
if ( ((unsigned int)(v41 - 3) > 1 || *(float *)&v49 != 1.0)
&& ((unsigned int)(v41 - 3) < 0xFFFFFFFE || *(float *)&v49 != 0.0) )
{
std::string::append(&v48, " ");
v20 = (char *)&__s + 2;
switch ( (int)v41 )
{
case 0:
LOWORD(__s) = 15618;
v21 = 1;
break;
case 1:
LOWORD(__s) = 11010;
v21 = 1;
break;
case 2:
LOWORD(__s) = 11522;
v21 = 1;
break;
case 3:
v20 = v52;
__s = -1568611834;
v21 = 3;
break;
case 4:
LOWORD(__s) = 12034;
v21 = 1;
break;
default:
v20 = (char *)&__s + 3;
LOBYTE(__s) = 4;
*(_WORD *)((char *)&__s + 1) = 16718;
v21 = 2;
break;
}
*v20 = 0;
std::string::append(&v48, (const std::string::value_type *)&__s + 1, v21);
if ( (__s & 1) != 0 )
operator delete(__p);
std::string::append(&v48, " ");
v22 = (cocos2d::CCString *)sub_1007AB580("%.03f", *(_BYTE *)&v39.__r_.__value_.__l.0);
CString = cocos2d::CCString::getCString(v22);
std::string::append(&v48, CString);
}
if ( v15 > 0 )
std::string::append(&v48, ")");
if ( v12 > 0 )
std::string::append(&v48, ")");
std::string::append(&v48, " ");
v24 = (char *)&__s + 3;
switch ( (int)v44 )
{
case 0:
LOBYTE(__s) = 4;
*(_WORD *)((char *)&__s + 1) = 15677;
v25 = 2;
goto LABEL_62;
case 1:
LOWORD(__s) = 15874;
goto LABEL_61;
case 2:
LOBYTE(__s) = 4;
*(_WORD *)((char *)&__s + 1) = 15678;
v25 = 2;
goto LABEL_62;
case 3:
LOWORD(__s) = 15362;
goto LABEL_61;
case 4:
LOBYTE(__s) = 4;
*(_WORD *)((char *)&__s + 1) = 15676;
v25 = 2;
goto LABEL_62;
case 5:
LOBYTE(__s) = 4;
*(_WORD *)((char *)&__s + 1) = 15649;
v25 = 2;
goto LABEL_62;
default:
LOWORD(__s) = 16130;
LABEL_61:
v25 = 1;
v24 = (char *)&__s + 2;
LABEL_62:
*v24 = 0;
std::string::append(&v48, (const std::string::value_type *)&__s + 1, v25);
if ( (__s & 1) != 0 )
operator delete(__p);
std::string::append(&v48, " ");
v26 = (int)v45;
if ( (int)v45 > 0 )
{
if ( v26 == 2 )
{
LOBYTE(__s) = 6;
qmemcpy((char *)&__s + 1, "neg", 3);
v27 = 3;
}
else if ( v26 == 1 )
{
LOBYTE(__s) = 6;
qmemcpy((char *)&__s + 1, "abs", 3);
v27 = 3;
}
else
{
v11 = (char *)&__s + 2;
LOWORD(__s) = 16130;
v27 = 1;
}
*v11 = 0;
std::string::append(&v48, (const std::string::value_type *)&__s + 1, v27);
if ( (__s & 1) != 0 )
operator delete(__p);
std::string::append(&v48, "(");
}
v28 = (int)v46;
if ( (int)v46 > 0 )
{
v29 = v52;
switch ( v28 )
{
case 3:
LOBYTE(__s) = 6;
qmemcpy((char *)&__s + 1, "cei", 3);
v30 = 3;
break;
case 2:
LOBYTE(__s) = 6;
qmemcpy((char *)&__s + 1, "flr", 3);
v30 = 3;
break;
case 1:
LOBYTE(__s) = 6;
qmemcpy((char *)&__s + 1, "rnd", 3);
v30 = 3;
break;
default:
v29 = (char *)&__s + 2;
LOWORD(__s) = 16130;
v30 = 1;
break;
}
*v29 = 0;
std::string::append(&v48, (const std::string::value_type *)&__s + 1, v30);
if ( (__s & 1) != 0 )
operator delete(__p);
std::string::append(&v48, "(");
}
if ( !(_BYTE)v47 )
goto LABEL_101;
if ( (*(_BYTE *)&v40.__r_.__value_.__s.0 & 1) != 0 )
{
v31 = v40.__r_.__value_.__l.__data_;
v32 = v40.__r_.__value_.__l.__size_;
}
else
{
v32 = *(_BYTE *)&v40.__r_.__value_.__l.0 >> 1;
v31 = v40.__r_.__value_.__s.__data_;
}
std::string::append(&v48, v31, v32);
if ( ((unsigned int)(v10 - 3) > 1 || v50 != 1.0) && ((unsigned int)(v10 - 3) < 0xFFFFFFFE || v50 != 0.0) )
{
std::string::append(&v48, " ");
v33 = (char *)&__s + 2;
switch ( v10 )
{
case 1:
LOWORD(__s) = 11010;
v34 = 1;
break;
case 2:
LOWORD(__s) = 11522;
v34 = 1;
break;
case 3:
v33 = v52;
__s = -1568611834;
v34 = 3;
break;
case 4:
LOWORD(__s) = 12034;
v34 = 1;
break;
default:
v33 = (char *)&__s + 3;
LOBYTE(__s) = 4;
*(_WORD *)((char *)&__s + 1) = 16718;
v34 = 2;
break;
}
*v33 = 0;
std::string::append(&v48, (const std::string::value_type *)&__s + 1, v34);
if ( (__s & 1) != 0 )
operator delete(__p);
std::string::append(&v48, " ");
LABEL_101:
v35 = (cocos2d::CCString *)sub_1007AB580("%.03f", *(_BYTE *)&v39.__r_.__value_.__l.0);
v36 = cocos2d::CCString::getCString(v35);
std::string::append(&v48, v36);
}
if ( v28 > 0 )
std::string::append(&v48, ")");
if ( v26 > 0 )
std::string::append(&v48, ")");
m_formulaLabel = a1->m_formulaLabel;
if ( (*(_BYTE *)&v48.__r_.__value_.__s.0 & 1) != 0 )
v38 = v48.__r_.__value_.__l.__data_;
else
v38 = v48.__r_.__value_.__s.__data_;
((void (__fastcall *)(cocos2d::CCLabelBMFont *, std::string::pointer))m_formulaLabel->setString)(
m_formulaLabel,
v38);
cocos2d::CCLabelBMFont::limitLabelWidth(a1->m_formulaLabel, 230.0, 0.69999999, 0.0);
if ( (*(_BYTE *)&v48.__r_.__value_.__s.0 & 1) != 0 )
{
operator delete(v48.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v40.__r_.__value_.__s.0 & 1) == 0 )
{
LABEL_111:
if ( (*(_BYTE *)&v39.__r_.__value_.__s.0 & 1) == 0 )
return;
goto LABEL_112;
}
}
else if ( (*(_BYTE *)&v40.__r_.__value_.__s.0 & 1) == 0 )
{
goto LABEL_111;
}
operator delete(v40.__r_.__value_.__l.__data_);
if ( (*(_BYTE *)&v39.__r_.__value_.__s.0 & 1) != 0 )
LABEL_112:
operator delete(v39.__r_.__value_.__l.__data_);
return;
}
}