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

/* Variables and functions */
scalar_t__ AF_INET;
int INET_ADDRSTRLEN;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ TCP_NODELAY;
int /*<<< orphan*/ close(int);
int connect(int, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
char *gai_strerror(int);
int getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int /*<<< orphan*/ inet_ntop(scalar_t__, void *, char *, int);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ receive_summarystats(int);
char *run_rx_test(int, int);
int /*<<< orphan*/ run_tx_test(int);
scalar_t__ send_ctrl_msg(int, unsigned char, int /*<<< orphan*/ *,
                         int /*<<< orphan*/);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, char *, int);
int socket(scalar_t__, int /*<<< orphan*/, int /*<<< orphan*/);
void c_run(char *hostname, char *port) {
  struct addrinfo hints, *res, *p;
  int status;
  char ipstr[INET_ADDRSTRLEN];
  int socketfd;
  int flag;
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_INET;
  hints.ai_socktype = SOCK_STREAM;
  if ((status = getaddrinfo(hostname, port, &hints, &res)) != 0) {
    printf("getaddrinfo: %s\n", gai_strerror(status));
    exit(1);
  }
  for (p = res; p != NULL; p = p->ai_next) {
    void *addr;
    if (p->ai_family == AF_INET) {
      struct sockaddr_in *ipv4 = (struct sockaddr_in *)p->ai_addr;
      addr = &(ipv4->sin_addr);
    } else {
      continue;
    }
    inet_ntop(p->ai_family, addr, ipstr, sizeof ipstr);
    printf("Will connect to: %s\n", ipstr);
    break;
  }
  socketfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
  if (socketfd < 0) {
    perror("Socket open failed: ");
  }
  int ret = setsockopt(socketfd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag,
                       sizeof(int));
  if (ret < 0) {
    printf("Cannot disable Nagle! Exit\n");
    exit(1);
  }
  if (connect(socketfd, p->ai_addr, p->ai_addrlen) == -1) {
    close(socketfd);
    perror("client: connect");
    return;
  }
  if (send_ctrl_msg(socketfd, 'O', NULL, 0)) {
    printf("Server is Ready for Download Test...\n");
    char *s = run_rx_test(socketfd, 1);
    if (s != NULL) {
      printf("\nDownlink Summary Stats:\n");
      printf("---------------------------------------------\n");
      printf("%s", s);
      printf("---------------------------------------------\n");
      free(s);
    }
  } else {
    printf("Internal Error! Will not run Download Test\n");
  }
  if (send_ctrl_msg(socketfd, 'U', NULL, 0)) {
    printf("Server is Ready for Upload Test...\n");
    run_tx_test(socketfd);
    receive_summarystats(socketfd);
  } else {
    printf("Internal Error! Will not run Upload Test\n");
  }
}


