//
// sub_D77C14 from 0xd77c14 to 0xd780a0 (1164 bytes)
//
// 1 xrefs:
// > ??> @ 0x11223d8
//
// 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
//
__int64 __fastcall sub_D77C14(__int64 a1, const void *a2, int a3)
{
unsigned int *v3; // x19
__int64 v6; // x1
__int64 (__fastcall *v8)(__int64, __int64, _QWORD); // x22
unsigned int v9; // w20
unsigned int v11; // w0
int v12; // w3
__int64 v13; // x0
int v14; // w20
int v15; // w0
unsigned int v16; // w0
int v17; // w20
unsigned __int16 *v18; // x0
__int64 v19; // x0
unsigned int v20; // w0
__int64 v21; // x0
_BOOL8 v22; // x0
unsigned int *v23; // x0
unsigned int *v24; // x0
int v25; // [xsp+68h] [xbp+68h]
__int64 v26; // [xsp+68h] [xbp+68h]
v3 = *(unsigned int **)(a1 + 48);
v6 = *v3;
if ( (_DWORD)v6 == 5 )
goto LABEL_8;
v8 = *((__int64 (__fastcall **)(__int64, __int64, _QWORD))v3 + 6);
v9 = -1;
while ( 2 )
{
switch ( (int)v6 )
{
case 1:
if ( *((_QWORD *)v3 + 1) || *((_QWORD *)v3 + 2) )
{
*v3 = 2;
if ( !v8 )
goto LABEL_13;
v6 = 2;
goto LABEL_24;
}
ERR_put_error(32, 115, 144, "crypto/bio/bss_conn.c", 83);
ERR_add_error_data(4, "hostname=", *((_QWORD *)v3 + 1));
if ( v8 )
goto LABEL_5;
goto LABEL_7;
case 2:
LABEL_13:
v11 = v3[1];
switch ( v11 )
{
case 6u:
v12 = 10;
break;
case 0x100u:
v12 = 0;
break;
case 4u:
v12 = 2;
break;
default:
ERR_put_error(32, 115, 146, "crypto/bio/bss_conn.c", 116);
if ( v8 )
goto LABEL_5;
goto LABEL_7;
}
if ( !(unsigned int)BIO_lookup(
*((char **)v3 + 1),
*((const char **)v3 + 2),
0,
v12,
1,
(struct addrinfo **)v3 + 4) )
{
LABEL_4:
if ( v8 )
goto LABEL_5;
goto LABEL_7;
}
v13 = *((_QWORD *)v3 + 4);
if ( !v13 )
{
ERR_put_error(32, 115, 142, "crypto/bio/bss_conn.c", 125);
if ( v8 )
goto LABEL_5;
goto LABEL_7;
}
*((_QWORD *)v3 + 5) = v13;
*v3 = 3;
if ( v8 )
{
v6 = 3;
goto LABEL_24;
}
LABEL_19:
v14 = BIO_ADDRINFO_family(*((_QWORD *)v3 + 5));
v25 = BIO_ADDRINFO_socktype(*((_QWORD *)v3 + 5));
v15 = BIO_ADDRINFO_protocol(*((_DWORD **)v3 + 5));
v16 = BIO_socket(v14, v25, v15);
v9 = v16;
if ( v16 == -1 )
{
v23 = (unsigned int *)__errno();
ERR_put_error(2, 4, *v23, "crypto/bio/bss_conn.c", 137);
ERR_add_error_data(4, "hostname=", *((_QWORD *)v3 + 1));
ERR_put_error(32, 115, 118, "crypto/bio/bss_conn.c", 141);
if ( v8 )
goto LABEL_5;
return v9;
}
*(_DWORD *)(a1 + 40) = v16;
*v3 = 4;
if ( v8 )
{
v6 = 4;
goto LABEL_24;
}
LABEL_21:
BIO_clear_flags(a1, 15);
v17 = *(_DWORD *)(a1 + 40);
v18 = (unsigned __int16 *)BIO_ADDRINFO_address(*((_QWORD *)v3 + 5));
v19 = BIO_connect(v17, v18, *((_BYTE *)v3 + 24) | 4u);
*(_DWORD *)(a1 + 36) = 0;
v9 = v19;
if ( (_DWORD)v19 )
{
LABEL_22:
*v3 = 5;
if ( !v8 )
goto LABEL_8;
v6 = 5;
LABEL_24:
v9 = v8(a1, v6, v9);
if ( !v9 )
return v9;
v6 = *v3;
continue;
}
if ( (unsigned int)BIO_sock_should_retry(v19) )
{
BIO_set_flags(a1, 12);
*v3 = 6;
*(_DWORD *)(a1 + 36) = 2;
ERR_clear_error(2);
if ( v8 )
goto LABEL_5;
return v9;
}
v21 = BIO_ADDRINFO_next(*((_QWORD *)v3 + 5));
*((_QWORD *)v3 + 5) = v21;
if ( v21 )
{
v22 = BIO_closesocket(*(_DWORD *)(a1 + 40));
*v3 = 3;
ERR_clear_error(v22);
v6 = *v3;
if ( v8 )
goto LABEL_24;
continue;
}
v24 = (unsigned int *)__errno();
ERR_put_error(2, 2, *v24, "crypto/bio/bss_conn.c", 169);
ERR_add_error_data(4, "hostname=", *((_QWORD *)v3 + 1));
ERR_put_error(32, 115, 103, "crypto/bio/bss_conn.c", 173);
if ( !v8 )
return v9;
LABEL_5:
v6 = *v3;
LABEL_6:
v9 = v8(a1, v6, v9);
LABEL_7:
if ( (int)v9 > 0 )
{
LABEL_8:
*(_DWORD *)__errno() = 0;
v9 = write(*(_DWORD *)(a1 + 40), a2, a3);
BIO_clear_flags(a1, 15);
if ( (int)v9 <= 0 && (unsigned int)BIO_sock_should_retry(v9) )
BIO_set_flags(a1, 10);
}
return v9;
case 3:
goto LABEL_19;
case 4:
goto LABEL_21;
case 5:
v9 = 1;
if ( !v8 )
goto LABEL_8;
goto LABEL_6;
case 6:
v20 = BIO_sock_error(*(_DWORD *)(a1 + 40));
if ( !v20 )
goto LABEL_22;
v26 = v20;
BIO_clear_flags(a1, 15);
v9 = 0;
ERR_put_error(2, 2, v26, "crypto/bio/bss_conn.c", 185);
ERR_add_error_data(4, "hostname=", *((_QWORD *)v3 + 1));
ERR_put_error(32, 115, 110, "crypto/bio/bss_conn.c", 189);
if ( !v8 )
return v9;
goto LABEL_5;
default:
goto LABEL_4;
}
}
}