#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 */
scalar_t__ EFAULT;
scalar_t__ EPERM;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
scalar_t__ SIGSEGV;
int /*<<< orphan*/ WIFSIGNALED(int);
scalar_t__ WTERMSIG(int);
scalar_t__ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int fork();
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ stdout;
scalar_t__ waitpid(int, int *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int pid, status, fd, n;
  printf("Trying to directly write %p...", ((unsigned long *)(0xa0800000)));
  fflush(stdout);
  if ((pid = fork()) != 0) {
    if (waitpid(pid, &status, 0) < 0) {
      perror("waitpid");
      exit(1);
    }
    if (!WIFSIGNALED(status) || (WTERMSIG(status) != SIGSEGV))
      printf("No segv (status = 0x%x) - BAD!\n", status);
    else
      printf("Segv - GOOD\n");
  } else {
    *((unsigned long *)(0xa0800000)) = 0xdeadbeef;
    exit(1);
  }
  printf("Trying to write %p via read...", ((unsigned long *)(0xa0800000)));
  if ((fd = open("/etc/passwd", O_RDONLY)) < 0) {
    perror("open");
    exit(1);
  }
  n = read(fd, (char *)((unsigned long *)(0xa0800000)),
           sizeof(*((unsigned long *)(0xa0800000))));
  if ((n > 0) || (errno != EFAULT))
    printf("Didn't return EFAULT - BAD!\n");
  else
    printf("Returned EFAULT - GOOD\n");
  printf("Trying to open /dev/mem...");
  fd = open("/dev/mem", O_WRONLY);
  if ((fd >= 0) || (errno != EPERM))
    printf("Didn't fail with EPERM (fd = %d, errno = %d) - BAD!\n", fd, errno);
  else
    printf("Failed with EPERM - GOOD\n");
  printf("Trying to open /dev/kmem...");
  fd = open("/dev/kmem", O_WRONLY);
  if ((fd >= 0) || (errno != EPERM))
    printf("Didn't fail with EPERM (fd = %d, errno = %d) - BAD!\n", fd, errno);
  else
    printf("Failed with EPERM - GOOD\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe43(%rip),%rdi
mov    $0xa0800000,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    $0x0,%al
call   10c0 <fork@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     126a <main+0xca>
mov    -0x14(%rbp),%edi
lea    -0x18(%rbp),%rsi
xor    %edx,%edx
call   1080 <waitpid@plt>
cmp    $0x0,%rax
jge    1218 <main+0x78>
lea    0xe16(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x18(%rbp),%edi
call   1050 <WIFSIGNALED@plt>
cmp    $0x0,%eax
je     1241 <main+0xa1>
mov    -0x18(%rbp),%edi
call   1070 <WTERMSIG@plt>
mov    0x2da8(%rip),%rcx
cmp    (%rcx),%rax
je     1257 <main+0xb7>
mov    -0x18(%rbp),%esi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1265 <main+0xc5>
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1281 <main+0xe1>
mov    $0xa0800000,%eax
mov    $0xdeadbeef,%ecx
mov    %rcx,(%rax)
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xdcc(%rip),%rdi
mov    $0xa0800000,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d3d(%rip),%rax
mov    (%rax),%esi
lea    0xdcf(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    12cb <main+0x12b>
lea    0xdc3(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x1c(%rbp),%edi
mov    $0xa0800000,%esi
mov    $0x8,%edx
call   1040 <read@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jg     1304 <main+0x164>
mov    0x2cd7(%rip),%rax
mov    (%rax),%rax
mov    0x2cfd(%rip),%rcx
cmp    (%rcx),%rax
je     1317 <main+0x177>
lea    0xd79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1325 <main+0x185>
lea    0xd83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2c76(%rip),%rax
mov    (%rax),%esi
lea    0xd91(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    136f <main+0x1cf>
mov    0x2c6c(%rip),%rax
mov    (%rax),%rax
mov    0x2c42(%rip),%rcx
cmp    (%rcx),%rax
je     138f <main+0x1ef>
mov    -0x1c(%rbp),%esi
mov    0x2c4f(%rip),%rax
mov    (%rax),%rdx
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    139d <main+0x1fd>
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2bfe(%rip),%rax
mov    (%rax),%esi
lea    0xd8d(%rip),%rdi
call   1090 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    13e7 <main+0x247>
mov    0x2bf4(%rip),%rax
mov    (%rax),%rax
mov    0x2bca(%rip),%rcx
cmp    (%rcx),%rax
je     1407 <main+0x267>
mov    -0x1c(%rbp),%esi
mov    0x2bd7(%rip),%rax
mov    (%rax),%rdx
lea    0xce2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1415 <main+0x275>
lea    0xd04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0xa0800000,%ebx
lea    0xe3b(%rip),%rdi
mov    $0xa0800000,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %eax,%eax
je     135f <main+0x1af>
lea    0xc(%rsp),%rsi
mov    %eax,%edi
xor    %edx,%edx
call   1090 <waitpid@plt>
test   %rax,%rax
js     1373 <main+0x1c3>
mov    0xc(%rsp),%edi
call   1060 <WIFSIGNALED@plt>
test   %eax,%eax
je     1235 <main+0x85>
mov    0xc(%rsp),%edi
call   1080 <WTERMSIG@plt>
mov    0x2dbe(%rip),%rcx
cmp    (%rcx),%rax
jne    1235 <main+0x85>
lea    0xf14(%rip),%rdi
call   1030 <puts@plt>
jmp    1247 <main+0x97>
mov    0xc(%rsp),%esi
lea    0xde7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdf9(%rip),%rdi
mov    $0xa0800000,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d77(%rip),%rax
mov    (%rax),%esi
lea    0xdfc(%rip),%rdi
call   10a0 <open@plt>
test   %eax,%eax
js     137c <main+0x1cc>
mov    $0xa0800000,%esi
mov    %eax,%edi
mov    $0x8,%edx
call   1050 <read@plt>
mov    0x2d39(%rip),%r15
mov    (%r15),%rcx
mov    0x2d5f(%rip),%rdx
cmp    (%rdx),%rcx
lea    0xe53(%rip),%rdi
lea    0xe7c(%rip),%rcx
cmovne %rcx,%rdi
test   %eax,%eax
cmovg  %rcx,%rdi
call   1030 <puts@plt>
lea    0xdb7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2ce2(%rip),%rbx
mov    (%rbx),%esi
lea    0xdbb(%rip),%rdi
call   10a0 <open@plt>
mov    (%r15),%rdx
mov    0x2cc2(%rip),%r14
test   %eax,%eax
jns    12fd <main+0x14d>
cmp    (%r14),%rdx
jne    12fd <main+0x14d>
lea    0xe17(%rip),%rdi
call   1030 <puts@plt>
jmp    130d <main+0x15d>
lea    0xd97(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdbc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%esi
lea    0xdc8(%rip),%rdi
call   10a0 <open@plt>
mov    (%r15),%rdx
test   %eax,%eax
jns    1343 <main+0x193>
cmp    (%r14),%rdx
jne    1343 <main+0x193>
lea    0xdd1(%rip),%rdi
call   1030 <puts@plt>
jmp    1353 <main+0x1a3>
lea    0xd51(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0x3e2dbeef(%rbx),%rax
mov    %rax,(%rbx)
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xca5(%rip),%rdi
jmp    1383 <main+0x1d3>
lea    0xcef(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"Trying to directly write %p...\00"
@stdout = global i32 0
@.str.1 = [8 x i8] c"waitpid\00"
@SIGSEGV = global i64 0
@.str.2 = [32 x i8] c"No segv (status = 0x%x) - BAD!\0A\00"
@.str.3 = [13 x i8] c"Segv - GOOD\0A\00"
@.str.4 = [31 x i8] c"Trying to write %p via read...\00"
@.str.5 = [12 x i8] c"/etc/passwd\00"
@O_RDONLY = global i32 0
@.str.6 = [5 x i8] c"open\00"
@errno = global i64 0
@EFAULT = global i64 0
@.str.7 = [29 x i8] c"Didn't return EFAULT - BAD!\0A\00"
@.str.8 = [24 x i8] c"Returned EFAULT - GOOD\0A\00"
@.str.9 = [27 x i8] c"Trying to open /dev/mem...\00"
@.str.10 = [9 x i8] c"/dev/mem\00"
@O_WRONLY = global i32 0
@EPERM = global i64 0
@.str.11 = [53 x i8] c"Didn't fail with EPERM (fd = %d, errno = %d) - BAD!\0A\00"
@.str.12 = [26 x i8] c"Failed with EPERM - GOOD\0A\00"
@.str.13 = [28 x i8] c"Trying to open /dev/kmem...\00"
@.str.14 = [10 x i8] c"/dev/kmem\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i64* inttoptr (i64 2692743168 to i64*))
%11 = load i32, i32* @stdout
%12 = call i32 @fflush(i32 %11)
%13 = call i32 (...) @fork()
store i32 %13, i32* %6
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %37
15: ; preds = %2
%16 = load i32, i32* %6
%17 = call i64 @waitpid(i32 %16, i32* %7, i32 0)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %15
%23 = load i32, i32* %7
%24 = call i32 @WIFSIGNALED(i32 %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load i32, i32* %7
%28 = call i64 @WTERMSIG(i32 %27)
%29 = load i64, i64* @SIGSEGV
%30 = icmp ne i64 %28, %29
br i1 %30, label %31, label %34
31: ; preds = %26, %22
%32 = load i32, i32* %7
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %32)
br label %36
34: ; preds = %26
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %34, %31
br label %39
37: ; preds = %2
store i64 3735928559, i64* inttoptr (i64 2692743168 to i64*)
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %36
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i64* inttoptr (i64 2692743168 to i64*))
%41 = load i32, i32* @O_RDONLY
%42 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %41)
store i32 %42, i32* %8
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %39
%45 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %39
%48 = load i32, i32* %8
%49 = call i32 @read(i32 %48, i8* inttoptr (i64 2692743168 to i8*), i32 8)
store i32 %49, i32* %9
%50 = load i32, i32* %9
%51 = icmp sgt i32 %50, 0
br i1 %51, label %56, label %52
52: ; preds = %47
%53 = load i64, i64* @errno
%54 = load i64, i64* @EFAULT
%55 = icmp ne i64 %53, %54
br i1 %55, label %56, label %58
56: ; preds = %52, %47
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
br label %60
58: ; preds = %52
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %60
60: ; preds = %58, %56
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%62 = load i32, i32* @O_WRONLY
%63 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %62)
store i32 %63, i32* %8
%64 = load i32, i32* %8
%65 = icmp sge i32 %64, 0
br i1 %65, label %70, label %66
66: ; preds = %60
%67 = load i64, i64* @errno
%68 = load i64, i64* @EPERM
%69 = icmp ne i64 %67, %68
br i1 %69, label %70, label %74
70: ; preds = %66, %60
%71 = load i32, i32* %8
%72 = load i64, i64* @errno
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0), i32 %71, i64 %72)
br label %76
74: ; preds = %66
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0))
br label %76
76: ; preds = %74, %70
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
%78 = load i32, i32* @O_WRONLY
%79 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i32 %78)
store i32 %79, i32* %8
%80 = load i32, i32* %8
%81 = icmp sge i32 %80, 0
br i1 %81, label %86, label %82
82: ; preds = %76
%83 = load i64, i64* @errno
%84 = load i64, i64* @EPERM
%85 = icmp ne i64 %83, %84
br i1 %85, label %86, label %90
86: ; preds = %82, %76
%87 = load i32, i32* %8
%88 = load i64, i64* @errno
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0), i32 %87, i64 %88)
br label %92
90: ; preds = %82
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0))
br label %92
92: ; preds = %90, %86
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"Trying to directly write %p...\00"
@stdout = global i32 0
@.str.1 = [8 x i8] c"waitpid\00"
@SIGSEGV = global i64 0
@.str.2 = [32 x i8] c"No segv (status = 0x%x) - BAD!\0A\00"
@.str.4 = [31 x i8] c"Trying to write %p via read...\00"
@.str.5 = [12 x i8] c"/etc/passwd\00"
@O_RDONLY = global i32 0
@.str.6 = [5 x i8] c"open\00"
@errno = global i64 0
@EFAULT = global i64 0
@.str.9 = [27 x i8] c"Trying to open /dev/mem...\00"
@.str.10 = [9 x i8] c"/dev/mem\00"
@O_WRONLY = global i32 0
@EPERM = global i64 0
@.str.11 = [53 x i8] c"Didn't fail with EPERM (fd = %d, errno = %d) - BAD!\0A\00"
@.str.13 = [28 x i8] c"Trying to open /dev/kmem...\00"
@.str.14 = [10 x i8] c"/dev/kmem\00"
@str = [23 x i8] c"Returned EFAULT - GOOD\00"
@str.16 = [25 x i8] c"Failed with EPERM - GOOD\00"
@str.17 = [28 x i8] c"Didn't return EFAULT - BAD!\00"
@str.18 = [12 x i8] c"Segv - GOOD\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i64* inttoptr (i64 2692743168 to i64*))
%6 = load i32, i32* @stdout
%7 = tail call i32 @fflush(i32 %6)
%8 = tail call i32 (...) @fork()
%9 = icmp eq i32 %8, 0
br i1 %9, label %30, label %10
10: ; preds = %2
%11 = call i64 @waitpid(i32 %8, i32* %3, i32 0)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %10
%17 = load i32, i32* %3
%18 = call i32 @WIFSIGNALED(i32 %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %16
%21 = load i32, i32* %3
%22 = call i64 @WTERMSIG(i32 %21)
%23 = load i64, i64* @SIGSEGV
%24 = icmp eq i64 %22, %23
br i1 %24, label %28, label %25
25: ; preds = %20, %16
%26 = load i32, i32* %3
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %32
28: ; preds = %20
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.18, i64 0, i64 0))
br label %32
30: ; preds = %2
store i64 3735928559, i64* inttoptr (i64 2692743168 to i64*)
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %25, %28
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i64* inttoptr (i64 2692743168 to i64*))
%34 = load i32, i32* @O_RDONLY
%35 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %34)
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %32
%41 = call i32 @read(i32 %35, i8* inttoptr (i64 2692743168 to i8*), i32 8)
%42 = icmp sgt i32 %41, 0
%43 = load i64, i64* @errno
%44 = load i64, i64* @EFAULT
%45 = icmp eq i64 %43, %44
%46 = select i1 %45, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @str.17, i64 0, i64 0)
%47 = select i1 %42, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @str.17, i64 0, i64 0), i8* %46
%48 = call i32 @puts(i8* dereferenceable(1) %47)
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%50 = load i32, i32* @O_WRONLY
%51 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %50)
%52 = icmp slt i32 %51, 0
%53 = load i64, i64* @errno
%54 = load i64, i64* @EPERM
%55 = icmp eq i64 %53, %54
%56 = select i1 %52, i1 %55, i1 false
br i1 %56, label %59, label %57
57: ; preds = %40
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0), i32 %51, i64 %53)
br label %61
59: ; preds = %40
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.16, i64 0, i64 0))
br label %61
61: ; preds = %59, %57
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
%63 = load i32, i32* @O_WRONLY
%64 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i32 %63)
%65 = icmp slt i32 %64, 0
%66 = load i64, i64* @errno
%67 = load i64, i64* @EPERM
%68 = icmp eq i64 %66, %67
%69 = select i1 %65, i1 %68, i1 false
br i1 %69, label %72, label %70
70: ; preds = %61
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0), i32 %64, i64 %66)
br label %74
72: ; preds = %61
%73 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.16, i64 0, i64 0))
br label %74
74: ; preds = %72, %70
ret i32 0
}