//
// SetupKeyframePopup::onCustomButton from 0xb6b610 to 0xb6bc7c (1644 bytes)
//
// 2 xrefs:
// > ??> @ 0xd8700
// > ??> @ 0x14c7560
//
// This function is hookable on this platform (idp: arm, 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 13:02:18 +0000
//
__int64 __fastcall SetupKeyframePopup::onCustomButton(SetupKeyframePopup *this, cocos2d::CCObject *a2)
{
cocos2d::CCArray *v4; // x0
cocos2d::CCArray *v5; // x19
_QWORD *v6; // x0
_QWORD *v7; // x19
void *v8; // x0
unsigned int *v10; // x1
__int64 *v11; // x22
__int64 v12; // x0
char *v13; // x26
__int64 v14; // x24
int v15; // w3
unsigned __int64 v16; // x20
unsigned __int64 v17; // x19
unsigned __int64 v18; // x23
__int64 *v19; // x0
unsigned __int64 v20; // x1
unsigned __int64 v21; // x1
_DWORD *v22; // x21
float v23; // s0
__int64 v24; // x24
unsigned __int64 prime; // x24
unsigned __int64 v26; // x19
bool v27; // cf
unsigned __int64 v28; // x20
unsigned __int64 v29; // x1
_QWORD *v30; // x0
cocos2d::CCDictionary **v31; // x0
_DWORD *v32; // x19
unsigned __int64 v33; // x0
unsigned __int64 v34; // x1
unsigned __int64 v35; // x0
unsigned __int64 v36; // x19
cocos2d::CCDictionary **v37; // x0
_DWORD *v38; // x19
cocos2d::CCArray *v39; // x0
cocos2d::CCArray *v40; // x0
cocos2d::CCArray *v41; // x19
__int64 *v42; // x19
cocos2d::CCArray *v43; // x0
__int64 *v44; // x0
__int64 *v45; // x1
__int64 *v46; // x1
unsigned int *v47; // x1
unsigned __int64 v48; // x19
__int64 v49; // x0
unsigned __int64 i; // x20
void *v51; // x19
__int64 *v52; // [xsp+78h] [xbp+78h] BYREF
_QWORD v53[2]; // [xsp+80h] [xbp+80h] BYREF
void *v54; // [xsp+90h] [xbp+90h] BYREF
unsigned __int64 v55; // [xsp+98h] [xbp+98h]
void *v56; // [xsp+A0h] [xbp+A0h] BYREF
unsigned __int64 v57; // [xsp+A8h] [xbp+A8h]
float v58; // [xsp+B0h] [xbp+B0h]
v54 = nullptr;
v55 = 0;
v4 = *((cocos2d::CCArray **)this + 85);
v56 = nullptr;
v57 = 0;
v58 = 1.0;
if ( v4 )
v5 = (cocos2d::CCArray *)cocos2d::CCArray::createWithObject(v4, _stack_chk_guard);
else
v5 = *((cocos2d::CCArray **)this + 86);
if ( v5 )
{
if ( (unsigned int)cocos2d::CCArray::count(v5) )
{
v10 = *((unsigned int **)v5 + 7);
if ( *v10 )
{
v11 = *((__int64 **)v10 + 2);
v12 = 8LL * *v10 - 8;
v13 = (char *)v11 + v12;
if ( v11 <= (__int64 *)((char *)v11 + v12) )
{
v14 = *v11;
if ( *v11 )
{
while ( 1 )
{
v15 = *(_DWORD *)(v14 + 1856);
v16 = 0;
v17 = v55;
v18 = v15;
if ( v55 )
{
v16 = v15 & (v55 - 1);
if ( ((v55 - 1) & v55) != 0 )
v16 = v15 % v55;
v19 = *((__int64 **)v54 + v16);
if ( v19 )
{
while ( 1 )
{
v19 = (__int64 *)*v19;
if ( !v19 )
break;
v20 = v19[1];
v21 = ((v55 - 1) & v55) != 0 ? v20 % v55 : (v55 - 1) & v20;
if ( v16 != v21 )
break;
if ( v15 == *((_DWORD *)v19 + 4) )
goto LABEL_44;
}
}
}
v22 = (_DWORD *)operator new(0x18u);
v22[4] = *(_DWORD *)(v14 + 1856);
*((_QWORD *)v22 + 1) = v18;
*(_QWORD *)v22 = 0;
v23 = (float)(v57 + 1);
if ( v23 <= (float)((float)v17 * v58) )
break;
v24 = 2 * v17;
if ( v17 <= 2 )
goto LABEL_28;
prime = (((v17 - 1) & v17) != 0) + v24;
v36 = vcvtps_u32_f32(v23 / v58);
if ( v36 >= prime )
prime = v36;
if ( prime == 1 )
{
LABEL_74:
v17 = v55;
prime = 2;
v27 = v55 <= 2;
if ( v55 < 2 )
goto LABEL_75;
goto LABEL_34;
}
LABEL_31:
if ( ((prime - 1) & prime) != 0 )
prime = std::__next_prime(prime);
v17 = v55;
v27 = prime >= v55;
if ( prime > v55 )
{
LABEL_75:
std::__hash_table,std::equal_to,std::allocator>::__rehash(
(__int64)&v54,
prime);
goto LABEL_60;
}
LABEL_34:
if ( v27 )
goto LABEL_61;
if ( v17 <= 2 || (v28 = v17 - 1, ((v17 - 1) & v17) != 0) )
{
v33 = std::__next_prime(vcvtps_u32_f32((float)v57 / v58));
if ( v33 < prime )
v29 = prime;
else
v29 = v33;
if ( v17 <= v29 )
goto LABEL_60;
}
else
{
v29 = 1LL << (64 - (unsigned __int8)__clz(vcvtps_u32_f32((float)v57 / v58) - 1));
if ( v29 < prime )
v29 = prime;
if ( v17 <= v29 )
{
LABEL_40:
v16 = v28 & v18;
LABEL_41:
v30 = *((_QWORD **)v54 + v16);
if ( v30 )
goto LABEL_42;
goto LABEL_63;
}
}
std::__hash_table,std::equal_to,std::allocator>::__rehash((__int64)&v54, v29);
LABEL_60:
v17 = v55;
LABEL_61:
v28 = v17 - 1;
if ( ((v17 - 1) & v17) == 0 )
goto LABEL_40;
v16 = v18 % v17;
v30 = *((_QWORD **)v54 + v18 % v17);
if ( v30 )
{
LABEL_42:
*(_QWORD *)v22 = *v30;
*v30 = v22;
goto LABEL_43;
}
LABEL_63:
*(_QWORD *)v22 = v56;
v56 = v22;
*((_QWORD *)v54 + v16) = &v56;
if ( *(_QWORD *)v22 )
{
v34 = *(_QWORD *)(*(_QWORD *)v22 + 8LL);
if ( ((v17 - 1) & v17) != 0 )
v35 = v34 % v17;
else
v35 = (v17 - 1) & v34;
*((_QWORD *)v54 + v35) = v22;
}
LABEL_43:
++v57;
LABEL_44:
if ( v13 >= (char *)++v11 )
{
v14 = *v11;
if ( *v11 )
continue;
}
goto LABEL_5;
}
if ( v17 )
goto LABEL_41;
v24 = 0;
LABEL_28:
prime = v24 + 1;
v26 = vcvtps_u32_f32(v23 / v58);
if ( v26 >= prime )
prime = v26;
if ( prime == 1 )
goto LABEL_74;
goto LABEL_31;
}
}
}
}
}
LABEL_5:
if ( (*(unsigned int (__fastcall **)(cocos2d::CCObject *))(*(_QWORD *)a2 + 64LL))(a2) == 2 )
{
SetupKeyframePopup::refreshPreviewArt(this);
goto LABEL_9;
}
if ( (*(unsigned int (__fastcall **)(cocos2d::CCObject *))(*(_QWORD *)a2 + 64LL))(a2) == 4 )
{
v31 = *((cocos2d::CCDictionary ***)this + 128);
if ( v31 )
{
v32 = v56;
if ( v56 )
{
while ( 1 )
{
LevelEditorLayer::reverseKeyframeAnimationOrder(v31, v32[4]);
v32 = *(_DWORD **)v32;
if ( !v32 )
break;
v31 = *((cocos2d::CCDictionary ***)this + 128);
}
}
}
goto LABEL_82;
}
if ( (*(unsigned int (__fastcall **)(cocos2d::CCObject *))(*(_QWORD *)a2 + 64LL))(a2) == 3 )
{
EditorUI::deselectAll(*(EditorUI **)(*((_QWORD *)this + 128) + 14248LL));
v37 = *((cocos2d::CCDictionary ***)this + 128);
if ( v37 )
{
v38 = v56;
if ( v56 )
{
while ( 1 )
{
v39 = (cocos2d::CCArray *)LevelEditorLayer::duplicateKeyframeAnimation(v37, v38[4]);
EditorUI::selectObjects(*(EditorUI **)(*((_QWORD *)this + 128) + 14248LL), v39, 0);
v38 = *(_DWORD **)v38;
if ( !v38 )
break;
v37 = *((cocos2d::CCDictionary ***)this + 128);
}
}
}
LABEL_82:
(*(void (__fastcall **)(SetupKeyframePopup *, _QWORD))(*(_QWORD *)this + 1368LL))(this, 0);
goto LABEL_9;
}
if ( (*(unsigned int (__fastcall **)(cocos2d::CCObject *))(*(_QWORD *)a2 + 64LL))(a2) == 1 && *((_QWORD *)this + 128) )
{
v40 = *((cocos2d::CCArray **)this + 85);
v53[0] = 0;
v53[1] = 0;
v52 = v53;
if ( v40 )
v41 = (cocos2d::CCArray *)cocos2d::CCArray::createWithObject(v40, (cocos2d::CCObject *)v53);
else
v41 = *((cocos2d::CCArray **)this + 86);
if ( v41 )
{
if ( (unsigned int)cocos2d::CCArray::count(v41) )
{
v47 = *((unsigned int **)v41 + 7);
if ( *v47 )
{
v48 = *((_QWORD *)v47 + 2);
v49 = 8LL * *v47 - 8;
for ( i = v48 + v49; i >= v48; v48 += 8LL )
{
if ( !*(_QWORD *)v48 )
break;
std::__tree::__emplace_unique_key_args(
&v52,
(int *)(*(_QWORD *)v48 + 1856LL),
(_DWORD *)(*(_QWORD *)v48 + 1856LL));
}
}
}
}
EditorUI::deselectAll(*(EditorUI **)(*((_QWORD *)this + 128) + 14248LL));
v42 = v52;
while ( v42 != v53 )
{
v43 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(
*(cocos2d::CCDictionary **)(*((_QWORD *)this + 128) + 13272LL),
*((int *)v42 + 7));
EditorUI::selectObjects(*(EditorUI **)(*((_QWORD *)this + 128) + 14248LL), v43, 0);
v44 = (__int64 *)v42[1];
if ( v44 )
{
do
{
v42 = v44;
v44 = (__int64 *)*v44;
}
while ( v44 );
}
else
{
do
{
v45 = v42;
v42 = (__int64 *)v42[2];
if ( v45 == (__int64 *)*v42 )
break;
v46 = v42;
v42 = (__int64 *)v42[2];
}
while ( v46 != (__int64 *)*v42 );
}
}
(*(void (__fastcall **)(SetupKeyframePopup *, _QWORD))(*(_QWORD *)this + 1368LL))(this, 0);
v51 = (void *)v53[0];
if ( v53[0] )
{
std::__tree::destroy((__int64)&v52, *(_QWORD **)v53[0]);
std::__tree::destroy((__int64)&v52, *(_QWORD **)&byte_8[(_QWORD)v51]);
operator delete(v51);
}
}
LABEL_9:
v6 = v56;
if ( v56 )
{
do
{
v7 = (_QWORD *)*v6;
operator delete(v6);
v6 = v7;
}
while ( v7 );
}
v8 = v54;
v54 = nullptr;
if ( v8 )
operator delete(v8);
return _stack_chk_guard;
}