//
// sub_9789A0 from 0x9789a0 to 0x978a4c (172 bytes)
//
// 0 xrefs:
//
// 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:06:00 +0000
//
unsigned int __fastcall sub_9789A0(unsigned __int8 *a1, char *a2, unsigned int a3)
{
unsigned int v4; // r1
unsigned __int64 v6; // kr00_8
size_t v7; // r0
bool v8; // cf
int v9; // r1
int v10; // r9
unsigned int v11; // r1
unsigned int v12; // r12
size_t v13; // lr
int v14; // r5
int v15; // r3
char *v16; // r10
int v17; // t1
unsigned int v18; // r6
int v19; // r2
int v20; // r0
int v21; // r2
int v22; // r4
v4 = *a1;
if ( (v4 & 1) != 0 )
v6 = *(_QWORD *)(a1 + 4);
else
v6 = __PAIR64__((unsigned int)(a1 + 1), v4 >> 1);
v7 = strlen(a2);
v8 = (unsigned int)v6 >= a3;
v9 = -1;
if ( (unsigned int)v6 >= a3 )
v8 = (unsigned int)v6 - a3 >= v7;
if ( v8 )
{
if ( v7 )
{
v10 = HIDWORD(v6) + v6;
v11 = HIDWORD(v6) + a3;
v12 = HIDWORD(v6) + v6;
if ( (int)(v6 - a3) >= (int)v7 )
{
v12 = HIDWORD(v6) + v6;
if ( 1 - v7 + v10 != v11 )
{
v13 = v7 - 1;
v14 = v7 - HIDWORD(v6) - v6;
v17 = (unsigned __int8)*a2;
v16 = a2 + 1;
v15 = v17;
v18 = v11;
while ( 2 )
{
++v11;
while ( *(unsigned __int8 *)(v11 - 1) != v15 )
{
v18 = v11;
v19 = ++v11 + v14;
if ( v19 == 2 )
goto LABEL_23;
}
v20 = 0;
do
{
if ( v13 == v20 )
{
v12 = v18;
goto LABEL_23;
}
v21 = (unsigned __int8)v16[v20];
v22 = *(unsigned __int8 *)(v11 + v20++);
}
while ( v22 == v21 );
v18 = v11;
if ( v11 + v14 != 1 )
continue;
break;
}
}
}
LABEL_23:
v9 = v12 - HIDWORD(v6);
if ( v12 == v10 )
return -1;
}
else
{
return a3;
}
}
return v9;
}