#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*/ stderr;
int /*<<< orphan*/ wocky(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
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();
  wocky(ifp, ofp);
  fprintf(ofp, "\n");
  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   1070 <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   1070 <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   1060 <wocky@plt>
mov    -0x20(%rbp),%rax
mov    %eax,%edi
lea    0xe15(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x28(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    0x2d94(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
movsd  -0x38(%rbp),%xmm0
lea    0xdbd(%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   %rbx
mov    %rsi,%r15
cmp    $0x2,%edi
jg     1174 <main+0x24>
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x8(%r15),%rdi
lea    0xe97(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    11a7 <main+0x57>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r15),%rdx
lea    0xe78(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x10(%r15),%rdi
lea    0xe7b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11da <main+0x8a>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
mov    0x10(%r15),%rdx
lea    0xe45(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1030 <clock@plt>
mov    %rax,%r15
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <wocky@plt>
lea    0xe4d(%rip),%rsi
mov    %ebx,%edi
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r15,%rax
cvtsi2sd %rax,%xmm0
mov    0x2dd3(%rip),%rax
divsd  (%rax),%xmm0
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
pop    %rbx
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"
@.str.4 = [2 x i8] c"\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.5 = [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 @wocky(i32* %42, i32* %43)
%45 = load i32*, i32** %7
%46 = ptrtoint i32* %45 to i32
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%48 = call i64 (...) @clock()
store i64 %48, i64* %9
%49 = load i64, i64* %9
%50 = load i64, i64* %8
%51 = sub nsw i64 %49, %50
%52 = sitofp i64 %51 to double
%53 = load double, double* @CLOCKS_PER_SEC
%54 = fdiv double %52, %53
store double %54, double* %10
%55 = load i32, i32* @stderr
%56 = load double, double* %10
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), double %56)
%58 = load i32*, i32** %6
%59 = call i32 @fclose(i32* %58)
%60 = load i32*, i32** %7
%61 = call i32 @fclose(i32* %60)
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"
@.str.4 = [2 x i8] c"\0A\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.5 = [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 @wocky(i32* %10, i32* %19)
%28 = ptrtoint i32* %19 to i64
%29 = trunc i64 %28 to i32
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%31 = tail call i64 (...) @clock()
%32 = sub nsw i64 %31, %26
%33 = sitofp i64 %32 to double
%34 = load double, double* @CLOCKS_PER_SEC
%35 = fdiv double %33, %34
%36 = load i32, i32* @stderr
%37 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), double %35)
%38 = tail call i32 @fclose(i32* %10)
%39 = tail call i32 @fclose(i32* %19)
ret i32 0
}