#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 addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ msgsum;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int gai_strerror(int);
int getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, ...);
int send(int, unsigned int *, int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main() {
  int i;
  struct addrinfo host_info;
  struct addrinfo *host_info_list;
  memset(&host_info, 0, sizeof host_info);
  host_info.ai_family = AF_UNSPEC;
  host_info.ai_socktype = SOCK_STREAM;
  int status = getaddrinfo("vortex.labs.overthewire.org", "5842", &host_info,
                           &host_info_list);
  if (status != 0)
    printf("getaddrinfo error %i", gai_strerror(status));
  int socketfd;
  socketfd = socket(host_info_list->ai_family, host_info_list->ai_socktype,
                    host_info_list->ai_protocol);
  if (socketfd == -1)
    printf("socket error ");
  status =
      connect(socketfd, host_info_list->ai_addr, host_info_list->ai_addrlen);
  if (status == -1)
    printf("connect error\n");
  int n = 4;
  unsigned int incoming_data_buffer[n];
  ssize_t bytes_recieved;
  for (i = 0; i < n; i++) {
    bytes_recieved =
        recv(socketfd, incoming_data_buffer + i, sizeof(unsigned int), 0);
    if (bytes_recieved == 0)
      printf("host shut down.\n");
    if (bytes_recieved == -1)
      printf("recieve error!\n");
  }
  printf("Recieved integers");
  unsigned int sum = 0;
  for (i = 0; i < n; i++) {
    printf("%u\n", incoming_data_buffer[i]);
    sum += incoming_data_buffer[i];
  }
  printf("Sum: %u\n\n", sum);
  unsigned int *msgsum = &sum;
  int len = sizeof(msgsum);
  ssize_t bytes_sent;
  bytes_sent = send(socketfd, msgsum, len, 0);
  char incoming_data_buffer2[1000];
  bytes_recieved = recv(socketfd, incoming_data_buffer2, 1000, 0);
  if (bytes_recieved == 0)
    printf("host shut down.\n");
  if (bytes_recieved == -1)
    printf("recieve error!\n");
  printf(incoming_data_buffer2);
  printf("\n");
  freeaddrinfo(host_info_list);
  close(socketfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1070 <memset@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e03(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
lea    0xe1f(%rip),%rdi
lea    0xe34(%rip),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   10a0 <getaddrinfo@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     121a <main+0x7a>
mov    -0x2c(%rbp),%edi
call   1060 <gai_strerror@plt>
mov    %eax,%esi
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x28(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%edx
call   10c0 <socket@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    124f <main+0xaf>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x30(%rbp),%edi
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
call   1090 <connect@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    127f <main+0xdf>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x4,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x458(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    132c <main+0x18c>
mov    -0x458(%rbp),%rsi
mov    -0x30(%rbp),%edi
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
mov    $0x0,%al
call   1030 <recv@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
jne    1301 <main+0x161>
lea    0xd59(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0xffffffff,-0x4c(%rbp)
jne    1319 <main+0x179>
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    131e <main+0x17e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    12b7 <main+0x117>
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    1392 <main+0x1f2>
mov    -0x458(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd1d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x458(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x50(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1348 <main+0x1a8>
mov    -0x50(%rbp),%esi
lea    0xcee(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
movl   $0x8,-0x5c(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    -0x5c(%rbp),%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    %eax,-0x60(%rbp)
mov    -0x30(%rbp),%edi
lea    -0x450(%rbp),%rsi
mov    $0x3e8,%edx
xor    %ecx,%ecx
mov    $0x0,%al
call   1030 <recv@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
jne    13f9 <main+0x259>
lea    0xc61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0xffffffff,-0x4c(%rbp)
jne    1411 <main+0x271>
lea    0xc5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x450(%rbp),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xc6c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%rdi
call   10b0 <freeaddrinfo@plt>
mov    -0x30(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x40(%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    $0x408,%rsp
lea    -0x48(%rbp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1090 <memset@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2dde(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
lea    0xdfa(%rip),%rdi
lea    0xe0f(%rip),%rsi
lea    -0x30(%rbp),%rcx
mov    %rbx,%rdx
call   10c0 <getaddrinfo@plt>
test   %eax,%eax
je     1234 <main+0x74>
mov    %eax,%edi
call   1080 <gai_strerror@plt>
lea    0xdf6(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    -0x30(%rbp),%rax
mov    0x10(%rax),%edi
mov    0x8(%rax),%edx
mov    0xc(%rax),%esi
call   10e0 <socket@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
jne    125c <main+0x9c>
lea    0xde1(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %r14d,%edi
call   10b0 <connect@plt>
cmp    $0xffffffff,%eax
jne    127e <main+0xbe>
lea    0xe0a(%rip),%rdi
call   1050 <puts@plt>
mov    %rsp,%r13
mov    %rsp,%r15
add    $0xfffffffffffffff0,%r15
mov    %r15,%rsp
mov    $0x4,%edx
mov    %r14d,%edi
mov    %r15,%rsi
xor    %ecx,%ecx
xor    %eax,%eax
call   1030 <recv@plt>
test   %eax,%eax
je     12b1 <main+0xf1>
cmp    $0xffffffff,%eax
jne    12bd <main+0xfd>
lea    0xdb5(%rip),%rdi
jmp    12b8 <main+0xf8>
lea    0xdbb(%rip),%rdi
call   1050 <puts@plt>
lea    0x4(%r15),%rsi
mov    $0x4,%edx
mov    %r14d,%edi
xor    %ecx,%ecx
xor    %eax,%eax
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
je     12e4 <main+0x124>
test   %eax,%eax
jne    12f0 <main+0x130>
lea    0xd91(%rip),%rdi
jmp    12eb <main+0x12b>
lea    0xd79(%rip),%rdi
call   1050 <puts@plt>
lea    0x8(%r15),%rsi
mov    $0x4,%edx
mov    %r14d,%edi
xor    %ecx,%ecx
xor    %eax,%eax
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
je     1317 <main+0x157>
test   %eax,%eax
jne    1323 <main+0x163>
lea    0xd5e(%rip),%rdi
jmp    131e <main+0x15e>
lea    0xd46(%rip),%rdi
call   1050 <puts@plt>
lea    0xc(%r15),%rsi
mov    $0x4,%edx
mov    %r14d,%edi
xor    %ecx,%ecx
xor    %eax,%eax
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
je     134a <main+0x18a>
test   %eax,%eax
jne    1356 <main+0x196>
lea    0xd2b(%rip),%rdi
jmp    1351 <main+0x191>
lea    0xd13(%rip),%rdi
call   1050 <puts@plt>
lea    0xce7(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%r15),%esi
lea    0xce8(%rip),%r12
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%r15),%ebx
mov    0x4(%r15),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    0x4(%r15),%ebx
mov    0x8(%r15),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    0x8(%r15),%ebx
mov    0xc(%r15),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    0xc(%r15),%ebx
mov    %ebx,-0x34(%rbp)
lea    0xc9f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    -0x34(%rbp),%rsi
mov    %r14d,%edi
mov    $0x8,%edx
xor    %ecx,%ecx
call   1060 <send@plt>
lea    -0x430(%rbp),%rsi
mov    %r14d,%edi
mov    $0x3e8,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1030 <recv@plt>
test   %eax,%eax
je     1401 <main+0x241>
cmp    $0xffffffff,%eax
jne    140d <main+0x24d>
lea    0xc65(%rip),%rdi
jmp    1408 <main+0x248>
lea    0xc6b(%rip),%rdi
call   1050 <puts@plt>
lea    -0x430(%rbp),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    -0x30(%rbp),%rdi
call   10d0 <freeaddrinfo@plt>
mov    %r14d,%edi
call   10a0 <close@plt>
mov    %r13,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i32, i32 }
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str = [28 x i8] c"vortex.labs.overthewire.org\00"
@.str.1 = [5 x i8] c"5842\00"
@.str.2 = [21 x i8] c"getaddrinfo error %i\00"
@.str.3 = [14 x i8] c"socket error \00"
@.str.4 = [15 x i8] c"connect error\0A\00"
@.str.5 = [17 x i8] c"host shut down.\0A\00"
@.str.6 = [16 x i8] c"recieve error!\0A\00"
@.str.7 = [18 x i8] c"Recieved integers\00"
@.str.8 = [4 x i8] c"%u\0A\00"
@.str.9 = [10 x i8] c"Sum: %u\0A\0A\00"
@.str.10 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca [1000 x i8]
store i32 0, i32* %1
%16 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 20)
%17 = load i32, i32* @AF_UNSPEC
%18 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i32 0, i32 4
store i32 %17, i32* %18
%19 = load i32, i32* @SOCK_STREAM
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i32 0, i32 3
store i32 %19, i32* %20
%21 = call i32 @getaddrinfo(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %struct.addrinfo* %3, %struct.addrinfo** %4)
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %0
%25 = load i32, i32* %5
%26 = call i32 @gai_strerror(i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %24, %0
%29 = load %struct.addrinfo*, %struct.addrinfo** %4
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %29, i32 0, i32 4
%31 = load i32, i32* %30
%32 = load %struct.addrinfo*, %struct.addrinfo** %4
%33 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i32 0, i32 3
%34 = load i32, i32* %33
%35 = load %struct.addrinfo*, %struct.addrinfo** %4
%36 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %35, i32 0, i32 2
%37 = load i32, i32* %36
%38 = call i32 @socket(i32 %31, i32 %34, i32 %37)
store i32 %38, i32* %6
%39 = load i32, i32* %6
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %43
41: ; preds = %28
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %41, %28
%44 = load i32, i32* %6
%45 = load %struct.addrinfo*, %struct.addrinfo** %4
%46 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %45, i32 0, i32 1
%47 = load i32, i32* %46
%48 = load %struct.addrinfo*, %struct.addrinfo** %4
%49 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %48, i32 0, i32 0
%50 = load i32, i32* %49
%51 = call i32 @connect(i32 %44, i32 %47, i32 %50)
store i32 %51, i32* %5
%52 = load i32, i32* %5
%53 = icmp eq i32 %52, -1
br i1 %53, label %54, label %56
54: ; preds = %43
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %56
56: ; preds = %54, %43
store i32 4, i32* %7
%57 = load i32, i32* %7
%58 = zext i32 %57 to i64
%59 = call i8* @llvm.stacksave()
store i8* %59, i8** %8
%60 = alloca i32, i64 %58
store i64 %58, i64* %9
store i32 0, i32* %2
br label %61
61: ; preds = %81, %56
%62 = load i32, i32* %2
%63 = load i32, i32* %7
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %84
65: ; preds = %61
%66 = load i32, i32* %6
%67 = load i32, i32* %2
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* %60, i64 %68
%70 = call i32 (i32, ...) @recv(i32 %66, i32* %69, i64 4, i32 0)
store i32 %70, i32* %10
%71 = load i32, i32* %10
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %65
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %75
75: ; preds = %73, %65
%76 = load i32, i32* %10
%77 = icmp eq i32 %76, -1
br i1 %77, label %78, label %80
78: ; preds = %75
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
br label %80
80: ; preds = %78, %75
br label %81
81: ; preds = %80
%82 = load i32, i32* %2
%83 = add nsw i32 %82, 1
store i32 %83, i32* %2
br label %61
84: ; preds = %61
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %11
store i32 0, i32* %2
br label %86
86: ; preds = %102, %84
%87 = load i32, i32* %2
%88 = load i32, i32* %7
%89 = icmp slt i32 %87, %88
br i1 %89, label %90, label %105
90: ; preds = %86
%91 = load i32, i32* %2
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i32, i32* %60, i64 %92
%94 = load i32, i32* %93
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %94)
%96 = load i32, i32* %2
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i32, i32* %60, i64 %97
%99 = load i32, i32* %98
%100 = load i32, i32* %11
%101 = add i32 %100, %99
store i32 %101, i32* %11
br label %102
102: ; preds = %90
%103 = load i32, i32* %2
%104 = add nsw i32 %103, 1
store i32 %104, i32* %2
br label %86
105: ; preds = %86
%106 = load i32, i32* %11
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %106)
store i32* %11, i32** %12
store i32 8, i32* %13
%108 = load i32, i32* %6
%109 = load i32*, i32** %12
%110 = load i32, i32* %13
%111 = call i32 @send(i32 %108, i32* %109, i32 %110, i32 0)
store i32 %111, i32* %14
%112 = load i32, i32* %6
%113 = getelementptr inbounds [1000 x i8], [1000 x i8]* %15, i64 0, i64 0
%114 = call i32 (i32, ...) @recv(i32 %112, i8* %113, i32 1000, i32 0)
store i32 %114, i32* %10
%115 = load i32, i32* %10
%116 = icmp eq i32 %115, 0
br i1 %116, label %117, label %119
117: ; preds = %105
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %119
119: ; preds = %117, %105
%120 = load i32, i32* %10
%121 = icmp eq i32 %120, -1
br i1 %121, label %122, label %124
122: ; preds = %119
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
br label %124
124: ; preds = %122, %119
%125 = getelementptr inbounds [1000 x i8], [1000 x i8]* %15, i64 0, i64 0
%126 = call i32 (i8*, ...) @printf(i8* %125)
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%128 = load %struct.addrinfo*, %struct.addrinfo** %4
%129 = call i32 @freeaddrinfo(%struct.addrinfo* %128)
%130 = load i32, i32* %6
%131 = call i32 @close(i32 %130)
store i32 0, i32* %1
%132 = load i8*, i8** %8
%133 = load i32, i32* %1
ret i32 %133
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i32 }
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str = [28 x i8] c"vortex.labs.overthewire.org\00"
@.str.1 = [5 x i8] c"5842\00"
@.str.2 = [21 x i8] c"getaddrinfo error %i\00"
@.str.3 = [14 x i8] c"socket error \00"
@.str.7 = [18 x i8] c"Recieved integers\00"
@.str.8 = [4 x i8] c"%u\0A\00"
@.str.9 = [10 x i8] c"Sum: %u\0A\0A\00"
@str.12 = [15 x i8] c"recieve error!\00"
@str.13 = [16 x i8] c"host shut down.\00"
@str.14 = [14 x i8] c"connect error\00"
define i32 @main() {
%1 = alloca %struct.addrinfo
%2 = alloca %struct.addrinfo*
%3 = alloca i32
%4 = alloca [1000 x i8]
%5 = bitcast %struct.addrinfo* %1 to i8*
%6 = bitcast %struct.addrinfo** %2 to i8*
%7 = call i32 @memset(%struct.addrinfo* %1, i32 0, i32 20)
%8 = load i32, i32* @AF_UNSPEC
%9 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %1, i64 0, i32 4
store i32 %8, i32* %9
%10 = load i32, i32* @SOCK_STREAM
%11 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %1, i64 0, i32 3
store i32 %10, i32* %11
%12 = call i32 @getaddrinfo(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %struct.addrinfo* %1, %struct.addrinfo** %2)
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %0
%15 = call i32 @gai_strerror(i32 %12)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %14, %0
%18 = load %struct.addrinfo*, %struct.addrinfo** %2
%19 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i64 0, i32 4
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i64 0, i32 3
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i64 0, i32 2
%24 = load i32, i32* %23
%25 = call i32 @socket(i32 %20, i32 %22, i32 %24)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %29
27: ; preds = %17
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %27, %17
%30 = load %struct.addrinfo*, %struct.addrinfo** %2
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %30, i64 0, i32 1
%32 = load i32, i32* %31
%33 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %30, i64 0, i32 0
%34 = load i32, i32* %33
%35 = call i32 @connect(i32 %25, i32 %32, i32 %34)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %39
37: ; preds = %29
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.14, i64 0, i64 0))
br label %39
39: ; preds = %37, %29
%40 = call i8* @llvm.stacksave()
%41 = alloca [4 x i32]
%42 = getelementptr inbounds [4 x i32], [4 x i32]* %41, i64 0, i64 0
%43 = call i32 (i32, ...) @recv(i32 %25, i32* %42, i64 4, i32 0)
switch i32 %43, label %48 [
i32 0, label %45
i32 -1, label %44
]
44: ; preds = %39
br label %45
45: ; preds = %39, %44
%46 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.12, i64 0, i64 0), %44 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.13, i64 0, i64 0), %39 ]
%47 = call i32 @puts(i8* dereferenceable(1) %46)
br label %48
48: ; preds = %45, %39
%49 = getelementptr inbounds [4 x i32], [4 x i32]* %41, i64 0, i64 1
%50 = call i32 (i32, ...) @recv(i32 %25, i32* %49, i64 4, i32 0)
switch i32 %50, label %55 [
i32 0, label %51
i32 -1, label %52
]
51: ; preds = %48
br label %52
52: ; preds = %48, %51
%53 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.13, i64 0, i64 0), %51 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.12, i64 0, i64 0), %48 ]
%54 = call i32 @puts(i8* dereferenceable(1) %53)
br label %55
55: ; preds = %52, %48
%56 = getelementptr inbounds [4 x i32], [4 x i32]* %41, i64 0, i64 2
%57 = call i32 (i32, ...) @recv(i32 %25, i32* %56, i64 4, i32 0)
switch i32 %57, label %62 [
i32 0, label %58
i32 -1, label %59
]
58: ; preds = %55
br label %59
59: ; preds = %55, %58
%60 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.13, i64 0, i64 0), %58 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.12, i64 0, i64 0), %55 ]
%61 = call i32 @puts(i8* dereferenceable(1) %60)
br label %62
62: ; preds = %59, %55
%63 = getelementptr inbounds [4 x i32], [4 x i32]* %41, i64 0, i64 3
%64 = call i32 (i32, ...) @recv(i32 %25, i32* %63, i64 4, i32 0)
switch i32 %64, label %69 [
i32 0, label %65
i32 -1, label %66
]
65: ; preds = %62
br label %66
66: ; preds = %62, %65
%67 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.13, i64 0, i64 0), %65 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.12, i64 0, i64 0), %62 ]
%68 = call i32 @puts(i8* dereferenceable(1) %67)
br label %69
69: ; preds = %66, %62
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%71 = bitcast i32* %3 to i8*
%72 = load i32, i32* %42
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %72)
%74 = load i32, i32* %42
%75 = load i32, i32* %49
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %75)
%77 = load i32, i32* %49
%78 = add i32 %74, %77
%79 = load i32, i32* %56
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %79)
%81 = load i32, i32* %56
%82 = add i32 %78, %81
%83 = load i32, i32* %63
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %83)
%85 = load i32, i32* %63
%86 = add i32 %82, %85
store i32 %86, i32* %3
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i32 %86)
%88 = call i32 @send(i32 %25, i32* %3, i32 8, i32 0)
%89 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%90 = call i32 (i32, ...) @recv(i32 %25, i8* %89, i32 1000, i32 0)
switch i32 %90, label %95 [
i32 0, label %92
i32 -1, label %91
]
91: ; preds = %69
br label %92
92: ; preds = %69, %91
%93 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.12, i64 0, i64 0), %91 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.13, i64 0, i64 0), %69 ]
%94 = call i32 @puts(i8* dereferenceable(1) %93)
br label %95
95: ; preds = %92, %69
%96 = call i32 (i8*, ...) @printf(i8* %89)
%97 = call i32 @putchar(i32 10)
%98 = load %struct.addrinfo*, %struct.addrinfo** %2
%99 = call i32 @freeaddrinfo(%struct.addrinfo* %98)
%100 = call i32 @close(i32 %25)
ret i32 0
}