//
// sub_1401F4E50 from 0x1401f4e50 to 0x1401f4f66 (278 bytes)
//
// 33 xrefs:
// > GameStatsManager::createSpecialChestItems @ 0x1401e99c5
// > GameStatsManager::createSpecialChestItems @ 0x1401e99e7
// > GameStatsManager::createSpecialChestItems @ 0x1401e9a09
// > GameStatsManager::createSpecialChestItems @ 0x1401e9a2b
// > GameStatsManager::createSpecialChestItems @ 0x1401e9a4d
// > GameStatsManager::createSpecialChestItems @ 0x1401e9a6f
// > GameStatsManager::createSpecialChestItems @ 0x1401e9a91
// > GameStatsManager::createSpecialChestItems @ 0x1401e9ab3
// > GameStatsManager::createSpecialChestItems @ 0x1401e9ad5
// > GameStatsManager::createSpecialChestItems @ 0x1401e9af7
// > GameStatsManager::createSpecialChestItems @ 0x1401e9b19
// > GameStatsManager::createSpecialChestItems @ 0x1401e9b3b
// > GameStatsManager::createSpecialChestItems @ 0x1401e9b5d
// > GameStatsManager::createSpecialChestItems @ 0x1401e9b7f
// > GameStatsManager::createSpecialChestItems @ 0x1401e9ba1
// > GameStatsManager::createSpecialChestItems @ 0x1401e9bc3
// > GameStatsManager::createSpecialChestItems @ 0x1401e9be5
// > GameStatsManager::createSpecialChestItems @ 0x1401e9c07
// > GameStatsManager::createSpecialChestItems @ 0x1401e9c29
// > GameStatsManager::createSpecialChestItems @ 0x1401e9c4b
// > GameStatsManager::createSpecialChestItems @ 0x1401e9c6d
// > GameStatsManager::createSpecialChestItems @ 0x1401e9c8f
// > GameStatsManager::createSpecialChestItems @ 0x1401e9cb1
// > GameStatsManager::createSpecialChestItems @ 0x1401e9cd3
// > GameStatsManager::createSpecialChestItems @ 0x1401e9cf5
// > GameStatsManager::createSpecialChestItems @ 0x1401e9d17
// > GameStatsManager::createSpecialChestItems @ 0x1401e9d39
// > GameStatsManager::createSpecialChestItems @ 0x1401e9d5b
// > GameStatsManager::createSpecialChestItems @ 0x1401e9d7d
// > GameStatsManager::createSpecialChestItems @ 0x1401e9d9f
// > GameStatsManager::createSpecialChestItems @ 0x1401e9dc1
// > GameStatsManager::createSpecialChestItems @ 0x1401e9de3
// > ??> @ 0x1406cc810
//
// 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
//
// Hidden C++ exception states: #wind=1
__int64 __fastcall sub_1401F4E50(unsigned __int64 a1, __int64 a2, int *a3)
{
__int64 *v5; // rsi
__int64 v6; // r9
__int64 v7; // rax
int v8; // r10d
char v9; // al
__int64 v10; // rbx
_QWORD *v11; // rax
__int128 v13; // [rsp+20h] [rbp-38h] BYREF
__int128 v14; // [rsp+30h] [rbp-28h]
v5 = (__int64 *)a1;
v6 = *(_QWORD *)a1;
v7 = *(_QWORD *)(*(_QWORD *)a1 + 8LL);
*(_QWORD *)&v14 = v7;
DWORD2(v14) = 0;
if ( !*(_BYTE *)(v7 + 25) )
{
v8 = *a3;
do
{
*(_QWORD *)&v14 = v7;
if ( *(_DWORD *)(v7 + 28) < v8
|| *(_DWORD *)(v7 + 28) <= v8 && (a1 = (unsigned int)a3[1], *(_DWORD *)(v7 + 32) < (int)a1) )
{
DWORD2(v14) = 0;
v7 = *(_QWORD *)(v7 + 16);
}
else
{
DWORD2(v14) = 1;
v6 = v7;
v7 = *(_QWORD *)v7;
}
}
while ( !*(_BYTE *)(v7 + 25) );
}
if ( *(_BYTE *)(v6 + 25) || *a3 < *(_DWORD *)(v6 + 28) || *a3 <= *(_DWORD *)(v6 + 28) && a3[1] < *(_DWORD *)(v6 + 32) )
{
if ( v5[1] == 0x666666666666666LL )
sub_140052E40(a1, 0, a3);
v10 = *v5;
v13 = (unsigned __int64)v5;
v11 = operator new(0x28u);
*(_QWORD *)((char *)v11 + 28) = *(_QWORD *)a3;
*v11 = v10;
v11[1] = v10;
v11[2] = v10;
*((_WORD *)v11 + 12) = 0;
v13 = v14;
v6 = sub_1400636D0(v5, (__int64)&v13, (__int64)v11);
v9 = 1;
}
else
{
v9 = 0;
}
*(_QWORD *)a2 = v6;
*(_BYTE *)(a2 + 8) = v9;
return a2;
}