{"type": "func", "start": 5370691920, "end": 5370692683, "name": "GameStatsManager::getTotalCollectedDiamonds", "pseudocode": "// \n// GameStatsManager::getTotalCollectedDiamonds from 0x1401e4150 to 0x1401e444b (763 bytes)\n// \n// 2 xrefs:\n// > GameStatsManager::recountSpecialStats @ 0x1401e4553\n// > <???> @ 0x1406cc5d0\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=2\nint GameStatsManager::getTotalCollectedDiamonds(GameStatsManager *a1)\n{\n  int v2; // esi\n  cocos2d::CCDictionary *m_challengeDiamonds; // rcx\n  cocos2d::CCDictElement *m_pElements; // rcx\n  cocos2d::CCDictElement *i; // rbx\n  cocos2d::CCDictionary *m_completedLists; // rcx\n  cocos2d::CCDictElement *v7; // rcx\n  cocos2d::CCDictElement *j; // rbx\n  int k; // r12d\n  cocos2d::CCDictionary *m_timelyDiamondScores; // r13\n  cocos2d::CCDictionary *m_timelyStars; // rbx\n  cocos2d::CCArray *v12; // rbp\n  unsigned int m; // edi\n  cocos2d::CCString *v14; // rax\n  const char *CString; // rax\n  size_t v16; // r8\n  cocos2d::CCString *v17; // rax\n  int v18; // r14d\n  __int128 *v19; // rdx\n  size_t v20; // r8\n  cocos2d::CCString *v21; // rax\n  int v22; // ebx\n  void *v23; // rcx\n  int v24; // eax\n  void *v25; // rcx\n  cocos2d::CCDictionary *v27; // [rsp+20h] [rbp-88h]\n  __int128 v28; // [rsp+28h] [rbp-80h] BYREF\n  __int64 v29; // [rsp+38h] [rbp-70h]\n  unsigned __int64 v30; // [rsp+40h] [rbp-68h]\n  __int128 v31; // [rsp+48h] [rbp-60h] BYREF\n  __int64 v32; // [rsp+58h] [rbp-50h]\n  unsigned __int64 v33; // [rsp+60h] [rbp-48h]\n\n  v2 = 0;\n  m_challengeDiamonds = a1->m_challengeDiamonds;\n  if ( m_challengeDiamonds )\n  {\n    m_pElements = m_challengeDiamonds->m_pElements;\n    if ( m_pElements )\n    {\n      for ( i = (cocos2d::CCDictElement *)m_pElements->hh.next; ; i = (cocos2d::CCDictElement *)i->hh.next )\n      {\n        v2 += cocos2d::CCString::intValue((cocos2d::CCString *)m_pElements->m_pObject);\n        m_pElements = i;\n        if ( !i )\n          break;\n      }\n    }\n  }\n  m_completedLists = a1->m_completedLists;\n  if ( m_completedLists )\n  {\n    v7 = m_completedLists->m_pElements;\n    if ( v7 )\n    {\n      for ( j = (cocos2d::CCDictElement *)v7->hh.next; ; j = (cocos2d::CCDictElement *)j->hh.next )\n      {\n        v2 += cocos2d::CCString::intValue((cocos2d::CCString *)v7->m_pObject);\n        v7 = j;\n        if ( !j )\n          break;\n      }\n    }\n  }\n  for ( k = 0; k < 2; ++k )\n  {\n    if ( k )\n    {\n      m_timelyDiamondScores = a1->m_timelyDiamondScores;\n      m_timelyStars = a1->m_timelyStars;\n    }\n    else\n    {\n      m_timelyDiamondScores = a1->m_gauntletDiamondScores;\n      m_timelyStars = a1->m_onlineStars;\n    }\n    v27 = m_timelyStars;\n    v12 = cocos2d::CCDictionary::allKeys(m_timelyDiamondScores);\n    for ( m = 0; m < cocos2d::CCArray::count(v12); m_timelyStars = v27 )\n    {\n      v14 = cocos2d::CCArray::stringAtIndex(v12, m);\n      CString = cocos2d::CCString::getCString(v14);\n      v28 = 0;\n      v29 = 0;\n      v30 = 0;\n      v16 = -1;\n      do\n        ++v16;\n      while ( CString[v16] );\n      sub_14003A930(&v28, CString, v16);\n      v17 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(m_timelyDiamondScores, &v28);\n      v18 = cocos2d::CCString::intValue(v17);\n      v19 = &v28;\n      if ( v30 > 0xF )\n        v19 = (__int128 *)v28;\n      v31 = 0;\n      v32 = 0;\n      v33 = 0;\n      v20 = -1;\n      do\n        ++v20;\n      while ( *((_BYTE *)v19 + v20) );\n      sub_14003A930(&v31, v19, v20);\n      v21 = (cocos2d::CCString *)cocos2d::CCDictionary::valueForKey(m_timelyStars, &v31);\n      v22 = cocos2d::CCString::intValue(v21);\n      if ( v33 > 0xF )\n      {\n        v23 = (void *)v31;\n        if ( v33 + 1 >= 0x1000 )\n        {\n          v23 = *(void **)(v31 - 8);\n          if ( (unsigned __int64)(v31 - (_QWORD)v23 - 8) > 0x1F )\n            invalid_parameter_noinfo_noreturn();\n        }\n        j_j_free(v23);\n      }\n      if ( (unsigned int)(v22 - 2) > 8 )\n        v24 = 0;\n      else\n        v24 = v22 + 2;\n      v2 = (int)(float)(floorf((float)((float)v18 / 100.0) * (float)v24) + (float)v2);\n      if ( v30 > 0xF )\n      {\n        v25 = (void *)v28;\n        if ( v30 + 1 >= 0x1000 )\n        {\n          v25 = *(void **)(v28 - 8);\n          if ( (unsigned __int64)(v28 - (_QWORD)v25 - 8) > 0x1F )\n            invalid_parameter_noinfo_noreturn();\n        }\n        j_j_free(v25);\n      }\n      ++m;\n    }\n  }\n  return v2;\n}", "assembly": "; \n; GameStatsManager::getTotalCollectedDiamonds from 0x1401e4150 to 0x1401e444b (763 bytes)\n; \n; 2 xrefs:\n; > GameStatsManager::recountSpecialStats @ 0x1401e4553\n; > <???> @ 0x1406cc5d0\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_8], rbx                                               ; +0x0, 0x1401e4150\nmov     [rsp+arg_10], rbp                                              ; +0x5, 0x1401e4155\nmov     [rsp+arg_18], rsi                                              ; +0xa, 0x1401e415a\npush    rdi                                                            ; +0xf, 0x1401e415f\npush    r12                                                            ; +0x10, 0x1401e4160\npush    r13                                                            ; +0x12, 0x1401e4162\npush    r14                                                            ; +0x14, 0x1401e4164\npush    r15                                                            ; +0x16, 0x1401e4166\nsub     rsp, 80h                                                       ; +0x18, 0x1401e4168\nmovaps  [rsp+0A8h+var_38], xmm6                                        ; +0x1f, 0x1401e416f\nmov     rax, cs:__security_cookie                                      ; +0x24, 0x1401e4174\nxor     rax, rsp                                                       ; +0x2b, 0x1401e417b\nmov     [rsp+0A8h+var_40], rax                                         ; +0x2e, 0x1401e417e\nmov     r15, rcx                                                       ; +0x33, 0x1401e4183\nxor     r14d, r14d                                                     ; +0x36, 0x1401e4186\nmov     esi, r14d                                                      ; +0x39, 0x1401e4189\nmov     rcx, [rcx+330h]                                                ; +0x3c, 0x1401e418c\ntest    rcx, rcx                                                       ; +0x43, 0x1401e4193\njz      short loc_1401E41D0                                            ; +0x46, 0x1401e4196\nmov     rcx, [rcx+38h]                                                 ; +0x48, 0x1401e4198\ntest    rcx, rcx                                                       ; +0x4c, 0x1401e419c\njz      short loc_1401E41D0                                            ; +0x4f, 0x1401e419f\nmov     rbx, [rcx+120h]                                                ; +0x51, 0x1401e41a1\nnop     dword ptr [rax+rax+00000000h]                                  ; +0x58, 0x1401e41a8\nmov     rcx, [rcx+108h]                                                ; +0x60, 0x1401e41b0\ncall    cs:?intValue@CCString@cocos2d@@QEBAHXZ; cocos2d::CCString::intValue(void) ; +0x67, 0x1401e41b7\nadd     esi, eax                                                       ; +0x6d, 0x1401e41bd\nmov     rcx, rbx                                                       ; +0x6f, 0x1401e41bf\ntest    rbx, rbx                                                       ; +0x72, 0x1401e41c2\njz      short loc_1401E41D0                                            ; +0x75, 0x1401e41c5\nmov     rbx, [rbx+120h]                                                ; +0x77, 0x1401e41c7\njmp     short loc_1401E41B0                                            ; +0x7e, 0x1401e41ce\nmov     rcx, [r15+340h]                                                ; +0x80, 0x1401e41d0\ntest    rcx, rcx                                                       ; +0x87, 0x1401e41d7\njz      short loc_1401E4210                                            ; +0x8a, 0x1401e41da\nmov     rcx, [rcx+38h]                                                 ; +0x8c, 0x1401e41dc\ntest    rcx, rcx                                                       ; +0x90, 0x1401e41e0\njz      short loc_1401E4210                                            ; +0x93, 0x1401e41e3\nmov     rbx, [rcx+120h]                                                ; +0x95, 0x1401e41e5\nnop     dword ptr [rax+00h]                                            ; +0x9c, 0x1401e41ec\nmov     rcx, [rcx+108h]                                                ; +0xa0, 0x1401e41f0\ncall    cs:?intValue@CCString@cocos2d@@QEBAHXZ; cocos2d::CCString::intValue(void) ; +0xa7, 0x1401e41f7\nadd     esi, eax                                                       ; +0xad, 0x1401e41fd\nmov     rcx, rbx                                                       ; +0xaf, 0x1401e41ff\ntest    rbx, rbx                                                       ; +0xb2, 0x1401e4202\njz      short loc_1401E4210                                            ; +0xb5, 0x1401e4205\nmov     rbx, [rbx+120h]                                                ; +0xb7, 0x1401e4207\njmp     short loc_1401E41F0                                            ; +0xbe, 0x1401e420e\nmov     r12d, r14d                                                     ; +0xc0, 0x1401e4210\nmovss   xmm6, cs:dword_1406232BC                                       ; +0xc3, 0x1401e4213\nnop     dword ptr [rax+rax+00h]                                        ; +0xcb, 0x1401e421b\ntest    r12d, r12d                                                     ; +0xd0, 0x1401e4220\njnz     short loc_1401E4235                                            ; +0xd3, 0x1401e4223\nmov     r13, [r15+318h]                                                ; +0xd5, 0x1401e4225\nmov     rbx, [r15+308h]                                                ; +0xdc, 0x1401e422c\njmp     short loc_1401E4243                                            ; +0xe3, 0x1401e4233\nmov     r13, [r15+320h]                                                ; +0xe5, 0x1401e4235\nmov     rbx, [r15+310h]                                                ; +0xec, 0x1401e423c\nmov     [rsp+0A8h+var_88], rbx                                         ; +0xf3, 0x1401e4243\nmov     rcx, r13                                                       ; +0xf8, 0x1401e4248\ncall    cs:?allKeys@CCDictionary@cocos2d@@QEAAPEAVCCArray@2@XZ; cocos2d::CCDictionary::allKeys(void) ; +0xfb, 0x1401e424b\nmov     rbp, rax                                                       ; +0x101, 0x1401e4251\nmov     edi, r14d                                                      ; +0x104, 0x1401e4254\nmov     rcx, rax                                                       ; +0x107, 0x1401e4257\ncall    cs:?count@CCArray@cocos2d@@QEBAIXZ; cocos2d::CCArray::count(void) ; +0x10a, 0x1401e425a\ntest    eax, eax                                                       ; +0x110, 0x1401e4260\njz      loc_1401E43FB                                                  ; +0x112, 0x1401e4262\nnop     dword ptr [rax+rax+00000000h]                                  ; +0x118, 0x1401e4268\nmov     edx, edi                                                       ; +0x120, 0x1401e4270\nmov     rcx, rbp                                                       ; +0x122, 0x1401e4272\ncall    cs:?stringAtIndex@CCArray@cocos2d@@QEAAPEAVCCString@2@I@Z; cocos2d::CCArray::stringAtIndex(uint) ; +0x125, 0x1401e4275\nmov     rcx, rax                                                       ; +0x12b, 0x1401e427b\ncall    cs:?getCString@CCString@cocos2d@@QEBAPEBDXZ; cocos2d::CCString::getCString(void) ; +0x12e, 0x1401e427e\nxorps   xmm0, xmm0                                                     ; +0x134, 0x1401e4284\nmovups  [rsp+0A8h+var_80], xmm0                                        ; +0x137, 0x1401e4287\nmov     [rsp+0A8h+var_70], r14                                         ; +0x13c, 0x1401e428c\nmov     [rsp+0A8h+var_68], r14                                         ; +0x141, 0x1401e4291\nmov     r8, 0FFFFFFFFFFFFFFFFh                                         ; +0x146, 0x1401e4296\nnop     dword ptr [rax]                                                ; +0x14d, 0x1401e429d\ninc     r8                                                             ; +0x150, 0x1401e42a0\ncmp     byte ptr [rax+r8], 0                                           ; +0x153, 0x1401e42a3\njnz     short loc_1401E42A0                                            ; +0x158, 0x1401e42a8\nmov     rdx, rax                                                       ; +0x15a, 0x1401e42aa\nlea     rcx, [rsp+0A8h+var_80]                                         ; +0x15d, 0x1401e42ad\ncall    sub_14003A930                                                  ; +0x162, 0x1401e42b2\nnop                                                                    ; +0x167, 0x1401e42b7\nlea     rdx, [rsp+0A8h+var_80]                                         ; +0x168, 0x1401e42b8\nmov     rcx, r13                                                       ; +0x16d, 0x1401e42bd\ncall    cs:?valueForKey@CCDictionary@cocos2d@@QEAAPEBVCCString@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z; cocos2d::CCDictionary::valueForKey(std::string const &) ; +0x170, 0x1401e42c0\nmov     rcx, rax                                                       ; +0x176, 0x1401e42c6\ncall    cs:?intValue@CCString@cocos2d@@QEBAHXZ; cocos2d::CCString::intValue(void) ; +0x179, 0x1401e42c9\nmov     r14d, eax                                                      ; +0x17f, 0x1401e42cf\nlea     rdx, [rsp+0A8h+var_80]                                         ; +0x182, 0x1401e42d2\ncmp     [rsp+0A8h+var_68], 0Fh                                         ; +0x187, 0x1401e42d7\ncmova   rdx, qword ptr [rsp+0A8h+var_80]                               ; +0x18d, 0x1401e42dd\nxorps   xmm0, xmm0                                                     ; +0x193, 0x1401e42e3\nmovups  [rsp+0A8h+var_60], xmm0                                        ; +0x196, 0x1401e42e6\nxor     eax, eax                                                       ; +0x19b, 0x1401e42eb\nmov     [rsp+0A8h+var_50], rax                                         ; +0x19d, 0x1401e42ed\nmov     [rsp+0A8h+var_48], rax                                         ; +0x1a2, 0x1401e42f2\nmov     r8, 0FFFFFFFFFFFFFFFFh                                         ; +0x1a7, 0x1401e42f7\nxchg    ax, ax                                                         ; +0x1ae, 0x1401e42fe\ninc     r8                                                             ; +0x1b0, 0x1401e4300\ncmp     [rdx+r8], al                                                   ; +0x1b3, 0x1401e4303\njnz     short loc_1401E4300                                            ; +0x1b7, 0x1401e4307\nlea     rcx, [rsp+0A8h+var_60]                                         ; +0x1b9, 0x1401e4309\ncall    sub_14003A930                                                  ; +0x1be, 0x1401e430e\nnop                                                                    ; +0x1c3, 0x1401e4313\nlea     rdx, [rsp+0A8h+var_60]                                         ; +0x1c4, 0x1401e4314\nmov     rcx, rbx                                                       ; +0x1c9, 0x1401e4319\ncall    cs:?valueForKey@CCDictionary@cocos2d@@QEAAPEBVCCString@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z; cocos2d::CCDictionary::valueForKey(std::string const &) ; +0x1cc, 0x1401e431c\nmov     rcx, rax                                                       ; +0x1d2, 0x1401e4322\ncall    cs:?intValue@CCString@cocos2d@@QEBAHXZ; cocos2d::CCString::intValue(void) ; +0x1d5, 0x1401e4325\nmov     ebx, eax                                                       ; +0x1db, 0x1401e432b\nmov     rdx, [rsp+0A8h+var_48]                                         ; +0x1dd, 0x1401e432d\ncmp     rdx, 0Fh                                                       ; +0x1e2, 0x1401e4332\njbe     short loc_1401E436A                                            ; +0x1e6, 0x1401e4336\ninc     rdx                                                            ; +0x1e8, 0x1401e4338\nmov     rcx, qword ptr [rsp+0A8h+var_60]                               ; +0x1eb, 0x1401e433b\nmov     rax, rcx                                                       ; +0x1f0, 0x1401e4340\ncmp     rdx, 1000h                                                     ; +0x1f3, 0x1401e4343\njb      short loc_1401E4365                                            ; +0x1fa, 0x1401e434a\nadd     rdx, 27h ; '''                                                 ; +0x1fc, 0x1401e434c\nmov     rcx, [rcx-8]; Block                                            ; +0x200, 0x1401e4350\nsub     rax, rcx                                                       ; +0x204, 0x1401e4354\nadd     rax, 0FFFFFFFFFFFFFFF8h                                        ; +0x207, 0x1401e4357\ncmp     rax, 1Fh                                                       ; +0x20b, 0x1401e435b\nja      loc_1401E443D                                                  ; +0x20f, 0x1401e435f\ncall    j_j_free                                                       ; +0x215, 0x1401e4365\nlea     eax, [rbx-2]                                                   ; +0x21a, 0x1401e436a\ncmp     eax, 8                                                         ; +0x21d, 0x1401e436d\nja      short loc_1401E4377                                            ; +0x220, 0x1401e4370\nlea     eax, [rbx+2]                                                   ; +0x222, 0x1401e4372\njmp     short loc_1401E4379                                            ; +0x225, 0x1401e4375\nxor     eax, eax                                                       ; +0x227, 0x1401e4377\nmovd    xmm0, r14d                                                     ; +0x229, 0x1401e4379\ncvtdq2ps xmm0, xmm0                                                    ; +0x22e, 0x1401e437e\ndivss   xmm0, xmm6                                                     ; +0x231, 0x1401e4381\nmovd    xmm1, eax                                                      ; +0x235, 0x1401e4385\ncvtdq2ps xmm1, xmm1                                                    ; +0x239, 0x1401e4389\nmulss   xmm0, xmm1; X                                                  ; +0x23c, 0x1401e438c\ncall    floorf                                                         ; +0x240, 0x1401e4390\nmovd    xmm1, esi                                                      ; +0x245, 0x1401e4395\ncvtdq2ps xmm1, xmm1                                                    ; +0x249, 0x1401e4399\naddss   xmm0, xmm1                                                     ; +0x24c, 0x1401e439c\ncvttss2si esi, xmm0                                                    ; +0x250, 0x1401e43a0\nmov     rdx, [rsp+0A8h+var_68]                                         ; +0x254, 0x1401e43a4\ncmp     rdx, 0Fh                                                       ; +0x259, 0x1401e43a9\njbe     short loc_1401E43DD                                            ; +0x25d, 0x1401e43ad\ninc     rdx                                                            ; +0x25f, 0x1401e43af\nmov     rcx, qword ptr [rsp+0A8h+var_80]                               ; +0x262, 0x1401e43b2\nmov     rax, rcx                                                       ; +0x267, 0x1401e43b7\ncmp     rdx, 1000h                                                     ; +0x26a, 0x1401e43ba\njb      short loc_1401E43D8                                            ; +0x271, 0x1401e43c1\nadd     rdx, 27h ; '''                                                 ; +0x273, 0x1401e43c3\nmov     rcx, [rcx-8]; Block                                            ; +0x277, 0x1401e43c7\nsub     rax, rcx                                                       ; +0x27b, 0x1401e43cb\nadd     rax, 0FFFFFFFFFFFFFFF8h                                        ; +0x27e, 0x1401e43ce\ncmp     rax, 1Fh                                                       ; +0x282, 0x1401e43d2\nja      short loc_1401E4444                                            ; +0x286, 0x1401e43d6\ncall    j_j_free                                                       ; +0x288, 0x1401e43d8\ninc     edi                                                            ; +0x28d, 0x1401e43dd\nmov     rcx, rbp                                                       ; +0x28f, 0x1401e43df\ncall    cs:?count@CCArray@cocos2d@@QEBAIXZ; cocos2d::CCArray::count(void) ; +0x292, 0x1401e43e2\ncmp     edi, eax                                                       ; +0x298, 0x1401e43e8\nmov     rbx, [rsp+0A8h+var_88]                                         ; +0x29a, 0x1401e43ea\nmov     r14d, 0                                                        ; +0x29f, 0x1401e43ef\njb      loc_1401E4270                                                  ; +0x2a5, 0x1401e43f5\ninc     r12d                                                           ; +0x2ab, 0x1401e43fb\ncmp     r12d, 2                                                        ; +0x2ae, 0x1401e43fe\njl      loc_1401E4220                                                  ; +0x2b2, 0x1401e4402\nmov     eax, esi                                                       ; +0x2b8, 0x1401e4408\nmov     rcx, [rsp+0A8h+var_40]                                         ; +0x2ba, 0x1401e440a\nxor     rcx, rsp; StackCookie                                          ; +0x2bf, 0x1401e440f\ncall    __security_check_cookie                                        ; +0x2c2, 0x1401e4412\nlea     r11, [rsp+0A8h+var_28]                                         ; +0x2c7, 0x1401e4417\nmov     rbx, [r11+38h]                                                 ; +0x2cf, 0x1401e441f\nmov     rbp, [r11+40h]                                                 ; +0x2d3, 0x1401e4423\nmov     rsi, [r11+48h]                                                 ; +0x2d7, 0x1401e4427\nmovaps  xmm6, [rsp+0A8h+var_38]                                        ; +0x2db, 0x1401e442b\nmov     rsp, r11                                                       ; +0x2e0, 0x1401e4430\npop     r15                                                            ; +0x2e3, 0x1401e4433\npop     r14                                                            ; +0x2e5, 0x1401e4435\npop     r13                                                            ; +0x2e7, 0x1401e4437\npop     r12                                                            ; +0x2e9, 0x1401e4439\npop     rdi                                                            ; +0x2eb, 0x1401e443b\nretn                                                                   ; +0x2ec, 0x1401e443c\ncall    cs:_invalid_parameter_noinfo_noreturn                          ; +0x2ed, 0x1401e443d\nalign 4                                                                ; +0x2f3, 0x1401e4443\ncall    cs:_invalid_parameter_noinfo_noreturn                          ; +0x2f4, 0x1401e4444\ndb 0CCh                                                                ; +0x2fa, 0x1401e444a", "xrefs": ["GameStatsManager::recountSpecialStats @ 0x1401e4553", "<???> @ 0x1406cc5d0"], "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"}