//
// sub_62A3A0 from 0x62a3a0 to 0x62a8a8 (1288 bytes)
//
// 3 xrefs:
// > sub_630064 @ 0x630f96
// > sub_630064 @ 0x631070
// > sub_630064 @ 0x631130
//
// 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
//
int __fastcall sub_62A3A0(size_t a1, char *s, int a3)
{
const char *v6; // r0
char *v7; // r0
const char *v8; // r5
int v9; // r4
char *v10; // r0
char *v11; // r0
char *v12; // r0
char *v13; // r11
int v14; // r3
char *v15; // r2
int v16; // r1
int v17; // r4
int v18; // t1
int v19; // t1
size_t v20; // r9
char *v21; // r0
const char *v22; // r4
int v23; // r3
char *v24; // r5
int v25; // r12
const char *v26; // r9
int v27; // r4
int v28; // t1
int v29; // t1
int v30; // r3
char *v32; // r0
int v33; // r2
int v34; // r3
int v35; // r2
char *v36; // r0
int v37; // r3
size_t v38; // r0
char *v39; // r2
int v40; // r1
int v41; // r0
int v42; // t1
int v43; // t1
const char *v44; // r0
int v45; // r3
char *v46; // r9
char *v47; // r5
int v48; // r12
const char *v49; // r11
int v50; // r4
int v51; // t1
int v52; // r3
int v53; // r4
int v54; // t1
char *v55; // r0
int v56; // r3
const char *v57; // r2
int v58; // t1
char *v59; // r0
char *v60; // r9
char *v61; // r0
bool v62; // cc
char *v63; // r0
char *v64; // [sp+4h] [bp-28h]
int v65; // [sp+8h] [bp-24h]
int v66; // [sp+Ch] [bp-20h]
char v67; // [sp+17h] [bp-15h] BYREF
char v68; // [sp+18h] [bp-14h] BYREF
if ( a3 == 3 )
{
v33 = *(_DWORD *)(a1 + 384);
v34 = *(_DWORD *)(a1 + 380);
if ( v33 != -1 && v33 <= v34 )
{
sub_6180F8(a1, "Maximum (%ld) redirects followed", v33);
return 47;
}
v35 = *(unsigned __int8 *)(a1 + 903);
*(_DWORD *)(a1 + 380) = v34 + 1;
*(_BYTE *)(a1 + 34448) = 1;
if ( v35 )
{
if ( *(_BYTE *)(a1 + 1316) )
{
off_ABAEB0(*(void **)(a1 + 1312));
*(_DWORD *)(a1 + 1312) = 0;
*(_BYTE *)(a1 + 1316) = 0;
}
v36 = off_ABAEB8(*(const char **)(a1 + 1304));
*(_DWORD *)(a1 + 1312) = v36;
if ( !v36 )
return 27;
*(_BYTE *)(a1 + 1316) = 1;
}
}
if ( sscanf(s, "%15[^?&/:]://%c", &v68, &v67) == 2 )
{
v37 = (unsigned __int8)*s;
v38 = 1;
if ( !*s )
goto LABEL_73;
v39 = s;
v40 = 1;
v41 = 0;
while ( v37 == 32 )
{
if ( v40 )
{
v43 = (unsigned __int8)*++v39;
v37 = v43;
v41 += 3;
if ( !v43 )
{
LABEL_72:
v38 = v41 + 1;
LABEL_73:
v44 = (const char *)off_ABAEAC(v38);
v22 = v44;
if ( v44 )
{
v45 = (unsigned __int8)*s;
if ( !*s )
{
v47 = (char *)v44;
goto LABEL_108;
}
v46 = s;
v47 = (char *)v44;
v48 = 43;
v49 = v44;
v50 = 1;
while ( 2 )
{
while ( v45 == 32 )
{
if ( !v50 )
{
*v47++ = v48;
goto LABEL_78;
}
*v47 = 37;
v47[1] = 50;
v47 += 3;
*(v47 - 1) = 48;
v58 = (unsigned __int8)*++v46;
v45 = v58;
if ( !v58 )
{
LABEL_107:
v22 = v49;
LABEL_108:
*v47 = 0;
off_ABAEB0(s);
if ( a3 != 1 )
{
*(_BYTE *)(a1 + 34492) = 0;
goto LABEL_43;
}
LABEL_110:
*(_DWORD *)(a1 + 34824) = v22;
return 0;
}
}
if ( v45 == 63 )
{
v50 = 0;
}
else if ( (v45 & 0x80) != 0 )
{
v59 = v47;
v47 += 3;
v65 = v48;
sub_624640(v59, 4, "%%%02x");
v48 = v65;
LABEL_78:
v51 = (unsigned __int8)*++v46;
v45 = v51;
if ( !v51 )
goto LABEL_107;
continue;
}
break;
}
*v47++ = v45;
goto LABEL_78;
}
return 27;
}
}
else
{
LABEL_68:
v42 = (unsigned __int8)*++v39;
v37 = v42;
++v41;
if ( !v42 )
goto LABEL_72;
}
}
if ( v37 == 63 )
{
v40 = 0;
}
else if ( (v37 & 0x80) != 0 )
{
v41 += 2;
}
goto LABEL_68;
}
v6 = off_ABAEB8(*(const char **)(a1 + 1304));
v64 = (char *)v6;
if ( !v6 )
return 27;
v7 = strstr(v6, "//");
v8 = v7 + 2;
if ( !v7 )
v8 = v64;
v9 = (unsigned __int8)*s;
if ( v9 != 47 )
{
v10 = strchr(v8, 63);
if ( v10 )
{
*v10 = 0;
v9 = (unsigned __int8)*s;
}
if ( v9 == 63 )
{
v12 = strchr(v8, 47);
if ( v12 )
goto LABEL_13;
}
else
{
v11 = strrchr(v8, 47);
if ( v11 )
{
*v11 = 0;
v9 = (unsigned __int8)*s;
}
v12 = strchr(v8, 47);
if ( v12 )
{
LABEL_13:
v8 = v12 + 1;
if ( v9 != 46 )
{
v13 = s;
goto LABEL_16;
}
LABEL_84:
v52 = (unsigned __int8)s[1];
if ( v52 == 47 )
{
v13 = s + 2;
if ( s[2] != 46 )
{
LABEL_16:
if ( v8 )
{
LABEL_17:
v14 = (unsigned __int8)*v13;
goto LABEL_18;
}
goto LABEL_114;
}
v52 = (unsigned __int8)s[3];
}
else
{
v13 = s;
}
if ( v52 == 46 && v13[2] == 47 )
{
v53 = 0;
do
{
v54 = (unsigned __int8)v13[3];
v13 += 3;
++v53;
}
while ( v54 == 46 && v13[1] == 46 && v13[2] == 47 );
if ( v8 )
{
while ( 1 )
{
v55 = strrchr(v8, 47);
if ( !v55 )
break;
--v53;
*v55 = 0;
if ( !v53 )
goto LABEL_17;
}
*v8 = 0;
goto LABEL_17;
}
goto LABEL_114;
}
goto LABEL_16;
}
v8 = nullptr;
if ( v9 == 46 )
goto LABEL_84;
}
v13 = s;
LABEL_114:
v14 = (unsigned __int8)*v13;
v8 = nullptr;
goto LABEL_18;
}
if ( s[1] == 47 )
{
v13 = s + 2;
*v8 = 0;
v14 = (unsigned __int8)s[2];
}
else
{
v60 = strchr(v8, (unsigned __int8)*s);
if ( v60 )
{
v61 = strchr(v8, 63);
v13 = s;
v62 = v61 != nullptr;
if ( v61 )
v62 = v60 > v61;
if ( !v62 )
v61 = v60;
*v61 = 0;
v14 = (unsigned __int8)*s;
}
else
{
v63 = strchr(v8, 63);
if ( !v63 )
{
v14 = 47;
v13 = s;
goto LABEL_19;
}
*v63 = 0;
v13 = s;
v14 = (unsigned __int8)*s;
}
}
LABEL_18:
if ( v14 )
{
LABEL_19:
v15 = v13;
v16 = 1;
v17 = 0;
while ( v14 == 32 )
{
if ( v16 )
{
v19 = (unsigned __int8)*++v15;
v14 = v19;
v17 += 3;
if ( !v19 )
goto LABEL_28;
}
else
{
LABEL_24:
v18 = (unsigned __int8)*++v15;
v14 = v18;
++v17;
if ( !v18 )
goto LABEL_28;
}
}
if ( v14 == 63 )
{
v16 = 0;
}
else if ( (v14 & 0x80) != 0 )
{
v17 += 2;
}
goto LABEL_24;
}
v17 = 0;
LABEL_28:
v20 = strlen(v64);
v21 = (char *)off_ABAEAC(v17 + v20 + 2);
v22 = v21;
if ( !v21 )
{
off_ABAEB0(v64);
return 27;
}
memcpy(v21, v64, v20);
v23 = (unsigned __int8)*v13;
if ( v23 != 47 )
{
if ( v8 && !*v8 )
{
LABEL_32:
v24 = (char *)&v22[v20];
if ( !v23 )
goto LABEL_42;
goto LABEL_33;
}
if ( v23 != 63 )
{
v22[v20++] = 47;
v23 = (unsigned __int8)*v13;
goto LABEL_32;
}
}
v24 = (char *)&v22[v20];
LABEL_33:
v25 = 37;
v26 = v22;
v27 = 1;
do
{
while ( v23 != 32 )
{
if ( v23 == 63 )
{
v27 = 0;
}
else if ( (v23 & 0x80) != 0 )
{
v32 = v24;
v24 += 3;
v66 = v25;
sub_624640(v32, 4, "%%%02x");
v25 = v66;
goto LABEL_37;
}
LABEL_36:
*v24++ = v23;
LABEL_37:
v28 = (unsigned __int8)*++v13;
v23 = v28;
if ( !v28 )
goto LABEL_41;
}
if ( !v27 )
{
LOBYTE(v23) = 43;
goto LABEL_36;
}
*v24 = v25;
v24[1] = 50;
v24[2] = 48;
v24 += 3;
v29 = (unsigned __int8)*++v13;
v23 = v29;
}
while ( v29 );
LABEL_41:
v22 = v26;
LABEL_42:
*v24 = 0;
off_ABAEB0(v64);
off_ABAEB0(s);
if ( a3 == 1 )
goto LABEL_110;
LABEL_43:
if ( *(_BYTE *)(a1 + 1308) )
off_ABAEB0(*(void **)(a1 + 1304));
*(_DWORD *)(a1 + 1304) = v22;
*(_BYTE *)(a1 + 1308) = 1;
sub_61807C(a1, "Issue another request to this URL: '%s'\n", v22);
v30 = *(_DWORD *)(a1 + 34780);
if ( v30 == 302 )
{
if ( (unsigned int)(*(_DWORD *)(a1 + 636) - 2) <= 1 && (*(_DWORD *)(a1 + 388) & 2) == 0 )
{
LABEL_121:
sub_61807C(a1, "Switch from POST to GET\n");
*(_DWORD *)(a1 + 636) = 1;
}
}
else if ( v30 == 303 )
{
if ( *(_DWORD *)(a1 + 636) != 1 && (*(_DWORD *)(a1 + 388) & 4) == 0 )
{
v56 = *(unsigned __int8 *)(a1 + 904);
*(_DWORD *)(a1 + 636) = 1;
if ( v56 )
v57 = "HEAD";
else
v57 = "GET";
sub_61807C(a1, "Disables POST, goes with %s\n", v57);
}
}
else if ( v30 == 301 && (unsigned int)(*(_DWORD *)(a1 + 636) - 2) <= 1 && (*(_DWORD *)(a1 + 388) & 1) == 0 )
{
goto LABEL_121;
}
sub_610B54(a1, 10);
sub_610B08(a1);
return 0;
}