#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 LLONG_MAX;
int O_CREAT;
int O_WRONLY;
int POSIX_FADV_DONTNEED;
int POSIX_FADV_NORMAL;
int POSIX_FADV_RANDOM;
int POSIX_FADV_SEQUENTIAL;
int POSIX_FADV_WILLNEED;
int /*<<< orphan*/ S_IRWXU;
int /*<<< orphan*/ close(int);
int open(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ posix_fadvise(int, int, int, int);
int main() {
  int fd;
  fd = open("foobar", O_WRONLY | O_CREAT, S_IRWXU);
  posix_fadvise(fd, 0, 1024, POSIX_FADV_NORMAL);
  posix_fadvise(-1, 0, 1024, POSIX_FADV_RANDOM);
  posix_fadvise(fd, -1, 1024, POSIX_FADV_SEQUENTIAL);
  posix_fadvise(fd, 0, -1, POSIX_FADV_WILLNEED);
  posix_fadvise(fd, LLONG_MAX, 0, POSIX_FADV_DONTNEED);
  posix_fadvise(fd, 0x72345678deadbeefLL, 0, POSIX_FADV_DONTNEED);
  posix_fadvise(fd, 0, LLONG_MAX, POSIX_FADV_DONTNEED);
  posix_fadvise(fd, 0, 0x72345678deadbeefLL, POSIX_FADV_DONTNEED);
  posix_fadvise(fd, 0, 1024, -1);
  close(fd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
mov    0x2eb0(%rip),%rax
or     (%rax),%esi
mov    0x2e87(%rip),%rax
mov    (%rax),%edx
lea    0xea6(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e64(%rip),%rax
mov    (%rax),%ecx
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <posix_fadvise@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%ecx
mov    $0xffffffff,%edi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <posix_fadvise@plt>
mov    -0x4(%rbp),%edi
mov    0x2e0a(%rip),%rax
mov    (%rax),%ecx
mov    $0xffffffff,%esi
mov    $0x400,%edx
call   1040 <posix_fadvise@plt>
mov    -0x4(%rbp),%edi
mov    0x2e0f(%rip),%rax
mov    (%rax),%ecx
xor    %esi,%esi
mov    $0xffffffff,%edx
call   1040 <posix_fadvise@plt>
mov    -0x4(%rbp),%edi
mov    0x2def(%rip),%rax
mov    (%rax),%esi
mov    0x2e0e(%rip),%rax
mov    (%rax),%ecx
xor    %edx,%edx
call   1040 <posix_fadvise@plt>
mov    -0x4(%rbp),%edi
mov    0x2dfb(%rip),%rax
mov    (%rax),%ecx
mov    $0xdeadbeef,%esi
xor    %edx,%edx
call   1040 <posix_fadvise@plt>
mov    -0x4(%rbp),%edi
mov    0x2dbb(%rip),%rax
mov    (%rax),%edx
mov    0x2dda(%rip),%rax
mov    (%rax),%ecx
xor    %esi,%esi
call   1040 <posix_fadvise@plt>
mov    -0x4(%rbp),%edi
mov    0x2dc7(%rip),%rax
mov    (%rax),%ecx
xor    %esi,%esi
mov    $0xdeadbeef,%edx
call   1040 <posix_fadvise@plt>
mov    -0x4(%rbp),%edi
xor    %esi,%esi
mov    $0x400,%edx
mov    $0xffffffff,%ecx
call   1040 <posix_fadvise@plt>
mov    -0x4(%rbp),%edi
call   1030 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2e5c(%rip),%rax
mov    0x2eb5(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e8a(%rip),%rax
mov    (%rax),%edx
lea    0xea9(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebx
mov    0x2e6b(%rip),%rax
mov    (%rax),%ecx
mov    %ebx,%edi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <posix_fadvise@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%ecx
mov    $0xffffffff,%edi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <posix_fadvise@plt>
mov    0x2e12(%rip),%rax
mov    (%rax),%ecx
mov    %ebx,%edi
mov    $0xffffffff,%esi
mov    $0x400,%edx
call   1040 <posix_fadvise@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%ecx
mov    %ebx,%edi
xor    %esi,%esi
mov    $0xffffffff,%edx
call   1040 <posix_fadvise@plt>
mov    0x2df9(%rip),%r14
mov    (%r14),%esi
mov    0x2e17(%rip),%r15
mov    (%r15),%ecx
mov    %ebx,%edi
xor    %edx,%edx
call   1040 <posix_fadvise@plt>
mov    (%r15),%ecx
mov    %ebx,%edi
mov    $0xdeadbeef,%esi
xor    %edx,%edx
call   1040 <posix_fadvise@plt>
mov    (%r14),%edx
mov    (%r15),%ecx
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <posix_fadvise@plt>
mov    (%r15),%ecx
mov    %ebx,%edi
xor    %esi,%esi
mov    $0xdeadbeef,%edx
call   1040 <posix_fadvise@plt>
mov    %ebx,%edi
xor    %esi,%esi
mov    $0x400,%edx
mov    $0xffffffff,%ecx
call   1040 <posix_fadvise@plt>
mov    %ebx,%edi
call   1030 <close@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"foobar\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@S_IRWXU = global i32 0
@POSIX_FADV_NORMAL = global i32 0
@POSIX_FADV_RANDOM = global i32 0
@POSIX_FADV_SEQUENTIAL = global i32 0
@POSIX_FADV_WILLNEED = global i32 0
@LLONG_MAX = global i32 0
@POSIX_FADV_DONTNEED = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = load i32, i32* @O_WRONLY
%3 = load i32, i32* @O_CREAT
%4 = or i32 %2, %3
%5 = load i32, i32* @S_IRWXU
%6 = call i32 @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5)
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = load i32, i32* @POSIX_FADV_NORMAL
%9 = call i32 @posix_fadvise(i32 %7, i32 0, i32 1024, i32 %8)
%10 = load i32, i32* @POSIX_FADV_RANDOM
%11 = call i32 @posix_fadvise(i32 -1, i32 0, i32 1024, i32 %10)
%12 = load i32, i32* %1
%13 = load i32, i32* @POSIX_FADV_SEQUENTIAL
%14 = call i32 @posix_fadvise(i32 %12, i32 -1, i32 1024, i32 %13)
%15 = load i32, i32* %1
%16 = load i32, i32* @POSIX_FADV_WILLNEED
%17 = call i32 @posix_fadvise(i32 %15, i32 0, i32 -1, i32 %16)
%18 = load i32, i32* %1
%19 = load i32, i32* @LLONG_MAX
%20 = load i32, i32* @POSIX_FADV_DONTNEED
%21 = call i32 @posix_fadvise(i32 %18, i32 %19, i32 0, i32 %20)
%22 = load i32, i32* %1
%23 = load i32, i32* @POSIX_FADV_DONTNEED
%24 = call i32 @posix_fadvise(i32 %22, i32 -559038737, i32 0, i32 %23)
%25 = load i32, i32* %1
%26 = load i32, i32* @LLONG_MAX
%27 = load i32, i32* @POSIX_FADV_DONTNEED
%28 = call i32 @posix_fadvise(i32 %25, i32 0, i32 %26, i32 %27)
%29 = load i32, i32* %1
%30 = load i32, i32* @POSIX_FADV_DONTNEED
%31 = call i32 @posix_fadvise(i32 %29, i32 0, i32 -559038737, i32 %30)
%32 = load i32, i32* %1
%33 = call i32 @posix_fadvise(i32 %32, i32 0, i32 1024, i32 -1)
%34 = load i32, i32* %1
%35 = call i32 @close(i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"foobar\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@S_IRWXU = global i32 0
@POSIX_FADV_NORMAL = global i32 0
@POSIX_FADV_RANDOM = global i32 0
@POSIX_FADV_SEQUENTIAL = global i32 0
@POSIX_FADV_WILLNEED = global i32 0
@LLONG_MAX = global i32 0
@POSIX_FADV_DONTNEED = global i32 0
define i32 @main() {
%1 = load i32, i32* @O_WRONLY
%2 = load i32, i32* @O_CREAT
%3 = or i32 %2, %1
%4 = load i32, i32* @S_IRWXU
%5 = tail call i32 @open(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
%6 = load i32, i32* @POSIX_FADV_NORMAL
%7 = tail call i32 @posix_fadvise(i32 %5, i32 0, i32 1024, i32 %6)
%8 = load i32, i32* @POSIX_FADV_RANDOM
%9 = tail call i32 @posix_fadvise(i32 -1, i32 0, i32 1024, i32 %8)
%10 = load i32, i32* @POSIX_FADV_SEQUENTIAL
%11 = tail call i32 @posix_fadvise(i32 %5, i32 -1, i32 1024, i32 %10)
%12 = load i32, i32* @POSIX_FADV_WILLNEED
%13 = tail call i32 @posix_fadvise(i32 %5, i32 0, i32 -1, i32 %12)
%14 = load i32, i32* @LLONG_MAX
%15 = load i32, i32* @POSIX_FADV_DONTNEED
%16 = tail call i32 @posix_fadvise(i32 %5, i32 %14, i32 0, i32 %15)
%17 = load i32, i32* @POSIX_FADV_DONTNEED
%18 = tail call i32 @posix_fadvise(i32 %5, i32 -559038737, i32 0, i32 %17)
%19 = load i32, i32* @LLONG_MAX
%20 = load i32, i32* @POSIX_FADV_DONTNEED
%21 = tail call i32 @posix_fadvise(i32 %5, i32 0, i32 %19, i32 %20)
%22 = load i32, i32* @POSIX_FADV_DONTNEED
%23 = tail call i32 @posix_fadvise(i32 %5, i32 0, i32 -559038737, i32 %22)
%24 = tail call i32 @posix_fadvise(i32 %5, i32 0, i32 1024, i32 -1)
%25 = tail call i32 @close(i32 %5)
ret i32 0
}