#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_in {
  int dummy;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  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;
};
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int INET6_ADDRSTRLEN;
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 /*<<< orphan*/ read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int temp, count, rv;
  int sockfd = 0;
  int returnStatus = 0;
  char buff[256] = "";
  char buffer[256] = "";
  char stringtemp[256] = "";
  char s[INET6_ADDRSTRLEN];
  struct sockaddr_in simpleServer;
  struct hostent *server;
  struct addrinfo hints, *servinfo, *p;
  if (4 != argc) {
    fprintf(stderr, "Usage: %s <server> <port> <sign #>\n", argv[0]);
    exit(1);
  }
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  if ((rv = getaddrinfo(argv[1], argv[2], &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);
  temp = sprintf(stringtemp, "C%s", argv[3]);
  temp = write(sockfd, stringtemp, temp);
  read(sockfd, buffer, sizeof(buffer));
  printf("%s \n", buffer);
  close(sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movaps %xmm0,-0x3b0(%rbp)
movaps %xmm0,-0x40(%rbp)
movaps %xmm0,-0x50(%rbp)
movaps %xmm0,-0x60(%rbp)
movaps %xmm0,-0x70(%rbp)
movaps %xmm0,-0x80(%rbp)
movaps %xmm0,-0x90(%rbp)
movaps %xmm0,-0xa0(%rbp)
movaps %xmm0,-0xb0(%rbp)
movaps %xmm0,-0xc0(%rbp)
movaps %xmm0,-0xd0(%rbp)
movaps %xmm0,-0xe0(%rbp)
movaps %xmm0,-0xf0(%rbp)
movaps %xmm0,-0x100(%rbp)
movaps %xmm0,-0x110(%rbp)
movaps %xmm0,-0x120(%rbp)
movaps %xmm0,-0x130(%rbp)
movaps %xmm0,-0x140(%rbp)
movaps %xmm0,-0x150(%rbp)
movaps %xmm0,-0x160(%rbp)
movaps %xmm0,-0x170(%rbp)
movaps %xmm0,-0x180(%rbp)
movaps %xmm0,-0x190(%rbp)
movaps %xmm0,-0x1a0(%rbp)
movaps %xmm0,-0x1b0(%rbp)
movaps %xmm0,-0x1c0(%rbp)
movaps %xmm0,-0x1d0(%rbp)
movaps %xmm0,-0x1e0(%rbp)
movaps %xmm0,-0x1f0(%rbp)
movaps %xmm0,-0x200(%rbp)
movaps %xmm0,-0x210(%rbp)
movaps %xmm0,-0x220(%rbp)
movaps %xmm0,-0x230(%rbp)
movaps %xmm0,-0x240(%rbp)
movaps %xmm0,-0x250(%rbp)
movaps %xmm0,-0x260(%rbp)
movaps %xmm0,-0x270(%rbp)
movaps %xmm0,-0x280(%rbp)
movaps %xmm0,-0x290(%rbp)
movaps %xmm0,-0x2a0(%rbp)
movaps %xmm0,-0x2b0(%rbp)
movaps %xmm0,-0x2c0(%rbp)
movaps %xmm0,-0x2d0(%rbp)
movaps %xmm0,-0x2e0(%rbp)
movaps %xmm0,-0x2f0(%rbp)
movaps %xmm0,-0x300(%rbp)
movaps %xmm0,-0x310(%rbp)
movaps %xmm0,-0x320(%rbp)
movaps %xmm0,-0x330(%rbp)
mov    0x2c6f(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x398(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x338(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x390(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x340(%rbp)
mov    $0x4,%eax
cmp    -0x8(%rbp),%eax
je     13e4 <main+0x1e4>
mov    0x2c0d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xc2d(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    -0x370(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
mov    0x2be2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x368(%rbp)
mov    0x2bbb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x35c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    -0x370(%rbp),%rdx
lea    -0x378(%rbp),%rcx
call   1100 <getaddrinfo@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
je     1488 <main+0x288>
mov    0x2b85(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3b4(%rbp)
mov    -0x1c(%rbp),%edi
call   1070 <gai_strerror@plt>
mov    -0x3b4(%rbp),%edi
mov    %rax,%rdx
lea    0xbb9(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x384(%rbp)
jmp    1647 <main+0x447>
mov    -0x378(%rbp),%rax
mov    %rax,-0x380(%rbp)
cmpq   $0x0,-0x380(%rbp)
je     153e <main+0x33e>
mov    -0x380(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x380(%rbp),%rax
mov    0x14(%rax),%esi
mov    -0x380(%rbp),%rax
mov    0x10(%rax),%edx
call   1120 <socket@plt>
mov    %eax,-0x20(%rbp)
cmp    $0xffffffff,%eax
jne    14e4 <main+0x2e4>
lea    0xb5b(%rip),%rdi
call   10c0 <perror@plt>
jmp    1527 <main+0x327>
mov    -0x20(%rbp),%edi
mov    -0x380(%rbp),%rax
mov    (%rax),%rsi
mov    -0x380(%rbp),%rax
mov    0xc(%rax),%edx
call   10f0 <connect@plt>
cmp    $0xffffffff,%eax
jne    1522 <main+0x322>
mov    -0x20(%rbp),%edi
call   1090 <close@plt>
lea    0xb2c(%rip),%rdi
call   10c0 <perror@plt>
jmp    1527 <main+0x327>
jmp    153e <main+0x33e>
mov    -0x380(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x380(%rbp)
jmp    1496 <main+0x296>
cmpq   $0x0,-0x380(%rbp)
jne    1579 <main+0x379>
mov    0x2a7d(%rip),%rax
mov    (%rax),%edi
lea    0xaf8(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0x384(%rbp)
jmp    1647 <main+0x447>
mov    -0x380(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x3b8(%rbp)
mov    -0x380(%rbp),%rax
mov    (%rax),%rdi
call   1040 <get_in_addr@plt>
mov    -0x3b8(%rbp),%edi
mov    -0x390(%rbp),%rdx
mov    %eax,%esi
mov    -0x398(%rbp),%rax
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0x390(%rbp),%rsi
lea    0xaac(%rip),%rdi
call   1060 <printf@plt>
mov    -0x378(%rbp),%rdi
call   1110 <freeaddrinfo@plt>
lea    -0x330(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xa9f(%rip),%rsi
call   10d0 <sprintf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x330(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <write@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x230(%rbp),%rsi
mov    $0x100,%edx
call   10a0 <read@plt>
lea    -0x230(%rbp),%rsi
lea    0xa64(%rip),%rdi
call   1060 <printf@plt>
mov    -0x20(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x384(%rbp)
mov    -0x338(%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    $0x238,%rsp
mov    %rsi,%r14
mov    %rsp,%r12
xorps  %xmm0,%xmm0
movaps %xmm0,-0x170(%rbp)
movaps %xmm0,-0x180(%rbp)
movaps %xmm0,-0x190(%rbp)
movaps %xmm0,-0x1a0(%rbp)
movaps %xmm0,-0x1b0(%rbp)
movaps %xmm0,-0x1c0(%rbp)
movaps %xmm0,-0x1d0(%rbp)
movaps %xmm0,-0x1e0(%rbp)
movaps %xmm0,-0x1f0(%rbp)
movaps %xmm0,-0x200(%rbp)
movaps %xmm0,-0x210(%rbp)
movaps %xmm0,-0x220(%rbp)
movaps %xmm0,-0x230(%rbp)
movaps %xmm0,-0x240(%rbp)
movaps %xmm0,-0x250(%rbp)
movaps %xmm0,-0x260(%rbp)
movaps %xmm0,-0x70(%rbp)
movaps %xmm0,-0x80(%rbp)
movaps %xmm0,-0x90(%rbp)
movaps %xmm0,-0xa0(%rbp)
movaps %xmm0,-0xb0(%rbp)
movaps %xmm0,-0xc0(%rbp)
movaps %xmm0,-0xd0(%rbp)
movaps %xmm0,-0xe0(%rbp)
movaps %xmm0,-0xf0(%rbp)
movaps %xmm0,-0x100(%rbp)
movaps %xmm0,-0x110(%rbp)
movaps %xmm0,-0x120(%rbp)
movaps %xmm0,-0x130(%rbp)
movaps %xmm0,-0x140(%rbp)
movaps %xmm0,-0x150(%rbp)
movaps %xmm0,-0x160(%rbp)
mov    0x2cea(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%r13
lea    0xf(%r15),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
cmp    $0x4,%edi
jne    14a8 <main+0x2a8>
lea    -0x60(%rbp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1080 <memset@plt>
mov    0x2cab(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    0x2c87(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    0x8(%r14),%rdi
mov    0x10(%r14),%rsi
lea    -0x40(%rbp),%rcx
mov    %rbx,%rdx
call   1100 <getaddrinfo@plt>
test   %eax,%eax
je     138b <main+0x18b>
mov    0x2c6b(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1070 <gai_strerror@plt>
lea    0xcaf(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%eax
jmp    1496 <main+0x296>
mov    %r12,-0x38(%rbp)
mov    -0x40(%rbp),%rbx
test   %rbx,%rbx
je     13e4 <main+0x1e4>
mov    0x14(%rbx),%esi
mov    0x8(%rbx),%edi
mov    0x10(%rbx),%edx
call   1120 <socket@plt>
lea    0xc88(%rip),%rdi
cmp    $0xffffffff,%eax
je     13d6 <main+0x1d6>
mov    %eax,%r12d
mov    (%rbx),%rsi
mov    0xc(%rbx),%edx
mov    %eax,%edi
call   10f0 <connect@plt>
cmp    $0xffffffff,%eax
jne    1405 <main+0x205>
mov    %r12d,%edi
call   1090 <close@plt>
lea    0xc6e(%rip),%rdi
call   10c0 <perror@plt>
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
jne    1398 <main+0x198>
mov    0x2be5(%rip),%rax
mov    (%rax),%edi
lea    0xc60(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x2,%eax
jmp    1492 <main+0x292>
mov    0x8(%rbx),%eax
mov    %eax,-0x2c(%rbp)
mov    (%rbx),%rdi
call   1040 <get_in_addr@plt>
mov    -0x2c(%rbp),%edi
mov    %eax,%esi
mov    %r13,%rdx
mov    %r15d,%ecx
call   1030 <inet_ntop@plt>
lea    0xc45(%rip),%rdi
mov    %r13,%rsi
call   1060 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1110 <freeaddrinfo@plt>
mov    0x18(%r14),%rdx
lea    0xc43(%rip),%rsi
lea    -0x160(%rbp),%rbx
mov    %rbx,%rdi
call   10d0 <sprintf@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
lea    -0x260(%rbp),%rbx
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x100,%edx
call   10a0 <read@plt>
lea    0xc0d(%rip),%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
mov    %r12d,%edi
call   1090 <close@plt>
xor    %eax,%eax
mov    -0x38(%rbp),%r12
mov    %r12,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b21(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xb45(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

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

LLVM IR (-O2):
%struct.addrinfo = type { i64, i32, i32, i32, i32, %struct.addrinfo* }
%struct.hostent = type { i32 }
%struct.sockaddr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@stderr = global i32 0
@.str = [36 x i8] c"Usage: %s <server> <port> <sign #>\0A\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.2 = [15 x i8] c"client: socket\00"
@.str.3 = [16 x i8] c"client: connect\00"
@.str.4 = [27 x i8] c"client: failed to connect\0A\00"
@.str.5 = [26 x i8] c"client: connecting to %s\0A\00"
@.str.6 = [4 x i8] c"C%s\00"
@.str.7 = [5 x i8] c"%s \0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = alloca %struct.addrinfo
%6 = alloca %struct.addrinfo*
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%9 = load i32, i32* @INET6_ADDRSTRLEN
%10 = zext i32 %9 to i64
%11 = tail call i8* @llvm.stacksave()
%12 = alloca i8, i64 %10
%13 = bitcast %struct.addrinfo* %5 to i8*
%14 = bitcast %struct.addrinfo** %6 to i8*
%15 = icmp eq i32 %0, 4
br i1 %15, label %21, label %16
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %1
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = call i32 @memset(%struct.addrinfo* %5, i32 0, i32 32)
%23 = load i32, i32* @AF_UNSPEC
%24 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 1
store i32 %23, i32* %24
%25 = load i32, i32* @SOCK_STREAM
%26 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i64 0, i32 4
store i32 %25, i32* %26
%27 = getelementptr inbounds i8*, i8** %1, i64 1
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8*, i8** %1, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @getaddrinfo(i8* %28, i8* %30, %struct.addrinfo* %5, %struct.addrinfo** %6)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %21
%34 = load %struct.addrinfo*, %struct.addrinfo** %6
%35 = icmp eq %struct.addrinfo* %34, null
br i1 %35, label %65, label %40
36: ; preds = %21
%37 = load i32, i32* @stderr
%38 = call i8* @gai_strerror(i32 %31)
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %38)
br label %86
40: ; preds = %33, %59
%41 = phi %struct.addrinfo* [ %63, %59 ], [ %34, %33 ]
%42 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i64 0, i32 1
%43 = load i32, i32* %42
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i64 0, i32 4
%45 = load i32, i32* %44
%46 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i64 0, i32 3
%47 = load i32, i32* %46
%48 = call i32 @socket(i32 %43, i32 %45, i32 %47)
%49 = icmp eq i32 %48, -1
br i1 %49, label %59, label %50
50: ; preds = %40
%51 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i64 0, i32 0
%52 = load i64, i64* %51
%53 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i64 0, i32 2
%54 = load i32, i32* %53
%55 = call i32 @connect(i32 %48, i64 %52, i32 %54)
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %68
57: ; preds = %50
%58 = call i32 @close(i32 %48)
br label %59
59: ; preds = %40, %57
%60 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), %57 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), %40 ]
%61 = call i32 @perror(i8* %60)
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i64 0, i32 5
%63 = load %struct.addrinfo*, %struct.addrinfo** %62
%64 = icmp eq %struct.addrinfo* %63, null
br i1 %64, label %65, label %40
65: ; preds = %59, %33
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
br label %86
68: ; preds = %50
%69 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i64 0, i32 1
%70 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %41, i64 0, i32 0
%71 = load i32, i32* %69
%72 = load i64, i64* %70
%73 = inttoptr i64 %72 to %struct.sockaddr*
%74 = call i32 @get_in_addr(%struct.sockaddr* %73)
%75 = call i32 @inet_ntop(i32 %71, i32 %74, i8* %12, i32 %9)
%76 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %12)
%77 = load %struct.addrinfo*, %struct.addrinfo** %6
%78 = call i32 @freeaddrinfo(%struct.addrinfo* %77)
%79 = getelementptr inbounds i8*, i8** %1, i64 3
%80 = load i8*, i8** %79
%81 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %80)
%82 = call i32 @write(i32 %48, i8* %8, i32 %81)
%83 = call i32 @read(i32 %48, i8* %7, i32 256)
%84 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8* %7)
%85 = call i32 @close(i32 %48)
br label %86
86: ; preds = %68, %65, %36
%87 = phi i32 [ 1, %36 ], [ 2, %65 ], [ 0, %68 ]
ret i32 %87
}