//
// sub_1005564D4 from 0x1005564d4 to 0x100556818 (836 bytes)
//
// 5 xrefs:
// > sub_100553438 @ 0x1005539ac
// > sub_100554164 @ 0x1005546e4
// > sub_100554D5C @ 0x100554e70
// > sub_100556818 @ 0x10055699c
// > sub_10055702C @ 0x100557070
//
// 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_1005564D4(__int64 a1, char a2, int a3)
{
__int64 v5; // x8
__int64 v6; // x9
__int64 v7; // x0
__int64 *v8; // x12
__int64 *v9; // x10
__int64 v10; // x10
int v11; // w11
int v12; // w12
bool v13; // cc
const char *v14; // x8
bool v15; // zf
__int64 result; // x0
const char *v17; // x10
__int64 v18; // x1
int v19; // w8
const char *v20; // x10
int v21; // w11
int v22; // w8
int v23; // w14
int v24; // w8
__int64 v25; // x20
__int64 v26; // x0
v5 = *(_QWORD *)a1;
v6 = *(_QWORD *)(*(_QWORD *)a1 + 536LL);
v7 = a1 + 1336;
v8 = (__int64 *)(v5 + 992);
if ( a3 != 15 )
v8 = (__int64 *)(v5 + 984);
if ( (unsigned int)(a3 - 13) >= 2 )
v9 = v8;
else
v9 = (__int64 *)(v5 + 1000);
v10 = *v9;
if ( (a2 & 1) != 0 )
v11 = 0;
else
v11 = *(_DWORD *)(a1 + 1500) + 1;
*(_DWORD *)(a1 + 1500) = v11;
if ( v10 )
{
if ( v11 < 1 )
goto LABEL_17;
v12 = 1;
do
{
v10 = *(_QWORD *)(v10 + 8);
if ( v10 )
v13 = v12 < v11;
else
v13 = 0;
++v12;
}
while ( v13 );
if ( v10 )
{
LABEL_17:
v14 = *(const char **)v10;
v15 = **(_BYTE **)v10 == 42;
if ( v15 )
v14 = (const char *)(*(_QWORD *)v10 + 1LL);
*(_DWORD *)(a1 + 1504) = v15;
result = sub_10057A8EC(v7, "%s", v14);
if ( !(_DWORD)result )
{
*(_DWORD *)(a1 + 1512) = a3;
return 0;
}
return result;
}
}
switch ( a3 )
{
case 13:
if ( *(_DWORD *)(v6 + 24) )
{
*(_DWORD *)(a1 + 1512) = 0;
return 0;
}
v18 = *(_QWORD *)(a1 + 1536);
if ( v18 != -1 )
{
sub_10054A714(v5, v18);
return sub_100556B58(a1, *(_QWORD *)(a1 + 1536));
}
if ( *(_BYTE *)(v5 + 1343) )
{
result = sub_10057A8EC(v7, "RETR %s", *(const char **)(a1 + 1472));
if ( (_DWORD)result )
return result;
result = 0;
v19 = 32;
}
else
{
result = sub_10057A8EC(v7, "SIZE %s", *(const char **)(a1 + 1472));
if ( (_DWORD)result )
return result;
result = 0;
v19 = 24;
}
goto LABEL_69;
case 14:
return sub_100556CF0(a1, 0);
case 15:
return 0;
}
if ( !*(_BYTE *)(a1 + 1482) )
{
*(_DWORD *)(a1 + 1504) = 0;
*(_DWORD *)(a1 + 1508) = *(_DWORD *)(v5 + 1276) == 2;
if ( *(_BYTE *)(a1 + 738) )
{
v17 = *(const char **)(a1 + 1448);
if ( v17 )
{
*(_DWORD *)(a1 + 1500) = 0;
result = sub_10057A8EC(v7, "CWD %s", v17);
LABEL_39:
if ( (_DWORD)result )
return result;
result = 0;
v19 = 16;
LABEL_69:
*(_DWORD *)(a1 + 1512) = v19;
return result;
}
}
if ( *(_DWORD *)(a1 + 1464) )
{
*(_DWORD *)(a1 + 1500) = 1;
result = sub_10057A8EC(v7, "CWD %s", **(const char ***)(a1 + 1456));
goto LABEL_39;
}
}
if ( (*(_BYTE *)(v5 + 1297) || *(_DWORD *)(v5 + 1048)) && *(_QWORD *)(a1 + 1472) )
{
result = sub_10057A8EC(a1 + 1336, "MDTM %s", *(const char **)(a1 + 1472));
if ( (_DWORD)result )
return result;
result = 0;
v19 = 18;
goto LABEL_69;
}
if ( !*(_BYTE *)(v5 + 1311)
|| (v20 = *(const char **)(a1 + 1472)) == nullptr
|| ((v21 = *(unsigned __int8 *)(v5 + 1299), v22 = *(char *)(a1 + 1496), !v21) ? (v23 = 73) : (v23 = 65), v22 == v23) )
{
v24 = *(_DWORD *)(v6 + 24);
if ( v24 )
{
if ( v24 == 1 && *(_QWORD *)(a1 + 1472) )
{
result = sub_10057A8EC(a1 + 1336, "SIZE %s", *(const char **)(a1 + 1472));
LABEL_67:
if ( (_DWORD)result )
return result;
result = 0;
v19 = 23;
goto LABEL_69;
}
if ( *(_QWORD *)(a1 + 1472) )
{
result = sub_10057A8EC(a1 + 1336, "REST %d", 0);
if ( (_DWORD)result )
return result;
result = 0;
v19 = 26;
goto LABEL_69;
}
}
return sub_10055702C(a1);
}
*(_DWORD *)(v6 + 24) = 1;
if ( v21 )
v25 = 65;
else
v25 = 73;
v26 = a1 + 1336;
if ( v22 == (_DWORD)v25 )
{
*(_DWORD *)(a1 + 1512) = 19;
result = sub_10057A8EC(v26, "SIZE %s", v20);
goto LABEL_67;
}
result = sub_10057A8EC(v26, "TYPE %c", v25);
if ( !(_DWORD)result )
{
*(_DWORD *)(a1 + 1512) = 19;
*(_BYTE *)(a1 + 1496) = v25;
return 0;
}
return result;
}