//
// sub_FEFF40 from 0xfeff40 to 0xff01e8 (680 bytes)
//
// 2 xrefs:
// > BIO_ADDR_hostname_string @ 0xff022c
// > BIO_ADDR_service_string @ 0xff0288
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:15:45 +0000
//
__int64 __fastcall sub_FEFF40(unsigned __int16 *a1, int a2, __int64 *a3, __int64 *a4)
{
int v8; // w6
const struct sockaddr *v9; // x0
const struct sockaddr *v10; // x22
socklen_t v11; // w0
int v12; // w0
int v13; // w22
const char *v14; // x0
__int64 v15; // x2
__int64 v17; // x0
__int64 v18; // x0
__int64 v19; // x19
unsigned int v20; // w0
unsigned int *v21; // x0
int v22; // [xsp+58h] [xbp+58h]
char v23; // [xsp+68h] [xbp+68h] BYREF
__int64 v24; // [xsp+69h] [xbp+69h]
__int64 v25; // [xsp+71h] [xbp+71h]
__int64 v26; // [xsp+79h] [xbp+79h]
int v27; // [xsp+81h] [xbp+81h]
__int16 v28; // [xsp+85h] [xbp+85h]
char v29; // [xsp+87h] [xbp+87h]
char v30; // [xsp+88h] [xbp+88h] BYREF
_BYTE v31[7]; // [xsp+89h] [xbp+89h] BYREF
v30 = 0;
memset(v31, 0, 0x400u);
if ( a2 )
v8 = 10;
else
v8 = 0;
v22 = v8;
v23 = 0;
v24 = 0;
v25 = 0;
v26 = 0;
v27 = 0;
v28 = 0;
v29 = 0;
BIO_ADDR_sockaddr();
v10 = v9;
v11 = BIO_ADDR_sockaddr_size(a1);
v12 = getnameinfo(v10, v11, &v30, 0x401u, &v23, 0x20u, v22);
v13 = v12;
if ( v12 )
{
if ( v12 == 11 )
{
v21 = (unsigned int *)__errno();
ERR_put_error(2, 13, *v21, "crypto/bio/b_addr.c", 210);
ERR_put_error(32, 134, 2, "crypto/bio/b_addr.c", 211);
}
else
{
ERR_put_error(32, 134, 2, "crypto/bio/b_addr.c", 215);
v14 = gai_strerror(v13);
ERR_add_error_data(1, v14, v15);
}
return 0;
}
if ( v23 )
{
if ( a3 )
goto LABEL_10;
LABEL_14:
if ( !a4 )
return 1;
v19 = CRYPTO_strdup(&v23, "crypto/bio/b_addr.c", 235);
*a4 = v19;
if ( v19 )
return 1;
goto LABEL_20;
}
v20 = BIO_ADDR_rawport(a1);
BIO_snprintf(&v23, 32, "%d", (unsigned __int16)__rev16(v20));
if ( !a3 )
goto LABEL_14;
LABEL_10:
v17 = CRYPTO_strdup(&v30, "crypto/bio/b_addr.c", 233);
*a3 = v17;
if ( !a4 )
{
if ( v17 )
return 1;
CRYPTO_free(0, "crypto/bio/b_addr.c", 250);
*a3 = 0;
LABEL_23:
ERR_put_error(32, 134, 65, "crypto/bio/b_addr.c", 257);
return 0;
}
v18 = CRYPTO_strdup(&v23, "crypto/bio/b_addr.c", 235);
*a4 = v18;
if ( !*a3 )
{
CRYPTO_free(0, "crypto/bio/b_addr.c", 250);
*a3 = 0;
v19 = *a4;
LABEL_22:
CRYPTO_free(v19, "crypto/bio/b_addr.c", 254);
*a4 = 0;
goto LABEL_23;
}
v19 = v18;
if ( !v18 )
{
LABEL_20:
if ( a3 )
{
CRYPTO_free(*a3, "crypto/bio/b_addr.c", 250);
*a3 = v19;
v19 = *a4;
}
goto LABEL_22;
}
return 1;
}