//
// sub_100581C20 from 0x100581c20 to 0x100581e70 (592 bytes)
//
// 1 xrefs:
// > sub_10055CD64 @ 0x10055d41c
//
// 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
//
char *__fastcall sub_100581C20(const char *a1)
{
size_t v2; // x0
_BYTE *v3; // x19
char *v4; // x0
char *v5; // x20
char *v6; // x0
char *v7; // x23
_BYTE *v8; // x22
char *v9; // x24
int v10; // w8
int v11; // t1
int v12; // t1
int v13; // t1
const char *v14; // x21
size_t v15; // x0
v2 = strlen(a1);
v3 = off_10085DEB0(v2 + 1);
if ( !v3 )
return nullptr;
v4 = off_10085DEC8(a1);
v5 = v4;
if ( !v4 )
{
off_10085DEB8(v3);
return nullptr;
}
if ( !*v4 )
{
off_10085DEB8(v3);
return v5;
}
v6 = strchr(v4, 63);
v7 = v6;
v8 = v3;
v9 = v5;
if ( v6 )
{
*v6 = 0;
v8 = v3;
v9 = v5;
}
do
{
if ( !strncmp("./", v9, 2u) )
{
v9 += 2;
continue;
}
if ( !strncmp("../", v9, 3u) )
{
v9 += 3;
continue;
}
if ( !strncmp("/./", v9, 3u) )
{
v9 += 2;
continue;
}
if ( !strcmp("/.", v9) )
{
*++v9 = 47;
continue;
}
if ( !strncmp("/../", v9, 4u) )
{
v9 += 3;
do
{
if ( v8 <= v3 )
break;
v12 = (unsigned __int8)*--v8;
}
while ( v12 != 47 );
goto LABEL_29;
}
if ( !strcmp("/..", v9) )
{
v9[2] = 47;
v9 += 2;
do
{
if ( v8 <= v3 )
break;
v13 = (unsigned __int8)*--v8;
}
while ( v13 != 47 );
goto LABEL_29;
}
if ( strcmp(".", v9) && strcmp("..", v9) )
{
LOBYTE(v10) = *v9;
do
{
*v8++ = v10;
v11 = (unsigned __int8)*++v9;
v10 = v11;
}
while ( v11 && v10 != 47 );
LABEL_29:
*v8 = 0;
continue;
}
*v9 = 0;
}
while ( *v9 );
if ( v7 )
{
v14 = &a1[v7 - v5];
v15 = strlen(v14);
memcpy(v8, v14, v15 + 1);
}
off_10085DEB8(v5);
return v3;
}