//
// sub_E1A400 from 0xe1a400 to 0xe1a614 (532 bytes)
//
// 1 xrefs:
// > sub_E157E8 @ 0xe158bc
//
// 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:09:43 +0000
//
__int64 __fastcall sub_E1A400(const char *a1, const char *a2, const struct addrinfo *a3, void ***a4)
{
__int64 result; // x0
struct addrinfo *v6; // x19
_QWORD *v7; // x24
void **v8; // x22
int ai_family; // w1
int v10; // w23
size_t v11; // x21
socklen_t ai_addrlen; // w1
void *v13; // x20
int ai_flags; // w5
int v15; // w4
int ai_protocol; // w2
void *(*v17)(size_t); // x1
void *v18; // x0
const char *ai_canonname; // x0
char *v20; // x0
void **v21; // x0
struct addrinfo *v22; // [xsp+68h] [xbp+68h] BYREF
*a4 = nullptr;
result = getaddrinfo(a1, a2, a3, &v22);
if ( (_DWORD)result )
return result;
v6 = v22;
if ( !v22 )
{
*a4 = nullptr;
return 8;
}
v7 = nullptr;
v8 = nullptr;
while ( 1 )
{
while ( 1 )
{
ai_family = v6->ai_family;
if ( ai_family == 2 )
break;
if ( ai_family == 10 )
{
v10 = 28;
v11 = 28;
goto LABEL_8;
}
LABEL_5:
v6 = v6->ai_next;
if ( !v6 )
goto LABEL_19;
}
v10 = 16;
v11 = 16;
LABEL_8:
if ( !v6->ai_addr )
goto LABEL_5;
ai_addrlen = v6->ai_addrlen;
if ( !ai_addrlen || v11 > ai_addrlen )
goto LABEL_5;
v13 = off_154A3C0(0x30u);
if ( !v13 )
goto LABEL_29;
ai_flags = v6->ai_flags;
v15 = v6->ai_family;
ai_protocol = v6->ai_protocol;
v17 = off_154A3C0;
*((_DWORD *)v13 + 2) = v6->ai_socktype;
*(_DWORD *)v13 = ai_flags;
*((_DWORD *)v13 + 1) = v15;
*((_DWORD *)v13 + 3) = ai_protocol;
*((_DWORD *)v13 + 4) = v10;
*((_QWORD *)v13 + 4) = 0;
*((_QWORD *)v13 + 3) = 0;
*((_QWORD *)v13 + 5) = 0;
v18 = v17(v11);
*((_QWORD *)v13 + 4) = v18;
if ( !v18 )
{
off_154A3C8(v13);
goto LABEL_29;
}
memcpy(v18, v6->ai_addr, v11);
ai_canonname = v6->ai_canonname;
if ( ai_canonname )
{
v20 = off_154A3D8(ai_canonname);
*((_QWORD *)v13 + 3) = v20;
if ( !v20 )
break;
}
if ( !v8 )
v8 = (void **)v13;
if ( !v7 )
{
v7 = v13;
goto LABEL_5;
}
v6 = v6->ai_next;
v7[5] = v13;
v7 = v13;
if ( !v6 )
{
LABEL_19:
if ( v22 )
freeaddrinfo(v22);
if ( v8 )
result = 0;
else
result = 8;
*a4 = v8;
return result;
}
}
off_154A3C8(*((void **)v13 + 4));
off_154A3C8(v13);
LABEL_29:
if ( v22 )
freeaddrinfo(v22);
while ( v8 )
{
off_154A3C8(v8[4]);
off_154A3C8(v8[3]);
v21 = v8;
v8 = (void **)v8[5];
off_154A3C8(v21);
}
*a4 = nullptr;
return 6;
}