#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int POSIX_FADV_NOREUSE;
int POSIX_FADV_NORMAL;
int POSIX_FADV_SEQUENTIAL;
int POSIX_MADV_NORMAL;
int POSIX_MADV_SEQUENTIAL;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ my_fread(char *, int);
int /*<<< orphan*/ my_mmap(char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int args, char **argc) {
  if (args < 4 || args > 4) {
    fprintf(stderr, "give 3 cmdline args: filename and readmethod mmap or "
                    "fread and the flag part of POSIX_FADV_FLAG\n");
    exit(EXIT_FAILURE);
  }
  int advice;
  int madvice;
  if (args < 4) {
    advice = POSIX_FADV_NORMAL;
    madvice = POSIX_MADV_NORMAL;
  } else if (!strcmp(argc[3], "NOREUSE")) {
    advice = POSIX_FADV_NOREUSE;
    madvice = POSIX_MADV_NORMAL;
  } else if (!strcmp(argc[3], "NORMAL")) {
    advice = POSIX_FADV_NORMAL;
    madvice = POSIX_MADV_NORMAL;
  } else if (!strcmp(argc[3], "SEQUENTIAL")) {
    advice = POSIX_FADV_SEQUENTIAL;
    madvice = POSIX_MADV_SEQUENTIAL;
  } else {
    fprintf(stderr, "3rd argument not supported\n");
    exit(EXIT_FAILURE);
  }
  if (!strcmp(argc[2], "mmap")) {
    my_mmap(argc[1], madvice);
  } else {
    my_fread(argc[1], advice);
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jl     117a <main+0x2a>
cmpl   $0x4,-0x8(%rbp)
jle    119d <main+0x4d>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jge    11c4 <main+0x74>
mov    0x2e3a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e26(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
jmp    12a4 <main+0x154>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe8e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11fe <main+0xae>
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2dec(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
jmp    129f <main+0x14f>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe5c(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1238 <main+0xe8>
mov    0x2dc6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2db2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
jmp    129a <main+0x14a>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe29(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1272 <main+0x122>
mov    0x2d6c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2d48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
jmp    1295 <main+0x145>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
lea    0xdf9(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    129a <main+0x14a>
jmp    129f <main+0x14f>
jmp    12a4 <main+0x154>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xde4(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12d6 <main+0x186>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%esi
call   1040 <my_mmap@plt>
jmp    12e6 <main+0x196>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
call   1030 <my_fread@plt>
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x4,%edi
jne    1184 <main+0x34>
mov    %rsi,%r14
mov    0x18(%rsi),%rbx
lea    0xef9(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
mov    0x2e69(%rip),%r15
test   %eax,%eax
jne    11a7 <main+0x57>
mov    0x2e26(%rip),%rbx
jmp    11e4 <main+0x94>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    0xebb(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    11c3 <main+0x73>
mov    0x2e27(%rip),%rbx
jmp    11e4 <main+0x94>
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    121f <main+0xcf>
mov    0x2dd3(%rip),%r15
mov    0x2de4(%rip),%rbx
mov    0x10(%r14),%rdi
lea    0xea8(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    1206 <main+0xb6>
mov    (%r15),%esi
mov    0x8(%r14),%rdi
call   1040 <my_mmap@plt>
jmp    1211 <main+0xc1>
mov    (%rbx),%esi
mov    0x8(%r14),%rdi
call   1030 <my_fread@plt>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
lea    0xe4c(%rip),%rsi
jmp    1194 <main+0x44>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [97 x i8] c"give 3 cmdline args: filename and readmethod mmap or fread and the flag part of POSIX_FADV_FLAG\0A\00"
@EXIT_FAILURE = global i32 0
@POSIX_FADV_NORMAL = global i32 0
@POSIX_MADV_NORMAL = global i32 0
@.str.1 = [8 x i8] c"NOREUSE\00"
@POSIX_FADV_NOREUSE = global i32 0
@.str.2 = [7 x i8] c"NORMAL\00"
@.str.3 = [11 x i8] c"SEQUENTIAL\00"
@POSIX_FADV_SEQUENTIAL = global i32 0
@POSIX_MADV_SEQUENTIAL = global i32 0
@.str.4 = [28 x i8] c"3rd argument not supported\0A\00"
@.str.5 = [5 x i8] c"mmap\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 4
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 4
br i1 %12, label %13, label %18
13: ; preds = %10, %2
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %10
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 4
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* @POSIX_FADV_NORMAL
store i32 %22, i32* %6
%23 = load i32, i32* @POSIX_MADV_NORMAL
store i32 %23, i32* %7
br label %59
24: ; preds = %18
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 3
%27 = load i8*, i8** %26
%28 = call i32 @strcmp(i8* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp ne i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %24
%31 = load i32, i32* @POSIX_FADV_NOREUSE
store i32 %31, i32* %6
%32 = load i32, i32* @POSIX_MADV_NORMAL
store i32 %32, i32* %7
br label %58
33: ; preds = %24
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 3
%36 = load i8*, i8** %35
%37 = call i32 @strcmp(i8* %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%38 = icmp ne i32 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %33
%40 = load i32, i32* @POSIX_FADV_NORMAL
store i32 %40, i32* %6
%41 = load i32, i32* @POSIX_MADV_NORMAL
store i32 %41, i32* %7
br label %57
42: ; preds = %33
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 3
%45 = load i8*, i8** %44
%46 = call i32 @strcmp(i8* %45, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%47 = icmp ne i32 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %42
%49 = load i32, i32* @POSIX_FADV_SEQUENTIAL
store i32 %49, i32* %6
%50 = load i32, i32* @POSIX_MADV_SEQUENTIAL
store i32 %50, i32* %7
br label %56
51: ; preds = %42
%52 = load i32, i32* @stderr
%53 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %48
br label %57
57: ; preds = %56, %39
br label %58
58: ; preds = %57, %30
br label %59
59: ; preds = %58, %21
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 2
%62 = load i8*, i8** %61
%63 = call i32 @strcmp(i8* %62, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%64 = icmp ne i32 %63, 0
br i1 %64, label %71, label %65
65: ; preds = %59
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 1
%68 = load i8*, i8** %67
%69 = load i32, i32* %7
%70 = call i32 @my_mmap(i8* %68, i32 %69)
br label %77
71: ; preds = %59
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 1
%74 = load i8*, i8** %73
%75 = load i32, i32* %6
%76 = call i32 @my_fread(i8* %74, i32 %75)
br label %77
77: ; preds = %71, %65
%78 = load i32, i32* @EXIT_SUCCESS
%79 = call i32 @exit(i32 %78)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [97 x i8] c"give 3 cmdline args: filename and readmethod mmap or fread and the flag part of POSIX_FADV_FLAG\0A\00"
@EXIT_FAILURE = global i32 0
@POSIX_FADV_NORMAL = global i32 0
@POSIX_MADV_NORMAL = global i32 0
@.str.1 = [8 x i8] c"NOREUSE\00"
@POSIX_FADV_NOREUSE = global i32 0
@.str.2 = [7 x i8] c"NORMAL\00"
@.str.3 = [11 x i8] c"SEQUENTIAL\00"
@POSIX_FADV_SEQUENTIAL = global i32 0
@POSIX_MADV_SEQUENTIAL = global i32 0
@.str.4 = [28 x i8] c"3rd argument not supported\0A\00"
@.str.5 = [5 x i8] c"mmap\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([97 x i8], [97 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 3
%11 = load i8*, i8** %10
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %25, label %14
14: ; preds = %9
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %14
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %17, %14, %9
%26 = phi i32* [ @POSIX_FADV_NOREUSE, %9 ], [ @POSIX_FADV_NORMAL, %14 ], [ @POSIX_FADV_SEQUENTIAL, %17 ]
%27 = phi i32* [ @POSIX_MADV_NORMAL, %9 ], [ @POSIX_MADV_NORMAL, %14 ], [ @POSIX_MADV_SEQUENTIAL, %17 ]
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = tail call i32 @strcmp(i8* dereferenceable(1) %29, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %25
%33 = load i32, i32* %27
%34 = getelementptr inbounds i8*, i8** %1, i64 1
%35 = load i8*, i8** %34
%36 = tail call i32 @my_mmap(i8* %35, i32 %33)
br label %42
37: ; preds = %25
%38 = load i32, i32* %26
%39 = getelementptr inbounds i8*, i8** %1, i64 1
%40 = load i8*, i8** %39
%41 = tail call i32 @my_fread(i8* %40, i32 %38)
br label %42
42: ; preds = %37, %32
%43 = load i32, i32* @EXIT_SUCCESS
%44 = tail call i32 @exit(i32 %43)
unreachable
}