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

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int EXIT_FAILURE;
int INET6_ADDRSTRLEN;
int /*<<< orphan*/ SHUT_RDWR;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int /*<<< orphan*/ get_in_addr(struct sockaddr *);
int getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/, char *,
                             int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int recv(int, char *, int, int /*<<< orphan*/);
scalar_t__ send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ shutdown(int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int strlen(char *);
int main(int argc, char *argv[]) {
  int sockfd, numbytes;
  char buf[100];
  struct addrinfo hints, *servinfo, *p;
  int rv;
  char s[INET6_ADDRSTRLEN];
  if (argc != 2) {
    fprintf(stderr, "usage: client hostname\n");
    exit(1);
  }
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  if ((rv = getaddrinfo(argv[1], "8888", &hints, &servinfo)) != 0) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
    return 1;
  }
  for (p = servinfo; p != NULL; p = p->ai_next) {
    if ((sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
      perror("client: socket");
      continue;
    }
    if (connect(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
      close(sockfd);
      perror("client: connect");
      continue;
    }
    break;
  }
  if (p == NULL) {
    fprintf(stderr, "client: failed to connect\n");
    return 2;
  }
  inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr), s,
            sizeof s);
  printf("client: connecting to %s\n", s);
  freeaddrinfo(servinfo);
  char buff[] = "i am epic and i know it\n";
  int length = strlen(buff);
  if ((send(sockfd, buff, length, 0)) < 0) {
    perror("SEND error");
    shutdown(sockfd, SHUT_RDWR);
    close(sockfd);
    exit(EXIT_FAILURE);
  }
  if ((numbytes = recv(sockfd, buf, 100 - 1, 0)) == -1) {
    perror("recv");
    exit(1);
  }
  buf[numbytes] = '\0';
  printf("client: received '%s'\n", buf);
  close(sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2db0(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x108(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0xc0(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x100(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xc8(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1290 <main+0x80>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
lea    0xd81(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10b0 <memset@plt>
mov    0x2d2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x98(%rbp)
mov    0x2d07(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd48(%rip),%rsi
lea    -0xa0(%rbp),%rdx
lea    -0xa8(%rbp),%rcx
call   1110 <getaddrinfo@plt>
mov    %eax,-0xb4(%rbp)
cmp    $0x0,%eax
je     1339 <main+0x129>
mov    0x2ccf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10c(%rbp)
mov    -0xb4(%rbp),%edi
call   10a0 <gai_strerror@plt>
mov    -0x10c(%rbp),%edi
mov    %rax,%rdx
lea    0xd01(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0xcc(%rbp)
jmp    1588 <main+0x378>
mov    -0xa8(%rbp),%rax
mov    %rax,-0xb0(%rbp)
cmpq   $0x0,-0xb0(%rbp)
je     13ef <main+0x1df>
mov    -0xb0(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0xb0(%rbp),%rax
mov    0x14(%rax),%esi
mov    -0xb0(%rbp),%rax
mov    0x10(%rax),%edx
call   1130 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    1395 <main+0x185>
lea    0xca3(%rip),%rdi
call   10e0 <perror@plt>
jmp    13d8 <main+0x1c8>
mov    -0x14(%rbp),%edi
mov    -0xb0(%rbp),%rax
mov    (%rax),%rsi
mov    -0xb0(%rbp),%rax
mov    0xc(%rax),%edx
call   1100 <connect@plt>
cmp    $0xffffffff,%eax
jne    13d3 <main+0x1c3>
mov    -0x14(%rbp),%edi
call   10c0 <close@plt>
lea    0xc74(%rip),%rdi
call   10e0 <perror@plt>
jmp    13d8 <main+0x1c8>
jmp    13ef <main+0x1df>
mov    -0xb0(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0xb0(%rbp)
jmp    1347 <main+0x137>
cmpq   $0x0,-0xb0(%rbp)
jne    142a <main+0x21a>
mov    0x2bc4(%rip),%rax
mov    (%rax),%edi
lea    0xc40(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0xcc(%rbp)
jmp    1588 <main+0x378>
mov    -0xb0(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x110(%rbp)
mov    -0xb0(%rbp),%rax
mov    (%rax),%rdi
call   1050 <get_in_addr@plt>
mov    -0x110(%rbp),%edi
mov    -0x100(%rbp),%rdx
mov    %eax,%esi
mov    -0x108(%rbp),%rax
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0x100(%rbp),%rsi
lea    0xbf4(%rip),%rdi
call   1090 <printf@plt>
mov    -0xa8(%rbp),%rdi
call   1120 <freeaddrinfo@plt>
mov    0xc24(%rip),%rax
mov    %rax,-0xf0(%rbp)
mov    0xc1e(%rip),%rax
mov    %rax,-0xe8(%rbp)
mov    0xc18(%rip),%rax
mov    %rax,-0xe0(%rbp)
mov    0xc13(%rip),%al
mov    %al,-0xd8(%rbp)
lea    -0xf0(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,-0xf4(%rbp)
mov    -0x14(%rbp),%edi
lea    -0xf0(%rbp),%rsi
mov    -0xf4(%rbp),%edx
xor    %ecx,%ecx
call   1080 <send@plt>
cmp    $0x0,%rax
jge    1521 <main+0x311>
lea    0xb8d(%rip),%rdi
call   10e0 <perror@plt>
mov    -0x14(%rbp),%edi
mov    0x2aec(%rip),%rax
mov    (%rax),%esi
call   1060 <shutdown@plt>
mov    -0x14(%rbp),%edi
call   10c0 <close@plt>
mov    0x2a9e(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0x63,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    1556 <main+0x346>
lea    0xb46(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
lea    -0x80(%rbp),%rsi
lea    0xb28(%rip),%rdi
call   1090 <printf@plt>
mov    -0x14(%rbp),%edi
call   10c0 <close@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xcc(%rbp)
mov    -0xc0(%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    $0xc8,%rsp
mov    %rsp,%r13
mov    0x2db2(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%r12
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
cmp    $0x2,%edi
jne    140f <main+0x1ff>
mov    %rsi,%rbx
lea    -0x80(%rbp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10b0 <memset@plt>
mov    0x2d70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x78(%rbp)
mov    0x2d4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    0x8(%rbx),%rdi
lea    0xd94(%rip),%rsi
lea    -0x38(%rbp),%rcx
mov    %r15,%rdx
call   1110 <getaddrinfo@plt>
test   %eax,%eax
je     12c1 <main+0xb1>
mov    0x2d2d(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   10a0 <gai_strerror@plt>
lea    0xd72(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x1,%ebx
jmp    13fb <main+0x1eb>
mov    %r13,-0x30(%rbp)
mov    -0x38(%rbp),%r13
test   %r13,%r13
je     1322 <main+0x112>
lea    0xd59(%rip),%rbx
mov    0x14(%r13),%esi
mov    0x8(%r13),%edi
mov    0x10(%r13),%edx
call   1130 <socket@plt>
mov    %rbx,%rdi
cmp    $0xffffffff,%eax
je     1314 <main+0x104>
mov    %eax,%r15d
mov    0x0(%r13),%rsi
mov    0xc(%r13),%edx
mov    %eax,%edi
call   1100 <connect@plt>
cmp    $0xffffffff,%eax
jne    1347 <main+0x137>
mov    %r15d,%edi
call   10c0 <close@plt>
lea    0xd29(%rip),%rdi
call   10e0 <perror@plt>
mov    0x18(%r13),%r13
test   %r13,%r13
jne    12d5 <main+0xc5>
mov    0x2c9f(%rip),%rax
mov    (%rax),%edi
lea    0xd1b(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x2,%ebx
mov    -0x30(%rbp),%r13
jmp    13fb <main+0x1eb>
mov    0x8(%r13),%ebx
mov    0x0(%r13),%rdi
call   1050 <get_in_addr@plt>
mov    %ebx,%edi
mov    %eax,%esi
mov    %r12,%rdx
mov    %r14d,%ecx
call   1030 <inet_ntop@plt>
lea    0xcfe(%rip),%rdi
mov    %r12,%rsi
call   1090 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1120 <freeaddrinfo@plt>
movups 0xd37(%rip),%xmm0
movups %xmm0,-0x57(%rbp)
movaps 0xd23(%rip),%xmm0
movaps %xmm0,-0x60(%rbp)
lea    -0x60(%rbp),%rbx
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
test   %rax,%rax
js     1430 <main+0x220>
lea    -0xf0(%rbp),%rsi
xor    %ebx,%ebx
mov    %r15d,%edi
mov    $0x63,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
cmp    $0xffffffff,%eax
mov    -0x30(%rbp),%r13
je     1463 <main+0x253>
cltq
movb   $0x0,-0xf0(%rbp,%rax,1)
lea    0xcab(%rip),%rdi
lea    -0xf0(%rbp),%rsi
call   1090 <printf@plt>
mov    %r15d,%edi
call   10c0 <close@plt>
mov    %r13,%rsp
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bb2(%rip),%rax
mov    (%rax),%edi
lea    0xbe1(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    0xc4b(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2bad(%rip),%rax
mov    (%rax),%esi
mov    %r15d,%edi
call   1060 <shutdown@plt>
mov    %r15d,%edi
call   10c0 <close@plt>
mov    0x2b5c(%rip),%rax
mov    (%rax),%edi
call   10f0 <exit@plt>
lea    0xc23(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i64, i32, i32, i32, i32, %struct.addrinfo* }
%struct.sockaddr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@stderr = global i32 0
@.str = [24 x i8] c"usage: client hostname\0A\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [5 x i8] c"8888\00"
@.str.2 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.3 = [15 x i8] c"client: socket\00"
@.str.4 = [16 x i8] c"client: connect\00"
@.str.5 = [27 x i8] c"client: failed to connect\0A\00"
@.str.6 = [26 x i8] c"client: connecting to %s\0A\00"
@__const.main.buff = [25 x i8] c"i am epic and i know it\0A\00"
@.str.7 = [11 x i8] c"SEND error\00"
@SHUT_RDWR = global i32 0
@EXIT_FAILURE = global i32 0
@.str.8 = [5 x i8] c"recv\00"
@.str.9 = [23 x i8] c"client: received '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [100 x i8]
%9 = alloca %struct.addrinfo
%10 = alloca %struct.addrinfo*
%11 = alloca %struct.addrinfo*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32
%16 = alloca [25 x i8]
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* @INET6_ADDRSTRLEN
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %13
%21 = alloca i8, i64 %19
store i64 %19, i64* %14
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 2
br i1 %23, label %24, label %28
24: ; preds = %2
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %2
%29 = call i32 @memset(%struct.addrinfo* %9, i32 0, i32 32)
%30 = load i32, i32* @AF_UNSPEC
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i32 0, i32 1
store i32 %30, i32* %31
%32 = load i32, i32* @SOCK_STREAM
%33 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i32 0, i32 4
store i32 %32, i32* %33
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @getaddrinfo(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %struct.addrinfo* %9, %struct.addrinfo** %10)
store i32 %37, i32* %12
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %28
%40 = load i32, i32* @stderr
%41 = load i32, i32* %12
%42 = call i8* @gai_strerror(i32 %41)
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %42)
store i32 1, i32* %3
store i32 1, i32* %15
br label %135
44: ; preds = %28
%45 = load %struct.addrinfo*, %struct.addrinfo** %10
store %struct.addrinfo* %45, %struct.addrinfo** %11
br label %46
46: ; preds = %78, %44
%47 = load %struct.addrinfo*, %struct.addrinfo** %11
%48 = icmp ne %struct.addrinfo* %47, null
br i1 %48, label %49, label %82
49: ; preds = %46
%50 = load %struct.addrinfo*, %struct.addrinfo** %11
%51 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %50, i32 0, i32 1
%52 = load i32, i32* %51
%53 = load %struct.addrinfo*, %struct.addrinfo** %11
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i32 0, i32 4
%55 = load i32, i32* %54
%56 = load %struct.addrinfo*, %struct.addrinfo** %11
%57 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %56, i32 0, i32 3
%58 = load i32, i32* %57
%59 = call i32 @socket(i32 %52, i32 %55, i32 %58)
store i32 %59, i32* %6
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %63
61: ; preds = %49
%62 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %78
63: ; preds = %49
%64 = load i32, i32* %6
%65 = load %struct.addrinfo*, %struct.addrinfo** %11
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %65, i32 0, i32 0
%67 = load i64, i64* %66
%68 = load %struct.addrinfo*, %struct.addrinfo** %11
%69 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %68, i32 0, i32 2
%70 = load i32, i32* %69
%71 = call i32 @connect(i32 %64, i64 %67, i32 %70)
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %77
73: ; preds = %63
%74 = load i32, i32* %6
%75 = call i32 @close(i32 %74)
%76 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %78
77: ; preds = %63
br label %82
78: ; preds = %73, %61
%79 = load %struct.addrinfo*, %struct.addrinfo** %11
%80 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %79, i32 0, i32 5
%81 = load %struct.addrinfo*, %struct.addrinfo** %80
store %struct.addrinfo* %81, %struct.addrinfo** %11
br label %46
82: ; preds = %77, %46
%83 = load %struct.addrinfo*, %struct.addrinfo** %11
%84 = icmp eq %struct.addrinfo* %83, null
br i1 %84, label %85, label %88
85: ; preds = %82
%86 = load i32, i32* @stderr
%87 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
store i32 2, i32* %3
store i32 1, i32* %15
br label %135
88: ; preds = %82
%89 = load %struct.addrinfo*, %struct.addrinfo** %11
%90 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %89, i32 0, i32 1
%91 = load i32, i32* %90
%92 = load %struct.addrinfo*, %struct.addrinfo** %11
%93 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %92, i32 0, i32 0
%94 = load i64, i64* %93
%95 = inttoptr i64 %94 to %struct.sockaddr*
%96 = call i32 @get_in_addr(%struct.sockaddr* %95)
%97 = trunc i64 %19 to i32
%98 = call i32 @inet_ntop(i32 %91, i32 %96, i8* %21, i32 %97)
%99 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %21)
%100 = load %struct.addrinfo*, %struct.addrinfo** %10
%101 = call i32 @freeaddrinfo(%struct.addrinfo* %100)
%102 = bitcast [25 x i8]* %16 to i8*
%103 = getelementptr inbounds [25 x i8], [25 x i8]* %16, i64 0, i64 0
%104 = call i32 @strlen(i8* %103)
store i32 %104, i32* %17
%105 = load i32, i32* %6
%106 = getelementptr inbounds [25 x i8], [25 x i8]* %16, i64 0, i64 0
%107 = load i32, i32* %17
%108 = call i64 @send(i32 %105, i8* %106, i32 %107, i32 0)
%109 = icmp slt i64 %108, 0
br i1 %109, label %110, label %119
110: ; preds = %88
%111 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%112 = load i32, i32* %6
%113 = load i32, i32* @SHUT_RDWR
%114 = call i32 @shutdown(i32 %112, i32 %113)
%115 = load i32, i32* %6
%116 = call i32 @close(i32 %115)
%117 = load i32, i32* @EXIT_FAILURE
%118 = call i32 @exit(i32 %117)
unreachable
119: ; preds = %88
%120 = load i32, i32* %6
%121 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%122 = call i32 @recv(i32 %120, i8* %121, i32 99, i32 0)
store i32 %122, i32* %7
%123 = icmp eq i32 %122, -1
br i1 %123, label %124, label %127
124: ; preds = %119
%125 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%126 = call i32 @exit(i32 1)
unreachable
127: ; preds = %119
%128 = load i32, i32* %7
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %129
store i8 0, i8* %130
%131 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%132 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8* %131)
%133 = load i32, i32* %6
%134 = call i32 @close(i32 %133)
store i32 0, i32* %3
store i32 1, i32* %15
br label %135
135: ; preds = %127, %85, %39
%136 = load i8*, i8** %13
%137 = load i32, i32* %3
ret i32 %137
}

LLVM IR (-O2):
%struct.addrinfo = type { i64, i32, i32, i32, i32, %struct.addrinfo* }
%struct.sockaddr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@stderr = global i32 0
@.str = [24 x i8] c"usage: client hostname\0A\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [5 x i8] c"8888\00"
@.str.2 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.3 = [15 x i8] c"client: socket\00"
@.str.4 = [16 x i8] c"client: connect\00"
@.str.5 = [27 x i8] c"client: failed to connect\0A\00"
@.str.6 = [26 x i8] c"client: connecting to %s\0A\00"
@__const.main.buff = [25 x i8] c"i am epic and i know it\0A\00"
@.str.7 = [11 x i8] c"SEND error\00"
@SHUT_RDWR = global i32 0
@EXIT_FAILURE = global i32 0
@.str.8 = [5 x i8] c"recv\00"
@.str.9 = [23 x i8] c"client: received '%s'\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = alloca %struct.addrinfo
%5 = alloca %struct.addrinfo*
%6 = alloca [25 x i8]
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = bitcast %struct.addrinfo* %4 to i8*
%9 = bitcast %struct.addrinfo** %5 to i8*
%10 = load i32, i32* @INET6_ADDRSTRLEN
%11 = zext i32 %10 to i64
%12 = tail call i8* @llvm.stacksave()
%13 = alloca i8, i64 %11
%14 = icmp eq i32 %0, 2
br i1 %14, label %19, label %15
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = call i32 @memset(%struct.addrinfo* %4, i32 0, i32 32)
%21 = load i32, i32* @AF_UNSPEC
%22 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 1
store i32 %21, i32* %22
%23 = load i32, i32* @SOCK_STREAM
%24 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 4
store i32 %23, i32* %24
%25 = getelementptr inbounds i8*, i8** %1, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @getaddrinfo(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %struct.addrinfo* %4, %struct.addrinfo** %5)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %19
%30 = load %struct.addrinfo*, %struct.addrinfo** %5
%31 = icmp eq %struct.addrinfo* %30, null
br i1 %31, label %61, label %36
32: ; preds = %19
%33 = load i32, i32* @stderr
%34 = call i8* @gai_strerror(i32 %27)
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* %34)
br label %97
36: ; preds = %29, %55
%37 = phi %struct.addrinfo* [ %59, %55 ], [ %30, %29 ]
%38 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 1
%39 = load i32, i32* %38
%40 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 4
%41 = load i32, i32* %40
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 3
%43 = load i32, i32* %42
%44 = call i32 @socket(i32 %39, i32 %41, i32 %43)
%45 = icmp eq i32 %44, -1
br i1 %45, label %55, label %46
46: ; preds = %36
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 0
%48 = load i64, i64* %47
%49 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 2
%50 = load i32, i32* %49
%51 = call i32 @connect(i32 %44, i64 %48, i32 %50)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %64
53: ; preds = %46
%54 = call i32 @close(i32 %44)
br label %55
55: ; preds = %36, %53
%56 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), %53 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), %36 ]
%57 = call i32 @perror(i8* %56)
%58 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 5
%59 = load %struct.addrinfo*, %struct.addrinfo** %58
%60 = icmp eq %struct.addrinfo* %59, null
br i1 %60, label %61, label %36
61: ; preds = %55, %29
%62 = load i32, i32* @stderr
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
br label %97
64: ; preds = %46
%65 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 1
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %37, i64 0, i32 0
%67 = load i32, i32* %65
%68 = load i64, i64* %66
%69 = inttoptr i64 %68 to %struct.sockaddr*
%70 = call i32 @get_in_addr(%struct.sockaddr* %69)
%71 = call i32 @inet_ntop(i32 %67, i32 %70, i8* %13, i32 %10)
%72 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i8* %13)
%73 = load %struct.addrinfo*, %struct.addrinfo** %5
%74 = call i32 @freeaddrinfo(%struct.addrinfo* %73)
%75 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 0
%76 = call i32 @strlen(i8* %75)
%77 = call i64 @send(i32 %44, i8* %75, i32 %76, i32 0)
%78 = icmp slt i64 %77, 0
br i1 %78, label %79, label %86
79: ; preds = %64
%80 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%81 = load i32, i32* @SHUT_RDWR
%82 = call i32 @shutdown(i32 %44, i32 %81)
%83 = call i32 @close(i32 %44)
%84 = load i32, i32* @EXIT_FAILURE
%85 = call i32 @exit(i32 %84)
unreachable
86: ; preds = %64
%87 = call i32 @recv(i32 %44, i8* %7, i32 99, i32 0)
%88 = icmp eq i32 %87, -1
br i1 %88, label %89, label %92
89: ; preds = %86
%90 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%91 = call i32 @exit(i32 1)
unreachable
92: ; preds = %86
%93 = sext i32 %87 to i64
%94 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %93
store i8 0, i8* %94
%95 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8* %7)
%96 = call i32 @close(i32 %44)
br label %97
97: ; preds = %92, %61, %32
%98 = phi i32 [ 1, %32 ], [ 2, %61 ], [ 0, %92 ]
ret i32 %98
}