//
// a2i_ipadd from 0x85e0fc to 0x85e2a4 (424 bytes)
//
// 8 xrefs:
// > X509_VERIFY_PARAM_set1_ip_asc @ 0x847268
// > sub_84F580 @ 0x84f794
// > sub_84F580 @ 0x84f994
// > X509_check_ip_asc @ 0x85e2cc
// > a2i_IPADDRESS @ 0x85e320
// > a2i_IPADDRESS_NC @ 0x85e3c8
// > a2i_IPADDRESS_NC @ 0x85e3dc
// > ??> @ 0x67a0c
//
// 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 a2i_ipadd(_BYTE *a1, char *a2)
{
size_t v4; // r4
int v5; // r7
bool v6; // zf
int result; // r0
char v8; // r2
char v9; // r1
char v10; // r12
bool v11; // zf
unsigned int v12; // [sp+8h] [bp-2Ch] BYREF
unsigned int v13; // [sp+Ch] [bp-28h] BYREF
unsigned int v14; // [sp+10h] [bp-24h] BYREF
_DWORD v15[4]; // [sp+14h] [bp-20h] BYREF
int v16; // [sp+24h] [bp-10h]
size_t v17; // [sp+28h] [bp-Ch]
int v18; // [sp+2Ch] [bp-8h]
if ( strchr(a2, 58) )
{
v16 = 0;
v18 = 0;
v17 = -1;
if ( CONF_parse_list(a2, 58, 0, (int (__fastcall *)(const char *, int, int))sub_85C18C, (int)v15) )
{
v4 = v17;
if ( v17 == -1 )
{
if ( v16 == 16 )
goto LABEL_17;
}
else
{
v5 = v16;
if ( v16 != 16 && v18 <= 3 )
{
if ( v18 == 3 )
{
if ( v16 <= 0 )
goto LABEL_11;
}
else if ( v18 == 2 )
{
v11 = v17 == 0;
if ( v17 )
v11 = v17 == v16;
if ( v11 )
{
LABEL_11:
if ( (v17 & 0x80000000) == 0 )
{
memcpy(a1, v15, v17);
memset(&a1[v4], 0, 16 - v5);
if ( v4 != v5 )
memcpy(&a1[v4 + 16 - v5], (char *)v15 + v4, v5 - v4);
return 16;
}
LABEL_17:
memcpy(a1, v15, 0x10u);
return 16;
}
}
else
{
v6 = v17 == v16;
if ( v17 != v16 )
v6 = v17 == 0;
if ( !v6 )
goto LABEL_11;
}
}
}
}
return 0;
}
result = sscanf(a2, "%d.%d.%d.%d", &v12, &v13, &v14, v15);
if ( result != 4 )
return 0;
if ( v12 > 0xFF )
return 0;
v8 = v13;
if ( v13 > 0xFF )
return 0;
v9 = v14;
if ( v14 > 0xFF )
return 0;
v10 = v15[0];
if ( v15[0] > 0xFFu )
return 0;
*a1 = v12;
a1[1] = v8;
a1[2] = v9;
a1[3] = v10;
return result;
}