#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_DONTDUMP;
int MAP_ANONYMOUS;
int MAP_PRIVATE;
int MAP_SHARED;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ assert_perror(int /*<<< orphan*/);
char *do_mmap(int /*<<< orphan*/ *, size_t const, int const, int, int,
              int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int madvise(char *, size_t const, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int, size_t const);
int main(int argc, char *argv[]) {
  const size_t size = 10;
  const int default_prot = PROT_READ | PROT_WRITE;
  char *private_anon, *shared_anon;
  char *dont_dump;
  int i;
  private_anon =
      do_mmap(NULL, size, default_prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  memset(private_anon, 0x11, size);
  shared_anon =
      do_mmap(NULL, size, default_prot, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
  memset(shared_anon, 0x22, size);
  dont_dump =
      do_mmap(NULL, size, default_prot, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  memset(dont_dump, 0x55, size);
  i = madvise(dont_dump, size, MADV_DONTDUMP);
  assert_perror(errno);
  assert(i == 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0xa,-0x18(%rbp)
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    0x2e3a(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edx
mov    0x2e23(%rip),%rax
mov    (%rax),%ecx
mov    0x2e42(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xa,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <do_mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x11,%esi
mov    $0xa,%edx
call   1050 <memset@plt>
mov    -0x1c(%rbp),%edx
mov    0x2e18(%rip),%rax
mov    (%rax),%ecx
mov    0x2dff(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xa,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <do_mmap@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x22,%esi
mov    $0xa,%edx
call   1050 <memset@plt>
mov    -0x1c(%rbp),%edx
mov    0x2d9d(%rip),%rax
mov    (%rax),%ecx
mov    0x2dbc(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xa,%esi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <do_mmap@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    $0x55,%esi
mov    $0xa,%edx
call   1050 <memset@plt>
mov    -0x38(%rbp),%rdi
mov    0x2d69(%rip),%rax
mov    (%rax),%edx
mov    $0xa,%esi
call   1070 <madvise@plt>
mov    %eax,-0x3c(%rbp)
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
call   1040 <assert_perror@plt>
cmpl   $0x0,-0x3c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2e9c(%rip),%rax
mov    0x2e55(%rip),%rcx
mov    (%rcx),%ebx
or     (%rax),%ebx
mov    0x2e42(%rip),%r14
mov    0x2e63(%rip),%r15
mov    (%r15),%ecx
or     (%r14),%ecx
mov    $0xa,%esi
xor    %edi,%edi
mov    %ebx,%edx
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <do_mmap@plt>
mov    $0xa,%edx
mov    %rax,%rdi
mov    $0x11,%esi
call   1050 <memset@plt>
mov    0x2e3d(%rip),%rax
mov    (%r15),%ecx
or     (%rax),%ecx
mov    $0xa,%esi
xor    %edi,%edi
mov    %ebx,%edx
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <do_mmap@plt>
mov    $0xa,%edx
mov    %rax,%rdi
mov    $0x22,%esi
call   1050 <memset@plt>
mov    (%r15),%ecx
or     (%r14),%ecx
mov    $0xa,%esi
xor    %edi,%edi
mov    %ebx,%edx
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1030 <do_mmap@plt>
mov    %rax,%rbx
mov    $0xa,%edx
mov    %rax,%rdi
mov    $0x55,%esi
call   1050 <memset@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%edx
mov    $0xa,%esi
mov    %rbx,%rdi
call   1070 <madvise@plt>
mov    %eax,%ebx
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
call   1040 <assert_perror@plt>
xor    %edi,%edi
test   %ebx,%ebx
sete   %dil
call   1060 <assert@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_SHARED = global i32 0
@MADV_DONTDUMP = global i32 0
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 10, i64* %6
%12 = load i32, i32* @PROT_READ
%13 = load i32, i32* @PROT_WRITE
%14 = or i32 %12, %13
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = load i32, i32* @MAP_PRIVATE
%17 = load i32, i32* @MAP_ANONYMOUS
%18 = or i32 %16, %17
%19 = call i8* @do_mmap(i32* null, i64 10, i32 %15, i32 %18, i32 -1, i32 0)
store i8* %19, i8** %8
%20 = load i8*, i8** %8
%21 = call i32 @memset(i8* %20, i32 17, i64 10)
%22 = load i32, i32* %7
%23 = load i32, i32* @MAP_SHARED
%24 = load i32, i32* @MAP_ANONYMOUS
%25 = or i32 %23, %24
%26 = call i8* @do_mmap(i32* null, i64 10, i32 %22, i32 %25, i32 -1, i32 0)
store i8* %26, i8** %9
%27 = load i8*, i8** %9
%28 = call i32 @memset(i8* %27, i32 34, i64 10)
%29 = load i32, i32* %7
%30 = load i32, i32* @MAP_PRIVATE
%31 = load i32, i32* @MAP_ANONYMOUS
%32 = or i32 %30, %31
%33 = call i8* @do_mmap(i32* null, i64 10, i32 %29, i32 %32, i32 -1, i32 0)
store i8* %33, i8** %10
%34 = load i8*, i8** %10
%35 = call i32 @memset(i8* %34, i32 85, i64 10)
%36 = load i8*, i8** %10
%37 = load i32, i32* @MADV_DONTDUMP
%38 = call i32 @madvise(i8* %36, i64 10, i32 %37)
store i32 %38, i32* %11
%39 = load i32, i32* @errno
%40 = call i32 @assert_perror(i32 %39)
%41 = load i32, i32* %11
%42 = icmp eq i32 %41, 0
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
ret i32 0
}

LLVM IR (-O2):
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_SHARED = global i32 0
@MADV_DONTDUMP = global i32 0
@errno = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @PROT_READ
%4 = load i32, i32* @PROT_WRITE
%5 = or i32 %4, %3
%6 = load i32, i32* @MAP_PRIVATE
%7 = load i32, i32* @MAP_ANONYMOUS
%8 = or i32 %7, %6
%9 = tail call i8* @do_mmap(i32* null, i64 10, i32 %5, i32 %8, i32 -1, i32 0)
%10 = tail call i32 @memset(i8* %9, i32 17, i64 10)
%11 = load i32, i32* @MAP_SHARED
%12 = load i32, i32* @MAP_ANONYMOUS
%13 = or i32 %12, %11
%14 = tail call i8* @do_mmap(i32* null, i64 10, i32 %5, i32 %13, i32 -1, i32 0)
%15 = tail call i32 @memset(i8* %14, i32 34, i64 10)
%16 = load i32, i32* @MAP_PRIVATE
%17 = load i32, i32* @MAP_ANONYMOUS
%18 = or i32 %17, %16
%19 = tail call i8* @do_mmap(i32* null, i64 10, i32 %5, i32 %18, i32 -1, i32 0)
%20 = tail call i32 @memset(i8* %19, i32 85, i64 10)
%21 = load i32, i32* @MADV_DONTDUMP
%22 = tail call i32 @madvise(i8* %19, i64 10, i32 %21)
%23 = load i32, i32* @errno
%24 = tail call i32 @assert_perror(i32 %23)
%25 = icmp eq i32 %22, 0
%26 = zext i1 %25 to i32
%27 = tail call i32 @assert(i32 %26)
ret i32 0
}