#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 /*<<< orphan*/ targetip_str;
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
};
struct addrinfo {
  int /*<<< orphan*/ ai_family;
  scalar_t__ ai_addr;
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
};
typedef int /*<<< orphan*/ hints;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int INET6_ADDRSTRLEN;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int getaddrinfo(char const *, char const *, struct addrinfo *,
                struct addrinfo **);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, void *, char *, int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char const *argv[]) {
  if (argc != 3) {
    fprintf(stderr, "Usage: showip <target_hostname> <target_port>\n");
    return 1;
  }
  struct addrinfo hints, *targetinfo;
  int status;
  char targetip_str[INET6_ADDRSTRLEN];
  void *addr;
  int sockfd;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_INET;
  hints.ai_socktype = SOCK_STREAM;
  if ((status = getaddrinfo(argv[1], argv[2], &hints, &targetinfo)) != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(status));
    return 2;
  }
  struct sockaddr_in *ipv4_addr = (struct sockaddr_in *)targetinfo->ai_addr;
  addr = &(ipv4_addr->sin_addr);
  inet_ntop(targetinfo->ai_family, addr, targetip_str, sizeof(targetip_str));
  printf("\tAddress selected: %s\n", targetip_str);
  sockfd = socket(targetinfo->ai_family, targetinfo->ai_socktype,
                  targetinfo->ai_protocol);
  if (sockfd == -1) {
    perror("\tsocket");
    return 2;
  }
  printf("\tSocket created.\n");
  freeaddrinfo(targetinfo);
  if (connect(sockfd, targetinfo->ai_addr, targetinfo->ai_addrlen) == -1) {
    close(sockfd);
    perror("\tconnect");
    return 3;
  }
  addr = &(((struct sockaddr_in *)targetinfo->ai_addr)->sin_addr);
  inet_ntop(targetinfo->ai_family, addr, targetip_str, sizeof(targetip_str));
  printf("\tConnected to %s\n", targetip_str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11f6 <main+0x46>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xe1d(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13e0 <main+0x230>
mov    0x2deb(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x78(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x50(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d7f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   10b0 <getaddrinfo@plt>
mov    %eax,-0x3c(%rbp)
cmp    $0x0,%eax
je     12b2 <main+0x102>
mov    0x2d52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x3c(%rbp),%edi
call   1050 <gai_strerror@plt>
mov    -0x7c(%rbp),%edi
mov    %rax,%rdx
lea    0xd97(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0x60(%rbp)
jmp    13d9 <main+0x229>
mov    -0x70(%rbp),%rdx
mov    -0x78(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    0x8(%rcx),%rcx
mov    %rcx,-0x68(%rbp)
mov    -0x68(%rbp),%rcx
mov    %rcx,-0x58(%rbp)
mov    -0x38(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x58(%rbp),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0x70(%rbp),%rsi
lea    0xd56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rax
mov    0x18(%rax),%esi
mov    -0x38(%rbp),%rax
mov    0x14(%rax),%edx
call   10d0 <socket@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0xffffffff,-0x5c(%rbp)
jne    1336 <main+0x186>
lea    0xd39(%rip),%rdi
call   1090 <perror@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0x60(%rbp)
jmp    13d9 <main+0x229>
lea    0xd22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
call   10c0 <freeaddrinfo@plt>
mov    -0x5c(%rbp),%edi
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%edx
call   10a0 <connect@plt>
cmp    $0xffffffff,%eax
jne    1394 <main+0x1e4>
mov    -0x5c(%rbp),%edi
call   1070 <close@plt>
lea    0xcf5(%rip),%rdi
call   1090 <perror@plt>
movl   $0x3,-0x4(%rbp)
movl   $0x1,-0x60(%rbp)
jmp    13d9 <main+0x229>
mov    -0x70(%rbp),%rdx
mov    -0x78(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    0x8(%rcx),%rcx
mov    %rcx,-0x58(%rbp)
mov    -0x38(%rbp),%rcx
mov    (%rcx),%edi
mov    -0x58(%rbp),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0x70(%rbp),%rsi
lea    0xcb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x60(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x3,%edi
jne    126b <main+0xab>
mov    %rsi,%rbx
mov    %rsp,%r13
mov    0x2e01(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%r15
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    -0x50(%rbp),%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1070 <memset@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2da7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
lea    -0x30(%rbp),%rcx
mov    %r12,%rdx
call   10c0 <getaddrinfo@plt>
test   %eax,%eax
je     128c <main+0xcc>
mov    0x2d8b(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1060 <gai_strerror@plt>
lea    0xdda(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x2,%ebx
jmp    131e <main+0x15e>
mov    0x2d5e(%rip),%rax
mov    (%rax),%edi
lea    0xd85(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%ebx
jmp    1321 <main+0x161>
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rsi
mov    (%rax),%edi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1030 <inet_ntop@plt>
lea    0xd98(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x30(%rbp),%rax
mov    0x18(%rax),%esi
mov    (%rax),%edi
mov    0x14(%rax),%edx
call   10e0 <socket@plt>
cmp    $0xffffffff,%eax
je     1332 <main+0x172>
mov    %eax,%ebx
lea    0xda9(%rip),%rdi
call   1040 <puts@plt>
mov    -0x30(%rbp),%rdi
call   10d0 <freeaddrinfo@plt>
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rsi
mov    0x10(%rax),%edx
mov    %ebx,%edi
call   10b0 <connect@plt>
cmp    $0xffffffff,%eax
je     1345 <main+0x185>
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rsi
mov    (%rax),%edi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1030 <inet_ntop@plt>
lea    0xd56(%rip),%rdi
xor    %ebx,%ebx
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,%rsp
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd1e(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x2,%ebx
jmp    131e <main+0x15e>
mov    %ebx,%edi
call   1080 <close@plt>
lea    0xd0c(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x3,%ebx
jmp    131e <main+0x15e>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i64, i32, i32, i32 }
%struct.sockaddr_in = type { i32 }
@stderr = global i32 0
@.str = [47 x i8] c"Usage: showip <target_hostname> <target_port>\0A\00"
@INET6_ADDRSTRLEN = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.2 = [23 x i8] c"\09Address selected: %s\0A\00"
@.str.3 = [8 x i8] c"\09socket\00"
@.str.4 = [18 x i8] c"\09Socket created.\0A\00"
@.str.5 = [9 x i8] c"\09connect\00"
@.str.6 = [18 x i8] c"\09Connected to %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.addrinfo
%7 = alloca %struct.addrinfo*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca %struct.sockaddr_in*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 3
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %105
20: ; preds = %2
%21 = load i32, i32* @INET6_ADDRSTRLEN
%22 = zext i32 %21 to i64
%23 = call i8* @llvm.stacksave()
store i8* %23, i8** %9
%24 = alloca i8, i64 %22
store i64 %22, i64* %10
%25 = call i32 @memset(%struct.addrinfo* %6, i32 0, i32 32)
%26 = load i32, i32* @AF_INET
%27 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 0
store i32 %26, i32* %27
%28 = load i32, i32* @SOCK_STREAM
%29 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %6, i32 0, i32 4
store i32 %28, i32* %29
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call i32 @getaddrinfo(i8* %32, i8* %35, %struct.addrinfo* %6, %struct.addrinfo** %7)
store i32 %36, i32* %8
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %20
%39 = load i32, i32* @stderr
%40 = load i32, i32* %8
%41 = call i8* @gai_strerror(i32 %40)
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %41)
store i32 2, i32* %3
store i32 1, i32* %13
br label %103
43: ; preds = %20
%44 = load %struct.addrinfo*, %struct.addrinfo** %7
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i32 0, i32 1
%46 = load i64, i64* %45
%47 = inttoptr i64 %46 to %struct.sockaddr_in*
store %struct.sockaddr_in* %47, %struct.sockaddr_in** %14
%48 = load %struct.sockaddr_in*, %struct.sockaddr_in** %14
%49 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %48, i32 0, i32 0
%50 = bitcast i32* %49 to i8*
store i8* %50, i8** %11
%51 = load %struct.addrinfo*, %struct.addrinfo** %7
%52 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %51, i32 0, i32 0
%53 = load i32, i32* %52
%54 = load i8*, i8** %11
%55 = trunc i64 %22 to i32
%56 = call i32 @inet_ntop(i32 %53, i8* %54, i8* %24, i32 %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%58 = load %struct.addrinfo*, %struct.addrinfo** %7
%59 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %58, i32 0, i32 0
%60 = load i32, i32* %59
%61 = load %struct.addrinfo*, %struct.addrinfo** %7
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %61, i32 0, i32 4
%63 = load i32, i32* %62
%64 = load %struct.addrinfo*, %struct.addrinfo** %7
%65 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %64, i32 0, i32 3
%66 = load i32, i32* %65
%67 = call i32 @socket(i32 %60, i32 %63, i32 %66)
store i32 %67, i32* %12
%68 = load i32, i32* %12
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %72
70: ; preds = %43
%71 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
store i32 2, i32* %3
store i32 1, i32* %13
br label %103
72: ; preds = %43
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%74 = load %struct.addrinfo*, %struct.addrinfo** %7
%75 = call i32 @freeaddrinfo(%struct.addrinfo* %74)
%76 = load i32, i32* %12
%77 = load %struct.addrinfo*, %struct.addrinfo** %7
%78 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %77, i32 0, i32 1
%79 = load i64, i64* %78
%80 = load %struct.addrinfo*, %struct.addrinfo** %7
%81 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %80, i32 0, i32 2
%82 = load i32, i32* %81
%83 = call i32 @connect(i32 %76, i64 %79, i32 %82)
%84 = icmp eq i32 %83, -1
br i1 %84, label %85, label %89
85: ; preds = %72
%86 = load i32, i32* %12
%87 = call i32 @close(i32 %86)
%88 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
store i32 3, i32* %3
store i32 1, i32* %13
br label %103
89: ; preds = %72
%90 = load %struct.addrinfo*, %struct.addrinfo** %7
%91 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %90, i32 0, i32 1
%92 = load i64, i64* %91
%93 = inttoptr i64 %92 to %struct.sockaddr_in*
%94 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %93, i32 0, i32 0
%95 = bitcast i32* %94 to i8*
store i8* %95, i8** %11
%96 = load %struct.addrinfo*, %struct.addrinfo** %7
%97 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %96, i32 0, i32 0
%98 = load i32, i32* %97
%99 = load i8*, i8** %11
%100 = trunc i64 %22 to i32
%101 = call i32 @inet_ntop(i32 %98, i8* %99, i8* %24, i32 %100)
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %24)
store i32 0, i32* %3
store i32 1, i32* %13
br label %103
103: ; preds = %89, %85, %70, %38
%104 = load i8*, i8** %9
br label %105
105: ; preds = %103, %17
%106 = load i32, i32* %3
ret i32 %106
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i64, i32, i32, i32 }
@stderr = global i32 0
@.str = [47 x i8] c"Usage: showip <target_hostname> <target_port>\0A\00"
@INET6_ADDRSTRLEN = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.2 = [23 x i8] c"\09Address selected: %s\0A\00"
@.str.3 = [8 x i8] c"\09socket\00"
@.str.5 = [9 x i8] c"\09connect\00"
@.str.6 = [18 x i8] c"\09Connected to %s\0A\00"
@str = [17 x i8] c"\09Socket created.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = icmp eq i32 %0, 3
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
br label %76
9: ; preds = %2
%10 = bitcast %struct.addrinfo* %3 to i8*
%11 = bitcast %struct.addrinfo** %4 to i8*
%12 = load i32, i32* @INET6_ADDRSTRLEN
%13 = zext i32 %12 to i64
%14 = tail call i8* @llvm.stacksave()
%15 = alloca i8, i64 %13
%16 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 32)
%17 = load i32, i32* @AF_INET
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 0
store i32 %17, i32* %18
%19 = load i32, i32* @SOCK_STREAM
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 4
store i32 %19, i32* %20
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @getaddrinfo(i8* %22, i8* %24, %struct.addrinfo* %3, %struct.addrinfo** %4)
%26 = icmp eq i32 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %9
%28 = load i32, i32* @stderr
%29 = call i8* @gai_strerror(i32 %25)
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %29)
br label %74
31: ; preds = %9
%32 = load %struct.addrinfo*, %struct.addrinfo** %4
%33 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i64 0, i32 1
%34 = load i64, i64* %33
%35 = inttoptr i64 %34 to i8*
%36 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i64 0, i32 0
%37 = load i32, i32* %36
%38 = call i32 @inet_ntop(i32 %37, i8* %35, i8* %15, i32 %12)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%40 = load %struct.addrinfo*, %struct.addrinfo** %4
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 0
%42 = load i32, i32* %41
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 4
%44 = load i32, i32* %43
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %40, i64 0, i32 3
%46 = load i32, i32* %45
%47 = call i32 @socket(i32 %42, i32 %44, i32 %46)
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %51
49: ; preds = %31
%50 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %74
51: ; preds = %31
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%53 = load %struct.addrinfo*, %struct.addrinfo** %4
%54 = call i32 @freeaddrinfo(%struct.addrinfo* %53)
%55 = load %struct.addrinfo*, %struct.addrinfo** %4
%56 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %55, i64 0, i32 1
%57 = load i64, i64* %56
%58 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %55, i64 0, i32 2
%59 = load i32, i32* %58
%60 = call i32 @connect(i32 %47, i64 %57, i32 %59)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %65
62: ; preds = %51
%63 = call i32 @close(i32 %47)
%64 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %74
65: ; preds = %51
%66 = load %struct.addrinfo*, %struct.addrinfo** %4
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %66, i64 0, i32 1
%68 = load i64, i64* %67
%69 = inttoptr i64 %68 to i8*
%70 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %66, i64 0, i32 0
%71 = load i32, i32* %70
%72 = call i32 @inet_ntop(i32 %71, i8* %69, i8* %15, i32 %12)
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %15)
br label %74
74: ; preds = %49, %62, %65, %27
%75 = phi i32 [ 2, %27 ], [ 2, %49 ], [ 3, %62 ], [ 0, %65 ]
br label %76
76: ; preds = %74, %6
%77 = phi i32 [ 1, %6 ], [ %75, %74 ]
ret i32 %77
}