//
// sub_100554D5C from 0x100554d5c to 0x100556228 (5324 bytes)
//
// 1 xrefs:
// > sub_1005547D8 @ 0x100554804
//
// 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_100554D5C(__int64 a1)
{
__int64 v2; // x0
__int64 v3; // x23
__int64 v5; // x26
size_t v6; // x24
__int64 v7; // x0
__int64 v8; // x21
int v9; // w22
int v10; // w21
__int64 v11; // x23
__int64 v12; // x22
__int64 v13; // x0
__int64 v14; // x1
size_t v15; // x20
__int64 v16; // x8
__int64 v17; // x8
__int64 v18; // x22
__int64 v19; // x23
unsigned int v21; // w8
__int64 v22; // x8
__int64 v23; // x8
unsigned int v24; // w8
char *v25; // x0
char *v26; // x22
unsigned __int64 v27; // x8
int v28; // w10
int v29; // t1
char *v30; // x9
char *v31; // x0
unsigned __int8 *v32; // x8
unsigned __int8 v33; // w9
int v34; // t1
__int64 v35; // x10
void (__cdecl *v36)(void *); // x8
int v37; // w8
int v38; // w8
size_t v39; // x20
__int64 v40; // x23
size_t v41; // x0
int v42; // w8
__int64 v43; // x1
int v44; // w8
__int64 v45; // x21
const char *v46; // x23
int v47; // w8
char *v48; // x0
size_t v49; // x20
int v50; // w8
__int64 v52; // x0
__int64 v53; // x8
int v55; // w8
const char *v56; // x8
unsigned int v57; // w9
char *v58; // x0
char *v59; // x8
size_t v60; // x9
char *v61; // x10
int v62; // w8
__int64 v63; // x23
char *v64; // x0
const char *v65; // x0
int v66; // w22
int v67; // w8
__int64 v68; // x9
__int64 v69; // x10
char *v70; // x8
__int64 v71; // x24
size_t v72; // x0
const char *v73; // x20
int v74; // w10
int v75; // t1
__int64 v76; // [xsp+0h] [xbp-1E0h]
__int64 v77; // [xsp+48h] [xbp-198h] BYREF
int v78; // [xsp+50h] [xbp-190h] BYREF
int v79; // [xsp+54h] [xbp-18Ch] BYREF
int v80; // [xsp+58h] [xbp-188h] BYREF
unsigned int v81; // [xsp+5Ch] [xbp-184h] BYREF
__int64 *v82; // [xsp+60h] [xbp-180h] BYREF
int v83; // [xsp+68h] [xbp-178h] BYREF
__int16 v84; // [xsp+6Ch] [xbp-174h] BYREF
time_t v85; // [xsp+70h] [xbp-170h] BYREF
int v86; // [xsp+78h] [xbp-168h] BYREF
int v87; // [xsp+7Ch] [xbp-164h] BYREF
_BYTE __s[24]; // [xsp+80h] [xbp-160h] BYREF
int v89; // [xsp+98h] [xbp-148h]
v2 = *(unsigned int *)(a1 + 464);
v3 = *(_QWORD *)a1;
v77 = 0;
if ( *(_QWORD *)(a1 + 1384) )
return sub_10057ABFC(a1 + 1336);
v5 = *(_QWORD *)(a1 + 1424);
v6 = *(_QWORD *)v5;
v7 = sub_10057A914(v2, a1 + 1336, __s, &v77);
v8 = v7;
*(_DWORD *)(v6 + 35744) = *(_DWORD *)__s;
v9 = *(_DWORD *)__s;
if ( *(_DWORD *)__s == 421 )
{
sub_1005524A4(v6, "We got a 421 - timeout!\n");
*(_DWORD *)(v5 + 1512) = 0;
return 28;
}
if ( (_DWORD)v7 )
return v8;
if ( !*(_DWORD *)__s )
return 0;
v10 = *(_DWORD *)(a1 + 1512);
switch ( v10 )
{
case 1:
if ( *(_DWORD *)__s != 220 )
{
if ( *(_DWORD *)__s == 230 )
{
v14 = 230;
v13 = a1;
return sub_100556350(v13, v14);
}
sub_100552734(v3, "Got a %03d ftp-server response when 220 was expected");
return 8;
}
if ( !*(_DWORD *)(v3 + 1328) || *(_BYTE *)(a1 + 520) )
goto LABEL_175;
*(_DWORD *)(a1 + 1508) = 0;
v21 = *(_DWORD *)(v3 + 1332);
if ( v21 == 2 )
{
*(_QWORD *)(a1 + 1500) = 0xFFFFFFFF00000001LL;
v22 = 1;
}
else
{
if ( v21 > 1 )
{
sub_100552734(v3, "unsupported parameter to CURLOPT_FTPSSLAUTH: %d", *(_DWORD *)(v3 + 1332));
return 48;
}
v22 = 0;
*(_QWORD *)(a1 + 1500) = &_mh_execute_header;
}
v8 = sub_10057A8EC(a1 + 1336, "AUTH %s", &aSsl[4 * v22]);
if ( !(_DWORD)v8 )
{
v8 = 0;
*(_DWORD *)(a1 + 1512) = 2;
}
return v8;
case 2:
if ( *(_DWORD *)__s == 234 || *(_DWORD *)__s == 334 )
{
v8 = sub_1005870B0(a1, 0);
if ( (_DWORD)v8 )
return v8;
*(_BYTE *)(a1 + 560) = 0;
}
else
{
v55 = *(_DWORD *)(a1 + 1508);
if ( v55 <= 0 )
{
*(_DWORD *)(a1 + 1508) = v55 + 1;
*(_DWORD *)(a1 + 1500) += *(_DWORD *)(a1 + 1504);
return sub_10057A8EC(a1 + 1336, "AUTH %s");
}
if ( *(_DWORD *)(v3 + 1328) > 1u )
return 64;
}
LABEL_175:
v56 = *(const char **)(*(_QWORD *)(*(_QWORD *)a1 + 536LL) + 8LL);
if ( !v56 )
v56 = "";
v8 = sub_10057A8EC(a1 + 1336, "USER %s", v56);
if ( !(_DWORD)v8 )
{
v8 = 0;
*(_DWORD *)(a1 + 1512) = 3;
*(_BYTE *)(*(_QWORD *)a1 + 35552LL) = 0;
}
return v8;
case 3:
case 4:
v13 = a1;
v14 = *(unsigned int *)__s;
return sub_100556350(v13, v14);
case 5:
if ( *(_DWORD *)__s == 230 )
{
if ( !*(_BYTE *)(a1 + 520) )
goto LABEL_141;
v8 = sub_10057A8EC(a1 + 1336, "PBSZ %d", 0);
if ( !(_DWORD)v8 )
{
v8 = 0;
*(_DWORD *)(a1 + 1512) = 6;
}
}
else
{
sub_100552734(*(_QWORD *)a1, "ACCT rejected by server: %03d", *(_DWORD *)__s);
return 11;
}
return v8;
case 6:
if ( *(_DWORD *)(v3 + 1328) == 2 )
v23 = 67;
else
v23 = 80;
v8 = sub_10057A8EC(a1 + 1336, "PROT %c", v23);
if ( !(_DWORD)v8 )
{
v8 = 0;
*(_DWORD *)(a1 + 1512) = 7;
}
return v8;
case 7:
v24 = *(_DWORD *)(v3 + 1328);
if ( (unsigned int)(*(_DWORD *)__s - 200) > 0x63 )
{
if ( v24 > 2 )
return 64;
}
else
{
*(_BYTE *)(a1 + 560) = v24 != 2;
}
if ( !*(_DWORD *)(v3 + 1336) )
goto LABEL_141;
v8 = sub_10057A8EC(a1 + 1336, "%s", "CCC");
if ( !(_DWORD)v8 )
{
v8 = 0;
*(_DWORD *)(a1 + 1512) = 8;
}
return v8;
case 8:
if ( *(int *)__s <= 499 && (v8 = sub_100587770(a1, 0), (_DWORD)v8) )
{
sub_100552734(*(_QWORD *)a1, "Failed to clear the command channel (CCC)");
}
else
{
LABEL_141:
v8 = sub_10057A8EC(a1 + 1336, "%s", "PWD");
if ( !(_DWORD)v8 )
goto LABEL_142;
}
return v8;
case 9:
if ( *(_DWORD *)__s != 257 )
goto LABEL_209;
v25 = (char *)off_10085DEB0(v77 + 1);
v26 = v25;
if ( !v25 )
return 27;
v27 = v3 + 2388;
LOBYTE(v28) = *(_BYTE *)(v3 + 2388);
while ( 1 )
{
if ( !(_BYTE)v28 || (unsigned __int8)v28 == 10 )
goto LABEL_71;
if ( (unsigned __int8)v28 == 34 )
break;
v29 = *(unsigned __int8 *)++v27;
v28 = v29;
if ( v27 >= v3 + 18769 )
{
v30 = v25;
if ( v28 == 34 )
goto LABEL_290;
LABEL_71:
off_10085DEB8(v25);
sub_1005524A4(v3, "Failed to figure out path\n");
goto LABEL_209;
}
}
v30 = v25;
LABEL_290:
while ( 1 )
{
v74 = *(unsigned __int8 *)(v27 + 1);
if ( !*(_BYTE *)(v27 + 1) )
break;
if ( v74 == 34 )
{
v75 = *(unsigned __int8 *)(v27 + 2);
v27 += 2LL;
if ( v75 != 34 )
{
*v30 = 0;
break;
}
*v30++ = 34;
}
else
{
++v27;
*v30++ = v74;
}
}
if ( *(_QWORD *)(a1 + 1528) || *v25 == 47 )
{
off_10085DEB8(*(void **)(a1 + 1448));
*(_QWORD *)(a1 + 1448) = v26;
sub_1005524A4(v3, "Entry path is '%s'\n", v26);
*(_QWORD *)(v3 + 35544) = *(_QWORD *)(a1 + 1448);
LABEL_209:
v8 = 0;
*(_DWORD *)(a1 + 1512) = 0;
}
else
{
v8 = sub_10057A8EC(a1 + 1336, "%s", "SYST");
v36 = off_10085DEB8;
if ( (_DWORD)v8 )
{
LABEL_299:
v36(v26);
}
else
{
off_10085DEB8(*(void **)(a1 + 1448));
*(_QWORD *)(a1 + 1448) = v26;
sub_1005524A4(v3, "Entry path is '%s'\n", v26);
v8 = 0;
*(_QWORD *)(v3 + 35544) = *(_QWORD *)(a1 + 1448);
*(_DWORD *)(a1 + 1512) = 10;
}
}
return v8;
case 10:
if ( *(_DWORD *)__s != 215 )
goto LABEL_209;
v31 = (char *)off_10085DEB0(v77 + 1);
v26 = v31;
if ( !v31 )
return 27;
v32 = (unsigned __int8 *)(v3 + 2388);
do
{
v34 = *v32++;
v33 = v34;
}
while ( v34 == 32 );
v35 = 0;
while ( (v33 | 0x20) != 0x20 )
{
v31[v35] = v33;
v33 = v32[v35++];
}
v31[v35] = 0;
if ( !(unsigned int)sub_1005679B0(v31, "OS/400") )
{
off_10085DEB8(*(void **)(a1 + 1528));
*(_QWORD *)(a1 + 1528) = v26;
goto LABEL_209;
}
v8 = sub_10057A8EC(a1 + 1336, "%s", "SITE NAMEFMT 1");
v36 = off_10085DEB8;
if ( (_DWORD)v8 )
goto LABEL_299;
off_10085DEB8(*(void **)(a1 + 1528));
v8 = 0;
*(_QWORD *)(a1 + 1528) = v26;
*(_DWORD *)(a1 + 1512) = 11;
return v8;
case 11:
if ( *(_DWORD *)__s != 250 )
goto LABEL_209;
if ( (unsigned int)sub_10057A8EC(a1 + 1336, "%s", "PWD") )
return 0;
LABEL_142:
v8 = 0;
*(_DWORD *)(a1 + 1512) = 9;
return v8;
case 12:
case 13:
case 14:
case 15:
if ( *(int *)__s < 400 || *(_DWORD *)(a1 + 1504) )
return sub_1005564D4(a1, 0, *(unsigned int *)(a1 + 1512));
sub_100552734(*(_QWORD *)a1, "QUOT command failed with %03d", *(_DWORD *)__s);
return 21;
case 16:
if ( (unsigned int)(*(_DWORD *)__s - 200) >= 0x64 )
{
if ( *(_DWORD *)(*(_QWORD *)a1 + 1276LL) && (v37 = *(_DWORD *)(a1 + 1500)) != 0 && !*(_DWORD *)(a1 + 1504) )
{
*(_DWORD *)(a1 + 1504) = 1;
v8 = sub_10057A8EC(a1 + 1336, "MKD %s", *(const char **)(*(_QWORD *)(a1 + 1456) + 8LL * (v37 - 1)));
if ( !(_DWORD)v8 )
{
v8 = 0;
*(_DWORD *)(a1 + 1512) = 17;
}
}
else
{
sub_100552734(v3, "Server denied you to change to the given directory");
*(_BYTE *)(a1 + 1483) = 1;
return 9;
}
return v8;
}
*(_DWORD *)(a1 + 1504) = 0;
v50 = *(_DWORD *)(a1 + 1500);
*(_DWORD *)(a1 + 1500) = v50 + 1;
if ( v50 < *(_DWORD *)(a1 + 1464) )
return sub_10057A8EC(a1 + 1336, "CWD %s");
if ( !*(_BYTE *)(*(_QWORD *)a1 + 1297LL) && !*(_DWORD *)(*(_QWORD *)a1 + 1048LL) || !*(_QWORD *)(a1 + 1472) )
return sub_100556F00(a1);
v8 = sub_10057A8EC(a1 + 1336, "MDTM %s", *(const char **)(a1 + 1472));
if ( !(_DWORD)v8 )
{
v8 = 0;
*(_DWORD *)(a1 + 1512) = 18;
}
return v8;
case 17:
if ( (unsigned int)(*(_DWORD *)__s - 200) < 0x64
|| (v38 = *(_DWORD *)(a1 + 1508), *(_DWORD *)(a1 + 1508) = v38 - 1, v38) )
{
*(_DWORD *)(a1 + 1512) = 16;
return sub_10057A8EC(a1 + 1336, "CWD %s");
}
else
{
sub_100552734(v3, "Failed to MKD dir: %03d", v9);
return 9;
}
case 18:
v39 = *(_QWORD *)a1;
v40 = *(_QWORD *)(*(_QWORD *)a1 + 536LL);
if ( *(_DWORD *)__s == 550 )
{
sub_100552734(*(_QWORD *)a1, "Given file does not exist");
v8 = 19;
}
else if ( *(_DWORD *)__s == 213 )
{
if ( sscanf((const char *)(v39 + 2388), "%04d%02d%02d%02d%02d%02d", &v82, &v83, &v81, &v80, &v79, &v78) == 6 )
{
v85 = time(nullptr);
sub_100562884(v39 + 2384, 16385, "%04d%02d%02d %02d:%02d:%02d GMT", (_DWORD)v82, v83, v81, v80, v79, v78);
*(_QWORD *)(v39 + 35760) = sub_100570460((char *)(v39 + 2384));
}
if ( *(_BYTE *)(v39 + 1311) )
{
if ( *(_QWORD *)(a1 + 1472) )
{
if ( *(_BYTE *)(v39 + 1297) )
{
v52 = *(_QWORD *)(v39 + 35760);
if ( v52 < 0 )
{
v8 = 0;
}
else
{
v8 = sub_100570CFC(v52, __s);
if ( (_DWORD)v8 )
return v8;
v53 = 6;
if ( v89 )
v53 = v89 - 1LL;
sub_100562884(
v39 + 2384,
0x3FFF,
"Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
off_10082E3A0[v53],
*(_DWORD *)&__s[12],
off_10082E3D8[*(int *)&__s[16]],
*(_DWORD *)&__s[20] + 1900,
*(_DWORD *)&__s[8],
*(_DWORD *)&__s[4],
*(_DWORD *)__s);
v8 = sub_100552F3C(a1, 3, (char *)(v39 + 2384), 0);
if ( (_DWORD)v8 )
return v8;
v8 = 0;
}
}
else
{
v8 = 0;
}
}
else
{
v8 = 0;
}
}
else
{
v8 = 0;
}
}
else
{
sub_1005524A4(*(_QWORD *)a1, "unsupported MDTM reply format\n");
v8 = 0;
}
v67 = *(_DWORD *)(v39 + 1048);
if ( !v67 )
goto LABEL_255;
v68 = *(_QWORD *)(v39 + 35760);
if ( v68 < 1 || (v69 = *(_QWORD *)(v39 + 1056), v69 < 1) )
{
sub_1005524A4(v39, "Skipping time comparison\n");
}
else if ( v67 == 2 )
{
if ( v68 > v69 )
{
sub_1005524A4(v39, "The requested document is not old enough\n");
LABEL_259:
v8 = 0;
*(_DWORD *)(v40 + 24) = 2;
*(_BYTE *)(v39 + 35768) = 1;
*(_DWORD *)(a1 + 1512) = 0;
return v8;
}
}
else if ( v68 <= v69 )
{
sub_1005524A4(v39, "The requested document is not new enough\n");
goto LABEL_259;
}
LABEL_255:
if ( !(_DWORD)v8 )
return sub_100556F00(a1);
return v8;
case 19:
case 20:
case 21:
case 22:
return sub_100556818(a1, *(unsigned int *)__s, *(unsigned int *)(a1 + 1512));
case 23:
case 24:
case 25:
v11 = *(_QWORD *)a1;
if ( *(_DWORD *)__s == 213 )
v12 = strtol((const char *)(v11 + 2388), nullptr, 0);
else
v12 = -1;
if ( v10 == 25 )
{
*(_QWORD *)(v11 + 35608) = v12;
return sub_100556CF0(a1, 1);
}
if ( v10 == 24 )
{
sub_10054A714(v11, v12);
return sub_100556B58(a1, v12);
}
if ( v10 != 23 )
return 0;
if ( v12 != -1 )
{
sub_100562884(v11 + 2384, 16385, "Content-Length: %ld\r\n", v12);
v8 = sub_100552F3C(a1, 3, (char *)(v11 + 2384), 0);
if ( (_DWORD)v8 )
return v8;
}
sub_10054A714(v11, v12);
if ( !*(_DWORD *)(*(_QWORD *)(*(_QWORD *)a1 + 536LL) + 24LL) || !*(_QWORD *)(a1 + 1472) )
return sub_10055702C(a1);
v8 = sub_10057A8EC(a1 + 1336, "REST %d", 0);
if ( !(_DWORD)v8 )
{
v8 = 0;
*(_DWORD *)(a1 + 1512) = 26;
}
return v8;
case 26:
case 27:
if ( v10 == 27 )
{
if ( *(_DWORD *)__s == 350 )
{
v8 = sub_10057A8EC(a1 + 1336, "RETR %s", *(const char **)(a1 + 1472));
if ( !(_DWORD)v8 )
{
v8 = 0;
*(_DWORD *)(a1 + 1512) = 32;
}
}
else
{
sub_100552734(*(_QWORD *)a1, "Couldn't use REST");
return 31;
}
}
else
{
if ( *(_DWORD *)__s != 350 )
return sub_10055702C(a1);
__s[23] = 0;
strcpy(__s, "Accept-ranges: bytes\r\n");
v8 = sub_100552F3C(a1, 3, __s, 0);
if ( !(_DWORD)v8 )
return sub_10055702C(a1);
}
return v8;
case 28:
v41 = *(_QWORD *)a1;
if ( (unsigned int)(*(_DWORD *)__s - 200) < 0x64 )
{
sub_1005524A4(v41, "Connect data stream actively\n");
*(_DWORD *)(a1 + 1512) = 0;
if ( *(_DWORD *)(*(_QWORD *)(*(_QWORD *)a1 + 536LL) + 24LL) )
sub_100567898(a1, 0xFFFFFFFFLL, -1, 0, 0, 0xFFFFFFFFLL, 0);
else
*(_BYTE *)(a1 + 745) = 1;
v8 = 0;
*(_BYTE *)(a1 + 1481) = 1;
}
else
{
v42 = *(_DWORD *)(a1 + 1500);
if ( v42 )
{
v43 = (unsigned int)(v42 + 1);
if ( v42 == 1 )
{
sub_100552734(v41, "Failed to do PORT");
return 30;
}
}
else
{
sub_1005524A4(v41, "disabling EPRT usage\n");
*(_BYTE *)(a1 + 754) = 0;
v43 = 1;
}
return sub_100557194(a1, v43);
}
return v8;
case 29:
if ( *(_DWORD *)__s == 200 )
{
v44 = *(unsigned __int8 *)(a1 + 753);
if ( !*(_BYTE *)(a1 + 753) )
{
if ( *(_BYTE *)(a1 + 744) )
{
v44 = 1;
*(_BYTE *)(a1 + 753) = 1;
}
else
{
v44 = 0;
}
}
v66 = v44 ^ 1;
v8 = sub_10057A8EC(a1 + 1336, "%s", &aEpsv[5 * (v44 ^ 1)]);
if ( !(_DWORD)v8 )
{
*(_DWORD *)(a1 + 1500) = v66;
*(_DWORD *)(a1 + 1512) = 30;
sub_1005524A4(*(_QWORD *)a1, "Connect data stream passively\n");
return 0;
}
}
else
{
sub_100552734(v3, "PRET command not accepted: %03d", *(_DWORD *)__s);
return 84;
}
return v8;
case 30:
v45 = *(_QWORD *)a1;
v82 = nullptr;
v46 = (const char *)(v45 + 2388);
off_10085DEB8(*(void **)(a1 + 1544));
*(_QWORD *)(a1 + 1544) = 0;
v47 = *(_DWORD *)(a1 + 1500);
if ( v9 != 229 || v47 )
{
if ( v9 != 227 || v47 != 1 )
{
if ( v47 )
{
sub_100552734(v45, "Bad PASV/EPSV response: %03d");
return 13;
}
goto LABEL_277;
}
if ( !*v46 )
goto LABEL_225;
while ( sscanf(v46, "%d,%d,%d,%d,%d,%d", &v85, (char *)&v85 + 4, &v86, &v87, &v83, &v84) != 6 )
{
if ( !*(unsigned __int8 *)++v46 )
goto LABEL_225;
}
if ( !*v46 )
{
LABEL_225:
sub_100552734(v45, "Couldn't interpret the 227-response");
return 14;
}
v63 = v45;
if ( *(_BYTE *)(v45 + 1344) )
{
sub_1005524A4(
v45,
"Skip %d.%d.%d.%d for data connection, re-use %s instead\n",
v85,
HIDWORD(v85),
v86,
v87,
*(const char **)(a1 + 192));
if ( *(_BYTE *)(a1 + 750) || (*(_DWORD *)(a1 + 416) & 0xFFFFFFFC) == 4 )
v64 = off_10085DEC8(*(const char **)(a1 + 192));
else
v64 = off_10085DEC8((const char *)(a1 + 120));
}
else
{
v64 = (char *)sub_1005628DC("%d.%d.%d.%d", v85, HIDWORD(v85), v86, v87);
}
v70 = v64;
*(_QWORD *)(a1 + 1544) = v64;
if ( !v64 )
return 27;
*(_WORD *)(a1 + 1552) = v84 + ((_WORD)v83 << 8);
}
else
{
v48 = strchr((char *)(v45 + 2388), 40);
if ( !v48
|| sscanf(v48 + 1, "%c%c%c%u%c", &v80, (char *)&v80 + 1, (char *)&v80 + 2, &v81, (char *)&v80 + 3) != 5 )
{
goto LABEL_232;
}
if ( v81 >= 0x10000 )
{
sub_100552734(v45, "Illegal port number in EPSV reply", v76);
return 13;
}
if ( BYTE1(v80) != (unsigned __int8)v80
|| BYTE2(v80) != (unsigned __int8)v80
|| HIBYTE(v80) != (unsigned __int8)v80 )
{
LABEL_232:
sub_100552734(v45, "Weirdly formatted EPSV reply");
return 13;
}
v63 = v45;
*(_WORD *)(a1 + 1552) = v81;
if ( *(_BYTE *)(a1 + 750) || (*(_DWORD *)(a1 + 416) & 0xFFFFFFFC) == 4 )
v65 = *(const char **)(a1 + 192);
else
v65 = (const char *)(a1 + 120);
v70 = off_10085DEC8(v65);
*(_QWORD *)(a1 + 1544) = v70;
if ( !v70 )
return 27;
}
if ( *(_BYTE *)(a1 + 739) )
{
sub_100549994((__int64 *)a1, *(char **)(a1 + 224), *(_DWORD *)(a1 + 240), (__int64 *)&v82);
v71 = *(_QWORD *)(a1 + 240);
if ( !v82 )
{
sub_100552734(v63, "Can't resolve proxy host %s:%hu");
return 15;
}
}
else
{
sub_100549994((__int64 *)a1, v70, *(unsigned __int16 *)(a1 + 1552), (__int64 *)&v82);
LOWORD(v71) = *(_WORD *)(a1 + 1552);
if ( !v82 )
{
sub_100552734(v63, "Can't resolve new host %s:%hu");
return 15;
}
}
*(_BYTE *)(a1 + 747) = 0;
v8 = sub_10056AD44(a1);
if ( !(_DWORD)v8 )
{
if ( *(_BYTE *)(v63 + 1320) )
{
v73 = *(const char **)(a1 + 1544);
sub_1005495E8(*v82, __s, 0x100u);
sub_1005524A4(*(_QWORD *)a1, "Connecting to %s (%s) port %d\n", v73, __s, (unsigned __int16)v71);
}
sub_100549D10(v63, v82);
v8 = 0;
*(_BYTE *)(a1 + 745) = 1;
*(_DWORD *)(a1 + 1512) = 0;
return v8;
}
sub_100549D10(v63, v82);
if ( v9 == 229 && !*(_DWORD *)(a1 + 1500) )
{
LABEL_277:
v72 = *(_QWORD *)a1;
if ( *(_BYTE *)(a1 + 744) )
{
sub_100552734(v72, "Failed EPSV attempt, exiting\n");
return 8;
}
else
{
sub_1005524A4(v72, "Failed EPSV attempt. Disabling EPSV\n");
*(_BYTE *)(a1 + 753) = 0;
*(_BYTE *)(*(_QWORD *)a1 + 35232LL) = 0;
v8 = sub_10057A8EC(a1 + 1336, "%s", "PASV");
if ( !(_DWORD)v8 )
{
v8 = 0;
++*(_DWORD *)(a1 + 1500);
*(_DWORD *)(a1 + 1512) = 30;
}
}
}
return v8;
case 31:
case 32:
v15 = *(_QWORD *)a1;
v16 = *(_QWORD *)(*(_QWORD *)a1 + 536LL);
if ( *(_DWORD *)__s != 125 && *(_DWORD *)__s != 150 )
{
if ( *(_DWORD *)__s == 450 && v10 == 31 )
{
v8 = 0;
*(_DWORD *)(v16 + 24) = 2;
*(_DWORD *)(a1 + 1512) = 0;
}
else
{
sub_100552734(v15, "RETR response: %03d", *(_DWORD *)__s);
if ( v9 == 550 )
v57 = 78;
else
v57 = 19;
if ( v10 == 32 )
return v57;
else
return 19;
}
return v8;
}
if ( v10 == 31 || *(_BYTE *)(v15 + 1299) || *(__int64 *)(v16 + 32) > 0 )
{
v17 = *(_QWORD *)(v16 + 32);
if ( v17 < 0 )
v18 = -1;
else
v18 = v17;
goto LABEL_29;
}
v58 = strstr((char *)(v15 + 2384), " bytes");
if ( !v58 )
{
v18 = -1;
goto LABEL_29;
}
v59 = v58 - 1;
if ( &v58[-v15 - 2385] == (char *)1 )
goto LABEL_262;
v60 = v15 + 2385 - (_QWORD)v59;
while ( 1 )
{
v61 = v59;
v62 = (unsigned __int8)*v59;
if ( v62 == 40 )
{
v59 = v61;
LABEL_262:
v18 = strtol(v59 + 1, nullptr, 0);
goto LABEL_29;
}
if ( (unsigned int)(v62 - 48) >= 0xA )
break;
v59 = v58 - 2;
++v60;
v58 = v61;
if ( !v60 )
goto LABEL_262;
}
v18 = -1;
LABEL_29:
v19 = *(_QWORD *)(v15 + 136);
if ( v18 <= v19 || v19 <= 0 )
{
if ( v10 == 31 )
{
sub_1005524A4(v15, "Maxdownload = %ld\n", *(_QWORD *)(v15 + 136));
v19 = v18;
LABEL_186:
*(_DWORD *)(a1 + 1516) = v10;
*(_QWORD *)(a1 + 1520) = v19;
if ( !*(_BYTE *)(v15 + 1302) )
return sub_100557A54(a1);
v8 = sub_10055794C(a1, __s);
if ( !(_DWORD)v8 && !__s[0] )
{
sub_1005524A4(v15, "Data conn was not available immediately\n");
v8 = 0;
*(_DWORD *)(a1 + 1512) = 0;
goto LABEL_190;
}
return v8;
}
if ( *(_BYTE *)(v15 + 1299) )
v18 = -1;
sub_1005524A4(v15, "Maxdownload = %ld\n", *(_QWORD *)(v15 + 136));
v19 = v18;
}
else
{
*(_QWORD *)(v15 + 120) = v19;
sub_1005524A4(v15, "Maxdownload = %ld\n", v19);
if ( v10 == 31 )
goto LABEL_186;
}
sub_1005524A4(v15, "Getting file with size: %ld\n", v19);
goto LABEL_186;
case 33:
v49 = *(_QWORD *)a1;
if ( *(int *)__s < 400 )
{
*(_DWORD *)(a1 + 1516) = 33;
if ( *(_BYTE *)(v49 + 1302) )
{
*(_DWORD *)(a1 + 1512) = 0;
v8 = sub_10055794C(a1, __s);
if ( !(_DWORD)v8 )
{
if ( __s[0] )
{
return 0;
}
else
{
sub_1005524A4(v49, "Data conn was not available immediately\n");
v8 = 0;
LABEL_190:
*(_BYTE *)(a1 + 1484) = 1;
}
}
}
else
{
return sub_100557A54(a1);
}
}
else
{
sub_100552734(v49, "Failed FTP upload: %0d", *(_DWORD *)__s);
*(_DWORD *)(a1 + 1512) = 0;
return 25;
}
return v8;
default:
goto LABEL_209;
}
}