#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*/ MADV_DONTNEED;
int MAP_ANON;
int MAP_PRIVATE;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ _SC_PAGE_SIZE;
int /*<<< orphan*/ madvise(void *, size_t, int /*<<< orphan*/);
void *mmap(int /*<<< orphan*/ *, size_t, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ munmap(void *, size_t);
int sysconf(int /*<<< orphan*/);
int main(void) {
  size_t size = sysconf(_SC_PAGE_SIZE) * 1000;
  void *b = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON | 0,
                 -1, 0);
  madvise(b, size, MADV_DONTNEED);
  munmap(b, size);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
call   1060 <sysconf@plt>
imul   $0x3e8,%eax,%eax
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    0x2e84(%rip),%rax
mov    (%rax),%edx
mov    0x2e53(%rip),%rax
or     (%rax),%edx
mov    0x2e32(%rip),%rax
mov    (%rax),%ecx
mov    0x2e39(%rip),%rax
or     (%rax),%ecx
or     $0x0,%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e1f(%rip),%rax
mov    (%rax),%edx
call   1050 <madvise@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <munmap@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
call   1060 <sysconf@plt>
imul   $0x3e8,%eax,%eax
movslq %eax,%r14
mov    0x2e96(%rip),%rax
mov    0x2e67(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e44(%rip),%rax
mov    0x2e4d(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
xor    %edi,%edi
mov    %r14,%rsi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbx
mov    0x2e3c(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <madvise@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <munmap@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@_SC_PAGE_SIZE = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANON = global i32 0
@MADV_DONTNEED = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i8*
store i32 0, i32* %1
%4 = load i32, i32* @_SC_PAGE_SIZE
%5 = call i32 @sysconf(i32 %4)
%6 = mul nsw i32 %5, 1000
%7 = sext i32 %6 to i64
store i64 %7, i64* %2
%8 = load i64, i64* %2
%9 = load i32, i32* @PROT_READ
%10 = load i32, i32* @PROT_WRITE
%11 = or i32 %9, %10
%12 = load i32, i32* @MAP_PRIVATE
%13 = load i32, i32* @MAP_ANON
%14 = or i32 %12, %13
%15 = or i32 %14, 0
%16 = call i8* @mmap(i32* null, i64 %8, i32 %11, i32 %15, i32 -1, i32 0)
store i8* %16, i8** %3
%17 = load i8*, i8** %3
%18 = load i64, i64* %2
%19 = load i32, i32* @MADV_DONTNEED
%20 = call i32 @madvise(i8* %17, i64 %18, i32 %19)
%21 = load i8*, i8** %3
%22 = load i64, i64* %2
%23 = call i32 @munmap(i8* %21, i64 %22)
ret i32 0
}

LLVM IR (-O2):
@_SC_PAGE_SIZE = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANON = global i32 0
@MADV_DONTNEED = global i32 0
define i32 @main() {
%1 = load i32, i32* @_SC_PAGE_SIZE
%2 = tail call i32 @sysconf(i32 %1)
%3 = mul nsw i32 %2, 1000
%4 = sext i32 %3 to i64
%5 = load i32, i32* @PROT_READ
%6 = load i32, i32* @PROT_WRITE
%7 = or i32 %6, %5
%8 = load i32, i32* @MAP_PRIVATE
%9 = load i32, i32* @MAP_ANON
%10 = or i32 %9, %8
%11 = tail call i8* @mmap(i32* null, i64 %4, i32 %7, i32 %10, i32 -1, i32 0)
%12 = load i32, i32* @MADV_DONTNEED
%13 = tail call i32 @madvise(i8* %11, i64 %4, i32 %12)
%14 = tail call i32 @munmap(i8* %11, i64 %4)
ret i32 0
}