//
// sub_1003D0824 from 0x1003d0824 to 0x1003d0b08 (740 bytes)
//
// 3 xrefs:
// > sub_1000A79F0 @ 0x1000a7ad4
// > PlayLayer::levelComplete @ 0x100142ed8
// > PlayLayer::destroyPlayer @ 0x100147f04
//
// This function is hookable on this platform (idp: arm, 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:04:11 +0000
//
__int64 __fastcall sub_1003D0824(__int64 a1, __int64 a2)
{
int v4; // w25
unsigned int v5; // w24
int v6; // w26
int v7; // w22
bool v9; // w8
__int64 v10; // x23
__int64 v11; // x20
__int64 v12; // x8
unsigned int v13; // w27
char *v14; // x1
__int64 v15; // x0
int v16; // w20
int BaseCurrencyForLevel; // w0
unsigned int v18; // w8
float v19; // s1
unsigned int v20; // w9
int v21; // w10
void *v22; // x24
char *v23; // x1
__int64 v24; // x8
__int64 v25; // x22
char *v26; // x1
__int64 v27; // x0
int v28; // w21
void *v29; // x21
char *v30; // x1
void *v32[2]; // [xsp+8h] [xbp-98h] BYREF
char v33; // [xsp+1Fh] [xbp-81h]
void *__p[2]; // [xsp+20h] [xbp-80h] BYREF
char v35; // [xsp+37h] [xbp-69h]
void *v36[2]; // [xsp+38h] [xbp-68h] BYREF
char v37; // [xsp+4Fh] [xbp-51h]
v4 = *(_DWORD *)(a2 + 948) - *(_DWORD *)(a2 + 952);
v5 = *(_DWORD *)(a2 + 864) - *(_DWORD *)(a2 + 868);
v6 = *(_DWORD *)(a2 + 1140);
v7 = *(_DWORD *)(a2 + 920) - *(_DWORD *)(a2 + 924);
v9 = v4 < 1 || (int)v5 < 1;
if ( v7 <= 0 )
{
if ( !v9 )
{
v12 = 640;
if ( *(_BYTE *)(a2 + 649) )
v12 = 656;
if ( v6 == 1 )
v12 = 648;
v10 = *(_QWORD *)(a1 + v12);
goto LABEL_18;
}
return 0;
}
if ( v9 )
return 0;
v10 = *(_QWORD *)(a1 + 664);
if ( (GameStatsManager::isDailyRecall(a1, (unsigned int)(*(_DWORD *)(a2 + 920) - *(_DWORD *)(a2 + 924))) & 1) != 0 )
return 0;
LABEL_18:
if ( v5 >= 0x64 )
v13 = 100;
else
v13 = v5;
sub_1003D0444((_DWORD *)a2, v36);
if ( v37 >= 0 )
v14 = (char *)v36;
else
v14 = (char *)v36[0];
sub_100009900(__p, v14);
v15 = cocos2d::CCDictionary::valueForKey(v10, __p);
v16 = cocos2d::CCString::intValue(v15);
if ( v35 < 0 )
operator delete(__p[0]);
if ( v16 >= (int)v13 )
goto LABEL_52;
BaseCurrencyForLevel = GameStatsManager::getBaseCurrencyForLevel(a1, (_DWORD *)a2);
v18 = vcvtms_s32_f32((float)((float)v16 / 100.0) * (float)BaseCurrencyForLevel);
v19 = (float)((float)v13 / 100.0) * (float)BaseCurrencyForLevel;
v20 = vcvtms_s32_f32(v19);
v21 = (int)(float)((float)(int)floorf(v19) + (float)((float)BaseCurrencyForLevel * 0.25));
if ( v5 > 0x63 )
v20 = v21;
v11 = v20 - v18;
if ( (int)v11 < 1 )
{
LABEL_52:
v11 = 0;
}
else
{
v22 = sub_1003065B0("%i", v13);
if ( v37 >= 0 )
v23 = (char *)v36;
else
v23 = (char *)v36[0];
sub_100009900(__p, v23);
cocos2d::CCDictionary::setObject(v10, v22, __p);
if ( v35 < 0 )
operator delete(__p[0]);
if ( v6 != 1 )
{
v24 = 672;
if ( v7 > 0 )
v24 = 680;
v25 = *(_QWORD *)(a1 + v24);
sub_1003D0444((_DWORD *)a2, __p);
if ( v35 >= 0 )
v26 = (char *)__p;
else
v26 = (char *)__p[0];
sub_100009900(v32, v26);
v27 = cocos2d::CCDictionary::valueForKey(v25, v32);
v28 = cocos2d::CCString::intValue(v27);
if ( v33 < 0 )
operator delete(v32[0]);
if ( v28 < v4 )
{
v29 = sub_1003065B0("%i", v4);
v30 = v35 >= 0 ? (char *)__p : (char *)__p[0];
sub_100009900(v32, v30);
cocos2d::CCDictionary::setObject(v25, v29, v32);
if ( v33 < 0 )
operator delete(v32[0]);
}
if ( v35 < 0 )
operator delete(__p[0]);
}
GameStatsManager::incrementStat(a1, "14", v11);
}
if ( v37 < 0 )
operator delete(v36[0]);
return v11;
}