#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int /*<<< orphan*/ *s6_addr;
};
struct sockaddr_in6 {
  TYPE_1__ sin6_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
};
struct in_addr {
  int dummy;
};
struct in6_addr {
  int dummy;
};
struct addrinfo {
  TYPE_2__ *ai_addr;
};
typedef int /*<<< orphan*/ sa_family_t;
struct TYPE_4__ {
  int /*<<< orphan*/ sa_family;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ AF_INET6;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int getaddrinfo(char *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                struct addrinfo **);
unsigned char *malloc(size_t);
int max(int, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(unsigned char *, int /*<<< orphan*/ *, size_t);
int /*<<< orphan*/ memset(unsigned char *, int, size_t);
int /*<<< orphan*/ stderr;
long strtol(char *, char **, int);
void parse_param(char *param, sa_family_t *family, size_t *addr_len,
                 unsigned char **addr, unsigned char **mask) {
  char *addr_str = param, *mask_str = NULL;
  for (char *c = param; *c; c++)
    if (*c == '/') {
      *c = '\0';
      mask_str = c + 1;
      break;
    }
  struct addrinfo *addr_info;
  int error = getaddrinfo(addr_str, NULL, NULL, &addr_info);
  if (error != 0) {
    fprintf(stderr, "net: %s: %s\n", addr_str, gai_strerror(error));
    exit(EXIT_FAILURE);
  }
  *family = addr_info->ai_addr->sa_family;
  if (*family == AF_INET)
    *addr_len = sizeof(struct in_addr);
  if (*family == AF_INET6)
    *addr_len = sizeof(struct in6_addr);
  *addr = malloc((*addr_len) * 2);
  *mask = *addr + (*addr_len);
  if (*family == AF_INET)
    memcpy(*addr, &((struct sockaddr_in *)addr_info->ai_addr)->sin_addr,
           *addr_len);
  if (*family == AF_INET6)
    memcpy(*addr,
           ((struct sockaddr_in6 *)addr_info->ai_addr)->sin6_addr.s6_addr,
           *addr_len);
  freeaddrinfo(addr_info);
  if (mask_str) {
    char *mask_after;
    long mask_len = strtol(mask_str, &mask_after, 10);
    if (*mask_after) {
      fprintf(stderr, "net: \"%s\" is not valid mask size\n", mask_str);
      exit(EXIT_FAILURE);
    }
    memset(*mask, 0, *addr_len);
    for (unsigned int i = 0; i < *addr_len; i++, mask_len -= 8)
      (*mask)[i] = 0xff << max(8 - mask_len, 0);
  } else {
    memset(*mask, 0xff, *addr_len);
  }
}


x86 assembly (clang, -O0):
<parse_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmpb   $0x0,(%rax)
je     1222 <parse_param+0x82>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    120c <parse_param+0x6c>
mov    -0x40(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1222 <parse_param+0x82>
jmp    1211 <parse_param+0x71>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    11d7 <parse_param+0x37>
mov    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x48(%rbp),%rcx
mov    %rdx,%rsi
call   10b0 <getaddrinfo@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
je     1285 <parse_param+0xe5>
mov    0x2d86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x4c(%rbp),%edi
call   1040 <gai_strerror@plt>
mov    -0x74(%rbp),%edi
mov    -0x70(%rbp),%rdx
mov    %rax,%rcx
lea    0xd90(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2d4a(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2d47(%rip),%rcx
cmp    (%rcx),%eax
jne    12b4 <parse_param+0x114>
mov    -0x18(%rbp),%rax
movq   $0x4,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2d1f(%rip),%rcx
cmp    (%rcx),%eax
jne    12d4 <parse_param+0x134>
mov    -0x18(%rbp),%rax
movq   $0x4,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
shl    $0x1,%rdi
call   1090 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
add    (%rax),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2cd8(%rip),%rcx
cmp    (%rcx),%eax
jne    1332 <parse_param+0x192>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
call   1080 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2ca1(%rip),%rcx
cmp    (%rcx),%eax
jne    1364 <parse_param+0x1c4>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
call   1080 <memcpy@plt>
mov    -0x48(%rbp),%rdi
call   10c0 <freeaddrinfo@plt>
cmpq   $0x0,-0x38(%rbp)
je     1439 <parse_param+0x299>
mov    -0x38(%rbp),%rdi
lea    -0x58(%rbp),%rsi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,-0x60(%rbp)
mov    -0x58(%rbp),%rax
cmpb   $0x0,(%rax)
je     13c4 <parse_param+0x224>
mov    0x2c2e(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xc5e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2c0b(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
xor    %esi,%esi
call   1050 <memset@plt>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%rax
jae    1434 <parse_param+0x294>
mov    $0x8,%eax
sub    -0x60(%rbp),%rax
mov    %eax,%edi
xor    %esi,%esi
call   1030 <max@plt>
mov    %eax,%ecx
mov    $0xff,%eax
shl    %cl,%eax
mov    %al,%dl
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    -0x64(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
mov    -0x60(%rbp),%rax
sub    $0x8,%rax
mov    %rax,-0x60(%rbp)
jmp    13e0 <parse_param+0x240>
jmp    1451 <parse_param+0x2b1>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
mov    $0xff,%esi
call   1050 <memset@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_param>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8,%r14
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %rdi,%r12
lea    0x1(%rdi),%rbx
mov    %rcx,0x28(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl -0x1(%rbx),%eax
test   %al,%al
je     11e2 <parse_param+0x42>
cmp    $0x2f,%al
je     11e6 <parse_param+0x46>
add    $0x1,%rbx
jmp    11d0 <parse_param+0x30>
xor    %ebx,%ebx
jmp    11ea <parse_param+0x4a>
movb   $0x0,-0x1(%rbx)
lea    0x8(%rsp),%rcx
mov    %r12,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10b0 <getaddrinfo@plt>
test   %eax,%eax
jne    1354 <parse_param+0x1b4>
mov    0x8(%rsp),%rax
mov    %rax,0x18(%rsp)
mov    (%rax),%rax
mov    (%rax),%r13d
mov    %r13d,0x0(%rbp)
mov    0x2dca(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
cmp    %eax,%r13d
jne    1230 <parse_param+0x90>
movq   $0x4,(%r15)
mov    %rbp,0x20(%rsp)
mov    0x2da4(%rip),%rax
mov    (%rax),%eax
cmp    %eax,%r13d
mov    %eax,0x14(%rsp)
jne    1256 <parse_param+0xb6>
movq   $0x4,(%r15)
mov    $0x4,%r12d
jmp    1259 <parse_param+0xb9>
mov    (%r15),%r12
lea    (%r12,%r12,1),%rdi
call   1090 <malloc@plt>
lea    (%rax,%r12,1),%rcx
mov    0x28(%rsp),%rbp
mov    %rax,0x0(%rbp)
mov    %rcx,(%r14)
cmp    0x10(%rsp),%r13d
mov    0x14(%rsp),%eax
jne    12a2 <parse_param+0x102>
mov    0x0(%rbp),%rdi
mov    0x18(%rsp),%rax
mov    (%rax),%rsi
mov    %r12,%rdx
call   1080 <memcpy@plt>
mov    0x20(%rsp),%rax
mov    (%rax),%r13d
mov    0x2d40(%rip),%rax
mov    (%rax),%eax
cmp    %eax,%r13d
jne    12be <parse_param+0x11e>
mov    0x0(%rbp),%rdi
mov    0x8(%rsp),%rax
mov    (%rax),%rax
mov    (%rax),%rsi
mov    (%r15),%rdx
call   1080 <memcpy@plt>
mov    0x8(%rsp),%rdi
call   10c0 <freeaddrinfo@plt>
test   %rbx,%rbx
je     1335 <parse_param+0x195>
lea    0x30(%rsp),%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,%rbp
mov    0x30(%rsp),%rax
cmpb   $0x0,(%rax)
jne    137c <parse_param+0x1dc>
mov    (%r14),%rdi
mov    (%r15),%rdx
xor    %esi,%esi
call   1050 <memset@plt>
cmpq   $0x0,(%r15)
je     1345 <parse_param+0x1a5>
mov    $0x8,%ebx
sub    %ebp,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %ebx,%edi
xor    %esi,%esi
call   1030 <max@plt>
mov    $0xff,%edx
mov    %eax,%ecx
shl    %cl,%edx
mov    (%r14),%rax
mov    %dl,(%rax,%rbp,1)
add    $0x1,%ebp
add    $0x8,%ebx
cmp    %rbp,(%r15)
ja     1310 <parse_param+0x170>
jmp    1345 <parse_param+0x1a5>
mov    (%r14),%rdi
mov    (%r15),%rdx
mov    $0xff,%esi
call   1050 <memset@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c75(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1040 <gai_strerror@plt>
lea    0xc95(%rip),%rsi
mov    %ebx,%edi
mov    %r12,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1396 <parse_param+0x1f6>
mov    0x2c4d(%rip),%rax
mov    (%rax),%edi
lea    0xc81(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x2c2b(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { %struct.TYPE_4__* }
%struct.TYPE_4__ = type { i32 }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr_in6 = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i32* }
@stderr = global i32 0
@.str = [13 x i8] c"net: %s: %s\0A\00"
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@AF_INET6 = global i32 0
@.str.1 = [34 x i8] c"net: \22%s\22 is not valid mask size\0A\00"
define void @parse_param(i8* %0, i32* %1, i64* %2, i8** %3, i8** %4) {
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i64*
%9 = alloca i8**
%10 = alloca i8**
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca %struct.addrinfo*
%15 = alloca i32
%16 = alloca i8*
%17 = alloca i64
%18 = alloca i32
store i8* %0, i8** %6
store i32* %1, i32** %7
store i64* %2, i64** %8
store i8** %3, i8*** %9
store i8** %4, i8*** %10
%19 = load i8*, i8** %6
store i8* %19, i8** %11
store i8* null, i8** %12
%20 = load i8*, i8** %6
store i8* %20, i8** %13
br label %21
21: ; preds = %35, %5
%22 = load i8*, i8** %13
%23 = load i8, i8* %22
%24 = icmp ne i8 %23, 0
br i1 %24, label %25, label %38
25: ; preds = %21
%26 = load i8*, i8** %13
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 47
br i1 %29, label %30, label %34
30: ; preds = %25
%31 = load i8*, i8** %13
store i8 0, i8* %31
%32 = load i8*, i8** %13
%33 = getelementptr inbounds i8, i8* %32, i64 1
store i8* %33, i8** %12
br label %38
34: ; preds = %25
br label %35
35: ; preds = %34
%36 = load i8*, i8** %13
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %13
br label %21
38: ; preds = %30, %21
%39 = load i8*, i8** %11
%40 = call i32 @getaddrinfo(i8* %39, i32* null, i32* null, %struct.addrinfo** %14)
store i32 %40, i32* %15
%41 = load i32, i32* %15
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %51
43: ; preds = %38
%44 = load i32, i32* @stderr
%45 = load i8*, i8** %11
%46 = load i32, i32* %15
%47 = call i8* @gai_strerror(i32 %46)
%48 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %45, i8* %47)
%49 = load i32, i32* @EXIT_FAILURE
%50 = call i32 @exit(i32 %49)
unreachable
51: ; preds = %38
%52 = load %struct.addrinfo*, %struct.addrinfo** %14
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %52, i32 0, i32 0
%54 = load %struct.TYPE_4__*, %struct.TYPE_4__** %53
%55 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %54, i32 0, i32 0
%56 = load i32, i32* %55
%57 = load i32*, i32** %7
store i32 %56, i32* %57
%58 = load i32*, i32** %7
%59 = load i32, i32* %58
%60 = load i32, i32* @AF_INET
%61 = icmp eq i32 %59, %60
br i1 %61, label %62, label %64
62: ; preds = %51
%63 = load i64*, i64** %8
store i64 4, i64* %63
br label %64
64: ; preds = %62, %51
%65 = load i32*, i32** %7
%66 = load i32, i32* %65
%67 = load i32, i32* @AF_INET6
%68 = icmp eq i32 %66, %67
br i1 %68, label %69, label %71
69: ; preds = %64
%70 = load i64*, i64** %8
store i64 4, i64* %70
br label %71
71: ; preds = %69, %64
%72 = load i64*, i64** %8
%73 = load i64, i64* %72
%74 = mul i64 %73, 2
%75 = call i8* @malloc(i64 %74)
%76 = load i8**, i8*** %9
store i8* %75, i8** %76
%77 = load i8**, i8*** %9
%78 = load i8*, i8** %77
%79 = load i64*, i64** %8
%80 = load i64, i64* %79
%81 = getelementptr inbounds i8, i8* %78, i64 %80
%82 = load i8**, i8*** %10
store i8* %81, i8** %82
%83 = load i32*, i32** %7
%84 = load i32, i32* %83
%85 = load i32, i32* @AF_INET
%86 = icmp eq i32 %84, %85
br i1 %86, label %87, label %98
87: ; preds = %71
%88 = load i8**, i8*** %9
%89 = load i8*, i8** %88
%90 = load %struct.addrinfo*, %struct.addrinfo** %14
%91 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %90, i32 0, i32 0
%92 = load %struct.TYPE_4__*, %struct.TYPE_4__** %91
%93 = bitcast %struct.TYPE_4__* %92 to %struct.sockaddr_in*
%94 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %93, i32 0, i32 0
%95 = load i64*, i64** %8
%96 = load i64, i64* %95
%97 = call i32 @memcpy(i8* %89, i32* %94, i64 %96)
br label %98
98: ; preds = %87, %71
%99 = load i32*, i32** %7
%100 = load i32, i32* %99
%101 = load i32, i32* @AF_INET6
%102 = icmp eq i32 %100, %101
br i1 %102, label %103, label %116
103: ; preds = %98
%104 = load i8**, i8*** %9
%105 = load i8*, i8** %104
%106 = load %struct.addrinfo*, %struct.addrinfo** %14
%107 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %106, i32 0, i32 0
%108 = load %struct.TYPE_4__*, %struct.TYPE_4__** %107
%109 = bitcast %struct.TYPE_4__* %108 to %struct.sockaddr_in6*
%110 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %109, i32 0, i32 0
%111 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %110, i32 0, i32 0
%112 = load i32*, i32** %111
%113 = load i64*, i64** %8
%114 = load i64, i64* %113
%115 = call i32 @memcpy(i8* %105, i32* %112, i64 %114)
br label %116
116: ; preds = %103, %98
%117 = load %struct.addrinfo*, %struct.addrinfo** %14
%118 = call i32 @freeaddrinfo(%struct.addrinfo* %117)
%119 = load i8*, i8** %12
%120 = icmp ne i8* %119, null
br i1 %120, label %121, label %163
121: ; preds = %116
%122 = load i8*, i8** %12
%123 = call i64 @strtol(i8* %122, i8** %16, i32 10)
store i64 %123, i64* %17
%124 = load i8*, i8** %16
%125 = load i8, i8* %124
%126 = icmp ne i8 %125, 0
br i1 %126, label %127, label %133
127: ; preds = %121
%128 = load i32, i32* @stderr
%129 = load i8*, i8** %12
%130 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %129)
%131 = load i32, i32* @EXIT_FAILURE
%132 = call i32 @exit(i32 %131)
unreachable
133: ; preds = %121
%134 = load i8**, i8*** %10
%135 = load i8*, i8** %134
%136 = load i64*, i64** %8
%137 = load i64, i64* %136
%138 = call i32 @memset(i8* %135, i32 0, i64 %137)
store i32 0, i32* %18
br label %139
139: ; preds = %157, %133
%140 = load i32, i32* %18
%141 = zext i32 %140 to i64
%142 = load i64*, i64** %8
%143 = load i64, i64* %142
%144 = icmp ult i64 %141, %143
br i1 %144, label %145, label %162
145: ; preds = %139
%146 = load i64, i64* %17
%147 = sub nsw i64 8, %146
%148 = trunc i64 %147 to i32
%149 = call i32 @max(i32 %148, i32 0)
%150 = shl i32 255, %149
%151 = trunc i32 %150 to i8
%152 = load i8**, i8*** %10
%153 = load i8*, i8** %152
%154 = load i32, i32* %18
%155 = zext i32 %154 to i64
%156 = getelementptr inbounds i8, i8* %153, i64 %155
store i8 %151, i8* %156
br label %157
157: ; preds = %145
%158 = load i32, i32* %18
%159 = add i32 %158, 1
store i32 %159, i32* %18
%160 = load i64, i64* %17
%161 = sub nsw i64 %160, 8
store i64 %161, i64* %17
br label %139
162: ; preds = %139
br label %169
163: ; preds = %116
%164 = load i8**, i8*** %10
%165 = load i8*, i8** %164
%166 = load i64*, i64** %8
%167 = load i64, i64* %166
%168 = call i32 @memset(i8* %165, i32 255, i64 %167)
br label %169
169: ; preds = %163, %162
ret void
}

LLVM IR (-O2):
%struct.addrinfo = type { %struct.TYPE_4__* }
%struct.TYPE_4__ = type { i32 }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr_in6 = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i32* }
@stderr = global i32 0
@.str = [13 x i8] c"net: %s: %s\0A\00"
@EXIT_FAILURE = global i32 0
@AF_INET = global i32 0
@AF_INET6 = global i32 0
@.str.1 = [34 x i8] c"net: \22%s\22 is not valid mask size\0A\00"
define void @parse_param(i8* %0, i32* nocapture %1, i64* nocapture %2, i8** nocapture %3, i8** nocapture %4) {
%6 = alloca %struct.addrinfo*
%7 = alloca i8*
br label %8
8: ; preds = %13, %5
%9 = phi i8* [ %0, %5 ], [ %14, %13 ]
%10 = load i8, i8* %9
switch i8 %10, label %13 [
i8 0, label %15
i8 47, label %11
]
11: ; preds = %8
store i8 0, i8* %9
%12 = getelementptr inbounds i8, i8* %9, i64 1
br label %15
13: ; preds = %8
%14 = getelementptr inbounds i8, i8* %9, i64 1
br label %8
15: ; preds = %8, %11
%16 = phi i8* [ %12, %11 ], [ null, %8 ]
%17 = bitcast %struct.addrinfo** %6 to i8*
%18 = call i32 @getaddrinfo(i8* %0, i32* null, i32* null, %struct.addrinfo** %6)
%19 = icmp eq i32 %18, 0
br i1 %19, label %26, label %20
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = call i8* @gai_strerror(i32 %18)
%23 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %15
%27 = load %struct.addrinfo*, %struct.addrinfo** %6
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %27, i64 0, i32 0
%29 = load %struct.TYPE_4__*, %struct.TYPE_4__** %28
%30 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %29, i64 0, i32 0
%31 = load i32, i32* %30
store i32 %31, i32* %1
%32 = load i32, i32* @AF_INET
%33 = icmp eq i32 %31, %32
%34 = bitcast %struct.addrinfo* %27 to %struct.sockaddr_in**
br i1 %33, label %35, label %36
35: ; preds = %26
store i64 4, i64* %2
br label %36
36: ; preds = %35, %26
%37 = load i32, i32* @AF_INET6
%38 = icmp eq i32 %31, %37
br i1 %38, label %41, label %39
39: ; preds = %36
%40 = load i64, i64* %2
br label %42
41: ; preds = %36
store i64 4, i64* %2
br label %42
42: ; preds = %39, %41
%43 = phi i64 [ %40, %39 ], [ 4, %41 ]
%44 = shl i64 %43, 1
%45 = call i8* @malloc(i64 %44)
store i8* %45, i8** %3
%46 = getelementptr inbounds i8, i8* %45, i64 %43
store i8* %46, i8** %4
br i1 %33, label %47, label %54
47: ; preds = %42
%48 = load i8*, i8** %3
%49 = load %struct.sockaddr_in*, %struct.sockaddr_in** %34
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %49, i64 0, i32 0
%51 = call i32 @memcpy(i8* %48, i32* %50, i64 %43)
%52 = load i32, i32* %1
%53 = load i32, i32* @AF_INET6
br label %54
54: ; preds = %47, %42
%55 = phi i32 [ %53, %47 ], [ %37, %42 ]
%56 = phi i32 [ %52, %47 ], [ %31, %42 ]
%57 = icmp eq i32 %56, %55
br i1 %57, label %58, label %67
58: ; preds = %54
%59 = load i8*, i8** %3
%60 = bitcast %struct.addrinfo** %6 to %struct.sockaddr_in6***
%61 = load %struct.sockaddr_in6**, %struct.sockaddr_in6*** %60
%62 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %61
%63 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %62, i64 0, i32 0, i32 0
%64 = load i32*, i32** %63
%65 = load i64, i64* %2
%66 = call i32 @memcpy(i8* %59, i32* %64, i64 %65)
br label %67
67: ; preds = %58, %54
%68 = load %struct.addrinfo*, %struct.addrinfo** %6
%69 = call i32 @freeaddrinfo(%struct.addrinfo* %68)
%70 = icmp eq i8* %16, null
br i1 %70, label %104, label %71
71: ; preds = %67
%72 = bitcast i8** %7 to i8*
%73 = call i64 @strtol(i8* %16, i8** %7, i32 10)
%74 = load i8*, i8** %7
%75 = load i8, i8* %74
%76 = icmp eq i8 %75, 0
br i1 %76, label %82, label %77
77: ; preds = %71
%78 = load i32, i32* @stderr
%79 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%80 = load i32, i32* @EXIT_FAILURE
%81 = call i32 @exit(i32 %80)
unreachable
82: ; preds = %71
%83 = load i8*, i8** %4
%84 = load i64, i64* %2
%85 = call i32 @memset(i8* %83, i32 0, i64 %84)
%86 = load i64, i64* %2
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %89
88: ; preds = %89, %82
br label %108
89: ; preds = %82, %89
%90 = phi i64 [ %101, %89 ], [ 0, %82 ]
%91 = phi i64 [ %100, %89 ], [ %73, %82 ]
%92 = trunc i64 %91 to i32
%93 = sub i32 8, %92
%94 = call i32 @max(i32 %93, i32 0)
%95 = shl i32 255, %94
%96 = trunc i32 %95 to i8
%97 = load i8*, i8** %4
%98 = getelementptr inbounds i8, i8* %97, i64 %90
store i8 %96, i8* %98
%99 = add nuw nsw i64 %90, 1
%100 = add nsw i64 %91, -8
%101 = and i64 %99, 4294967295
%102 = load i64, i64* %2
%103 = icmp ugt i64 %102, %101
br i1 %103, label %89, label %88
104: ; preds = %67
%105 = load i8*, i8** %4
%106 = load i64, i64* %2
%107 = call i32 @memset(i8* %105, i32 255, i64 %106)
br label %108
108: ; preds = %104, %88
ret void
}