//
// sub_810040 from 0x810040 to 0x8100f6 (182 bytes)
//
// 1 xrefs:
// > sub_81406C @ 0x814b1a
//
// 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:01:36 +0000
//
_BYTE *__fastcall sub_810040(_BYTE *a1)
{
_BYTE *v2; // r1
int v3; // r3
unsigned int v4; // r0
_BYTE *v5; // r3
int v7; // t1
unsigned int v8; // r0
_BYTE *v9; // r3
int v10; // t1
_BYTE *v11; // [sp+4h] [bp-14h] BYREF
_DWORD v12[2]; // [sp+Ch] [bp-Ch] BYREF
v11 = a1;
v12[0] = 0;
v12[1] = 0;
while ( 1 )
{
while ( 1 )
{
v2 = v11;
v3 = (unsigned __int8)*v11;
if ( (a7[v3] & 1) == 0 )
goto LABEL_3;
if ( v3 == 60 )
{
v4 = sub_80FCC2((int)v12, (int)v11);
do
{
v5 = (_BYTE *)v4;
if ( v4 <= (unsigned int)a1 )
break;
v7 = *(unsigned __int8 *)--v4;
}
while ( (a7[v7] & 8) != 0 );
*v5 = 0;
return v11 + 1;
}
if ( v3 != 13 )
break;
++v11;
*v2 = 10;
if ( *v11 == 10 )
sub_80FE34(v12, &v11, 1);
}
if ( !*v11 )
break;
LABEL_3:
++v11;
}
v8 = sub_80FCC2((int)v12, (int)v11);
do
{
v9 = (_BYTE *)v8;
if ( v8 <= (unsigned int)a1 )
break;
v10 = *(unsigned __int8 *)--v8;
}
while ( (a7[v10] & 8) != 0 );
*v9 = 0;
return v11;
}