#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 */
struct sockaddr {
  int dummy;
};
struct addrinfo {
  int ai_family;
  int ai_socktype;
  int /*<<< orphan*/ ai_addrlen;
  scalar_t__ ai_addr;
  int /*<<< orphan*/ ai_protocol;
  struct addrinfo *ai_next;
};

/* Variables and functions */
scalar_t__ PF_INET;
scalar_t__ PF_INET6;
scalar_t__ connect(int, struct sockaddr *, int /*<<< orphan*/);
int /*<<< orphan*/ debug(int, char *, ...);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int /*<<< orphan*/ gai_strerror(int);
int getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int socket(scalar_t__, int, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int socket_connect_ip(char *host, char *service, int family, int socktype) {
  struct addrinfo hints, *list = NULL, *p = NULL, *ipv6 = NULL, *ipv4 = NULL;
  int sock, res;
  if ((!host) || (!service))
    return -1;
  memset(&hints, 0, sizeof hints);
  hints.ai_family = family;
  hints.ai_socktype = socktype;
  if ((res = getaddrinfo(host, service, &hints, &list)) == -1) {
    debug(1, "socket_connect_ip(): getaddrinfo failed: %s", gai_strerror(res));
    return -1;
  }
  for (p = list; p; p = p->ai_next) {
    if ((!ipv6) && (p->ai_family == PF_INET6))
      ipv6 = p;
    if ((!ipv4) && (p->ai_family == PF_INET))
      ipv4 = p;
  }
  if (!ipv4 && !ipv6) {
    debug(1, "socket_connect_ip(): Could not find a suitable IP address to "
             "connect to");
    return -1;
  }
  p = (ipv6) ? ipv6 : ipv4;
  sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
  if (sock == -1) {
    freeaddrinfo(list);
    debug(1, "socket_connect_ip(): Could not create ip socket: %s",
          strerror(errno));
    return -1;
  }
  if (connect(sock, (struct sockaddr *)p->ai_addr, p->ai_addrlen)) {
    freeaddrinfo(list);
    debug(1,
          "socket_connect_ip(): Could not connect to inet host:port '%s:%s'.",
          host, service);
    return -1;
  }
  freeaddrinfo(list);
  return (sock);
}


x86 assembly (clang, -O0):
<socket_connect_ip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
movq   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movq   $0x0,-0x60(%rbp)
movq   $0x0,-0x68(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11cf <socket_connect_ip+0x4f>
cmpq   $0x0,-0x18(%rbp)
jne    11db <socket_connect_ip+0x5b>
movl   $0xffffffff,-0x4(%rbp)
jmp    13da <socket_connect_ip+0x25a>
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x48(%rbp),%rdx
lea    -0x50(%rbp),%rcx
call   1070 <getaddrinfo@plt>
mov    %eax,-0x70(%rbp)
cmp    $0xffffffff,%eax
jne    1241 <socket_connect_ip+0xc1>
mov    -0x70(%rbp),%edi
call   1040 <gai_strerror@plt>
mov    %eax,%edx
mov    $0x1,%edi
lea    0xdd2(%rip),%rsi
mov    $0x0,%al
call   1030 <debug@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13da <socket_connect_ip+0x25a>
mov    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     12be <socket_connect_ip+0x13e>
cmpq   $0x0,-0x60(%rbp)
jne    127e <socket_connect_ip+0xfe>
mov    -0x58(%rbp),%rax
movslq (%rax),%rax
mov    0x2d7b(%rip),%rcx
cmp    (%rcx),%rax
jne    127e <socket_connect_ip+0xfe>
mov    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    12a8 <socket_connect_ip+0x128>
mov    -0x58(%rbp),%rax
movslq (%rax),%rax
mov    0x2d39(%rip),%rcx
cmp    (%rcx),%rax
jne    12a8 <socket_connect_ip+0x128>
mov    -0x58(%rbp),%rax
mov    %rax,-0x68(%rbp)
jmp    12ad <socket_connect_ip+0x12d>
mov    -0x58(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x58(%rbp)
jmp    1249 <socket_connect_ip+0xc9>
cmpq   $0x0,-0x68(%rbp)
jne    12f3 <socket_connect_ip+0x173>
cmpq   $0x0,-0x60(%rbp)
jne    12f3 <socket_connect_ip+0x173>
mov    $0x1,%edi
lea    0xd4c(%rip),%rsi
mov    $0x0,%al
call   1030 <debug@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13da <socket_connect_ip+0x25a>
cmpq   $0x0,-0x60(%rbp)
je     130b <socket_connect_ip+0x18b>
mov    -0x60(%rbp),%rax
mov    %rax,-0x78(%rbp)
jmp    1313 <socket_connect_ip+0x193>
mov    -0x68(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
movslq (%rax),%rdi
mov    -0x58(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x58(%rbp),%rax
mov    0x18(%rax),%edx
call   10a0 <socket@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0xffffffff,-0x6c(%rbp)
jne    137a <socket_connect_ip+0x1fa>
mov    -0x50(%rbp),%rdi
call   1090 <freeaddrinfo@plt>
mov    0x2c86(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    %eax,%edx
mov    $0x1,%edi
lea    0xd0d(%rip),%rsi
mov    $0x0,%al
call   1030 <debug@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13da <socket_connect_ip+0x25a>
mov    -0x6c(%rbp),%edi
mov    -0x58(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%edx
call   1060 <connect@plt>
cmp    $0x0,%rax
je     13cb <socket_connect_ip+0x24b>
mov    -0x50(%rbp),%rdi
call   1090 <freeaddrinfo@plt>
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    $0x1,%edi
lea    0xcf0(%rip),%rsi
mov    $0x0,%al
call   1030 <debug@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13da <socket_connect_ip+0x25a>
mov    -0x50(%rbp),%rdi
call   1090 <freeaddrinfo@plt>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<socket_connect_ip>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
movq   $0x0,(%rsp)
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     1326 <socket_connect_ip+0x1a6>
mov    %rsi,%r14
test   %rsi,%rsi
je     1326 <socket_connect_ip+0x1a6>
mov    %ecx,%r12d
mov    %edx,%ebx
mov    %rdi,%r15
lea    0x8(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
mov    %ebx,0x8(%rsp)
mov    %r12d,0xc(%rsp)
mov    %rsp,%rcx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1070 <getaddrinfo@plt>
cmp    $0xffffffff,%eax
je     1255 <socket_connect_ip+0xd5>
mov    (%rsp),%rax
test   %rax,%rax
je     127e <socket_connect_ip+0xfe>
mov    0x2deb(%rip),%rcx
mov    (%rcx),%rdx
mov    0x2dc9(%rip),%rcx
mov    (%rcx),%rsi
xor    %ebx,%ebx
xor    %ecx,%ecx
jmp    1219 <socket_connect_ip+0x99>
mov    0x20(%rax),%rax
test   %rax,%rax
je     1282 <socket_connect_ip+0x102>
test   %rcx,%rcx
je     1230 <socket_connect_ip+0xb0>
test   %rbx,%rbx
jne    1210 <socket_connect_ip+0x90>
jmp    1244 <socket_connect_ip+0xc4>
cs nopw 0x0(%rax,%rax,1)
nop
movslq (%rax),%rcx
cmp    %rcx,%rdx
mov    $0x0,%ecx
cmove  %rax,%rcx
test   %rbx,%rbx
jne    1210 <socket_connect_ip+0x90>
movslq (%rax),%rdi
cmp    %rdi,%rsi
mov    $0x0,%ebx
cmove  %rax,%rbx
jmp    1210 <socket_connect_ip+0x90>
mov    $0xffffffff,%ebp
mov    $0xffffffff,%edi
call   1040 <gai_strerror@plt>
lea    0xd95(%rip),%rsi
mov    $0x1,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <debug@plt>
jmp    1326 <socket_connect_ip+0x1a6>
xor    %ecx,%ecx
xor    %ebx,%ebx
mov    %rbx,%rax
or     %rcx,%rax
je     12e0 <socket_connect_ip+0x160>
test   %rcx,%rcx
cmovne %rcx,%rbx
movslq (%rbx),%rdi
mov    0x4(%rbx),%esi
mov    0x18(%rbx),%edx
call   10a0 <socket@plt>
cmp    $0xffffffff,%eax
je     12f5 <socket_connect_ip+0x175>
mov    %eax,%ebp
mov    0x10(%rbx),%rsi
mov    0x8(%rbx),%edx
mov    %eax,%edi
call   1060 <connect@plt>
mov    %rax,%rbx
mov    (%rsp),%rdi
call   1090 <freeaddrinfo@plt>
test   %rbx,%rbx
je     1326 <socket_connect_ip+0x1a6>
lea    0xddc(%rip),%rsi
mov    $0x1,%edi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <debug@plt>
jmp    1321 <socket_connect_ip+0x1a1>
lea    0xd45(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <debug@plt>
jmp    1321 <socket_connect_ip+0x1a1>
mov    (%rsp),%rdi
call   1090 <freeaddrinfo@plt>
mov    0x2cd3(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xd61(%rip),%rsi
mov    $0x1,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <debug@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i64, i32, %struct.addrinfo* }
%struct.sockaddr = type { i32 }
@.str = [44 x i8] c"socket_connect_ip(): getaddrinfo failed: %s\00"
@PF_INET6 = global i64 0
@PF_INET = global i64 0
@.str.1 = [72 x i8] c"socket_connect_ip(): Could not find a suitable IP address to connect to\00"
@.str.2 = [52 x i8] c"socket_connect_ip(): Could not create ip socket: %s\00"
@errno = global i32 0
@.str.3 = [66 x i8] c"socket_connect_ip(): Could not connect to inet host:port '%s:%s'.\00"
define i32 @socket_connect_ip(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.addrinfo
%11 = alloca %struct.addrinfo*
%12 = alloca %struct.addrinfo*
%13 = alloca %struct.addrinfo*
%14 = alloca %struct.addrinfo*
%15 = alloca i32
%16 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store %struct.addrinfo* null, %struct.addrinfo** %11
store %struct.addrinfo* null, %struct.addrinfo** %12
store %struct.addrinfo* null, %struct.addrinfo** %13
store %struct.addrinfo* null, %struct.addrinfo** %14
%17 = load i8*, i8** %6
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %4
%20 = load i8*, i8** %7
%21 = icmp ne i8* %20, null
br i1 %21, label %23, label %22
22: ; preds = %19, %4
store i32 -1, i32* %5
br label %128
23: ; preds = %19
%24 = call i32 @memset(%struct.addrinfo* %10, i32 0, i32 40)
%25 = load i32, i32* %8
%26 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 0
store i32 %25, i32* %26
%27 = load i32, i32* %9
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 1
store i32 %27, i32* %28
%29 = load i8*, i8** %6
%30 = load i8*, i8** %7
%31 = call i32 @getaddrinfo(i8* %29, i8* %30, %struct.addrinfo* %10, %struct.addrinfo** %11)
store i32 %31, i32* %16
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %37
33: ; preds = %23
%34 = load i32, i32* %16
%35 = call i32 @gai_strerror(i32 %34)
%36 = call i32 (i32, i8*, ...) @debug(i32 1, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %35)
store i32 -1, i32* %5
br label %128
37: ; preds = %23
%38 = load %struct.addrinfo*, %struct.addrinfo** %11
store %struct.addrinfo* %38, %struct.addrinfo** %12
br label %39
39: ; preds = %67, %37
%40 = load %struct.addrinfo*, %struct.addrinfo** %12
%41 = icmp ne %struct.addrinfo* %40, null
br i1 %41, label %42, label %71
42: ; preds = %39
%43 = load %struct.addrinfo*, %struct.addrinfo** %13
%44 = icmp ne %struct.addrinfo* %43, null
br i1 %44, label %54, label %45
45: ; preds = %42
%46 = load %struct.addrinfo*, %struct.addrinfo** %12
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %46, i32 0, i32 0
%48 = load i32, i32* %47
%49 = sext i32 %48 to i64
%50 = load i64, i64* @PF_INET6
%51 = icmp eq i64 %49, %50
br i1 %51, label %52, label %54
52: ; preds = %45
%53 = load %struct.addrinfo*, %struct.addrinfo** %12
store %struct.addrinfo* %53, %struct.addrinfo** %13
br label %54
54: ; preds = %52, %45, %42
%55 = load %struct.addrinfo*, %struct.addrinfo** %14
%56 = icmp ne %struct.addrinfo* %55, null
br i1 %56, label %66, label %57
57: ; preds = %54
%58 = load %struct.addrinfo*, %struct.addrinfo** %12
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %58, i32 0, i32 0
%60 = load i32, i32* %59
%61 = sext i32 %60 to i64
%62 = load i64, i64* @PF_INET
%63 = icmp eq i64 %61, %62
br i1 %63, label %64, label %66
64: ; preds = %57
%65 = load %struct.addrinfo*, %struct.addrinfo** %12
store %struct.addrinfo* %65, %struct.addrinfo** %14
br label %66
66: ; preds = %64, %57, %54
br label %67
67: ; preds = %66
%68 = load %struct.addrinfo*, %struct.addrinfo** %12
%69 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %68, i32 0, i32 5
%70 = load %struct.addrinfo*, %struct.addrinfo** %69
store %struct.addrinfo* %70, %struct.addrinfo** %12
br label %39
71: ; preds = %39
%72 = load %struct.addrinfo*, %struct.addrinfo** %14
%73 = icmp ne %struct.addrinfo* %72, null
br i1 %73, label %79, label %74
74: ; preds = %71
%75 = load %struct.addrinfo*, %struct.addrinfo** %13
%76 = icmp ne %struct.addrinfo* %75, null
br i1 %76, label %79, label %77
77: ; preds = %74
%78 = call i32 (i32, i8*, ...) @debug(i32 1, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %5
br label %128
79: ; preds = %74, %71
%80 = load %struct.addrinfo*, %struct.addrinfo** %13
%81 = icmp ne %struct.addrinfo* %80, null
br i1 %81, label %82, label %84
82: ; preds = %79
%83 = load %struct.addrinfo*, %struct.addrinfo** %13
br label %86
84: ; preds = %79
%85 = load %struct.addrinfo*, %struct.addrinfo** %14
br label %86
86: ; preds = %84, %82
%87 = phi %struct.addrinfo* [ %83, %82 ], [ %85, %84 ]
store %struct.addrinfo* %87, %struct.addrinfo** %12
%88 = load %struct.addrinfo*, %struct.addrinfo** %12
%89 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %88, i32 0, i32 0
%90 = load i32, i32* %89
%91 = sext i32 %90 to i64
%92 = load %struct.addrinfo*, %struct.addrinfo** %12
%93 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %92, i32 0, i32 1
%94 = load i32, i32* %93
%95 = load %struct.addrinfo*, %struct.addrinfo** %12
%96 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %95, i32 0, i32 4
%97 = load i32, i32* %96
%98 = call i32 @socket(i64 %91, i32 %94, i32 %97)
store i32 %98, i32* %15
%99 = load i32, i32* %15
%100 = icmp eq i32 %99, -1
br i1 %100, label %101, label %107
101: ; preds = %86
%102 = load %struct.addrinfo*, %struct.addrinfo** %11
%103 = call i32 @freeaddrinfo(%struct.addrinfo* %102)
%104 = load i32, i32* @errno
%105 = call i32 @strerror(i32 %104)
%106 = call i32 (i32, i8*, ...) @debug(i32 1, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %105)
store i32 -1, i32* %5
br label %128
107: ; preds = %86
%108 = load i32, i32* %15
%109 = load %struct.addrinfo*, %struct.addrinfo** %12
%110 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %109, i32 0, i32 3
%111 = load i64, i64* %110
%112 = inttoptr i64 %111 to %struct.sockaddr*
%113 = load %struct.addrinfo*, %struct.addrinfo** %12
%114 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %113, i32 0, i32 2
%115 = load i32, i32* %114
%116 = call i64 @connect(i32 %108, %struct.sockaddr* %112, i32 %115)
%117 = icmp ne i64 %116, 0
br i1 %117, label %118, label %124
118: ; preds = %107
%119 = load %struct.addrinfo*, %struct.addrinfo** %11
%120 = call i32 @freeaddrinfo(%struct.addrinfo* %119)
%121 = load i8*, i8** %6
%122 = load i8*, i8** %7
%123 = call i32 (i32, i8*, ...) @debug(i32 1, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), i8* %121, i8* %122)
store i32 -1, i32* %5
br label %128
124: ; preds = %107
%125 = load %struct.addrinfo*, %struct.addrinfo** %11
%126 = call i32 @freeaddrinfo(%struct.addrinfo* %125)
%127 = load i32, i32* %15
store i32 %127, i32* %5
br label %128
128: ; preds = %124, %118, %101, %77, %33, %22
%129 = load i32, i32* %5
ret i32 %129
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i64, i32, %struct.addrinfo* }
%struct.sockaddr = type { i32 }
@.str = [44 x i8] c"socket_connect_ip(): getaddrinfo failed: %s\00"
@PF_INET6 = global i64 0
@PF_INET = global i64 0
@.str.1 = [72 x i8] c"socket_connect_ip(): Could not find a suitable IP address to connect to\00"
@.str.2 = [52 x i8] c"socket_connect_ip(): Could not create ip socket: %s\00"
@errno = global i32 0
@.str.3 = [66 x i8] c"socket_connect_ip(): Could not connect to inet host:port '%s:%s'.\00"
define i32 @socket_connect_ip(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca %struct.addrinfo
%6 = alloca %struct.addrinfo*
%7 = bitcast %struct.addrinfo* %5 to i8*
%8 = bitcast %struct.addrinfo** %6 to i8*
store %struct.addrinfo* null, %struct.addrinfo** %6
%9 = icmp ne i8* %0, null
%10 = icmp ne i8* %1, null
%11 = and i1 %9, %10
br i1 %11, label %12, label %89
12: ; preds = %4
%13 = call i32 @memset(%struct.addrinfo* %5, i32 0, i32 40)
%14 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 0
store i32 %2, i32* %14
%15 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 1
store i32 %3, i32* %15
%16 = call i32 @getaddrinfo(i8* %0, i8* %1, %struct.addrinfo* %5, %struct.addrinfo** %6)
%17 = icmp eq i32 %16, -1
br i1 %17, label %24, label %18
18: ; preds = %12
%19 = load %struct.addrinfo*, %struct.addrinfo** %6
%20 = icmp eq %struct.addrinfo* %19, null
br i1 %20, label %52, label %21
21: ; preds = %18
%22 = load i64, i64* @PF_INET6
%23 = load i64, i64* @PF_INET
br label %27
24: ; preds = %12
%25 = call i32 @gai_strerror(i32 -1)
%26 = call i32 (i32, i8*, ...) @debug(i32 1, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %25)
br label %89
27: ; preds = %21, %47
%28 = phi %struct.addrinfo* [ %19, %21 ], [ %50, %47 ]
%29 = phi %struct.addrinfo* [ null, %21 ], [ %48, %47 ]
%30 = phi %struct.addrinfo* [ null, %21 ], [ %39, %47 ]
%31 = icmp eq %struct.addrinfo* %30, null
br i1 %31, label %32, label %38
32: ; preds = %27
%33 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %28, i64 0, i32 0
%34 = load i32, i32* %33
%35 = sext i32 %34 to i64
%36 = icmp eq i64 %22, %35
%37 = select i1 %36, %struct.addrinfo* %28, %struct.addrinfo* null
br label %38
38: ; preds = %32, %27
%39 = phi %struct.addrinfo* [ %30, %27 ], [ %37, %32 ]
%40 = icmp eq %struct.addrinfo* %29, null
br i1 %40, label %41, label %47
41: ; preds = %38
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %28, i64 0, i32 0
%43 = load i32, i32* %42
%44 = sext i32 %43 to i64
%45 = icmp eq i64 %23, %44
%46 = select i1 %45, %struct.addrinfo* %28, %struct.addrinfo* null
br label %47
47: ; preds = %41, %38
%48 = phi %struct.addrinfo* [ %29, %38 ], [ %46, %41 ]
%49 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %28, i64 0, i32 5
%50 = load %struct.addrinfo*, %struct.addrinfo** %49
%51 = icmp eq %struct.addrinfo* %50, null
br i1 %51, label %52, label %27
52: ; preds = %47, %18
%53 = phi %struct.addrinfo* [ null, %18 ], [ %39, %47 ]
%54 = phi %struct.addrinfo* [ null, %18 ], [ %48, %47 ]
%55 = icmp ne %struct.addrinfo* %54, null
%56 = icmp ne %struct.addrinfo* %53, null
%57 = select i1 %55, i1 true, i1 %56
br i1 %57, label %60, label %58
58: ; preds = %52
%59 = call i32 (i32, i8*, ...) @debug(i32 1, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.1, i64 0, i64 0))
br label %89
60: ; preds = %52
%61 = select i1 %56, %struct.addrinfo* %53, %struct.addrinfo* %54
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %61, i64 0, i32 0
%63 = load i32, i32* %62
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %61, i64 0, i32 1
%66 = load i32, i32* %65
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %61, i64 0, i32 4
%68 = load i32, i32* %67
%69 = call i32 @socket(i64 %64, i32 %66, i32 %68)
%70 = icmp eq i32 %69, -1
br i1 %70, label %71, label %77
71: ; preds = %60
%72 = load %struct.addrinfo*, %struct.addrinfo** %6
%73 = call i32 @freeaddrinfo(%struct.addrinfo* %72)
%74 = load i32, i32* @errno
%75 = call i32 @strerror(i32 %74)
%76 = call i32 (i32, i8*, ...) @debug(i32 1, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %75)
br label %89
77: ; preds = %60
%78 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %61, i64 0, i32 3
%79 = load i64, i64* %78
%80 = inttoptr i64 %79 to %struct.sockaddr*
%81 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %61, i64 0, i32 2
%82 = load i32, i32* %81
%83 = call i64 @connect(i32 %69, %struct.sockaddr* %80, i32 %82)
%84 = icmp eq i64 %83, 0
%85 = load %struct.addrinfo*, %struct.addrinfo** %6
%86 = call i32 @freeaddrinfo(%struct.addrinfo* %85)
br i1 %84, label %89, label %87
87: ; preds = %77
%88 = call i32 (i32, i8*, ...) @debug(i32 1, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.3, i64 0, i64 0), i8* %0, i8* %1)
br label %89
89: ; preds = %77, %4, %87, %71, %58, %24
%90 = phi i32 [ -1, %24 ], [ -1, %71 ], [ -1, %87 ], [ -1, %58 ], [ -1, %4 ], [ %69, %77 ]
ret i32 %90
}