//
// sub_A86B00 from 0xa86b00 to 0xa86d90 (656 bytes)
//
// 4 xrefs:
// > GJChestSprite::switchToState @ 0xa86ed4
// > GJChestSprite::switchToState @ 0xa86f24
// > GJChestSprite::switchToState @ 0xa8720c
// > GJChestSprite::switchToState @ 0xa8725c
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:00:35 +0000
//
__int64 *__usercall sub_A86B00@(char *a1@, char *a2@, __int64 *a3@)
{
__int64 v6; // x1
size_t v7; // x0
size_t v8; // x0
unsigned __int8 v9; // w1
size_t v10; // x0
unsigned __int8 v11; // w4
unsigned __int8 v12; // w2
char *v13; // x7
unsigned __int64 v14; // x1
int v15; // w5
unsigned __int8 *v16; // x8
unsigned __int64 v17; // x3
size_t v18; // x24
size_t v19; // x2
char *v20; // x3
size_t v21; // x4
size_t v22; // x2
char *v24; // x0
char *v25; // x1
char *v26; // x12
char *v27; // x0
unsigned __int8 *v28; // x3
char *v29; // x24
char *v30; // x13
unsigned __int8 *v31; // x6
char *v32; // x9
int v33; // t1
__int64 v34; // [xsp+48h] [xbp+48h] BYREF
size_t v35; // [xsp+50h] [xbp+50h]
void *v36; // [xsp+58h] [xbp+58h]
__int64 v37; // [xsp+60h] [xbp+60h] BYREF
size_t v38; // [xsp+68h] [xbp+68h]
void *v39; // [xsp+70h] [xbp+70h]
__int64 v40; // [xsp+78h] [xbp+78h]
a3[1] = 0;
v6 = _stack_chk_guard;
a3[2] = 0;
*a3 = 0;
v40 = v6;
v7 = strlen(a1);
std::string::__init(a3, a1, v7);
v34 = 0;
v35 = 0;
v36 = nullptr;
std::string::__init(&v34, "_001", 4u);
v37 = 0;
v38 = 0;
v39 = nullptr;
v8 = strlen(a2);
std::string::__init(&v37, a2, v8);
v9 = *(_BYTE *)a3;
v10 = 0;
v11 = v37;
if ( (*(_BYTE *)a3 & 1) == 0 )
goto LABEL_14;
LABEL_2:
v12 = v34;
v13 = (char *)a3[2];
v14 = a3[1];
v15 = v34 & 1;
if ( v15 )
{
LABEL_3:
v16 = (unsigned __int8 *)v36;
v17 = v35;
if ( v10 <= v14 )
goto LABEL_4;
}
else
{
while ( 1 )
{
v17 = v12 >> 1;
v16 = (unsigned __int8 *)&v34 + 1;
if ( v10 > v14 )
break;
LABEL_4:
if ( v14 - v10 < v17 )
break;
v18 = v10;
if ( v17 )
{
v24 = &v13[v10];
v25 = &v13[v14];
if ( (__int64)v17 > v25 - v24 )
break;
v26 = &v25[1 - v17];
if ( v24 == v26 )
break;
v27 = v24 + 1;
v28 = &v16[v17];
do
{
v29 = v27 - 1;
v30 = v27;
if ( (unsigned __int8)*(v27 - 1) == *v16 )
{
v31 = v16;
v32 = v27 - 1;
while ( ++v31 != v28 )
{
v33 = (unsigned __int8)*++v32;
if ( v33 != *v31 )
goto LABEL_31;
}
if ( v25 != v29 )
{
v18 = v29 - v13;
goto LABEL_6;
}
goto LABEL_16;
}
LABEL_31:
++v27;
}
while ( v26 != v30 );
if ( (v11 & 1) == 0 )
goto LABEL_17;
goto LABEL_30;
}
LABEL_6:
if ( v18 == -1 )
break;
v19 = v12 >> 1;
if ( v15 )
v19 = v35;
if ( (v11 & 1) != 0 )
{
v20 = (char *)v39;
v21 = v38;
}
else
{
v21 = v11 >> 1;
v20 = (char *)&v37 + 1;
}
std::string::replace(a3, v18, v19, v20, v21);
v11 = v37;
v22 = (unsigned __int8)v37 >> 1;
if ( (v37 & 1) != 0 )
v22 = v38;
v9 = *(_BYTE *)a3;
v10 = v22 + v18;
if ( (*(_BYTE *)a3 & 1) != 0 )
goto LABEL_2;
LABEL_14:
v12 = v34;
v13 = (char *)a3 + 1;
v14 = v9 >> 1;
v15 = v34 & 1;
if ( v15 )
goto LABEL_3;
}
}
LABEL_16:
if ( (v11 & 1) != 0 )
{
LABEL_30:
operator delete(v39);
v15 = v34 & 1;
}
LABEL_17:
if ( v15 )
operator delete(v36);
return a3;
}