//
// LevelTools::timeForPos from 0x7319c8 to 0x732154 (1932 bytes)
//
// 4 xrefs:
// > PlayLayer::timeForPos @ 0x6f2bb0
// > DrawGridLayer::draw @ 0x7922a0
// > DrawGridLayer::timeForPos @ 0x79243c
// > ??> @ 0x48a00
//
// This function is hookable on this platform (idp: arm, 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 12:52:37 +0000
//
__int64 __fastcall LevelTools::timeForPos(
float *a1,
cocos2d::CCArray *a2,
unsigned int a3,
int a4,
int a5,
unsigned __int8 a6,
unsigned __int8 a7,
unsigned __int8 a8,
char a9,
int a10)
{
int v11; // w28
float v12; // s9
float v13; // s10
unsigned int *v15; // x1
__int64 *v16; // x21
__int64 v17; // x20
float v18; // s12
float v19; // s8
int v20; // w26
int v21; // w0
float v22; // s11
float v23; // s13
float v24; // s14
float v25; // s14
int v26; // w28
float v27; // s1
float v28; // s3
float v29; // s0
float v30; // s13
_QWORD **v31; // x19
int v32; // w0
float v33; // s1
float v34; // s0
float v35; // s1
float v36; // s0
int v37; // s0
long double v38; // q0
bool v39; // w1
int v40; // [xsp+A4h] [xbp+A4h]
int v44; // [xsp+BCh] [xbp+BCh]
__int64 *v45; // [xsp+D0h] [xbp+D0h]
int v46; // [xsp+D8h] [xbp+D8h]
int v47; // [xsp+DCh] [xbp+DCh]
unsigned int v48; // [xsp+E0h] [xbp+E0h]
int v49; // [xsp+114h] [xbp+114h] BYREF
float v50; // [xsp+118h] [xbp+118h] BYREF
float v51; // [xsp+11Ch] [xbp+11Ch]
float v52; // [xsp+120h] [xbp+120h] BYREF
_BYTE v53[4]; // [xsp+128h] [xbp+128h] BYREF
float v54; // [xsp+12Ch] [xbp+12Ch]
float v55; // [xsp+130h] [xbp+130h] BYREF
float v56; // [xsp+138h] [xbp+138h] BYREF
_BYTE v57[4]; // [xsp+140h] [xbp+140h] BYREF
float v58; // [xsp+144h] [xbp+144h]
_BYTE v59[4]; // [xsp+148h] [xbp+148h] BYREF
float v60; // [xsp+14Ch] [xbp+14Ch]
int *v61; // [xsp+150h] [xbp+150h] BYREF
int *v62; // [xsp+158h] [xbp+158h] BYREF
int *v63; // [xsp+160h] [xbp+160h] BYREF
int *v64; // [xsp+168h] [xbp+168h] BYREF
__int64 *v65; // [xsp+170h] [xbp+170h] BYREF
_QWORD v66[2]; // [xsp+178h] [xbp+178h] BYREF
v47 = a6;
v40 = a8;
v11 = a7;
if ( *a1 <= 0.0 )
return _stack_chk_guard;
v12 = a7 ? 311.58 : LevelTools::valueForSpeedMod((LevelTools *)a3);
v13 = 1.0;
byte_155C5A0 = 0;
byte_155C5A1 = 0;
dword_1548014 = 1.0;
if ( !a2 || v11 | ((unsigned int)cocos2d::CCArray::count(a2) == 0) )
return _stack_chk_guard;
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v50, (const cocos2d::CCPoint *)&unk_155C5A8);
v66[0] = 0;
v15 = *((unsigned int **)a2 + 7);
v66[1] = 0;
v65 = v66;
v49 = 0;
if ( *v15 )
{
v16 = *((__int64 **)v15 + 2);
v45 = &v16[*v15 - 1];
if ( v16 <= v45 )
{
v17 = *v16;
if ( *v16 )
{
v18 = 0.0;
v44 = 0;
while ( 1 )
{
v19 = v12 * v13;
if ( v47 || *(__int16 *)(v17 + 1782) != -3 )
break;
LABEL_39:
if ( v45 >= ++v16 )
{
v17 = *v16;
if ( *v16 )
continue;
}
v31 = (_QWORD **)v66[0];
goto LABEL_42;
}
v61 = &v49;
v46 = *(_DWORD *)(std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::__emplace_unique_key_args,std::tuple<>>(
&v65,
&v49,
(__int64)&unk_1122F80,
&v61)
+ 32);
v20 = *(_DWORD *)(v17 + 1772);
v62 = &v49;
if ( v20 > *(_DWORD *)(std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::__emplace_unique_key_args,std::tuple<>>(
&v65,
&v49,
(__int64)&unk_1122F80,
&v62)
+ 32) )
{
v63 = &v49;
*(_DWORD *)(std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::__emplace_unique_key_args,std::tuple<>>(
&v65,
&v49,
(__int64)&unk_1122F80,
&v63)
+ 32) = *(_DWORD *)(v17 + 1772);
}
if ( a10 > 0 )
{
v21 = v44;
if ( *(_DWORD *)(v17 + 916) == a10 )
v21 = 1;
v44 = v21;
}
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v64, (const cocos2d::CCPoint *)(v17 + 1784));
if ( *(float *)&v64 <= 0.0 )
{
v22 = 0.0 - v50;
}
else
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v52, (const cocos2d::CCPoint *)(v17 + 1784));
v22 = v52 - v50;
}
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v64, (const cocos2d::CCPoint *)(v17 + 1784));
if ( *((float *)&v64 + 1) <= 0.0 )
{
v23 = 0.0 - v51;
}
else
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v53, (const cocos2d::CCPoint *)(v17 + 1784));
v23 = v54 - v51;
}
v48 = (unsigned __int8)byte_155C5A0;
if ( byte_155C5A1 )
{
if ( !byte_155C5A0 )
{
if ( v22 < 0.0 )
goto LABEL_26;
goto LABEL_48;
}
if ( v23 <= 0.0 )
goto LABEL_81;
}
else
{
if ( !byte_155C5A0 )
{
if ( v22 > 0.0 )
{
LABEL_26:
v24 = fabsf(v22);
goto LABEL_27;
}
LABEL_48:
v22 = 0.0;
v25 = 0.0 / v19;
if ( v44 )
goto LABEL_49;
LABEL_28:
if ( v49 != a5 && a5 != -1 )
{
LABEL_30:
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v61, (const cocos2d::CCPoint *)&unk_155C5A8);
switch ( *(_WORD *)(v17 + 1782) )
{
case 0xFFFB:
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v62, (const cocos2d::CCPoint *)(v17 + 1900));
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v63, (const cocos2d::CCPoint *)(v17 + 1784));
cocos2d::CCPoint::operator-(&v64, &v62, &v63, v38);
cocos2d::CCPoint::operator=(&v61, &v64);
if ( *(_BYTE *)(v17 + 1889) )
{
v28 = 0.0;
LODWORD(v61) = 0;
}
else
{
v28 = *(float *)&v61;
}
if ( *(_BYTE *)(v17 + 1890) )
{
v27 = 0.0;
v26 = (unsigned __int8)byte_155C5A0;
HIDWORD(v61) = 0;
}
else
{
v27 = *((float *)&v61 + 1);
v26 = (unsigned __int8)byte_155C5A0;
}
break;
case 0xFFFC:
if ( *(_BYTE *)(v17 + 1861) )
{
v26 = (unsigned __int8)byte_155C5A0;
}
else
{
v26 = (unsigned int)(*(_DWORD *)(v17 + 1840) - 3) <= 1;
v39 = (*(_DWORD *)(v17 + 1844) & 0xFFFFFFFD) == 1;
byte_155C5A0 = (unsigned int)(*(_DWORD *)(v17 + 1840) - 3) <= 1;
byte_155C5A1 = v39;
}
if ( *(_BYTE *)(v17 + 1860) )
v49 = *(_DWORD *)(v17 + 1864);
v27 = *((float *)&v61 + 1);
v28 = *(float *)&v61;
break;
case 0xFFFD:
v27 = *((float *)&v61 + 1);
v26 = (unsigned __int8)byte_155C5A0;
v28 = *(float *)&v61;
break;
case 0xFFFE:
v37 = *(_DWORD *)(v17 + 1764);
v27 = *((float *)&v61 + 1);
v26 = (unsigned __int8)byte_155C5A0;
dword_1548014 = v37;
if ( v40 )
goto LABEL_32;
v28 = *(float *)&v61;
v13 = *(float *)&v37;
break;
case 0xFFFF:
v26 = (unsigned __int8)byte_155C5A0;
v27 = *((float *)&v61 + 1);
v28 = *(float *)&v61;
byte_155C5A1 ^= 1u;
break;
default:
v12 = LevelTools::valueForSpeedMod((LevelTools *)(unsigned int)*(__int16 *)(v17 + 1782));
v26 = (unsigned __int8)byte_155C5A0;
v27 = *((float *)&v61 + 1);
LABEL_32:
v28 = *(float *)&v61;
break;
}
v18 = v18 + v25;
v29 = v50;
if ( v48 <= (v26 ^ v48) )
v29 = v22 + v50;
if ( v26 != v48 || v48 )
v30 = v23 + v51;
else
v30 = v51;
v50 = v29 + v28;
v51 = v27 + v30;
goto LABEL_39;
}
if ( a4 > 0 )
{
v64 = &v49;
if ( a4 > *(_DWORD *)(std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::__emplace_unique_key_args,std::tuple<>>(
&v65,
&v49,
(__int64)&unk_1122F80,
&v64)
+ 32)
&& v46 != a4 )
{
goto LABEL_30;
}
v32 = (unsigned __int8)byte_155C5A0;
LABEL_50:
if ( v32 )
{
if ( a9 )
goto LABEL_30;
}
else
{
v33 = v50;
v34 = *a1;
if ( v50 <= *a1 )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v55, (const cocos2d::CCPoint *)(v17 + 1784));
v34 = *a1;
if ( v55 >= *a1 )
goto LABEL_58;
v33 = v50;
}
if ( v34 <= v33 )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)&v56, (const cocos2d::CCPoint *)(v17 + 1784));
if ( v56 <= *a1 )
goto LABEL_58;
}
if ( a9 || !byte_155C5A0 )
goto LABEL_30;
}
v35 = v51;
v36 = a1[1];
if ( v51 <= v36 )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v57, (const cocos2d::CCPoint *)(v17 + 1784));
v36 = a1[1];
if ( v58 >= v36 )
goto LABEL_58;
v35 = v51;
}
if ( v36 <= v35 )
{
cocos2d::CCPoint::CCPoint((cocos2d::CCPoint *)v59, (const cocos2d::CCPoint *)(v17 + 1784));
if ( v60 <= a1[1] )
{
LABEL_58:
v31 = (_QWORD **)v66[0];
goto LABEL_42;
}
}
goto LABEL_30;
}
LABEL_49:
v32 = (unsigned __int8)byte_155C5A0;
goto LABEL_50;
}
if ( v23 >= 0.0 )
{
LABEL_81:
v23 = 0.0;
v24 = 0.0;
LABEL_27:
v25 = v24 / v19;
if ( v44 )
goto LABEL_49;
goto LABEL_28;
}
}
v24 = fabsf(v23);
goto LABEL_27;
}
}
}
v31 = nullptr;
LABEL_42:
if ( v31 )
{
std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::destroy(
(__int64)&v65,
*v31);
std::__tree,std::__map_value_compare,std::less,true>,std::allocator>>::destroy(
(__int64)&v65,
*(_QWORD **)&byte_8[(_QWORD)v31]);
operator delete(v31);
}
return _stack_chk_guard;
}