//
// sub_140406240 from 0x140406240 to 0x140406b75 (2357 bytes)
//
// 3 xrefs:
// > LevelEditorLayer::updateDebugDraw @ 0x14040785c
// > LevelEditorLayer::updateDebugDraw @ 0x1404078c2
// > ??> @ 0x140925c04
//
// 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=6
void __fastcall sub_140406240(__int64 a1, _QWORD *a2, __int64 a3, cocos2d::CCDrawNode *a4)
{
__int64 v6; // r14
_QWORD *v7; // rax
_QWORD *v8; // rax
int v9; // r10d
_DWORD *v10; // rsi
_DWORD *v11; // rax
const struct cocos2d::_ccColor4F *v12; // r13
int v13; // eax
__int64 v14; // rsi
__int64 (__fastcall *v15)(__int64); // rbx
float *v16; // rdi
float *v17; // rax
__int64 v18; // r9
__int64 v19; // r15
__int64 v20; // rax
int v21; // ecx
_QWORD *v22; // rcx
__int64 v23; // rsi
__int64 (__fastcall *v24)(__int64); // rdi
const struct cocos2d::CCPoint *v25; // rbx
cocos2d *v26; // rax
const struct cocos2d::CCPoint *v27; // r8
float v28; // xmm0_4
__int64 v29; // r14
__int64 (__fastcall *v30)(__int64); // rsi
const struct cocos2d::CCPoint *v31; // rbx
const struct cocos2d::CCPoint *v32; // rax
__int64 v33; // rcx
const struct cocos2d::CCRect *v34; // rax
struct cocos2d::CCObject *Group; // rbx
_DWORD *v36; // r14
unsigned int *v37; // rdi
__int64 v38; // rax
_QWORD *v39; // rdi
_QWORD *v40; // rsi
float v41; // xmm2_4
float v42; // xmm4_4
float v43; // xmm0_4
float v44; // xmm1_4
_DWORD *v45; // rbx
__int64 v46; // rax
int v47; // edx
int v48; // r10d
struct cocos2d::CCObject *v49; // r15
_QWORD *v50; // rdi
__int64 v51; // r9
__int64 v52; // rbx
unsigned int *v53; // rsi
__int64 v54; // rax
_QWORD *v55; // rsi
_QWORD *i; // r14
unsigned int *v57; // rax
__int64 v58; // rcx
unsigned __int64 v59; // rbx
__int64 v60; // rsi
unsigned __int64 v61; // rbx
__int64 v62; // rcx
int v63; // [rsp+48h] [rbp-C0h]
float v64; // [rsp+50h] [rbp-B8h] BYREF
float v65; // [rsp+54h] [rbp-B4h]
float v66; // [rsp+58h] [rbp-B0h] BYREF
float v67; // [rsp+5Ch] [rbp-ACh]
__int64 v68; // [rsp+60h] [rbp-A8h]
_DWORD *v69; // [rsp+68h] [rbp-A0h]
__int16 v70; // [rsp+78h] [rbp-90h]
float v71; // [rsp+88h] [rbp-80h] BYREF
float v72; // [rsp+8Ch] [rbp-7Ch]
float v73; // [rsp+90h] [rbp-78h]
float v74; // [rsp+94h] [rbp-74h]
float v75; // [rsp+98h] [rbp-70h] BYREF
float v76; // [rsp+9Ch] [rbp-6Ch]
_DWORD *v77; // [rsp+A0h] [rbp-68h]
char v78[16]; // [rsp+A8h] [rbp-60h] BYREF
__int128 v79; // [rsp+B8h] [rbp-50h] BYREF
char v80[8]; // [rsp+C8h] [rbp-40h] BYREF
char v81[8]; // [rsp+D0h] [rbp-38h] BYREF
float v82[4]; // [rsp+D8h] [rbp-30h] BYREF
int v83; // [rsp+E8h] [rbp-20h] BYREF
void *v84[2]; // [rsp+F0h] [rbp-18h] BYREF
__int64 v85; // [rsp+100h] [rbp-8h] BYREF
__int128 v86; // [rsp+108h] [rbp+0h]
__int64 v87; // [rsp+118h] [rbp+10h]
__int64 v88; // [rsp+120h] [rbp+18h]
int v89; // [rsp+128h] [rbp+20h] BYREF
void *v90[2]; // [rsp+130h] [rbp+28h] BYREF
__int64 v91; // [rsp+140h] [rbp+38h] BYREF
__int128 v92; // [rsp+148h] [rbp+40h]
__int64 v93; // [rsp+158h] [rbp+50h]
__int64 v94; // [rsp+160h] [rbp+58h]
_BYTE v95[16]; // [rsp+168h] [rbp+60h] BYREF
_BYTE v96[16]; // [rsp+178h] [rbp+70h] BYREF
char v97[16]; // [rsp+188h] [rbp+80h] BYREF
char v98[16]; // [rsp+198h] [rbp+90h] BYREF
__int128 v99; // [rsp+1A8h] [rbp+A0h] BYREF
__int128 v100; // [rsp+1B8h] [rbp+B0h] BYREF
__int128 v101; // [rsp+1C8h] [rbp+C0h] BYREF
__int128 v102; // [rsp+1D8h] [rbp+D0h] BYREF
v6 = a1;
v68 = a1;
v84[1] = nullptr;
v7 = operator new(0x20u);
*v7 = v7;
v7[1] = v7;
v84[0] = v7;
v85 = 0;
v86 = 0;
v87 = 7;
v88 = 8;
v83 = 1065353216;
sub_14003F200((__int64)&v85, 0x10u, (unsigned __int64)v7);
v89 = 0;
v90[0] = nullptr;
v90[1] = nullptr;
v8 = operator new(0x18u);
*v8 = v8;
v8[1] = v8;
v90[0] = v8;
v91 = 0;
v92 = 0;
v93 = 7;
v94 = 8;
v89 = 1065353216;
sub_14003F200((__int64)&v91, 0x10u, (unsigned __int64)v8);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)v96, (const struct cocos2d::CCRect *)(*(_QWORD *)(v6 + 14448) + 380LL));
v9 = 0;
v63 = 0;
v10 = (_DWORD *)a2[1];
v69 = v10;
v11 = (_DWORD *)*a2;
v77 = v11;
if ( v11 != v10 )
{
v12 = (const struct cocos2d::_ccColor4F *)(v11 + 7);
while ( 1 )
{
v13 = *v11;
if ( !v13 )
{
v100 = *(_OWORD *)v12;
v14 = *(_QWORD *)((char *)v12 - 20);
v15 = *(__int64 (__fastcall **)(__int64))(*(_QWORD *)v14 + 200LL);
v16 = (float *)(*(__int64 (__fastcall **)(_QWORD, _QWORD, unsigned __int64))(**(_QWORD **)((char *)v12 - 12)
+ 200LL))(
*(_QWORD *)((char *)v12 - 12),
*(_QWORD *)(**(_QWORD **)((char *)v12 - 12) + 200LL),
0xCBF29CE484222325uLL);
v17 = (float *)v15(v14);
sub_140403260(a4, v17, v16, v18, (__int64)&v100);
goto LABEL_18;
}
if ( v13 == 1 )
break;
if ( v13 == 2 )
{
v33 = *(_QWORD *)((char *)v12 - 20);
if ( v33 )
{
v34 = (const struct cocos2d::CCRect *)(*(__int64 (__fastcall **)(__int64, __int64, unsigned __int64))(*(_QWORD *)v33 + 1184LL))(
v33,
0x100000001B3LL,
0xCBF29CE484222325uLL);
cocos2d::CCRect::CCRect((cocos2d::CCRect *)&v71, v34);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v81, v71, v72);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v80, v73 + v71, v74 + v72);
v100 = 0;
cocos2d::CCDrawNode::drawRect(a4, v81, v80, &v100, 1065353216, v12, 2);
goto LABEL_19;
}
Group = GJBaseGameLayer::getGroup(v6, *((unsigned int *)v12 - 1));
if ( !cocos2d::CCArray::count(Group) )
goto LABEL_19;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v66, (const struct cocos2d::CCPoint *)&dword_14090AF10);
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v64, (const struct cocos2d::CCPoint *)&dword_14090AF10);
v36 = nullptr;
v102 = *(_OWORD *)v12;
v101 = v102;
HIDWORD(v102) = 1022739087;
HIDWORD(v101) = 1041865114;
if ( Group
&& (v37 = *((unsigned int **)Group + 7), v38 = *v37, (_DWORD)v38)
&& (v39 = *((_QWORD **)v37 + 2), v40 = &v39[v38 - 1], v39 <= v40) )
{
v41 = v67;
v42 = v66;
v43 = v65;
v44 = v64;
do
{
v45 = (_DWORD *)*v39;
if ( !*v39 )
break;
if ( v45[314] == 1 )
{
(*(void (__fastcall **)(_QWORD, float *))(*(_QWORD *)v45 + 1208LL))(*v39, &v75);
v42 = v66;
if ( v66 > v75 || v66 == 0.0 )
{
v42 = v75;
v66 = v75;
v36 = v45;
}
v41 = v67;
if ( v67 > v76 || v67 == 0.0 )
{
v41 = v76;
v67 = v76;
}
v44 = v64;
if ( v75 > v64 || v64 == 0.0 )
{
v44 = v75;
v64 = v75;
}
v43 = v65;
if ( v76 > v65 || v65 == 0.0 )
{
v43 = v76;
v65 = v76;
}
}
++v39;
}
while ( v39 <= v40 );
}
else
{
v41 = v67;
v42 = v66;
v43 = v65;
v44 = v64;
}
if ( v42 != v44 || v41 != v43 )
{
*(_QWORD *)(*(_QWORD *)sub_140356E00((__int64)&v83, (__int64)v97, (unsigned __int8 *)v12 - 4) + 24LL) = v36;
v66 = v66 + -30.0;
v67 = v67 + -30.0;
v64 = v64 + 30.0;
v65 = v65 + 30.0;
cocos2d::CCDrawNode::drawRect(a4, &v66, &v64, &v102, 1069547520, &v101, 2);
}
LABEL_17:
v6 = v68;
LABEL_18:
v10 = v69;
goto LABEL_19;
}
if ( v13 != 3 )
goto LABEL_20;
v46 = sub_140401470((__int64)v78, v9);
v70 = *(_WORD *)v46;
v47 = *(unsigned __int8 *)(v46 + 2);
*(float *)&v99 = (float)(unsigned __int8)v70 / 255.0;
*((float *)&v99 + 1) = (float)HIBYTE(v70) / 255.0;
*((float *)&v99 + 2) = (float)v47 / 255.0;
HIDWORD(v99) = 1053609165;
v63 = v48 + 1;
(*(void (__fastcall **)(_QWORD, float *))(**(_QWORD **)((char *)v12 - 20) + 1208LL))(
*(_QWORD *)((char *)v12 - 20),
v82);
v49 = GJBaseGameLayer::getGroup(v6, *((unsigned int *)v12 - 1));
v50 = *(_QWORD **)sub_1404162A0(v6 + 15744, v98, (char *)v12 - 4);
sub_140068190((__int64)&v89, (__int64)v95, (unsigned __int8 *)v12 - 4);
if ( v95[8] )
{
v52 = 0xCBF29CE484222325uLL;
if ( v49 )
{
v53 = *((unsigned int **)v49 + 7);
v54 = *v53;
if ( (_DWORD)v54 )
{
v55 = *((_QWORD **)v53 + 2);
for ( i = &v55[v54 - 1]; v55 <= i; ++v55 )
{
if ( !*v55 )
break;
v57 = (unsigned int *)(*(__int64 (__fastcall **)(_QWORD))(*(_QWORD *)*v55 + 1184LL))(*v55);
v52 = 0x100000001B3LL
* (v57[3]
^ (0x100000001B3LL
* (v57[2] ^ (0x100000001B3LL * (v57[1] ^ (0x100000001B3LL * (*v57 ^ (unsigned __int64)v52)))))));
}
v6 = v68;
}
}
if ( v50[3] != v52 )
{
v50[3] = v52;
sub_140405690(v49, (__int64)(v50 + 3));
}
cocos2d::CCDrawNode::enableDrawArea(*(cocos2d::CCDrawNode **)(v6 + 14448), (struct cocos2d::CCRect *)v96);
v58 = v50[4];
if ( (unsigned __int64)((v50[5] - v58) >> 3) > 1 )
{
v59 = 1;
v60 = 0;
do
{
cocos2d::CCDrawNode::drawSegmentEx(
a4,
(const struct cocos2d::CCPoint *)(v58 + v60),
(const struct cocos2d::CCPoint *)(v58 + v60 + 8),
1.0,
(const struct cocos2d::_ccColor4F *)&v99,
0,
0);
v60 += 16;
v59 += 2LL;
v58 = v50[4];
}
while ( v59 < (v50[5] - v58) >> 3 );
}
cocos2d::CCDrawNode::disableDrawArea(*(cocos2d::CCDrawNode **)(v6 + 14448));
v10 = v69;
}
v61 = 0;
v62 = v50[7];
if ( (v50[8] - v62) >> 3 )
{
do
{
v79 = v99;
sub_140403260(a4, v82, (float *)(v62 + 8 * v61++), v51, (__int64)&v79);
v62 = v50[7];
}
while ( v61 < (v50[8] - v62) >> 3 );
}
LABEL_19:
v9 = v63;
LABEL_20:
v11 = v77 + 12;
v77 = v11;
v12 = (const struct cocos2d::_ccColor4F *)((char *)v12 + 48);
if ( v11 == v10 )
goto LABEL_21;
}
v19 = *(_QWORD *)((char *)v12 - 12);
v20 = *(_QWORD *)(v85
+ 16
* (v87
& (0x100000001B3LL
* (*((unsigned __int8 *)v12 - 1)
^ (0x100000001B3LL
* (*((unsigned __int8 *)v12 - 2)
^ (0x100000001B3LL
* (*((unsigned __int8 *)v12 - 3)
^ (0x100000001B3LL * (*((unsigned __int8 *)v12 - 4) ^ 0xCBF29CE484222325uLL)))))))))
+ 8);
if ( (void *)v20 != v84[0] )
{
v21 = *((_DWORD *)v12 - 1);
if ( v21 == *(_DWORD *)(v20 + 16) )
{
LABEL_12:
v22 = v84[0];
if ( v20 )
v22 = (_QWORD *)v20;
if ( v22 != v84[0] )
v19 = v22[3];
v23 = *(_QWORD *)((char *)v12 - 20);
v24 = *(__int64 (__fastcall **)(__int64))(*(_QWORD *)v23 + 200LL);
v25 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v19 + 200LL))(v19);
v26 = (cocos2d *)v24(v23);
v28 = cocos2d::ccpDistance(v26, v25, v27);
v29 = *(_QWORD *)((char *)v12 - 20);
v30 = *(__int64 (__fastcall **)(__int64))(*(_QWORD *)v29 + 200LL);
v31 = (const struct cocos2d::CCPoint *)(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v19 + 200LL))(v19);
v32 = (const struct cocos2d::CCPoint *)v30(v29);
cocos2d::CCDrawNode::drawArchLikeHalfCircle(
a4,
v32,
v31,
90.0,
(int)fminf((float)(v28 / 30.0) + 20.0, 100.0),
v12,
1.0);
goto LABEL_17;
}
while ( v20 != *(_QWORD *)(v85
+ 16
* (v87
& (0x100000001B3LL
* (*((unsigned __int8 *)v12 - 1)
^ (0x100000001B3LL
* (*((unsigned __int8 *)v12 - 2)
^ (0x100000001B3LL
* (*((unsigned __int8 *)v12 - 3)
^ (0x100000001B3LL * (*((unsigned __int8 *)v12 - 4) ^ 0xCBF29CE484222325uLL)))))))))) )
{
v20 = *(_QWORD *)(v20 + 8);
if ( v21 == *(_DWORD *)(v20 + 16) )
goto LABEL_12;
}
}
v20 = 0;
goto LABEL_12;
}
LABEL_21:
sub_14003EA90(&v91);
sub_14003EB00(v90);
sub_14003EA90(&v85);
sub_1400665B0(v84);
}