//
// a2i_ipadd from 0xe0478c to 0xe0494c (448 bytes)
//
// 8 xrefs:
// > X509_VERIFY_PARAM_set1_ip_asc @ 0xdeee74
// > sub_DF6EDC @ 0xdf70bc
// > sub_DF6EDC @ 0xdf721c
// > X509_check_ip_asc @ 0xe04970
// > a2i_IPADDRESS @ 0xe049d4
// > a2i_IPADDRESS_NC @ 0xe04a94
// > a2i_IPADDRESS_NC @ 0xe04aa8
// > ??> @ 0x5cbc8
//
// 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 a2i_ipadd(char *a1, char *a2)
{
int v4; // w19
int v5; // w22
__int64 result; // x0
__int64 v7; // x1
char v8; // w2
char v9; // w3
char v10; // w4
unsigned int v11; // [xsp+44h] [xbp+44h] BYREF
unsigned int v12; // [xsp+48h] [xbp+48h] BYREF
unsigned int v13; // [xsp+4Ch] [xbp+4Ch] BYREF
_QWORD v14[2]; // [xsp+50h] [xbp+50h] BYREF
int v15; // [xsp+60h] [xbp+60h]
int v16; // [xsp+64h] [xbp+64h]
int v17; // [xsp+68h] [xbp+68h]
if ( !strchr(a2, 58) )
{
result = sscanf(a2, "%d.%d.%d.%d", &v11, &v12, &v13, v14);
if ( (_DWORD)result == 4 && v11 <= 0xFF )
{
v8 = v12;
if ( v12 <= 0xFF )
{
v9 = v13;
if ( v13 <= 0xFF )
{
v10 = v14[0];
if ( LODWORD(v14[0]) <= 0xFF )
{
*a1 = v11;
a1[1] = v8;
a1[2] = v9;
a1[3] = v10;
return result;
}
}
}
}
return 0;
}
v15 = 0;
v16 = -1;
v17 = 0;
if ( !(unsigned int)CONF_parse_list(
a2,
58,
0,
(__int64 (__fastcall *)(const char *, _QWORD, __int64))sub_E02A64,
(__int64)v14) )
return 0;
v4 = v16;
if ( v16 == -1 )
{
if ( v15 == 16 )
goto LABEL_20;
return 0;
}
v5 = v15;
if ( v15 == 16 || v17 > 3 )
return 0;
if ( v17 == 3 )
{
if ( v15 <= 0 )
goto LABEL_10;
return 0;
}
if ( v17 != 2 )
{
if ( v16 && v16 != v15 )
goto LABEL_10;
return 0;
}
if ( v16 && v16 != v15 )
return 0;
LABEL_10:
if ( v16 < 0 )
{
LABEL_20:
v7 = v14[1];
*(_QWORD *)a1 = v14[0];
*((_QWORD *)a1 + 1) = v7;
return 16;
}
memcpy(a1, v14, v16);
memset(&a1[v4], 0, 16 - v5);
if ( v4 != v5 )
memcpy(&a1[v4 + 16LL - v5], (char *)v14 + v4, v5 - v4);
return 16;
}