//
// sub_1800223A0 from 0x1800223a0 to 0x180022455 (181 bytes)
//
// 2 xrefs:
// > ??> @ 0x1800ed0b8
// > ??> @ 0x1801b8f8c
//
// 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:21:28 +0000
//
__int64 __fastcall sub_1800223A0(__int64 a1, char *a2, signed __int64 a3)
{
signed __int64 v3; // rbx
__int64 v8; // rax
size_t v9; // rbp
void *v10; // rax
FILE *v11; // r9
v3 = a3;
if ( *(_QWORD *)(a1 + 104) )
return std::streambuf::xsputn();
v8 = std::streambuf::_Pnavail();
v9 = v8;
if ( v3 > 0 )
{
if ( v8 <= 0 )
goto LABEL_8;
if ( v3 < v8 )
v9 = v3;
v10 = (void *)std::streambuf::pptr(a1);
memcpy(v10, a2, v9);
v3 -= v9;
std::streambuf::pbump(a1, (unsigned int)v9);
a2 += v9;
if ( v3 > 0 )
{
LABEL_8:
v11 = *(FILE **)(a1 + 128);
if ( v11 )
v3 -= fwrite(a2, 1u, v3, v11);
}
}
return a3 - v3;
}