//
// sub_635B08 from 0x635b08 to 0x635c40 (312 bytes)
//
// 1 xrefs:
// > sub_6326AC @ 0x63272c
//
// 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
//
int __fastcall sub_635B08(const char *a1, const char *a2, const struct addrinfo *a3, int **a4)
{
int result; // r0
struct addrinfo *v5; // r4
int *v6; // r8
int *v7; // r7
int v8; // r6
size_t v9; // r11
int ai_family; // r3
int ai_addrlen; // r3
int *v12; // r5
void *(*v13)(size_t); // r1
int ai_protocol; // r2
void *v15; // r0
const char *ai_canonname; // r0
char *v17; // r0
int *v18; // r5
struct addrinfo *v20; // [sp+Ch] [bp-8h] BYREF
*a4 = nullptr;
result = getaddrinfo(a1, a2, a3, &v20);
if ( result )
return result;
v5 = v20;
if ( !v20 )
{
v7 = nullptr;
result = 8;
goto LABEL_25;
}
v6 = nullptr;
v7 = nullptr;
while ( 1 )
{
while ( 1 )
{
ai_family = v5->ai_family;
if ( ai_family == 2 )
{
v8 = 16;
v9 = 16;
goto LABEL_9;
}
if ( ai_family == 10 )
break;
LABEL_6:
v5 = v5->ai_next;
if ( !v5 )
goto LABEL_20;
}
v8 = 28;
v9 = 28;
LABEL_9:
if ( !v5->ai_addr )
goto LABEL_6;
ai_addrlen = v5->ai_addrlen;
if ( ai_addrlen <= 0 || v9 > ai_addrlen )
goto LABEL_6;
v12 = (int *)off_ABAEAC(0x20u);
if ( !v12 )
goto LABEL_29;
*v12 = v5->ai_flags;
v13 = off_ABAEAC;
v12[1] = v5->ai_family;
v12[2] = v5->ai_socktype;
ai_protocol = v5->ai_protocol;
v12[4] = v8;
v12[6] = 0;
v12[3] = ai_protocol;
v12[5] = 0;
v12[7] = 0;
v15 = v13(v9);
v12[6] = (int)v15;
if ( !v15 )
{
off_ABAEB0(v12);
goto LABEL_29;
}
memcpy(v15, v5->ai_addr, v9);
ai_canonname = v5->ai_canonname;
if ( ai_canonname )
{
v17 = off_ABAEB8(ai_canonname);
v12[5] = (int)v17;
if ( !v17 )
break;
}
if ( !v7 )
v7 = v12;
if ( !v6 )
{
v6 = v12;
goto LABEL_6;
}
v6[7] = (int)v12;
v6 = v12;
v5 = v5->ai_next;
if ( !v5 )
{
LABEL_20:
if ( v20 )
freeaddrinfo(v20);
if ( v7 )
result = 0;
else
result = 8;
goto LABEL_25;
}
}
off_ABAEB0((void *)v12[6]);
off_ABAEB0(v12);
LABEL_29:
if ( v20 )
freeaddrinfo(v20);
if ( v7 )
{
do
{
off_ABAEB0((void *)v7[6]);
off_ABAEB0((void *)v7[5]);
v18 = (int *)v7[7];
off_ABAEB0(v7);
v7 = v18;
}
while ( v18 );
}
result = 6;
v7 = nullptr;
LABEL_25:
*a4 = v7;
return result;
}