//
// sub_9E6944 from 0x9e6944 to 0x9e6e0c (1224 bytes)
//
// 1 xrefs:
// > ??> @ 0xc77a38
//
// 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:24 +0000
//
ssize_t __fastcall sub_9E6944(_DWORD *a1, const void *a2, size_t a3)
{
struct addrinfo **v3; // r11
struct addrinfo *v5; // r1
struct addrinfo *v8; // r6
ssize_t v9; // r4
int v10; // r0
ssize_t result; // r0
struct addrinfo *v12; // r3
unsigned int v13; // r3
struct addrinfo *v14; // r3
int v15; // r4
int v16; // r0
int v17; // r0
int v18; // r4
unsigned __int16 *v19; // r0
int v20; // r0
int v21; // r0
_BOOL4 v22; // r0
_DWORD *v23; // r0
_DWORD *v24; // r0
int v25; // r0
struct addrinfo **v26; // [sp+8h] [bp-Ch]
int v27; // [sp+Ch] [bp-8h]
v3 = (struct addrinfo **)a1[8];
v5 = *v3;
if ( *v3 == (struct addrinfo *)&byte_5 )
goto LABEL_6;
v8 = v3[7];
v9 = -1;
while ( 2 )
{
switch ( (unsigned int)v5 )
{
case 1u:
if ( !v3[2] && !v3[3] )
{
ERR_put_error(32, 115, 144, "crypto/bio/bss_conn.c", 83);
ERR_add_error_data(4, "hostname=", v3[2]);
goto LABEL_14;
}
*v3 = (struct addrinfo *)(&dword_0 + 2);
if ( v8 )
goto LABEL_29;
goto LABEL_10;
case 2u:
LABEL_10:
v12 = v3[1];
if ( v12 == (struct addrinfo *)&byte_6 )
{
v13 = 10;
}
else if ( v12 == (struct addrinfo *)&dword_100 )
{
v13 = 0;
}
else
{
if ( v12 != (struct addrinfo *)&byte_4 )
{
ERR_put_error(32, 115, 146, "crypto/bio/bss_conn.c", 116);
goto LABEL_14;
}
v13 = 2;
}
if ( !BIO_lookup((const char *)v3[2], (const char *)v3[3], 0, v13, 1, v3 + 5) )
goto LABEL_14;
v14 = v3[5];
if ( v14 )
{
v3[6] = v14;
*v3 = (struct addrinfo *)(&dword_0 + 3);
if ( v8 )
goto LABEL_29;
LABEL_23:
v27 = BIO_ADDRINFO_family((int)v3[6]);
v15 = BIO_ADDRINFO_socktype((int)v3[6]);
v16 = BIO_ADDRINFO_protocol(v3[6]);
v17 = BIO_socket(v27, v15, v16);
v9 = v17;
if ( v17 == -1 )
{
v23 = (_DWORD *)_errno();
ERR_put_error(2, 4, *v23, "crypto/bio/bss_conn.c", 137);
ERR_add_error_data(4, "hostname=", v3[2]);
ERR_put_error(32, 115, 118, "crypto/bio/bss_conn.c", 141);
goto LABEL_44;
}
a1[7] = v17;
*v3 = (struct addrinfo *)&byte_4;
if ( v8 )
{
LABEL_29:
v9 = ((int (__fastcall *)(_DWORD *))v8)(a1);
if ( !v9 )
return v9;
v5 = *v3;
}
else
{
LABEL_25:
BIO_clear_flags((int)a1, 15);
v18 = a1[7];
v19 = (unsigned __int16 *)BIO_ADDRINFO_address((int)v3[6]);
v20 = BIO_connect(v18, v19, *((_BYTE *)v3 + 16) | 4);
a1[6] = 0;
v9 = v20;
if ( v20 )
{
LABEL_5:
*v3 = (struct addrinfo *)&byte_5;
if ( !v8 )
goto LABEL_6;
goto LABEL_29;
}
if ( BIO_sock_should_retry(0) )
{
v25 = BIO_set_flags((int)a1, 12);
*v3 = (struct addrinfo *)&byte_6;
a1[6] = 2;
ERR_clear_error(v25);
LABEL_44:
if ( v8 )
goto LABEL_15;
return v9;
}
v21 = BIO_ADDRINFO_next((int)v3[6]);
v3[6] = (struct addrinfo *)v21;
if ( !v21 )
{
v24 = (_DWORD *)_errno();
ERR_put_error(2, 2, *v24, "crypto/bio/bss_conn.c", 169);
ERR_add_error_data(4, "hostname=", v3[2]);
ERR_put_error(32, 115, 103, "crypto/bio/bss_conn.c", 173);
goto LABEL_44;
}
v22 = BIO_closesocket(a1[7]);
*v3 = (struct addrinfo *)(&dword_0 + 3);
ERR_clear_error(v22);
v5 = *v3;
if ( v8 )
goto LABEL_29;
}
continue;
}
ERR_put_error(32, 115, 142, "crypto/bio/bss_conn.c", 125);
LABEL_14:
if ( v8 )
{
LABEL_15:
v5 = *v3;
LABEL_16:
v9 = ((int (__fastcall *)(_DWORD *, struct addrinfo *, ssize_t))v8)(a1, v5, v9);
}
if ( v9 <= 0 )
return v9;
LABEL_6:
*(_DWORD *)_errno() = 0;
v9 = write(a1[7], a2, a3);
BIO_clear_flags((int)a1, 15);
result = v9;
if ( v9 <= 0 )
{
if ( !BIO_sock_should_retry(v9) )
return v9;
BIO_set_flags((int)a1, 10);
return v9;
}
return result;
case 3u:
goto LABEL_23;
case 4u:
goto LABEL_25;
case 5u:
if ( !v8 )
goto LABEL_6;
v9 = 1;
goto LABEL_16;
case 6u:
v10 = BIO_sock_error(a1[7]);
if ( !v10 )
goto LABEL_5;
v26 = (struct addrinfo **)v10;
BIO_clear_flags((int)a1, 15);
ERR_put_error(2, 2, v26, "crypto/bio/bss_conn.c", 185);
ERR_add_error_data(4, "hostname=", v3[2]);
ERR_put_error(32, 115, 110, "crypto/bio/bss_conn.c", 189);
v9 = 0;
goto LABEL_44;
default:
goto LABEL_14;
}
}
}