//
// sub_B7E560 from 0xb7e560 to 0xb7e798 (568 bytes)
//
// 6 xrefs:
// > sub_B7F490 @ 0xb7f77c
// > sub_B7F490 @ 0xb7f8bc
// > sub_B7F490 @ 0xb80440
// > sub_B7F490 @ 0xb80838
// > sub_B80C64 @ 0xb810e8
// > sub_B813E8 @ 0xb814f4
//
// 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_B7E560(__int64 a1, int a2, unsigned int a3)
{
bool v3; // cf
__int64 v5; // x0
__int64 v7; // x2
__int64 v8; // x3
__int64 v9; // x19
const char *v10; // x2
int v11; // w0
__int64 result; // x0
int v13; // w4
int v14; // w1
int v15; // w2
int v16; // w0
const char **v17; // x2
__int64 v18; // x1
__int64 v19; // x2
const char *v20; // x2
const char *v21; // x2
v3 = a3 >= 0xD;
a2 = (unsigned __int8)a2;
v5 = *(_QWORD *)a1;
v7 = *(_QWORD *)(v5 + 536);
if ( !v3 )
{
LABEL_13:
v8 = *(_QWORD *)(v5 + 984);
v9 = a1 + 1560;
if ( !(_BYTE)a2 )
goto LABEL_14;
goto LABEL_7;
}
if ( a3 <= 0xE )
{
v8 = *(_QWORD *)(v5 + 1000);
}
else
{
if ( a3 != 15 )
goto LABEL_13;
v8 = *(_QWORD *)(v5 + 992);
}
v9 = a1 + 1560;
if ( !(_BYTE)a2 )
{
LABEL_14:
v13 = *(_DWORD *)(v9 + 164) + 1;
*(_DWORD *)(v9 + 164) = v13;
if ( !v8 )
goto LABEL_20;
if ( v13 > 0 )
{
while ( 1 )
{
++a2;
v8 = *(_QWORD *)(v8 + 8);
if ( v13 == a2 )
break;
if ( !v8 )
goto LABEL_20;
}
if ( !v8 )
goto LABEL_20;
}
LABEL_8:
v10 = *(const char **)v8;
v11 = 0;
if ( **(_BYTE **)v8 == 42 )
{
++v10;
v11 = 1;
}
*(_DWORD *)(v9 + 168) = v11;
result = sub_BAA4B0(v9, "%s", v10);
if ( !(_DWORD)result )
*(_DWORD *)(v9 + 176) = a3;
return result;
}
LABEL_7:
*(_DWORD *)(v9 + 164) = 0;
if ( v8 )
goto LABEL_8;
LABEL_20:
if ( a3 == 14 )
return sub_B7CAA0(a1, 0);
if ( a3 == 15 )
return 0;
if ( a3 != 13 )
{
v14 = *(unsigned __int8 *)(v9 + 146);
if ( !*(_BYTE *)(v9 + 146) )
{
v15 = *(_DWORD *)(v5 + 1532);
v16 = *(unsigned __int8 *)(a1 + 954);
*(_DWORD *)(v9 + 168) = v14;
*(_DWORD *)(v9 + 172) = v15 == 2;
if ( v16 )
{
v20 = *(const char **)(v9 + 112);
if ( v20 )
{
*(_DWORD *)(v9 + 164) = v14;
result = sub_BAA4B0(v9, "CWD %s", v20);
if ( (_DWORD)result )
return result;
LABEL_27:
*(_DWORD *)(v9 + 176) = 16;
return result;
}
}
if ( *(_DWORD *)(v9 + 128) )
{
v17 = *(const char ***)(v9 + 120);
*(_DWORD *)(v9 + 164) = 1;
result = sub_BAA4B0(v9, "CWD %s", *v17);
if ( (_DWORD)result )
return result;
goto LABEL_27;
}
}
return sub_B7E3AC((__int64 *)a1);
}
if ( *(_DWORD *)(v7 + 24) )
{
*(_DWORD *)(v9 + 176) = 0;
return 0;
}
else
{
v18 = *(_QWORD *)(v9 + 200);
if ( v18 == -1 )
{
v21 = *(const char **)(v9 + 136);
if ( *(_BYTE *)(v5 + 1599) )
{
result = sub_BAA4B0(v9, "RETR %s", v21);
if ( !(_DWORD)result )
*(_DWORD *)(v9 + 176) = 32;
}
else
{
result = sub_BAA4B0(v9, "SIZE %s", v21);
if ( !(_DWORD)result )
*(_DWORD *)(v9 + 176) = 24;
}
}
else
{
sub_B72430(v5, v18);
return sub_B7C8E0(a1, *(_QWORD *)(v9 + 200), v19);
}
}
return result;
}