#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 */
typedef scalar_t__ clock_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ read_write(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *ifp, *ofp;
  clock_t begin_time, end_time;
  double time_used;
  if (argc < 3) {
    fprintf(stderr, "Not enough arguments\n");
  }
  if (!(ifp = fopen(argv[1], "r"))) {
    fprintf(stderr, "Cannot open file %s\n", argv[1]);
  }
  if (!(ofp = fopen(argv[2], "w"))) {
    fprintf(stderr, "Cannot open file %s\n", argv[2]);
  }
  begin_time = clock();
  read_write(ifp, ofp);
  end_time = clock();
  time_used = (double)(end_time - begin_time) / CLOCKS_PER_SEC;
  fprintf(stderr, "Time usage = %17.13f\n", time_used);
  fclose(ifp);
  fclose(ofp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1187 <main+0x37>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe80(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11c8 <main+0x78>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe56(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1209 <main+0xb9>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe16(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <read_write@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x28(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2da8(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
movsd  -0x38(%rbp),%xmm0
lea    0xdd1(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
cmp    $0x2,%edi
jg     1177 <main+0x27>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x8(%r15),%rdi
lea    0xe94(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    11aa <main+0x5a>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xe75(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x10(%r15),%rdi
lea    0xe78(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r12
test   %rax,%rax
jne    11dd <main+0x8d>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
mov    0x10(%r15),%rdx
lea    0xe42(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %r12,%rsi
call   1070 <read_write@plt>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %rbx,%rax
cvtsi2sd %rax,%xmm0
mov    0x2de0(%rip),%rax
divsd  (%rax),%xmm0
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
lea    0xe13(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Not enough arguments\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"Cannot open file %s\0A\00"
@.str.3 = [2 x i8] c"w\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.4 = [22 x i8] c"Time usage = %17.13f\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 i64
%9 = alloca i64
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %13, %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %6
%21 = icmp ne i32* %20, null
br i1 %21, label %28, label %22
22: ; preds = %16
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %22, %16
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %32, i32** %7
%33 = icmp ne i32* %32, null
br i1 %33, label %40, label %34
34: ; preds = %28
%35 = load i32, i32* @stderr
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %34, %28
%41 = call i64 (...) @clock()
store i64 %41, i64* %8
%42 = load i32*, i32** %6
%43 = load i32*, i32** %7
%44 = call i32 @read_write(i32* %42, i32* %43)
%45 = call i64 (...) @clock()
store i64 %45, i64* %9
%46 = load i64, i64* %9
%47 = load i64, i64* %8
%48 = sub nsw i64 %46, %47
%49 = sitofp i64 %48 to double
%50 = load double, double* @CLOCKS_PER_SEC
%51 = fdiv double %49, %50
store double %51, double* %10
%52 = load i32, i32* @stderr
%53 = load double, double* %10
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), double %53)
%55 = load i32*, i32** %6
%56 = call i32 @fclose(i32* %55)
%57 = load i32*, i32** %7
%58 = call i32 @fclose(i32* %57)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Not enough arguments\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [21 x i8] c"Cannot open file %s\0A\00"
@.str.3 = [2 x i8] c"w\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.4 = [22 x i8] c"Time usage = %17.13f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %4, %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %8
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %12, %7
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %17
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %21, %16
%26 = tail call i64 (...) @clock()
%27 = tail call i32 @read_write(i32* %10, i32* %19)
%28 = tail call i64 (...) @clock()
%29 = sub nsw i64 %28, %26
%30 = sitofp i64 %29 to double
%31 = load double, double* @CLOCKS_PER_SEC
%32 = fdiv double %30, %31
%33 = load i32, i32* @stderr
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), double %32)
%35 = tail call i32 @fclose(i32* %10)
%36 = tail call i32 @fclose(i32* %19)
ret i32 0
}