x86 assembly (clang, -O0):
<c_run>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2da6(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x98(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x90(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x60(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1090 <memset@plt>
mov    0x2d80(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    0x2d5a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   1110 <getaddrinfo@plt>
mov    %eax,-0x4c(%rbp)
cmp    $0x0,%eax
je     12b7 <c_run+0xb7>
mov    -0x4c(%rbp),%edi
call   1080 <gai_strerror@plt>
mov    %rax,%rsi
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     134a <c_run+0x14a>
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
mov    0x2d08(%rip),%rcx
cmp    (%rcx),%rax
jne    12fa <c_run+0xfa>
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0x70(%rbp)
jmp    12ff <c_run+0xff>
jmp    1339 <c_run+0x139>
mov    -0x90(%rbp),%rdx
mov    -0x98(%rbp),%rax
mov    -0x48(%rbp),%rcx
mov    (%rcx),%rdi
mov    -0x70(%rbp),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0x90(%rbp),%rsi
lea    0xce4(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    134a <c_run+0x14a>
mov    -0x48(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x48(%rbp)
jmp    12bf <c_run+0xbf>
mov    -0x48(%rbp),%rax
mov    (%rax),%rdi
mov    -0x48(%rbp),%rax
mov    0x1c(%rax),%esi
mov    -0x48(%rbp),%rax
mov    0x18(%rax),%edx
call   1120 <socket@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jge    137d <c_run+0x17d>
lea    0xcae(%rip),%rdi
call   10d0 <perror@plt>
mov    -0x64(%rbp),%edi
mov    0x2c51(%rip),%rax
mov    (%rax),%esi
mov    0x2c58(%rip),%rax
mov    (%rax),%edx
lea    -0x68(%rbp),%rcx
mov    $0x4,%r8d
call   1060 <setsockopt@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
jge    13c6 <c_run+0x1c6>
lea    0xc86(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x64(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%edx
call   1100 <connect@plt>
cmp    $0xffffffff,%eax
jne    1406 <c_run+0x206>
mov    -0x64(%rbp),%edi
call   10a0 <close@plt>
lea    0xc62(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x80(%rbp)
jmp    1506 <c_run+0x306>
mov    -0x64(%rbp),%edi
mov    $0x4f,%esi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10c0 <send_ctrl_msg@plt>
cmp    $0x0,%rax
je     14a3 <c_run+0x2a3>
lea    0xc3d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x64(%rbp),%edi
mov    $0x1,%esi
call   1050 <run_rx_test@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     149e <c_run+0x29e>
lea    0xc33(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xc3f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x88(%rbp),%rsi
lea    0xc59(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xc1c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x88(%rbp),%rdi
call   1040 <free@plt>
jmp    14b1 <c_run+0x2b1>
lea    0xc2f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x64(%rbp),%edi
mov    $0x55,%esi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   10c0 <send_ctrl_msg@plt>
cmp    $0x0,%rax
je     14f1 <c_run+0x2f1>
lea    0xc30(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x64(%rbp),%edi
call   10e0 <run_tx_test@plt>
mov    -0x64(%rbp),%edi
call   10b0 <receive_summarystats@plt>
jmp    14ff <c_run+0x2ff>
lea    0xc31(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x80(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_run>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%r15
mov    %rdi,%r12
mov    %rsp,-0x38(%rbp)
mov    0x2d8e(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r14
mov    %rax,-0x30(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
lea    -0x70(%rbp),%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   10a0 <memset@plt>
mov    0x2d7d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x70(%rbp)
mov    0x2d57(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
lea    -0x40(%rbp),%rcx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
call   1120 <getaddrinfo@plt>
test   %eax,%eax
jne    143b <c_run+0x22b>
mov    -0x40(%rbp),%rbx
test   %rbx,%rbx
je     12be <c_run+0xae>
mov    0x2d40(%rip),%rax
mov    (%rax),%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    %rdi,(%rbx)
je     12c2 <c_run+0xb2>
mov    0x20(%rbx),%rbx
test   %rbx,%rbx
jne    12b0 <c_run+0xa0>
xor    %ebx,%ebx
jmp    12e3 <c_run+0xd3>
mov    0x10(%rbx),%rsi
mov    %r14,%rdx
mov    -0x30(%rbp),%rcx
call   1030 <inet_ntop@plt>
lea    0xd38(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    (%rbx),%rdi
mov    0x1c(%rbx),%esi
mov    0x18(%rbx),%edx
call   1130 <socket@plt>
mov    %eax,%r12d
test   %eax,%eax
js     1414 <c_run+0x204>
mov    0x2cd5(%rip),%rax
mov    (%rax),%esi
mov    0x2cdc(%rip),%rax
mov    (%rax),%edx
lea    -0x44(%rbp),%rcx
mov    %r12d,%edi
mov    $0x4,%r8d
call   1070 <setsockopt@plt>
test   %eax,%eax
js     145d <c_run+0x24d>
mov    0x10(%rbx),%rsi
mov    0x8(%rbx),%edx
mov    %r12d,%edi
call   1110 <connect@plt>
cmp    $0xffffffff,%eax
je     1425 <c_run+0x215>
mov    %r12d,%edi
mov    $0x4f,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   10d0 <send_ctrl_msg@plt>
test   %rax,%rax
je     13b5 <c_run+0x1a5>
lea    0xd68(%rip),%rdi
call   1050 <puts@plt>
mov    %r12d,%edi
mov    $0x1,%esi
call   1060 <run_rx_test@plt>
test   %rax,%rax
je     13c1 <c_run+0x1b1>
mov    %rax,%r14
lea    0xd6c(%rip),%rdi
call   1050 <puts@plt>
lea    0xd79(%rip),%r15
mov    %r15,%rdi
call   1050 <puts@plt>
lea    0xcb2(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r15,%rdi
call   1050 <puts@plt>
mov    %r14,%rdi
call   1040 <free@plt>
jmp    13c1 <c_run+0x1b1>
lea    0xc92(%rip),%rdi
call   1050 <puts@plt>
mov    %r12d,%edi
mov    $0x55,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   10d0 <send_ctrl_msg@plt>
test   %rax,%rax
je     13f5 <c_run+0x1e5>
lea    0xcc4(%rip),%rdi
call   1050 <puts@plt>
mov    %r12d,%edi
call   10f0 <run_tx_test@plt>
mov    %r12d,%edi
call   10c0 <receive_summarystats@plt>
jmp    1401 <c_run+0x1f1>
lea    0xc7d(%rip),%rdi
call   1050 <puts@plt>
mov    -0x38(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc0b(%rip),%rdi
call   10e0 <perror@plt>
jmp    12fc <c_run+0xec>
mov    %r12d,%edi
call   10b0 <close@plt>
lea    0xc07(%rip),%rdi
call   10e0 <perror@plt>
jmp    1401 <c_run+0x1f1>
mov    %eax,%edi
call   1090 <gai_strerror@plt>
lea    0xbb7(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    0xccd(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i64, i32, i64, i32, i32, %struct.addrinfo* }
%struct.sockaddr_in = type { i32 }
@INET_ADDRSTRLEN = global i32 0
@AF_INET = global i64 0
@SOCK_STREAM = global i32 0
@.str = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.1 = [21 x i8] c"Will connect to: %s\0A\00"
@.str.2 = [21 x i8] c"Socket open failed: \00"
@IPPROTO_TCP = global i32 0
@TCP_NODELAY = global i32 0
@.str.3 = [28 x i8] c"Cannot disable Nagle! Exit\0A\00"
@.str.4 = [16 x i8] c"client: connect\00"
@.str.5 = [38 x i8] c"Server is Ready for Download Test...\0A\00"
@.str.6 = [26 x i8] c"\0ADownlink Summary Stats:\0A\00"
@.str.7 = [47 x i8] c"---------------------------------------------\0A\00"
@.str.8 = [3 x i8] c"%s\00"
@.str.9 = [44 x i8] c"Internal Error! Will not run Download Test\0A\00"
@.str.10 = [36 x i8] c"Server is Ready for Upload Test...\0A\00"
@.str.11 = [42 x i8] c"Internal Error! Will not run Upload Test\0A\00"
define void @c_run(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.addrinfo
%6 = alloca %struct.addrinfo*
%7 = alloca %struct.addrinfo*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca %struct.sockaddr_in*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%18 = load i32, i32* @INET_ADDRSTRLEN
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %9
%21 = alloca i8, i64 %19
store i64 %19, i64* %10
%22 = call i32 @memset(%struct.addrinfo* %5, i32 0, i32 40)
%23 = load i64, i64* @AF_INET
%24 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i32 0, i32 0
store i64 %23, i64* %24
%25 = load i32, i32* @SOCK_STREAM
%26 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %5, i32 0, i32 4
store i32 %25, i32* %26
%27 = load i8*, i8** %3
%28 = load i8*, i8** %4
%29 = call i32 @getaddrinfo(i8* %27, i8* %28, %struct.addrinfo* %5, %struct.addrinfo** %6)
store i32 %29, i32* %8
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %2
%32 = load i32, i32* %8
%33 = call i8* @gai_strerror(i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %33)
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %2
%37 = load %struct.addrinfo*, %struct.addrinfo** %6
store %struct.addrinfo* %37, %struct.addrinfo** %7
br label %38
38: ; preds = %64, %36
%39 = load %struct.addrinfo*, %struct.addrinfo** %7
%40 = icmp ne %struct.addrinfo* %39, null
br i1 %40, label %41, label %68
41: ; preds = %38
%42 = load %struct.addrinfo*, %struct.addrinfo** %7
%43 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %42, i32 0, i32 0
%44 = load i64, i64* %43
%45 = load i64, i64* @AF_INET
%46 = icmp eq i64 %44, %45
br i1 %46, label %47, label %55
47: ; preds = %41
%48 = load %struct.addrinfo*, %struct.addrinfo** %7
%49 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %48, i32 0, i32 2
%50 = load i64, i64* %49
%51 = inttoptr i64 %50 to %struct.sockaddr_in*
store %struct.sockaddr_in* %51, %struct.sockaddr_in** %14
%52 = load %struct.sockaddr_in*, %struct.sockaddr_in** %14
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %52, i32 0, i32 0
%54 = bitcast i32* %53 to i8*
store i8* %54, i8** %13
br label %56
55: ; preds = %41
br label %64
56: ; preds = %47
%57 = load %struct.addrinfo*, %struct.addrinfo** %7
%58 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %57, i32 0, i32 0
%59 = load i64, i64* %58
%60 = load i8*, i8** %13
%61 = trunc i64 %19 to i32
%62 = call i32 @inet_ntop(i64 %59, i8* %60, i8* %21, i32 %61)
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %68
64: ; preds = %55
%65 = load %struct.addrinfo*, %struct.addrinfo** %7
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %65, i32 0, i32 5
%67 = load %struct.addrinfo*, %struct.addrinfo** %66
store %struct.addrinfo* %67, %struct.addrinfo** %7
br label %38
68: ; preds = %56, %38
%69 = load %struct.addrinfo*, %struct.addrinfo** %7
%70 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %69, i32 0, i32 0
%71 = load i64, i64* %70
%72 = load %struct.addrinfo*, %struct.addrinfo** %7
%73 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %72, i32 0, i32 4
%74 = load i32, i32* %73
%75 = load %struct.addrinfo*, %struct.addrinfo** %7
%76 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %75, i32 0, i32 3
%77 = load i32, i32* %76
%78 = call i32 @socket(i64 %71, i32 %74, i32 %77)
store i32 %78, i32* %11
%79 = load i32, i32* %11
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %68
%82 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %83
83: ; preds = %81, %68
%84 = load i32, i32* %11
%85 = load i32, i32* @IPPROTO_TCP
%86 = load i32, i32* @TCP_NODELAY
%87 = bitcast i32* %12 to i8*
%88 = call i32 @setsockopt(i32 %84, i32 %85, i32 %86, i8* %87, i32 4)
store i32 %88, i32* %15
%89 = load i32, i32* %15
%90 = icmp slt i32 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %83
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%93 = call i32 @exit(i32 1)
unreachable
94: ; preds = %83
%95 = load i32, i32* %11
%96 = load %struct.addrinfo*, %struct.addrinfo** %7
%97 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %96, i32 0, i32 2
%98 = load i64, i64* %97
%99 = load %struct.addrinfo*, %struct.addrinfo** %7
%100 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %99, i32 0, i32 1
%101 = load i32, i32* %100
%102 = call i32 @connect(i32 %95, i64 %98, i32 %101)
%103 = icmp eq i32 %102, -1
br i1 %103, label %104, label %108
104: ; preds = %94
%105 = load i32, i32* %11
%106 = call i32 @close(i32 %105)
%107 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %16
br label %142
108: ; preds = %94
%109 = load i32, i32* %11
%110 = call i64 @send_ctrl_msg(i32 %109, i8 zeroext 79, i32* null, i32 0)
%111 = icmp ne i64 %110, 0
br i1 %111, label %112, label %127
112: ; preds = %108
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
%114 = load i32, i32* %11
%115 = call i8* @run_rx_test(i32 %114, i32 1)
store i8* %115, i8** %17
%116 = load i8*, i8** %17
%117 = icmp ne i8* %116, null
br i1 %117, label %118, label %126
118: ; preds = %112
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0))
%121 = load i8*, i8** %17
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %121)
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0))
%124 = load i8*, i8** %17
%125 = call i32 @free(i8* %124)
br label %126
126: ; preds = %118, %112
br label %129
127: ; preds = %108
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.9, i64 0, i64 0))
br label %129
129: ; preds = %127, %126
%130 = load i32, i32* %11
%131 = call i64 @send_ctrl_msg(i32 %130, i8 zeroext 85, i32* null, i32 0)
%132 = icmp ne i64 %131, 0
br i1 %132, label %133, label %139
133: ; preds = %129
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
%135 = load i32, i32* %11
%136 = call i32 @run_tx_test(i32 %135)
%137 = load i32, i32* %11
%138 = call i32 @receive_summarystats(i32 %137)
br label %141
139: ; preds = %129
%140 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.11, i64 0, i64 0))
br label %141
141: ; preds = %139, %133
store i32 0, i32* %16
br label %142
142: ; preds = %141, %104
%143 = load i8*, i8** %9
%144 = load i32, i32* %16
switch i32 %144, label %146 [
i32 0, label %145
i32 1, label %145
]
145: ; preds = %142, %142
ret void
146: ; preds = %142
unreachable
}

LLVM IR (-O2):
%struct.addrinfo = type { i64, i32, i64, i32, i32, %struct.addrinfo* }
@INET_ADDRSTRLEN = global i32 0
@AF_INET = global i64 0
@SOCK_STREAM = global i32 0
@.str = [17 x i8] c"getaddrinfo: %s\0A\00"
@.str.1 = [21 x i8] c"Will connect to: %s\0A\00"
@.str.2 = [21 x i8] c"Socket open failed: \00"
@IPPROTO_TCP = global i32 0
@TCP_NODELAY = global i32 0
@.str.4 = [16 x i8] c"client: connect\00"
@.str.8 = [3 x i8] c"%s\00"
@str = [43 x i8] c"Internal Error! Will not run Download Test\00"
@str.12 = [41 x i8] c"Internal Error! Will not run Upload Test\00"
@str.13 = [35 x i8] c"Server is Ready for Upload Test...\00"
@str.14 = [37 x i8] c"Server is Ready for Download Test...\00"
@str.15 = [25 x i8] c"\0ADownlink Summary Stats:\00"
@str.17 = [46 x i8] c"---------------------------------------------\00"
@str.18 = [27 x i8] c"Cannot disable Nagle! Exit\00"
define void @c_run(i8* %0, i8* %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = alloca i32
%6 = bitcast %struct.addrinfo* %3 to i8*
%7 = bitcast %struct.addrinfo** %4 to i8*
%8 = load i32, i32* @INET_ADDRSTRLEN
%9 = zext i32 %8 to i64
%10 = tail call i8* @llvm.stacksave()
%11 = alloca i8, i64 %9
%12 = bitcast i32* %5 to i8*
%13 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 40)
%14 = load i64, i64* @AF_INET
%15 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 0
store i64 %14, i64* %15
%16 = load i32, i32* @SOCK_STREAM
%17 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 4
store i32 %16, i32* %17
%18 = call i32 @getaddrinfo(i8* %0, i8* %1, %struct.addrinfo* %3, %struct.addrinfo** %4)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %2
%21 = load %struct.addrinfo*, %struct.addrinfo** %4
%22 = icmp eq %struct.addrinfo* %21, null
br i1 %22, label %44, label %23
23: ; preds = %20
%24 = load i64, i64* @AF_INET
br label %29
25: ; preds = %2
%26 = call i8* @gai_strerror(i32 %18)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %23, %40
%30 = phi %struct.addrinfo* [ %21, %23 ], [ %42, %40 ]
%31 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %30, i64 0, i32 0
%32 = load i64, i64* %31
%33 = icmp eq i64 %32, %24
br i1 %33, label %34, label %40
34: ; preds = %29
%35 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %30, i64 0, i32 2
%36 = load i64, i64* %35
%37 = inttoptr i64 %36 to i8*
%38 = call i32 @inet_ntop(i64 %24, i8* %37, i8* %11, i32 %8)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %44
40: ; preds = %29
%41 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %30, i64 0, i32 5
%42 = load %struct.addrinfo*, %struct.addrinfo** %41
%43 = icmp eq %struct.addrinfo* %42, null
br i1 %43, label %44, label %29
44: ; preds = %40, %20, %34
%45 = phi %struct.addrinfo* [ %30, %34 ], [ null, %20 ], [ null, %40 ]
%46 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %45, i64 0, i32 0
%47 = load i64, i64* %46
%48 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %45, i64 0, i32 4
%49 = load i32, i32* %48
%50 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %45, i64 0, i32 3
%51 = load i32, i32* %50
%52 = call i32 @socket(i64 %47, i32 %49, i32 %51)
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %44
%55 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %56
56: ; preds = %54, %44
%57 = load i32, i32* @IPPROTO_TCP
%58 = load i32, i32* @TCP_NODELAY
%59 = call i32 @setsockopt(i32 %52, i32 %57, i32 %58, i8* %12, i32 4)
%60 = icmp slt i32 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %56
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.18, i64 0, i64 0))
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %56
%65 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %45, i64 0, i32 2
%66 = load i64, i64* %65
%67 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %45, i64 0, i32 1
%68 = load i32, i32* %67
%69 = call i32 @connect(i32 %52, i64 %66, i32 %68)
%70 = icmp eq i32 %69, -1
br i1 %70, label %71, label %74
71: ; preds = %64
%72 = call i32 @close(i32 %52)
%73 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %98
74: ; preds = %64
%75 = call i64 @send_ctrl_msg(i32 %52, i8 zeroext 79, i32* null, i32 0)
%76 = icmp eq i64 %75, 0
br i1 %76, label %87, label %77
77: ; preds = %74
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.14, i64 0, i64 0))
%79 = call i8* @run_rx_test(i32 %52, i32 1)
%80 = icmp eq i8* %79, null
br i1 %80, label %89, label %81
81: ; preds = %77
%82 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.15, i64 0, i64 0))
%83 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.17, i64 0, i64 0))
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %79)
%85 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.17, i64 0, i64 0))
%86 = call i32 @free(i8* %79)
br label %89
87: ; preds = %74
%88 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
br label %89
89: ; preds = %77, %81, %87
%90 = call i64 @send_ctrl_msg(i32 %52, i8 zeroext 85, i32* null, i32 0)
%91 = icmp eq i64 %90, 0
br i1 %91, label %96, label %92
92: ; preds = %89
%93 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.13, i64 0, i64 0))
%94 = call i32 @run_tx_test(i32 %52)
%95 = call i32 @receive_summarystats(i32 %52)
br label %98
96: ; preds = %89
%97 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.12, i64 0, i64 0))
br label %98
98: ; preds = %92, %96, %71
ret void
}