//
// sub_10054BA7C from 0x10054ba7c to 0x10054bd2c (688 bytes)
//
// 3 xrefs:
// > sub_10054B9CC @ 0x10054ba14
// > sub_100558DA8 @ 0x10055bb10
// > sub_100558DA8 @ 0x10055bbe8
//
// 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
//
_BYTE *__fastcall sub_10054BA7C(__int64 a1, const char *a2, _BYTE *a3, char a4)
{
_BYTE *v8; // x19
const char *v9; // x0
char *v10; // x0
int v11; // w24
FILE *v12; // x20
char *v13; // x0
char *v14; // x23
int v15; // w0
char *v16; // x3
int v17; // w8
void **v18; // x21
void **v19; // x23
v8 = a3;
if ( !a3 )
{
v8 = off_10085DED0(1u, 0x28u);
if ( !v8 )
return nullptr;
v9 = a2 ? a2 : "none";
v10 = off_10085DEC8(v9);
*((_QWORD *)v8 + 1) = v10;
if ( !v10 )
{
off_10085DEB8(nullptr);
v12 = nullptr;
v11 = 1;
LABEL_29:
off_10085DEB8(*((void **)v8 + 1));
v18 = *(void ***)v8;
if ( *(_QWORD *)v8 )
{
do
{
v19 = (void **)*v18;
off_10085DEB8(v18[7]);
off_10085DEB8(v18[5]);
off_10085DEB8(v18[3]);
off_10085DEB8(v18[4]);
off_10085DEB8(v18[1]);
off_10085DEB8(v18[2]);
off_10085DEB8(v18[10]);
off_10085DEB8(v18[9]);
off_10085DEB8(v18);
v18 = v19;
}
while ( v19 );
}
off_10085DEB8(v8);
goto LABEL_32;
}
}
v8[16] = 0;
if ( !a2 )
goto LABEL_24;
if ( (unsigned int)sub_1005679B0(a2, "-") )
{
v11 = 0;
v12 = __stdinp;
goto LABEL_12;
}
if ( !*a2 )
{
LABEL_24:
v8[32] = a4;
goto LABEL_25;
}
v12 = fopen(a2, "r");
v11 = 1;
LABEL_12:
v8[32] = a4;
if ( !v12 )
{
LABEL_25:
v8[16] = 1;
return v8;
}
v13 = (char *)off_10085DEB0(0x1388u);
v14 = v13;
if ( v13 )
{
if ( fgets(v13, 5000, v12) )
{
do
{
v15 = sub_10057405C("Set-Cookie:", v14, 11);
if ( v15 )
v16 = v14 + 11;
else
v16 = v14;
while ( 1 )
{
v17 = (unsigned __int8)*v16;
if ( v17 != 9 && v17 != 32 )
break;
++v16;
}
sub_10054BD2C(a1, v8, v15 != 0);
}
while ( fgets(v14, 5000, v12) );
}
off_10085DEB8(v14);
if ( v11 )
fclose(v12);
goto LABEL_25;
}
off_10085DEB8(nullptr);
if ( !a3 )
goto LABEL_29;
LABEL_32:
v8 = nullptr;
if ( v11 && v12 )
{
fclose(v12);
return nullptr;
}
return v8;
}