//
// sub_140179B40 from 0x140179b40 to 0x140179c97 (343 bytes)
//
// 5 xrefs:
// > GJGameLevel::scoreStringToVector @ 0x14016d6dd
// > GJGameLevel::scoreStringToVector @ 0x14016d741
// > sub_140491FC0 @ 0x14049203e
// > sub_140491FC0 @ 0x14049222b
// > ??> @ 0x1406cb1d8
//
// 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=3
__int64 __fastcall sub_140179B40(__int64 a1, __int64 a2)
{
__int64 v2; // r14
__int64 v3; // rdi
unsigned int v4; // ebx
char v5; // si
__int64 v6; // r15
__int64 v7; // rcx
_BYTE *v8; // rax
__int64 v9; // r8
int i; // eax
__int64 v11; // rcx
char v15; // [rsp+70h] [rbp+18h]
unsigned int v16; // [rsp+78h] [rbp+20h]
v2 = a2;
v3 = a1;
v4 = 0;
v16 = 0;
v5 = 0;
v15 = 0;
v6 = a1;
v7 = *(_QWORD *)(*(int *)(*(_QWORD *)a1 + 4LL) + a1 + 72);
if ( v7 )
(*(void (__fastcall **)(__int64))(*(_QWORD *)v7 + 8LL))(v7);
LOBYTE(a2) = 1;
if ( !(unsigned __int8)std::istream::_Ipfx(v3, a2) )
goto LABEL_15;
*(_QWORD *)(v2 + 16) = 0;
v8 = (_BYTE *)v2;
if ( *(_QWORD *)(v2 + 24) > 0xFu )
v8 = *(_BYTE **)v2;
try
{
*v8 = 0;
for ( i = std::streambuf::sgetc(*(_QWORD *)(*(int *)(*(_QWORD *)v3 + 4LL) + v3 + 72));
;
i = std::streambuf::snextc(*(_QWORD *)(*(int *)(*(_QWORD *)v3 + 4LL) + v3 + 72)) )
{
if ( i == -1 )
{
v4 = 1;
goto LABEL_12;
}
if ( i == 44 )
{
v5 = 1;
v15 = 1;
std::streambuf::sbumpc(*(_QWORD *)(*(int *)(*(_QWORD *)v3 + 4LL) + v3 + 72));
goto LABEL_20;
}
if ( *(_QWORD *)(v2 + 16) >= 0x7FFFFFFFFFFFFFFFuLL )
break;
sub_14003B190((void **)v2, i);
v5 = 1;
v15 = 1;
}
v4 = 2;
LABEL_12:
v16 = v4;
}
catch ( ... )
{
LOBYTE(v9) = 1;
std::ios::setstate(a1 + *(int *)(*(_QWORD *)a1 + 4LL), 4, v9);
v3 = a1;
v4 = v16;
v5 = v15;
v6 = a1;
}
LABEL_20:
if ( !v5 )
LABEL_15:
v4 |= 2u;
std::ios::setstate(v3 + *(int *)(*(_QWORD *)v3 + 4LL), v4, 0);
v11 = *(_QWORD *)(*(int *)(*(_QWORD *)v6 + 4LL) + v6 + 72);
if ( v11 )
(*(void (__fastcall **)(__int64))(*(_QWORD *)v11 + 16LL))(v11);
return v3;
}