//
// sub_180020C20 from 0x180020c20 to 0x180020cfc (220 bytes)
//
// 4 xrefs:
// > ??> @ 0x1800e7070
// > ??> @ 0x180133b68
// > ??> @ 0x180133b78
// > ??> @ 0x1801aed7c
//
// 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_180020C20(__int64 a1, char *a2, size_t a3)
{
bool v5; // zf
int v6; // r8d
FILE *v7; // rcx
FILE *v8; // rdi
int *Count; // [rsp+60h] [rbp+8h] BYREF
char **Pointer; // [rsp+68h] [rbp+10h] BYREF
char **Base; // [rsp+70h] [rbp+18h] BYREF
if ( a2 || (v5 = a3 == 0, v6 = 4, !v5) )
v6 = 0;
v7 = *(FILE **)(a1 + 128);
if ( !v7 || setvbuf(v7, a2, v6, a3) )
return 0;
v8 = *(FILE **)(a1 + 128);
*(_BYTE *)(a1 + 124) = 1;
*(_BYTE *)(a1 + 113) = 0;
std::streambuf::_Init(a1);
if ( v8 )
{
Base = nullptr;
Pointer = nullptr;
Count = nullptr;
get_stream_buffer_pointers(v8, &Base, &Pointer, &Count);
std::streambuf::_Init(a1);
}
*(_QWORD *)(a1 + 128) = v8;
*(_QWORD *)(a1 + 116) = qword_1801A8360;
*(_QWORD *)(a1 + 104) = 0;
return a1;
}