//
// sub_978854 from 0x978854 to 0x978902 (174 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
//
int __fastcall sub_978854(unsigned __int8 *a1, unsigned __int8 *a2, unsigned int a3)
{
unsigned int v3; // r3
unsigned __int64 v4; // kr00_8
unsigned __int64 v5; // kr08_8
unsigned int v6; // r0
bool v7; // cf
int result; // r0
int v9; // r9
unsigned int v10; // r0
unsigned int v11; // lr
int v12; // r2
unsigned int v13; // r6
int v14; // r4
int v15; // r7
int v16; // r4
int v17; // r1
v3 = *a1;
if ( (v3 & 1) != 0 )
v4 = *(_QWORD *)(a1 + 4);
else
v4 = __PAIR64__((unsigned int)(a1 + 1), v3 >> 1);
v5 = *(_QWORD *)(a2 + 4);
v6 = *a2;
if ( (v6 & 1) == 0 )
v5 = __PAIR64__((unsigned int)(a2 + 1), v6 >> 1);
v7 = (unsigned int)v4 >= a3;
result = -1;
if ( (unsigned int)v4 >= a3 )
v7 = (unsigned int)v4 - a3 >= (unsigned int)v5;
if ( v7 )
{
if ( (_DWORD)v5 )
{
v9 = HIDWORD(v4) + v4;
v10 = HIDWORD(v4) + a3;
v11 = HIDWORD(v4) + v4;
if ( (int)(v4 - a3) >= (int)v5 )
{
v11 = HIDWORD(v4) + v4;
if ( 1 - (_DWORD)v5 + v9 != v10 )
{
v12 = v5 - HIDWORD(v4) - v4;
v13 = v10;
while ( 2 )
{
++v10;
while ( *(unsigned __int8 *)(v10 - 1) != (unsigned __int8)*(_BYTE *)HIDWORD(v5) )
{
v13 = v10;
v14 = ++v10 + v12;
if ( v14 == 2 )
goto LABEL_25;
}
v15 = 0;
do
{
if ( (_DWORD)v5 - 1 == v15 )
{
v11 = v13;
goto LABEL_25;
}
v16 = *(unsigned __int8 *)(HIDWORD(v5) + 1 + v15);
v17 = *(unsigned __int8 *)(v10 + v15++);
}
while ( v17 == v16 );
v13 = v10;
if ( v10 + v12 != 1 )
continue;
break;
}
}
}
LABEL_25:
result = v11 - HIDWORD(v4);
if ( v11 == v9 )
return -1;
}
else
{
return a3;
}
}
return result;
}