//
// sub_B82270 from 0xb82270 to 0xb8256c (764 bytes)
//
// 2 xrefs:
// > sub_B828FC @ 0xb82998
// > sub_B87DB4 @ 0xb8853c
//
// 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 __fastcall sub_B82270(char *a1, size_t a2, void **a3, void **a4, void **a5)
{
char *v10; // x22
char *v11; // x20
char *v12; // x0
char *v13; // x19
size_t v14; // x28
size_t v15; // d8
char *v16; // x21
void *v17; // x27
void *v18; // x23
void **v19; // x22
_BOOL4 v21; // w0
if ( !a4 || (v10 = &a1[a2], v11 = strchr(a1, 58), v11 >= v10) )
{
if ( !a5 )
{
v14 = a2;
v13 = nullptr;
goto LABEL_47;
}
v13 = strchr(a1, 59);
if ( v13 < &a1[a2] )
goto LABEL_34;
LABEL_49:
v14 = a2;
v13 = nullptr;
goto LABEL_47;
}
if ( !a5 || (v12 = strchr(a1, 59), v13 = v12, v12 >= v10) )
{
if ( v11 )
{
v21 = 0;
v13 = nullptr;
v14 = v11 - a1;
goto LABEL_29;
}
goto LABEL_49;
}
if ( !v11 )
{
LABEL_34:
v14 = v13 - a1;
if ( !v13 )
v14 = a2;
LABEL_47:
v11 = nullptr;
v15 = 0;
if ( v13 )
goto LABEL_10;
goto LABEL_31;
}
if ( v11 <= v12 || !v12 )
{
v14 = v11 - a1;
v21 = v12 != nullptr && v11 < v12;
LABEL_29:
if ( v21 )
goto LABEL_9;
goto LABEL_30;
}
v14 = v12 - a1;
if ( v11 >= v12 )
{
LABEL_30:
v15 = v10 - v11 - 1;
if ( v13 )
goto LABEL_10;
LABEL_31:
v16 = v13;
goto LABEL_13;
}
LABEL_9:
v15 = v13 - v11 - 1;
LABEL_10:
if ( v11 > v13 && v11 )
v16 = (char *)(v11 - v13 - 1);
else
v16 = (char *)(&a1[a2] - v13 - 1);
LABEL_13:
if ( v14 && a3 )
{
v17 = off_1231000(v14 + 1);
if ( !v17 )
return 27;
}
else
{
v17 = nullptr;
}
if ( !a4 )
{
v18 = nullptr;
if ( !a5 )
{
if ( !v17 )
return 0;
v18 = nullptr;
v19 = nullptr;
goto LABEL_21;
}
LABEL_19:
v19 = nullptr;
if ( v16 )
{
v19 = (void **)off_1231000((size_t)(v16 + 1));
if ( !v19 )
{
off_1231008(v18);
off_1231008(v17);
return 27;
}
}
LABEL_20:
if ( !v17 )
{
LABEL_22:
if ( v18 )
{
memcpy(v18, v11 + 1, v15);
*((_BYTE *)v18 + v15) = 0;
off_1231008(*a4);
*a4 = v18;
}
if ( v19 )
{
memcpy(v19, v13 + 1, (size_t)v16);
v16[(_QWORD)v19] = 0;
off_1231008(*a5);
*a5 = v19;
}
return 0;
}
LABEL_21:
memcpy(v17, a1, v14);
*((_BYTE *)v17 + v14) = 0;
off_1231008(*a3);
*a3 = v17;
goto LABEL_22;
}
v18 = nullptr;
if ( !v15 || (v18 = off_1231000(v15 + 1)) != nullptr )
{
v19 = a5;
if ( !a5 )
goto LABEL_20;
goto LABEL_19;
}
off_1231008(v17);
return 27;
}