#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 */
char *MAP_FAILED;
int /*<<< orphan*/ MAP_PRIVATE;
int /*<<< orphan*/ MS_SYNC;
int O_CREAT;
int O_RDWR;
int O_TRUNC;
int O_WRONLY;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ close(int);
int errno;
int /*<<< orphan*/ exit(int);
scalar_t__ malloc(int);
char *mmap(char *, int, int, int /*<<< orphan*/, int, long);
scalar_t__ msync(char *, int, int /*<<< orphan*/);
scalar_t__ munmap(char *, int);
int open(char *, int, ...);
int /*<<< orphan*/ printf(char *, int);
char rand();
int read(int, char *, int);
int /*<<< orphan*/ umask(int /*<<< orphan*/);
int /*<<< orphan*/ unlink(char *);
int write(int, char *, int);
int main() {
  char *data, *data2, *data3;
  int i, pagesize;
  int fd;
  pagesize = 65536;
  data = (char *)malloc(pagesize);
  if (!data)
    exit(1);
  for (i = 0; i < pagesize; ++i)
    *(data + i) = rand();
  umask(0);
  fd = open("conftestmmap", O_CREAT | O_TRUNC | O_WRONLY | 0, 0600);
  if (fd < 0) {
    printf("creat: %d\n", errno);
    exit(1);
  }
  if (write(fd, data, pagesize) != pagesize) {
    printf("write: %d\n", errno);
    exit(1);
  }
  close(fd);
  fd = open("conftestmmap", O_RDWR | 0);
  if (fd < 0) {
    printf("write: %d\n", errno);
    exit(1);
  }
  if ((data2 = mmap(data2, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd,
                    0L)) == MAP_FAILED) {
    printf("mmap: %d\n", errno);
    exit(1);
  }
  for (i = 0; i < pagesize; ++i)
    if (*(data + i) != *(data2 + i)) {
      printf("check-if: %d\n", errno);
      exit(1);
    }
  for (i = 0; i < pagesize; ++i)
    *(data2 + i) = *(data2 + i) + 1;
  data3 = (char *)malloc(pagesize);
  if (!data3) {
    printf("malloc2: %d\n", errno);
    exit(1);
  }
  if (read(fd, data3, pagesize) != pagesize) {
    printf("read: %d\n", errno);
    exit(1);
  }
  for (i = 0; i < pagesize; ++i)
    if (*(data + i) != *(data3 + i)) {
      printf("check-if2: %d\n", errno);
      exit(1);
    }
  if (msync(data2, pagesize, MS_SYNC)) {
    printf("msync: %d\n", errno);
    exit(1);
  }
  if (munmap(data2, pagesize)) {
    printf("munmap: %d\n", errno);
    exit(1);
  }
  close(fd);
  unlink("conftestmmap");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x10000,-0x28(%rbp)
mov    -0x28(%rbp),%edi
call   10b0 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1207 <main+0x37>
mov    $0x1,%edi
call   10e0 <exit@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    123c <main+0x6c>
mov    $0x0,%al
call   10f0 <rand@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    120e <main+0x3e>
xor    %edi,%edi
call   10a0 <umask@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%esi
mov    0x2d9d(%rip),%rax
or     (%rax),%esi
mov    0x2d34(%rip),%rax
or     (%rax),%esi
or     $0x0,%esi
lea    0xd98(%rip),%rdi
mov    $0x180,%edx
mov    $0x0,%al
call   10d0 <open@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    12a0 <main+0xd0>
mov    0x2d38(%rip),%rax
mov    (%rax),%esi
lea    0xd7c(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x2c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%edx
call   1040 <write@plt>
cmp    -0x28(%rbp),%eax
je     12d7 <main+0x107>
mov    0x2d01(%rip),%rax
mov    (%rax),%esi
lea    0xd50(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x2c(%rbp),%edi
call   1080 <close@plt>
mov    0x2cea(%rip),%rax
mov    (%rax),%esi
or     $0x0,%esi
lea    0xd0e(%rip),%rdi
mov    $0x0,%al
call   10d0 <open@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1325 <main+0x155>
mov    0x2cb3(%rip),%rax
mov    (%rax),%esi
lea    0xd02(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    0x2cb5(%rip),%rax
mov    (%rax),%edx
mov    0x2c74(%rip),%rax
or     (%rax),%edx
mov    0x2c63(%rip),%rax
mov    (%rax),%ecx
mov    -0x2c(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%r9d
call   1060 <mmap@plt>
mov    %rax,-0x18(%rbp)
mov    0x2c40(%rip),%rcx
cmp    (%rcx),%rax
jne    1388 <main+0x1b8>
mov    0x2c50(%rip),%rax
mov    (%rax),%esi
lea    0xcaa(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    13ed <main+0x21d>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     13da <main+0x20a>
mov    0x2bfe(%rip),%rax
mov    (%rax),%esi
lea    0xc62(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
jmp    13df <main+0x20f>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    138f <main+0x1bf>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    142a <main+0x25a>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0x1,%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    13f4 <main+0x224>
mov    -0x28(%rbp),%edi
call   10b0 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1460 <main+0x290>
mov    0x2b78(%rip),%rax
mov    (%rax),%esi
lea    0xbea(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x2c(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%edx
call   1090 <read@plt>
cmp    -0x28(%rbp),%eax
je     1497 <main+0x2c7>
mov    0x2b41(%rip),%rax
mov    (%rax),%esi
lea    0xbc0(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    14fc <main+0x32c>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x20(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     14e9 <main+0x319>
mov    0x2aef(%rip),%rax
mov    (%rax),%esi
lea    0xb78(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
jmp    14ee <main+0x31e>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    149e <main+0x2ce>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    0x2aae(%rip),%rax
mov    (%rax),%edx
call   1050 <msync@plt>
cmp    $0x0,%rax
je     153a <main+0x36a>
mov    0x2a9e(%rip),%rax
mov    (%rax),%esi
lea    0xb36(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   10c0 <munmap@plt>
cmp    $0x0,%rax
je     156f <main+0x39f>
mov    0x2a69(%rip),%rax
mov    (%rax),%esi
lea    0xb0c(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x2c(%rbp),%edi
call   1080 <close@plt>
lea    0xa82(%rip),%rdi
call   1030 <unlink@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x10000,%edi
call   10b0 <malloc@plt>
test   %rax,%rax
jne    11f0 <main+0x20>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    %rax,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   10f0 <rand@plt>
mov    %al,(%rbx,%rbp,1)
add    $0x1,%rbp
cmp    $0x10000,%rbp
jne    1200 <main+0x30>
xor    %edi,%edi
call   10a0 <umask@plt>
mov    0x2dd3(%rip),%rax
mov    0x2dc4(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d59(%rip),%rax
or     (%rax),%esi
lea    0xdc0(%rip),%rdi
mov    $0x180,%edx
xor    %eax,%eax
call   10d0 <open@plt>
test   %eax,%eax
jns    1262 <main+0x92>
mov    0x2d69(%rip),%rax
mov    (%rax),%esi
lea    0xdad(%rip),%rdi
jmp    12ac <main+0xdc>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x10000,%edx
call   1040 <write@plt>
cmp    $0x10000,%eax
jne    129c <main+0xcc>
mov    %ebp,%edi
call   1080 <close@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%esi
lea    0xd6f(%rip),%rdi
xor    %eax,%eax
call   10d0 <open@plt>
test   %eax,%eax
jns    12bb <main+0xeb>
mov    0x2d1d(%rip),%rax
mov    (%rax),%esi
lea    0xd6c(%rip),%rdi
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    %eax,%r14d
mov    0x2d23(%rip),%rax
mov    0x2ce4(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2cd1(%rip),%rax
mov    (%rax),%ecx
mov    $0x10000,%esi
mov    %r14d,%r8d
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    %rax,%rbp
mov    0x2cad(%rip),%rax
cmp    (%rax),%rbp
jne    130a <main+0x13a>
mov    0x2cc1(%rip),%rax
mov    (%rax),%esi
lea    0xd1b(%rip),%rdi
jmp    12ac <main+0xdc>
mov    $0x3,%eax
nop
movzbl -0x3(%rbx,%rax,1),%ecx
cmp    -0x3(%rbp,%rax,1),%cl
jne    13d0 <main+0x200>
movzbl -0x2(%rbx,%rax,1),%ecx
cmp    -0x2(%rbp,%rax,1),%cl
jne    13d0 <main+0x200>
movzbl -0x1(%rbx,%rax,1),%ecx
cmp    -0x1(%rbp,%rax,1),%cl
jne    13d0 <main+0x200>
movzbl (%rbx,%rax,1),%ecx
cmp    0x0(%rbp,%rax,1),%cl
jne    13d0 <main+0x200>
add    $0x4,%rax
cmp    $0x10003,%rax
jne    1310 <main+0x140>
mov    $0x30,%eax
pcmpeqd %xmm0,%xmm0
movdqu -0x30(%rbp,%rax,1),%xmm1
movdqu -0x20(%rbp,%rax,1),%xmm2
movdqu -0x10(%rbp,%rax,1),%xmm3
movdqu 0x0(%rbp,%rax,1),%xmm4
psubb  %xmm0,%xmm1
psubb  %xmm0,%xmm2
movdqu %xmm1,-0x30(%rbp,%rax,1)
movdqu %xmm2,-0x20(%rbp,%rax,1)
psubb  %xmm0,%xmm3
psubb  %xmm0,%xmm4
movdqu %xmm3,-0x10(%rbp,%rax,1)
movdqu %xmm4,0x0(%rbp,%rax,1)
add    $0x40,%rax
cmp    $0x10030,%rax
jne    1360 <main+0x190>
mov    $0x10000,%edi
call   10b0 <malloc@plt>
test   %rax,%rax
jne    13e5 <main+0x215>
mov    0x2bfe(%rip),%rax
mov    (%rax),%esi
lea    0xc70(%rip),%rdi
jmp    12ac <main+0xdc>
mov    0x2be9(%rip),%rax
mov    (%rax),%esi
lea    0xc4d(%rip),%rdi
jmp    12ac <main+0xdc>
mov    %rax,%r15
mov    %r14d,%edi
mov    %rax,%rsi
mov    $0x10000,%edx
call   1090 <read@plt>
cmp    $0x10000,%eax
jne    149a <main+0x2ca>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rbx,%rax,1),%ecx
cmp    (%r15,%rax,1),%cl
jne    14af <main+0x2df>
movzbl 0x1(%rbx,%rax,1),%ecx
cmp    0x1(%r15,%rax,1),%cl
jne    14af <main+0x2df>
movzbl 0x2(%rbx,%rax,1),%ecx
cmp    0x2(%r15,%rax,1),%cl
jne    14af <main+0x2df>
movzbl 0x3(%rbx,%rax,1),%ecx
cmp    0x3(%r15,%rax,1),%cl
jne    14af <main+0x2df>
add    $0x4,%rax
cmp    $0x10000,%rax
jne    1410 <main+0x240>
mov    0x2b5f(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    $0x10000,%esi
call   1050 <msync@plt>
test   %rax,%rax
jne    14c4 <main+0x2f4>
mov    %rbp,%rdi
mov    $0x10000,%esi
call   10c0 <munmap@plt>
test   %rax,%rax
jne    14d9 <main+0x309>
mov    %r14d,%edi
call   1080 <close@plt>
lea    0xb72(%rip),%rdi
call   1030 <unlink@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    0x2b1f(%rip),%rax
mov    (%rax),%esi
lea    0xb9e(%rip),%rdi
jmp    12ac <main+0xdc>
mov    0x2b0a(%rip),%rax
mov    (%rax),%esi
lea    0xb93(%rip),%rdi
jmp    12ac <main+0xdc>
mov    0x2af5(%rip),%rax
mov    (%rax),%esi
lea    0xb8d(%rip),%rdi
jmp    12ac <main+0xdc>
mov    0x2ae0(%rip),%rax
mov    (%rax),%esi
lea    0xb83(%rip),%rdi
jmp    12ac <main+0xdc>

LLVM IR (-O0):
@.str = [13 x i8] c"conftestmmap\00"
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_WRONLY = global i32 0
@.str.1 = [11 x i8] c"creat: %d\0A\00"
@errno = global i32 0
@.str.2 = [11 x i8] c"write: %d\0A\00"
@O_RDWR = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FAILED = global i8* null
@.str.3 = [10 x i8] c"mmap: %d\0A\00"
@.str.4 = [14 x i8] c"check-if: %d\0A\00"
@.str.5 = [13 x i8] c"malloc2: %d\0A\00"
@.str.6 = [10 x i8] c"read: %d\0A\00"
@.str.7 = [15 x i8] c"check-if2: %d\0A\00"
@MS_SYNC = global i32 0
@.str.8 = [11 x i8] c"msync: %d\0A\00"
@.str.9 = [12 x i8] c"munmap: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 65536, i32* %6
%8 = load i32, i32* %6
%9 = call i64 @malloc(i32 %8)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %2
%11 = load i8*, i8** %2
%12 = icmp ne i8* %11, null
br i1 %12, label %15, label %13
13: ; preds = %0
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %0
store i32 0, i32* %5
br label %16
16: ; preds = %26, %15
%17 = load i32, i32* %5
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %29
20: ; preds = %16
%21 = call signext i8 (...) @rand()
%22 = load i8*, i8** %2
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8 %21, i8* %25
br label %26
26: ; preds = %20
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %16
29: ; preds = %16
%30 = call i32 @umask(i32 0)
%31 = load i32, i32* @O_CREAT
%32 = load i32, i32* @O_TRUNC
%33 = or i32 %31, %32
%34 = load i32, i32* @O_WRONLY
%35 = or i32 %33, %34
%36 = or i32 %35, 0
%37 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %36, i32 384)
store i32 %37, i32* %7
%38 = load i32, i32* %7
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %29
%41 = load i32, i32* @errno
%42 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %41)
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %29
%45 = load i32, i32* %7
%46 = load i8*, i8** %2
%47 = load i32, i32* %6
%48 = call i32 @write(i32 %45, i8* %46, i32 %47)
%49 = load i32, i32* %6
%50 = icmp ne i32 %48, %49
br i1 %50, label %51, label %55
51: ; preds = %44
%52 = load i32, i32* @errno
%53 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %52)
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %44
%56 = load i32, i32* %7
%57 = call i32 @close(i32 %56)
%58 = load i32, i32* @O_RDWR
%59 = or i32 %58, 0
%60 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %59)
store i32 %60, i32* %7
%61 = load i32, i32* %7
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %67
63: ; preds = %55
%64 = load i32, i32* @errno
%65 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %64)
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %55
%68 = load i8*, i8** %3
%69 = load i32, i32* %6
%70 = load i32, i32* @PROT_READ
%71 = load i32, i32* @PROT_WRITE
%72 = or i32 %70, %71
%73 = load i32, i32* @MAP_PRIVATE
%74 = load i32, i32* %7
%75 = call i8* @mmap(i8* %68, i32 %69, i32 %72, i32 %73, i32 %74, i64 0)
store i8* %75, i8** %3
%76 = load i8*, i8** @MAP_FAILED
%77 = icmp eq i8* %75, %76
br i1 %77, label %78, label %82
78: ; preds = %67
%79 = load i32, i32* @errno
%80 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %79)
%81 = call i32 @exit(i32 1)
unreachable
82: ; preds = %67
store i32 0, i32* %5
br label %83
83: ; preds = %106, %82
%84 = load i32, i32* %5
%85 = load i32, i32* %6
%86 = icmp slt i32 %84, %85
br i1 %86, label %87, label %109
87: ; preds = %83
%88 = load i8*, i8** %2
%89 = load i32, i32* %5
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %88, i64 %90
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = load i8*, i8** %3
%95 = load i32, i32* %5
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %94, i64 %96
%98 = load i8, i8* %97
%99 = sext i8 %98 to i32
%100 = icmp ne i32 %93, %99
br i1 %100, label %101, label %105
101: ; preds = %87
%102 = load i32, i32* @errno
%103 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %102)
%104 = call i32 @exit(i32 1)
unreachable
105: ; preds = %87
br label %106
106: ; preds = %105
%107 = load i32, i32* %5
%108 = add nsw i32 %107, 1
store i32 %108, i32* %5
br label %83
109: ; preds = %83
store i32 0, i32* %5
br label %110
110: ; preds = %127, %109
%111 = load i32, i32* %5
%112 = load i32, i32* %6
%113 = icmp slt i32 %111, %112
br i1 %113, label %114, label %130
114: ; preds = %110
%115 = load i8*, i8** %3
%116 = load i32, i32* %5
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i8, i8* %115, i64 %117
%119 = load i8, i8* %118
%120 = sext i8 %119 to i32
%121 = add nsw i32 %120, 1
%122 = trunc i32 %121 to i8
%123 = load i8*, i8** %3
%124 = load i32, i32* %5
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds i8, i8* %123, i64 %125
store i8 %122, i8* %126
br label %127
127: ; preds = %114
%128 = load i32, i32* %5
%129 = add nsw i32 %128, 1
store i32 %129, i32* %5
br label %110
130: ; preds = %110
%131 = load i32, i32* %6
%132 = call i64 @malloc(i32 %131)
%133 = inttoptr i64 %132 to i8*
store i8* %133, i8** %4
%134 = load i8*, i8** %4
%135 = icmp ne i8* %134, null
br i1 %135, label %140, label %136
136: ; preds = %130
%137 = load i32, i32* @errno
%138 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %137)
%139 = call i32 @exit(i32 1)
unreachable
140: ; preds = %130
%141 = load i32, i32* %7
%142 = load i8*, i8** %4
%143 = load i32, i32* %6
%144 = call i32 @read(i32 %141, i8* %142, i32 %143)
%145 = load i32, i32* %6
%146 = icmp ne i32 %144, %145
br i1 %146, label %147, label %151
147: ; preds = %140
%148 = load i32, i32* @errno
%149 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %148)
%150 = call i32 @exit(i32 1)
unreachable
151: ; preds = %140
store i32 0, i32* %5
br label %152
152: ; preds = %175, %151
%153 = load i32, i32* %5
%154 = load i32, i32* %6
%155 = icmp slt i32 %153, %154
br i1 %155, label %156, label %178
156: ; preds = %152
%157 = load i8*, i8** %2
%158 = load i32, i32* %5
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds i8, i8* %157, i64 %159
%161 = load i8, i8* %160
%162 = sext i8 %161 to i32
%163 = load i8*, i8** %4
%164 = load i32, i32* %5
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds i8, i8* %163, i64 %165
%167 = load i8, i8* %166
%168 = sext i8 %167 to i32
%169 = icmp ne i32 %162, %168
br i1 %169, label %170, label %174
170: ; preds = %156
%171 = load i32, i32* @errno
%172 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %171)
%173 = call i32 @exit(i32 1)
unreachable
174: ; preds = %156
br label %175
175: ; preds = %174
%176 = load i32, i32* %5
%177 = add nsw i32 %176, 1
store i32 %177, i32* %5
br label %152
178: ; preds = %152
%179 = load i8*, i8** %3
%180 = load i32, i32* %6
%181 = load i32, i32* @MS_SYNC
%182 = call i64 @msync(i8* %179, i32 %180, i32 %181)
%183 = icmp ne i64 %182, 0
br i1 %183, label %184, label %188
184: ; preds = %178
%185 = load i32, i32* @errno
%186 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %185)
%187 = call i32 @exit(i32 1)
unreachable
188: ; preds = %178
%189 = load i8*, i8** %3
%190 = load i32, i32* %6
%191 = call i64 @munmap(i8* %189, i32 %190)
%192 = icmp ne i64 %191, 0
br i1 %192, label %193, label %197
193: ; preds = %188
%194 = load i32, i32* @errno
%195 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %194)
%196 = call i32 @exit(i32 1)
unreachable
197: ; preds = %188
%198 = load i32, i32* %7
%199 = call i32 @close(i32 %198)
%200 = call i32 @unlink(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%201 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [13 x i8] c"conftestmmap\00"
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_WRONLY = global i32 0
@.str.1 = [11 x i8] c"creat: %d\0A\00"
@errno = global i32 0
@.str.2 = [11 x i8] c"write: %d\0A\00"
@O_RDWR = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_FAILED = global i8* null
@.str.3 = [10 x i8] c"mmap: %d\0A\00"
@.str.4 = [14 x i8] c"check-if: %d\0A\00"
@.str.5 = [13 x i8] c"malloc2: %d\0A\00"
@.str.6 = [10 x i8] c"read: %d\0A\00"
@.str.7 = [15 x i8] c"check-if2: %d\0A\00"
@MS_SYNC = global i32 0
@.str.8 = [11 x i8] c"msync: %d\0A\00"
@.str.9 = [12 x i8] c"munmap: %d\0A\00"
define i32 @main() {
%1 = tail call i64 @malloc(i32 65536)
%2 = inttoptr i64 %1 to i8*
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %0, %6
%7 = phi i64 [ %10, %6 ], [ 0, %0 ]
%8 = tail call signext i8 (...) @rand()
%9 = getelementptr inbounds i8, i8* %2, i64 %7
store i8 %8, i8* %9
%10 = add nuw nsw i64 %7, 1
%11 = icmp eq i64 %10, 65536
br i1 %11, label %12, label %6
12: ; preds = %6
%13 = tail call i32 @umask(i32 0)
%14 = load i32, i32* @O_CREAT
%15 = load i32, i32* @O_TRUNC
%16 = or i32 %15, %14
%17 = load i32, i32* @O_WRONLY
%18 = or i32 %16, %17
%19 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %18, i32 384)
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %12
%22 = load i32, i32* @errno
%23 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %12
%26 = tail call i32 @write(i32 %19, i8* %2, i32 65536)
%27 = icmp eq i32 %26, 65536
br i1 %27, label %32, label %28
28: ; preds = %25
%29 = load i32, i32* @errno
%30 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %25
%33 = tail call i32 @close(i32 %19)
%34 = load i32, i32* @O_RDWR
%35 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %34)
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %41
37: ; preds = %32
%38 = load i32, i32* @errno
%39 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = tail call i32 @exit(i32 1)
unreachable
41: ; preds = %32
%42 = load i32, i32* @PROT_READ
%43 = load i32, i32* @PROT_WRITE
%44 = or i32 %43, %42
%45 = load i32, i32* @MAP_PRIVATE
%46 = tail call i8* @mmap(i8* undef, i32 65536, i32 %44, i32 %45, i32 %35, i64 0)
%47 = load i8*, i8** @MAP_FAILED
%48 = icmp eq i8* %46, %47
br i1 %48, label %49, label %102
49: ; preds = %41
%50 = load i32, i32* @errno
%51 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %50)
%52 = tail call i32 @exit(i32 1)
unreachable
53: ; preds = %102
%54 = or i64 %103, 1
%55 = getelementptr inbounds i8, i8* %2, i64 %54
%56 = load i8, i8* %55
%57 = getelementptr inbounds i8, i8* %46, i64 %54
%58 = load i8, i8* %57
%59 = icmp eq i8 %56, %58
br i1 %59, label %60, label %109
60: ; preds = %53
%61 = or i64 %103, 2
%62 = getelementptr inbounds i8, i8* %2, i64 %61
%63 = load i8, i8* %62
%64 = getelementptr inbounds i8, i8* %46, i64 %61
%65 = load i8, i8* %64
%66 = icmp eq i8 %63, %65
br i1 %66, label %67, label %109
67: ; preds = %60
%68 = or i64 %103, 3
%69 = getelementptr inbounds i8, i8* %2, i64 %68
%70 = load i8, i8* %69
%71 = getelementptr inbounds i8, i8* %46, i64 %68
%72 = load i8, i8* %71
%73 = icmp eq i8 %70, %72
br i1 %73, label %74, label %109
74: ; preds = %67
%75 = add nuw nsw i64 %103, 4
%76 = icmp eq i64 %75, 65536
br i1 %76, label %77, label %102
77: ; preds = %74, %77
%78 = phi i64 [ %100, %77 ], [ 0, %74 ]
%79 = getelementptr inbounds i8, i8* %46, i64 %78
%80 = bitcast i8* %79 to <16 x i8>*
%81 = load <16 x i8>, <16 x i8>* %80
%82 = getelementptr inbounds i8, i8* %79, i64 16
%83 = bitcast i8* %82 to <16 x i8>*
%84 = load <16 x i8>, <16 x i8>* %83
%85 = add <16 x i8> %81, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%86 = add <16 x i8> %84, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%87 = bitcast i8* %79 to <16 x i8>*
store <16 x i8> %85, <16 x i8>* %87
%88 = bitcast i8* %82 to <16 x i8>*
store <16 x i8> %86, <16 x i8>* %88
%89 = or i64 %78, 32
%90 = getelementptr inbounds i8, i8* %46, i64 %89
%91 = bitcast i8* %90 to <16 x i8>*
%92 = load <16 x i8>, <16 x i8>* %91
%93 = getelementptr inbounds i8, i8* %90, i64 16
%94 = bitcast i8* %93 to <16 x i8>*
%95 = load <16 x i8>, <16 x i8>* %94
%96 = add <16 x i8> %92, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%97 = add <16 x i8> %95, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
%98 = bitcast i8* %90 to <16 x i8>*
store <16 x i8> %96, <16 x i8>* %98
%99 = bitcast i8* %93 to <16 x i8>*
store <16 x i8> %97, <16 x i8>* %99
%100 = add nuw nsw i64 %78, 64
%101 = icmp eq i64 %100, 65536
br i1 %101, label %113, label %77
102: ; preds = %41, %74
%103 = phi i64 [ %75, %74 ], [ 0, %41 ]
%104 = getelementptr inbounds i8, i8* %2, i64 %103
%105 = load i8, i8* %104
%106 = getelementptr inbounds i8, i8* %46, i64 %103
%107 = load i8, i8* %106
%108 = icmp eq i8 %105, %107
br i1 %108, label %53, label %109
109: ; preds = %67, %60, %53, %102
%110 = load i32, i32* @errno
%111 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %110)
%112 = tail call i32 @exit(i32 1)
unreachable
113: ; preds = %77
%114 = tail call i64 @malloc(i32 65536)
%115 = inttoptr i64 %114 to i8*
%116 = icmp eq i64 %114, 0
br i1 %116, label %117, label %121
117: ; preds = %113
%118 = load i32, i32* @errno
%119 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %118)
%120 = tail call i32 @exit(i32 1)
unreachable
121: ; preds = %113
%122 = tail call i32 @read(i32 %35, i8* %115, i32 65536)
%123 = icmp eq i32 %122, 65536
br i1 %123, label %152, label %124
124: ; preds = %121
%125 = load i32, i32* @errno
%126 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %125)
%127 = tail call i32 @exit(i32 1)
unreachable
128: ; preds = %152
%129 = or i64 %153, 1
%130 = getelementptr inbounds i8, i8* %2, i64 %129
%131 = load i8, i8* %130
%132 = getelementptr inbounds i8, i8* %115, i64 %129
%133 = load i8, i8* %132
%134 = icmp eq i8 %131, %133
br i1 %134, label %135, label %159
135: ; preds = %128
%136 = or i64 %153, 2
%137 = getelementptr inbounds i8, i8* %2, i64 %136
%138 = load i8, i8* %137
%139 = getelementptr inbounds i8, i8* %115, i64 %136
%140 = load i8, i8* %139
%141 = icmp eq i8 %138, %140
br i1 %141, label %142, label %159
142: ; preds = %135
%143 = or i64 %153, 3
%144 = getelementptr inbounds i8, i8* %2, i64 %143
%145 = load i8, i8* %144
%146 = getelementptr inbounds i8, i8* %115, i64 %143
%147 = load i8, i8* %146
%148 = icmp eq i8 %145, %147
br i1 %148, label %149, label %159
149: ; preds = %142
%150 = add nuw nsw i64 %153, 4
%151 = icmp eq i64 %150, 65536
br i1 %151, label %163, label %152
152: ; preds = %121, %149
%153 = phi i64 [ %150, %149 ], [ 0, %121 ]
%154 = getelementptr inbounds i8, i8* %2, i64 %153
%155 = load i8, i8* %154
%156 = getelementptr inbounds i8, i8* %115, i64 %153
%157 = load i8, i8* %156
%158 = icmp eq i8 %155, %157
br i1 %158, label %128, label %159
159: ; preds = %142, %135, %128, %152
%160 = load i32, i32* @errno
%161 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %160)
%162 = tail call i32 @exit(i32 1)
unreachable
163: ; preds = %149
%164 = load i32, i32* @MS_SYNC
%165 = tail call i64 @msync(i8* %46, i32 65536, i32 %164)
%166 = icmp eq i64 %165, 0
br i1 %166, label %171, label %167
167: ; preds = %163
%168 = load i32, i32* @errno
%169 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 %168)
%170 = tail call i32 @exit(i32 1)
unreachable
171: ; preds = %163
%172 = tail call i64 @munmap(i8* %46, i32 65536)
%173 = icmp eq i64 %172, 0
br i1 %173, label %178, label %174
174: ; preds = %171
%175 = load i32, i32* @errno
%176 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i32 %175)
%177 = tail call i32 @exit(i32 1)
unreachable
178: ; preds = %171
%179 = tail call i32 @close(i32 %35)
%180 = tail call i32 @unlink(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%181 = tail call i32 @exit(i32 0)
unreachable
}