//
// sub_180021E90 from 0x180021e90 to 0x180021f45 (181 bytes)
//
// 2 xrefs:
// > ??> @ 0x1800e7058
// > ??> @ 0x1801aeea8
//
// 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
//
__int64 __fastcall sub_180021E90(__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);
a2 += v9;
v3 -= v9;
std::streambuf::pbump(a1, (unsigned int)v9);
if ( v3 > 0 )
{
LABEL_8:
v11 = *(FILE **)(a1 + 128);
if ( v11 )
v3 -= fwrite(a2, 1u, v3, v11);
}
}
return a3 - v3;
}