#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 */

/* Variables and functions */
int EXIT_SUCCESS;
int atoi(char *);
int /*<<< orphan*/ read_test(int, unsigned long);
int /*<<< orphan*/ write_test(int, unsigned long);
int main(int argc, char *argv[]) {
  int read, should_seek;
  unsigned long file_size;
  read = (argc >= 2) ? atoi(argv[1]) : 0;
  should_seek = (argc >= 3) ? atoi(argv[2]) : 0;
  file_size = (argc >= 4) ? atoi(argv[3]) : 4 * 1024 * 1024;
  if (read) {
    read_test(should_seek, file_size);
  } else {
    write_test(should_seek, file_size);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1165 <main+0x35>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x24(%rbp)
jmp    116f <main+0x3f>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
jmp    116f <main+0x3f>
mov    -0x24(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     1194 <main+0x64>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x28(%rbp)
jmp    119e <main+0x6e>
xor    %eax,%eax
mov    %eax,-0x28(%rbp)
jmp    119e <main+0x6e>
mov    -0x28(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x4,-0x8(%rbp)
jl     11c3 <main+0x93>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x2c(%rbp)
jmp    11d0 <main+0xa0>
mov    $0x400000,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d0 <main+0xa0>
mov    -0x2c(%rbp),%eax
cltq
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11f4 <main+0xc4>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1030 <read_test@plt>
jmp    1200 <main+0xd0>
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1040 <write_test@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%edi
jl     118b <main+0x5b>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%r14d
mov    $0x400000,%r15d
xor    %r12d,%r12d
cmp    $0x2,%ebp
je     1179 <main+0x49>
mov    0x10(%rbx),%rdi
call   1050 <atoi@plt>
mov    %eax,%r12d
cmp    $0x4,%ebp
jb     1179 <main+0x49>
mov    0x18(%rbx),%rdi
call   1050 <atoi@plt>
movslq %eax,%r15
test   %r14d,%r14d
je     1194 <main+0x64>
mov    %r12d,%edi
mov    %r15,%rsi
call   1030 <read_test@plt>
jmp    119f <main+0x6f>
xor    %r12d,%r12d
mov    $0x400000,%r15d
mov    %r12d,%edi
mov    %r15,%rsi
call   1040 <write_test@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@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 i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp sge i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
br label %17
16: ; preds = %2
br label %17
17: ; preds = %16, %11
%18 = phi i32 [ %15, %11 ], [ 0, %16 ]
store i32 %18, i32* %6
%19 = load i32, i32* %4
%20 = icmp sge i32 %19, 3
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
br label %27
26: ; preds = %17
br label %27
27: ; preds = %26, %21
%28 = phi i32 [ %25, %21 ], [ 0, %26 ]
store i32 %28, i32* %7
%29 = load i32, i32* %4
%30 = icmp sge i32 %29, 4
br i1 %30, label %31, label %36
31: ; preds = %27
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 3
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
br label %37
36: ; preds = %27
br label %37
37: ; preds = %36, %31
%38 = phi i32 [ %35, %31 ], [ 4194304, %36 ]
%39 = sext i32 %38 to i64
store i64 %39, i64* %8
%40 = load i32, i32* %6
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %37
%43 = load i32, i32* %7
%44 = load i64, i64* %8
%45 = call i32 @read_test(i32 %43, i64 %44)
br label %50
46: ; preds = %37
%47 = load i32, i32* %7
%48 = load i64, i64* %8
%49 = call i32 @write_test(i32 %47, i64 %48)
br label %50
50: ; preds = %46, %42
%51 = load i32, i32* @EXIT_SUCCESS
ret i32 %51
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %25
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = icmp eq i32 %0, 2
br i1 %8, label %19, label %9
9: ; preds = %4
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = icmp ugt i32 %0, 3
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = sext i32 %17 to i64
br label %19
19: ; preds = %4, %9, %14
%20 = phi i32 [ %12, %14 ], [ %12, %9 ], [ 0, %4 ]
%21 = phi i64 [ %18, %14 ], [ 4194304, %9 ], [ 4194304, %4 ]
%22 = icmp eq i32 %7, 0
br i1 %22, label %25, label %23
23: ; preds = %19
%24 = tail call i32 @read_test(i32 %20, i64 %21)
br label %29
25: ; preds = %2, %19
%26 = phi i64 [ %21, %19 ], [ 4194304, %2 ]
%27 = phi i32 [ %20, %19 ], [ 0, %2 ]
%28 = tail call i32 @write_test(i32 %27, i64 %26)
br label %29
29: ; preds = %25, %23
%30 = load i32, i32* @EXIT_SUCCESS
ret i32 %30
}