#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 */
void *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_RDWR;
int PROT_EXEC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SYS_memfd_create;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
void *mmap(int /*<<< orphan*/, int, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int /*<<< orphan*/ mprotect(void *, int, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int syscall(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "TESTING ERROR: memwrexe insufficient params\n");
    usage();
    return 1;
  }
  if (strcmp(argv[1], "mmap") == 0) {
    int fd = open("memwrexe.c", O_RDONLY);
    if (fd == -1) {
      fprintf(stderr, "TESTING ERROR: file not found, cannot run mmap test\n");
      return 1;
    }
    int size = lseek(fd, 0, SEEK_END);
    if (size == -1) {
      fprintf(stderr, "TESTING ERROR: file not found, cannot run mmap test\n");
      return 1;
    }
    void *p =
        mmap(0, size, PROT_WRITE | PROT_READ | PROT_EXEC, MAP_SHARED, fd, 0);
    printf("mmap successful\n");
    sleep(100);
    return 0;
  } else if (strcmp(argv[1], "mprotect") == 0) {
    int fd = open("memwrexe.c", O_RDWR);
    if (fd == -1) {
      fprintf(stderr, "TESTING ERROR: file not found, cannot run mmap test\n");
      return 1;
    }
    int size = lseek(fd, 0, SEEK_END);
    if (size == -1) {
      fprintf(stderr, "TESTING ERROR: file not found, cannot run mmap test\n");
      return 1;
    }
    void *p = mmap(0, size, PROT_READ, MAP_SHARED, fd, 0);
    if (p == MAP_FAILED) {
      fprintf(stderr, "TESTING ERROR: cannot map file for mprotect test\n");
      return 1;
    }
    mprotect(p, size, PROT_READ | PROT_WRITE | PROT_EXEC);
    printf("mprotect successful\n");
    sleep(100);
    return 0;
  } else if (strcmp(argv[1], "memfd_create") == 0) {
    int fd = syscall(SYS_memfd_create, "memfd_create", 0);
    if (fd == -1) {
      fprintf(stderr, "TESTING ERROR: cannot run memfd_create test\n");
      return 1;
    }
    printf("memfd_create successful\n");
    sleep(100);
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11e8 <main+0x48>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x0,%al
call   1090 <usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    14bd <main+0x31d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe36(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12e6 <main+0x146>
mov    0x2dbb(%rip),%rax
mov    (%rax),%esi
lea    0xe1c(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1249 <main+0xa9>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
lea    0xe05(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14bd <main+0x31d>
mov    -0x14(%rbp),%edi
mov    0x2d7d(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    128a <main+0xea>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
lea    0xdc4(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14bd <main+0x31d>
mov    -0x18(%rbp),%esi
mov    0x2d0c(%rip),%rax
mov    (%rax),%edx
mov    0x2d5b(%rip),%rax
or     (%rax),%edx
mov    0x2d1a(%rip),%rax
or     (%rax),%edx
mov    0x2d39(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1030 <mmap@plt>
mov    %rax,-0x20(%rbp)
lea    0xda7(%rip),%rdi
call   1040 <printf@plt>
mov    $0x64,%edi
call   10c0 <sleep@plt>
movl   $0x0,-0x4(%rbp)
jmp    14bd <main+0x31d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd8e(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    142e <main+0x28e>
mov    0x2ccd(%rip),%rax
mov    (%rax),%esi
lea    0xd1e(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1347 <main+0x1a7>
mov    0x2c7b(%rip),%rax
mov    (%rax),%edi
lea    0xd07(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14bd <main+0x31d>
mov    -0x24(%rbp),%edi
mov    0x2c7f(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
jne    1388 <main+0x1e8>
mov    0x2c3a(%rip),%rax
mov    (%rax),%edi
lea    0xcc6(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14bd <main+0x31d>
mov    -0x28(%rbp),%esi
mov    0x2c66(%rip),%rax
mov    (%rax),%edx
mov    0x2c4d(%rip),%rax
mov    (%rax),%ecx
mov    -0x24(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1030 <mmap@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    0x2bdd(%rip),%rcx
cmp    (%rcx),%rax
jne    13e5 <main+0x245>
mov    0x2bdd(%rip),%rax
mov    (%rax),%edi
lea    0xcb8(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14bd <main+0x31d>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    0x2c05(%rip),%rax
mov    (%rax),%edx
mov    0x2ba4(%rip),%rax
or     (%rax),%edx
mov    0x2bbb(%rip),%rax
or     (%rax),%edx
call   10a0 <mprotect@plt>
lea    0xcab(%rip),%rdi
call   1040 <printf@plt>
mov    $0x64,%edi
call   10c0 <sleep@plt>
movl   $0x0,-0x4(%rbp)
jmp    14bd <main+0x31d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xc96(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    14b3 <main+0x313>
mov    0x2b5d(%rip),%rax
mov    (%rax),%edi
lea    0xc77(%rip),%rsi
xor    %edx,%edx
call   1080 <syscall@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    1491 <main+0x2f1>
mov    0x2b31(%rip),%rax
mov    (%rax),%edi
lea    0xc60(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14bd <main+0x31d>
lea    0xc75(%rip),%rdi
call   1040 <printf@plt>
mov    $0x64,%edi
call   10c0 <sleep@plt>
movl   $0x0,-0x4(%rbp)
jmp    14bd <main+0x31d>
jmp    14b8 <main+0x318>
jmp    14bd <main+0x31d>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    122a <main+0x8a>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe73(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     124b <main+0xab>
mov    0x8(%rbx),%rdi
lea    0xe9f(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     12c7 <main+0x127>
mov    0x8(%rbx),%rdi
lea    0xec1(%rip),%rsi
call   1060 <strcmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
jne    1384 <main+0x1e4>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
xor    %ebx,%ebx
xor    %edx,%edx
call   1080 <syscall@plt>
cmp    $0xffffffff,%eax
je     1391 <main+0x1f1>
lea    0xec2(%rip),%rdi
jmp    1359 <main+0x1b9>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
lea    0xdc6(%rip),%rsi
call   1070 <fprintf@plt>
xor    %eax,%eax
call   1090 <usage@plt>
jmp    137f <main+0x1df>
mov    0x2d76(%rip),%rax
mov    (%rax),%esi
lea    0xdd7(%rip),%rdi
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
je     136a <main+0x1ca>
mov    %eax,%ebp
mov    0x2d5e(%rip),%rax
mov    (%rax),%edx
xor    %ebx,%ebx
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
cmp    $0xffffffff,%eax
je     136a <main+0x1ca>
mov    0x2d11(%rip),%rcx
mov    0x2d62(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2d1f(%rip),%rcx
or     (%rcx),%edx
mov    0x2d3e(%rip),%rcx
mov    (%rcx),%ecx
xor    %edi,%edi
mov    %eax,%esi
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
lea    0xe51(%rip),%rdi
jmp    1359 <main+0x1b9>
mov    0x2d0a(%rip),%rax
mov    (%rax),%esi
lea    0xd5b(%rip),%rdi
call   10b0 <open@plt>
cmp    $0xffffffff,%eax
je     136a <main+0x1ca>
mov    %eax,%ebp
mov    0x2ce2(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <lseek@plt>
cmp    $0xffffffff,%eax
je     136a <main+0x1ca>
mov    %eax,%r14d
mov    0x2cf0(%rip),%r15
mov    (%r15),%edx
mov    0x2cd6(%rip),%rax
mov    (%rax),%ecx
xor    %ebx,%ebx
xor    %edi,%edi
mov    %r14d,%esi
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    0x2c6b(%rip),%rcx
cmp    (%rcx),%rax
je     13a3 <main+0x203>
mov    0x2c67(%rip),%rcx
mov    (%rcx),%edx
or     (%r15),%edx
mov    0x2c7b(%rip),%rcx
or     (%rcx),%edx
mov    %rax,%rdi
mov    %r14d,%esi
call   10a0 <mprotect@plt>
lea    0xda6(%rip),%rdi
call   1030 <puts@plt>
mov    $0x64,%edi
call   10c0 <sleep@plt>
jmp    1384 <main+0x1e4>
mov    0x2c37(%rip),%rax
mov    (%rax),%edi
lea    0xcc3(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c10(%rip),%rax
mov    (%rax),%edi
lea    0xd19(%rip),%rsi
jmp    137a <main+0x1da>
mov    0x2bfe(%rip),%rax
mov    (%rax),%edi
lea    0xcc8(%rip),%rsi
jmp    137a <main+0x1da>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [45 x i8] c"TESTING ERROR: memwrexe insufficient params\0A\00"
@.str.1 = [5 x i8] c"mmap\00"
@.str.2 = [11 x i8] c"memwrexe.c\00"
@O_RDONLY = global i32 0
@.str.3 = [53 x i8] c"TESTING ERROR: file not found, cannot run mmap test\0A\00"
@SEEK_END = global i32 0
@PROT_WRITE = global i32 0
@PROT_READ = global i32 0
@PROT_EXEC = global i32 0
@MAP_SHARED = global i32 0
@.str.4 = [17 x i8] c"mmap successful\0A\00"
@.str.5 = [9 x i8] c"mprotect\00"
@O_RDWR = global i32 0
@MAP_FAILED = global i8* null
@.str.6 = [50 x i8] c"TESTING ERROR: cannot map file for mprotect test\0A\00"
@.str.7 = [21 x i8] c"mprotect successful\0A\00"
@.str.8 = [13 x i8] c"memfd_create\00"
@SYS_memfd_create = global i32 0
@.str.9 = [45 x i8] c"TESTING ERROR: cannot run memfd_create test\0A\00"
@.str.10 = [25 x i8] c"memfd_create successful\0A\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 i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%18 = call i32 (...) @usage()
store i32 1, i32* %3
br label %119
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %54
25: ; preds = %19
%26 = load i32, i32* @O_RDONLY
%27 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %26)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %119
33: ; preds = %25
%34 = load i32, i32* %6
%35 = load i32, i32* @SEEK_END
%36 = call i32 @lseek(i32 %34, i32 0, i32 %35)
store i32 %36, i32* %7
%37 = load i32, i32* %7
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %42
39: ; preds = %33
%40 = load i32, i32* @stderr
%41 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %119
42: ; preds = %33
%43 = load i32, i32* %7
%44 = load i32, i32* @PROT_WRITE
%45 = load i32, i32* @PROT_READ
%46 = or i32 %44, %45
%47 = load i32, i32* @PROT_EXEC
%48 = or i32 %46, %47
%49 = load i32, i32* @MAP_SHARED
%50 = load i32, i32* %6
%51 = call i8* @mmap(i32 0, i32 %43, i32 %48, i32 %49, i32 %50, i32 0)
store i8* %51, i8** %8
%52 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%53 = call i32 @sleep(i32 100)
store i32 0, i32* %3
br label %119
54: ; preds = %19
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 1
%57 = load i8*, i8** %56
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %100
60: ; preds = %54
%61 = load i32, i32* @O_RDWR
%62 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %61)
store i32 %62, i32* %9
%63 = load i32, i32* %9
%64 = icmp eq i32 %63, -1
br i1 %64, label %65, label %68
65: ; preds = %60
%66 = load i32, i32* @stderr
%67 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %119
68: ; preds = %60
%69 = load i32, i32* %9
%70 = load i32, i32* @SEEK_END
%71 = call i32 @lseek(i32 %69, i32 0, i32 %70)
store i32 %71, i32* %10
%72 = load i32, i32* %10
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %77
74: ; preds = %68
%75 = load i32, i32* @stderr
%76 = call i32 @fprintf(i32 %75, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %119
77: ; preds = %68
%78 = load i32, i32* %10
%79 = load i32, i32* @PROT_READ
%80 = load i32, i32* @MAP_SHARED
%81 = load i32, i32* %9
%82 = call i8* @mmap(i32 0, i32 %78, i32 %79, i32 %80, i32 %81, i32 0)
store i8* %82, i8** %11
%83 = load i8*, i8** %11
%84 = load i8*, i8** @MAP_FAILED
%85 = icmp eq i8* %83, %84
br i1 %85, label %86, label %89
86: ; preds = %77
%87 = load i32, i32* @stderr
%88 = call i32 @fprintf(i32 %87, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %119
89: ; preds = %77
%90 = load i8*, i8** %11
%91 = load i32, i32* %10
%92 = load i32, i32* @PROT_READ
%93 = load i32, i32* @PROT_WRITE
%94 = or i32 %92, %93
%95 = load i32, i32* @PROT_EXEC
%96 = or i32 %94, %95
%97 = call i32 @mprotect(i8* %90, i32 %91, i32 %96)
%98 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0))
%99 = call i32 @sleep(i32 100)
store i32 0, i32* %3
br label %119
100: ; preds = %54
%101 = load i8**, i8*** %5
%102 = getelementptr inbounds i8*, i8** %101, i64 1
%103 = load i8*, i8** %102
%104 = call i64 @strcmp(i8* %103, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%105 = icmp eq i64 %104, 0
br i1 %105, label %106, label %117
106: ; preds = %100
%107 = load i32, i32* @SYS_memfd_create
%108 = call i32 @syscall(i32 %107, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 0)
store i32 %108, i32* %12
%109 = load i32, i32* %12
%110 = icmp eq i32 %109, -1
br i1 %110, label %111, label %114
111: ; preds = %106
%112 = load i32, i32* @stderr
%113 = call i32 @fprintf(i32 %112, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %3
br label %119
114: ; preds = %106
%115 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0))
%116 = call i32 @sleep(i32 100)
store i32 0, i32* %3
br label %119
117: ; preds = %100
br label %118
118: ; preds = %117
br label %119
119: ; preds = %15, %30, %39, %42, %65, %74, %86, %89, %111, %114, %118
%120 = load i32, i32* %3
ret i32 %120
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [45 x i8] c"TESTING ERROR: memwrexe insufficient params\0A\00"
@.str.1 = [5 x i8] c"mmap\00"
@.str.2 = [11 x i8] c"memwrexe.c\00"
@O_RDONLY = global i32 0
@.str.3 = [53 x i8] c"TESTING ERROR: file not found, cannot run mmap test\0A\00"
@SEEK_END = global i32 0
@PROT_WRITE = global i32 0
@PROT_READ = global i32 0
@PROT_EXEC = global i32 0
@MAP_SHARED = global i32 0
@.str.5 = [9 x i8] c"mprotect\00"
@O_RDWR = global i32 0
@MAP_FAILED = global i8* null
@.str.6 = [50 x i8] c"TESTING ERROR: cannot map file for mprotect test\0A\00"
@.str.8 = [13 x i8] c"memfd_create\00"
@SYS_memfd_create = global i32 0
@.str.9 = [45 x i8] c"TESTING ERROR: cannot run memfd_create test\0A\00"
@str = [24 x i8] c"memfd_create successful\00"
@str.11 = [20 x i8] c"mprotect successful\00"
@str.12 = [16 x i8] c"mmap successful\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (...) @usage()
br label %87
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %37
13: ; preds = %8
%14 = load i32, i32* @O_RDONLY
%15 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
br label %87
20: ; preds = %13
%21 = load i32, i32* @SEEK_END
%22 = tail call i32 @lseek(i32 %15, i32 0, i32 %21)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
br label %87
27: ; preds = %20
%28 = load i32, i32* @PROT_WRITE
%29 = load i32, i32* @PROT_READ
%30 = or i32 %29, %28
%31 = load i32, i32* @PROT_EXEC
%32 = or i32 %30, %31
%33 = load i32, i32* @MAP_SHARED
%34 = tail call i8* @mmap(i32 0, i32 %22, i32 %32, i32 %33, i32 %15, i32 0)
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.12, i64 0, i64 0))
%36 = tail call i32 @sleep(i32 100)
br label %87
37: ; preds = %8
%38 = load i8*, i8** %9
%39 = tail call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %73
41: ; preds = %37
%42 = load i32, i32* @O_RDWR
%43 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %42)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i32, i32* @stderr
%47 = tail call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
br label %87
48: ; preds = %41
%49 = load i32, i32* @SEEK_END
%50 = tail call i32 @lseek(i32 %43, i32 0, i32 %49)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = load i32, i32* @stderr
%54 = tail call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
br label %87
55: ; preds = %48
%56 = load i32, i32* @PROT_READ
%57 = load i32, i32* @MAP_SHARED
%58 = tail call i8* @mmap(i32 0, i32 %50, i32 %56, i32 %57, i32 %43, i32 0)
%59 = load i8*, i8** @MAP_FAILED
%60 = icmp eq i8* %58, %59
br i1 %60, label %61, label %64
61: ; preds = %55
%62 = load i32, i32* @stderr
%63 = tail call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0))
br label %87
64: ; preds = %55
%65 = load i32, i32* @PROT_READ
%66 = load i32, i32* @PROT_WRITE
%67 = or i32 %66, %65
%68 = load i32, i32* @PROT_EXEC
%69 = or i32 %67, %68
%70 = tail call i32 @mprotect(i8* %58, i32 %50, i32 %69)
%71 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.11, i64 0, i64 0))
%72 = tail call i32 @sleep(i32 100)
br label %87
73: ; preds = %37
%74 = load i8*, i8** %9
%75 = tail call i64 @strcmp(i8* %74, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%76 = icmp eq i64 %75, 0
br i1 %76, label %77, label %87
77: ; preds = %73
%78 = load i32, i32* @SYS_memfd_create
%79 = tail call i32 @syscall(i32 %78, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 0)
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %84
81: ; preds = %77
%82 = load i32, i32* @stderr
%83 = tail call i32 @fprintf(i32 %82, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0))
br label %87
84: ; preds = %77
%85 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%86 = tail call i32 @sleep(i32 100)
br label %87
87: ; preds = %81, %84, %45, %61, %64, %52, %17, %27, %24, %73, %4
%88 = phi i32 [ 1, %4 ], [ 0, %73 ], [ 1, %17 ], [ 1, %24 ], [ 0, %27 ], [ 1, %45 ], [ 1, %52 ], [ 1, %61 ], [ 0, %64 ], [ 1, %81 ], [ 0, %84 ]
ret i32 %88
}