#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int uint8_t;

/* Variables and functions */
int AF_INET;
int AF_INET6;
int AF_UNSPEC;
int EINVAL;
int inet_pton(int, char const *, int *);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, unsigned int);
void *strchr(char const *, char);
scalar_t__ strcmp(char const *, char const *);
unsigned int strtoul(char *, char **, int);
int /*<<< orphan*/ warnx(char *, ...);
int parse_ipaddr(const char *param, const char *args[], int *afp,
                 uint8_t addr[], uint8_t mask[]) {
  const char *colon, *afn;
  char *slash;
  uint8_t *m;
  int af, ret;
  unsigned int masksize;
  if (strcmp(param, args[0]) != 0)
    return (EINVAL);
  colon = strchr(args[1], ':');
  if (!colon) {
    afn = "IPv4";
    af = AF_INET;
    masksize = 32;
  } else {
    afn = "IPv6";
    af = AF_INET6;
    masksize = 128;
  }
  if (*afp == AF_UNSPEC)
    *afp = af;
  else if (*afp != af) {
    warnx("address %s is not of expected family %s", args[1],
          *afp == AF_INET ? "IP" : "IPv6");
    return (EINVAL);
  }
  slash = strchr(args[1], '/');
  if (slash)
    *slash = 0;
  ret = inet_pton(af, args[1], addr);
  if (slash)
    *slash = '/';
  if (ret <= 0) {
    warnx("Cannot parse %s %s address %s", param, afn, args[1]);
    return (EINVAL);
  }
  if (slash) {
    char *p;
    unsigned int prefix = strtoul(slash + 1, &p, 10);
    if (p == slash + 1) {
      warnx("missing address prefix for %s", param);
      return (EINVAL);
    }
    if (*p) {
      warnx("%s is not a valid address prefix", slash + 1);
      return (EINVAL);
    }
    if (prefix > masksize) {
      warnx("prefix %u is too long for an %s address", prefix, afn);
      return (EINVAL);
    }
    memset(mask, 0, masksize / 8);
    masksize = prefix;
  }
  for (m = mask; masksize >= 8; m++, masksize -= 8)
    *m = ~0;
  if (masksize)
    *m = ~0 << (8 - masksize);
  return (0);
}


