#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 */
void *MAP_FAILED;
int MAP_FILE;
int MAP_PRIVATE;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ PROT_NONE;
int /*<<< orphan*/ _SC_PAGESIZE;
int /*<<< orphan*/ fail(char *, unsigned long, unsigned long);
void *mmap(int /*<<< orphan*/ *, unsigned int const, int /*<<< orphan*/, int,
           int, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ pass(char *, unsigned long, unsigned long);
unsigned int sysconf(int /*<<< orphan*/);
int main(void) {
  const unsigned int PAGE_SIZE = sysconf(_SC_PAGESIZE);
  void *p;
  int fd;
  unsigned long a, b;
  fd = open("/dev/zero", O_RDONLY);
  if (fd == -1)
    return 1;
  p = mmap(NULL, PAGE_SIZE, PROT_NONE, MAP_PRIVATE | MAP_FILE, fd, 0);
  if (p == MAP_FAILED)
    return 1;
  a = (unsigned long)p;
  b = (unsigned long)p + PAGE_SIZE;
  pass("/proc/self/map_files/%lx-%lx", a, b);
  fail("/proc/self/map_files/ %lx-%lx", a, b);
  fail("/proc/self/map_files/%lx -%lx", a, b);
  fail("/proc/self/map_files/%lx- %lx", a, b);
  fail("/proc/self/map_files/%lx-%lx ", a, b);
  fail("/proc/self/map_files/0%lx-%lx", a, b);
  fail("/proc/self/map_files/%lx-0%lx", a, b);
  if (sizeof(long) == 4) {
    fail("/proc/self/map_files/100000000%lx-%lx", a, b);
    fail("/proc/self/map_files/%lx-100000000%lx", a, b);
  } else if (sizeof(long) == 8) {
    fail("/proc/self/map_files/10000000000000000%lx-%lx", a, b);
    fail("/proc/self/map_files/%lx-10000000000000000%lx", a, b);
  } else
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
call   1070 <sysconf@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
lea    0xe80(%rip),%rdi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    119e <main+0x4e>
movl   $0x1,-0x4(%rbp)
jmp    12c1 <main+0x171>
mov    -0x8(%rbp),%esi
mov    0x2e48(%rip),%rax
mov    (%rax),%edx
mov    0x2e0f(%rip),%rax
mov    (%rax),%ecx
mov    0x2e1e(%rip),%rax
or     (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2ddd(%rip),%rcx
cmp    (%rcx),%rax
jne    11f0 <main+0xa0>
movl   $0x1,-0x4(%rbp)
jmp    12c1 <main+0x171>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xdf5(%rip),%rdi
call   1040 <pass@plt>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xdfe(%rip),%rdi
call   1030 <fail@plt>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe08(%rip),%rdi
call   1030 <fail@plt>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe12(%rip),%rdi
call   1030 <fail@plt>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe1c(%rip),%rdi
call   1030 <fail@plt>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe26(%rip),%rdi
call   1030 <fail@plt>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe30(%rip),%rdi
call   1030 <fail@plt>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe3a(%rip),%rdi
call   1030 <fail@plt>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe54(%rip),%rdi
call   1030 <fail@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
call   1070 <sysconf@plt>
mov    %eax,%r14d
mov    0x2e74(%rip),%rax
mov    (%rax),%esi
lea    0xe8b(%rip),%rdi
call   1060 <open@plt>
mov    $0x1,%ebp
cmp    $0xffffffff,%eax
je     1270 <main+0x120>
mov    0x2e61(%rip),%rcx
mov    (%rcx),%edx
mov    0x2e28(%rip),%rsi
mov    0x2e39(%rip),%rcx
mov    (%rcx),%ecx
or     (%rsi),%ecx
xor    %edi,%edi
mov    %r14d,%esi
mov    %eax,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,%rbx
mov    0x2dfb(%rip),%rax
cmp    (%rax),%rbx
je     1270 <main+0x120>
mov    %r14d,%r14d
add    %rbx,%r14
lea    0xe37(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1040 <pass@plt>
lea    0xe42(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <fail@plt>
lea    0xe4e(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <fail@plt>
lea    0xe5a(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <fail@plt>
lea    0xe66(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <fail@plt>
lea    0xe72(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <fail@plt>
lea    0xe7e(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <fail@plt>
lea    0xe8a(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <fail@plt>
lea    0xea6(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <fail@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@_SC_PAGESIZE = global i32 0
@.str = [10 x i8] c"/dev/zero\00"
@O_RDONLY = global i32 0
@PROT_NONE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FILE = global i32 0
@MAP_FAILED = global i8* null
@.str.1 = [29 x i8] c"/proc/self/map_files/%lx-%lx\00"
@.str.2 = [30 x i8] c"/proc/self/map_files/ %lx-%lx\00"
@.str.3 = [30 x i8] c"/proc/self/map_files/%lx -%lx\00"
@.str.4 = [30 x i8] c"/proc/self/map_files/%lx- %lx\00"
@.str.5 = [30 x i8] c"/proc/self/map_files/%lx-%lx \00"
@.str.6 = [30 x i8] c"/proc/self/map_files/0%lx-%lx\00"
@.str.7 = [30 x i8] c"/proc/self/map_files/%lx-0%lx\00"
@.str.8 = [46 x i8] c"/proc/self/map_files/10000000000000000%lx-%lx\00"
@.str.9 = [46 x i8] c"/proc/self/map_files/%lx-10000000000000000%lx\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
%7 = load i32, i32* @_SC_PAGESIZE
%8 = call i32 @sysconf(i32 %7)
store i32 %8, i32* %2
%9 = load i32, i32* @O_RDONLY
%10 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %9)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %14
13: ; preds = %0
store i32 1, i32* %1
br label %61
14: ; preds = %0
%15 = load i32, i32* %2
%16 = load i32, i32* @PROT_NONE
%17 = load i32, i32* @MAP_PRIVATE
%18 = load i32, i32* @MAP_FILE
%19 = or i32 %17, %18
%20 = load i32, i32* %4
%21 = call i8* @mmap(i32* null, i32 %15, i32 %16, i32 %19, i32 %20, i32 0)
store i8* %21, i8** %3
%22 = load i8*, i8** %3
%23 = load i8*, i8** @MAP_FAILED
%24 = icmp eq i8* %22, %23
br i1 %24, label %25, label %26
25: ; preds = %14
store i32 1, i32* %1
br label %61
26: ; preds = %14
%27 = load i8*, i8** %3
%28 = ptrtoint i8* %27 to i64
store i64 %28, i64* %5
%29 = load i8*, i8** %3
%30 = ptrtoint i8* %29 to i64
%31 = load i32, i32* %2
%32 = zext i32 %31 to i64
%33 = add i64 %30, %32
store i64 %33, i64* %6
%34 = load i64, i64* %5
%35 = load i64, i64* %6
%36 = call i32 @pass(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i64 %34, i64 %35)
%37 = load i64, i64* %5
%38 = load i64, i64* %6
%39 = call i32 @fail(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i64 %37, i64 %38)
%40 = load i64, i64* %5
%41 = load i64, i64* %6
%42 = call i32 @fail(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i64 %40, i64 %41)
%43 = load i64, i64* %5
%44 = load i64, i64* %6
%45 = call i32 @fail(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i64 %43, i64 %44)
%46 = load i64, i64* %5
%47 = load i64, i64* %6
%48 = call i32 @fail(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i64 %46, i64 %47)
%49 = load i64, i64* %5
%50 = load i64, i64* %6
%51 = call i32 @fail(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i64 %49, i64 %50)
%52 = load i64, i64* %5
%53 = load i64, i64* %6
%54 = call i32 @fail(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i64 %52, i64 %53)
%55 = load i64, i64* %5
%56 = load i64, i64* %6
%57 = call i32 @fail(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0), i64 %55, i64 %56)
%58 = load i64, i64* %5
%59 = load i64, i64* %6
%60 = call i32 @fail(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0), i64 %58, i64 %59)
store i32 0, i32* %1
br label %61
61: ; preds = %26, %25, %13
%62 = load i32, i32* %1
ret i32 %62
}

LLVM IR (-O2):
@_SC_PAGESIZE = global i32 0
@.str = [10 x i8] c"/dev/zero\00"
@O_RDONLY = global i32 0
@PROT_NONE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FILE = global i32 0
@MAP_FAILED = global i8* null
@.str.1 = [29 x i8] c"/proc/self/map_files/%lx-%lx\00"
@.str.2 = [30 x i8] c"/proc/self/map_files/ %lx-%lx\00"
@.str.3 = [30 x i8] c"/proc/self/map_files/%lx -%lx\00"
@.str.4 = [30 x i8] c"/proc/self/map_files/%lx- %lx\00"
@.str.5 = [30 x i8] c"/proc/self/map_files/%lx-%lx \00"
@.str.6 = [30 x i8] c"/proc/self/map_files/0%lx-%lx\00"
@.str.7 = [30 x i8] c"/proc/self/map_files/%lx-0%lx\00"
@.str.8 = [46 x i8] c"/proc/self/map_files/10000000000000000%lx-%lx\00"
@.str.9 = [46 x i8] c"/proc/self/map_files/%lx-10000000000000000%lx\00"
define i32 @main() {
%1 = load i32, i32* @_SC_PAGESIZE
%2 = tail call i32 @sysconf(i32 %1)
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp eq i32 %4, -1
br i1 %5, label %27, label %6
6: ; preds = %0
%7 = load i32, i32* @PROT_NONE
%8 = load i32, i32* @MAP_PRIVATE
%9 = load i32, i32* @MAP_FILE
%10 = or i32 %9, %8
%11 = tail call i8* @mmap(i32* null, i32 %2, i32 %7, i32 %10, i32 %4, i32 0)
%12 = load i8*, i8** @MAP_FAILED
%13 = icmp eq i8* %11, %12
br i1 %13, label %27, label %14
14: ; preds = %6
%15 = ptrtoint i8* %11 to i64
%16 = zext i32 %2 to i64
%17 = add i64 %15, %16
%18 = tail call i32 @pass(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i64 %15, i64 %17)
%19 = tail call i32 @fail(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i64 %15, i64 %17)
%20 = tail call i32 @fail(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i64 %15, i64 %17)
%21 = tail call i32 @fail(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i64 %15, i64 %17)
%22 = tail call i32 @fail(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i64 %15, i64 %17)
%23 = tail call i32 @fail(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i64 %15, i64 %17)
%24 = tail call i32 @fail(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i64 %15, i64 %17)
%25 = tail call i32 @fail(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0), i64 %15, i64 %17)
%26 = tail call i32 @fail(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0), i64 %15, i64 %17)
br label %27
27: ; preds = %6, %0, %14
%28 = phi i32 [ 0, %14 ], [ 1, %0 ], [ 1, %6 ]
ret i32 %28
}