//
// sub_1402F9BA0 from 0x1402f9ba0 to 0x1402f9cc8 (296 bytes)
//
// 37 xrefs:
// > GameStatsManager::createSpecialChestItems @ 0x1402edc39
// > GameStatsManager::createSpecialChestItems @ 0x1402edc5b
// > GameStatsManager::createSpecialChestItems @ 0x1402edc7d
// > GameStatsManager::createSpecialChestItems @ 0x1402edc9f
// > GameStatsManager::createSpecialChestItems @ 0x1402edcc1
// > GameStatsManager::createSpecialChestItems @ 0x1402edce3
// > GameStatsManager::createSpecialChestItems @ 0x1402edd05
// > GameStatsManager::createSpecialChestItems @ 0x1402edd27
// > GameStatsManager::createSpecialChestItems @ 0x1402edd49
// > GameStatsManager::createSpecialChestItems @ 0x1402edd6b
// > GameStatsManager::createSpecialChestItems @ 0x1402edd8d
// > GameStatsManager::createSpecialChestItems @ 0x1402eddaf
// > GameStatsManager::createSpecialChestItems @ 0x1402eddd1
// > GameStatsManager::createSpecialChestItems @ 0x1402eddf3
// > GameStatsManager::createSpecialChestItems @ 0x1402ede15
// > GameStatsManager::createSpecialChestItems @ 0x1402ede37
// > GameStatsManager::createSpecialChestItems @ 0x1402ede59
// > GameStatsManager::createSpecialChestItems @ 0x1402ede7b
// > GameStatsManager::createSpecialChestItems @ 0x1402ede9d
// > GameStatsManager::createSpecialChestItems @ 0x1402edebf
// > GameStatsManager::createSpecialChestItems @ 0x1402edee1
// > GameStatsManager::createSpecialChestItems @ 0x1402edf03
// > GameStatsManager::createSpecialChestItems @ 0x1402edf25
// > GameStatsManager::createSpecialChestItems @ 0x1402edf47
// > GameStatsManager::createSpecialChestItems @ 0x1402edf69
// > GameStatsManager::createSpecialChestItems @ 0x1402edf8b
// > GameStatsManager::createSpecialChestItems @ 0x1402edfad
// > GameStatsManager::createSpecialChestItems @ 0x1402edfcf
// > GameStatsManager::createSpecialChestItems @ 0x1402edff1
// > GameStatsManager::createSpecialChestItems @ 0x1402ee013
// > GameStatsManager::createSpecialChestItems @ 0x1402ee035
// > GameStatsManager::createSpecialChestItems @ 0x1402ee057
// > GJBaseGameLayer::collisionCheckObjects @ 0x14031d0a7
// > GJBaseGameLayer::collisionCheckObjects @ 0x14031d19f
// > GJBaseGameLayer::playerTouchedTrigger @ 0x14031f84e
// > sub_14052CFE0 @ 0x14052d177
// > ??> @ 0x14091e284
//
// 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:30:05 +0000
//
// Hidden C++ exception states: #wind=1
__int64 __fastcall sub_1402F9BA0(__int64 *a1, __int64 a2, int *a3)
{
__int64 v4; // rdi
__int64 v6; // rbp
__int64 v7; // rbx
int v8; // eax
__int64 v9; // r9
int v10; // r10d
int v11; // eax
char v12; // al
__int64 *v13; // rax
__int128 v15; // [rsp+20h] [rbp-38h] BYREF
__int128 v16; // [rsp+30h] [rbp-28h]
v4 = a2;
v6 = *a1;
v7 = *(_QWORD *)(*a1 + 8);
v8 = 0;
v9 = *a1;
if ( !*(_BYTE *)(v7 + 25) )
{
v10 = *a3;
a2 = *(_QWORD *)(*a1 + 8);
do
{
v7 = a2;
if ( *(_DWORD *)(a2 + 28) < v10 || *(_DWORD *)(a2 + 28) <= v10 && *(_DWORD *)(a2 + 32) < a3[1] )
{
v8 = 0;
a2 += 16;
}
else
{
v8 = 1;
v9 = a2;
}
a2 = *(_QWORD *)a2;
}
while ( !*(_BYTE *)(a2 + 25) );
}
*(_QWORD *)&v16 = v7;
DWORD2(v16) = v8;
if ( *(_BYTE *)(v9 + 25) || (v11 = *(_DWORD *)(v9 + 28), *a3 < v11) || *a3 <= v11 && a3[1] < *(_DWORD *)(v9 + 32) )
{
if ( a1[1] == 0x666666666666666LL )
sub_14005BD90(a1, a2, a3);
v15 = (unsigned __int64)a1;
v13 = (__int64 *)operator new(0x28u);
*(__int64 *)((char *)v13 + 28) = *(_QWORD *)a3;
*v13 = v6;
v13[1] = v6;
v13[2] = v6;
*((_WORD *)v13 + 12) = 0;
v15 = v16;
v9 = sub_14006A770(a1, (__int64)&v15, (__int64)v13);
v12 = 1;
}
else
{
v12 = 0;
}
*(_QWORD *)v4 = v9;
*(_BYTE *)(v4 + 8) = v12;
return v4;
}