#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 scalar_t__ 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 /*<<< orphan*/ free(char *);
int getpid();
char *malloc(scalar_t__);
int /*<<< orphan*/ memset(char *, char, scalar_t__);
void *mmap(int /*<<< orphan*/ *, scalar_t__, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
scalar_t__ msync(void *, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ munmap(void *, scalar_t__);
int open(char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ unlink(char *);
scalar_t__ write(int, char *, scalar_t__);
int main(void) {
  char tmpfname[256];
  char *data;
  void *pa;
  ssize_t size = 1024;
  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);
  data = malloc(size);
  memset(data, 'a', size);
  if (write(fd, data, size) != size) {
    printf("Error at write(): %s\n", strerror(errno));
    return 2;
  }
  free(data);
  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    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x400,-0x128(%rbp)
lea    -0x110(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    -0x138(%rbp),%rdi
mov    %eax,%ecx
mov    $0x100,%esi
lea    0xdd9(%rip),%rdx
call   10a0 <snprintf@plt>
lea    -0x110(%rbp),%rdi
call   1040 <unlink@plt>
lea    -0x110(%rbp),%rdi
mov    0x2db2(%rip),%rax
mov    (%rax),%esi
mov    0x2d81(%rip),%rax
or     (%rax),%esi
mov    0x2d60(%rip),%rax
or     (%rax),%esi
mov    0x2d37(%rip),%rax
mov    (%rax),%edx
mov    0x2d5e(%rip),%rax
or     (%rax),%edx
call   10f0 <open@plt>
mov    %eax,-0x12c(%rbp)
cmpl   $0xffffffff,-0x12c(%rbp)
jne    12af <main+0xcf>
mov    0x2d25(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %rax,%rsi
lea    0xd79(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    152b <main+0x34b>
lea    -0x110(%rbp),%rdi
call   1040 <unlink@plt>
mov    -0x128(%rbp),%rdi
call   10d0 <malloc@plt>
mov    %rax,-0x118(%rbp)
mov    -0x118(%rbp),%rdi
mov    -0x128(%rbp),%rdx
mov    $0x61,%esi
call   10b0 <memset@plt>
mov    -0x12c(%rbp),%edi
mov    -0x118(%rbp),%rsi
mov    -0x128(%rbp),%rdx
call   1050 <write@plt>
cmp    -0x128(%rbp),%rax
je     1337 <main+0x157>
mov    0x2c9d(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %rax,%rsi
lea    0xd06(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    152b <main+0x34b>
mov    -0x118(%rbp),%rdi
call   1030 <free@plt>
mov    -0x128(%rbp),%rsi
mov    0x2c9f(%rip),%rax
mov    (%rax),%edx
mov    0x2c46(%rip),%rax
or     (%rax),%edx
mov    0x2c7d(%rip),%rax
mov    (%rax),%ecx
mov    -0x12c(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1080 <mmap@plt>
mov    %rax,-0x120(%rbp)
mov    -0x120(%rbp),%rax
mov    0x2c03(%rip),%rcx
cmp    (%rcx),%rax
jne    13c1 <main+0x1e1>
mov    0x2c13(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %rax,%rsi
lea    0xc92(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    152b <main+0x34b>
mov    -0x120(%rbp),%rax
movb   $0x62,(%rax)
mov    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rsi
mov    0x2bc8(%rip),%rax
mov    (%rax),%edx
call   1070 <msync@plt>
cmp    $0x0,%rax
je     141c <main+0x23c>
mov    0x2bb8(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %rax,%rsi
lea    0xc4c(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    152b <main+0x34b>
mov    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rsi
call   10e0 <munmap@plt>
mov    -0x128(%rbp),%rsi
mov    0x2bb3(%rip),%rax
mov    (%rax),%edx
mov    0x2b5a(%rip),%rax
or     (%rax),%edx
mov    0x2b91(%rip),%rax
mov    (%rax),%ecx
mov    -0x12c(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1080 <mmap@plt>
mov    %rax,-0x120(%rbp)
mov    -0x120(%rbp),%rax
mov    0x2b17(%rip),%rcx
cmp    (%rcx),%rax
jne    14ad <main+0x2cd>
mov    0x2b27(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    %rax,%rsi
lea    0xbd1(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    152b <main+0x34b>
mov    -0x120(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x62,%eax
jne    14f8 <main+0x318>
lea    0xbbd(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x12c(%rbp),%edi
call   10c0 <close@plt>
mov    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rsi
call   10e0 <munmap@plt>
movl   $0x0,-0x4(%rbp)
jmp    152b <main+0x34b>
mov    -0x12c(%rbp),%edi
call   10c0 <close@plt>
mov    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rsi
call   10e0 <munmap@plt>
lea    0xbb1(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
xor    %eax,%eax
call   1070 <getpid@plt>
lea    0xdf1(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %eax,%ecx
call   10b0 <snprintf@plt>
mov    %rbx,%rdi
call   1040 <unlink@plt>
mov    0x2dc8(%rip),%rax
mov    0x2d99(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d76(%rip),%rax
or     (%rax),%esi
mov    0x2d4d(%rip),%rax
mov    0x2d76(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    %rbx,%rdi
call   1100 <open@plt>
cmp    $0xffffffff,%eax
je     1331 <main+0x141>
mov    %eax,%ebp
mov    %rsp,%rdi
call   1040 <unlink@plt>
mov    $0x400,%edi
call   10e0 <malloc@plt>
mov    %rax,%rbx
mov    $0x400,%edx
mov    %rax,%rdi
mov    $0x61,%esi
call   10c0 <memset@plt>
mov    $0x400,%edx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <write@plt>
cmp    $0x400,%rax
jne    1348 <main+0x158>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2d36(%rip),%r14
mov    0x2cdf(%rip),%r15
mov    (%r15),%edx
or     (%r14),%edx
mov    0x2d12(%rip),%r12
mov    (%r12),%ecx
mov    $0x400,%esi
xor    %edi,%edi
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1090 <mmap@plt>
mov    0x2ca5(%rip),%r13
cmp    0x0(%r13),%rax
je     137e <main+0x18e>
mov    %rax,%rbx
movb   $0x62,(%rax)
mov    0x2ca6(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
mov    %rbx,%rdi
call   1080 <msync@plt>
test   %rax,%rax
je     13a4 <main+0x1b4>
mov    0x2c8f(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xd26(%rip),%rdi
jmp    135d <main+0x16d>
mov    0x2c78(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xccf(%rip),%rdi
jmp    135d <main+0x16d>
mov    0x2c61(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xccd(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    $0x2,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c2b(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xcad(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    $0x1,%eax
jmp    136c <main+0x17c>
mov    $0x400,%esi
mov    %rbx,%rdi
call   10f0 <munmap@plt>
mov    (%r15),%edx
or     (%r14),%edx
mov    (%r12),%ecx
mov    $0x400,%esi
xor    %edi,%edi
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1090 <mmap@plt>
cmp    0x0(%r13),%rax
je     1402 <main+0x212>
mov    %rax,%r14
cmpb   $0x62,(%rax)
jne    141c <main+0x22c>
lea    0xcef(%rip),%rdi
call   1050 <puts@plt>
mov    %ebp,%edi
call   10d0 <close@plt>
mov    $0x400,%esi
mov    %r14,%rdi
call   10f0 <munmap@plt>
xor    %eax,%eax
jmp    136c <main+0x17c>
mov    0x2ba7(%rip),%rax
mov    (%rax),%edi
call   1110 <strerror@plt>
lea    0xc54(%rip),%rdi
jmp    1393 <main+0x1a3>
mov    %ebp,%edi
call   10d0 <close@plt>
mov    $0x400,%esi
mov    %r14,%rdi
call   10f0 <munmap@plt>
lea    0xc4d(%rip),%rdi
call   1050 <puts@plt>
jmp    139d <main+0x1ad>

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 i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i32 0, i32* %1
store i64 1024, i64* %5
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%8 = call i32 (...) @getpid()
%9 = call i32 @snprintf(i8* %7, i32 256, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%11 = call i32 @unlink(i8* %10)
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%13 = load i32, i32* @O_CREAT
%14 = load i32, i32* @O_RDWR
%15 = or i32 %13, %14
%16 = load i32, i32* @O_EXCL
%17 = or i32 %15, %16
%18 = load i32, i32* @S_IRUSR
%19 = load i32, i32* @S_IWUSR
%20 = or i32 %18, %19
%21 = call i32 @open(i8* %12, i32 %17, i32 %20)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %28
24: ; preds = %0
%25 = load i32, i32* @errno
%26 = call i8* @strerror(i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %26)
store i32 2, i32* %1
br label %111
28: ; preds = %0
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%30 = call i32 @unlink(i8* %29)
%31 = load i64, i64* %5
%32 = call i8* @malloc(i64 %31)
store i8* %32, i8** %3
%33 = load i8*, i8** %3
%34 = load i64, i64* %5
%35 = call i32 @memset(i8* %33, i8 signext 97, i64 %34)
%36 = load i32, i32* %6
%37 = load i8*, i8** %3
%38 = load i64, i64* %5
%39 = call i64 @write(i32 %36, i8* %37, i64 %38)
%40 = load i64, i64* %5
%41 = icmp ne i64 %39, %40
br i1 %41, label %42, label %46
42: ; preds = %28
%43 = load i32, i32* @errno
%44 = call i8* @strerror(i32 %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %44)
store i32 2, i32* %1
br label %111
46: ; preds = %28
%47 = load i8*, i8** %3
%48 = call i32 @free(i8* %47)
%49 = load i64, i64* %5
%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* %6
%55 = call i8* @mmap(i32* null, i64 %49, i32 %52, i32 %53, i32 %54, i32 0)
store i8* %55, i8** %4
%56 = load i8*, i8** %4
%57 = load i8*, i8** @MAP_FAILED
%58 = icmp eq i8* %56, %57
br i1 %58, label %59, label %63
59: ; preds = %46
%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
br label %111
63: ; preds = %46
%64 = load i8*, i8** %4
store i8 98, i8* %64
%65 = load i8*, i8** %4
%66 = load i64, i64* %5
%67 = load i32, i32* @MS_SYNC
%68 = call i64 @msync(i8* %65, i64 %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
br label %111
74: ; preds = %63
%75 = load i8*, i8** %4
%76 = load i64, i64* %5
%77 = call i32 @munmap(i8* %75, i64 %76)
%78 = load i64, i64* %5
%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* %6
%84 = call i8* @mmap(i32* null, i64 %78, i32 %81, i32 %82, i32 %83, i32 0)
store i8* %84, i8** %4
%85 = load i8*, i8** %4
%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
br label %111
92: ; preds = %74
%93 = load i8*, i8** %4
%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* %6
%100 = call i32 @close(i32 %99)
%101 = load i8*, i8** %4
%102 = load i64, i64* %5
%103 = call i32 @munmap(i8* %101, i64 %102)
store i32 0, i32* %1
br label %111
104: ; preds = %92
%105 = load i32, i32* %6
%106 = call i32 @close(i32 %105)
%107 = load i8*, i8** %4
%108 = load i64, i64* %5
%109 = call i32 @munmap(i8* %107, i64 %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
br label %111
111: ; preds = %104, %97, %88, %70, %59, %42, %24
%112 = load i32, i32* %1
ret i32 %112
}

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 i32 (...) @getpid()
%4 = call i32 @snprintf(i8* %2, i32 256, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = call i32 @unlink(i8* %2)
%6 = load i32, i32* @O_CREAT
%7 = load i32, i32* @O_RDWR
%8 = or i32 %7, %6
%9 = load i32, i32* @O_EXCL
%10 = or i32 %8, %9
%11 = load i32, i32* @S_IRUSR
%12 = load i32, i32* @S_IWUSR
%13 = or i32 %12, %11
%14 = call i32 @open(i8* %2, i32 %10, i32 %13)
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %20
16: ; preds = %0
%17 = load i32, i32* @errno
%18 = call i8* @strerror(i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %75
20: ; preds = %0
%21 = call i32 @unlink(i8* %2)
%22 = call dereferenceable_or_null(1024) i8* @malloc(i64 1024)
%23 = call i32 @memset(i8* %22, i8 signext 97, i64 1024)
%24 = call i64 @write(i32 %14, i8* %22, i64 1024)
%25 = icmp eq i64 %24, 1024
br i1 %25, label %30, label %26
26: ; preds = %20
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %75
30: ; preds = %20
%31 = call i32 @free(i8* %22)
%32 = load i32, i32* @PROT_READ
%33 = load i32, i32* @PROT_WRITE
%34 = or i32 %33, %32
%35 = load i32, i32* @MAP_SHARED
%36 = call i8* @mmap(i32* null, i64 1024, i32 %34, i32 %35, i32 %14, i32 0)
%37 = load i8*, i8** @MAP_FAILED
%38 = icmp eq i8* %36, %37
br i1 %38, label %39, label %43
39: ; preds = %30
%40 = load i32, i32* @errno
%41 = call i8* @strerror(i32 %40)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %41)
br label %75
43: ; preds = %30
store i8 98, i8* %36
%44 = load i32, i32* @MS_SYNC
%45 = call i64 @msync(i8* %36, i64 1024, i32 %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %51, label %47
47: ; preds = %43
%48 = load i32, i32* @errno
%49 = call i8* @strerror(i32 %48)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %49)
br label %75
51: ; preds = %43
%52 = call i32 @munmap(i8* %36, i64 1024)
%53 = load i32, i32* @PROT_READ
%54 = load i32, i32* @PROT_WRITE
%55 = or i32 %54, %53
%56 = load i32, i32* @MAP_SHARED
%57 = call i8* @mmap(i32* null, i64 1024, i32 %55, i32 %56, i32 %14, i32 0)
%58 = load i8*, i8** @MAP_FAILED
%59 = icmp eq i8* %57, %58
br i1 %59, label %60, label %64
60: ; preds = %51
%61 = load i32, i32* @errno
%62 = call i8* @strerror(i32 %61)
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %62)
br label %75
64: ; preds = %51
%65 = load i8, i8* %57
%66 = icmp eq i8 %65, 98
br i1 %66, label %67, label %71
67: ; preds = %64
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str.8, i64 0, i64 0))
%69 = call i32 @close(i32 %14)
%70 = call i32 @munmap(i8* %57, i64 1024)
br label %75
71: ; preds = %64
%72 = call i32 @close(i32 %14)
%73 = call i32 @munmap(i8* %57, i64 1024)
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @str, i64 0, i64 0))
br label %75
75: ; preds = %71, %67, %60, %47, %39, %26, %16
%76 = phi i32 [ 2, %16 ], [ 2, %26 ], [ 1, %39 ], [ 2, %47 ], [ 1, %60 ], [ 0, %67 ], [ 1, %71 ]
ret i32 %76
}