#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 */
typedef int /*<<< orphan*/ tmpfname;
typedef int ssize_t;

/* Variables and functions */
void *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ MS_SYNC;
int O_CREAT;
int O_EXCL;
int O_RDWR;
int PROT_READ;
int PROT_WRITE;
int S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int getpid();
int /*<<< orphan*/ memset(char *, char, int);
void *mmap(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
scalar_t__ msync(void *, int, int /*<<< orphan*/);
int /*<<< orphan*/ munmap(void *, int);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ unlink(char *);
int write(int, char *, int);
int main(void) {
  char tmpfname[256];
  ssize_t size = 1024;
  char data[size];
  void *pa;
  int fd;
  snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_mmap_7_1_%d", getpid());
  unlink(tmpfname);
  fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR);
  if (fd == -1) {
    printf("Error at open(): %s\n", strerror(errno));
    return 2;
  }
  unlink(tmpfname);
  memset(data, 'a', size);
  if (write(fd, data, size) != size) {
    printf("Error at write(): %s\n", strerror(errno));
    return 2;
  }
  pa = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
  if (pa == MAP_FAILED) {
    printf("Error at mmap(): %s\n", strerror(errno));
    return 1;
  }
  *(char *)pa = 'b';
  if (msync(pa, size, MS_SYNC) != 0) {
    printf("Error at msync(): %s\n", strerror(errno));
    return 2;
  }
  munmap(pa, size);
  pa = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
  if (pa == MAP_FAILED) {
    printf("Error at 2nd mmap(): %s\n", strerror(errno));
    return 1;
  }
  if (*(char *)pa == 'b') {
    printf("Memory write with MAP_SHARED has changed "
           "the underlying file\n"
           "Test PASSED\n");
    close(fd);
    munmap(pa, size);
    return 0;
  }
  close(fd);
  munmap(pa, size);
  printf("Memory write with MAP_SHARED has not changed "
         "the underlying file\n"
         "Test FAILED\n");
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x400,-0x114(%rbp)
mov    -0x114(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x120(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x148(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x128(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x140(%rbp)
mov    $0x0,%al
call   1050 <getpid@plt>
mov    -0x140(%rbp),%rdi
mov    %eax,%ecx
mov    $0x100,%esi
lea    0xdc8(%rip),%rdx
call   1090 <snprintf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <unlink@plt>
lea    -0x110(%rbp),%rdi
mov    0x2da1(%rip),%rax
mov    (%rax),%esi
mov    0x2d70(%rip),%rax
or     (%rax),%esi
mov    0x2d4f(%rip),%rax
or     (%rax),%esi
mov    0x2d26(%rip),%rax
mov    (%rax),%edx
mov    0x2d4d(%rip),%rax
or     (%rax),%edx
call   10d0 <open@plt>
mov    %eax,-0x134(%rbp)
cmpl   $0xffffffff,-0x134(%rbp)
jne    12ca <main+0x10a>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    %rax,%rsi
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0x138(%rbp)
jmp    155a <main+0x39a>
lea    -0x110(%rbp),%rdi
call   1030 <unlink@plt>
mov    -0x148(%rbp),%rdi
mov    -0x114(%rbp),%edx
mov    $0x61,%esi
call   10a0 <memset@plt>
mov    -0x148(%rbp),%rsi
mov    -0x134(%rbp),%edi
mov    -0x114(%rbp),%edx
call   1040 <write@plt>
cmp    -0x114(%rbp),%eax
je     1346 <main+0x186>
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    %rax,%rsi
lea    0xd01(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0x138(%rbp)
jmp    155a <main+0x39a>
mov    -0x114(%rbp),%esi
mov    0x2c9d(%rip),%rax
mov    (%rax),%edx
mov    0x2c44(%rip),%rax
or     (%rax),%edx
mov    0x2c7b(%rip),%rax
mov    (%rax),%ecx
mov    -0x134(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1070 <mmap@plt>
mov    %rax,-0x130(%rbp)
mov    -0x130(%rbp),%rax
mov    0x2c01(%rip),%rcx
cmp    (%rcx),%rax
jne    13cd <main+0x20d>
mov    0x2c11(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    %rax,%rsi
lea    0xc90(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x138(%rbp)
jmp    155a <main+0x39a>
mov    -0x130(%rbp),%rax
movb   $0x62,(%rax)
mov    -0x130(%rbp),%rdi
mov    -0x114(%rbp),%esi
mov    0x2bbd(%rip),%rax
mov    (%rax),%edx
call   1060 <msync@plt>
cmp    $0x0,%rax
je     1431 <main+0x271>
mov    0x2bad(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    %rax,%rsi
lea    0xc41(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0x138(%rbp)
jmp    155a <main+0x39a>
mov    -0x130(%rbp),%rdi
mov    -0x114(%rbp),%esi
call   10c0 <munmap@plt>
mov    -0x114(%rbp),%esi
mov    0x2ba0(%rip),%rax
mov    (%rax),%edx
mov    0x2b47(%rip),%rax
or     (%rax),%edx
mov    0x2b7e(%rip),%rax
mov    (%rax),%ecx
mov    -0x134(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1070 <mmap@plt>
mov    %rax,-0x130(%rbp)
mov    -0x130(%rbp),%rax
mov    0x2b04(%rip),%rcx
cmp    (%rcx),%rax
jne    14ca <main+0x30a>
mov    0x2b14(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    %rax,%rsi
lea    0xbbe(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x138(%rbp)
jmp    155a <main+0x39a>
mov    -0x130(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x62,%eax
jne    151e <main+0x35e>
lea    0xba0(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x134(%rbp),%edi
call   10b0 <close@plt>
mov    -0x130(%rbp),%rdi
mov    -0x114(%rbp),%esi
call   10c0 <munmap@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x138(%rbp)
jmp    155a <main+0x39a>
mov    -0x134(%rbp),%edi
call   10b0 <close@plt>
mov    -0x130(%rbp),%rdi
mov    -0x114(%rbp),%esi
call   10c0 <munmap@plt>
lea    0xb8c(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x138(%rbp)
mov    -0x120(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x508,%rsp
mov    %rsp,%r15
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xe0e(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %eax,%ecx
call   10a0 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
mov    0x2de5(%rip),%rax
mov    0x2db6(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d93(%rip),%rax
or     (%rax),%esi
mov    0x2d6a(%rip),%rax
mov    0x2d93(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    %rbx,%rdi
call   10e0 <open@plt>
cmp    $0xffffffff,%eax
je     1304 <main+0x134>
mov    %eax,%ebp
mov    %rsp,%rdi
call   1030 <unlink@plt>
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x61,%esi
mov    $0x400,%edx
call   10b0 <memset@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
call   1050 <write@plt>
cmp    $0x400,%eax
jne    131b <main+0x14b>
mov    0x2d61(%rip),%rax
mov    0x2d0a(%rip),%r13
mov    0x0(%r13),%edx
or     (%rax),%edx
mov    0x2d3d(%rip),%rbx
mov    (%rbx),%ecx
xor    %edi,%edi
mov    $0x400,%esi
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1080 <mmap@plt>
mov    0x2cd2(%rip),%r12
cmp    (%r12),%rax
je     1354 <main+0x184>
mov    %rax,%r14
movb   $0x62,(%rax)
mov    0x2cd3(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
mov    $0x400,%esi
call   1070 <msync@plt>
test   %rax,%rax
je     137a <main+0x1aa>
mov    0x2cbc(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xd53(%rip),%rdi
jmp    1330 <main+0x160>
mov    0x2ca5(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xcfc(%rip),%rdi
jmp    1330 <main+0x160>
mov    0x2c8e(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xcfa(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x2,%eax
mov    %r15,%rsp
add    $0x508,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c55(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xcd7(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    $0x1,%eax
jmp    133f <main+0x16f>
mov    %r14,%rdi
mov    $0x400,%esi
call   10d0 <munmap@plt>
mov    0x0(%r13),%edx
mov    0x2c5e(%rip),%rax
or     (%rax),%edx
mov    (%rbx),%ecx
xor    %edi,%edi
mov    $0x400,%esi
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1080 <mmap@plt>
cmp    (%r12),%rax
je     13dd <main+0x20d>
mov    %rax,%r14
cmpb   $0x62,(%rax)
jne    13f7 <main+0x227>
lea    0xd14(%rip),%rdi
call   1040 <puts@plt>
mov    %ebp,%edi
call   10c0 <close@plt>
mov    %r14,%rdi
mov    $0x400,%esi
call   10d0 <munmap@plt>
xor    %eax,%eax
jmp    133f <main+0x16f>
mov    0x2bcc(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xc79(%rip),%rdi
jmp    1369 <main+0x199>
mov    %ebp,%edi
call   10c0 <close@plt>
mov    %r14,%rdi
mov    $0x400,%esi
call   10d0 <munmap@plt>
lea    0xc72(%rip),%rdi
call   1040 <puts@plt>
jmp    1373 <main+0x1a3>

LLVM IR (-O0):
@.str = [21 x i8] c"/tmp/pts_mmap_7_1_%d\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@O_EXCL = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.1 = [21 x i8] c"Error at open(): %s\0A\00"
@errno = global i32 0
@.str.2 = [22 x i8] c"Error at write(): %s\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.3 = [21 x i8] c"Error at mmap(): %s\0A\00"
@MS_SYNC = global i32 0
@.str.4 = [22 x i8] c"Error at msync(): %s\0A\00"
@.str.5 = [25 x i8] c"Error at 2nd mmap(): %s\0A\00"
@.str.6 = [74 x i8] c"Memory write with MAP_SHARED has changed the underlying file\0ATest PASSED\0A\00"
@.str.7 = [78 x i8] c"Memory write with MAP_SHARED has not changed the underlying file\0ATest FAILED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 1024, i32* %3
%9 = load i32, i32* %3
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %4
%12 = alloca i8, i64 %10
store i64 %10, i64* %5
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%14 = call i32 (...) @getpid()
%15 = call i32 @snprintf(i8* %13, i32 256, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%17 = call i32 @unlink(i8* %16)
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%19 = load i32, i32* @O_CREAT
%20 = load i32, i32* @O_RDWR
%21 = or i32 %19, %20
%22 = load i32, i32* @O_EXCL
%23 = or i32 %21, %22
%24 = load i32, i32* @S_IRUSR
%25 = load i32, i32* @S_IWUSR
%26 = or i32 %24, %25
%27 = call i32 @open(i8* %18, i32 %23, i32 %26)
store i32 %27, i32* %7
%28 = load i32, i32* %7
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %34
30: ; preds = %0
%31 = load i32, i32* @errno
%32 = call i8* @strerror(i32 %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %32)
store i32 2, i32* %1
store i32 1, i32* %8
br label %111
34: ; preds = %0
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%36 = call i32 @unlink(i8* %35)
%37 = load i32, i32* %3
%38 = call i32 @memset(i8* %12, i8 signext 97, i32 %37)
%39 = load i32, i32* %7
%40 = load i32, i32* %3
%41 = call i32 @write(i32 %39, i8* %12, i32 %40)
%42 = load i32, i32* %3
%43 = icmp ne i32 %41, %42
br i1 %43, label %44, label %48
44: ; preds = %34
%45 = load i32, i32* @errno
%46 = call i8* @strerror(i32 %45)
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %46)
store i32 2, i32* %1
store i32 1, i32* %8
br label %111
48: ; preds = %34
%49 = load i32, i32* %3
%50 = load i32, i32* @PROT_READ
%51 = load i32, i32* @PROT_WRITE
%52 = or i32 %50, %51
%53 = load i32, i32* @MAP_SHARED
%54 = load i32, i32* %7
%55 = call i8* @mmap(i32* null, i32 %49, i32 %52, i32 %53, i32 %54, i32 0)
store i8* %55, i8** %6
%56 = load i8*, i8** %6
%57 = load i8*, i8** @MAP_FAILED
%58 = icmp eq i8* %56, %57
br i1 %58, label %59, label %63
59: ; preds = %48
%60 = load i32, i32* @errno
%61 = call i8* @strerror(i32 %60)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %61)
store i32 1, i32* %1
store i32 1, i32* %8
br label %111
63: ; preds = %48
%64 = load i8*, i8** %6
store i8 98, i8* %64
%65 = load i8*, i8** %6
%66 = load i32, i32* %3
%67 = load i32, i32* @MS_SYNC
%68 = call i64 @msync(i8* %65, i32 %66, i32 %67)
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %63
%71 = load i32, i32* @errno
%72 = call i8* @strerror(i32 %71)
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %72)
store i32 2, i32* %1
store i32 1, i32* %8
br label %111
74: ; preds = %63
%75 = load i8*, i8** %6
%76 = load i32, i32* %3
%77 = call i32 @munmap(i8* %75, i32 %76)
%78 = load i32, i32* %3
%79 = load i32, i32* @PROT_READ
%80 = load i32, i32* @PROT_WRITE
%81 = or i32 %79, %80
%82 = load i32, i32* @MAP_SHARED
%83 = load i32, i32* %7
%84 = call i8* @mmap(i32* null, i32 %78, i32 %81, i32 %82, i32 %83, i32 0)
store i8* %84, i8** %6
%85 = load i8*, i8** %6
%86 = load i8*, i8** @MAP_FAILED
%87 = icmp eq i8* %85, %86
br i1 %87, label %88, label %92
88: ; preds = %74
%89 = load i32, i32* @errno
%90 = call i8* @strerror(i32 %89)
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %90)
store i32 1, i32* %1
store i32 1, i32* %8
br label %111
92: ; preds = %74
%93 = load i8*, i8** %6
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 98
br i1 %96, label %97, label %104
97: ; preds = %92
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.6, i64 0, i64 0))
%99 = load i32, i32* %7
%100 = call i32 @close(i32 %99)
%101 = load i8*, i8** %6
%102 = load i32, i32* %3
%103 = call i32 @munmap(i8* %101, i32 %102)
store i32 0, i32* %1
store i32 1, i32* %8
br label %111
104: ; preds = %92
%105 = load i32, i32* %7
%106 = call i32 @close(i32 %105)
%107 = load i8*, i8** %6
%108 = load i32, i32* %3
%109 = call i32 @munmap(i8* %107, i32 %108)
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %1
store i32 1, i32* %8
br label %111
111: ; preds = %104, %97, %88, %70, %59, %44, %30
%112 = load i8*, i8** %4
%113 = load i32, i32* %1
ret i32 %113
}

LLVM IR (-O2):
@.str = [21 x i8] c"/tmp/pts_mmap_7_1_%d\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@O_EXCL = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.1 = [21 x i8] c"Error at open(): %s\0A\00"
@errno = global i32 0
@.str.2 = [22 x i8] c"Error at write(): %s\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i8* null
@.str.3 = [21 x i8] c"Error at mmap(): %s\0A\00"
@MS_SYNC = global i32 0
@.str.4 = [22 x i8] c"Error at msync(): %s\0A\00"
@.str.5 = [25 x i8] c"Error at 2nd mmap(): %s\0A\00"
@str = [77 x i8] c"Memory write with MAP_SHARED has not changed the underlying file\0ATest FAILED\00"
@str.8 = [73 x i8] c"Memory write with MAP_SHARED has changed the underlying file\0ATest PASSED\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i8* @llvm.stacksave()
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = tail call i32 (...) @getpid()
%7 = call i32 @snprintf(i8* %2, i32 256, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @unlink(i8* %2)
%9 = load i32, i32* @O_CREAT
%10 = load i32, i32* @O_RDWR
%11 = or i32 %10, %9
%12 = load i32, i32* @O_EXCL
%13 = or i32 %11, %12
%14 = load i32, i32* @S_IRUSR
%15 = load i32, i32* @S_IWUSR
%16 = or i32 %15, %14
%17 = call i32 @open(i8* %2, i32 %13, i32 %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %23
19: ; preds = %0
%20 = load i32, i32* @errno
%21 = call i8* @strerror(i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %76
23: ; preds = %0
%24 = call i32 @unlink(i8* %2)
%25 = call i32 @memset(i8* %5, i8 signext 97, i32 1024)
%26 = call i32 @write(i32 %17, i8* %5, i32 1024)
%27 = icmp eq i32 %26, 1024
br i1 %27, label %32, label %28
28: ; preds = %23
%29 = load i32, i32* @errno
%30 = call i8* @strerror(i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %30)
br label %76
32: ; preds = %23
%33 = load i32, i32* @PROT_READ
%34 = load i32, i32* @PROT_WRITE
%35 = or i32 %34, %33
%36 = load i32, i32* @MAP_SHARED
%37 = call i8* @mmap(i32* null, i32 1024, i32 %35, i32 %36, i32 %17, i32 0)
%38 = load i8*, i8** @MAP_FAILED
%39 = icmp eq i8* %37, %38
br i1 %39, label %40, label %44
40: ; preds = %32
%41 = load i32, i32* @errno
%42 = call i8* @strerror(i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %42)
br label %76
44: ; preds = %32
store i8 98, i8* %37
%45 = load i32, i32* @MS_SYNC
%46 = call i64 @msync(i8* %37, i32 1024, i32 %45)
%47 = icmp eq i64 %46, 0
br i1 %47, label %52, label %48
48: ; preds = %44
%49 = load i32, i32* @errno
%50 = call i8* @strerror(i32 %49)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %50)
br label %76
52: ; preds = %44
%53 = call i32 @munmap(i8* %37, i32 1024)
%54 = load i32, i32* @PROT_READ
%55 = load i32, i32* @PROT_WRITE
%56 = or i32 %55, %54
%57 = load i32, i32* @MAP_SHARED
%58 = call i8* @mmap(i32* null, i32 1024, i32 %56, i32 %57, i32 %17, i32 0)
%59 = load i8*, i8** @MAP_FAILED
%60 = icmp eq i8* %58, %59
br i1 %60, label %61, label %65
61: ; preds = %52
%62 = load i32, i32* @errno
%63 = call i8* @strerror(i32 %62)
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %63)
br label %76
65: ; preds = %52
%66 = load i8, i8* %58
%67 = icmp eq i8 %66, 98
br i1 %67, label %68, label %72
68: ; preds = %65
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str.8, i64 0, i64 0))
%70 = call i32 @close(i32 %17)
%71 = call i32 @munmap(i8* %58, i32 1024)
br label %76
72: ; preds = %65
%73 = call i32 @close(i32 %17)
%74 = call i32 @munmap(i8* %58, i32 1024)
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @str, i64 0, i64 0))
br label %76
76: ; preds = %72, %68, %61, %48, %40, %28, %19
%77 = phi i32 [ 2, %19 ], [ 2, %28 ], [ 1, %40 ], [ 2, %48 ], [ 1, %61 ], [ 0, %68 ], [ 1, %72 ]
ret i32 %77
}