#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct sockaddr_storage {
  int /*<<< orphan*/ ss_family;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  char *h_name;
};
typedef scalar_t__ clock_t;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
double CLOCKS_PER_SEC;
int /*<<< orphan*/ INADDR_ANY;
int INET6_ADDRSTRLEN;
int /*<<< orphan*/ SOCK_STREAM;
int accept(int, struct sockaddr *, int *);
int atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
scalar_t__ clock();
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
struct hostent *gethostbyaddr(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ herror(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, TYPE_1__ *, char *, int);
scalar_t__ listen(int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int write(int, char *, int);
int main(int argc, char **argv) {
  int port, sd, sd2, fd, len;
  char buf[INET6_ADDRSTRLEN];
  port = atoi(argv[1]);
  if ((sd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    perror("socket error");
    return -1;
  }
  struct sockaddr_in sockaddr;
  struct sockaddr_storage sender;
  sockaddr.sin_family = AF_INET;
  sockaddr.sin_addr.s_addr = INADDR_ANY;
  sockaddr.sin_port = htons(port);
  len = sizeof sockaddr;
  if (bind(sd, (struct sockaddr *)&sockaddr, len) < 0) {
    perror("bind error");
    return -1;
  }
  if (listen(sd, 128) < 0) {
    perror("listen error");
    return -1;
  }
  if ((sd2 = accept(sd, (struct sockaddr *)&sender, &len)) < 0) {
    perror("accept error");
    return -1;
  }
  char *hostname;
  inet_ntop(sender.ss_family, &(((struct sockaddr_in *)&sender)->sin_addr), buf,
            sizeof buf);
  printf("%s\n", buf);
  struct hostent *addr;
  addr = gethostbyaddr(buf, sizeof buf, AF_INET);
  if (addr == NULL) {
    herror(" ");
  } else {
    hostname = addr->h_name;
  }
  int rc, wc, totalc = 0;
  char rb[1024];
  clock_t start = clock();
  while ((rc = read(sd2, rb, 1024)) > 0) {
    wc = write(1, rb, rc);
    totalc = totalc + wc;
    if (wc < 0)
      perror("write error");
  }
  if (rc < 0)
    perror("read error");
  clock_t end = clock();
  close(sd);
  close(sd2);
  fprintf(stderr,
          "\n\n--------------------------------------------------------\nTotal "
          "bytes sent: %i B\nThroughput is %f MB/S",
          totalc,
          ((totalc) / (((double)end - (double)start) / CLOCKS_PER_SEC)) /
              1000000);
  fprintf(stderr, "hostname is %s\n", hostname);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dc8(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x490(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x488(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1100 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
mov    0x2d49(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    12a3 <main+0xa3>
lea    0xd7d(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    150b <main+0x30b>
mov    0x2d36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2d1a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <htons@plt>
mov    %eax,-0x44(%rbp)
movl   $0xc,-0x24(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   10d0 <bind@plt>
cmp    $0x0,%rax
jge    1305 <main+0x105>
lea    0xd28(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    150b <main+0x30b>
mov    -0x18(%rbp),%edi
mov    $0x80,%esi
call   10c0 <listen@plt>
cmp    $0x0,%rax
jge    133b <main+0x13b>
lea    0xcfd(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    150b <main+0x30b>
mov    -0x18(%rbp),%edi
lea    -0x50(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   10f0 <accept@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1376 <main+0x176>
lea    0xccf(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
jmp    150b <main+0x30b>
mov    -0x488(%rbp),%rdx
mov    -0x490(%rbp),%rax
mov    -0x50(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0x488(%rbp),%rsi
lea    0xd27(%rip),%rdi
call   1070 <printf@plt>
mov    -0x488(%rbp),%rdi
mov    -0x490(%rbp),%rax
mov    %eax,%esi
mov    0x2c24(%rip),%rax
mov    (%rax),%edx
call   1110 <gethostbyaddr@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    13e3 <main+0x1e3>
lea    0xc61(%rip),%rdi
call   10b0 <herror@plt>
jmp    13ee <main+0x1ee>
mov    -0x60(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    $0x0,%al
call   1050 <clock@plt>
mov    %rax,-0x478(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x470(%rbp),%rsi
mov    $0x400,%edx
call   1090 <read@plt>
mov    %eax,-0x64(%rbp)
cmp    $0x0,%eax
jle    145e <main+0x25e>
lea    -0x470(%rbp),%rsi
mov    -0x64(%rbp),%edx
mov    $0x1,%edi
call   1040 <write@plt>
mov    %eax,-0x68(%rbp)
mov    -0x6c(%rbp),%eax
add    -0x68(%rbp),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0x0,-0x68(%rbp)
jge    1459 <main+0x259>
lea    0xbe8(%rip),%rdi
call   10e0 <perror@plt>
jmp    1403 <main+0x203>
cmpl   $0x0,-0x64(%rbp)
jge    1474 <main+0x274>
lea    0xbd9(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x0,%al
call   1050 <clock@plt>
mov    %rax,-0x480(%rbp)
mov    -0x18(%rbp),%edi
call   1080 <close@plt>
mov    -0x1c(%rbp),%edi
call   1080 <close@plt>
mov    0x2b27(%rip),%rax
mov    (%rax),%edi
mov    -0x6c(%rbp),%edx
cvtsi2sdl -0x6c(%rbp),%xmm0
cvtsi2sdq -0x480(%rbp),%xmm1
ff ff
cvtsi2sdq -0x478(%rbp),%xmm2
ff ff
subsd  %xmm2,%xmm1
mov    0x2b18(%rip),%rax
divsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  0xb30(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xb78(%rip),%rsi
mov    $0x1,%al
call   10a0 <fprintf@plt>
mov    0x2ad7(%rip),%rax
mov    (%rax),%edi
mov    -0x58(%rbp),%rdx
lea    0xbc5(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x30(%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    $0x438,%rsp
mov    %rsp,-0x30(%rbp)
mov    0x2dc9(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%rbx
lea    0xf(%r15),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    0x8(%rsi),%rdi
call   1100 <atoi@plt>
mov    %eax,%r12d
mov    0x2d9a(%rip),%r13
mov    0x0(%r13),%edi
mov    0x2d67(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
test   %eax,%eax
js     140b <main+0x20b>
mov    %eax,%r14d
mov    0x0(%r13),%eax
mov    %eax,-0x40(%rbp)
mov    0x2d5d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    %r12d,%edi
call   1060 <htons@plt>
mov    %eax,-0x44(%rbp)
movl   $0xc,-0x3c(%rbp)
lea    -0x48(%rbp),%rsi
mov    %r14d,%edi
mov    $0xc,%edx
call   10d0 <bind@plt>
test   %rax,%rax
js     1414 <main+0x214>
mov    %r14d,%edi
mov    $0x80,%esi
call   10c0 <listen@plt>
test   %rax,%rax
js     141d <main+0x21d>
lea    -0x38(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
mov    %r14d,%edi
call   10f0 <accept@plt>
test   %eax,%eax
js     1426 <main+0x226>
mov    %eax,%r12d
mov    -0x38(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    %rbx,%rdx
mov    %r15d,%ecx
call   1030 <inet_ntop@plt>
lea    0xdd9(%rip),%rdi
mov    %rbx,%rsi
call   1070 <printf@plt>
mov    0x0(%r13),%edx
mov    %rbx,%rdi
mov    %r15d,%esi
call   1110 <gethostbyaddr@plt>
test   %rax,%rax
je     1313 <main+0x113>
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
jmp    131f <main+0x11f>
lea    0xd20(%rip),%rdi
call   10b0 <herror@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,-0x58(%rbp)
lea    -0x460(%rbp),%rsi
mov    %r12d,%edi
mov    $0x400,%edx
call   1090 <read@plt>
test   %eax,%eax
jle    138b <main+0x18b>
xor    %ebx,%ebx
lea    -0x460(%rbp),%r15
jmp    1367 <main+0x167>
nop
add    %r13d,%ebx
mov    %r12d,%edi
mov    %r15,%rsi
mov    $0x400,%edx
call   1090 <read@plt>
test   %eax,%eax
jle    138b <main+0x18b>
mov    $0x1,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,%r13d
test   %eax,%eax
jns    1350 <main+0x150>
lea    0xcb8(%rip),%rdi
call   10e0 <perror@plt>
jmp    1350 <main+0x150>
test   %eax,%eax
js     1451 <main+0x251>
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%r13
mov    %r14d,%edi
call   1080 <close@plt>
mov    %r12d,%edi
call   1080 <close@plt>
mov    0x2c09(%rip),%r14
cvtsi2sd %ebx,%xmm0
cvtsi2sd %r13,%xmm1
cvtsi2sdq -0x58(%rbp),%xmm2
subsd  %xmm2,%xmm1
mov    0x2c07(%rip),%rax
divsd  (%rax),%xmm1
mov    (%r14),%edi
divsd  %xmm1,%xmm0
divsd  0xc1c(%rip),%xmm0
lea    0xc68(%rip),%rsi
mov    %ebx,%edx
mov    $0x1,%al
call   10a0 <fprintf@plt>
mov    (%r14),%edi
lea    0xcbd(%rip),%rsi
mov    -0x50(%rbp),%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1438 <main+0x238>
lea    0xbf6(%rip),%rdi
jmp    142d <main+0x22d>
lea    0xbfa(%rip),%rdi
jmp    142d <main+0x22d>
lea    0xbfc(%rip),%rdi
jmp    142d <main+0x22d>
lea    0xc00(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xffffffff,%r15d
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    %r15d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbf0(%rip),%rdi
call   10e0 <perror@plt>
jmp    1393 <main+0x193>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr_storage = type { i32 }
%struct.hostent = type { i8* }
%struct.sockaddr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [13 x i8] c"socket error\00"
@INADDR_ANY = global i32 0
@.str.1 = [11 x i8] c"bind error\00"
@.str.2 = [13 x i8] c"listen error\00"
@.str.3 = [13 x i8] c"accept error\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [2 x i8] c" \00"
@.str.6 = [12 x i8] c"write error\00"
@.str.7 = [11 x i8] c"read error\00"
@stderr = global i32 0
@.str.8 = [104 x i8] c"\0A\0A--------------------------------------------------------\0ATotal bytes sent: %i B\0AThroughput is %f MB/S\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.9 = [16 x i8] c"hostname is %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 i8*
%12 = alloca i64
%13 = alloca i32
%14 = alloca %struct.sockaddr_in
%15 = alloca %struct.sockaddr_storage
%16 = alloca i8*
%17 = alloca %struct.hostent*
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca [1024 x i8]
%22 = alloca i64
%23 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%24 = load i32, i32* @INET6_ADDRSTRLEN
%25 = zext i32 %24 to i64
%26 = call i8* @llvm.stacksave()
store i8* %26, i8** %11
%27 = alloca i8, i64 %25
store i64 %25, i64* %12
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %6
%32 = load i32, i32* @AF_INET
%33 = load i32, i32* @SOCK_STREAM
%34 = call i32 @socket(i32 %32, i32 %33, i32 0)
store i32 %34, i32* %7
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %2
%37 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %13
br label %133
38: ; preds = %2
%39 = load i32, i32* @AF_INET
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 2
store i32 %39, i32* %40
%41 = load i32, i32* @INADDR_ANY
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 0
%43 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %42, i32 0, i32 0
store i32 %41, i32* %43
%44 = load i32, i32* %6
%45 = call i32 @htons(i32 %44)
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 1
store i32 %45, i32* %46
store i32 12, i32* %10
%47 = load i32, i32* %7
%48 = bitcast %struct.sockaddr_in* %14 to %struct.sockaddr*
%49 = load i32, i32* %10
%50 = call i64 @bind(i32 %47, %struct.sockaddr* %48, i32 %49)
%51 = icmp slt i64 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %38
%53 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %13
br label %133
54: ; preds = %38
%55 = load i32, i32* %7
%56 = call i64 @listen(i32 %55, i32 128)
%57 = icmp slt i64 %56, 0
br i1 %57, label %58, label %60
58: ; preds = %54
%59 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %13
br label %133
60: ; preds = %54
%61 = load i32, i32* %7
%62 = bitcast %struct.sockaddr_storage* %15 to %struct.sockaddr*
%63 = call i32 @accept(i32 %61, %struct.sockaddr* %62, i32* %10)
store i32 %63, i32* %8
%64 = icmp slt i32 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %60
%66 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
store i32 1, i32* %13
br label %133
67: ; preds = %60
%68 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %15, i32 0, i32 0
%69 = load i32, i32* %68
%70 = bitcast %struct.sockaddr_storage* %15 to %struct.sockaddr_in*
%71 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %70, i32 0, i32 0
%72 = trunc i64 %25 to i32
%73 = call i32 @inet_ntop(i32 %69, %struct.TYPE_2__* %71, i8* %27, i32 %72)
%74 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %27)
%75 = trunc i64 %25 to i32
%76 = load i32, i32* @AF_INET
%77 = call %struct.hostent* @gethostbyaddr(i8* %27, i32 %75, i32 %76)
store %struct.hostent* %77, %struct.hostent** %17
%78 = load %struct.hostent*, %struct.hostent** %17
%79 = icmp eq %struct.hostent* %78, null
br i1 %79, label %80, label %82
80: ; preds = %67
%81 = call i32 @herror(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %86
82: ; preds = %67
%83 = load %struct.hostent*, %struct.hostent** %17
%84 = getelementptr inbounds %struct.hostent, %struct.hostent* %83, i32 0, i32 0
%85 = load i8*, i8** %84
store i8* %85, i8** %16
br label %86
86: ; preds = %82, %80
store i32 0, i32* %20
%87 = call i64 (...) @clock()
store i64 %87, i64* %22
br label %88
88: ; preds = %104, %86
%89 = load i32, i32* %8
%90 = getelementptr inbounds [1024 x i8], [1024 x i8]* %21, i64 0, i64 0
%91 = call i32 @read(i32 %89, i8* %90, i32 1024)
store i32 %91, i32* %18
%92 = icmp sgt i32 %91, 0
br i1 %92, label %93, label %105
93: ; preds = %88
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %21, i64 0, i64 0
%95 = load i32, i32* %18
%96 = call i32 @write(i32 1, i8* %94, i32 %95)
store i32 %96, i32* %19
%97 = load i32, i32* %20
%98 = load i32, i32* %19
%99 = add nsw i32 %97, %98
store i32 %99, i32* %20
%100 = load i32, i32* %19
%101 = icmp slt i32 %100, 0
br i1 %101, label %102, label %104
102: ; preds = %93
%103 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %104
104: ; preds = %102, %93
br label %88
105: ; preds = %88
%106 = load i32, i32* %18
%107 = icmp slt i32 %106, 0
br i1 %107, label %108, label %110
108: ; preds = %105
%109 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
br label %110
110: ; preds = %108, %105
%111 = call i64 (...) @clock()
store i64 %111, i64* %23
%112 = load i32, i32* %7
%113 = call i32 @close(i32 %112)
%114 = load i32, i32* %8
%115 = call i32 @close(i32 %114)
%116 = load i32, i32* @stderr
%117 = load i32, i32* %20
%118 = load i32, i32* %20
%119 = sitofp i32 %118 to double
%120 = load i64, i64* %23
%121 = sitofp i64 %120 to double
%122 = load i64, i64* %22
%123 = sitofp i64 %122 to double
%124 = fsub double %121, %123
%125 = load double, double* @CLOCKS_PER_SEC
%126 = fdiv double %124, %125
%127 = fdiv double %119, %126
%128 = fdiv double %127, 1.000000e+06
%129 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.8, i64 0, i64 0), i32 %117, double %128)
%130 = load i32, i32* @stderr
%131 = load i8*, i8** %16
%132 = call i32 (i32, i8*, ...) @fprintf(i32 %130, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i8* %131)
store i32 0, i32* %3
store i32 1, i32* %13
br label %133
133: ; preds = %110, %65, %58, %52, %36
%134 = load i8*, i8** %11
%135 = load i32, i32* %3
ret i32 %135
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
%struct.hostent = type { i8* }
@INET6_ADDRSTRLEN = global i32 0
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [13 x i8] c"socket error\00"
@INADDR_ANY = global i32 0
@.str.1 = [11 x i8] c"bind error\00"
@.str.2 = [13 x i8] c"listen error\00"
@.str.3 = [13 x i8] c"accept error\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [2 x i8] c" \00"
@.str.6 = [12 x i8] c"write error\00"
@.str.7 = [11 x i8] c"read error\00"
@stderr = global i32 0
@.str.8 = [104 x i8] c"\0A\0A--------------------------------------------------------\0ATotal bytes sent: %i B\0AThroughput is %f MB/S\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.9 = [16 x i8] c"hostname is %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.sockaddr_storage
%6 = alloca [1024 x i8]
%7 = bitcast i32* %3 to i8*
%8 = load i32, i32* @INET6_ADDRSTRLEN
%9 = zext i32 %8 to i64
%10 = tail call i8* @llvm.stacksave()
%11 = alloca i8, i64 %9
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = load i32, i32* @AF_INET
%16 = load i32, i32* @SOCK_STREAM
%17 = tail call i32 @socket(i32 %15, i32 %16, i32 0)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %101
21: ; preds = %2
%22 = bitcast %struct.sockaddr_in* %4 to i8*
%23 = bitcast %struct.sockaddr_storage* %5 to i8*
%24 = load i32, i32* @AF_INET
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %24, i32* %25
%26 = load i32, i32* @INADDR_ANY
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
store i32 %26, i32* %27
%28 = tail call i32 @htons(i32 %14)
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %28, i32* %29
store i32 12, i32* %3
%30 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%31 = call i64 @bind(i32 %17, %struct.sockaddr* %30, i32 12)
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %21
%34 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %99
35: ; preds = %21
%36 = call i64 @listen(i32 %17, i32 128)
%37 = icmp slt i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %99
40: ; preds = %35
%41 = bitcast %struct.sockaddr_storage* %5 to %struct.sockaddr*
%42 = call i32 @accept(i32 %17, %struct.sockaddr* %41, i32* %3)
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %99
46: ; preds = %40
%47 = getelementptr inbounds %struct.sockaddr_storage, %struct.sockaddr_storage* %5, i64 0, i32 0
%48 = load i32, i32* %47
%49 = bitcast %struct.sockaddr_storage* %5 to %struct.TYPE_2__*
%50 = call i32 @inet_ntop(i32 %48, %struct.TYPE_2__* %49, i8* %11, i32 %8)
%51 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %11)
%52 = load i32, i32* @AF_INET
%53 = call %struct.hostent* @gethostbyaddr(i8* %11, i32 %8, i32 %52)
%54 = icmp eq %struct.hostent* %53, null
br i1 %54, label %55, label %57
55: ; preds = %46
%56 = call i32 @herror(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %60
57: ; preds = %46
%58 = getelementptr inbounds %struct.hostent, %struct.hostent* %53, i64 0, i32 0
%59 = load i8*, i8** %58
br label %60
60: ; preds = %57, %55
%61 = phi i8* [ undef, %55 ], [ %59, %57 ]
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%63 = call i64 (...) @clock()
%64 = call i32 @read(i32 %42, i8* %62, i32 1024)
%65 = icmp sgt i32 %64, 0
br i1 %65, label %66, label %77
66: ; preds = %60, %74
%67 = phi i32 [ %75, %74 ], [ %64, %60 ]
%68 = phi i32 [ %70, %74 ], [ 0, %60 ]
%69 = call i32 @write(i32 1, i8* %62, i32 %67)
%70 = add nsw i32 %69, %68
%71 = icmp slt i32 %69, 0
br i1 %71, label %72, label %74
72: ; preds = %66
%73 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %74
74: ; preds = %72, %66
%75 = call i32 @read(i32 %42, i8* %62, i32 1024)
%76 = icmp sgt i32 %75, 0
br i1 %76, label %66, label %77
77: ; preds = %74, %60
%78 = phi i32 [ 0, %60 ], [ %70, %74 ]
%79 = phi i32 [ %64, %60 ], [ %75, %74 ]
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %77
%82 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
br label %83
83: ; preds = %81, %77
%84 = call i64 (...) @clock()
%85 = call i32 @close(i32 %17)
%86 = call i32 @close(i32 %42)
%87 = load i32, i32* @stderr
%88 = sitofp i32 %78 to double
%89 = sitofp i64 %84 to double
%90 = sitofp i64 %63 to double
%91 = fsub double %89, %90
%92 = load double, double* @CLOCKS_PER_SEC
%93 = fdiv double %91, %92
%94 = fdiv double %88, %93
%95 = fdiv double %94, 1.000000e+06
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str.8, i64 0, i64 0), i32 %78, double %95)
%97 = load i32, i32* @stderr
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i8* %61)
br label %99
99: ; preds = %83, %44, %38, %33
%100 = phi i32 [ -1, %33 ], [ -1, %38 ], [ -1, %44 ], [ 0, %83 ]
br label %101
101: ; preds = %99, %19
%102 = phi i32 [ -1, %19 ], [ %100, %99 ]
ret i32 %102
}