//
// sub_140178A10 from 0x140178a10 to 0x140178afb (235 bytes)
//
// 7 xrefs:
// > sub_1401411E0 @ 0x14014121d
// > GJGameLevel::scoreStringToVector @ 0x14016d7d9
// > std::basic_stringbuf,std::allocator>::`scalar deleting destructor' @ 0x140178c3f
// > sub_140178C70 @ 0x140178cbc
// > sub_140491FC0 @ 0x1404923a5
// > ??> @ 0x1406cb0dc
// > ??> @ 0x1406cb0e8
//
// 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_140178A10(__int64 a1)
{
bool v1; // zf
_DWORD *v2; // rdi
__int64 **v4; // rbp
__int64 v5; // rcx
__int64 v6; // rdx
_QWORD *v7; // rcx
v1 = (*(_BYTE *)(a1 + 112) & 1) == 0;
v2 = (_DWORD *)(a1 + 112);
*(_QWORD *)a1 = &std::stringbuf::`vftable';
v4 = (__int64 **)(a1 + 64);
if ( !v1 )
{
v5 = **v4;
if ( v5 )
v6 = v5 + **(int **)(a1 + 88);
else
v6 = **(_QWORD **)(a1 + 56) + **(int **)(a1 + 80);
v7 = **(_QWORD ***)(a1 + 24);
if ( (unsigned __int64)(v6 - (_QWORD)v7) >= 0x1000 )
{
if ( (unsigned __int64)v7 - *(v7 - 1) - 8 > 0x1F )
invalid_parameter_noinfo_noreturn();
v7 = (_QWORD *)*(v7 - 1);
v4 = (__int64 **)(a1 + 64);
v2 = (_DWORD *)(a1 + 112);
}
j_j_free(v7);
}
**(_QWORD **)(a1 + 24) = 0;
**(_QWORD **)(a1 + 56) = 0;
**(_DWORD **)(a1 + 80) = 0;
**(_QWORD **)(a1 + 32) = 0;
**v4 = 0;
**(_DWORD **)(a1 + 88) = 0;
*v2 &= ~1u;
*(_QWORD *)(a1 + 104) = 0;
return std::streambuf::~streambuf>(a1);
}