// // sub_140405690 from 0x140405690 to 0x140406166 (2774 bytes) // // 2 xrefs: // > sub_140406240 @ 0x140406a81 // > @ 0x140925bec // // This function is hookable on this platform (idp: pc, 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:31:57 +0000 // // Hidden C++ exception states: #wind=7 __int64 __fastcall sub_140405690(cocos2d::CCArray *a1, __int64 a2) { const struct cocos2d::CCPoint **v3; // rdi __int64 v4; // rax __int64 v5; // rax _QWORD *v6; // rax unsigned int v7; // eax unsigned int *v8; // rcx __int64 v9; // rax __int64 *v10; // rcx __int64 v11; // rcx const struct cocos2d::CCRect *v12; // rax float MinX; // xmm0_4 int v14; // r12d float MinY; // xmm0_4 int v16; // r15d float MaxX; // xmm0_4 int v18; // r13d float MaxY; // xmm0_4 int v20; // eax __int64 v21; // rsi __int64 v22; // rbx _QWORD *v23; // rax _QWORD *v24; // r15 _QWORD *v25; // rbx __m128i si128; // xmm14 __m128i v27; // xmm15 unsigned __int64 v28; // rsi _QWORD *v29; // rax _QWORD *v30; // r14 const void *v31; // rdx void *v32; // rcx size_t v33; // r8 void *v34; // rcx double v35; // xmm10_8 double v36; // xmm11_8 int v37; // ecx __int64 v38; // rbx float v39; // xmm7_4 float v40; // xmm6_4 float v41; // xmm9_4 float v42; // xmm8_4 const struct cocos2d::CCPoint *v43; // rax cocos2d::CCPoint *v44; // rcx const struct cocos2d::CCPoint *v45; // rax cocos2d::CCPoint *v46; // rcx const struct cocos2d::CCPoint *v47; // rax cocos2d::CCPoint *v48; // rcx const struct cocos2d::CCPoint *v49; // rax cocos2d::CCPoint *v50; // rcx __int64 v51; // rsi const struct cocos2d::CCPoint *v52; // rax cocos2d::CCPoint *v53; // rcx const struct cocos2d::CCPoint *v54; // rax cocos2d::CCPoint *v55; // rcx const struct cocos2d::CCPoint *v56; // rax cocos2d::CCPoint *v57; // rcx const struct cocos2d::CCPoint *v58; // rax cocos2d::CCPoint *v59; // rcx __int64 v60; // rsi int v61; // edi unsigned __int64 v62; // r14 unsigned __int64 v63; // r15 unsigned __int64 v64; // r12 unsigned __int64 v65; // r13 __int64 v66; // r10 __int64 v67; // r11 _QWORD *v68; // rax float v69; // xmm2_4 float v70; // xmm1_4 const struct cocos2d::CCPoint *v71; // rax const struct cocos2d::CCPoint **v72; // r14 cocos2d::CCPoint *v73; // rcx void *v74; // rcx void *Src_8[2]; // [rsp+38h] [rbp-D0h] BYREF char *v77; // [rsp+48h] [rbp-C0h] unsigned __int64 v78; // [rsp+50h] [rbp-B8h] BYREF _QWORD *v79; // [rsp+58h] [rbp-B0h] BYREF _BYTE v80[24]; // [rsp+60h] [rbp-A8h] BYREF __int64 v81; // [rsp+78h] [rbp-90h] BYREF _QWORD *v82; // [rsp+80h] [rbp-88h] __int64 v83; // [rsp+88h] [rbp-80h] __int64 v84; // [rsp+90h] [rbp-78h] BYREF __int128 v85; // [rsp+98h] [rbp-70h] __int64 v86; // [rsp+A8h] [rbp-60h] __int64 v87; // [rsp+B0h] [rbp-58h] int v88; // [rsp+B8h] [rbp-50h] BYREF _QWORD *v89; // [rsp+C0h] [rbp-48h] __int64 v90; // [rsp+C8h] [rbp-40h] __int64 v91; // [rsp+D0h] [rbp-38h] BYREF __int128 v92; // [rsp+D8h] [rbp-30h] __int64 v93; // [rsp+E8h] [rbp-20h] __int64 v94; // [rsp+F0h] [rbp-18h] unsigned __int64 v95; // [rsp+F8h] [rbp-10h] unsigned __int64 v96; // [rsp+100h] [rbp-8h] _QWORD *v97; // [rsp+108h] [rbp+0h] const struct cocos2d::CCPoint **v98; // [rsp+110h] [rbp+8h] __m128i v99; // [rsp+118h] [rbp+10h] BYREF char v100[8]; // [rsp+128h] [rbp+20h] BYREF char v101[8]; // [rsp+130h] [rbp+28h] BYREF char v102[8]; // [rsp+138h] [rbp+30h] BYREF char v103[8]; // [rsp+140h] [rbp+38h] BYREF char v104[8]; // [rsp+148h] [rbp+40h] BYREF char v105[8]; // [rsp+150h] [rbp+48h] BYREF char v106[8]; // [rsp+158h] [rbp+50h] BYREF char v107[8]; // [rsp+160h] [rbp+58h] BYREF __m128i v108; // [rsp+168h] [rbp+60h] char v109[16]; // [rsp+178h] [rbp+70h] BYREF char v110[176]; // [rsp+188h] [rbp+80h] BYREF unsigned __int64 v111; // [rsp+280h] [rbp+178h] BYREF unsigned __int64 v112; // [rsp+288h] [rbp+180h] BYREF const struct cocos2d::CCPoint **v113; // [rsp+290h] [rbp+188h] v3 = (const struct cocos2d::CCPoint **)(a2 + 8); v113 = (const struct cocos2d::CCPoint **)(a2 + 8); v4 = *(_QWORD *)(a2 + 8); if ( v4 != *(_QWORD *)(a2 + 16) ) *(_QWORD *)(a2 + 16) = v4; v98 = (const struct cocos2d::CCPoint **)(a2 + 32); v5 = *(_QWORD *)(a2 + 32); if ( v5 != *(_QWORD *)(a2 + 40) ) *(_QWORD *)(a2 + 40) = v5; v90 = 0; v6 = operator new(0x18u); *v6 = v6; v6[1] = v6; v89 = v6; v91 = 0; v92 = 0; v93 = 7; v94 = 8; v88 = 1065353216; sub_14003F200((__int64)&v91, 0x10u, (unsigned __int64)v6); v7 = cocos2d::CCArray::count(a1); sub_140413EC0(&v88, 8 * v7); if ( a1 ) { v8 = *((unsigned int **)a1 + 7); v9 = *v8; if ( (_DWORD)v9 ) { v10 = *((__int64 **)v8 + 2); v112 = (unsigned __int64)v10; v78 = (unsigned __int64)&v10[v9 - 1]; if ( (unsigned __int64)v10 <= v78 ) { do { v11 = *v10; if ( !v11 ) break; v12 = (const struct cocos2d::CCRect *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v11 + 1184LL))(v11); cocos2d::CCRect::CCRect((cocos2d::CCRect *)v80, v12); cocos2d::CCRect::inflateRect((cocos2d::CCRect *)v80, 3.0); MinX = cocos2d::CCRect::getMinX((cocos2d::CCRect *)v80); v14 = (int)floorf((float)(MinX + 0.001) / 15.0); MinY = cocos2d::CCRect::getMinY((cocos2d::CCRect *)v80); v16 = (int)floorf((float)(MinY + 0.001) / 15.0); MaxX = cocos2d::CCRect::getMaxX((cocos2d::CCRect *)v80); v18 = (int)floorf((float)(MaxX - 0.001) / 15.0); MaxY = cocos2d::CCRect::getMaxY((cocos2d::CCRect *)v80); v20 = (int)floorf((float)(MaxY - 0.001) / 15.0); for ( LODWORD(v111) = v20; v16 <= v20; ++v16 ) { if ( v14 <= v18 ) { v21 = (unsigned int)(v18 - v14 + 1); v22 = (__int64)v14 << 32; do { v79 = (_QWORD *)((unsigned int)v16 ^ (unsigned __int64)v22); sub_140415070(&v88, &v99, &v79); v22 += 0x100000000LL; --v21; } while ( v21 ); v20 = v111; } } v10 = (__int64 *)(v112 + 8); v112 = (unsigned __int64)v10; } while ( (unsigned __int64)v10 <= v78 ); v3 = v113; } } } LODWORD(v81) = 0; v82 = nullptr; v83 = 0; v23 = operator new(0x18u); *v23 = v23; v23[1] = v23; v82 = v23; v84 = 0; v85 = 0; v86 = 7; v87 = 8; LODWORD(v81) = 1065353216; sub_14003F200((__int64)&v84, 0x10u, (unsigned __int64)v23); sub_140413EC0(&v81, v90); v24 = v89; v97 = v89; v25 = (_QWORD *)*v89; v79 = v25; if ( v25 != v89 ) { si128 = _mm_load_si128((const __m128i *)&xmmword_140836770); v27 = _mm_load_si128((const __m128i *)&xmmword_140836500); do { v28 = v25[2]; v111 = v28; v29 = *(_QWORD **)(v84 + 16 * (v86 & (0x100000001B3LL * (HIBYTE(v28) ^ (0x100000001B3LL * (BYTE6(v28) ^ (0x100000001B3LL * (BYTE5(v28) ^ (0x100000001B3LL * (BYTE4(v28) ^ (0x100000001B3LL * (BYTE3(v28) ^ (0x100000001B3LL * (BYTE2(v28) ^ (0x100000001B3LL * ((0x100000001B3LL * ((unsigned __int8)v28 ^ 0xCBF29CE484222325uLL)) ^ BYTE1(v28)))))))))))))))) + 8); if ( v29 != v82 ) { if ( v28 == v29[2] ) goto LABEL_25; while ( v29 != *(_QWORD **)(v84 + 16 * (v86 & (0x100000001B3LL * (HIBYTE(v28) ^ (0x100000001B3LL * (BYTE6(v28) ^ (0x100000001B3LL * (BYTE5(v28) ^ (0x100000001B3LL * (BYTE4(v28) ^ (0x100000001B3LL * (BYTE3(v28) ^ (0x100000001B3LL * (BYTE2(v28) ^ (0x100000001B3LL * ((0x100000001B3LL * ((unsigned __int8)v28 ^ 0xCBF29CE484222325uLL)) ^ BYTE1(v28))))))))))))))))) ) { v29 = (_QWORD *)v29[1]; if ( v28 == v29[2] ) goto LABEL_25; } } v29 = nullptr; LABEL_25: if ( !v29 ) { *(_OWORD *)Src_8 = 0; v77 = nullptr; v30 = sub_14003D460(8u); *v30 = v28; v31 = Src_8[0]; v32 = v30; v33 = -(__int64)Src_8[0]; if ( Src_8[1] ) { memmove(v30, Src_8[0], v33); v33 = (size_t)Src_8[1]; v31 = nullptr; v32 = v30 + 1; } memmove(v32, v31, v33); v34 = Src_8[0]; if ( Src_8[0] ) { if ( ((v77 - (char *)Src_8[0]) & 0xFFFFFFFFFFFFFFF8uLL) >= 0x1000 ) { v34 = *((void **)Src_8[0] - 1); if ( (unsigned __int64)((char *)Src_8[0] - (char *)v34 - 8) > 0x1F ) invoke_watson(nullptr, nullptr, nullptr, 0, 0); } j_j_free(v34); } Src_8[0] = v30; Src_8[1] = v30 + 1; v77 = (char *)(v30 + 1); sub_140415070(&v81, v109, &v111); v35 = 0.0; v36 = 0.0; v37 = 0; if ( Src_8[0] != Src_8[1] ) { v108 = v27; v99 = si128; while ( 1 ) { v38 = *((_QWORD *)Src_8[1] - 1); Src_8[1] = (char *)Src_8[1] - 8; v78 = v38 >> 32; v35 = v35 + (double)SHIDWORD(v38); v36 = v36 + (double)(int)v38; LODWORD(v111) = v37 + 1; v39 = (float)SHIDWORD(v38) * 15.0; v40 = (float)(int)v38 * 15.0; v41 = v39 + 15.0; v42 = v40 + 15.0; v112 = (unsigned int)v38 ^ (unsigned __int64)((__int64)(HIDWORD(v38) - 1) << 32); if ( !sub_140413DF0(&v88, &v112) ) { cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v100, v39, v40); v44 = v3[1]; if ( v44 == v3[2] ) { sub_1403C0830(v3, v3[1], v43); } else { cocos2d::CCPoint::CCPoint(v44, v43); v3[1] = (const struct cocos2d::CCPoint *)((char *)v3[1] + 8); } cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v101, v39, v42); v46 = v3[1]; if ( v46 == v3[2] ) { sub_1403C0830(v3, v3[1], v45); } else { cocos2d::CCPoint::CCPoint(v46, v45); v3[1] = (const struct cocos2d::CCPoint *)((char *)v3[1] + 8); } } v112 = (unsigned int)v38 ^ (unsigned __int64)((__int64)(HIDWORD(v38) + 1) << 32); if ( !sub_140413DF0(&v88, &v112) ) { cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v102, v41, v40); v48 = v3[1]; if ( v48 == v3[2] ) { sub_1403C0830(v3, v3[1], v47); } else { cocos2d::CCPoint::CCPoint(v48, v47); v3[1] = (const struct cocos2d::CCPoint *)((char *)v3[1] + 8); } cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v103, v41, v42); v50 = v3[1]; if ( v50 == v3[2] ) { sub_1403C0830(v3, v3[1], v49); } else { cocos2d::CCPoint::CCPoint(v50, v49); v3[1] = (const struct cocos2d::CCPoint *)((char *)v3[1] + 8); } } v51 = (__int64)SHIDWORD(v38) << 32; v112 = v51 ^ (unsigned int)(v38 - 1); if ( !sub_140413DF0(&v88, &v112) ) { cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v104, v39, v40); v53 = v3[1]; if ( v53 == v3[2] ) { sub_1403C0830(v3, v3[1], v52); } else { cocos2d::CCPoint::CCPoint(v53, v52); v3[1] = (const struct cocos2d::CCPoint *)((char *)v3[1] + 8); } cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v105, v41, v40); v55 = v3[1]; if ( v55 == v3[2] ) { sub_1403C0830(v3, v3[1], v54); } else { cocos2d::CCPoint::CCPoint(v55, v54); v3[1] = (const struct cocos2d::CCPoint *)((char *)v3[1] + 8); } } v112 = v51 ^ (unsigned int)(v38 + 1); if ( !sub_140413DF0(&v88, &v112) ) { cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v106, v39, v42); v57 = v3[1]; if ( v57 == v3[2] ) { sub_1403C0830(v3, v3[1], v56); } else { cocos2d::CCPoint::CCPoint(v57, v56); v3[1] = (const struct cocos2d::CCPoint *)((char *)v3[1] + 8); } cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v107, v41, v42); v59 = v3[1]; if ( v59 == v3[2] ) { sub_1403C0830(v3, v3[1], v58); } else { cocos2d::CCPoint::CCPoint(v59, v58); v3[1] = (const struct cocos2d::CCPoint *)((char *)v3[1] + 8); } } v60 = 0; v61 = v78; do { v112 = (unsigned int)(v38 + v99.m128i_i32[v60]) ^ (unsigned __int64)((__int64)(v61 + v108.m128i_i32[v60]) << 32); v62 = HIWORD(v112); v63 = v112 >> 40; v64 = HIDWORD(v112); v65 = v112 >> 24; v96 = v112 >> 16; v95 = v112 >> 8; v78 = v112; if ( !sub_140413DF0(&v88, &v78) ) goto LABEL_74; v68 = *(_QWORD **)(v84 + 16 * (v86 & (0x100000001B3LL * (v67 ^ (0x100000001B3LL * ((unsigned __int8)v62 ^ (0x100000001B3LL * ((unsigned __int8)v63 ^ (0x100000001B3LL * ((unsigned __int8)v64 ^ (0x100000001B3LL * ((unsigned __int8)v65 ^ (0x100000001B3LL * ((unsigned __int8)v96 ^ (0x100000001B3LL * ((unsigned __int8)v95 ^ (0x100000001B3LL * ((unsigned __int8)v66 ^ 0xCBF29CE484222325uLL))))))))))))))))) + 8); if ( v68 != v82 ) { if ( v66 == v68[2] ) goto LABEL_70; while ( v68 != *(_QWORD **)(v84 + 16 * (v86 & (0x100000001B3LL * (v67 ^ (0x100000001B3LL * ((unsigned __int8)v62 ^ (0x100000001B3LL * ((unsigned __int8)v63 ^ (0x100000001B3LL * ((unsigned __int8)v64 ^ (0x100000001B3LL * ((unsigned __int8)v65 ^ (0x100000001B3LL * ((unsigned __int8)v96 ^ (0x100000001B3LL * ((unsigned __int8)v95 ^ (0x100000001B3LL * ((unsigned __int8)v66 ^ 0xCBF29CE484222325uLL)))))))))))))))))) ) { v68 = (_QWORD *)v68[1]; if ( v66 == v68[2] ) goto LABEL_70; } } v68 = nullptr; LABEL_70: if ( !v68 ) { sub_140415070(&v81, v110, &v112); if ( Src_8[1] == v77 ) { sub_1400699B0(Src_8, (_BYTE *)Src_8[1], &v112); } else { *(_QWORD *)Src_8[1] = v112; Src_8[1] = (char *)Src_8[1] + 8; } } LABEL_74: ++v60; } while ( v60 < 4 ); v3 = v113; v37 = v111; if ( Src_8[0] == Src_8[1] ) { v25 = v79; v24 = v97; break; } } } v69 = v36 / (double)v37; v70 = v35 / (double)v37; cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v80, (float)(v70 + 0.5) * 15.0, (float)(v69 + 0.5) * 15.0); v72 = v98; v73 = v98[1]; if ( v73 == v98[2] ) { sub_1403C0830(v98, v98[1], v71); } else { cocos2d::CCPoint::CCPoint(v73, v71); v72[1] = (const struct cocos2d::CCPoint *)((char *)v72[1] + 8); } v74 = Src_8[0]; if ( Src_8[0] ) { if ( ((v77 - (char *)Src_8[0]) & 0xFFFFFFFFFFFFFFF8uLL) >= 0x1000 ) { v74 = *((void **)Src_8[0] - 1); if ( (unsigned __int64)((char *)Src_8[0] - (char *)v74 - 8) > 0x1F ) invoke_watson(nullptr, nullptr, nullptr, 0, 0); } j_j_free(v74); } } v25 = (_QWORD *)*v25; v79 = v25; } while ( v25 != v24 ); } sub_140406180(&v81); return sub_140406180(&v88); }
GD Web Decomp Icon

GD Web Decomp

Raw Source