//
// GameToolbox::pathSegmentCount from 0x3d07c0 to 0x3d08ae (238 bytes)
//
// 2 xrefs:
// > SetTextPopup::addPathLabel @ 0x5d5dbe
// > SFXBrowser::fitFolderPath @ 0x6c567a
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// 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:46:40 +0000
//
unsigned int __fastcall GameToolbox::pathSegmentCount(unsigned __int8 *a1, char *a2)
{
int v3; // r4
unsigned int v5; // r4
unsigned __int8 *v6; // r5
size_t v7; // r9
unsigned int v8; // r5
unsigned __int8 *v9; // r4
int v10; // r8
unsigned int v11; // r8
unsigned __int8 *v12; // r11
size_t v13; // r0
unsigned __int8 *v14; // r8
unsigned __int8 *v16[3]; // [sp+10h] [bp-Ch] BYREF
v3 = *a1;
if ( (v3 & 1) != 0 )
{
v5 = *((_DWORD *)a1 + 1);
if ( !v5 )
return v5;
v6 = *((unsigned __int8 **)a1 + 2);
v7 = strlen(a2);
}
else
{
v5 = v3 >> 1;
if ( !v5 )
return v5;
v6 = a1 + 1;
v7 = strlen(a2);
}
if ( v5 < v7 )
goto LABEL_7;
if ( v7 )
{
v9 = &v6[v5];
std::__search(
v16,
v6,
v9,
(unsigned __int8 *)a2,
(unsigned __int8 *)&a2[v7],
(int (__fastcall *)(int, _DWORD))std::char_traits::eq);
if ( v16[0] == v9 )
{
LABEL_7:
v8 = -1;
goto LABEL_12;
}
v8 = v16[0] - v6;
}
else
{
v8 = 0;
}
LABEL_12:
v5 = 1;
while ( v8 != -1 )
{
v10 = *a1;
v8 += v7;
++v5;
if ( (v10 & 1) != 0 )
{
v11 = *((_DWORD *)a1 + 1);
v12 = *((unsigned __int8 **)a1 + 2);
}
else
{
v11 = v10 >> 1;
v12 = a1 + 1;
}
v13 = strlen(a2);
if ( v8 > v11 || v11 - v8 < v13 )
break;
if ( v13 )
{
v14 = &v12[v11];
std::__search(
v16,
&v12[v8],
v14,
(unsigned __int8 *)a2,
(unsigned __int8 *)&a2[v13],
(int (__fastcall *)(int, _DWORD))std::char_traits::eq);
if ( v16[0] == v14 )
return v5;
v8 = v16[0] - v12;
}
}
return v5;
}