//
// sub_85C18C from 0x85c18c to 0x85c2e4 (344 bytes)
//
// 3 xrefs:
// > a2i_ipadd @ 0x85e120
// > a2i_ipadd @ 0x85e140
// > ??> @ 0x85e2a4
//
// 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_85C18C(const char *a1, int a2, _DWORD *a3)
{
int v3; // r7
int v5; // r3
char *v7; // r8
char v8; // r1
char v9; // r0
char v10; // r12
_BYTE *v11; // r3
int v12; // r4
int v13; // r3
char v14; // t1
int v15; // r5
int v16; // r0
unsigned int v17; // [sp+8h] [bp-10h] BYREF
unsigned int v18; // [sp+Ch] [bp-Ch] BYREF
unsigned int v19; // [sp+10h] [bp-8h] BYREF
unsigned int v20; // [sp+14h] [bp-4h] BYREF
v3 = a3[4];
if ( v3 != 16 )
{
if ( a2 )
{
v7 = (char *)a1;
if ( a2 <= 4 )
{
v12 = a2;
v13 = 0;
while ( 1 )
{
v14 = *v7++;
v15 = 16 * v13;
v16 = OPENSSL_hexchar2int(v14);
if ( v16 < 0 )
break;
--v12;
v13 = (unsigned __int8)v16 | v15;
if ( !v12 )
{
*((_BYTE *)a3 + v3) = BYTE1(v13);
*((_BYTE *)a3 + v3 + 1) = v16 | v15;
a3[4] += 2;
return 1;
}
}
}
else if ( v3 <= 12 && !a1[a2] && sscanf(a1, "%d.%d.%d.%d", &v17, &v18, &v19, &v20) == 4 && v17 <= 0xFF )
{
v8 = v18;
if ( v18 <= 0xFF )
{
v9 = v19;
if ( v19 <= 0xFF )
{
v10 = v20;
if ( v20 <= 0xFF )
{
v11 = (char *)a3 + v3;
*((_BYTE *)a3 + v3) = v17;
v11[2] = v9;
v11[1] = v8;
v11[3] = v10;
a3[4] += 4;
return 1;
}
}
}
}
}
else
{
v5 = a3[5];
if ( v5 == -1 )
{
a3[5] = v3;
LABEL_17:
++a3[6];
return 1;
}
if ( v3 == v5 )
goto LABEL_17;
}
}
return 0;
}