{"type": "func", "start": 5372612240, "end": 5372612603, "name": "GJSmartTemplate::getRandomPrefab", "pseudocode": "// \n// GJSmartTemplate::getRandomPrefab from 0x1403b8e90 to 0x1403b8ffb (363 bytes)\n// \n// 5 xrefs:\n// > GJSmartTemplate::scanForPrefab @ 0x1403b8051\n// > GJSmartTemplate::getPrefab @ 0x1403b908f\n// > BrowseSmartTemplateLayer::addPrefabMenuItem @ 0x1405f007a\n// > <???> @ 0x140923d44\n// > <???> @ 0x140923d50\n// \n// This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!\n// \n// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA\n// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings\n// Generated at Fri, 27 Nov 2026 11:31:25 +0000\n// \n\n// Hidden C++ exception states: #wind=2\nstruct cocos2d::CCObject *__fastcall GJSmartTemplate::getRandomPrefab(__int64 a1, __int64 a2)\n{\n  cocos2d::CCArray *v4; // rdi\n  __int64 v5; // rax\n  int TotalChanceForPrefab; // ebx\n  int v7; // esi\n  float v8; // xmm6_4\n  unsigned int v9; // ebx\n  struct cocos2d::CCObject *v10; // rbp\n  struct cocos2d::CCObject *v12; // rbx\n  __int64 v13; // [rsp+20h] [rbp-88h]\n  __int64 v14; // [rsp+28h] [rbp-80h] BYREF\n  _BYTE v15[32]; // [rsp+48h] [rbp-60h] BYREF\n  __int64 v16; // [rsp+68h] [rbp-40h]\n\n  v16 = a2;\n  v13 = sub_14003F4F0((__int64)&v14, a2);\n  v4 = (cocos2d::CCArray *)cocos2d::CCDictionary::objectForKey(*(_QWORD *)(a1 + 56), v13);\n  sub_14003D310(v13);\n  if ( !v4 || !cocos2d::CCArray::count(v4) )\n    goto LABEL_8;\n  if ( cocos2d::CCArray::count(v4) <= 1 )\n  {\n    v12 = cocos2d::CCArray::objectAtIndex(v4, 0);\n    sub_14003D310(a2);\n    return v12;\n  }\n  v5 = sub_14003F4F0((__int64)v15, a2);\n  TotalChanceForPrefab = GJSmartTemplate::getTotalChanceForPrefab(a1, v5);\n  v7 = 0;\n  v8 = (float)((float)rand() / 32767.0) * (float)TotalChanceForPrefab;\n  v9 = 0;\n  if ( !cocos2d::CCArray::count(v4) )\n  {\nLABEL_8:\n    sub_14003D310(a2);\n    return nullptr;\n  }\n  while ( 1 )\n  {\n    v10 = cocos2d::CCArray::objectAtIndex(v4, v9);\n    v7 += *((_DWORD *)v10 + 31);\n    if ( (float)v7 >= v8 || v9 == cocos2d::CCArray::count(v4) - 1 )\n      break;\n    if ( ++v9 >= cocos2d::CCArray::count(v4) )\n      goto LABEL_8;\n  }\n  sub_14003D310(a2);\n  return v10;\n}", "assembly": "; \n; GJSmartTemplate::getRandomPrefab from 0x1403b8e90 to 0x1403b8ffb (363 bytes)\n; \n; 5 xrefs:\n; > GJSmartTemplate::scanForPrefab @ 0x1403b8051\n; > GJSmartTemplate::getPrefab @ 0x1403b908f\n; > BrowseSmartTemplateLayer::addPrefabMenuItem @ 0x1405f007a\n; > <???> @ 0x140923d44\n; > <???> @ 0x140923d50\n; \n; This function is hookable on this platform (idp: pc, 32 bit: False, 64 bit: True!\n; \n; Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA\n; Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings\n; Generated at Fri, 27 Nov 2026 11:31:25 +0000\n; \nmov     r11, rsp                                                       ; +0x0, 0x1403b8e90\nmov     [r11+18h], rbx                                                 ; +0x3, 0x1403b8e93\nmov     [r11+20h], rbp                                                 ; +0x7, 0x1403b8e97\npush    rsi                                                            ; +0xb, 0x1403b8e9b\npush    rdi                                                            ; +0xc, 0x1403b8e9c\npush    r14                                                            ; +0xd, 0x1403b8e9d\nsub     rsp, 90h                                                       ; +0xf, 0x1403b8e9f\nmovaps  xmmword ptr [r11-28h], xmm6                                    ; +0x16, 0x1403b8ea6\nmov     rax, cs:__security_cookie                                      ; +0x1b, 0x1403b8eab\nxor     rax, rsp                                                       ; +0x22, 0x1403b8eb2\nmov     [rsp+0A8h+var_38], rax                                         ; +0x25, 0x1403b8eb5\nmov     r14, rdx                                                       ; +0x2a, 0x1403b8eba\nmov     rsi, rcx                                                       ; +0x2d, 0x1403b8ebd\nmov     [r11-40h], rdx                                                 ; +0x30, 0x1403b8ec0\nlea     rcx, [r11-80h]                                                 ; +0x34, 0x1403b8ec4\ncall    sub_14003F4F0                                                  ; +0x38, 0x1403b8ec8\nmov     rbx, rax                                                       ; +0x3d, 0x1403b8ecd\nmov     [rsp+0A8h+var_88], rax                                         ; +0x40, 0x1403b8ed0\nmov     rdx, rax                                                       ; +0x45, 0x1403b8ed5\nmov     rcx, [rsi+38h]                                                 ; +0x48, 0x1403b8ed8\ncall    cs:?objectForKey@CCDictionary@cocos2d@@QEAAPEAVCCObject@2@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z; cocos2d::CCDictionary::objectForKey(std::string const &) ; +0x4c, 0x1403b8edc\nmov     rdi, rax                                                       ; +0x52, 0x1403b8ee2\nmov     rcx, rbx                                                       ; +0x55, 0x1403b8ee5\ncall    sub_14003D310                                                  ; +0x58, 0x1403b8ee8\ntest    rdi, rdi                                                       ; +0x5d, 0x1403b8eed\njz      loc_1403B8F9F                                                  ; +0x60, 0x1403b8ef0\nmov     rcx, rdi                                                       ; +0x66, 0x1403b8ef6\ncall    cs:?count@CCArray@cocos2d@@QEBAIXZ; cocos2d::CCArray::count(void) ; +0x69, 0x1403b8ef9\ntest    eax, eax                                                       ; +0x6f, 0x1403b8eff\njz      loc_1403B8F9F                                                  ; +0x71, 0x1403b8f01\nmov     rcx, rdi                                                       ; +0x77, 0x1403b8f07\ncall    cs:?count@CCArray@cocos2d@@QEBAIXZ; cocos2d::CCArray::count(void) ; +0x7a, 0x1403b8f0a\ncmp     eax, 1                                                         ; +0x80, 0x1403b8f10\njbe     loc_1403B8FE0                                                  ; +0x83, 0x1403b8f13\nmov     rdx, r14                                                       ; +0x89, 0x1403b8f19\nlea     rcx, [rsp+0A8h+var_60]                                         ; +0x8c, 0x1403b8f1c\ncall    sub_14003F4F0                                                  ; +0x91, 0x1403b8f21\nmov     rdx, rax                                                       ; +0x96, 0x1403b8f26\nmov     rcx, rsi                                                       ; +0x99, 0x1403b8f29\ncall    GJSmartTemplate__getTotalChanceForPrefab                       ; +0x9c, 0x1403b8f2c\nmov     ebx, eax                                                       ; +0xa1, 0x1403b8f31\nxor     esi, esi                                                       ; +0xa3, 0x1403b8f33\ncall    cs:rand                                                        ; +0xa5, 0x1403b8f35\nmovd    xmm6, eax                                                      ; +0xab, 0x1403b8f3b\ncvtdq2ps xmm6, xmm6                                                    ; +0xaf, 0x1403b8f3f\ndivss   xmm6, cs:dword_140835BDC                                       ; +0xb2, 0x1403b8f42\nmovd    xmm0, ebx                                                      ; +0xba, 0x1403b8f4a\ncvtdq2ps xmm0, xmm0                                                    ; +0xbe, 0x1403b8f4e\nmulss   xmm6, xmm0                                                     ; +0xc1, 0x1403b8f51\nmov     ebx, esi                                                       ; +0xc5, 0x1403b8f55\nmov     rcx, rdi                                                       ; +0xc7, 0x1403b8f57\ncall    cs:?count@CCArray@cocos2d@@QEBAIXZ; cocos2d::CCArray::count(void) ; +0xca, 0x1403b8f5a\ntest    eax, eax                                                       ; +0xd0, 0x1403b8f60\njz      short loc_1403B8F9F                                            ; +0xd2, 0x1403b8f62\nmov     edx, ebx                                                       ; +0xd4, 0x1403b8f64\nmov     rcx, rdi                                                       ; +0xd6, 0x1403b8f66\ncall    cs:?objectAtIndex@CCArray@cocos2d@@QEAAPEAVCCObject@2@I@Z; cocos2d::CCArray::objectAtIndex(uint) ; +0xd9, 0x1403b8f69\nmov     rbp, rax                                                       ; +0xdf, 0x1403b8f6f\nadd     esi, [rax+7Ch]                                                 ; +0xe2, 0x1403b8f72\nmovd    xmm0, esi                                                      ; +0xe5, 0x1403b8f75\ncvtdq2ps xmm0, xmm0                                                    ; +0xe9, 0x1403b8f79\ncomiss  xmm0, xmm6                                                     ; +0xec, 0x1403b8f7c\njnb     short loc_1403B8FD3                                            ; +0xef, 0x1403b8f7f\nmov     rcx, rdi                                                       ; +0xf1, 0x1403b8f81\ncall    cs:?count@CCArray@cocos2d@@QEBAIXZ; cocos2d::CCArray::count(void) ; +0xf4, 0x1403b8f84\ndec     eax                                                            ; +0xfa, 0x1403b8f8a\ncmp     ebx, eax                                                       ; +0xfc, 0x1403b8f8c\njz      short loc_1403B8FD3                                            ; +0xfe, 0x1403b8f8e\ninc     ebx                                                            ; +0x100, 0x1403b8f90\nmov     rcx, rdi                                                       ; +0x102, 0x1403b8f92\ncall    cs:?count@CCArray@cocos2d@@QEBAIXZ; cocos2d::CCArray::count(void) ; +0x105, 0x1403b8f95\ncmp     ebx, eax                                                       ; +0x10b, 0x1403b8f9b\njb      short loc_1403B8F64                                            ; +0x10d, 0x1403b8f9d\nmov     rcx, r14                                                       ; +0x10f, 0x1403b8f9f\ncall    sub_14003D310                                                  ; +0x112, 0x1403b8fa2\nxor     eax, eax                                                       ; +0x117, 0x1403b8fa7\nmov     rcx, [rsp+0A8h+var_38]                                         ; +0x119, 0x1403b8fa9\nxor     rcx, rsp; StackCookie                                          ; +0x11e, 0x1403b8fae\ncall    __security_check_cookie                                        ; +0x121, 0x1403b8fb1\nlea     r11, [rsp+0A8h+var_18]                                         ; +0x126, 0x1403b8fb6\nmov     rbx, [r11+30h]                                                 ; +0x12e, 0x1403b8fbe\nmov     rbp, [r11+38h]                                                 ; +0x132, 0x1403b8fc2\nmovaps  xmm6, xmmword ptr [r11-10h]                                    ; +0x136, 0x1403b8fc6\nmov     rsp, r11                                                       ; +0x13b, 0x1403b8fcb\npop     r14                                                            ; +0x13e, 0x1403b8fce\npop     rdi                                                            ; +0x140, 0x1403b8fd0\npop     rsi                                                            ; +0x141, 0x1403b8fd1\nretn                                                                   ; +0x142, 0x1403b8fd2\nmov     rcx, r14                                                       ; +0x143, 0x1403b8fd3\ncall    sub_14003D310                                                  ; +0x146, 0x1403b8fd6\nmov     rax, rbp                                                       ; +0x14b, 0x1403b8fdb\njmp     short loc_1403B8FA9                                            ; +0x14e, 0x1403b8fde\nxor     edx, edx                                                       ; +0x150, 0x1403b8fe0\nmov     rcx, rdi                                                       ; +0x152, 0x1403b8fe2\ncall    cs:?objectAtIndex@CCArray@cocos2d@@QEAAPEAVCCObject@2@I@Z; cocos2d::CCArray::objectAtIndex(uint) ; +0x155, 0x1403b8fe5\nmov     rbx, rax                                                       ; +0x15b, 0x1403b8feb\nmov     rcx, r14                                                       ; +0x15e, 0x1403b8fee\ncall    sub_14003D310                                                  ; +0x161, 0x1403b8ff1\nmov     rax, rbx                                                       ; +0x166, 0x1403b8ff6\njmp     short loc_1403B8FA9                                            ; +0x169, 0x1403b8ff9", "xrefs": ["GJSmartTemplate::scanForPrefab @ 0x1403b8051", "GJSmartTemplate::getPrefab @ 0x1403b908f", "BrowseSmartTemplateLayer::addPrefabMenuItem @ 0x1405f007a", "<???> @ 0x140923d44", "<???> @ 0x140923d50"], "is_objc": false, "is_32_bit": false, "is_64_bit": true, "idp_name": "pc", "bida_info": "8.3.0 @ https://github.com/Stazzical/BromaIDA", "bindings_info": "commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings"}