//
// sub_18007E980 from 0x18007e980 to 0x18007eb23 (419 bytes)
//
// 2 xrefs:
// > sub_18007ECE0 @ 0x18007ed76
// > ??> @ 0x1801b4f44
//
// 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=6
__int64 __fastcall sub_18007E980(__int64 a1, _QWORD *a2, unsigned __int64 *a3)
{
unsigned int v6; // ebp
_QWORD *v7; // rdi
unsigned __int64 v8; // r15
_QWORD *v9; // r14
_QWORD *v10; // rax
_QWORD *v11; // rbx
char *v12; // rax
void *v13; // r14
char *v14; // rsi
_QWORD *i; // rbx
_QWORD *v16; // rbx
v6 = 0;
v7 = nullptr;
v8 = 0;
v9 = nullptr;
if ( std::ios_base::eof((std::ios_base *)(a1 + *(int *)(*(_QWORD *)a1 + 4LL))) )
{
LABEL_10:
v12 = (char *)off_1801A2FA0(v8 + 1);
v13 = v12;
if ( v12 )
{
v14 = v12;
for ( i = v7; i; i = (_QWORD *)*i )
{
memcpy(v14, i + 2, i[1]);
v14 += i[1];
}
*a2 = v13;
*a3 = v8;
}
else
{
LABEL_11:
v6 = 3;
}
}
else
{
while ( 1 )
{
v10 = off_1801A2FA0(0x8010u);
v11 = v10;
*v10 = 0;
v10[1] = 0;
if ( v9 )
*v9 = v10;
else
v7 = v10;
v9 = v10;
std::istream::read(a1, v10 + 2, 0x8000);
v11[1] = std::istream::gcount(a1);
if ( std::ios_base::bad((std::ios_base *)(a1 + *(int *)(*(_QWORD *)a1 + 4LL)))
|| !std::ios_base::eof((std::ios_base *)(a1 + *(int *)(*(_QWORD *)a1 + 4LL)))
&& std::ios_base::fail((std::ios_base *)(a1 + *(int *)(*(_QWORD *)a1 + 4LL))) )
{
break;
}
if ( v8 + v11[1] < v8 )
goto LABEL_11;
v8 += v11[1];
if ( std::ios_base::eof((std::ios_base *)(a1 + *(int *)(*(_QWORD *)a1 + 4LL))) )
goto LABEL_10;
}
v6 = 2;
}
if ( v7 )
{
do
{
v16 = (_QWORD *)*v7;
off_1801A2FA8(v7);
v7 = v16;
}
while ( v16 );
}
return v6;
}