#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 /*<<< orphan*/ POSIX_FADV_RANDOM;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ close(int);
int mkstemp(char *);
scalar_t__ posix_fadvise(int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ unlink(char *);
int main(void) {
  char file[] = "/tmp/dietlibc-fadvise-test.XXXXXX";
  int fd;
  fd = mkstemp(file);
  unlink(file);
  assert(posix_fadvise(fd, 23, 42, POSIX_FADV_RANDOM) == 0);
  close(fd);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe86(%rip),%rsi
mov    $0x22,%edx
call   1070 <memcpy@plt>
lea    -0x30(%rbp),%rdi
call   1080 <mkstemp@plt>
mov    %eax,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <unlink@plt>
mov    -0x34(%rbp),%edi
mov    0x2e3d(%rip),%rax
mov    (%rax),%ecx
mov    $0x17,%esi
mov    $0x2a,%edx
call   1050 <posix_fadvise@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x34(%rbp),%edi
call   1040 <close@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
movaps 0xeb3(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe97(%rip),%xmm0
movaps %xmm0,(%rsp)
movw   $0x58,0x20(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <mkstemp@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%ecx
mov    %ebp,%edi
mov    $0x17,%esi
mov    $0x2a,%edx
call   1050 <posix_fadvise@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
mov    %ebp,%edi
call   1040 <close@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.file = [34 x i8] c"/tmp/dietlibc-fadvise-test.XXXXXX\00"
@POSIX_FADV_RANDOM = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [34 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [34 x i8]* %2 to i8*
%5 = getelementptr inbounds [34 x i8], [34 x i8]* %2, i64 0, i64 0
%6 = call i32 @mkstemp(i8* %5)
store i32 %6, i32* %3
%7 = getelementptr inbounds [34 x i8], [34 x i8]* %2, i64 0, i64 0
%8 = call i32 @unlink(i8* %7)
%9 = load i32, i32* %3
%10 = load i32, i32* @POSIX_FADV_RANDOM
%11 = call i64 @posix_fadvise(i32 %9, i32 23, i32 42, i32 %10)
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i32, i32* %3
%16 = call i32 @close(i32 %15)
%17 = load i32, i32* @EXIT_SUCCESS
ret i32 %17
}

LLVM IR (-O2):
@__const.main.file = [34 x i8] c"/tmp/dietlibc-fadvise-test.XXXXXX\00"
@POSIX_FADV_RANDOM = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [34 x i8]
%2 = getelementptr inbounds [34 x i8], [34 x i8]* %1, i64 0, i64 0
%3 = call i32 @mkstemp(i8* %2)
%4 = call i32 @unlink(i8* %2)
%5 = load i32, i32* @POSIX_FADV_RANDOM
%6 = call i64 @posix_fadvise(i32 %3, i32 23, i32 42, i32 %5)
%7 = icmp eq i64 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = call i32 @close(i32 %3)
%11 = load i32, i32* @EXIT_SUCCESS
ret i32 %11
}