//
// sub_100556B58 from 0x100556b58 to 0x100556cf0 (408 bytes)
//
// 2 xrefs:
// > sub_100554D5C @ 0x100554fb4
// > sub_1005564D4 @ 0x100556644
//
// 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_100556B58(__int64 a1, __int64 a2)
{
size_t v3; // x20
__int64 v4; // x8
bool v5; // cc
__int64 result; // x0
__int64 v7; // x22
_QWORD *v8; // x23
__int64 v9; // x8
__int64 v10; // x9
int v11; // w8
v3 = *(_QWORD *)a1;
v4 = *(_QWORD *)(*(_QWORD *)a1 + 1264LL);
if ( v4 )
v5 = v4 < a2;
else
v5 = 0;
if ( v5 )
{
sub_100552734(*(_QWORD *)a1, "Maximum file size exceeded");
return 63;
}
v7 = *(_QWORD *)(v3 + 536);
*(_QWORD *)(v7 + 32) = a2;
v8 = (_QWORD *)(v3 + 35608);
v9 = *(_QWORD *)(v3 + 35608);
if ( v9 )
{
if ( a2 == -1 )
{
sub_1005524A4(v3, "ftp server doesn't support SIZE\n");
v10 = *(_QWORD *)(v7 + 32);
}
else
{
if ( (v9 & 0x8000000000000000LL) == 0 )
{
if ( v9 <= a2 )
{
v10 = a2 - v9;
*(_QWORD *)(v7 + 32) = a2 - v9;
goto LABEL_19;
}
LABEL_17:
sub_100552734(v3, "Offset (%ld) was beyond file size (%ld)", *(_QWORD *)(v3 + 35608), a2);
return 36;
}
v10 = -v9;
if ( a2 < -v9 )
goto LABEL_17;
*(_QWORD *)(v7 + 32) = v10;
*v8 = v9 + a2;
}
LABEL_19:
if ( v10 )
{
sub_1005524A4(v3, "Instructs server to resume from offset %ld\n", *v8);
result = sub_10057A8EC(a1 + 1336, "REST %ld", *v8);
if ( !(_DWORD)result )
{
result = 0;
v11 = 27;
goto LABEL_22;
}
}
else
{
sub_100567898(a1, 0xFFFFFFFFLL, -1, 0, 0, 0xFFFFFFFFLL, 0);
sub_1005524A4(v3, "File already completely downloaded\n");
*(_DWORD *)(v7 + 24) = 2;
*(_DWORD *)(a1 + 1512) = 0;
return 0;
}
return result;
}
result = sub_10057A8EC(a1 + 1336, "RETR %s", *(const char **)(a1 + 1472));
if ( !(_DWORD)result )
{
result = 0;
v11 = 32;
LABEL_22:
*(_DWORD *)(a1 + 1512) = v11;
}
return result;
}