//
// sub_805974 from 0x805974 to 0x805aac (312 bytes)
//
// 42 xrefs:
// > cocos2d::CCTMXMapInfo::startElement @ 0x806106
// > cocos2d::CCTMXMapInfo::startElement @ 0x806128
// > cocos2d::CCTMXMapInfo::startElement @ 0x8061e2
// > cocos2d::CCTMXMapInfo::startElement @ 0x8061fe
// > cocos2d::CCTMXMapInfo::startElement @ 0x806224
// > cocos2d::CCTMXMapInfo::startElement @ 0x806240
// > cocos2d::CCTMXMapInfo::startElement @ 0x8062aa
// > cocos2d::CCTMXMapInfo::startElement @ 0x806486
// > cocos2d::CCTMXMapInfo::startElement @ 0x8064bc
// > cocos2d::CCTMXMapInfo::startElement @ 0x8064d8
// > cocos2d::CCTMXMapInfo::startElement @ 0x8064f4
// > cocos2d::CCTMXMapInfo::startElement @ 0x806506
// > cocos2d::CCTMXMapInfo::startElement @ 0x80651e
// > cocos2d::CCTMXMapInfo::startElement @ 0x80653a
// > cocos2d::CCTMXMapInfo::startElement @ 0x8065c4
// > cocos2d::CCTMXMapInfo::startElement @ 0x806632
// > cocos2d::CCTMXMapInfo::startElement @ 0x80664e
// > cocos2d::CCTMXMapInfo::startElement @ 0x80666a
// > cocos2d::CCTMXMapInfo::startElement @ 0x806692
// > cocos2d::CCTMXMapInfo::startElement @ 0x8066e8
// > cocos2d::CCTMXMapInfo::startElement @ 0x806764
// > cocos2d::CCTMXMapInfo::startElement @ 0x806776
// > cocos2d::CCTMXMapInfo::startElement @ 0x8067fa
// > cocos2d::CCTMXMapInfo::startElement @ 0x806814
// > cocos2d::CCTMXMapInfo::startElement @ 0x806836
// > cocos2d::CCTMXMapInfo::startElement @ 0x8068c6
// > cocos2d::CCTMXMapInfo::startElement @ 0x806b48
// > cocos2d::CCTMXMapInfo::startElement @ 0x806b6a
// > cocos2d::CCTMXMapInfo::startElement @ 0x806ca4
// > cocos2d::CCTMXMapInfo::startElement @ 0x806cfe
// > cocos2d::CCTMXMapInfo::startElement @ 0x806d6c
// > cocos2d::CCTMXMapInfo::startElement @ 0x806da8
// > cocos2d::CCTMXMapInfo::startElement @ 0x806e58
// > cocos2d::CCTMXMapInfo::startElement @ 0x806e76
// > cocos2d::CCTMXMapInfo::startElement @ 0x806ef2
// > cocos2d::CCTMXMapInfo::startElement @ 0x806f10
// > cocos2d::CCTMXMapInfo::startElement @ 0x806f94
// > cocos2d::CCTMXMapInfo::startElement @ 0x806fb0
// > cocos2d::CCTMXMapInfo::startElement @ 0x806fe6
// > cocos2d::CCTMXMapInfo::startElement @ 0x807010
// > cocos2d::CCTMXMapInfo::startElement @ 0x80701e
// > cocos2d::CCTMXMapInfo::startElement @ 0x8070ae
//
// 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:24 +0000
//
char *__fastcall sub_805974(const char *a1, int a2)
{
size_t v4; // r0
int *v5; // r5
int *v6; // r7
int *v7; // t1
char *v8; // r2
char *v9; // r10
size_t v10; // r3
unsigned int v11; // r8
int v12; // r6
int *v13; // r4
int v14; // r9
unsigned int v15; // r9
size_t v16; // r12
const void *v17; // r0
size_t v18; // r2
int v19; // r0
int *v20; // r2
int v21; // r5
unsigned int v22; // r5
const void *v23; // r1
size_t v24; // r2
int v25; // r0
void *v27; // [sp+0h] [bp-24h]
size_t v28; // [sp+8h] [bp-1Ch]
size_t v29; // [sp+Ch] [bp-18h]
int v30; // [sp+10h] [bp-14h] BYREF
size_t v31; // [sp+14h] [bp-10h]
void *v32; // [sp+18h] [bp-Ch]
if ( !a2 )
return (char *)&unk_B6B226;
v30 = 0;
v31 = 0;
v32 = nullptr;
v4 = strlen(a1);
std::string::__init(&v30, a1, v4);
v7 = *(int **)(a2 + 4);
v6 = (int *)(a2 + 4);
v5 = v7;
v8 = (char *)&v30 + 1;
v9 = (char *)v32;
v10 = v31;
v11 = (int)(unsigned __int8)v30 >> 1;
v12 = v30 & 1;
v13 = v6;
if ( v12 )
v8 = (char *)v32;
v27 = v8;
while ( v5 )
{
v14 = *((unsigned __int8 *)v5 + 16);
if ( (v14 & 1) != 0 )
{
v15 = v5[5];
if ( v12 )
v16 = v10;
else
v16 = v11;
v17 = (const void *)v5[6];
}
else
{
v15 = v14 >> 1;
if ( v12 )
v16 = v10;
else
v16 = v11;
v17 = (char *)v5 + 17;
}
v18 = v16;
if ( v16 >= v15 )
v18 = v15;
if ( v18 && (v29 = v10, v28 = v16, v19 = memcmp(v17, v27, v18), v16 = v28, v10 = v29, v19) )
{
if ( v19 >= 0 )
{
LABEL_22:
v20 = (int *)*v5;
goto LABEL_24;
}
}
else if ( v15 >= v16 )
{
goto LABEL_22;
}
v20 = (int *)v5[1];
v5 = v13;
LABEL_24:
v13 = v5;
v5 = v20;
}
if ( v13 == v6 )
goto LABEL_40;
v21 = *((unsigned __int8 *)v13 + 16);
if ( v12 )
v11 = v10;
if ( (v21 & 1) != 0 )
{
v22 = v13[5];
if ( !v12 )
v9 = (char *)&v30 + 1;
v23 = (const void *)v13[6];
}
else
{
v22 = v21 >> 1;
if ( !v12 )
v9 = (char *)&v30 + 1;
v23 = (char *)v13 + 17;
}
v24 = v22;
if ( v22 >= v11 )
v24 = v11;
if ( v24 && (v25 = memcmp(v9, v23, v24)) != 0 )
{
if ( v25 >= 0 )
goto LABEL_43;
LABEL_40:
std::string::~string((int)&v30);
return (char *)&unk_B6B226;
}
else
{
if ( v11 < v22 )
goto LABEL_40;
LABEL_43:
std::string::~string((int)&v30);
if ( (v13[7] & 1) != 0 )
return (char *)v13[9];
else
return (char *)v13 + 29;
}
}