x86 assembly (clang, -O0):
<parse_ipaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     11a7 <parse_ipaddr+0x47>
mov    0x2e2b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    144b <parse_ipaddr+0x2eb>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11eb <parse_ipaddr+0x8b>
lea    0xe31(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2e0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
movl   $0x20,-0x5c(%rbp)
jmp    1209 <parse_ipaddr+0xa9>
lea    0xe13(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2ddb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
movl   $0x80,-0x5c(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    0x2dca(%rip),%rcx
cmp    (%rcx),%eax
jne    122c <parse_ipaddr+0xcc>
mov    -0x54(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
jmp    128a <parse_ipaddr+0x12a>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
cmp    -0x54(%rbp),%eax
je     1285 <parse_ipaddr+0x125>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
lea    0xdac(%rip),%rdx
lea    0xdd2(%rip),%rax
cmp    %edi,%ecx
cmove  %rax,%rdx
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1040 <warnx@plt>
mov    0x2d4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    144b <parse_ipaddr+0x2eb>
jmp    128a <parse_ipaddr+0x12a>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     12b2 <parse_ipaddr+0x152>
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x54(%rbp),%edi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x28(%rbp),%rdx
call   1070 <inet_pton@plt>
mov    %eax,-0x58(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     12db <parse_ipaddr+0x17b>
mov    -0x48(%rbp),%rax
movb   $0x2f,(%rax)
cmpl   $0x0,-0x58(%rbp)
jg     1314 <parse_ipaddr+0x1b4>
mov    -0x10(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xd39(%rip),%rdi
mov    $0x0,%al
call   1040 <warnx@plt>
mov    0x2cbe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    144b <parse_ipaddr+0x2eb>
cmpq   $0x0,-0x48(%rbp)
je     13ed <parse_ipaddr+0x28d>
mov    -0x48(%rbp),%rdi
add    $0x1,%rdi
lea    -0x68(%rbp),%rsi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x68(%rbp),%rax
mov    -0x48(%rbp),%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1370 <parse_ipaddr+0x210>
mov    -0x10(%rbp),%rsi
lea    0xcfb(%rip),%rdi
mov    $0x0,%al
call   1040 <warnx@plt>
mov    0x2c62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    144b <parse_ipaddr+0x2eb>
mov    -0x68(%rbp),%rax
cmpb   $0x0,(%rax)
je     13a4 <parse_ipaddr+0x244>
mov    -0x48(%rbp),%rsi
add    $0x1,%rsi
lea    0xce5(%rip),%rdi
mov    $0x0,%al
call   1040 <warnx@plt>
mov    0x2c2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    144b <parse_ipaddr+0x2eb>
mov    -0x6c(%rbp),%eax
cmp    -0x5c(%rbp),%eax
jbe    13d6 <parse_ipaddr+0x276>
mov    -0x6c(%rbp),%esi
mov    -0x40(%rbp),%rdx
lea    0xcd4(%rip),%rdi
mov    $0x0,%al
call   1040 <warnx@plt>
mov    0x2bfc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    144b <parse_ipaddr+0x2eb>
mov    -0x30(%rbp),%rdi
mov    -0x5c(%rbp),%edx
shr    $0x3,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpl   $0x8,-0x5c(%rbp)
jb     1423 <parse_ipaddr+0x2c3>
mov    -0x50(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x50(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x50(%rbp)
mov    -0x5c(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x5c(%rbp)
jmp    13f5 <parse_ipaddr+0x295>
cmpl   $0x0,-0x5c(%rbp)
je     1444 <parse_ipaddr+0x2e4>
mov    $0x8,%ecx
sub    -0x5c(%rbp),%ecx
mov    $0xffffffff,%eax
shl    %cl,%eax
mov    %eax,%ecx
mov    -0x50(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_ipaddr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r12
mov    %rcx,%rbp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r13
mov    (%rsi),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11a2 <parse_ipaddr+0x42>
mov    0x2e37(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbp,0x10(%rsp)
mov    0x8(%rbx),%rdi
mov    %rdi,0x18(%rsp)
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
lea    0xe3c(%rip),%rbp
lea    0xe3a(%rip),%rdx
cmovne %rdx,%rbp
mov    $0x20,%eax
mov    $0x80,%edi
cmove  %eax,%edi
mov    0x2e05(%rip),%rax
mov    (%rax),%eax
mov    0x2dec(%rip),%rcx
mov    (%rcx),%r15d
cmove  %eax,%r15d
mov    (%r14),%ecx
mov    0x2de3(%rip),%rsi
cmp    (%rsi),%ecx
jne    1206 <parse_ipaddr+0xa6>
mov    %r15d,(%r14)
jmp    120f <parse_ipaddr+0xaf>
cmp    %r15d,%ecx
jne    1314 <parse_ipaddr+0x1b4>
mov    %rbp,0x8(%rsp)
mov    %rdi,%r14
mov    %r12,(%rsp)
mov    0x18(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1294 <parse_ipaddr+0x134>
mov    %rax,%r12
movb   $0x0,(%rax)
mov    0x8(%rbx),%rsi
mov    %r15d,%edi
mov    0x10(%rsp),%rdx
call   1070 <inet_pton@plt>
movb   $0x2f,(%r12)
test   %eax,%eax
jle    12f5 <parse_ipaddr+0x195>
add    $0x1,%r12
lea    0x20(%rsp),%rsi
mov    %r12,%rdi
mov    $0xa,%edx
call   1080 <strtoul@plt>
mov    %eax,%ebx
mov    0x20(%rsp),%rax
cmp    %r12,%rax
je     1339 <parse_ipaddr+0x1d9>
cmpb   $0x0,(%rax)
je     134f <parse_ipaddr+0x1ef>
lea    0xde5(%rip),%rdi
mov    %r12,%rsi
jmp    1343 <parse_ipaddr+0x1e3>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    0x10(%rsp),%rdx
call   1070 <inet_pton@plt>
test   %eax,%eax
jle    12f5 <parse_ipaddr+0x195>
mov    %r14,%rbp
lea    -0x8(%r14),%ebx
shr    $0x3,%ebx
lea    0x4(,%rbx,4),%rdx
mov    (%rsp),%r14
mov    %r14,%rdi
mov    $0xff,%esi
call   1050 <memset@plt>
lea    (%r14,%rbx,4),%r14
add    $0x4,%r14
and    $0x7,%ebp
mov    %ebp,%ebx
xor    %eax,%eax
test   %ebx,%ebx
je     1193 <parse_ipaddr+0x33>
mov    $0x8,%cl
sub    %bl,%cl
mov    $0xffffffff,%edx
shl    %cl,%edx
mov    %edx,(%r14)
jmp    1193 <parse_ipaddr+0x33>
mov    0x8(%rbx),%rcx
lea    0xd35(%rip),%rdi
mov    %r13,%rsi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   1040 <warnx@plt>
jmp    118a <parse_ipaddr+0x2a>
cmp    %eax,%ecx
lea    0xd15(%rip),%rax
cmove  %rax,%rdx
lea    0xce2(%rip),%rdi
mov    0x18(%rsp),%rsi
xor    %eax,%eax
call   1040 <warnx@plt>
jmp    118a <parse_ipaddr+0x2a>
lea    0xd13(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <warnx@plt>
jmp    118a <parse_ipaddr+0x2a>
cmp    %r14d,%ebx
jbe    136e <parse_ipaddr+0x20e>
lea    0xd37(%rip),%rdi
mov    %ebx,%esi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   1040 <warnx@plt>
jmp    118a <parse_ipaddr+0x2a>
shr    $0x3,%r14d
mov    (%rsp),%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1050 <memset@plt>
mov    %ebx,%r14d
cmp    $0x8,%ebx
jae    12a8 <parse_ipaddr+0x148>
mov    (%rsp),%r14
jmp    12d8 <parse_ipaddr+0x178>

LLVM IR (-O0):
@EINVAL = global i32 0
@.str = [5 x i8] c"IPv4\00"
@AF_INET = global i32 0
@.str.1 = [5 x i8] c"IPv6\00"
@AF_INET6 = global i32 0
@AF_UNSPEC = global i32 0
@.str.2 = [40 x i8] c"address %s is not of expected family %s\00"
@.str.3 = [3 x i8] c"IP\00"
@.str.4 = [30 x i8] c"Cannot parse %s %s address %s\00"
@.str.5 = [30 x i8] c"missing address prefix for %s\00"
@.str.6 = [33 x i8] c"%s is not a valid address prefix\00"
@.str.7 = [40 x i8] c"prefix %u is too long for an %s address\00"
define i32 @parse_ipaddr(i8* %0, i8** %1, i32* %2, i32* %3, i32* %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8**
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i8*
%20 = alloca i32
store i8* %0, i8** %7
store i8** %1, i8*** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i32* %4, i32** %11
%21 = load i8*, i8** %7
%22 = load i8**, i8*** %8
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %21, i8* %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %5
%28 = load i32, i32* @EINVAL
store i32 %28, i32* %6
br label %157
29: ; preds = %5
%30 = load i8**, i8*** %8
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i8* @strchr(i8* %32, i8 signext 58)
store i8* %33, i8** %12
%34 = load i8*, i8** %12
%35 = icmp ne i8* %34, null
br i1 %35, label %38, label %36
36: ; preds = %29
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %13
%37 = load i32, i32* @AF_INET
store i32 %37, i32* %16
store i32 32, i32* %18
br label %40
38: ; preds = %29
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %13
%39 = load i32, i32* @AF_INET6
store i32 %39, i32* %16
store i32 128, i32* %18
br label %40
40: ; preds = %38, %36
%41 = load i32*, i32** %9
%42 = load i32, i32* %41
%43 = load i32, i32* @AF_UNSPEC
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %48
45: ; preds = %40
%46 = load i32, i32* %16
%47 = load i32*, i32** %9
store i32 %46, i32* %47
br label %66
48: ; preds = %40
%49 = load i32*, i32** %9
%50 = load i32, i32* %49
%51 = load i32, i32* %16
%52 = icmp ne i32 %50, %51
br i1 %52, label %53, label %65
53: ; preds = %48
%54 = load i8**, i8*** %8
%55 = getelementptr inbounds i8*, i8** %54, i64 1
%56 = load i8*, i8** %55
%57 = load i32*, i32** %9
%58 = load i32, i32* %57
%59 = load i32, i32* @AF_INET
%60 = icmp eq i32 %58, %59
%61 = zext i1 %60 to i64
%62 = select i1 %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%63 = call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %56, i8* %62)
%64 = load i32, i32* @EINVAL
store i32 %64, i32* %6
br label %157
65: ; preds = %48
br label %66
66: ; preds = %65, %45
%67 = load i8**, i8*** %8
%68 = getelementptr inbounds i8*, i8** %67, i64 1
%69 = load i8*, i8** %68
%70 = call i8* @strchr(i8* %69, i8 signext 47)
store i8* %70, i8** %14
%71 = load i8*, i8** %14
%72 = icmp ne i8* %71, null
br i1 %72, label %73, label %75
73: ; preds = %66
%74 = load i8*, i8** %14
store i8 0, i8* %74
br label %75
75: ; preds = %73, %66
%76 = load i32, i32* %16
%77 = load i8**, i8*** %8
%78 = getelementptr inbounds i8*, i8** %77, i64 1
%79 = load i8*, i8** %78
%80 = load i32*, i32** %10
%81 = call i32 @inet_pton(i32 %76, i8* %79, i32* %80)
store i32 %81, i32* %17
%82 = load i8*, i8** %14
%83 = icmp ne i8* %82, null
br i1 %83, label %84, label %86
84: ; preds = %75
%85 = load i8*, i8** %14
store i8 47, i8* %85
br label %86
86: ; preds = %84, %75
%87 = load i32, i32* %17
%88 = icmp sle i32 %87, 0
br i1 %88, label %89, label %97
89: ; preds = %86
%90 = load i8*, i8** %7
%91 = load i8*, i8** %13
%92 = load i8**, i8*** %8
%93 = getelementptr inbounds i8*, i8** %92, i64 1
%94 = load i8*, i8** %93
%95 = call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %90, i8* %91, i8* %94)
%96 = load i32, i32* @EINVAL
store i32 %96, i32* %6
br label %157
97: ; preds = %86
%98 = load i8*, i8** %14
%99 = icmp ne i8* %98, null
br i1 %99, label %100, label %136
100: ; preds = %97
%101 = load i8*, i8** %14
%102 = getelementptr inbounds i8, i8* %101, i64 1
%103 = call i32 @strtoul(i8* %102, i8** %19, i32 10)
store i32 %103, i32* %20
%104 = load i8*, i8** %19
%105 = load i8*, i8** %14
%106 = getelementptr inbounds i8, i8* %105, i64 1
%107 = icmp eq i8* %104, %106
br i1 %107, label %108, label %112
108: ; preds = %100
%109 = load i8*, i8** %7
%110 = call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* %109)
%111 = load i32, i32* @EINVAL
store i32 %111, i32* %6
br label %157
112: ; preds = %100
%113 = load i8*, i8** %19
%114 = load i8, i8* %113
%115 = icmp ne i8 %114, 0
br i1 %115, label %116, label %121
116: ; preds = %112
%117 = load i8*, i8** %14
%118 = getelementptr inbounds i8, i8* %117, i64 1
%119 = call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %118)
%120 = load i32, i32* @EINVAL
store i32 %120, i32* %6
br label %157
121: ; preds = %112
%122 = load i32, i32* %20
%123 = load i32, i32* %18
%124 = icmp ugt i32 %122, %123
br i1 %124, label %125, label %130
125: ; preds = %121
%126 = load i32, i32* %20
%127 = load i8*, i8** %13
%128 = call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i32 %126, i8* %127)
%129 = load i32, i32* @EINVAL
store i32 %129, i32* %6
br label %157
130: ; preds = %121
%131 = load i32*, i32** %11
%132 = load i32, i32* %18
%133 = udiv i32 %132, 8
%134 = call i32 @memset(i32* %131, i32 0, i32 %133)
%135 = load i32, i32* %20
store i32 %135, i32* %18
br label %136
136: ; preds = %130, %97
%137 = load i32*, i32** %11
store i32* %137, i32** %15
br label %138
138: ; preds = %143, %136
%139 = load i32, i32* %18
%140 = icmp uge i32 %139, 8
br i1 %140, label %141, label %148
141: ; preds = %138
%142 = load i32*, i32** %15
store i32 -1, i32* %142
br label %143
143: ; preds = %141
%144 = load i32*, i32** %15
%145 = getelementptr inbounds i32, i32* %144, i32 1
store i32* %145, i32** %15
%146 = load i32, i32* %18
%147 = sub i32 %146, 8
store i32 %147, i32* %18
br label %138
148: ; preds = %138
%149 = load i32, i32* %18
%150 = icmp ne i32 %149, 0
br i1 %150, label %151, label %156
151: ; preds = %148
%152 = load i32, i32* %18
%153 = sub i32 8, %152
%154 = shl i32 -1, %153
%155 = load i32*, i32** %15
store i32 %154, i32* %155
br label %156
156: ; preds = %151, %148
store i32 0, i32* %6
br label %157
157: ; preds = %156, %125, %116, %108, %89, %53, %27
%158 = load i32, i32* %6
ret i32 %158
}

LLVM IR (-O2):
@EINVAL = global i32 0
@.str = [5 x i8] c"IPv4\00"
@AF_INET = global i32 0
@.str.1 = [5 x i8] c"IPv6\00"
@AF_INET6 = global i32 0
@AF_UNSPEC = global i32 0
@.str.2 = [40 x i8] c"address %s is not of expected family %s\00"
@.str.3 = [3 x i8] c"IP\00"
@.str.4 = [30 x i8] c"Cannot parse %s %s address %s\00"
@.str.5 = [30 x i8] c"missing address prefix for %s\00"
@.str.6 = [33 x i8] c"%s is not a valid address prefix\00"
@.str.7 = [40 x i8] c"prefix %u is too long for an %s address\00"
define i32 @parse_ipaddr(i8* %0, i8** nocapture %1, i32* nocapture %2, i32* %3, i32* %4) {
%6 = bitcast i32* %4 to i8*
%7 = alloca i8*
%8 = load i8*, i8** %1
%9 = tail call i64 @strcmp(i8* %0, i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %5
%12 = load i32, i32* @EINVAL
br label %88
13: ; preds = %5
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i8* @strchr(i8* dereferenceable(1) %15, i8 signext 58)
%17 = icmp eq i8* %16, null
%18 = select i1 %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%19 = select i1 %17, i32 32, i32 128
%20 = load i32, i32* @AF_INET
%21 = load i32, i32* @AF_INET6
%22 = select i1 %17, i32 %20, i32 %21
%23 = load i32, i32* %2
%24 = load i32, i32* @AF_UNSPEC
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %13
store i32 %22, i32* %2
br label %34
27: ; preds = %13
%28 = icmp eq i32 %23, %22
br i1 %28, label %34, label %29
29: ; preds = %27
%30 = icmp eq i32 %23, %20
%31 = select i1 %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0)
%32 = tail call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %15, i8* %31)
%33 = load i32, i32* @EINVAL
br label %88
34: ; preds = %27, %26
%35 = tail call i8* @strchr(i8* dereferenceable(1) %15, i8 signext 47)
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = tail call i32 @inet_pton(i32 %22, i8* %15, i32* %3)
%39 = icmp slt i32 %38, 1
br i1 %39, label %44, label %71
40: ; preds = %34
store i8 0, i8* %35
%41 = load i8*, i8** %14
%42 = tail call i32 @inet_pton(i32 %22, i8* %41, i32* %3)
store i8 47, i8* %35
%43 = icmp slt i32 %42, 1
br i1 %43, label %44, label %48
44: ; preds = %40, %37
%45 = load i8*, i8** %14
%46 = tail call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* %18, i8* %45)
%47 = load i32, i32* @EINVAL
br label %88
48: ; preds = %40
%49 = bitcast i8** %7 to i8*
%50 = getelementptr inbounds i8, i8* %35, i64 1
%51 = call i32 @strtoul(i8* %50, i8** %7, i32 10)
%52 = load i8*, i8** %7
%53 = icmp eq i8* %52, %50
br i1 %53, label %54, label %56
54: ; preds = %48
%55 = tail call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i8* %0)
br label %65
56: ; preds = %48
%57 = load i8, i8* %52
%58 = icmp eq i8 %57, 0
br i1 %58, label %61, label %59
59: ; preds = %56
%60 = tail call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %50)
br label %65
61: ; preds = %56
%62 = icmp ugt i32 %51, %19
br i1 %62, label %63, label %67
63: ; preds = %61
%64 = tail call i32 (i8*, ...) @warnx(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i32 %51, i8* %18)
br label %65
65: ; preds = %54, %59, %63
%66 = load i32, i32* @EINVAL
br label %88
67: ; preds = %61
%68 = lshr exact i32 %19, 3
%69 = tail call i32 @memset(i32* %4, i32 0, i32 %68)
%70 = icmp ugt i32 %51, 7
br i1 %70, label %71, label %81
71: ; preds = %37, %67
%72 = phi i32 [ %51, %67 ], [ %19, %37 ]
%73 = add i32 %72, -8
%74 = lshr i32 %73, 3
%75 = zext i32 %74 to i64
%76 = shl nuw nsw i64 %75, 2
%77 = add nuw nsw i64 %76, 4
%78 = add nuw nsw i64 %75, 1
%79 = getelementptr i32, i32* %4, i64 %78
%80 = and i32 %72, 7
br label %81
81: ; preds = %71, %67
%82 = phi i32* [ %4, %67 ], [ %79, %71 ]
%83 = phi i32 [ %51, %67 ], [ %80, %71 ]
%84 = icmp eq i32 %83, 0
br i1 %84, label %88, label %85
85: ; preds = %81
%86 = sub nuw nsw i32 8, %83
%87 = shl nsw i32 -1, %86
store i32 %87, i32* %82
br label %88
88: ; preds = %65, %81, %85, %44, %29, %11
%89 = phi i32 [ %12, %11 ], [ %47, %44 ], [ %33, %29 ], [ 0, %85 ], [ 0, %81 ], [ %66, %65 ]
ret i32 %89
}