#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*/ O_RDWR;
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int posix_fadvise(int, int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
main(int argc, char **argv) {
  int fd, result;
  printf("Opening: %s\n", argv[1]);
  fd = open(argv[1], O_RDWR);
  printf("FD: %d\n", fd);
  result = posix_fadvise(fd, 0, 0, 4);
  printf("Result: %d\n", result);
  close(fd);
  _exit(0);
}


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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e5d(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
xor    %edx,%edx
mov    $0x4,%ecx
mov    %edx,%esi
call   1060 <posix_fadvise@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
xor    %edi,%edi
call   1030 <_exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%rdi
mov    0x2e77(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,%ebx
lea    0xe8c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x4,%ecx
call   1060 <posix_fadvise@plt>
lea    0xe74(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
call   1050 <close@plt>
xor    %edi,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"Opening: %s\0A\00"
@O_RDWR = global i32 0
@.str.1 = [8 x i8] c"FD: %d\0A\00"
@.str.2 = [12 x i8] c"Result: %d\0A\00"
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 i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = load i32, i32* @O_RDWR
%16 = call i32 @open(i8* %14, i32 %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %6
%20 = call i32 @posix_fadvise(i32 %19, i32 0, i32 0, i32 4)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %6
%24 = call i32 @close(i32 %23)
%25 = call i32 @_exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [13 x i8] c"Opening: %s\0A\00"
@O_RDWR = global i32 0
@.str.1 = [8 x i8] c"FD: %d\0A\00"
@.str.2 = [12 x i8] c"Result: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = load i8*, i8** %3
%7 = load i32, i32* @O_RDWR
%8 = tail call i32 @open(i8* %6, i32 %7)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = tail call i32 @posix_fadvise(i32 %8, i32 0, i32 0, i32 4)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = tail call i32 @close(i32 %8)
%13 = tail call i32 @_exit(i32 0)
unreachable
}