{"type": "func", "start": 4299310640, "end": 4299311010, "name": "GJSmartTemplate::getRandomPrefab", "pseudocode": "// \n// GJSmartTemplate::getRandomPrefab from 0x100424630 to 0x1004247a2 (370 bytes)\n// \n// 3 xrefs:\n// > GJSmartTemplate::scanForPrefab @ 0x100423bfb\n// > GJSmartTemplate::getPrefab_1 @ 0x100425918\n// > BrowseSmartTemplateLayer::addPrefabMenuItem @ 0x1004e9c07\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__int64 __fastcall GJSmartTemplate::getRandomPrefab(__int64 a1, __int64 a2, __m128 a3)\n{\n  __int64 v3; // rbx\n  __int64 v4; // r15\n  int TotalChanceForPrefab; // r14d\n  int v6; // r15d\n  unsigned int v7; // r14d\n  int v8; // r12d\n  __m128 v10; // [rsp+0h] [rbp-60h] BYREF\n  void *__p; // [rsp+10h] [rbp-50h]\n  __m128 v12; // [rsp+20h] [rbp-40h] BYREF\n  void *v13; // [rsp+30h] [rbp-30h]\n  float v14; // [rsp+3Ch] [rbp-24h]\n\n  if ( (*(_BYTE *)a2 & 1) != 0 )\n  {\n    sub_100006B70(&v10, *(const void **)(a2 + 16), *(_QWORD *)(a2 + 8), *(double *)a3.i64);\n  }\n  else\n  {\n    __p = *(void **)(a2 + 16);\n    a3 = *(__m128 *)a2;\n    v10 = *(__m128 *)a2;\n  }\n  v3 = cocos2d::CCDictionary::objectForKey_1(*(_QWORD *)(a1 + 56), (char *)&v10);\n  if ( (v10.i8[0] & 1) != 0 )\n    operator delete(__p);\n  if ( !v3 || !(unsigned int)sub_100720070(v3) )\n    return 0;\n  if ( (unsigned int)sub_100720070(v3) < 2 )\n    return sub_1007200C0(v3, 0);\n  if ( (*(_BYTE *)a2 & 1) != 0 )\n  {\n    sub_100006B70(&v12, *(const void **)(a2 + 16), *(_QWORD *)(a2 + 8), *(double *)a3.i64);\n  }\n  else\n  {\n    v13 = *(void **)(a2 + 16);\n    v12 = *(__m128 *)a2;\n  }\n  TotalChanceForPrefab = GJSmartTemplate::getTotalChanceForPrefab(a1, &v12);\n  if ( (v12.i8[0] & 1) != 0 )\n    operator delete(v13);\n  v6 = rand();\n  if ( !(unsigned int)sub_100720070(v3) )\n    return 0;\n  v14 = (float)TotalChanceForPrefab * (float)((float)v6 * 4.6566129e-10);\n  v7 = 0;\n  v8 = 0;\n  while ( 1 )\n  {\n    v4 = sub_1007200C0(v3, v7);\n    v8 += *(_DWORD *)(v4 + 108);\n    if ( (float)v8 >= v14 || v7 == (unsigned int)sub_100720070(v3) - 1 )\n      break;\n    if ( ++v7 >= (unsigned int)sub_100720070(v3) )\n      return 0;\n  }\n  return v4;\n}", "assembly": "; \n; GJSmartTemplate::getRandomPrefab from 0x100424630 to 0x1004247a2 (370 bytes)\n; \n; 3 xrefs:\n; > GJSmartTemplate::scanForPrefab @ 0x100423bfb\n; > GJSmartTemplate::getPrefab_1 @ 0x100425918\n; > BrowseSmartTemplateLayer::addPrefabMenuItem @ 0x1004e9c07\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\npush    rbp                                                            ; +0x0, 0x100424630\nmov     rbp, rsp                                                       ; +0x1, 0x100424631\npush    r15                                                            ; +0x4, 0x100424634\npush    r14                                                            ; +0x6, 0x100424636\npush    r12                                                            ; +0x8, 0x100424638\npush    rbx                                                            ; +0xa, 0x10042463a\nsub     rsp, 40h                                                       ; +0xb, 0x10042463b\nmov     r15, rsi                                                       ; +0xf, 0x10042463f\nmov     r14, rdi                                                       ; +0x12, 0x100424642\ntest    byte ptr [rsi], 1                                              ; +0x15, 0x100424645\njnz     short loc_10042465C                                            ; +0x18, 0x100424648\nmov     rax, [r15+10h]                                                 ; +0x1a, 0x10042464a\nmov     [rbp+__p], rax                                                 ; +0x1e, 0x10042464e\nmovups  xmm0, xmmword ptr [r15]                                        ; +0x22, 0x100424652\nmovaps  [rbp+var_60], xmm0                                             ; +0x26, 0x100424656\njmp     short loc_10042466D                                            ; +0x2a, 0x10042465a\nmov     rdx, [r15+8]                                                   ; +0x2c, 0x10042465c\nmov     rsi, [r15+10h]                                                 ; +0x30, 0x100424660\nlea     rdi, [rbp+var_60]                                              ; +0x34, 0x100424664\ncall    sub_100006B70                                                  ; +0x38, 0x100424668\nlea     r12, [rbp+__p]                                                 ; +0x3d, 0x10042466d\nmov     rdi, [r14+38h]                                                 ; +0x41, 0x100424671\nlea     rsi, [rbp+var_60]                                              ; +0x45, 0x100424675\ncall    cocos2d__CCDictionary__objectForKey_1                          ; +0x49, 0x100424679\nmov     rbx, rax                                                       ; +0x4e, 0x10042467e\ntest    byte ptr [rbp+var_60], 1                                       ; +0x51, 0x100424681\njz      short loc_100424690                                            ; +0x55, 0x100424685\nmov     rdi, [rbp+__p]; __p                                            ; +0x57, 0x100424687\ncall    __ZdlPv; operator delete(void *)                               ; +0x5b, 0x10042468b\ntest    rbx, rbx                                                       ; +0x60, 0x100424690\njz      loc_10042478F                                                  ; +0x63, 0x100424693\nmov     rdi, rbx                                                       ; +0x69, 0x100424699\ncall    sub_100720070                                                  ; +0x6c, 0x10042469c\ntest    eax, eax                                                       ; +0x71, 0x1004246a1\njz      loc_10042478F                                                  ; +0x73, 0x1004246a3\nmov     rdi, rbx                                                       ; +0x79, 0x1004246a9\ncall    sub_100720070                                                  ; +0x7c, 0x1004246ac\ncmp     eax, 2                                                         ; +0x81, 0x1004246b1\njb      short loc_1004246CE                                            ; +0x84, 0x1004246b4\ntest    byte ptr [r15], 1                                              ; +0x86, 0x1004246b6\njnz     short loc_1004246E0                                            ; +0x8a, 0x1004246ba\nmov     rax, [r15+10h]                                                 ; +0x8c, 0x1004246bc\nmov     [rbp+var_30], rax                                              ; +0x90, 0x1004246c0\nmovups  xmm0, xmmword ptr [r15]                                        ; +0x94, 0x1004246c4\nmovaps  [rbp+var_40], xmm0                                             ; +0x98, 0x1004246c8\njmp     short loc_1004246F1                                            ; +0x9c, 0x1004246cc\nmov     rdi, rbx                                                       ; +0x9e, 0x1004246ce\nxor     esi, esi                                                       ; +0xa1, 0x1004246d1\ncall    sub_1007200C0                                                  ; +0xa3, 0x1004246d3\nmov     r15, rax                                                       ; +0xa8, 0x1004246d8\njmp     loc_100424792                                                  ; +0xab, 0x1004246db\nmov     rdx, [r15+8]                                                   ; +0xb0, 0x1004246e0\nmov     rsi, [r15+10h]                                                 ; +0xb4, 0x1004246e4\nlea     rdi, [rbp+var_40]                                              ; +0xb8, 0x1004246e8\ncall    sub_100006B70                                                  ; +0xbc, 0x1004246ec\nlea     r12, [rbp+var_30]                                              ; +0xc1, 0x1004246f1\nlea     rsi, [rbp+var_40]                                              ; +0xc5, 0x1004246f5\nmov     rdi, r14                                                       ; +0xc9, 0x1004246f9\ncall    GJSmartTemplate__getTotalChanceForPrefab                       ; +0xcc, 0x1004246fc\nmov     r14d, eax                                                      ; +0xd1, 0x100424701\ntest    byte ptr [rbp+var_40], 1                                       ; +0xd4, 0x100424704\njz      short loc_100424713                                            ; +0xd8, 0x100424708\nmov     rdi, [rbp+var_30]; __p                                         ; +0xda, 0x10042470a\ncall    __ZdlPv; operator delete(void *)                               ; +0xde, 0x10042470e\ncall    _rand                                                          ; +0xe3, 0x100424713\nmov     r15d, eax                                                      ; +0xe8, 0x100424718\nmov     rdi, rbx                                                       ; +0xeb, 0x10042471b\ncall    sub_100720070                                                  ; +0xee, 0x10042471e\ntest    eax, eax                                                       ; +0xf3, 0x100424723\njz      short loc_10042478F                                            ; +0xf5, 0x100424725\nxorps   xmm0, xmm0                                                     ; +0xf7, 0x100424727\ncvtsi2ss xmm0, r15d                                                    ; +0xfa, 0x10042472a\nmulss   xmm0, cs:dword_100815710                                       ; +0xff, 0x10042472f\ncvtsi2ss xmm1, r14d                                                    ; +0x107, 0x100424737\nmulss   xmm1, xmm0                                                     ; +0x10c, 0x10042473c\nmovss   [rbp+var_24], xmm1                                             ; +0x110, 0x100424740\nxor     r14d, r14d                                                     ; +0x115, 0x100424745\nxor     r12d, r12d                                                     ; +0x118, 0x100424748\nnop     dword ptr [rax+rax+00h]                                        ; +0x11b, 0x10042474b\nmov     rdi, rbx                                                       ; +0x120, 0x100424750\nmov     esi, r14d                                                      ; +0x123, 0x100424753\ncall    sub_1007200C0                                                  ; +0x126, 0x100424756\nmov     r15, rax                                                       ; +0x12b, 0x10042475b\nadd     r12d, [rax+6Ch]                                                ; +0x12e, 0x10042475e\nxorps   xmm0, xmm0                                                     ; +0x132, 0x100424762\ncvtsi2ss xmm0, r12d                                                    ; +0x135, 0x100424765\nucomiss xmm0, [rbp+var_24]                                             ; +0x13a, 0x10042476a\njnb     short loc_100424792                                            ; +0x13e, 0x10042476e\nmov     rdi, rbx                                                       ; +0x140, 0x100424770\ncall    sub_100720070                                                  ; +0x143, 0x100424773\ndec     eax                                                            ; +0x148, 0x100424778\ncmp     r14d, eax                                                      ; +0x14a, 0x10042477a\njz      short loc_100424792                                            ; +0x14d, 0x10042477d\ninc     r14d                                                           ; +0x14f, 0x10042477f\nmov     rdi, rbx                                                       ; +0x152, 0x100424782\ncall    sub_100720070                                                  ; +0x155, 0x100424785\ncmp     r14d, eax                                                      ; +0x15a, 0x10042478a\njb      short loc_100424750                                            ; +0x15d, 0x10042478d\nxor     r15d, r15d                                                     ; +0x15f, 0x10042478f\nmov     rax, r15                                                       ; +0x162, 0x100424792\nadd     rsp, 40h                                                       ; +0x165, 0x100424795\npop     rbx                                                            ; +0x169, 0x100424799\npop     r12                                                            ; +0x16a, 0x10042479a\npop     r14                                                            ; +0x16c, 0x10042479c\npop     r15                                                            ; +0x16e, 0x10042479e\npop     rbp                                                            ; +0x170, 0x1004247a0\nretn                                                                   ; +0x171, 0x1004247a1", "xrefs": ["GJSmartTemplate::scanForPrefab @ 0x100423bfb", "GJSmartTemplate::getPrefab_1 @ 0x100425918", "BrowseSmartTemplateLayer::addPrefabMenuItem @ 0x1004e9c07"], "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"}