//
// cocos2d::CCFileUtils::getPathForFilename from 0xb05278 to 0xb055c0 (840 bytes)
//
// 3 xrefs:
// > ??> @ 0x83d90
// > ??> @ 0x1217b70
// > ??> @ 0x1218030
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __usercall cocos2d::CCFileUtils::getPathForFilename@(
__int64 a1@,
_QWORD *a2@,
__int64 a3@,
__int64 a4@)
{
__int64 v8; // x0
void *v9; // x0
unsigned __int64 v10; // x4
unsigned __int64 v11; // x3
void *v12; // x0
void *v13; // x0
void *v14; // x0
void *v15; // x0
unsigned int *v17; // x1
int v18; // w2
unsigned int *v19; // x1
int v20; // w2
unsigned int *v21; // x1
int v22; // w2
unsigned int *v23; // x1
int v24; // w2
unsigned int *v25; // x1
int v26; // w2
__int64 v27; // [xsp+68h] [xbp+68h]
__int64 v28; // [xsp+80h] [xbp+80h] BYREF
__int64 v29; // [xsp+88h] [xbp+88h] BYREF
__int64 v30; // [xsp+90h] [xbp+90h] BYREF
sub_D18D28(&v28);
sub_D153B8((int)&v29, &byte_F288A0);
v8 = sub_D16A88((int)a2, &word_F2A0A8, -1, 1u);
if ( v8 != -1 )
{
v27 = v8 + 1;
sub_D14F84(&v30, a2, 0, v8 + 1);
sub_D163D4(&v29, &v30);
v9 = (void *)(v30 - 24);
v10 = v27;
if ( (__int64 *)(v30 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v23 = (unsigned int *)(v30 - 8);
do
v24 = __ldaxr(v23);
while ( __stlxr(v24 - 1, v23) );
}
else
{
v24 = *(_DWORD *)(v30 - 8);
*(_DWORD *)(v30 - 8) = v24 - 1;
}
if ( v24 <= 0 )
{
operator delete(v9);
v10 = v27;
}
}
v11 = *(_QWORD *)(*a2 - 24LL);
if ( v10 > v11 )
sub_D13C5C("%s: __pos (which is %zu) > this->size() (which is %zu)", "basic_string::substr", v10, v11);
sub_D14F84(&v30, a2, v10, -1);
sub_D163D4(&v28, &v30);
v12 = (void *)(v30 - 24);
if ( (__int64 *)(v30 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v25 = (unsigned int *)(v30 - 8);
do
v26 = __ldaxr(v25);
while ( __stlxr(v26 - 1, v25) );
}
else
{
v26 = *(_DWORD *)(v30 - 8);
*(_DWORD *)(v30 - 8) = v26 - 1;
}
if ( v26 <= 0 )
operator delete(v12);
}
}
sub_D18D28(a4);
sub_D15E14(a4, &v29);
sub_D15E14(a4, a3);
(*(void (__fastcall **)(__int64 *__return_ptr, __int64, __int64, __int64 *))(*(_QWORD *)a1 + 232LL))(
&v30,
a1,
a4,
&v28);
sub_D163D4(a4, &v30);
v13 = (void *)(v30 - 24);
if ( (__int64 *)(v30 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v17 = (unsigned int *)(v30 - 8);
do
v18 = __ldaxr(v17);
while ( __stlxr(v18 - 1, v17) );
}
else
{
v18 = *(_DWORD *)(v30 - 8);
*(_DWORD *)(v30 - 8) = v18 - 1;
}
if ( v18 <= 0 )
operator delete(v13);
}
v14 = (void *)(v29 - 24);
if ( (__int64 *)(v29 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v19 = (unsigned int *)(v29 - 8);
do
v20 = __ldaxr(v19);
while ( __stlxr(v20 - 1, v19) );
}
else
{
v20 = *(_DWORD *)(v29 - 8);
*(_DWORD *)(v29 - 8) = v20 - 1;
}
if ( v20 <= 0 )
operator delete(v14);
}
v15 = (void *)(v28 - 24);
if ( (__int64 *)(v28 - 24) != &qword_124B6B0 )
{
if ( &pthread_create )
{
v21 = (unsigned int *)(v28 - 8);
do
v22 = __ldaxr(v21);
while ( __stlxr(v22 - 1, v21) );
}
else
{
v22 = *(_DWORD *)(v28 - 8);
*(_DWORD *)(v28 - 8) = v22 - 1;
}
if ( v22 <= 0 )
operator delete(v15);
}
return a4;
}