//
// sub_1800B2040 from 0x1800b2040 to 0x1800b21de (414 bytes)
//
// 5 xrefs:
// > cocos2d::CCTMXMapInfo::startElement @ 0x1800b56c5
// > cocos2d::CCTMXMapInfo::startElement @ 0x1800b577b
// > cocos2d::CCTMXMapInfo::startElement @ 0x1800b585e
// > cocos2d::CCTMXMapInfo::startElement @ 0x1800b598a
// > ??> @ 0x1801c26b8
//
// This function is hookable on this platform (idp: pc, 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 11:22:20 +0000
//
// Hidden C++ exception states: #wind=3
__int64 __fastcall sub_1800B2040(__int64 a1, __int64 a2, unsigned __int8 a3)
{
int v3; // r15d
__int64 v5; // rdi
unsigned int v6; // ebx
char v7; // si
__int64 v8; // r12
__int64 v9; // rax
__int64 v10; // rdx
_BYTE *v11; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // r8
__int64 v15; // rax
int i; // eax
__int64 v17; // rax
unsigned int v19; // [rsp+20h] [rbp-48h]
char v22; // [rsp+88h] [rbp+20h]
v3 = a3;
v5 = a1;
v6 = 0;
v19 = 0;
v7 = 0;
v22 = 0;
v8 = a1;
v9 = std::ios::rdbuf(a1 + *(int *)(*(_QWORD *)a1 + 4LL));
if ( v9 )
(*(void (__fastcall **)(__int64))(*(_QWORD *)v9 + 8LL))(v9);
LOBYTE(v10) = 1;
if ( !(unsigned __int8)std::istream::_Ipfx(v5, v10) )
goto LABEL_16;
*(_QWORD *)(a2 + 16) = 0;
v11 = (_BYTE *)a2;
if ( *(_QWORD *)(a2 + 24) > 0xFu )
v11 = *(_BYTE **)a2;
*v11 = 0;
v12 = std::ios::rdbuf(v5 + *(int *)(*(_QWORD *)v5 + 4LL));
try
{
for ( i = std::streambuf::sgetc(v12); ; i = std::streambuf::snextc(v15) )
{
if ( i == -1 )
{
v6 = 1;
goto LABEL_13;
}
if ( i == v3 )
{
v7 = 1;
v22 = 1;
v13 = std::ios::rdbuf(v5 + *(int *)(*(_QWORD *)v5 + 4LL));
std::streambuf::sbumpc(v13);
goto LABEL_21;
}
if ( *(_QWORD *)(a2 + 16) >= 0x7FFFFFFFFFFFFFFFuLL )
break;
sub_180075910((void **)a2, i);
v7 = 1;
v22 = 1;
v15 = std::ios::rdbuf(v5 + *(int *)(*(_QWORD *)v5 + 4LL));
}
v6 = 2;
LABEL_13:
v19 = v6;
}
catch ( ... )
{
LOBYTE(v14) = 1;
std::ios::setstate(a1 + *(int *)(*(_QWORD *)a1 + 4LL), 4, v14);
v5 = a1;
v6 = v19;
v7 = v22;
v8 = a1;
}
LABEL_21:
if ( !v7 )
LABEL_16:
v6 |= 2u;
std::ios::setstate(v5 + *(int *)(*(_QWORD *)v5 + 4LL), v6, 0);
v17 = std::ios::rdbuf(v8 + *(int *)(*(_QWORD *)v8 + 4LL));
if ( v17 )
(*(void (__fastcall **)(__int64))(*(_QWORD *)v17 + 16LL))(v17);
return v5;
}