#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 EBADF;
int POSIX_FADV_NORMAL;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int posix_fadvise(int, int, int, int);
int /*<<< orphan*/ stderr;
int main() {
  int x;
  (void)posix_fadvise(x, 1, 2, POSIX_FADV_NORMAL);
  (void)posix_fadvise(42, x, 2, POSIX_FADV_NORMAL);
  (void)posix_fadvise(42, 1, x, POSIX_FADV_NORMAL);
  (void)posix_fadvise(42, 1, 2, x);
  x = posix_fadvise(42, 1, 2, POSIX_FADV_NORMAL);
  if (x != EBADF)
    fprintf(stderr, "Unexpected return value: %d\n", x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2eaf(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <posix_fadvise@plt>
mov    -0x8(%rbp),%esi
mov    0x2e94(%rip),%rax
mov    (%rax),%ecx
mov    $0x2a,%edi
mov    $0x2,%edx
call   1030 <posix_fadvise@plt>
mov    -0x8(%rbp),%edx
mov    0x2e79(%rip),%rax
mov    (%rax),%ecx
mov    $0x2a,%edi
mov    $0x1,%esi
call   1030 <posix_fadvise@plt>
mov    -0x8(%rbp),%ecx
mov    $0x2a,%edi
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <posix_fadvise@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%ecx
mov    $0x2a,%edi
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <posix_fadvise@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e0f(%rip),%rcx
cmp    (%rcx),%eax
je     11e1 <main+0xc1>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe24(%rip),%rsi
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2ec0(%rip),%rbx
mov    (%rbx),%ecx
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <posix_fadvise@plt>
mov    (%rbx),%ecx
mov    $0x2a,%edi
mov    $0x2,%edx
call   1030 <posix_fadvise@plt>
mov    (%rbx),%ecx
mov    $0x2a,%edi
mov    $0x1,%esi
call   1030 <posix_fadvise@plt>
mov    $0x2a,%edi
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <posix_fadvise@plt>
mov    (%rbx),%ecx
mov    $0x2a,%edi
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <posix_fadvise@plt>
mov    0x2e44(%rip),%rcx
cmp    (%rcx),%eax
je     11a7 <main+0x87>
mov    0x2e41(%rip),%rcx
mov    (%rcx),%edi
lea    0xe60(%rip),%rsi
mov    %eax,%edx
call   1040 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@POSIX_FADV_NORMAL = global i32 0
@EBADF = global i32 0
@stderr = global i32 0
@.str = [29 x i8] c"Unexpected return value: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* %2
%4 = load i32, i32* @POSIX_FADV_NORMAL
%5 = call i32 @posix_fadvise(i32 %3, i32 1, i32 2, i32 %4)
%6 = load i32, i32* %2
%7 = load i32, i32* @POSIX_FADV_NORMAL
%8 = call i32 @posix_fadvise(i32 42, i32 %6, i32 2, i32 %7)
%9 = load i32, i32* %2
%10 = load i32, i32* @POSIX_FADV_NORMAL
%11 = call i32 @posix_fadvise(i32 42, i32 1, i32 %9, i32 %10)
%12 = load i32, i32* %2
%13 = call i32 @posix_fadvise(i32 42, i32 1, i32 2, i32 %12)
%14 = load i32, i32* @POSIX_FADV_NORMAL
%15 = call i32 @posix_fadvise(i32 42, i32 1, i32 2, i32 %14)
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = load i32, i32* @EBADF
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %23
19: ; preds = %0
%20 = load i32, i32* @stderr
%21 = load i32, i32* %2
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %19, %0
ret i32 0
}

LLVM IR (-O2):
@POSIX_FADV_NORMAL = global i32 0
@EBADF = global i32 0
@stderr = global i32 0
@.str = [29 x i8] c"Unexpected return value: %d\0A\00"
define i32 @main() {
%1 = load i32, i32* @POSIX_FADV_NORMAL
%2 = tail call i32 @posix_fadvise(i32 undef, i32 1, i32 2, i32 %1)
%3 = load i32, i32* @POSIX_FADV_NORMAL
%4 = tail call i32 @posix_fadvise(i32 42, i32 undef, i32 2, i32 %3)
%5 = load i32, i32* @POSIX_FADV_NORMAL
%6 = tail call i32 @posix_fadvise(i32 42, i32 1, i32 undef, i32 %5)
%7 = tail call i32 @posix_fadvise(i32 42, i32 1, i32 2, i32 undef)
%8 = load i32, i32* @POSIX_FADV_NORMAL
%9 = tail call i32 @posix_fadvise(i32 42, i32 1, i32 2, i32 %8)
%10 = load i32, i32* @EBADF
%11 = icmp eq i32 %9, %10
br i1 %11, label %15, label %12
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %15
15: ; preds = %12, %0
ret i32 0
}