//
// _fputwc_nolock from 0x18013831c to 0x180138497 (379 bytes)
//
// 7 xrefs:
// > __crt_stdio_output::write_multiple_characters<__crt_stdio_output::stream_output_adapter,char> @ 0x18012c184
// > __crt_stdio_output::output_processor,__crt_stdio_output::standard_base>>::process @ 0x18012caf7
// > unknown_libname_57 @ 0x18012eec7
// > __crt_stdio_output::output_adapter_common>::write_string_impl @ 0x18012f1e6
// > __crt_stdio_output::output_adapter_common>::write_string_impl @ 0x18012f22a
// > ??> @ 0x180203638
// > ??> @ 0x180203644
//
// 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
//
wint_t __cdecl fputwc_nolock(wchar_t Character, FILE *Stream)
{
FILE *v2; // rdi
unsigned int v3; // esi
bool v4; // sf
char *v5; // rbp
__int64 v6; // rbx
_BYTE *v7; // rdx
__int64 v8; // rbx
int v9; // ebx
char *i; // rbp
int SizeConverted; // [rsp+20h] [rbp-38h] BYREF
char MbCh[12]; // [rsp+24h] [rbp-34h] BYREF
v2 = Stream;
v3 = Character;
if ( (HIDWORD(Stream->_base) & 0x1000) == 0 )
{
v5 = (char *)&unk_1801B19F0;
if ( fileno(Stream) == -1 || fileno(v2) == -2 )
{
v7 = &unk_1801B19F0;
}
else
{
v6 = (__int64)fileno(v2) >> 6;
v7 = (_BYTE *)(qword_1801F5160[v6] + 72LL * (fileno(v2) & 0x3F));
}
if ( (unsigned __int8)(v7[57] - 1) > 1u )
{
if ( fileno(v2) != -1 && fileno(v2) != -2 )
{
v8 = (__int64)fileno(v2) >> 6;
v5 = (char *)(qword_1801F5160[v8] + 72LL * (fileno(v2) & 0x3F));
}
v9 = 0;
if ( v5[56] < 0 )
{
if ( !wctomb_s(&SizeConverted, MbCh, 5u, v3) )
{
if ( SizeConverted <= 0 )
return v3;
for ( i = MbCh; (unsigned int)unknown_libname_68((unsigned int)*i, v2) != -1; ++i )
{
if ( ++v9 >= SizeConverted )
return v3;
}
}
return -1;
}
}
v4 = LODWORD(v2->_base) - 2 < 0;
LODWORD(v2->_base) -= 2;
if ( !v4 )
{
*(_WORD *)v2->_ptr = v3;
v2->_ptr += 2;
return v3;
}
Stream = v2;
return unknown_libname_73(v3, Stream);
}
v4 = LODWORD(Stream->_base) - 2 < 0;
LODWORD(Stream->_base) -= 2;
if ( v4 )
return unknown_libname_73(v3, Stream);
*(_WORD *)Stream->_ptr = Character;
Stream->_ptr += 2;
return v3;
}