#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 pid_t;

/* Variables and functions */
int /*<<< orphan*/ FAIL_IF(int);
int MAP_ANONYMOUS;
int *MAP_FAILED;
int MAP_FIXED;
int MAP_PRIVATE;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ SKIP_IF(int);
scalar_t__ WEXITSTATUS(int);
int /*<<< orphan*/ WIFEXITED(int);
int /*<<< orphan*/ _SC_PAGESIZE;
int /*<<< orphan*/ barrier();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int getpid();
int *mmap(void *, unsigned long, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, int *, int);
unsigned long sysconf(int /*<<< orphan*/);
int waitpid(int, int *, int /*<<< orphan*/);
int write(int, int *, int);
int test(void) {
  int p2c[2], c2p[2], rc, status, c, *p;
  unsigned long page_size;
  pid_t pid;
  page_size = sysconf(_SC_PAGESIZE);
  SKIP_IF(page_size != 65536);
  p = mmap((void *)(512ul << 40), page_size, PROT_READ | PROT_WRITE,
           MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
  if (p == MAP_FAILED) {
    perror("mmap");
    printf("Error: couldn't mmap(), confirm kernel has 4TB support?\n");
    return 1;
  }
  printf("parent writing %p = 1\n", p);
  *p = 1;
  FAIL_IF(pipe(p2c) == -1 || pipe(c2p) == -1);
  pid = fork();
  if (pid == 0) {
    FAIL_IF(read(p2c[0], &c, 1) != 1);
    pid = getpid();
    printf("child writing  %p = %d\n", p, pid);
    *p = pid;
    FAIL_IF(write(c2p[1], &c, 1) != 1);
    FAIL_IF(read(p2c[0], &c, 1) != 1);
    exit(0);
  }
  c = 0;
  FAIL_IF(write(p2c[1], &c, 1) != 1);
  FAIL_IF(read(c2p[0], &c, 1) != 1);
  barrier();
  rc = 0;
  printf("parent reading %p = %d\n", p, *p);
  if (*p != 1) {
    printf("Error: BUG! parent saw child's write! *p = %d\n", *p);
    rc = 1;
  }
  FAIL_IF(write(p2c[1], &c, 1) != 1);
  FAIL_IF(waitpid(pid, &status, 0) == -1);
  FAIL_IF(!WIFEXITED(status) || WEXITSTATUS(status));
  if (rc == 0)
    printf("success: test completed OK\n");
  return rc;
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
call   10e0 <sysconf@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x10000,-0x30(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   10f0 <SKIP_IF@plt>
mov    -0x30(%rbp),%rsi
mov    0x2dbe(%rip),%rax
mov    (%rax),%edx
mov    0x2d85(%rip),%rax
or     (%rax),%edx
mov    0x2d74(%rip),%rax
mov    (%rax),%ecx
mov    0x2d83(%rip),%rax
or     (%rax),%ecx
mov    0x2d5a(%rip),%rax
or     (%rax),%ecx
movabs $0x2000000000000,%rdi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1060 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2d29(%rip),%rcx
cmp    (%rcx),%rax
jne    12b6 <test+0xb6>
lea    0xd69(%rip),%rdi
call   10d0 <perror@plt>
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14db <test+0x2db>
mov    -0x28(%rbp),%rsi
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x28(%rbp),%rax
movl   $0x1,(%rax)
lea    -0xc(%rbp),%rdi
call   1080 <pipe@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0xffffffff,%ecx
mov    %al,-0x35(%rbp)
je     12fd <test+0xfd>
lea    -0x14(%rbp),%rdi
call   1080 <pipe@plt>
cmp    $0xffffffff,%eax
sete   %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <FAIL_IF@plt>
mov    $0x0,%al
call   1120 <fork@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    13b0 <test+0x1b0>
mov    -0xc(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
cmp    $0x1,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <FAIL_IF@plt>
mov    $0x0,%al
call   1050 <getpid@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x34(%rbp),%edx
lea    0xcfe(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x34(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0x1,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <FAIL_IF@plt>
mov    -0xc(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
cmp    $0x1,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <FAIL_IF@plt>
xor    %edi,%edi
call   1110 <exit@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0x1,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <FAIL_IF@plt>
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
cmp    $0x1,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <FAIL_IF@plt>
mov    $0x0,%al
call   1030 <barrier@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
lea    0xc55(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x28(%rbp),%rax
cmpl   $0x1,(%rax)
je     1447 <test+0x247>
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
lea    0xc4c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
cmp    $0x1,%eax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <FAIL_IF@plt>
mov    -0x34(%rbp),%edi
lea    -0x1c(%rbp),%rsi
xor    %edx,%edx
call   10c0 <waitpid@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <FAIL_IF@plt>
mov    -0x1c(%rbp),%edi
call   1100 <WIFEXITED@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x36(%rbp)
je     14b0 <test+0x2b0>
mov    -0x1c(%rbp),%edi
call   10b0 <WEXITSTATUS@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x36(%rbp)
mov    -0x36(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <FAIL_IF@plt>
cmpl   $0x0,-0x18(%rbp)
jne    14d5 <test+0x2d5>
lea    0xbe6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
call   10f0 <sysconf@plt>
mov    %rax,%rbx
xor    %edi,%edi
cmp    $0x10000,%rax
setne  %dil
call   1100 <SKIP_IF@plt>
mov    0x2db3(%rip),%rax
mov    0x2d7c(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d69(%rip),%rax
mov    0x2d7a(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2d4f(%rip),%rax
or     (%rax),%ecx
movabs $0x2000000000000,%rdi
mov    %rbx,%rsi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1070 <mmap@plt>
mov    %rax,%rbx
mov    0x2d20(%rip),%rax
cmp    (%rax),%rbx
je     1402 <test+0x1f2>
lea    0xd65(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
movl   $0x1,(%rbx)
lea    0x10(%rsp),%rdi
call   1090 <pipe@plt>
cmp    $0xffffffff,%eax
je     12d4 <test+0xc4>
lea    0x18(%rsp),%rdi
call   1090 <pipe@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
jmp    12d9 <test+0xc9>
mov    $0x1,%edi
call   10b0 <FAIL_IF@plt>
xor    %r14d,%r14d
xor    %eax,%eax
call   1130 <fork@plt>
test   %eax,%eax
je     1422 <test+0x212>
mov    %eax,%r15d
movl   $0x0,0x8(%rsp)
mov    0x14(%rsp),%edi
lea    0x8(%rsp),%rbp
mov    $0x1,%r12d
mov    %rbp,%rsi
mov    $0x1,%edx
call   1050 <write@plt>
xor    %edi,%edi
cmp    $0x1,%eax
setne  %dil
call   10b0 <FAIL_IF@plt>
mov    0x18(%rsp),%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
xor    %edi,%edi
cmp    $0x1,%eax
setne  %dil
call   10b0 <FAIL_IF@plt>
xor    %eax,%eax
call   1030 <barrier@plt>
mov    (%rbx),%edx
lea    0xce0(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    (%rbx),%ebx
cmp    $0x1,%ebx
je     137b <test+0x16b>
lea    0xce0(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%r14d
mov    0x14(%rsp),%edi
lea    0x8(%rsp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
xor    %edi,%edi
cmp    $0x1,%eax
setne  %dil
call   10b0 <FAIL_IF@plt>
lea    0xc(%rsp),%rsi
mov    %r15d,%edi
xor    %edx,%edx
call   10d0 <waitpid@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   10b0 <FAIL_IF@plt>
mov    0xc(%rsp),%edi
call   1110 <WIFEXITED@plt>
test   %eax,%eax
je     13d9 <test+0x1c9>
mov    0xc(%rsp),%edi
call   10c0 <WEXITSTATUS@plt>
xor    %r12d,%r12d
test   %rax,%rax
setne  %r12b
mov    %r12d,%edi
call   10b0 <FAIL_IF@plt>
cmp    $0x1,%ebx
jne    13f2 <test+0x1e2>
lea    0xc8e(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbf7(%rip),%rdi
call   10e0 <perror@plt>
lea    0xc81(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r14d
jmp    13f2 <test+0x1e2>
mov    0x10(%rsp),%edi
lea    0x8(%rsp),%r14
mov    %r14,%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
xor    %edi,%edi
cmp    $0x1,%eax
setne  %dil
call   10b0 <FAIL_IF@plt>
xor    %eax,%eax
call   1060 <getpid@plt>
mov    %eax,%ebp
lea    0xbc6(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %ebp,(%rbx)
mov    0x1c(%rsp),%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1050 <write@plt>
xor    %edi,%edi
cmp    $0x1,%eax
setne  %dil
call   10b0 <FAIL_IF@plt>
mov    0x10(%rsp),%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
xor    %edi,%edi
cmp    $0x1,%eax
setne  %dil
call   10b0 <FAIL_IF@plt>
xor    %edi,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
@_SC_PAGESIZE = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_FIXED = global i32 0
@MAP_FAILED = global i32* null
@.str = [5 x i8] c"mmap\00"
@.str.1 = [57 x i8] c"Error: couldn't mmap(), confirm kernel has 4TB support?\0A\00"
@.str.2 = [23 x i8] c"parent writing %p = 1\0A\00"
@.str.3 = [24 x i8] c"child writing %p = %d\0A\00"
@.str.4 = [24 x i8] c"parent reading %p = %d\0A\00"
@.str.5 = [47 x i8] c"Error: BUG! parent saw child's write! *p = %d\0A\00"
@.str.6 = [28 x i8] c"success: test completed OK\0A\00"
define i32 @test() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca [2 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i32
%10 = load i32, i32* @_SC_PAGESIZE
%11 = call i64 @sysconf(i32 %10)
store i64 %11, i64* %8
%12 = load i64, i64* %8
%13 = icmp ne i64 %12, 65536
%14 = zext i1 %13 to i32
%15 = call i32 @SKIP_IF(i32 %14)
%16 = load i64, i64* %8
%17 = load i32, i32* @PROT_READ
%18 = load i32, i32* @PROT_WRITE
%19 = or i32 %17, %18
%20 = load i32, i32* @MAP_PRIVATE
%21 = load i32, i32* @MAP_ANONYMOUS
%22 = or i32 %20, %21
%23 = load i32, i32* @MAP_FIXED
%24 = or i32 %22, %23
%25 = call i32* @mmap(i8* inttoptr (i64 562949953421312 to i8*), i64 %16, i32 %19, i32 %24, i32 -1, i32 0)
store i32* %25, i32** %7
%26 = load i32*, i32** %7
%27 = load i32*, i32** @MAP_FAILED
%28 = icmp eq i32* %26, %27
br i1 %28, label %29, label %32
29: ; preds = %0
%30 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %130
32: ; preds = %0
%33 = load i32*, i32** %7
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32* %33)
%35 = load i32*, i32** %7
store i32 1, i32* %35
%36 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%37 = call i32 @pipe(i32* %36)
%38 = icmp eq i32 %37, -1
br i1 %38, label %43, label %39
39: ; preds = %32
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%41 = call i32 @pipe(i32* %40)
%42 = icmp eq i32 %41, -1
br label %43
43: ; preds = %39, %32
%44 = phi i1 [ true, %32 ], [ %42, %39 ]
%45 = zext i1 %44 to i32
%46 = call i32 @FAIL_IF(i32 %45)
%47 = call i32 (...) @fork()
store i32 %47, i32* %9
%48 = load i32, i32* %9
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %76
50: ; preds = %43
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%52 = load i32, i32* %51
%53 = call i32 @read(i32 %52, i32* %6, i32 1)
%54 = icmp ne i32 %53, 1
%55 = zext i1 %54 to i32
%56 = call i32 @FAIL_IF(i32 %55)
%57 = call i32 (...) @getpid()
store i32 %57, i32* %9
%58 = load i32*, i32** %7
%59 = load i32, i32* %9
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32* %58, i32 %59)
%61 = load i32, i32* %9
%62 = load i32*, i32** %7
store i32 %61, i32* %62
%63 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%64 = load i32, i32* %63
%65 = call i32 @write(i32 %64, i32* %6, i32 1)
%66 = icmp ne i32 %65, 1
%67 = zext i1 %66 to i32
%68 = call i32 @FAIL_IF(i32 %67)
%69 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%70 = load i32, i32* %69
%71 = call i32 @read(i32 %70, i32* %6, i32 1)
%72 = icmp ne i32 %71, 1
%73 = zext i1 %72 to i32
%74 = call i32 @FAIL_IF(i32 %73)
%75 = call i32 @exit(i32 0)
unreachable
76: ; preds = %43
store i32 0, i32* %6
%77 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%78 = load i32, i32* %77
%79 = call i32 @write(i32 %78, i32* %6, i32 1)
%80 = icmp ne i32 %79, 1
%81 = zext i1 %80 to i32
%82 = call i32 @FAIL_IF(i32 %81)
%83 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%84 = load i32, i32* %83
%85 = call i32 @read(i32 %84, i32* %6, i32 1)
%86 = icmp ne i32 %85, 1
%87 = zext i1 %86 to i32
%88 = call i32 @FAIL_IF(i32 %87)
%89 = call i32 (...) @barrier()
store i32 0, i32* %4
%90 = load i32*, i32** %7
%91 = load i32*, i32** %7
%92 = load i32, i32* %91
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32* %90, i32 %92)
%94 = load i32*, i32** %7
%95 = load i32, i32* %94
%96 = icmp ne i32 %95, 1
br i1 %96, label %97, label %101
97: ; preds = %76
%98 = load i32*, i32** %7
%99 = load i32, i32* %98
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), i32 %99)
store i32 1, i32* %4
br label %101
101: ; preds = %97, %76
%102 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%103 = load i32, i32* %102
%104 = call i32 @write(i32 %103, i32* %6, i32 1)
%105 = icmp ne i32 %104, 1
%106 = zext i1 %105 to i32
%107 = call i32 @FAIL_IF(i32 %106)
%108 = load i32, i32* %9
%109 = call i32 @waitpid(i32 %108, i32* %5, i32 0)
%110 = icmp eq i32 %109, -1
%111 = zext i1 %110 to i32
%112 = call i32 @FAIL_IF(i32 %111)
%113 = load i32, i32* %5
%114 = call i32 @WIFEXITED(i32 %113)
%115 = icmp ne i32 %114, 0
br i1 %115, label %116, label %120
116: ; preds = %101
%117 = load i32, i32* %5
%118 = call i64 @WEXITSTATUS(i32 %117)
%119 = icmp ne i64 %118, 0
br label %120
120: ; preds = %116, %101
%121 = phi i1 [ true, %101 ], [ %119, %116 ]
%122 = zext i1 %121 to i32
%123 = call i32 @FAIL_IF(i32 %122)
%124 = load i32, i32* %4
%125 = icmp eq i32 %124, 0
br i1 %125, label %126, label %128
126: ; preds = %120
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
br label %128
128: ; preds = %126, %120
%129 = load i32, i32* %4
store i32 %129, i32* %1
br label %130
130: ; preds = %128, %29
%131 = load i32, i32* %1
ret i32 %131
}

LLVM IR (-O2):
@_SC_PAGESIZE = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_PRIVATE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_FIXED = global i32 0
@MAP_FAILED = global i32* null
@.str = [5 x i8] c"mmap\00"
@.str.2 = [23 x i8] c"parent writing %p = 1\0A\00"
@.str.3 = [24 x i8] c"child writing %p = %d\0A\00"
@.str.4 = [24 x i8] c"parent reading %p = %d\0A\00"
@.str.5 = [47 x i8] c"Error: BUG! parent saw child's write! *p = %d\0A\00"
@str = [27 x i8] c"success: test completed OK\00"
@str.7 = [56 x i8] c"Error: couldn't mmap(), confirm kernel has 4TB support?\00"
define i32 @test() {
%1 = alloca [2 x i32]
%2 = alloca [2 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [2 x i32]* %1 to i8*
%6 = bitcast [2 x i32]* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = load i32, i32* @_SC_PAGESIZE
%10 = tail call i64 @sysconf(i32 %9)
%11 = icmp ne i64 %10, 65536
%12 = zext i1 %11 to i32
%13 = tail call i32 @SKIP_IF(i32 %12)
%14 = load i32, i32* @PROT_READ
%15 = load i32, i32* @PROT_WRITE
%16 = or i32 %15, %14
%17 = load i32, i32* @MAP_PRIVATE
%18 = load i32, i32* @MAP_ANONYMOUS
%19 = or i32 %18, %17
%20 = load i32, i32* @MAP_FIXED
%21 = or i32 %19, %20
%22 = tail call i32* @mmap(i8* inttoptr (i64 562949953421312 to i8*), i64 %10, i32 %16, i32 %21, i32 -1, i32 0)
%23 = load i32*, i32** @MAP_FAILED
%24 = icmp eq i32* %22, %23
br i1 %24, label %25, label %28
25: ; preds = %0
%26 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.7, i64 0, i64 0))
br label %107
28: ; preds = %0
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32* %22)
store i32 1, i32* %22
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%31 = call i32 @pipe(i32* %30)
%32 = icmp eq i32 %31, -1
br i1 %32, label %38, label %33
33: ; preds = %28
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%35 = call i32 @pipe(i32* %34)
%36 = icmp eq i32 %35, -1
%37 = zext i1 %36 to i32
br label %38
38: ; preds = %33, %28
%39 = phi i32 [ 1, %28 ], [ %37, %33 ]
%40 = call i32 @FAIL_IF(i32 %39)
%41 = call i32 (...) @fork()
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %63
43: ; preds = %38
%44 = load i32, i32* %30
%45 = call i32 @read(i32 %44, i32* %4, i32 1)
%46 = icmp ne i32 %45, 1
%47 = zext i1 %46 to i32
%48 = call i32 @FAIL_IF(i32 %47)
%49 = call i32 (...) @getpid()
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32* %22, i32 %49)
store i32 %49, i32* %22
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
%52 = load i32, i32* %51
%53 = call i32 @write(i32 %52, i32* %4, i32 1)
%54 = icmp ne i32 %53, 1
%55 = zext i1 %54 to i32
%56 = call i32 @FAIL_IF(i32 %55)
%57 = load i32, i32* %30
%58 = call i32 @read(i32 %57, i32* %4, i32 1)
%59 = icmp ne i32 %58, 1
%60 = zext i1 %59 to i32
%61 = call i32 @FAIL_IF(i32 %60)
%62 = call i32 @exit(i32 0)
unreachable
63: ; preds = %38
store i32 0, i32* %4
%64 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
%65 = load i32, i32* %64
%66 = call i32 @write(i32 %65, i32* %4, i32 1)
%67 = icmp ne i32 %66, 1
%68 = zext i1 %67 to i32
%69 = call i32 @FAIL_IF(i32 %68)
%70 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%71 = load i32, i32* %70
%72 = call i32 @read(i32 %71, i32* %4, i32 1)
%73 = icmp ne i32 %72, 1
%74 = zext i1 %73 to i32
%75 = call i32 @FAIL_IF(i32 %74)
%76 = call i32 (...) @barrier()
%77 = load i32, i32* %22
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32* %22, i32 %77)
%79 = load i32, i32* %22
%80 = icmp eq i32 %79, 1
br i1 %80, label %83, label %81
81: ; preds = %63
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0), i32 %79)
br label %83
83: ; preds = %81, %63
%84 = phi i32 [ 1, %81 ], [ 0, %63 ]
%85 = load i32, i32* %64
%86 = call i32 @write(i32 %85, i32* %4, i32 1)
%87 = icmp ne i32 %86, 1
%88 = zext i1 %87 to i32
%89 = call i32 @FAIL_IF(i32 %88)
%90 = call i32 @waitpid(i32 %41, i32* %3, i32 0)
%91 = icmp eq i32 %90, -1
%92 = zext i1 %91 to i32
%93 = call i32 @FAIL_IF(i32 %92)
%94 = load i32, i32* %3
%95 = call i32 @WIFEXITED(i32 %94)
%96 = icmp eq i32 %95, 0
br i1 %96, label %102, label %97
97: ; preds = %83
%98 = load i32, i32* %3
%99 = call i64 @WEXITSTATUS(i32 %98)
%100 = icmp ne i64 %99, 0
%101 = zext i1 %100 to i32
br label %102
102: ; preds = %97, %83
%103 = phi i32 [ 1, %83 ], [ %101, %97 ]
%104 = call i32 @FAIL_IF(i32 %103)
br i1 %80, label %105, label %107
105: ; preds = %102
%106 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %107
107: ; preds = %102, %105, %25
%108 = phi i32 [ 1, %25 ], [ %84, %105 ], [ %84, %102 ]
ret i32 %108
}