//
// sub_9E60BC from 0x9e60bc to 0x9e64fc (1088 bytes)
//
// 2 xrefs:
// > sub_9E6534 @ 0x9e66d4
// > sub_9E68A8 @ 0x9e68d4
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:07:23 +0000
//
int __fastcall sub_9E60BC(int a1, int *a2)
{
int (__fastcall *v2)(int); // r4
struct addrinfo **v5; // r11
int v6; // r6
int v7; // r1
int v9; // r2
int v10; // r3
unsigned int v11; // r3
int v12; // r3
int v13; // r6
int v14; // r0
int v15; // r0
int v16; // r6
unsigned __int16 *v17; // r0
int v18; // r0
int v19; // r0
_BOOL4 v20; // r0
_DWORD *v21; // r0
int v22; // r0
_DWORD *v23; // r0
int v24; // [sp+Ch] [bp-8h]
int v25; // [sp+Ch] [bp-8h]
v2 = (int (__fastcall *)(int))a2[7];
v5 = (struct addrinfo **)(a2 + 5);
v6 = -1;
LABEL_2:
v7 = *a2;
while ( 2 )
{
switch ( v7 )
{
case 1:
if ( !a2[2] && !a2[3] )
{
ERR_put_error(32, 115, 144, "crypto/bio/bss_conn.c", 83);
ERR_add_error_data(4, "hostname=", a2[2]);
goto LABEL_5;
}
*a2 = 2;
if ( v2 )
goto LABEL_26;
goto LABEL_13;
case 2:
LABEL_13:
v10 = a2[1];
switch ( v10 )
{
case 6:
v11 = 10;
goto LABEL_17;
case 256:
v11 = 0;
LABEL_17:
if ( !BIO_lookup((const char *)a2[2], (const char *)a2[3], 0, v11, 1, v5) )
goto LABEL_5;
v12 = a2[5];
if ( !v12 )
{
ERR_put_error(32, 115, 142, "crypto/bio/bss_conn.c", 125);
goto LABEL_5;
}
a2[6] = v12;
*a2 = 3;
if ( v2 )
goto LABEL_26;
LABEL_20:
v24 = BIO_ADDRINFO_family(a2[6]);
v13 = BIO_ADDRINFO_socktype(a2[6]);
v14 = BIO_ADDRINFO_protocol((_DWORD *)a2[6]);
v15 = BIO_socket(v24, v13, v14);
v6 = v15;
if ( v15 == -1 )
{
v21 = (_DWORD *)_errno();
ERR_put_error(2, 4, *v21, "crypto/bio/bss_conn.c", 137);
ERR_add_error_data(4, "hostname=", a2[2]);
ERR_put_error(32, 115, 118, "crypto/bio/bss_conn.c", 141);
goto LABEL_5;
}
*(_DWORD *)(a1 + 28) = v15;
*a2 = 4;
if ( v2 )
goto LABEL_26;
LABEL_22:
BIO_clear_flags(a1, 15);
v16 = *(_DWORD *)(a1 + 28);
v17 = (unsigned __int16 *)BIO_ADDRINFO_address(a2[6]);
v18 = BIO_connect(v16, v17, *((_BYTE *)a2 + 16) | 4);
*(_DWORD *)(a1 + 24) = 0;
v6 = v18;
if ( !v18 )
{
if ( BIO_sock_should_retry() )
{
v22 = BIO_set_flags(a1, 12);
*a2 = 6;
*(_DWORD *)(a1 + 24) = 2;
ERR_clear_error(v22);
goto LABEL_5;
}
v19 = BIO_ADDRINFO_next(a2[6]);
a2[6] = v19;
if ( !v19 )
{
v23 = (_DWORD *)_errno();
ERR_put_error(2, 2, *v23, "crypto/bio/bss_conn.c", 169);
ERR_add_error_data(4, "hostname=", a2[2]);
ERR_put_error(32, 115, 103, "crypto/bio/bss_conn.c", 173);
goto LABEL_5;
}
v20 = BIO_closesocket(*(_DWORD *)(a1 + 28));
*a2 = 3;
ERR_clear_error(v20);
v7 = *a2;
if ( v2 )
goto LABEL_26;
continue;
}
LABEL_8:
*a2 = 5;
if ( !v2 )
return 1;
LABEL_26:
v6 = v2(a1);
if ( !v6 )
return v6;
goto LABEL_2;
case 4:
v11 = 2;
goto LABEL_17;
}
ERR_put_error(32, 115, 146, "crypto/bio/bss_conn.c", 116);
LABEL_5:
if ( !v2 )
return v6;
return ((int (__fastcall *)(int, _DWORD, int))v2)(a1, *a2, v6);
case 3:
goto LABEL_20;
case 4:
goto LABEL_22;
case 5:
v6 = 1;
goto LABEL_5;
case 6:
v9 = BIO_sock_error(*(_DWORD *)(a1 + 28));
if ( !v9 )
goto LABEL_8;
v25 = v9;
BIO_clear_flags(a1, 15);
ERR_put_error(2, 2, v25, "crypto/bio/bss_conn.c", 185);
ERR_add_error_data(4, "hostname=", a2[2]);
ERR_put_error(32, 115, 110, "crypto/bio/bss_conn.c", 189);
v6 = 0;
goto LABEL_5;
default:
goto LABEL_5;
}
}
}