//
// sub_18001C230 from 0x18001c230 to 0x18001c36f (319 bytes)
//
// 3 xrefs:
// > sub_180016A40 @ 0x180016b22
// > sub_180016B60 @ 0x180016c42
// > ??> @ 0x1801aead0
//
// 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=1
__int64 __fastcall sub_18001C230(__int64 a1, const char *a2, int a3, int a4)
{
FILE *v5; // rdi
__int64 v6; // rax
struct std::_Facet_base *v7; // rdi
void (__fastcall ***v8)(_QWORD, __int64); // rax
char **Pointer; // [rsp+40h] [rbp-28h] BYREF
char **Base; // [rsp+48h] [rbp-20h] BYREF
__int64 v12; // [rsp+50h] [rbp-18h]
int *Count; // [rsp+70h] [rbp+8h] BYREF
if ( *(_QWORD *)(a1 + 128) )
return 0;
v5 = std::_Fiopen(a2, a3, a4);
if ( !v5 )
return 0;
*(_BYTE *)(a1 + 124) = 1;
*(_BYTE *)(a1 + 113) = 0;
std::streambuf::_Init(a1);
Base = nullptr;
Pointer = nullptr;
Count = nullptr;
get_stream_buffer_pointers(v5, &Base, &Pointer, &Count);
std::streambuf::_Init(a1);
*(_QWORD *)(a1 + 128) = v5;
*(_QWORD *)(a1 + 116) = qword_1801A8360;
*(_QWORD *)(a1 + 104) = 0;
v6 = std::streambuf::getloc(a1, &Base);
v7 = sub_180016880(v6);
if ( std::codecvt_base::always_noconv(v7) )
{
*(_QWORD *)(a1 + 104) = 0;
}
else
{
*(_QWORD *)(a1 + 104) = v7;
std::streambuf::_Init(a1);
}
if ( v12 )
{
v8 = (void (__fastcall ***)(_QWORD, __int64))(*(__int64 (__fastcall **)(__int64))(*(_QWORD *)v12 + 16LL))(v12);
if ( v8 )
(**v8)(v8, 1);
}
return a1;
}