//
// sub_1800A2680 from 0x1800a2680 to 0x1800a28be (574 bytes)
//
// 3 xrefs:
// > cocos2d::ZipUtils::urlDecode @ 0x1800a4976
// > cocos2d::ZipUtils::urlDecode @ 0x1800a4a67
// > ??> @ 0x1801b79f8
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
// Hidden C++ exception states: #wind=3
__int64 __fastcall sub_1800A2680(__int64 a1, unsigned __int8 a2)
{
__int64 v3; // rsi
unsigned int v4; // ebx
__int64 v5; // r15
__int64 v6; // rax
bool v7; // al
__int64 v8; // rax
__int64 v9; // r14
__int16 v10; // ax
__int64 v11; // r8
unsigned __int8 v12; // di
__int64 v13; // rcx
int v14; // eax
int v15; // ecx
__int64 v16; // rax
unsigned __int8 v17; // di
__int64 v18; // rax
int v19; // eax
int v20; // ecx
__int64 v21; // rax
unsigned int v25; // [rsp+70h] [rbp+18h]
v3 = a1;
v4 = 0;
v25 = 0;
v5 = a1;
v6 = std::ios::rdbuf(a1 + *(int *)(*(_QWORD *)a1 + 4LL));
if ( v6 )
(*(void (__fastcall **)(__int64))(*(_QWORD *)v6 + 8LL))(v6);
v7 = std::ios_base::good((std::ios_base *)(v3 + *(int *)(*(_QWORD *)v3 + 4LL)));
if ( v7 )
{
v8 = std::ios::tie(v3 + *(int *)(*(_QWORD *)v3 + 4LL));
if ( !v8 || v8 == v3 )
{
v7 = 1;
}
else
{
std::ostream::flush(v8);
v7 = std::ios_base::good((std::ios_base *)(v3 + *(int *)(*(_QWORD *)v3 + 4LL)));
}
}
if ( v7 )
{
if ( std::ios_base::width((std::ios_base *)(v3 + *(int *)(*(_QWORD *)v3 + 4LL))) > 1 )
v9 = std::ios_base::width((std::ios_base *)(v3 + *(int *)(*(_QWORD *)v3 + 4LL))) - 1;
else
v9 = 0;
v10 = std::ios_base::flags((std::ios_base *)(v3 + *(int *)(*(_QWORD *)v3 + 4LL)));
try
{
if ( (v10 & 0x1C0) == 0x40 )
{
LABEL_19:
v16 = std::ios::rdbuf(v3 + *(int *)(*(_QWORD *)v3 + 4LL));
if ( (unsigned int)std::streambuf::sputc(v16, a2) == -1 )
v4 = 4;
v25 = v4;
while ( !v4 && v9 > 0 )
{
v17 = std::ios::fill(v3 + *(int *)(*(_QWORD *)v3 + 4LL));
v18 = std::ios::rdbuf(v3 + *(int *)(*(_QWORD *)v3 + 4LL));
v19 = std::streambuf::sputc(v18, v17);
--v9;
v20 = 4;
if ( v19 != -1 )
v20 = 0;
v4 = v20;
v25 = v20;
}
}
else
{
while ( !v4 )
{
if ( v9 <= 0 )
goto LABEL_19;
v12 = std::ios::fill(v3 + *(int *)(*(_QWORD *)v3 + 4LL));
v13 = std::ios::rdbuf(v3 + *(int *)(*(_QWORD *)v3 + 4LL));
v14 = std::streambuf::sputc(v13, v12);
--v9;
v15 = 4;
if ( v14 != -1 )
v15 = 0;
v4 = v15;
v25 = v15;
}
}
}
catch ( ... )
{
LOBYTE(v11) = 1;
std::ios::setstate(a1 + *(int *)(*(_QWORD *)a1 + 4LL), 4, v11);
v3 = a1;
v4 = v25;
v5 = a1;
}
}
std::ios_base::width((std::ios_base *)(v3 + *(int *)(*(_QWORD *)v3 + 4LL)), 0);
std::ios::setstate(v3 + *(int *)(*(_QWORD *)v3 + 4LL), v4, 0);
if ( !std::uncaught_exception() )
std::ostream::_Osfx(v5);
v21 = std::ios::rdbuf(v5 + *(int *)(*(_QWORD *)v5 + 4LL));
if ( v21 )
(*(void (__fastcall **)(__int64))(*(_QWORD *)v21 + 16LL))(v21);
return v3;
}