{"type": "func", "start": 5370045376, "end": 5370046183, "name": "GameLevelManager::updateLevelRewards", "pseudocode": "// \n// GameLevelManager::updateLevelRewards from 0x1401463c0 to 0x1401466e7 (807 bytes)\n// \n// 5 xrefs:\n// > GameLevelManager::saveFetchedLevels @ 0x140146b79\n// > GameLevelManager::onGetLevelSaveDataCompleted @ 0x14014f468\n// > GameLevelManager::processOnDownloadLevelCompleted @ 0x1401533c4\n// > GameLevelManager::processOnDownloadLevelCompleted @ 0x1401534dc\n// > <???> @ 0x1406ca5b4\n// \n// This function is hookable on this platform!\n// \n// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA\n// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings\n// \n\n// Hidden C++ exception states: #wind=6\nvoid GameLevelManager::updateLevelRewards(GameLevelManager *a1, GJGameLevel *a2)\n{\n  GameStatsManager *v3; // rcx\n  float v4; // xmm0_4\n  GameStatsManager *v5; // rcx\n  GameStatsManager *v6; // rcx\n  GameStatsManager *v7; // rsi\n  int i; // ebp\n  const char *CoinKey; // rbx\n  size_t v10; // r8\n  void *v11; // rcx\n  void *v12; // [rsp+20h] [rbp-48h]\n  void *v13; // [rsp+20h] [rbp-48h]\n  void *v14; // [rsp+20h] [rbp-48h]\n  void *v15; // [rsp+20h] [rbp-48h]\n  void *v16; // [rsp+20h] [rbp-48h]\n  __int128 v17; // [rsp+28h] [rbp-40h] BYREF\n  __int64 v18; // [rsp+38h] [rbp-30h]\n  unsigned __int64 v19; // [rsp+40h] [rbp-28h]\n\n  v3 = (GameStatsManager *)qword_1406C2EE8;\n  if ( !qword_1406C2EE8 )\n  {\n    v12 = operator new(0x3E0u);\n    qword_1406C2EE8 = sub_1401D0AE0(v12);\n    (*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);\n    v3 = (GameStatsManager *)qword_1406C2EE8;\n  }\n  if ( !GameStatsManager::hasCompletedLevel(v3, a2) )\n    goto LABEL_28;\n  a2->m_normalPercent.value = 100;\n  v4 = (float)((float)rand() / 32767.0) * 1000.0;\n  a2->m_normalPercent.seed = (int)v4;\n  a2->m_normalPercent.random = (int)v4 + 100;\n  if ( a2->m_demon.random - a2->m_demon.seed == 1 )\n  {\n    v5 = (GameStatsManager *)qword_1406C2EE8;\n    if ( !qword_1406C2EE8 )\n    {\n      v13 = operator new(0x3E0u);\n      qword_1406C2EE8 = sub_1401D0AE0(v13);\n      (*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);\n      v5 = (GameStatsManager *)qword_1406C2EE8;\n    }\n    GameStatsManager::completedDemonLevel(v5, a2);\n  }\n  if ( a2->m_stars.random - a2->m_stars.seed > 0 )\n  {\n    v6 = (GameStatsManager *)qword_1406C2EE8;\n    if ( !qword_1406C2EE8 )\n    {\n      v14 = operator new(0x3E0u);\n      qword_1406C2EE8 = sub_1401D0AE0(v14);\n      (*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);\n      v6 = (GameStatsManager *)qword_1406C2EE8;\n    }\n    GameStatsManager::completedStarLevel(v6, a2);\n  }\n  v7 = (GameStatsManager *)qword_1406C2EE8;\n  if ( !qword_1406C2EE8 )\n  {\n    v15 = operator new(0x3E0u);\n    qword_1406C2EE8 = sub_1401D0AE0(v15);\n    (*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);\n    v7 = (GameStatsManager *)qword_1406C2EE8;\n  }\n  if ( a2->m_coins > 0 && a2->m_coinsVerified.random - a2->m_coinsVerified.seed == 1 )\n  {\n    for ( i = 1; i <= 3; ++i )\n    {\n      CoinKey = GJGameLevel::getCoinKey(a2, i);\n      if ( GameStatsManager::hasPendingUserCoin(v7, CoinKey) )\n      {\n        if ( !GameStatsManager::hasUserCoin(v7, CoinKey) )\n        {\n          GameStatsManager::storeUserCoin(v7, CoinKey);\n          GameStatsManager::incrementStat(v7, \"12\", 1);\n        }\n        v17 = 0;\n        v18 = 0;\n        v19 = 0;\n        v10 = -1;\n        do\n          ++v10;\n        while ( CoinKey[v10] );\n        sub_14003A930(&v17, CoinKey, v10);\n        cocos2d::CCDictionary::removeObjectForKey(v7->m_pendingUserCoins, &v17);\n        if ( v19 > 0xF )\n        {\n          v11 = (void *)v17;\n          if ( v19 + 1 >= 0x1000 )\n          {\n            v11 = *(void **)(v17 - 8);\n            if ( (unsigned __int64)(v17 - (_QWORD)v11 - 8) > 0x1F )\n              invalid_parameter_noinfo_noreturn();\n          }\n          j_j_free(v11);\n        }\n        v18 = 0;\n        v19 = 15;\n        LOBYTE(v17) = 0;\n      }\n    }\nLABEL_28:\n    v7 = (GameStatsManager *)qword_1406C2EE8;\n  }\n  if ( a2->m_stars.random - a2->m_stars.seed > 0 )\n  {\n    if ( !v7 )\n    {\n      v16 = operator new(0x3E0u);\n      qword_1406C2EE8 = sub_1401D0AE0(v16);\n      (*(void (__fastcall **)(__int64))(*(_QWORD *)qword_1406C2EE8 + 72LL))(qword_1406C2EE8);\n      v7 = (GameStatsManager *)qword_1406C2EE8;\n    }\n    GameStatsManager::awardCurrencyForLevel(v7, a2);\n  }\n}", "assembly": "; \n; GameLevelManager::updateLevelRewards from 0x1401463c0 to 0x1401466e7 (807 bytes)\n; \n; 5 xrefs:\n; > GameLevelManager::saveFetchedLevels @ 0x140146b79\n; > GameLevelManager::onGetLevelSaveDataCompleted @ 0x14014f468\n; > GameLevelManager::processOnDownloadLevelCompleted @ 0x1401533c4\n; > GameLevelManager::processOnDownloadLevelCompleted @ 0x1401534dc\n; > <???> @ 0x1406ca5b4\n; \n; This function is hookable on this platform!\n; \n; Using BromaIDA 8.0.0 @ https:;github.com/Stazzical/BromaIDA\n; Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https:;github.com/geode-sdk/bindings\n; \n\nmov     [rsp+arg_0], rbx                                               ; +0x0, 0x1401463c0\nmov     [rsp+arg_10], rbp                                              ; +0x5, 0x1401463c5\npush    rsi                                                            ; +0xa, 0x1401463ca\npush    rdi                                                            ; +0xb, 0x1401463cb\npush    r14                                                            ; +0xc, 0x1401463cc\nsub     rsp, 50h                                                       ; +0xe, 0x1401463ce\nmov     rax, cs:__security_cookie                                      ; +0x12, 0x1401463d2\nxor     rax, rsp                                                       ; +0x19, 0x1401463d9\nmov     [rsp+68h+var_20], rax                                          ; +0x1c, 0x1401463dc\nmov     rdi, rdx                                                       ; +0x21, 0x1401463e1\nmov     rcx, cs:qword_1406C2EE8                                        ; +0x24, 0x1401463e4\ntest    rcx, rcx                                                       ; +0x2b, 0x1401463eb\njnz     short loc_14014641F                                            ; +0x2e, 0x1401463ee\nmov     ecx, 3E0h; Size                                                ; +0x30, 0x1401463f0\ncall    ??2@YAPEAX_K@Z; operator new(unsigned __int64)                 ; +0x35, 0x1401463f5\nmov     [rsp+68h+var_48], rax                                          ; +0x3a, 0x1401463fa\nmov     rcx, rax                                                       ; +0x3f, 0x1401463ff\ncall    sub_1401D0AE0                                                  ; +0x42, 0x140146402\nnop                                                                    ; +0x47, 0x140146407\nmov     cs:qword_1406C2EE8, rax                                        ; +0x48, 0x140146408\nmov     rdx, [rax]                                                     ; +0x4f, 0x14014640f\nmov     rcx, rax                                                       ; +0x52, 0x140146412\ncall    qword ptr [rdx+48h]                                            ; +0x55, 0x140146415\nmov     rcx, cs:qword_1406C2EE8                                        ; +0x58, 0x140146418\nmov     rdx, rdi                                                       ; +0x5f, 0x14014641f\ncall    GameStatsManager__hasCompletedLevel                            ; +0x62, 0x140146422\ntest    al, al                                                         ; +0x67, 0x140146427\njz      loc_140146666                                                  ; +0x69, 0x140146429\nmov     dword ptr [rdi+328h], 64h ; 'd'                                ; +0x6f, 0x14014642f\ncall    cs:rand                                                        ; +0x79, 0x140146439\nmovd    xmm0, eax                                                      ; +0x7f, 0x14014643f\ncvtdq2ps xmm0, xmm0                                                    ; +0x83, 0x140146443\ndivss   xmm0, cs:dword_140623644                                       ; +0x86, 0x140146446\nmulss   xmm0, cs:dword_14062350C                                       ; +0x8e, 0x14014644e\ncvttss2si eax, xmm0                                                    ; +0x96, 0x140146456\nmov     [rdi+32Ch], eax                                                ; +0x9a, 0x14014645a\nadd     eax, 64h ; 'd'                                                 ; +0xa0, 0x140146460\nmov     [rdi+330h], eax                                                ; +0xa3, 0x140146463\nmov     eax, [rdi+378h]                                                ; +0xa9, 0x140146469\nsub     eax, [rdi+37Ch]                                                ; +0xaf, 0x14014646f\ncmp     eax, 1                                                         ; +0xb5, 0x140146475\njnz     short loc_1401464BD                                            ; +0xb8, 0x140146478\nmov     rcx, cs:qword_1406C2EE8                                        ; +0xba, 0x14014647a\ntest    rcx, rcx                                                       ; +0xc1, 0x140146481\njnz     short loc_1401464B5                                            ; +0xc4, 0x140146484\nmov     ecx, 3E0h; Size                                                ; +0xc6, 0x140146486\ncall    ??2@YAPEAX_K@Z; operator new(unsigned __int64)                 ; +0xcb, 0x14014648b\nmov     [rsp+68h+var_48], rax                                          ; +0xd0, 0x140146490\nmov     rcx, rax                                                       ; +0xd5, 0x140146495\ncall    sub_1401D0AE0                                                  ; +0xd8, 0x140146498\nnop                                                                    ; +0xdd, 0x14014649d\nmov     cs:qword_1406C2EE8, rax                                        ; +0xde, 0x14014649e\nmov     rdx, [rax]                                                     ; +0xe5, 0x1401464a5\nmov     rcx, rax                                                       ; +0xe8, 0x1401464a8\ncall    qword ptr [rdx+48h]                                            ; +0xeb, 0x1401464ab\nmov     rcx, cs:qword_1406C2EE8                                        ; +0xee, 0x1401464ae\nmov     rdx, rdi                                                       ; +0xf5, 0x1401464b5\ncall    GameStatsManager__completedDemonLevel                          ; +0xf8, 0x1401464b8\nmov     eax, [rdi+388h]                                                ; +0xfd, 0x1401464bd\nsub     eax, [rdi+38Ch]                                                ; +0x103, 0x1401464c3\ntest    eax, eax                                                       ; +0x109, 0x1401464c9\njle     short loc_140146510                                            ; +0x10b, 0x1401464cb\nmov     rcx, cs:qword_1406C2EE8                                        ; +0x10d, 0x1401464cd\ntest    rcx, rcx                                                       ; +0x114, 0x1401464d4\njnz     short loc_140146508                                            ; +0x117, 0x1401464d7\nmov     ecx, 3E0h; Size                                                ; +0x119, 0x1401464d9\ncall    ??2@YAPEAX_K@Z; operator new(unsigned __int64)                 ; +0x11e, 0x1401464de\nmov     [rsp+68h+var_48], rax                                          ; +0x123, 0x1401464e3\nmov     rcx, rax                                                       ; +0x128, 0x1401464e8\ncall    sub_1401D0AE0                                                  ; +0x12b, 0x1401464eb\nnop                                                                    ; +0x130, 0x1401464f0\nmov     cs:qword_1406C2EE8, rax                                        ; +0x131, 0x1401464f1\nmov     rdx, [rax]                                                     ; +0x138, 0x1401464f8\nmov     rcx, rax                                                       ; +0x13b, 0x1401464fb\ncall    qword ptr [rdx+48h]                                            ; +0x13e, 0x1401464fe\nmov     rcx, cs:qword_1406C2EE8                                        ; +0x141, 0x140146501\nmov     rdx, rdi                                                       ; +0x148, 0x140146508\ncall    GameStatsManager__completedStarLevel                           ; +0x14b, 0x14014650b\nmov     rsi, cs:qword_1406C2EE8                                        ; +0x150, 0x140146510\ntest    rsi, rsi                                                       ; +0x157, 0x140146517\njnz     short loc_14014654B                                            ; +0x15a, 0x14014651a\nmov     ecx, 3E0h; Size                                                ; +0x15c, 0x14014651c\ncall    ??2@YAPEAX_K@Z; operator new(unsigned __int64)                 ; +0x161, 0x140146521\nmov     [rsp+68h+var_48], rax                                          ; +0x166, 0x140146526\nmov     rcx, rax                                                       ; +0x16b, 0x14014652b\ncall    sub_1401D0AE0                                                  ; +0x16e, 0x14014652e\nnop                                                                    ; +0x173, 0x140146533\nmov     cs:qword_1406C2EE8, rax                                        ; +0x174, 0x140146534\nmov     rdx, [rax]                                                     ; +0x17b, 0x14014653b\nmov     rcx, rax                                                       ; +0x17e, 0x14014653e\ncall    qword ptr [rdx+48h]                                            ; +0x181, 0x140146541\nmov     rsi, cs:qword_1406C2EE8                                        ; +0x184, 0x140146544\ncmp     dword ptr [rdi+398h], 0                                        ; +0x18b, 0x14014654b\njle     loc_14014666D                                                  ; +0x192, 0x140146552\nmov     eax, [rdi+39Ch]                                                ; +0x198, 0x140146558\nsub     eax, [rdi+3A0h]                                                ; +0x19e, 0x14014655e\ncmp     eax, 1                                                         ; +0x1a4, 0x140146564\njnz     loc_14014666D                                                  ; +0x1a7, 0x140146567\nmov     ebp, eax                                                       ; +0x1ad, 0x14014656d\nxor     r14d, r14d                                                     ; +0x1af, 0x14014656f\nmov     edx, ebp                                                       ; +0x1b2, 0x140146572\nmov     rcx, rdi                                                       ; +0x1b4, 0x140146574\ncall    GJGameLevel__getCoinKey                                        ; +0x1b7, 0x140146577\nmov     rbx, rax                                                       ; +0x1bc, 0x14014657c\nmov     rdx, rax                                                       ; +0x1bf, 0x14014657f\nmov     rcx, rsi                                                       ; +0x1c2, 0x140146582\ncall    GameStatsManager__hasPendingUserCoin                           ; +0x1c5, 0x140146585\ntest    al, al                                                         ; +0x1ca, 0x14014658a\njz      loc_14014665B                                                  ; +0x1cc, 0x14014658c\nmov     rdx, rbx                                                       ; +0x1d2, 0x140146592\nmov     rcx, rsi                                                       ; +0x1d5, 0x140146595\ncall    GameStatsManager__hasUserCoin                                  ; +0x1d8, 0x140146598\ntest    al, al                                                         ; +0x1dd, 0x14014659d\njnz     short loc_1401465C1                                            ; +0x1df, 0x14014659f\nmov     rdx, rbx                                                       ; +0x1e1, 0x1401465a1\nmov     rcx, rsi                                                       ; +0x1e4, 0x1401465a4\ncall    GameStatsManager__storeUserCoin                                ; +0x1e7, 0x1401465a7\nmov     r8d, 1                                                         ; +0x1ec, 0x1401465ac\nlea     rdx, a12; \"12\"                                                 ; +0x1f2, 0x1401465b2\nmov     rcx, rsi                                                       ; +0x1f9, 0x1401465b9\ncall    GameStatsManager__incrementStat                                ; +0x1fc, 0x1401465bc\nxorps   xmm0, xmm0                                                     ; +0x201, 0x1401465c1\nmovups  [rsp+68h+var_40], xmm0                                         ; +0x204, 0x1401465c4\nmov     [rsp+68h+var_30], r14                                          ; +0x209, 0x1401465c9\nmov     [rsp+68h+var_28], r14                                          ; +0x20e, 0x1401465ce\nmov     r8, 0FFFFFFFFFFFFFFFFh                                         ; +0x213, 0x1401465d3\nnop     word ptr [rax+rax+00h]                                         ; +0x21a, 0x1401465da\ninc     r8                                                             ; +0x220, 0x1401465e0\ncmp     byte ptr [rbx+r8], 0                                           ; +0x223, 0x1401465e3\njnz     short loc_1401465E0                                            ; +0x228, 0x1401465e8\nmov     rdx, rbx                                                       ; +0x22a, 0x1401465ea\nlea     rcx, [rsp+68h+var_40]                                          ; +0x22d, 0x1401465ed\ncall    sub_14003A930                                                  ; +0x232, 0x1401465f2\nnop                                                                    ; +0x237, 0x1401465f7\nlea     rdx, [rsp+68h+var_40]                                          ; +0x238, 0x1401465f8\nmov     rcx, [rsi+2D8h]                                                ; +0x23d, 0x1401465fd\ncall    cs:?removeObjectForKey@CCDictionary@cocos2d@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z; cocos2d::CCDictionary::removeObjectForKey(std::string const &) ; +0x244, 0x140146604\nnop                                                                    ; +0x24a, 0x14014660a\nmov     rdx, [rsp+68h+var_28]                                          ; +0x24b, 0x14014660b\ncmp     rdx, 0Fh                                                       ; +0x250, 0x140146610\njbe     short loc_140146648                                            ; +0x254, 0x140146614\ninc     rdx                                                            ; +0x256, 0x140146616\nmov     rcx, qword ptr [rsp+68h+var_40]                                ; +0x259, 0x140146619\nmov     rax, rcx                                                       ; +0x25e, 0x14014661e\ncmp     rdx, 1000h                                                     ; +0x261, 0x140146621\njb      short loc_140146643                                            ; +0x268, 0x140146628\nadd     rdx, 27h ; '''                                                 ; +0x26a, 0x14014662a\nmov     rcx, [rcx-8]; Block                                            ; +0x26e, 0x14014662e\nsub     rax, rcx                                                       ; +0x272, 0x140146632\nadd     rax, 0FFFFFFFFFFFFFFF8h                                        ; +0x275, 0x140146635\ncmp     rax, 1Fh                                                       ; +0x279, 0x140146639\nja      loc_1401466E0                                                  ; +0x27d, 0x14014663d\ncall    j_j_free                                                       ; +0x283, 0x140146643\nmov     [rsp+68h+var_30], r14                                          ; +0x288, 0x140146648\nmov     [rsp+68h+var_28], 0Fh                                          ; +0x28d, 0x14014664d\nmov     byte ptr [rsp+68h+var_40], 0                                   ; +0x296, 0x140146656\ninc     ebp                                                            ; +0x29b, 0x14014665b\ncmp     ebp, 3                                                         ; +0x29d, 0x14014665d\njle     loc_140146572                                                  ; +0x2a0, 0x140146660\nmov     rsi, cs:qword_1406C2EE8                                        ; +0x2a6, 0x140146666\nmov     eax, [rdi+388h]                                                ; +0x2ad, 0x14014666d\nsub     eax, [rdi+38Ch]                                                ; +0x2b3, 0x140146673\ntest    eax, eax                                                       ; +0x2b9, 0x140146679\njle     short loc_1401466BD                                            ; +0x2bb, 0x14014667b\ntest    rsi, rsi                                                       ; +0x2bd, 0x14014667d\njnz     short loc_1401466B2                                            ; +0x2c0, 0x140146680\nmov     ecx, 3E0h; Size                                                ; +0x2c2, 0x140146682\ncall    ??2@YAPEAX_K@Z; operator new(unsigned __int64)                 ; +0x2c7, 0x140146687\nmov     [rsp+68h+var_48], rax                                          ; +0x2cc, 0x14014668c\nmov     rcx, rax                                                       ; +0x2d1, 0x140146691\ncall    sub_1401D0AE0                                                  ; +0x2d4, 0x140146694\nnop                                                                    ; +0x2d9, 0x140146699\nmov     cs:qword_1406C2EE8, rax                                        ; +0x2da, 0x14014669a\nmov     r8, [rax]                                                      ; +0x2e1, 0x1401466a1\nmov     rcx, rax                                                       ; +0x2e4, 0x1401466a4\ncall    qword ptr [r8+48h]                                             ; +0x2e7, 0x1401466a7\nmov     rsi, cs:qword_1406C2EE8                                        ; +0x2eb, 0x1401466ab\nmov     rdx, rdi                                                       ; +0x2f2, 0x1401466b2\nmov     rcx, rsi                                                       ; +0x2f5, 0x1401466b5\ncall    GameStatsManager__awardCurrencyForLevel                        ; +0x2f8, 0x1401466b8\nmov     rcx, [rsp+68h+var_20]                                          ; +0x2fd, 0x1401466bd\nxor     rcx, rsp; StackCookie                                          ; +0x302, 0x1401466c2\ncall    __security_check_cookie                                        ; +0x305, 0x1401466c5\nmov     rbx, [rsp+68h+arg_0]                                           ; +0x30a, 0x1401466ca\nmov     rbp, [rsp+68h+arg_10]                                          ; +0x30f, 0x1401466cf\nadd     rsp, 50h                                                       ; +0x317, 0x1401466d7\npop     r14                                                            ; +0x31b, 0x1401466db\npop     rdi                                                            ; +0x31d, 0x1401466dd\npop     rsi                                                            ; +0x31e, 0x1401466de\nretn                                                                   ; +0x31f, 0x1401466df\ncall    cs:_invalid_parameter_noinfo_noreturn                          ; +0x320, 0x1401466e0\ndb 0CCh                                                                ; +0x326, 0x1401466e6", "xrefs": ["GameLevelManager::saveFetchedLevels @ 0x140146b79", "GameLevelManager::onGetLevelSaveDataCompleted @ 0x14014f468", "GameLevelManager::processOnDownloadLevelCompleted @ 0x1401533c4", "GameLevelManager::processOnDownloadLevelCompleted @ 0x1401534dc", "<???> @ 0x1406ca5b4"], "is_objc": false, "is_arm32": false, "is_arm64": false, "bida_info": "8.0.0 @ https://github.com/Stazzical/BromaIDA", "bindings_info": "commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings"}