#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 */
struct stat {
  unsigned long st_size;
};

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stat(char *, struct stat *);
double test(char *, char *, unsigned long, unsigned int, unsigned int);
int main(int argc, char *argv[]) {
  unsigned int t, threads, times;
  unsigned long size;
  char *filename, *output;
  double elapsed;
  struct stat st;
  if (argc < 3) {
    printf("Usage: ./%s FILE OUTPUT THREADS TIMES\n", argv[0]);
    return EXIT_FAILURE;
  }
  filename = argv[1];
  stat(filename, &st);
  size = st.st_size;
  output = argv[2];
  threads = argc > 3 ? atoi(argv[3]) : 4;
  times = argc > 4 ? atoi(argv[4]) : 1024;
  for (t = 1; t <= threads; t *= 2) {
    printf("AESMIX-ing with OAEP %s (%luB) with %d threads %d times\n",
           filename, size, t, times);
    elapsed = test(filename, output, size, t, times);
    printf("DONE in %f seconds.\n", elapsed);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1186 <main+0x46>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1291 <main+0x151>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    -0x48(%rbp),%rsi
call   1040 <stat@plt>
mov    -0x48(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    11d2 <main+0x92>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x4c(%rbp)
jmp    11df <main+0x9f>
mov    $0x4,%eax
mov    %eax,-0x4c(%rbp)
jmp    11df <main+0x9f>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x4,-0x8(%rbp)
jle    1204 <main+0xc4>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x50(%rbp)
jmp    1211 <main+0xd1>
mov    $0x400,%eax
mov    %eax,-0x50(%rbp)
jmp    1211 <main+0xd1>
mov    -0x50(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
ja     1285 <main+0x145>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
call   1060 <test@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
lea    0xdf0(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    121e <main+0xde>
mov    0x2d4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
cmp    $0x2,%edi
jg     1174 <main+0x34>
mov    0x0(%rbp),%rsi
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e71(%rip),%rax
jmp    1228 <main+0xe8>
mov    %edi,%ebx
mov    0x8(%rbp),%r14
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   1040 <stat@plt>
mov    0x10(%rsp),%r13
mov    0x10(%rbp),%r15
cmp    $0x3,%ebx
jne    11a2 <main+0x62>
mov    $0x4,%r12d
mov    $0x400,%ebp
jmp    11d2 <main+0x92>
mov    %rbp,0x8(%rsp)
mov    0x18(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%r12d
mov    $0x400,%ebp
cmp    $0x5,%ebx
jb     11cd <main+0x8d>
mov    0x8(%rsp),%rax
mov    0x20(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
test   %r12d,%r12d
je     1221 <main+0xe1>
mov    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
lea    0xe40(%rip),%rdi
mov    %r14,%rsi
mov    %r13,%rdx
mov    %ebx,%ecx
mov    %ebp,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
mov    %ebx,%ecx
mov    %ebp,%r8d
call   1060 <test@plt>
lea    0xe4d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    %ebx,%ebx
cmp    %r12d,%ebx
jbe    11e0 <main+0xa0>
mov    0x2db0(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i64 }
@.str = [39 x i8] c"Usage: ./%s FILE OUTPUT THREADS TIMES\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [57 x i8] c"AESMIX-ing with OAEP %s (%luB) with %d threads %d times\0A\00"
@.str.2 = [21 x i8] c"DONE in %f seconds.\0A\00"
@EXIT_SUCCESS = global i32 0
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 i64
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca double
%13 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 3
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
store i32 %21, i32* %3
br label %76
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
store i8* %25, i8** %10
%26 = load i8*, i8** %10
%27 = call i32 @stat(i8* %26, %struct.stat* %13)
%28 = getelementptr inbounds %struct.stat, %struct.stat* %13, i32 0, i32 0
%29 = load i64, i64* %28
store i64 %29, i64* %9
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
store i8* %32, i8** %11
%33 = load i32, i32* %4
%34 = icmp sgt i32 %33, 3
br i1 %34, label %35, label %40
35: ; preds = %22
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 3
%38 = load i8*, i8** %37
%39 = call i32 @atoi(i8* %38)
br label %41
40: ; preds = %22
br label %41
41: ; preds = %40, %35
%42 = phi i32 [ %39, %35 ], [ 4, %40 ]
store i32 %42, i32* %7
%43 = load i32, i32* %4
%44 = icmp sgt i32 %43, 4
br i1 %44, label %45, label %50
45: ; preds = %41
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 4
%48 = load i8*, i8** %47
%49 = call i32 @atoi(i8* %48)
br label %51
50: ; preds = %41
br label %51
51: ; preds = %50, %45
%52 = phi i32 [ %49, %45 ], [ 1024, %50 ]
store i32 %52, i32* %8
store i32 1, i32* %6
br label %53
53: ; preds = %71, %51
%54 = load i32, i32* %6
%55 = load i32, i32* %7
%56 = icmp ule i32 %54, %55
br i1 %56, label %57, label %74
57: ; preds = %53
%58 = load i8*, i8** %10
%59 = load i64, i64* %9
%60 = load i32, i32* %6
%61 = load i32, i32* %8
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i8* %58, i64 %59, i32 %60, i32 %61)
%63 = load i8*, i8** %10
%64 = load i8*, i8** %11
%65 = load i64, i64* %9
%66 = load i32, i32* %6
%67 = load i32, i32* %8
%68 = call double @test(i8* %63, i8* %64, i64 %65, i32 %66, i32 %67)
store double %68, double* %12
%69 = load double, double* %12
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %69)
br label %71
71: ; preds = %57
%72 = load i32, i32* %6
%73 = mul i32 %72, 2
store i32 %73, i32* %6
br label %53
74: ; preds = %53
%75 = load i32, i32* @EXIT_SUCCESS
store i32 %75, i32* %3
br label %76
76: ; preds = %74, %16
%77 = load i32, i32* %3
ret i32 %77
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@.str = [39 x i8] c"Usage: ./%s FILE OUTPUT THREADS TIMES\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [57 x i8] c"AESMIX-ing with OAEP %s (%luB) with %d threads %d times\0A\00"
@.str.2 = [21 x i8] c"DONE in %f seconds.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %40
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @stat(i8* %11, %struct.stat* %3)
%13 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%14 = load i64, i64* %13
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = icmp eq i32 %0, 3
br i1 %17, label %30, label %18
18: ; preds = %9
%19 = getelementptr inbounds i8*, i8** %1, i64 3
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
%22 = icmp ugt i32 %0, 4
br i1 %22, label %23, label %27
23: ; preds = %18
%24 = getelementptr inbounds i8*, i8** %1, i64 4
%25 = load i8*, i8** %24
%26 = tail call i32 @atoi(i8* %25)
br label %27
27: ; preds = %18, %23
%28 = phi i32 [ %26, %23 ], [ 1024, %18 ]
%29 = icmp eq i32 %21, 0
br i1 %29, label %40, label %30
30: ; preds = %9, %27
%31 = phi i32 [ %28, %27 ], [ 1024, %9 ]
%32 = phi i32 [ %21, %27 ], [ 4, %9 ]
br label %33
33: ; preds = %30, %33
%34 = phi i32 [ %38, %33 ], [ 1, %30 ]
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i8* %11, i64 %14, i32 %34, i32 %31)
%36 = tail call double @test(i8* %11, i8* %16, i64 %14, i32 %34, i32 %31)
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %36)
%38 = shl i32 %34, 1
%39 = icmp ugt i32 %38, %32
br i1 %39, label %40, label %33
40: ; preds = %33, %27, %6
%41 = phi i32* [ @EXIT_FAILURE, %6 ], [ @EXIT_SUCCESS, %27 ], [ @EXIT_SUCCESS, %33 ]
%42 = load i32, i32* %41
ret i32 %42
}