//
// sub_846358 from 0x846358 to 0x84645c (260 bytes)
//
// 8 xrefs:
// > sub_8465F0 @ 0x8465fc
// > sub_8465F0 @ 0x846608
// > sub_846EF0 @ 0x84751c
// > sub_846EF0 @ 0x847830
// > sub_847974 @ 0x847efe
// > sub_847974 @ 0x847f0a
// > sub_847974 @ 0x848080
// > sub_847974 @ 0x84808c
//
// 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 12:02:24 +0000
//
char *__fastcall sub_846358(char *a1, int a2)
{
const char *v2; // r6
int v3; // r2
_BOOL4 v4; // r4
int v5; // r8
int v6; // r7
int v7; // r3
char *v8; // r5
int v9; // r4
int v10; // t1
int v11; // t1
size_t v12; // r7
char *v13; // r0
char *v14; // r4
int v15; // r3
bool v16; // zf
int v17; // t1
size_t v19; // r5
char *v20; // r0
char *v21; // r5
char v22[12]; // [sp+0h] [bp-Ch] BYREF
v2 = a1;
strcpy(v22, "(){ %*]");
if ( !a1 )
return nullptr;
v3 = (unsigned __int8)*a1;
if ( !*a1 )
return off_D200B8(v2);
v4 = 0;
v5 = 0;
v6 = 0;
do
{
if ( v3 == 92 )
{
++v6;
}
else if ( v3 == 34 )
{
++v5;
}
else if ( !a2 && v22[0] && !v4 )
{
v7 = (unsigned __int8)v22[0];
v8 = v22;
do
{
v9 = v3 - v7;
v10 = (unsigned __int8)*++v8;
v7 = v10;
v4 = v9 == 0;
}
while ( v10 && !v4 );
}
v11 = (unsigned __int8)*++a1;
v3 = v11;
}
while ( v11 );
if ( !(v6 | v5) )
{
if ( v4 )
{
v19 = strlen(v2);
goto LABEL_28;
}
return off_D200B8(v2);
}
v12 = v6 + v5 + strlen(v2);
if ( v4 )
{
v19 = v12;
LABEL_28:
v12 = v19 + 2;
v20 = (char *)off_D200AC(v19 + 3);
v14 = v20;
if ( v20 )
{
v21 = &v20[v19];
v13 = v20 + 1;
*v14 = 34;
v21[1] = 34;
goto LABEL_19;
}
return nullptr;
}
v13 = (char *)off_D200AC(v12 + 1);
if ( !v13 )
return nullptr;
v14 = v13;
LABEL_19:
v15 = *(unsigned __int8 *)v2;
if ( *v2 )
{
do
{
v16 = v15 == 92;
if ( v15 != 92 )
v16 = v15 == 34;
if ( v16 )
*v13++ = 92;
*v13++ = *v2;
v17 = *(unsigned __int8 *)++v2;
v15 = v17;
}
while ( v17 );
}
v14[v12] = 0;
return v14;
}