//
// sub_100165F60 from 0x100165f60 to 0x1001662d4 (884 bytes)
//
// 31 xrefs:
// > GJGameState::processStateTriggers @ 0x10010e6d1
// > GJBaseGameLayer::stopSFXTrigger @ 0x1001369be
// > GJBaseGameLayer::update @ 0x100152bc1
// > GJBaseGameLayer::addProximityVolumeEffect @ 0x10015e7da
// > sub_10016EA00 @ 0x10016eabb
// > GJEffectManager::removeTriggeredID @ 0x1002e9736
// > cocos2d::CCSpriteFrameCache::removeSpriteFramesFromFile @ 0x10031d89f
// > cocos2d::extension::CCControl::removeHandleOfControlEvent @ 0x100352906
// > GameManager::unloadIcon @ 0x1003829e0
// > GameManager::unloadIcon @ 0x100382b16
// > GameManager::unloadIcons @ 0x100382ee6
// > FMODAudioEngine::updateChannelTweens @ 0x1003df85d
// > FMODAudioEngine::stopChannelTween @ 0x1003e31db
// > FMODAudioEngine::updateChannel @ 0x1003e613c
// > FMODAudioEngine::startMusic @ 0x1003e7789
// > FMODAudioEngine::startMusic @ 0x1003e7839
// > cocos2d::extension::CCScrollView::dCCScrollView @ 0x1003f7101
// > cocos2d::extension::CCScrollView::dCCScrollView @ 0x1003f7161
// > cocos2d::extension::CCScrollView::unregisterScriptHandler @ 0x1003f7226
// > cocos2d::extension::CCScrollView::registerScriptHandler @ 0x1003f93c8
// > cocos2d::extension::CCTableView::_moveCellOutOfSight @ 0x10042ce4e
// > cocos2d::extension::CCTableView::removeCellAtIndex @ 0x10042d2f8
// > cocos2d::CCFileUtils::removeFullPath @ 0x10043c77f
// > GameLevelManager::onUploadLevelListCompleted @ 0x10052ac77
// > GameLevelManager::onDeleteServerLevelListCompleted @ 0x10052ae67
// > SelectEventLayer::onCustomToggleTriggerValue @ 0x10057a516
// > EnterEffectInstance::animateValue @ 0x1005d3bee
// > EnterEffectInstance::updateTransitions @ 0x1005d3e9b
// > CustomSongWidget::loadSongInfoFinished @ 0x100620496
// > CustomSongWidget::loadSongInfoFailed @ 0x1006206d9
// > cocos2d::CCSet::removeObject @ 0x1007b393e
//
// 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
//
__int64 *__fastcall sub_100165F60(__int64 *a1, __int64 *a2)
{
__int64 v2; // rcx
__int64 *v3; // rdx
__int64 *v4; // rax
__int64 **v5; // r9
char v6; // r8
__int64 *result; // rax
char v8; // r9
_QWORD *v9; // r10
__int64 v10; // r10
__int64 v11; // r10
__int64 **v12; // rcx
__int64 *v13; // rdx
char v14; // si
__int64 *v15; // rdx
__int64 v16; // rsi
__int64 ***v17; // rsi
_QWORD *v18; // rcx
__int64 *v19; // rdx
__int64 *v20; // rsi
__int64 ***v21; // rsi
__int64 *v22; // rcx
_QWORD *v23; // rdx
char v24; // cl
__int64 *v25; // rcx
__int64 v26; // rdx
__int64 **v27; // rdx
__int64 *v28; // rcx
__int64 v29; // rdx
__int64 **v30; // rdx
__int64 v31; // rdx
__int64 **v32; // rdx
__int64 *v33; // rcx
__int64 v34; // rdx
__int64 **v35; // rdx
v2 = *a2;
v3 = a2;
if ( *a2 )
{
v4 = (__int64 *)a2[1];
v3 = a2;
if ( !v4 )
goto LABEL_5;
do
{
v3 = v4;
v4 = (__int64 *)*v4;
}
while ( v4 );
}
v2 = v3[1];
if ( v2 )
{
LABEL_5:
v5 = (__int64 **)v3[2];
*(_QWORD *)(v2 + 16) = v5;
v6 = 0;
result = *v5;
if ( *v5 != v3 )
goto LABEL_6;
goto LABEL_10;
}
v5 = (__int64 **)v3[2];
v6 = 1;
v2 = 0;
result = *v5;
if ( *v5 != v3 )
{
LABEL_6:
v5[1] = (__int64 *)v2;
v8 = *((_BYTE *)v3 + 24);
if ( v3 == a2 )
goto LABEL_7;
LABEL_14:
v9 = (_QWORD *)a2[2];
v3[2] = (__int64)v9;
v9[*v9 != (_QWORD)a2] = v3;
v10 = *a2;
*v3 = *a2;
*(_QWORD *)(v10 + 16) = v3;
v11 = a2[1];
v3[1] = v11;
if ( v11 )
*(_QWORD *)(v11 + 16) = v3;
*((_BYTE *)v3 + 24) = *((_BYTE *)a2 + 24);
if ( a1 == a2 )
a1 = v3;
if ( !a1 )
return result;
goto LABEL_19;
}
LABEL_10:
*v5 = (__int64 *)v2;
if ( v3 == a1 )
{
result = nullptr;
a1 = (__int64 *)v2;
v8 = *((_BYTE *)v3 + 24);
if ( v3 != a2 )
goto LABEL_14;
}
else
{
result = v5[1];
v8 = *((_BYTE *)v3 + 24);
if ( v3 != a2 )
goto LABEL_14;
}
LABEL_7:
if ( !a1 )
return result;
LABEL_19:
if ( !v8 )
return result;
if ( !v6 )
{
*(_BYTE *)(v2 + 24) = 1;
return result;
}
while ( 1 )
{
v12 = (__int64 **)result[2];
v13 = *v12;
v14 = *((_BYTE *)result + 24);
if ( *v12 == result )
break;
if ( !v14 )
{
*((_BYTE *)result + 24) = 1;
*((_BYTE *)v12 + 24) = 0;
v15 = v12[1];
v16 = *v15;
v12[1] = (__int64 *)*v15;
if ( v16 )
*(_QWORD *)(v16 + 16) = v12;
v17 = v12[2];
v15[2] = (__int64)v17;
v17[*v17 != (_QWORD)v12] = v15;
*v15 = (__int64)v12;
v12[2] = v15;
if ( a1 == (__int64 *)*result )
a1 = result;
result = *(__int64 **)(*result + 8);
}
v18 = (_QWORD *)*result;
if ( *result && *((_BYTE *)v18 + 24) != 1 )
{
v19 = (__int64 *)result[1];
if ( !v19 )
goto LABEL_52;
LABEL_51:
if ( *((_BYTE *)v19 + 24) == 1 )
{
LABEL_52:
*((_BYTE *)v18 + 24) = 1;
*((_BYTE *)result + 24) = 0;
v26 = v18[1];
*result = v26;
if ( v26 )
*(_QWORD *)(v26 + 16) = result;
v27 = (__int64 **)result[2];
v18[2] = v27;
v27[*v27 != result] = v18;
v18[1] = result;
result[2] = (__int64)v18;
v19 = result;
}
else
{
v18 = result;
}
result = (__int64 *)v18[2];
*((_BYTE *)v18 + 24) = *((_BYTE *)result + 24);
*((_BYTE *)result + 24) = 1;
*((_BYTE *)v19 + 24) = 1;
v28 = (__int64 *)result[1];
v29 = *v28;
result[1] = *v28;
if ( v29 )
*(_QWORD *)(v29 + 16) = result;
v30 = (__int64 **)result[2];
v28[2] = (__int64)v30;
v30[*v30 != result] = v28;
*v28 = (__int64)result;
result[2] = (__int64)v28;
return result;
}
v19 = (__int64 *)result[1];
if ( v19 && *((_BYTE *)v19 + 24) != 1 )
goto LABEL_51;
*((_BYTE *)result + 24) = 0;
result = (__int64 *)result[2];
if ( result == a1 || !*((_BYTE *)result + 24) )
goto LABEL_49;
LABEL_22:
result = *(__int64 **)(result[2] + 8LL * (*(_QWORD *)result[2] == (_QWORD)result));
}
if ( !v14 )
{
*((_BYTE *)result + 24) = 1;
*((_BYTE *)v12 + 24) = 0;
v20 = v13[1];
*v12 = (__int64 *)v20;
if ( v20 )
*(_QWORD *)(v20 + 16) = v12;
v21 = v12[2];
v13[2] = (__int64)v21;
v21[*v21 != (_QWORD)v12] = v13;
v13[1] = (__int64)v12;
v12[2] = v13;
v22 = (__int64 *)result[1];
if ( a1 == v22 )
a1 = result;
result = (__int64 *)*v22;
}
v23 = (_QWORD *)*result;
if ( *result )
{
v24 = *((_BYTE *)v23 + 24);
if ( v24 != 1 )
goto LABEL_61;
}
v25 = (__int64 *)result[1];
if ( !v25 || *((_BYTE *)v25 + 24) == 1 )
{
*((_BYTE *)result + 24) = 0;
result = (__int64 *)result[2];
if ( *((_BYTE *)result + 24) != 1 || result == a1 )
{
LABEL_49:
*((_BYTE *)result + 24) = 1;
return result;
}
goto LABEL_22;
}
if ( !v23 )
goto LABEL_63;
v24 = *((_BYTE *)v23 + 24);
LABEL_61:
if ( (v24 & 1) != 0 )
{
v25 = (__int64 *)result[1];
LABEL_63:
*((_BYTE *)v25 + 24) = 1;
*((_BYTE *)result + 24) = 0;
v31 = *v25;
result[1] = *v25;
if ( v31 )
*(_QWORD *)(v31 + 16) = result;
v32 = (__int64 **)result[2];
v25[2] = (__int64)v32;
v32[*v32 != result] = v25;
*v25 = (__int64)result;
result[2] = (__int64)v25;
v23 = result;
}
else
{
v25 = result;
}
result = (__int64 *)v25[2];
*((_BYTE *)v25 + 24) = *((_BYTE *)result + 24);
*((_BYTE *)result + 24) = 1;
*((_BYTE *)v23 + 24) = 1;
v33 = (__int64 *)*result;
v34 = *(_QWORD *)(*result + 8);
*result = v34;
if ( v34 )
*(_QWORD *)(v34 + 16) = result;
v35 = (__int64 **)result[2];
v33[2] = (__int64)v35;
v35[*v35 != result] = v33;
v33[1] = (__int64)result;
result[2] = (__int64)v33;
return result;
}