#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_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int sin_family;
  TYPE_1__ sin_addr;
};
struct sockaddr {
  int sa_family;
};
struct addrinfo {
  int ai_family;
  int ai_addrlen;
  int /*<<< orphan*/ *ai_addr;
  int /*<<< orphan*/ *ai_next;
  int /*<<< orphan*/ *ai_canonname;
  scalar_t__ ai_protocol;
  int /*<<< orphan*/ ai_flags;
  int /*<<< orphan*/ ai_socktype;
};

/* Variables and functions */
#define AF_INET 129
#define AF_INET6 128
int /*<<< orphan*/ AI_PASSIVE;
int /*<<< orphan*/ EFAULT;
int /*<<< orphan*/ INADDR_BROADCAST;
int /*<<< orphan*/ SOCK_STREAM;
void *calloc(int, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int getaddrinfo(char const *, char *, struct addrinfo *, struct addrinfo **);
int /*<<< orphan*/ memcpy(char *, int /*<<< orphan*/ *, size_t);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
scalar_t__ strcmp(char const *, char *);
int setipaddr(int resolve_af, const char *name, struct sockaddr *addr_ret,
              size_t *addr_ret_size) {
  struct addrinfo hints;
  struct addrinfo *result;
  hints.ai_family = resolve_af;
  hints.ai_socktype = SOCK_STREAM;
  hints.ai_flags = AI_PASSIVE;
  hints.ai_protocol = 0;
  hints.ai_canonname = NULL;
  hints.ai_addr = NULL;
  hints.ai_next = NULL;
  int error = 0;
  if (name[0] == '\0') {
    error = getaddrinfo(NULL, "0", &hints, &result);
    if (error) {
      return error;
    }
    if (result->ai_next) {
      freeaddrinfo(result);
      return -1;
    }
  } else if (strcmp(name, "255.255.255.255") == 0 ||
             strcmp(name, "<broadcast>") == 0) {
    result = calloc(1, sizeof(struct addrinfo));
    result->ai_addr = calloc(1, sizeof(struct sockaddr_in *));
    result->ai_addrlen = sizeof(struct sockaddr_in *);
    struct sockaddr_in *in = (struct sockaddr_in *)result->ai_addr;
    in->sin_family = AF_INET;
    in->sin_addr.s_addr = INADDR_BROADCAST;
  } else {
    error = getaddrinfo(name, NULL, &hints, &result);
    if (error) {
      puts("Unable to resolve!");
      errno = EFAULT;
      return error;
    }
  }
  if (result->ai_addrlen < *addr_ret_size)
    *addr_ret_size = result->ai_addrlen;
  memcpy((char *)addr_ret, result->ai_addr, *addr_ret_size);
  freeaddrinfo(result);
  switch (addr_ret->sa_family) {
  case AF_INET:
    return 4;
  case AF_INET6:
    return 16;
  default:
    puts("Unknown address family");
    printf("    %d\n", addr_ret->sa_family);
    return -1;
  }
}


x86 assembly (clang, -O0):
<setipaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    0x2e34(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2e40(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1235 <setipaddr+0xc5>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe19(%rip),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x58(%rbp),%rcx
call   1080 <getaddrinfo@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
je     120c <setipaddr+0x9c>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    13cf <setipaddr+0x25f>
mov    -0x58(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1230 <setipaddr+0xc0>
mov    -0x58(%rbp),%rdi
call   1090 <freeaddrinfo@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13cf <setipaddr+0x25f>
jmp    1321 <setipaddr+0x1b1>
mov    -0x10(%rbp),%rdi
lea    0xdc2(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1269 <setipaddr+0xf9>
mov    -0x10(%rbp),%rdi
lea    0xdb8(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12cc <setipaddr+0x15c>
mov    $0x1,%edi
mov    $0x30,%esi
call   1050 <calloc@plt>
mov    %rax,-0x58(%rbp)
mov    $0x1,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x58(%rbp),%rax
movl   $0x8,0x4(%rax)
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
movl   $0x81,(%rax)
mov    0x2d1a(%rip),%rax
mov    (%rax),%ecx
mov    -0x68(%rbp),%rax
mov    %ecx,0x4(%rax)
jmp    131c <setipaddr+0x1ac>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x50(%rbp),%rdx
lea    -0x58(%rbp),%rcx
call   1080 <getaddrinfo@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
je     1317 <setipaddr+0x1a7>
lea    0xd29(%rip),%rdi
call   1030 <puts@plt>
mov    0x2cf7(%rip),%rax
mov    (%rax),%ecx
mov    0x2cb6(%rip),%rax
mov    %ecx,(%rax)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    13cf <setipaddr+0x25f>
jmp    131c <setipaddr+0x1ac>
jmp    1321 <setipaddr+0x1b1>
mov    -0x58(%rbp),%rax
movslq 0x4(%rax),%rax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%rax
jae    1345 <setipaddr+0x1d5>
mov    -0x58(%rbp),%rax
movslq 0x4(%rax),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
call   1070 <memcpy@plt>
mov    -0x58(%rbp),%rdi
call   1090 <freeaddrinfo@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
sub    $0x80,%eax
je     139e <setipaddr+0x22e>
jmp    137f <setipaddr+0x20f>
mov    -0x6c(%rbp),%eax
sub    $0x81,%eax
jne    13aa <setipaddr+0x23a>
jmp    1392 <setipaddr+0x222>
movl   $0x4,-0x4(%rbp)
jmp    13cf <setipaddr+0x25f>
movl   $0x10,-0x4(%rbp)
jmp    13cf <setipaddr+0x25f>
lea    0xc80(%rip),%rdi
call   1030 <puts@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
lea    0xc85(%rip),%rdi
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setipaddr>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %edi,0x10(%rsp)
mov    0x2e3e(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x3c(%rsp)
mov    0x2e49(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x38(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x18(%rsp)
movups %xmm0,0x28(%rsp)
cmpb   $0x0,(%rsi)
je     121f <setipaddr+0xaf>
mov    %rsi,%rbx
lea    0xe49(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     125a <setipaddr+0xea>
lea    0xe41(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     125a <setipaddr+0xea>
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <getaddrinfo@plt>
test   %eax,%eax
je     129f <setipaddr+0x12f>
mov    %eax,%ebx
lea    0xe1b(%rip),%rdi
call   1030 <puts@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%eax
mov    0x2da8(%rip),%rcx
mov    %eax,(%rcx)
jmp    130b <setipaddr+0x19b>
lea    0xdda(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
xor    %edi,%edi
call   1080 <getaddrinfo@plt>
mov    %eax,%ebx
test   %eax,%eax
jne    130b <setipaddr+0x19b>
mov    0x8(%rsp),%rbx
cmpq   $0x0,0x10(%rbx)
je     12a4 <setipaddr+0x134>
mov    %rbx,%rdi
call   1090 <freeaddrinfo@plt>
jmp    1306 <setipaddr+0x196>
mov    $0x1,%edi
mov    $0x30,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
mov    %rax,0x8(%rsp)
mov    $0x1,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,0x8(%rbx)
movl   $0x8,0x4(%rbx)
movl   $0x81,(%rax)
mov    0x2d40(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x4(%rax)
jmp    12a4 <setipaddr+0x134>
mov    0x8(%rsp),%rbx
movslq 0x4(%rbx),%rax
mov    (%r14),%rdx
cmp    %rax,%rdx
jbe    12b6 <setipaddr+0x146>
mov    %rax,(%r14)
mov    %rax,%rdx
mov    0x8(%rbx),%rsi
mov    %r15,%rdi
call   1070 <memcpy@plt>
mov    0x8(%rsp),%rdi
call   1090 <freeaddrinfo@plt>
mov    (%r15),%eax
cmp    $0x81,%eax
je     12e4 <setipaddr+0x174>
cmp    $0x80,%eax
jne    12eb <setipaddr+0x17b>
mov    $0x10,%ebx
jmp    130b <setipaddr+0x19b>
mov    $0x4,%ebx
jmp    130b <setipaddr+0x19b>
lea    0xd3f(%rip),%rdi
call   1030 <puts@plt>
mov    (%r15),%esi
lea    0xd47(%rip),%rdi
call   1040 <printf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
%struct.addrinfo = type { i32, i32, i32*, i32*, i32*, i64, i32, i32 }
%struct.sockaddr_in = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@.str = [2 x i8] c"0\00"
@.str.1 = [16 x i8] c"255.255.255.255\00"
@.str.2 = [12 x i8] c"<broadcast>\00"
@INADDR_BROADCAST = global i32 0
@.str.3 = [19 x i8] c"Unable to resolve!\00"
@EFAULT = global i32 0
@errno = global i32 0
@.str.4 = [23 x i8] c"Unknown address family\00"
@.str.5 = [8 x i8] c" %d\0A\00"
define i32 @setipaddr(i32 %0, i8* %1, %struct.sockaddr* %2, i64* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca %struct.sockaddr*
%9 = alloca i64*
%10 = alloca %struct.addrinfo
%11 = alloca %struct.addrinfo*
%12 = alloca i32
%13 = alloca %struct.sockaddr_in*
store i32 %0, i32* %6
store i8* %1, i8** %7
store %struct.sockaddr* %2, %struct.sockaddr** %8
store i64* %3, i64** %9
%14 = load i32, i32* %6
%15 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 0
store i32 %14, i32* %15
%16 = load i32, i32* @SOCK_STREAM
%17 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 7
store i32 %16, i32* %17
%18 = load i32, i32* @AI_PASSIVE
%19 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 6
store i32 %18, i32* %19
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 5
store i64 0, i64* %20
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 4
store i32* null, i32** %21
%22 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 2
store i32* null, i32** %22
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 3
store i32* null, i32** %23
store i32 0, i32* %12
%24 = load i8*, i8** %7
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %44
29: ; preds = %4
%30 = call i32 @getaddrinfo(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %struct.addrinfo* %10, %struct.addrinfo** %11)
store i32 %30, i32* %12
%31 = load i32, i32* %12
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = load i32, i32* %12
store i32 %34, i32* %5
br label %118
35: ; preds = %29
%36 = load %struct.addrinfo*, %struct.addrinfo** %11
%37 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %36, i32 0, i32 3
%38 = load i32*, i32** %37
%39 = icmp ne i32* %38, null
br i1 %39, label %40, label %43
40: ; preds = %35
%41 = load %struct.addrinfo*, %struct.addrinfo** %11
%42 = call i32 @freeaddrinfo(%struct.addrinfo* %41)
store i32 -1, i32* %5
br label %118
43: ; preds = %35
br label %82
44: ; preds = %4
%45 = load i8*, i8** %7
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %52, label %48
48: ; preds = %44
%49 = load i8*, i8** %7
%50 = call i64 @strcmp(i8* %49, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %71
52: ; preds = %48, %44
%53 = call i8* @calloc(i32 1, i32 48)
%54 = bitcast i8* %53 to %struct.addrinfo*
store %struct.addrinfo* %54, %struct.addrinfo** %11
%55 = call i8* @calloc(i32 1, i32 8)
%56 = bitcast i8* %55 to i32*
%57 = load %struct.addrinfo*, %struct.addrinfo** %11
%58 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %57, i32 0, i32 2
store i32* %56, i32** %58
%59 = load %struct.addrinfo*, %struct.addrinfo** %11
%60 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %59, i32 0, i32 1
store i32 8, i32* %60
%61 = load %struct.addrinfo*, %struct.addrinfo** %11
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %61, i32 0, i32 2
%63 = load i32*, i32** %62
%64 = bitcast i32* %63 to %struct.sockaddr_in*
store %struct.sockaddr_in* %64, %struct.sockaddr_in** %13
%65 = load %struct.sockaddr_in*, %struct.sockaddr_in** %13
%66 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %65, i32 0, i32 0
store i32 129, i32* %66
%67 = load i32, i32* @INADDR_BROADCAST
%68 = load %struct.sockaddr_in*, %struct.sockaddr_in** %13
%69 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %68, i32 0, i32 1
%70 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %69, i32 0, i32 0
store i32 %67, i32* %70
br label %81
71: ; preds = %48
%72 = load i8*, i8** %7
%73 = call i32 @getaddrinfo(i8* %72, i8* null, %struct.addrinfo* %10, %struct.addrinfo** %11)
store i32 %73, i32* %12
%74 = load i32, i32* %12
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %71
%77 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%78 = load i32, i32* @EFAULT
store i32 %78, i32* @errno
%79 = load i32, i32* %12
store i32 %79, i32* %5
br label %118
80: ; preds = %71
br label %81
81: ; preds = %80, %52
br label %82
82: ; preds = %81, %43
%83 = load %struct.addrinfo*, %struct.addrinfo** %11
%84 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %83, i32 0, i32 1
%85 = load i32, i32* %84
%86 = sext i32 %85 to i64
%87 = load i64*, i64** %9
%88 = load i64, i64* %87
%89 = icmp ult i64 %86, %88
br i1 %89, label %90, label %96
90: ; preds = %82
%91 = load %struct.addrinfo*, %struct.addrinfo** %11
%92 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %91, i32 0, i32 1
%93 = load i32, i32* %92
%94 = sext i32 %93 to i64
%95 = load i64*, i64** %9
store i64 %94, i64* %95
br label %96
96: ; preds = %90, %82
%97 = load %struct.sockaddr*, %struct.sockaddr** %8
%98 = bitcast %struct.sockaddr* %97 to i8*
%99 = load %struct.addrinfo*, %struct.addrinfo** %11
%100 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %99, i32 0, i32 2
%101 = load i32*, i32** %100
%102 = load i64*, i64** %9
%103 = load i64, i64* %102
%104 = call i32 @memcpy(i8* %98, i32* %101, i64 %103)
%105 = load %struct.addrinfo*, %struct.addrinfo** %11
%106 = call i32 @freeaddrinfo(%struct.addrinfo* %105)
%107 = load %struct.sockaddr*, %struct.sockaddr** %8
%108 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %107, i32 0, i32 0
%109 = load i32, i32* %108
switch i32 %109, label %112 [
i32 129, label %110
i32 128, label %111
]
110: ; preds = %96
store i32 4, i32* %5
br label %118
111: ; preds = %96
store i32 16, i32* %5
br label %118
112: ; preds = %96
%113 = call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%114 = load %struct.sockaddr*, %struct.sockaddr** %8
%115 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %114, i32 0, i32 0
%116 = load i32, i32* %115
%117 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %116)
store i32 -1, i32* %5
br label %118
118: ; preds = %112, %111, %110, %76, %40, %33
%119 = load i32, i32* %5
ret i32 %119
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
%struct.addrinfo = type { i32, i32, i32*, i32*, i32*, i64, i32, i32 }
%struct.sockaddr_in = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@SOCK_STREAM = global i32 0
@AI_PASSIVE = global i32 0
@.str = [2 x i8] c"0\00"
@.str.1 = [16 x i8] c"255.255.255.255\00"
@.str.2 = [12 x i8] c"<broadcast>\00"
@INADDR_BROADCAST = global i32 0
@.str.3 = [19 x i8] c"Unable to resolve!\00"
@EFAULT = global i32 0
@errno = global i32 0
@.str.4 = [23 x i8] c"Unknown address family\00"
@.str.5 = [8 x i8] c" %d\0A\00"
define i32 @setipaddr(i32 %0, i8* %1, %struct.sockaddr* %2, i64* nocapture %3) {
%5 = alloca %struct.addrinfo
%6 = alloca %struct.addrinfo*
%7 = bitcast %struct.addrinfo* %5 to i8*
%8 = bitcast %struct.addrinfo** %6 to i8*
%9 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 0
store i32 %0, i32* %9
%10 = load i32, i32* @SOCK_STREAM
%11 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 7
store i32 %10, i32* %11
%12 = load i32, i32* @AI_PASSIVE
%13 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 6
store i32 %12, i32* %13
%14 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 2
%15 = bitcast i32** %14 to i8*
%16 = load i8, i8* %1
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %28
18: ; preds = %4
%19 = call i32 @getaddrinfo(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %struct.addrinfo* %5, %struct.addrinfo** %6)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %77
21: ; preds = %18
%22 = load %struct.addrinfo*, %struct.addrinfo** %6
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %22, i64 0, i32 3
%24 = load i32*, i32** %23
%25 = icmp eq i32* %24, null
br i1 %25, label %54, label %26
26: ; preds = %21
%27 = call i32 @freeaddrinfo(%struct.addrinfo* %22)
br label %77
28: ; preds = %4
%29 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %46
34: ; preds = %31, %28
%35 = tail call dereferenceable_or_null(48) i8* @calloc(i32 1, i32 48)
%36 = bitcast %struct.addrinfo** %6 to i8**
store i8* %35, i8** %36
%37 = tail call dereferenceable_or_null(8) i8* @calloc(i32 1, i32 8)
%38 = bitcast i8* %35 to %struct.addrinfo*
%39 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i64 0, i32 2
%40 = bitcast i32** %39 to i8**
store i8* %37, i8** %40
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %38, i64 0, i32 1
store i32 8, i32* %41
%42 = bitcast i8* %37 to %struct.sockaddr_in*
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %42, i64 0, i32 0
store i32 129, i32* %43
%44 = load i32, i32* @INADDR_BROADCAST
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %42, i64 0, i32 1, i32 0
store i32 %44, i32* %45
br label %54
46: ; preds = %31
%47 = call i32 @getaddrinfo(i8* %1, i8* null, %struct.addrinfo* %5, %struct.addrinfo** %6)
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = load %struct.addrinfo*, %struct.addrinfo** %6
br label %54
51: ; preds = %46
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%53 = load i32, i32* @EFAULT
store i32 %53, i32* @errno
br label %77
54: ; preds = %49, %34, %21
%55 = phi %struct.addrinfo* [ %50, %49 ], [ %38, %34 ], [ %22, %21 ]
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %55, i64 0, i32 1
%57 = load i32, i32* %56
%58 = sext i32 %57 to i64
%59 = load i64, i64* %3
%60 = icmp ugt i64 %59, %58
br i1 %60, label %61, label %62
61: ; preds = %54
store i64 %58, i64* %3
br label %62
62: ; preds = %61, %54
%63 = phi i64 [ %58, %61 ], [ %59, %54 ]
%64 = bitcast %struct.sockaddr* %2 to i8*
%65 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %55, i64 0, i32 2
%66 = load i32*, i32** %65
%67 = call i32 @memcpy(i8* %64, i32* %66, i64 %63)
%68 = load %struct.addrinfo*, %struct.addrinfo** %6
%69 = call i32 @freeaddrinfo(%struct.addrinfo* %68)
%70 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %2, i64 0, i32 0
%71 = load i32, i32* %70
switch i32 %71, label %73 [
i32 129, label %77
i32 128, label %72
]
72: ; preds = %62
br label %77
73: ; preds = %62
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%75 = load i32, i32* %70
%76 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %75)
br label %77
77: ; preds = %62, %18, %73, %72, %51, %26
%78 = phi i32 [ -1, %26 ], [ -1, %73 ], [ 16, %72 ], [ %47, %51 ], [ %19, %18 ], [ 4, %62 ]
ret i32 %78
}