//
// sub_140495350 from 0x140495350 to 0x14049559e (590 bytes)
//
// 4 xrefs:
// > RandTriggerGameObject::customObjectSetup @ 0x1404b44f6
// > SequenceTriggerGameObject::customObjectSetup @ 0x1404b4eb3
// > SpawnTriggerGameObject::customObjectSetup @ 0x1404b97ca
// > ??> @ 0x1406dc1d0
//
// 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
//
SetupTriggerPopup *__fastcall sub_140495350(__int64 *a1)
{
SetupTriggerPopup *v2; // r14
unsigned __int64 v3; // rdi
__int64 v4; // rcx
unsigned __int64 v5; // rbp
__int64 v6; // rsi
unsigned __int64 v7; // rcx
size_t v8; // r8
size_t v9; // rcx
__int64 *v10; // rax
void **v11; // rdx
size_t v12; // r8
struct cocos2d::CCObject *v13; // rax
ButtonSprite *v14; // r8
cocos2d::CCPoint v15; // r9
void *v16; // rcx
__int64 v17; // rcx
void *v18; // rcx
void *v19; // rcx
void *Block[2]; // [rsp+38h] [rbp-60h] BYREF
__int64 v22; // [rsp+48h] [rbp-50h]
unsigned __int64 v23; // [rsp+50h] [rbp-48h]
__int128 v24; // [rsp+58h] [rbp-40h] BYREF
__int64 v25; // [rsp+68h] [rbp-30h]
unsigned __int64 v26; // [rsp+70h] [rbp-28h]
v2 = (SetupTriggerPopup *)cocos2d::CCArray::create(a1);
v3 = 0;
v4 = (__int64)a1;
if ( (unsigned __int64)a1[3] > 0xF )
v4 = *a1;
v5 = a1[2];
v6 = sub_140042190(v4, v5, 0, byte_14055D9E4, 1);
while ( 1 )
{
*(_OWORD *)Block = 0;
v22 = 0;
v23 = 0;
v7 = a1[2];
if ( v7 < v3 )
sub_14003BCC0(v7);
v8 = v6 - v3;
v9 = v7 - v3;
if ( v9 < v6 - v3 )
v8 = v9;
v10 = a1;
if ( (unsigned __int64)a1[3] > 0xF )
v10 = (__int64 *)*a1;
sub_14003A930(Block, (char *)v10 + v3, v8);
if ( v22 || v3 != v5 )
{
v11 = Block;
if ( v23 > 0xF )
v11 = (void **)Block[0];
v24 = 0;
v25 = 0;
v26 = 0;
v12 = -1;
do
++v12;
while ( *((_BYTE *)v11 + v12) );
sub_14003A930(&v24, v11, v12);
v13 = (struct cocos2d::CCObject *)cocos2d::CCString::create(&v24);
cocos2d::CCArray::addObject(v2, v13, v14, v15);
if ( v26 > 0xF )
{
v16 = (void *)v24;
if ( v26 + 1 >= 0x1000 )
{
v16 = *(void **)(v24 - 8);
if ( (unsigned __int64)(v24 - (_QWORD)v16 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v16);
}
}
if ( v6 == -1 )
break;
v3 = v6 + 1;
v17 = (__int64)a1;
if ( (unsigned __int64)a1[3] > 0xF )
v17 = *a1;
v6 = sub_140042190(v17, a1[2], v6 + 1, byte_14055D9E4, 1);
if ( v23 > 0xF )
{
v18 = Block[0];
if ( v23 + 1 >= 0x1000 )
{
v18 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v18 - 8) > 0x1F )
goto LABEL_30;
}
j_j_free(v18);
}
}
if ( v23 > 0xF )
{
v19 = Block[0];
if ( v23 + 1 >= 0x1000 )
{
v19 = *((void **)Block[0] - 1);
if ( (unsigned __int64)((char *)Block[0] - (char *)v19 - 8) > 0x1F )
LABEL_30:
invalid_parameter_noinfo_noreturn();
}
j_j_free(v19);
}
return v2;
}