#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 timespec {
  double tv_sec;
  scalar_t__ tv_nsec;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ serv_addr;
typedef int /*<<< orphan*/ option;
typedef int /*<<< orphan*/ clnt_addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ INADDR_ANY;
int O_CREAT;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int accept(int, struct sockaddr *, int *);
int /*<<< orphan*/ atoi(char *);
int bind(int, struct sockaddr *, int);
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ error_handling(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int listen(int, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, void *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  int serv_sock;
  int clnt_sock;
  struct sockaddr_in serv_addr;
  struct sockaddr_in clnt_addr;
  socklen_t clnt_addr_size;
  char message[1048576];
  int option = 1;
  int str_len;
  int fd;
  int check = 1;
  long long total = 0;
  struct timespec t1, t2;
  double t11 = 0, t22 = 0;
  if (argc != 3) {
    printf("Usage : %s <port> <file locate>\n", argv[0]);
    exit(1);
  }
  serv_sock = socket(PF_INET, SOCK_STREAM, 0);
  if (serv_sock == -1)
    error_handling("socket() error");
  if (setsockopt(serv_sock, SOL_SOCKET, SO_REUSEADDR, (void *)&option,
                 sizeof(option)))
    error_handling("setsockopt() error");
  memset(&serv_addr, 0, sizeof(serv_addr));
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  serv_addr.sin_port = htons(atoi(argv[1]));
  if (bind(serv_sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == -1)
    error_handling("bind() error");
  if (listen(serv_sock, 5) == -1)
    error_handling("listen() error");
  clnt_addr_size = sizeof(clnt_addr);
  clnt_sock = accept(serv_sock, (struct sockaddr *)&clnt_addr, &clnt_addr_size);
  if (clnt_sock == -1)
    error_handling("accept() error");
  fd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 00700);
  if (fd == -1)
    error_handling("open() error");
  clock_gettime(CLOCK_MONOTONIC, &t1);
  while ((str_len = read(clnt_sock, message, 1048576)) != 0) {
    write(fd, message, str_len);
    total += str_len;
  }
  close(fd);
  clock_gettime(CLOCK_MONOTONIC, &t2);
  t11 = t1.tv_sec + (double)t1.tv_nsec / 1000000000.0;
  t22 = t2.tv_sec + (double)t2.tv_nsec / 1000000000.0;
  printf("%lf MB/s\n", total / (t22 - t11) / 1024.0 / 1024.0);
  close(clnt_sock);
  close(serv_sock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100090,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x100044(%rbp)
movl   $0x1,-0x100050(%rbp)
movq   $0x0,-0x100058(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x100080(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x100088(%rbp)
ff
cmpl   $0x3,-0x8(%rbp)
je     1287 <main+0x77>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>
mov    0x2d1a(%rip),%rax
mov    (%rax),%edi
mov    0x2d19(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    12b9 <main+0xa9>
lea    0xd7d(%rip),%rdi
call   10c0 <error_handling@plt>
mov    -0x14(%rbp),%edi
mov    0x2d15(%rip),%rax
mov    (%rax),%esi
mov    0x2cd4(%rip),%rax
mov    (%rax),%edx
lea    -0x100044(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
je     12f6 <main+0xe6>
lea    0xd4f(%rip),%rdi
call   10c0 <error_handling@plt>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x2cc3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2ca7(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1110 <atoi@plt>
mov    %eax,%edi
call   1060 <htons@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
jne    1360 <main+0x150>
lea    0xcf8(%rip),%rdi
call   10c0 <error_handling@plt>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   10d0 <listen@plt>
cmp    $0xffffffff,%eax
jne    1382 <main+0x172>
lea    0xce3(%rip),%rdi
call   10c0 <error_handling@plt>
movl   $0xc,-0x3c(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x38(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
call   1100 <accept@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    13b2 <main+0x1a2>
lea    0xcc2(%rip),%rdi
call   10c0 <error_handling@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2bcf(%rip),%rax
mov    (%rax),%esi
mov    0x2c2e(%rip),%rax
or     (%rax),%esi
mov    0x2c1d(%rip),%rax
or     (%rax),%esi
mov    $0x1c0,%edx
call   10f0 <open@plt>
mov    %eax,-0x10004c(%rbp)
cmpl   $0xffffffff,-0x10004c(%rbp)
jne    13fe <main+0x1ee>
lea    0xc85(%rip),%rdi
call   10c0 <error_handling@plt>
mov    0x2bc3(%rip),%rax
mov    (%rax),%edi
lea    -0x100068(%rbp),%rsi
call   1040 <clock_gettime@plt>
mov    -0x18(%rbp),%edi
lea    -0x100040(%rbp),%rsi
mov    $0x100000,%edx
call   10b0 <read@plt>
mov    %eax,-0x100048(%rbp)
cmp    $0x0,%eax
je     1468 <main+0x258>
mov    -0x10004c(%rbp),%edi
lea    -0x100040(%rbp),%rsi
mov    -0x100048(%rbp),%edx
call   1050 <write@plt>
movslq -0x100048(%rbp),%rax
add    -0x100058(%rbp),%rax
mov    %rax,-0x100058(%rbp)
jmp    1413 <main+0x203>
mov    -0x10004c(%rbp),%edi
call   10a0 <close@plt>
mov    0x2b4e(%rip),%rax
mov    (%rax),%edi
lea    -0x100078(%rbp),%rsi
call   1040 <clock_gettime@plt>
movsd  -0x100068(%rbp),%xmm0
ff
cvtsi2sdq -0x100060(%rbp),%xmm1
ef ff
movsd  0xb67(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x100080(%rbp)
ff
movsd  -0x100078(%rbp),%xmm0
ff
cvtsi2sdq -0x100070(%rbp),%xmm1
ef ff
movsd  0xb3e(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x100088(%rbp)
ff
cvtsi2sdq -0x100058(%rbp),%xmm0
ef ff
movsd  -0x100088(%rbp),%xmm1
ff
subsd  -0x100080(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
movsd  0xb01(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xaf5(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xb75(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
call   10a0 <close@plt>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
xor    %eax,%eax
add    $0x100090,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x100058,%rsp
mov    %rsi,%r14
movl   $0x1,(%rsp)
cmp    $0x3,%edi
jne    14ac <main+0x29c>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
mov    0x2d6c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
jne    1261 <main+0x51>
lea    0xddd(%rip),%rdi
call   10c0 <error_handling@plt>
mov    0x2d70(%rip),%rax
mov    (%rax),%esi
mov    0x2d2f(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rcx
mov    %r15d,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
je     1295 <main+0x85>
lea    0xdb8(%rip),%rdi
call   10c0 <error_handling@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x2d20(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,0x14(%rsp)
mov    0x8(%r14),%rdi
call   1110 <atoi@plt>
mov    %eax,%edi
call   1060 <htons@plt>
mov    %eax,0x10(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0xffffffff,%eax
jne    12fd <main+0xed>
lea    0xd63(%rip),%rdi
call   10c0 <error_handling@plt>
mov    %r15d,%edi
mov    $0x5,%esi
call   10d0 <listen@plt>
cmp    $0xffffffff,%eax
jne    131b <main+0x10b>
lea    0xd52(%rip),%rdi
call   10c0 <error_handling@plt>
movl   $0xc,0x4(%rsp)
lea    0x40(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %r15d,%edi
call   1100 <accept@plt>
mov    %eax,%r12d
cmp    $0xffffffff,%eax
jne    1349 <main+0x139>
lea    0xd33(%rip),%rdi
call   10c0 <error_handling@plt>
mov    0x2c40(%rip),%rax
mov    0x2ca1(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x10(%r14),%rdi
mov    0x2c8a(%rip),%rax
or     (%rax),%esi
mov    $0x1c0,%edx
call   10f0 <open@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
jne    1386 <main+0x176>
lea    0xd05(%rip),%rdi
call   10c0 <error_handling@plt>
mov    0x2c3b(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0x20(%rsp),%rsi
call   1040 <clock_gettime@plt>
lea    0x50(%rsp),%rsi
mov    %r12d,%edi
mov    $0x100000,%edx
call   10b0 <read@plt>
test   %eax,%eax
je     13fd <main+0x1ed>
mov    %eax,%ebx
xor    %r13d,%r13d
lea    0x50(%rsp),%rbp
nopw   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %ebx,%edx
call   1050 <write@plt>
movslq %ebx,%rax
add    %rax,%r13
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x100000,%edx
call   10b0 <read@plt>
mov    %eax,%ebx
test   %eax,%eax
jne    13c0 <main+0x1b0>
cvtsi2sd %r13,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x2bcd(%rip),%rbp
jmp    1407 <main+0x1f7>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r14d,%edi
call   10a0 <close@plt>
mov    0x0(%rbp),%edi
lea    0x30(%rsp),%rsi
call   1040 <clock_gettime@plt>
movdqa 0x30(%rsp),%xmm3
movdqa %xmm3,%xmm1
punpckhqdq %xmm3,%xmm1
cvtsi2sdq 0x28(%rsp),%xmm2
movq   %xmm1,%rax
xorps  %xmm1,%xmm1
cvtsi2sd %rax,%xmm1
unpcklpd %xmm2,%xmm1
divpd  0xbb6(%rip),%xmm1
movhpd 0x20(%rsp),%xmm3
addpd  %xmm1,%xmm3
movapd %xmm3,%xmm1
unpckhpd %xmm3,%xmm1
subsd  %xmm1,%xmm3
movsd  0x8(%rsp),%xmm0
divsd  %xmm3,%xmm0
movsd  0xb9e(%rip),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
lea    0xc12(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    %r12d,%edi
call   10a0 <close@plt>
mov    %r15d,%edi
call   10a0 <close@plt>
xor    %eax,%eax
add    $0x100058,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r14),%rsi
lea    0xb62(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timespec = type { double, i64 }
%struct.sockaddr = type { i32 }
@.str = [33 x i8] c"Usage : %s <port> <file locate>\0A\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [15 x i8] c"socket() error\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [19 x i8] c"setsockopt() error\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@.str.3 = [13 x i8] c"bind() error\00"
@.str.4 = [15 x i8] c"listen() error\00"
@.str.5 = [15 x i8] c"accept() error\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.6 = [13 x i8] c"open() error\00"
@CLOCK_MONOTONIC = global i32 0
@.str.7 = [10 x i8] c"%lf MB/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 %struct.sockaddr_in
%9 = alloca %struct.sockaddr_in
%10 = alloca i32
%11 = alloca [1048576 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i64
%17 = alloca %struct.timespec
%18 = alloca %struct.timespec
%19 = alloca double
%20 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %12
store i32 1, i32* %15
store i64 0, i64* %16
store double 0.000000e+00, double* %19
store double 0.000000e+00, double* %20
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 3
br i1 %22, label %23, label %29
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %2
%30 = load i32, i32* @PF_INET
%31 = load i32, i32* @SOCK_STREAM
%32 = call i32 @socket(i32 %30, i32 %31, i32 0)
store i32 %32, i32* %6
%33 = load i32, i32* %6
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = call i32 @error_handling(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %37
37: ; preds = %35, %29
%38 = load i32, i32* %6
%39 = load i32, i32* @SOL_SOCKET
%40 = load i32, i32* @SO_REUSEADDR
%41 = bitcast i32* %12 to i8*
%42 = call i64 @setsockopt(i32 %38, i32 %39, i32 %40, i8* %41, i32 4)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %37
%45 = call i32 @error_handling(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %46
46: ; preds = %44, %37
%47 = call i32 @memset(%struct.sockaddr_in* %8, i32 0, i32 12)
%48 = load i32, i32* @AF_INET
%49 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %48, i32* %49
%50 = load i32, i32* @INADDR_ANY
%51 = call i32 @htonl(i32 %50)
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%53 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %52, i32 0, i32 0
store i32 %51, i32* %53
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 1
%56 = load i8*, i8** %55
%57 = call i32 @atoi(i8* %56)
%58 = call i32 @htons(i32 %57)
%59 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
store i32 %58, i32* %59
%60 = load i32, i32* %6
%61 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%62 = call i32 @bind(i32 %60, %struct.sockaddr* %61, i32 12)
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %66
64: ; preds = %46
%65 = call i32 @error_handling(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %66
66: ; preds = %64, %46
%67 = load i32, i32* %6
%68 = call i32 @listen(i32 %67, i32 5)
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %72
70: ; preds = %66
%71 = call i32 @error_handling(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %72
72: ; preds = %70, %66
store i32 12, i32* %10
%73 = load i32, i32* %6
%74 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%75 = call i32 @accept(i32 %73, %struct.sockaddr* %74, i32* %10)
store i32 %75, i32* %7
%76 = load i32, i32* %7
%77 = icmp eq i32 %76, -1
br i1 %77, label %78, label %80
78: ; preds = %72
%79 = call i32 @error_handling(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %80
80: ; preds = %78, %72
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 2
%83 = load i8*, i8** %82
%84 = load i32, i32* @O_WRONLY
%85 = load i32, i32* @O_CREAT
%86 = or i32 %84, %85
%87 = load i32, i32* @O_TRUNC
%88 = or i32 %86, %87
%89 = call i32 @open(i8* %83, i32 %88, i32 448)
store i32 %89, i32* %14
%90 = load i32, i32* %14
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %94
92: ; preds = %80
%93 = call i32 @error_handling(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %94
94: ; preds = %92, %80
%95 = load i32, i32* @CLOCK_MONOTONIC
%96 = call i32 @clock_gettime(i32 %95, %struct.timespec* %17)
br label %97
97: ; preds = %102, %94
%98 = load i32, i32* %7
%99 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %11, i64 0, i64 0
%100 = call i32 @read(i32 %98, i8* %99, i32 1048576)
store i32 %100, i32* %13
%101 = icmp ne i32 %100, 0
br i1 %101, label %102, label %111
102: ; preds = %97
%103 = load i32, i32* %14
%104 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %11, i64 0, i64 0
%105 = load i32, i32* %13
%106 = call i32 @write(i32 %103, i8* %104, i32 %105)
%107 = load i32, i32* %13
%108 = sext i32 %107 to i64
%109 = load i64, i64* %16
%110 = add nsw i64 %109, %108
store i64 %110, i64* %16
br label %97
111: ; preds = %97
%112 = load i32, i32* %14
%113 = call i32 @close(i32 %112)
%114 = load i32, i32* @CLOCK_MONOTONIC
%115 = call i32 @clock_gettime(i32 %114, %struct.timespec* %18)
%116 = getelementptr inbounds %struct.timespec, %struct.timespec* %17, i32 0, i32 0
%117 = load double, double* %116
%118 = getelementptr inbounds %struct.timespec, %struct.timespec* %17, i32 0, i32 1
%119 = load i64, i64* %118
%120 = sitofp i64 %119 to double
%121 = fdiv double %120, 1.000000e+09
%122 = fadd double %117, %121
store double %122, double* %19
%123 = getelementptr inbounds %struct.timespec, %struct.timespec* %18, i32 0, i32 0
%124 = load double, double* %123
%125 = getelementptr inbounds %struct.timespec, %struct.timespec* %18, i32 0, i32 1
%126 = load i64, i64* %125
%127 = sitofp i64 %126 to double
%128 = fdiv double %127, 1.000000e+09
%129 = fadd double %124, %128
store double %129, double* %20
%130 = load i64, i64* %16
%131 = sitofp i64 %130 to double
%132 = load double, double* %20
%133 = load double, double* %19
%134 = fsub double %132, %133
%135 = fdiv double %131, %134
%136 = fdiv double %135, 1.024000e+03
%137 = fdiv double %136, 1.024000e+03
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), double %137)
%139 = load i32, i32* %7
%140 = call i32 @close(i32 %139)
%141 = load i32, i32* %6
%142 = call i32 @close(i32 %141)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.timespec = type { double, i64 }
%struct.sockaddr = type { i32 }
@.str = [33 x i8] c"Usage : %s <port> <file locate>\0A\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [15 x i8] c"socket() error\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [19 x i8] c"setsockopt() error\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@.str.3 = [13 x i8] c"bind() error\00"
@.str.4 = [15 x i8] c"listen() error\00"
@.str.5 = [15 x i8] c"accept() error\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.6 = [13 x i8] c"open() error\00"
@CLOCK_MONOTONIC = global i32 0
@.str.7 = [10 x i8] c"%lf MB/s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca [1048576 x i8]
%7 = alloca i32
%8 = alloca %struct.timespec
%9 = alloca <2 x double>
%10 = bitcast %struct.sockaddr_in* %3 to i8*
%11 = bitcast %struct.sockaddr_in* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = getelementptr inbounds [1048576 x i8], [1048576 x i8]* %6, i64 0, i64 0
%14 = bitcast i32* %7 to i8*
store i32 1, i32* %7
%15 = bitcast %struct.timespec* %8 to i8*
%16 = bitcast <2 x double>* %9 to i8*
%17 = icmp eq i32 %0, 3
br i1 %17, label %22, label %18
18: ; preds = %2
%19 = load i8*, i8** %1
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %2
%23 = load i32, i32* @PF_INET
%24 = load i32, i32* @SOCK_STREAM
%25 = tail call i32 @socket(i32 %23, i32 %24, i32 0)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = tail call i32 @error_handling(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %22
%30 = load i32, i32* @SOL_SOCKET
%31 = load i32, i32* @SO_REUSEADDR
%32 = call i64 @setsockopt(i32 %25, i32 %30, i32 %31, i8* %14, i32 4)
%33 = icmp eq i64 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %29
%35 = call i32 @error_handling(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %34, %29
%37 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%38 = load i32, i32* @AF_INET
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %38, i32* %39
%40 = load i32, i32* @INADDR_ANY
%41 = call i32 @htonl(i32 %40)
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %41, i32* %42
%43 = getelementptr inbounds i8*, i8** %1, i64 1
%44 = load i8*, i8** %43
%45 = call i32 @atoi(i8* %44)
%46 = call i32 @htons(i32 %45)
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %46, i32* %47
%48 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%49 = call i32 @bind(i32 %25, %struct.sockaddr* %48, i32 12)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %53
51: ; preds = %36
%52 = call i32 @error_handling(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %53
53: ; preds = %51, %36
%54 = call i32 @listen(i32 %25, i32 5)
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 @error_handling(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %58
58: ; preds = %56, %53
store i32 12, i32* %5
%59 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%60 = call i32 @accept(i32 %25, %struct.sockaddr* %59, i32* %5)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %64
62: ; preds = %58
%63 = call i32 @error_handling(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %64
64: ; preds = %62, %58
%65 = getelementptr inbounds i8*, i8** %1, i64 2
%66 = load i8*, i8** %65
%67 = load i32, i32* @O_WRONLY
%68 = load i32, i32* @O_CREAT
%69 = or i32 %68, %67
%70 = load i32, i32* @O_TRUNC
%71 = or i32 %69, %70
%72 = call i32 @open(i8* %66, i32 %71, i32 448)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %76
74: ; preds = %64
%75 = call i32 @error_handling(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %76
76: ; preds = %74, %64
%77 = load i32, i32* @CLOCK_MONOTONIC
%78 = call i32 @clock_gettime(i32 %77, %struct.timespec* %8)
%79 = call i32 @read(i32 %60, i8* %13, i32 1048576)
%80 = icmp eq i32 %79, 0
br i1 %80, label %91, label %81
81: ; preds = %76, %81
%82 = phi i32 [ %87, %81 ], [ %79, %76 ]
%83 = phi i64 [ %86, %81 ], [ 0, %76 ]
%84 = call i32 @write(i32 %72, i8* %13, i32 %82)
%85 = sext i32 %82 to i64
%86 = add nsw i64 %83, %85
%87 = call i32 @read(i32 %60, i8* %13, i32 1048576)
%88 = icmp eq i32 %87, 0
br i1 %88, label %89, label %81
89: ; preds = %81
%90 = sitofp i64 %86 to double
br label %91
91: ; preds = %89, %76
%92 = phi double [ 0.000000e+00, %76 ], [ %90, %89 ]
%93 = bitcast <2 x double>* %9 to %struct.timespec*
%94 = call i32 @close(i32 %72)
%95 = load i32, i32* @CLOCK_MONOTONIC
%96 = call i32 @clock_gettime(i32 %95, %struct.timespec* %93)
%97 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i64 0, i32 0
%98 = load double, double* %97
%99 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i64 0, i32 1
%100 = load i64, i64* %99
%101 = load <2 x double>, <2 x double>* %9
%102 = bitcast <2 x double> %101 to <2 x i64>
%103 = shufflevector <2 x i64> %102, <2 x i64> poison, <2 x i32> <i32 1, i32 undef>
%104 = insertelement <2 x i64> %103, i64 %100, i64 1
%105 = sitofp <2 x i64> %104 to <2 x double>
%106 = fdiv <2 x double> %105, <double 1.000000e+09, double 1.000000e+09>
%107 = insertelement <2 x double> %101, double %98, i64 1
%108 = fadd <2 x double> %107, %106
%109 = shufflevector <2 x double> %108, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%110 = fsub <2 x double> %108, %109
%111 = extractelement <2 x double> %110, i64 0
%112 = fdiv double %92, %111
%113 = fmul double %112, 0x3F50000000000000
%114 = fmul double %113, 0x3F50000000000000
%115 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), double %114)
%116 = call i32 @close(i32 %60)
%117 = call i32 @close(i32 %25)
ret i32 0
}