//
// cocos2d::extension::CCTableView::_indexFromOffset from 0x10041a1e0 to 0x10041a2f5 (277 bytes)
//
// 3 xrefs:
// > cocos2d::extension::CCTableView::scrollViewDidScroll @ 0x10041a466
// > cocos2d::extension::CCTableView::scrollViewDidScroll @ 0x10041a507
// > cocos2d::extension::CCTableView::ccTouchBegan @ 0x10041a806
//
// 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 12:30:12 +0000
//
__int64 __fastcall cocos2d::extension::CCTableView::_indexFromOffset(__int64 a1, __int64 a2)
{
__int64 v2; // rax
int v3; // ebx
__int64 Container; // rax
int v5; // eax
__int64 v6; // rcx
int v7; // eax
float v8; // xmm0_4
__int64 v9; // rdx
int v10; // ecx
int v11; // edi
int v12; // esi
float v13; // xmm1_4
__int64 result; // rax
int v15; // ebx
int v16; // ecx
_QWORD v17[4]; // [rsp+0h] [rbp-20h] BYREF
v17[0] = v2;
v3 = (*(__int64 (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 640) + 40LL))(*(_QWORD *)(a1 + 640), a1);
if ( !*(_DWORD *)(a1 + 584) )
{
Container = cocos2d::extension::CCScrollView::getContainer(a1);
*(float *)(a2 + 4) = *(float *)((*(__int64 (__fastcall **)(__int64))(*(_QWORD *)Container + 328LL))(Container) + 4)
- *(float *)(a2 + 4);
}
sub_1002782D0(v17, (_QWORD *)a2);
v5 = (*(__int64 (__fastcall **)(_QWORD, __int64))(**(_QWORD **)(a1 + 640) + 40LL))(*(_QWORD *)(a1 + 640), a1);
v6 = 0;
v7 = v5 - 1;
if ( v7 < 0 )
{
v12 = 0;
}
else
{
LOBYTE(v6) = *(_DWORD *)(a1 + 424) != 0;
v8 = *((float *)v17 + v6);
v9 = *(_QWORD *)(a1 + 600);
v10 = 0;
while ( 1 )
{
v11 = (v7 - v10) / 2;
v12 = v11 + v10;
v13 = *(float *)(v9 + 4LL * (v11 + v10));
if ( v8 >= v13 && *(float *)(v9 + 4LL * v12 + 4) >= v8 )
break;
if ( v13 <= v8 )
{
v10 += v11 + 1;
if ( v7 < v10 )
goto LABEL_10;
}
else
{
v7 = v12 - 1;
if ( v12 - 1 < v10 )
{
LABEL_10:
v12 = -(v10 > 0);
break;
}
}
}
if ( v12 == -1 )
return 0xFFFFFFFFLL;
}
v15 = v3 - 1;
v16 = 0;
if ( v12 > 0 )
v16 = v12;
result = 0xFFFFFFFFLL;
if ( v16 <= v15 )
return (unsigned int)v16;
return result;
}