//
// SetupItemEditTriggerPopup::updateFormulaLabel from 0x140602920 to 0x140603538 (3096 bytes)
//
// 5 xrefs:
// > SetupItemEditTriggerPopup::init @ 0x1406021da
// > SetupItemEditTriggerPopup::onOpButton @ 0x14060231d
// > SetupItemEditTriggerPopup::onCustomToggleTriggerValue @ 0x140603832
// > SetupItemEditTriggerPopup::valueDidChange @ 0x140603860
// > ??> @ 0x14092f8e8
//
// This function is hookable on this platform (idp: pc, 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 11:35:11 +0000
//
// Hidden C++ exception states: #wind=5
void __fastcall SetupItemEditTriggerPopup::updateFormulaLabel(__int64 a1)
{
signed int v2; // r13d
int v3; // r14d
int v4; // esi
int v5; // r12d
int v6; // r15d
int v7; // eax
int v8; // eax
int v9; // ebx
int v10; // edi
__int64 v11; // rdi
bool v12; // r14
bool v13; // si
void **v14; // rdx
void **v15; // rdx
__m128i si128; // xmm6
int v17; // edi
void *v18; // rcx
char v19; // r13
int v20; // ebx
int v21; // ebx
void **v22; // rdx
__int64 v23; // rax
void *v24; // rdx
void *v25; // rcx
void *v26; // rcx
double v27; // xmm0_8
bool v28; // bl
void **v29; // rdx
__int64 v30; // rax
void *v31; // rdx
void **v32; // rdx
cocos2d::CCString *v33; // rax
char *CString; // rax
size_t v35; // r8
__int128 *p_Block_8; // rdx
void *v37; // rcx
__int64 v38; // rax
void *v39; // rdx
cocos2d::CCString *v40; // rax
char v41; // [rsp+38h] [rbp-D0h]
int v42; // [rsp+3Ch] [rbp-CCh]
signed int v43; // [rsp+44h] [rbp-C4h]
signed int v44; // [rsp+48h] [rbp-C0h]
int v45; // [rsp+4Ch] [rbp-BCh]
int v47; // [rsp+58h] [rbp-B0h]
int v48; // [rsp+5Ch] [rbp-ACh]
void *v49[2]; // [rsp+60h] [rbp-A8h] BYREF
__m128i v50; // [rsp+70h] [rbp-98h]
__int128 Block_8; // [rsp+80h] [rbp-88h] BYREF
__int64 v52; // [rsp+90h] [rbp-78h]
unsigned __int64 v53; // [rsp+98h] [rbp-70h]
void *v54[2]; // [rsp+A0h] [rbp-68h] BYREF
size_t v55; // [rsp+B0h] [rbp-58h]
unsigned __int64 v56; // [rsp+B8h] [rbp-50h]
void *Src[2]; // [rsp+C0h] [rbp-48h] BYREF
size_t Size; // [rsp+D0h] [rbp-38h]
unsigned __int64 v59; // [rsp+D8h] [rbp-30h]
void *v60[4]; // [rsp+E0h] [rbp-28h] BYREF
Block_8 = 0;
v52 = 0;
v53 = 15;
LOBYTE(Block_8) = 0;
v2 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 80);
v44 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 95);
v43 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 51);
v3 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 476);
v4 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 477);
v5 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 478);
v6 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 480);
v7 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 481);
if ( v7 <= 0 )
v7 = 1;
v45 = v7;
v8 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 482);
if ( v8 < 3 )
v8 = 3;
v42 = v8;
v48 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 485);
v9 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 486);
v47 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 578);
v10 = (int)(*(float (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 579);
if ( v5 <= 0 )
v5 = 1;
if ( v43 <= 0 && v5 != 3 )
{
v52 = 15;
memmove(&Block_8, "Select a target", 0xFu);
HIBYTE(Block_8) = 0;
v11 = a1;
goto LABEL_113;
}
sub_140602550(v60, v3, v2);
sub_140602550(Src, v4, v44);
sub_140602550(v54, v5, v43);
v12 = v3 && (v2 > 0 || (unsigned int)(v3 - 3) <= 2);
v13 = v4 && (v44 > 0 || (unsigned int)(v4 - 3) <= 2);
if ( !v12 && v13 )
{
v14 = Src;
if ( v59 > 0xF )
v14 = (void **)Src[0];
sub_1400405A0(v60, v14, Size);
v12 = 1;
v13 = 0;
}
v15 = v54;
if ( v56 > 0xF )
v15 = (void **)v54[0];
sub_1400405A0((void **)&Block_8, v15, v55);
sub_140044D80(&Block_8, " ", 1u);
sub_140044D80(&Block_8, &unk_14080BC00, 2u);
si128 = _mm_load_si128((const __m128i *)&xmmword_140836540);
if ( v10 > 0 && v6 )
{
v41 = 1;
*(_OWORD *)v49 = 0;
v17 = v10 - 1;
if ( v17 )
{
if ( v17 == 1 )
{
v50 = si128;
LODWORD(v49[0]) = 6776174;
}
else
{
LOWORD(v49[0]) = 63;
v50 = _mm_load_si128((const __m128i *)&xmmword_140836520);
}
}
else
{
v50 = si128;
LODWORD(v49[0]) = 7561825;
}
sub_140044D80(&Block_8, v49, v50.m128i_u64[0]);
if ( v50.m128i_i64[1] > 0xFuLL )
{
v18 = v49[0];
if ( (unsigned __int64)(v50.m128i_i64[1] + 1) >= 0x1000 )
{
v18 = *((void **)v49[0] - 1);
if ( (unsigned __int64)((char *)v49[0] - (char *)v18 - 8) > 0x1F )
goto LABEL_73;
}
j_j_free(v18);
}
sub_140044D80(&Block_8, &word_140751D50, 1u);
}
else
{
v41 = 0;
}
if ( v9 > 0 && v6 )
{
v19 = 1;
*(_OWORD *)v49 = 0;
v20 = v9 - 1;
if ( v20 )
{
v21 = v20 - 1;
if ( v21 )
{
if ( v21 == 1 )
{
v50 = si128;
LODWORD(v49[0]) = 6907235;
}
else
{
LOWORD(v49[0]) = 63;
v50 = _mm_load_si128((const __m128i *)&xmmword_140836520);
}
}
else
{
v50 = si128;
LODWORD(v49[0]) = 7498854;
}
}
else
{
v50 = si128;
LODWORD(v49[0]) = 6581874;
}
sub_140044D80(&Block_8, v49, v50.m128i_u64[0]);
sub_14003D310((__int64)v49);
sub_140044D80(&Block_8, &word_140751D50, 1u);
}
else
{
v19 = 0;
if ( !v6 )
goto LABEL_56;
}
v22 = v54;
if ( v56 > 0xF )
v22 = (void **)v54[0];
sub_140044D80(&Block_8, v22, v55);
sub_140044D80(&Block_8, " ", 1u);
v23 = sub_140602330((__int64)v49, v6);
v24 = (void *)v23;
if ( *(_QWORD *)(v23 + 24) > 0xFu )
v24 = *(void **)v23;
sub_140044D80(&Block_8, v24, *(_QWORD *)(v23 + 16));
sub_14003D310((__int64)v49);
sub_140044D80(&Block_8, " ", 1u);
LABEL_56:
if ( v47 <= 0 )
goto LABEL_65;
*(_OWORD *)v49 = 0;
if ( v47 == 1 )
{
v50 = si128;
LODWORD(v49[0]) = 7561825;
}
else if ( v47 == 2 )
{
v50 = si128;
LODWORD(v49[0]) = 6776174;
}
else
{
LOWORD(v49[0]) = 63;
v50 = _mm_load_si128((const __m128i *)&xmmword_140836520);
}
sub_140044D80(&Block_8, v49, v50.m128i_u64[0]);
if ( v50.m128i_i64[1] > 0xFuLL )
{
v25 = v49[0];
if ( (unsigned __int64)(v50.m128i_i64[1] + 1) < 0x1000
|| (v25 = *((void **)v49[0] - 1), (unsigned __int64)((char *)v49[0] - (char *)v25 - 8) <= 0x1F) )
{
j_j_free(v25);
goto LABEL_64;
}
LABEL_73:
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
LABEL_64:
sub_140044D80(&Block_8, &word_140751D50, 1u);
LABEL_65:
if ( v48 > 0 )
{
*(_OWORD *)v49 = 0;
switch ( v48 )
{
case 1:
v50 = si128;
LODWORD(v49[0]) = 6581874;
break;
case 2:
v50 = si128;
LODWORD(v49[0]) = 7498854;
break;
case 3:
v50 = si128;
LODWORD(v49[0]) = 6907235;
break;
default:
LOWORD(v49[0]) = 63;
v50 = _mm_load_si128((const __m128i *)&xmmword_140836520);
break;
}
sub_140044D80(&Block_8, v49, v50.m128i_u64[0]);
if ( v50.m128i_i64[1] > 0xFuLL )
{
v26 = v49[0];
if ( (unsigned __int64)(v50.m128i_i64[1] + 1) >= 0x1000 )
{
v26 = *((void **)v49[0] - 1);
if ( (unsigned __int64)((char *)v49[0] - (char *)v26 - 8) > 0x1F )
goto LABEL_73;
}
j_j_free(v26);
}
sub_140044D80(&Block_8, &word_140751D50, 1u);
}
v11 = a1;
v27 = (*(double (__fastcall **)(__int64, __int64))(*(_QWORD *)a1 + 1168LL))(a1, 479);
v28 = *(float *)&v27 != 1.0 || (unsigned int)(v42 - 3) > 1;
if ( v13 && v28 )
sub_140044D80(&Block_8, &word_140751D50, 1u);
if ( v12 )
{
v29 = v60;
if ( v60[3] > (void *)0xF )
v29 = (void **)v60[0];
sub_140044D80(&Block_8, v29, (size_t)v60[2]);
}
if ( v13 )
{
sub_140044D80(&Block_8, " ", 1u);
v30 = sub_140602330((__int64)v49, v45);
v31 = (void *)v30;
if ( *(_QWORD *)(v30 + 24) > 0xFu )
v31 = *(void **)v30;
sub_140044D80(&Block_8, v31, *(_QWORD *)(v30 + 16));
sub_14003D310((__int64)v49);
sub_140044D80(&Block_8, " ", 1u);
v32 = Src;
if ( v59 > 0xF )
v32 = (void **)Src[0];
sub_140044D80(&Block_8, v32, Size);
if ( v28 )
sub_140044D80(&Block_8, ")", 1u);
}
if ( v12 || v13 )
{
if ( !v28 )
goto LABEL_104;
sub_140044D80(&Block_8, " ", 1u);
v38 = sub_140602330((__int64)v49, v42);
v39 = (void *)v38;
if ( *(_QWORD *)(v38 + 24) > 0xFu )
v39 = *(void **)v38;
sub_140044D80(&Block_8, v39, *(_QWORD *)(v38 + 16));
sub_14003D310((__int64)v49);
sub_140044D80(&Block_8, " ", 1u);
v40 = cocos2d::CCString::createWithFormat("%.03f", *(float *)&v27);
CString = (char *)cocos2d::CCString::getCString(v40);
v35 = -1;
do
++v35;
while ( CString[v35] );
}
else
{
v33 = cocos2d::CCString::createWithFormat("%.03f", *(float *)&v27);
CString = (char *)cocos2d::CCString::getCString(v33);
v35 = -1;
do
++v35;
while ( CString[v35] );
}
sub_140044D80(&Block_8, CString, v35);
LABEL_104:
if ( v48 > 0 )
sub_140044D80(&Block_8, ")", 1u);
if ( v47 > 0 )
sub_140044D80(&Block_8, ")", 1u);
if ( v19 )
sub_140044D80(&Block_8, ")", 1u);
if ( v41 )
sub_140044D80(&Block_8, ")", 1u);
sub_14003D310((__int64)v54);
sub_14003D310((__int64)Src);
sub_14003D310((__int64)v60);
LABEL_113:
p_Block_8 = &Block_8;
if ( v53 > 0xF )
p_Block_8 = (__int128 *)Block_8;
(**(void (__fastcall ***)(__int64, __int128 *))(*(_QWORD *)(v11 + 1000) + 360LL))(
*(_QWORD *)(v11 + 1000) + 360LL,
p_Block_8);
cocos2d::CCLabelBMFont::limitLabelWidth(*(cocos2d::CCLabelBMFont **)(v11 + 1000), 400.0, 0.80000001, 0.0);
if ( v53 > 0xF )
{
v37 = (void *)Block_8;
if ( v53 + 1 >= 0x1000 )
{
v37 = *(void **)(Block_8 - 8);
if ( (unsigned __int64)(Block_8 - (_QWORD)v37 - 8) > 0x1F )
invoke_watson(nullptr, nullptr, nullptr, 0, 0);
}
j_j_free(v37);
}
}