//
// GJChallengeItem::createFromString from 0x1401f4790 to 0x1401f49eb (603 bytes)
//
// 2 xrefs:
// > GameLevelManager::onGetGJChallengesCompleted @ 0x14016850e
// > ??> @ 0x1406cc7a4
//
// 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=2
__int64 __fastcall GJChallengeItem::createFromString(__int64 *a1)
{
cocos2d::CCArray *v2; // rbx
cocos2d::CCString *v4; // rax
int v5; // r12d
cocos2d::CCString *v6; // rax
int v7; // r13d
cocos2d::CCString *v8; // rax
cocos2d::CCString *v9; // rax
cocos2d::CCString *v10; // rax
const char *CString; // rax
size_t v12; // r8
__int64 v13; // rdx
__int64 v14; // rcx
__int64 v15; // r8
__int64 v16; // r9
void **v17; // r14
char *v18; // rbp
unsigned __int64 v19; // r15
__int64 v20; // rbx
unsigned __int64 v21; // rsi
__int64 v22; // rbx
char *v23; // rax
int v24; // [rsp+30h] [rbp-88h]
int v25; // [rsp+34h] [rbp-84h]
__int128 v26; // [rsp+38h] [rbp-80h] BYREF
unsigned __int64 v27; // [rsp+48h] [rbp-70h]
__int64 v28; // [rsp+50h] [rbp-68h]
__int64 *v29; // [rsp+60h] [rbp-58h]
void *Src[2]; // [rsp+68h] [rbp-50h] BYREF
unsigned __int64 v31; // [rsp+78h] [rbp-40h]
unsigned __int64 v32; // [rsp+80h] [rbp-38h]
v29 = a1;
v2 = sub_140140F70(a1, ",");
if ( cocos2d::CCArray::count(v2) >= 5 )
{
v4 = cocos2d::CCArray::stringAtIndex(v2, 0);
v5 = cocos2d::CCString::intValue(v4);
v6 = cocos2d::CCArray::stringAtIndex(v2, 1u);
v7 = cocos2d::CCString::intValue(v6);
v8 = cocos2d::CCArray::stringAtIndex(v2, 2u);
v25 = cocos2d::CCString::intValue(v8);
v9 = cocos2d::CCArray::stringAtIndex(v2, 3u);
v24 = cocos2d::CCString::intValue(v9);
v10 = cocos2d::CCArray::stringAtIndex(v2, 4u);
CString = cocos2d::CCString::getCString(v10);
*(_OWORD *)Src = 0;
v31 = 0;
v32 = 0;
v12 = -1;
do
++v12;
while ( CString[v12] );
sub_14003A930(Src, CString, v12);
v26 = 0;
v27 = 0;
v28 = 0;
v17 = Src;
v18 = (char *)Src[0];
v19 = v32;
if ( v32 > 0xF )
v17 = (void **)Src[0];
v20 = 0x7FFFFFFFFFFFFFFFLL;
v21 = v31;
if ( v31 > 0x7FFFFFFFFFFFFFFFLL )
sub_140007B50(v14, v13, v15, v16);
v28 = 15;
if ( v31 > 0xF )
{
if ( (v31 | 0xF) <= 0x7FFFFFFFFFFFFFFFLL )
{
v20 = v31 | 0xF;
if ( (v31 | 0xF) < 0x16 )
v20 = 22;
}
*(_QWORD *)&v26 = sub_14003AA10(v20 + 1);
v27 = v21;
v28 = v20;
memcpy((void *)v26, v17, v21 + 1);
}
else
{
v27 = v31;
v26 = *(_OWORD *)v17;
}
v22 = GJChallengeItem::create(v7, v25, v24, v5, (__int64)&v26);
if ( v19 > 0xF )
{
v23 = v18;
if ( v19 + 1 >= 0x1000 )
{
v18 = *((char **)v18 - 1);
if ( (unsigned __int64)(v23 - v18 - 8) > 0x1F )
invalid_parameter_noinfo_noreturn();
}
j_j_free(v18);
}
sub_14003A830((__int64)a1);
return v22;
}
else
{
sub_14003A830((__int64)a1);
return 0;
}
}