//
// sub_62E754 from 0x62e754 to 0x62e8ea (406 bytes)
//
// 14 xrefs:
// > sub_62FEB0 @ 0x62ff88
// > sub_630064 @ 0x630256
// > sub_630064 @ 0x63053e
// > sub_630064 @ 0x6307b8
// > sub_630064 @ 0x630860
// > sub_630064 @ 0x630ac0
// > sub_630064 @ 0x630b84
// > sub_630064 @ 0x630d14
// > sub_630064 @ 0x630d46
// > sub_630064 @ 0x630e1c
// > sub_630064 @ 0x630f72
// > sub_630064 @ 0x631058
// > sub_630064 @ 0x6310bc
// > sub_630064 @ 0x63117a
//
// 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_62E754(size_t **a1, int a2, int a3)
{
size_t *v3; // r6
size_t v5; // r5
int v6; // r7
int result; // r0
int (__fastcall *v10)(size_t *, int, int); // r3
_BOOL4 v11; // r0
_DWORD *v12; // r1
int v13; // r3
int v14; // r0
int v15; // r3
int v16; // r2
int v17; // r3
bool v18; // nf
const char *v19; // r3
size_t *v20; // r0
size_t *v21; // r9
v3 = *a1;
v5 = **a1;
v6 = *(unsigned __int8 *)(v5 + 34724);
if ( *(_BYTE *)(v5 + 34724) )
return 0;
sub_6210D8(**a1, (int)v3);
off_ABAEB0(*(void **)(v5 + 316));
*(_DWORD *)(v5 + 316) = v6;
off_ABAEB0(*(void **)(v5 + 312));
*(_DWORD *)(v5 + 312) = v6;
if ( a2 == 26 || a2 == 42 || a2 == 23 )
a3 = 1;
v10 = *(int (__fastcall **)(size_t *, int, int))(v3[166] + 12);
if ( v10 )
a2 = v10(v3, a2, a3);
if ( a2 != 42 )
{
v11 = sub_6115FC((int *)v3) != 0;
if ( a2 )
v11 = 0;
if ( v11 )
a2 = 42;
}
if ( !(*(_DWORD *)(v3[183] + 12) + *(_DWORD *)(v3[182] + 12))
|| *(_BYTE *)(v5 + 914)
|| (result = *((unsigned __int8 *)v3 + 613), *((_BYTE *)v3 + 613)) )
{
*(_BYTE *)(v5 + 34724) = 1;
v12 = (_DWORD *)v3[18];
if ( v12 )
{
sub_610524(v5, v12);
v3[18] = 0;
}
off_ABAEB0(*(void **)(v5 + 34468));
v13 = *(unsigned __int8 *)(v5 + 914);
*(_DWORD *)(v5 + 34468) = 0;
if ( v13 && v3[189] != 2 && v3[195] != 2 || a3 | *((unsigned __int8 *)v3 + 613) )
{
v14 = sub_620F5C((int)v3, a3);
v15 = v14;
if ( v14 )
v15 = 1;
if ( a2 )
v15 = 0;
if ( v15 )
a2 = v14;
}
else
{
v16 = *(_DWORD *)(v5 + 64);
v17 = *(_DWORD *)(v16 + 148);
v18 = v17 < 0;
if ( v17 < 0 )
v17 = *(_DWORD *)(v16 + 12);
*((_BYTE *)v3 + 64) = 0;
if ( v18 )
v17 *= 4;
if ( v17
&& (unsigned int)v17 < *(_DWORD *)(*(_DWORD *)(v5 + 1640) + 24)
&& (sub_61807C(v5, "Connection cache is full, closing the oldest one.\n"),
v20 = (size_t *)sub_621154(v5),
(v21 = v20) != nullptr)
&& (*v20 = v5, sub_620F5C((int)v20, 0), v3 == v21) )
{
*(_DWORD *)(v5 + 1656) = 0;
}
else
{
*(_DWORD *)(v5 + 1656) = v3;
if ( *((_BYTE *)v3 + 618) )
v19 = (const char *)v3[48];
else
v19 = (const char *)v3[39];
sub_61807C(v5, "Connection #%ld to host %s left intact\n", v3[17], v19);
}
}
*a1 = nullptr;
sub_6213F8(v5);
return a2;
}
else
{
*(_DWORD *)(v5 + 8) = result;
}
return result;
}