#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;
int /*<<< orphan*/ atoi(char *);
scalar_t__ clock();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ formatter(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                             int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
main(int argc, char *argv[]) {
  FILE *ifp, *ofp;
  clock_t begin_time, end_time;
  double time_used;
  if (argc < 4) {
    fprintf(stderr, "Not enough arguments\n");
    exit(1);
  }
  if (!(ifp = fopen(argv[1], "r"))) {
    fprintf(stderr, "Cannot open file %s\n", argv[1]);
    exit(1);
  }
  if (!(ofp = fopen(argv[2], "w"))) {
    fprintf(stderr, "Cannot open file %s\n", argv[2]);
    exit(1);
  }
  begin_time = clock();
  formatter(ifp, ofp, atoi(argv[3]));
  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);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x4(%rbp)
jge    11aa <main+0x3a>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11f5 <main+0x85>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe34(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe29(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1240 <main+0xd0>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xde9(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1080 <atoi@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
call   1060 <formatter@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x28(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2d52(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
movsd  -0x38(%rbp),%xmm0
lea    0xd7b(%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    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x3,%edi
jle    122b <main+0xbb>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe87(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     124c <main+0xdc>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe82(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     125b <main+0xeb>
mov    %rax,%r15
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%r12
mov    0x18(%rbx),%rdi
call   1080 <atoi@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1060 <formatter@plt>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r12,%rax
cvtsi2sd %rax,%xmm0
mov    0x2df6(%rip),%rax
divsd  (%rax),%xmm0
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    0xe29(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %r15,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
lea    0xdc5(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
jmp    1268 <main+0xf8>
mov    0x2d76(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
lea    0xda9(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

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 i8**
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
%9 = alloca double
store i32 %0, i32* %3
store i8** %1, i8*** %4
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %4
%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** %5
%21 = icmp ne i32* %20, null
br i1 %21, label %29, label %22
22: ; preds = %16
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %4
%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)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %16
%30 = load i8**, i8*** %4
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %33, i32** %6
%34 = icmp ne i32* %33, null
br i1 %34, label %42, label %35
35: ; preds = %29
%36 = load i32, i32* @stderr
%37 = load i8**, i8*** %4
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %29
%43 = call i64 (...) @clock()
store i64 %43, i64* %7
%44 = load i32*, i32** %5
%45 = load i32*, i32** %6
%46 = load i8**, i8*** %4
%47 = getelementptr inbounds i8*, i8** %46, i64 3
%48 = load i8*, i8** %47
%49 = call i32 @atoi(i8* %48)
%50 = call i32 @formatter(i32* %44, i32* %45, i32 %49)
%51 = call i64 (...) @clock()
store i64 %51, i64* %8
%52 = load i64, i64* %8
%53 = load i64, i64* %7
%54 = sub nsw i64 %52, %53
%55 = sitofp i64 %54 to double
%56 = load double, double* @CLOCKS_PER_SEC
%57 = fdiv double %55, %56
store double %57, double* %9
%58 = load i32, i32* @stderr
%59 = load double, double* %9
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), double %59)
%61 = load i32*, i32** %5
%62 = call i32 @fclose(i32* %61)
%63 = load i32*, i32** %6
%64 = call i32 @fclose(i32* %63)
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, 4
br i1 %3, label %4, label %8
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))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %9
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %8
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %19
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %18
%29 = tail call i64 (...) @clock()
%30 = getelementptr inbounds i8*, i8** %1, i64 3
%31 = load i8*, i8** %30
%32 = tail call i32 @atoi(i8* %31)
%33 = tail call i32 @formatter(i32* %11, i32* %21, i32 %32)
%34 = tail call i64 (...) @clock()
%35 = sub nsw i64 %34, %29
%36 = sitofp i64 %35 to double
%37 = load double, double* @CLOCKS_PER_SEC
%38 = fdiv double %36, %37
%39 = load i32, i32* @stderr
%40 = tail call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), double %38)
%41 = tail call i32 @fclose(i32* %11)
%42 = tail call i32 @fclose(i32* %21)
ret i32 0
}