//
// GJBaseGameLayer::generatePickupAnimRandVal from 0x886e14 to 0x8872a4 (1168 bytes)
//
// 2 xrefs:
// > GameObject::playDestroyObjectAnim @ 0x9b30a0
// > ??> @ 0x98340
//
// 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 GJBaseGameLayer::generatePickupAnimRandVal(GJBaseGameLayer *a1, GameObject *a2, float *a3, float *a4)
{
float *v7; // x21
const cocos2d::CCPoint *v8; // x19
std::_rb_tree_base *p_m_header; // x26
const cocos2d::CCPoint *v10; // x0
std::_rb_tree_base *m_parent; // x2
int x; // w19
int y; // w25
std::_rb_tree_base *v14; // x3
std::_rb_tree_base *v15; // x0
int v16; // w1
int v17; // w0
std::map,std::pair> *p_m_destroyObjectValues; // x24
__int64 v19; // x27
float v20; // s8
int v21; // w0
std::_rb_tree_base *v22; // x3
float v23; // s9
int v24; // w0
int v25; // w0
_DWORD *v26; // x28
__int64 insert_hint_unique_pos; // x0
__int64 v28; // x1
_DWORD *v29; // x3
__int64 v30; // x2
int v31; // w3
_BOOL8 v32; // x0
int v33; // w1
float *v34; // x1
__int64 v35; // x27
__int64 v36; // x0
__int64 v37; // x1
__int64 v38; // x3
__int64 v39; // x2
int v40; // w3
_BOOL8 v41; // x0
int v42; // w1
__int64 v43; // x20
__int64 v44; // x0
__int64 v45; // x1
__int64 v46; // x3
__int64 v47; // x2
int v48; // w3
_BOOL8 v49; // x0
int v50; // w1
float *p_m_isblack; // x3
std::_rb_tree_base *v52; // x0
int v53; // w1
int v54; // w0
int v55; // w0
int v56; // w0
void *v57; // x0
void *v58; // x0
void *v59; // x0
__int64 v61; // [xsp+78h] [xbp+78h]
__int64 v62; // [xsp+78h] [xbp+78h]
v7 = &a1->m_varianceValues.__elems_[1975];
v8 = a2->getPosition(a2);
p_m_header = &a1->m_destroyObjectValues.m_header;
v10 = a2->getPosition(a2);
m_parent = a1->m_destroyObjectValues.m_header.m_parent;
x = (int)v8->x;
y = (int)v10->y;
if ( !m_parent )
goto LABEL_9;
v14 = (std::_rb_tree_base *)(v7 + 28);
v15 = a1->m_destroyObjectValues.m_header.m_parent;
do
{
while ( 1 )
{
v16 = *(_DWORD *)&v15[1].m_isblack;
if ( x > v16 || x >= v16 && y > *((_DWORD *)&v15[1].m_isblack + 1) )
break;
v14 = v15;
v15 = v15->m_left;
if ( !v15 )
goto LABEL_7;
}
v15 = v15->m_right;
}
while ( v15 );
LABEL_7:
if ( p_m_header == v14
|| (v17 = *(_DWORD *)&v14[1].m_isblack, x < v17)
|| x <= v17 && y < *((_DWORD *)&v14[1].m_isblack + 1) )
{
LABEL_9:
p_m_destroyObjectValues = &a1->m_destroyObjectValues;
v19 = (__int64)(v7 + 28);
v20 = (float)((float)((float)rand() * 4.6566e-10) * 2.0) + -1.0;
v21 = rand();
m_parent = a1->m_destroyObjectValues.m_header.m_parent;
v22 = m_parent;
v23 = (float)v21 * 4.6566e-10;
if ( !m_parent )
goto LABEL_16;
do
{
while ( 1 )
{
v24 = *(_DWORD *)&v22[1].m_isblack;
if ( x > v24 || x >= v24 && y > *((_DWORD *)&v22[1].m_isblack + 1) )
break;
v19 = (__int64)v22;
v22 = v22->m_left;
if ( !v22 )
goto LABEL_14;
}
v22 = v22->m_right;
}
while ( v22 );
LABEL_14:
if ( p_m_header == (std::_rb_tree_base *)v19
|| (v25 = *(_DWORD *)(v19 + 32), x < v25)
|| x <= v25 && y < *(_DWORD *)(v19 + 36) )
{
LABEL_16:
v26 = (_DWORD *)operator new(0x30u);
v26[8] = x;
v26[9] = y;
v26[10] = 0;
v26[11] = 0;
insert_hint_unique_pos = std::_Rb_tree,std::pair const,std::pair>,std::_Select1st const,std::pair>>,std::less>,std::allocator const,std::pair>>>::_M_get_insert_hint_unique_pos(
(_QWORD *)v7 + 13,
v19,
v26 + 8);
v29 = (_DWORD *)insert_hint_unique_pos;
v30 = v28;
if ( v28 )
{
if ( insert_hint_unique_pos || p_m_header == (std::_rb_tree_base *)v28 )
{
v32 = 1;
}
else
{
v31 = v26[8];
v32 = 1;
v33 = *(_DWORD *)(v28 + 32);
if ( v31 >= v33 )
{
v32 = 0;
if ( v31 <= v33 )
v32 = v26[9] < *(_DWORD *)(v30 + 36);
}
}
sub_CFAD74(v32, v26, v30, v7 + 28);
++a1->m_destroyObjectValues.m_nodecount;
}
else
{
v59 = v26;
v26 = v29;
operator delete(v59);
}
m_parent = a1->m_destroyObjectValues.m_header.m_parent;
*((float *)v26 + 10) = v20;
*((float *)v26 + 11) = v23;
if ( !m_parent )
{
v34 = v7 + 28;
goto LABEL_25;
}
}
else
{
*(float *)(v19 + 40) = v20;
*(float *)(v19 + 44) = v23;
}
}
else
{
p_m_destroyObjectValues = &a1->m_destroyObjectValues;
}
p_m_isblack = v7 + 28;
v52 = m_parent;
do
{
while ( 1 )
{
v53 = *(_DWORD *)&v52[1].m_isblack;
if ( x > v53 || x >= v53 && y > *((_DWORD *)&v52[1].m_isblack + 1) )
break;
p_m_isblack = (float *)&v52->m_isblack;
v52 = v52->m_left;
if ( !v52 )
goto LABEL_50;
}
v52 = v52->m_right;
}
while ( v52 );
LABEL_50:
v34 = p_m_isblack;
if ( p_m_header != (std::_rb_tree_base *)p_m_isblack )
{
v54 = *((_DWORD *)p_m_isblack + 8);
if ( x >= v54 && (x > v54 || y >= *((_DWORD *)p_m_isblack + 9)) )
{
*a3 = p_m_isblack[10];
goto LABEL_55;
}
}
LABEL_25:
v61 = (__int64)v34;
v35 = operator new(0x30u);
*(_DWORD *)(v35 + 32) = x;
*(_DWORD *)(v35 + 36) = y;
*(_DWORD *)(v35 + 40) = 0;
*(_DWORD *)(v35 + 44) = 0;
v36 = std::_Rb_tree,std::pair const,std::pair>,std::_Select1st const,std::pair>>,std::less>,std::allocator const,std::pair>>>::_M_get_insert_hint_unique_pos(
p_m_destroyObjectValues,
v61,
(_DWORD *)(v35 + 32));
v38 = v36;
v39 = v37;
if ( v37 )
{
if ( v36 || p_m_header == (std::_rb_tree_base *)v37 )
{
v41 = 1;
}
else
{
v40 = *(_DWORD *)(v35 + 32);
v41 = 1;
v42 = *(_DWORD *)(v37 + 32);
if ( v40 >= v42 )
{
v41 = 0;
if ( v40 <= v42 )
v41 = *(_DWORD *)(v35 + 36) < *(_DWORD *)(v39 + 36);
}
}
sub_CFAD74(v41, v35, v39, v7 + 28);
++a1->m_destroyObjectValues.m_nodecount;
}
else
{
v58 = (void *)v35;
v35 = v38;
operator delete(v58);
}
m_parent = a1->m_destroyObjectValues.m_header.m_parent;
*a3 = *(float *)(v35 + 40);
if ( !m_parent )
{
v43 = (__int64)(v7 + 28);
LABEL_32:
v62 = v43;
v43 = operator new(0x30u);
*(_DWORD *)(v43 + 32) = x;
*(_DWORD *)(v43 + 36) = y;
*(_DWORD *)(v43 + 40) = 0;
*(_DWORD *)(v43 + 44) = 0;
v44 = std::_Rb_tree,std::pair const,std::pair>,std::_Select1st const,std::pair>>,std::less>,std::allocator const,std::pair>>>::_M_get_insert_hint_unique_pos(
p_m_destroyObjectValues,
v62,
(_DWORD *)(v43 + 32));
v46 = v44;
v47 = v45;
if ( v45 )
{
if ( v44 || p_m_header == (std::_rb_tree_base *)v45 )
{
v49 = 1;
}
else
{
v48 = *(_DWORD *)(v43 + 32);
v49 = 1;
v50 = *(_DWORD *)(v45 + 32);
if ( v48 >= v50 )
{
v49 = 0;
if ( v48 <= v50 )
v49 = *(_DWORD *)(v43 + 36) < *(_DWORD *)(v47 + 36);
}
}
sub_CFAD74(v49, v43, v47, v7 + 28);
++*((_QWORD *)v7 + 18);
}
else
{
v57 = (void *)v43;
v43 = v46;
operator delete(v57);
}
goto LABEL_39;
}
LABEL_55:
v43 = (__int64)(v7 + 28);
do
{
while ( 1 )
{
v55 = *(_DWORD *)&m_parent[1].m_isblack;
if ( x > v55 || x >= v55 && y > *((_DWORD *)&m_parent[1].m_isblack + 1) )
break;
v43 = (__int64)m_parent;
m_parent = m_parent->m_left;
if ( !m_parent )
goto LABEL_60;
}
m_parent = m_parent->m_right;
}
while ( m_parent );
LABEL_60:
if ( p_m_header == (std::_rb_tree_base *)v43 )
goto LABEL_32;
v56 = *(_DWORD *)(v43 + 32);
if ( x < v56 || x <= v56 && y < *(_DWORD *)(v43 + 36) )
goto LABEL_32;
LABEL_39:
*a4 = *(float *)(v43 + 44);
}