#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 */
int EXIT_SUCCESS;
int MAP_FILE;
int MAP_SHARED;
int O_CREAT;
int O_RDWR;
int O_TRUNC;
int PROT_EXEC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ _SC_PAGESIZE;
int /*<<< orphan*/ close(int);
int dup(int);
int /*<<< orphan*/ ftruncate(int, long);
char *mmap(int /*<<< orphan*/ *, long, int, int, int, int /*<<< orphan*/);
int shm_open(char *, int, int);
int /*<<< orphan*/ shm_unlink(char *);
long sysconf(int /*<<< orphan*/);
int main(int argc, char **argv) {
  long pz;
  int h, h2;
  char *w, *e;
  int i;
  pz = sysconf(_SC_PAGESIZE);
  h = shm_open("/jmploop", O_CREAT | O_TRUNC | O_RDWR, 0755);
  h2 = dup(h);
  ftruncate(h, pz);
  w = mmap(NULL, pz, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, h, 0);
  e = mmap(NULL, pz, PROT_READ | PROT_EXEC, MAP_FILE | MAP_SHARED, h2, 0);
  close(h);
  close(h2);
  for (i = 0; i < pz; i += 2) {
    w[i] = 0xeb;
    w[i + 1] = 0xfe;
  }
  w[0] = 0xeb;
  w[1] = 0xfc;
  void (*run)(void) = (void (*)(void))(e + 8);
  run();
  shm_unlink("/jmploop");
  return EXIT_SUCCESS;
}


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)
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
call   1070 <sysconf@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
mov    0x2e48(%rip),%rax
or     (%rax),%esi
mov    0x2e17(%rip),%rax
or     (%rax),%esi
lea    0xe46(%rip),%rdi
mov    $0x1ed,%edx
call   1080 <shm_open@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <dup@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <ftruncate@plt>
mov    -0x18(%rbp),%rsi
mov    0x2dff(%rip),%rax
mov    (%rax),%edx
mov    0x2dae(%rip),%rax
or     (%rax),%edx
mov    0x2dc5(%rip),%rax
mov    (%rax),%ecx
mov    0x2dd4(%rip),%rax
or     (%rax),%ecx
mov    -0x1c(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rsi
mov    0x2dc3(%rip),%rax
mov    (%rax),%edx
mov    0x2d82(%rip),%rax
or     (%rax),%edx
mov    0x2d89(%rip),%rax
mov    (%rax),%ecx
mov    0x2d98(%rip),%rax
or     (%rax),%ecx
mov    -0x20(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    12a6 <main+0x136>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movb   $0xeb,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0xfe,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x34(%rbp)
jmp    126d <main+0xfd>
mov    -0x28(%rbp),%rax
movb   $0xeb,(%rax)
mov    -0x28(%rbp),%rax
movb   $0xfc,0x1(%rax)
mov    -0x30(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x40(%rbp)
call   *-0x40(%rbp)
lea    0xd35(%rip),%rdi
call   1090 <shm_unlink@plt>
mov    0x2cc1(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
call   1070 <sysconf@plt>
mov    0x2e68(%rip),%rcx
mov    0x2e59(%rip),%rdx
mov    (%rdx),%esi
or     (%rcx),%esi
mov    %rax,%r14
mov    0x2e23(%rip),%rax
or     (%rax),%esi
lea    0xe62(%rip),%rdi
mov    $0x1ed,%edx
call   1080 <shm_open@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1050 <dup@plt>
mov    %eax,%r12d
mov    %ebp,%edi
mov    %r14,%rsi
call   1040 <ftruncate@plt>
mov    0x2e13(%rip),%rbx
mov    0x2dc4(%rip),%rax
mov    (%rax),%edx
or     (%rbx),%edx
mov    0x2dd9(%rip),%r15
mov    0x2dea(%rip),%r13
mov    0x0(%r13),%ecx
or     (%r15),%ecx
xor    %edi,%edi
mov    %r14,%rsi
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    0x2da4(%rip),%rcx
mov    (%rcx),%edx
or     (%rbx),%edx
mov    %rax,%rbx
mov    0x0(%r13),%ecx
or     (%r15),%ecx
xor    %edi,%edi
mov    %r14,%rsi
mov    %r12d,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%r15
mov    %ebp,%edi
call   1060 <close@plt>
mov    %r12d,%edi
call   1060 <close@plt>
test   %r14,%r14
jle    130f <main+0x19f>
lea    -0x1(%r14),%rcx
cmp    $0x1e,%rcx
jae    1256 <main+0xe6>
xor    %eax,%eax
jmp    1300 <main+0x190>
shr    %rcx
add    $0x1,%rcx
mov    %rcx,%rax
and    $0xfffffffffffffff0,%rax
lea    -0x10(%rax),%rsi
mov    %rsi,%rdi
shr    $0x4,%rdi
add    $0x1,%rdi
mov    %edi,%edx
and    $0x3,%edx
cmp    $0x30,%rsi
jae    1282 <main+0x112>
xor    %esi,%esi
jmp    12c1 <main+0x151>
and    $0xfffffffffffffffc,%rdi
xor    %esi,%esi
movaps 0xd71(%rip),%xmm0
nop
movups %xmm0,(%rbx,%rsi,2)
movups %xmm0,0x10(%rbx,%rsi,2)
movups %xmm0,0x20(%rbx,%rsi,2)
movups %xmm0,0x30(%rbx,%rsi,2)
movups %xmm0,0x40(%rbx,%rsi,2)
movups %xmm0,0x50(%rbx,%rsi,2)
movups %xmm0,0x60(%rbx,%rsi,2)
movups %xmm0,0x70(%rbx,%rsi,2)
add    $0x40,%rsi
add    $0xfffffffffffffffc,%rdi
jne    1290 <main+0x120>
test   %rdx,%rdx
je     12ea <main+0x17a>
add    %rsi,%rsi
movaps 0xd30(%rip),%xmm0
mov    %rsi,%rdi
or     $0x11,%rdi
movups %xmm0,(%rbx,%rsi,1)
movups %xmm0,-0x1(%rbx,%rdi,1)
add    $0x20,%rsi
add    $0xffffffffffffffff,%rdx
jne    12d0 <main+0x160>
cmp    %rax,%rcx
je     130f <main+0x19f>
add    %rax,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movw   $0xfeeb,(%rbx,%rax,1)
add    $0x2,%rax
cmp    %rax,%r14
jg     1300 <main+0x190>
movw   $0xfceb,(%rbx)
add    $0x8,%r15
call   *%r15
lea    0xcee(%rip),%rdi
call   1090 <shm_unlink@plt>
mov    0x2c6a(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@_SC_PAGESIZE = global i32 0
@.str = [9 x i8] c"/jmploop\00"
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_RDWR = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_FILE = global i32 0
@MAP_SHARED = global i32 0
@PROT_EXEC = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca void ()*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* @_SC_PAGESIZE
%14 = call i64 @sysconf(i32 %13)
store i64 %14, i64* %6
%15 = load i32, i32* @O_CREAT
%16 = load i32, i32* @O_TRUNC
%17 = or i32 %15, %16
%18 = load i32, i32* @O_RDWR
%19 = or i32 %17, %18
%20 = call i32 @shm_open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %19, i32 493)
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = call i32 @dup(i32 %21)
store i32 %22, i32* %8
%23 = load i32, i32* %7
%24 = load i64, i64* %6
%25 = call i32 @ftruncate(i32 %23, i64 %24)
%26 = load i64, i64* %6
%27 = load i32, i32* @PROT_READ
%28 = load i32, i32* @PROT_WRITE
%29 = or i32 %27, %28
%30 = load i32, i32* @MAP_FILE
%31 = load i32, i32* @MAP_SHARED
%32 = or i32 %30, %31
%33 = load i32, i32* %7
%34 = call i8* @mmap(i32* null, i64 %26, i32 %29, i32 %32, i32 %33, i32 0)
store i8* %34, i8** %9
%35 = load i64, i64* %6
%36 = load i32, i32* @PROT_READ
%37 = load i32, i32* @PROT_EXEC
%38 = or i32 %36, %37
%39 = load i32, i32* @MAP_FILE
%40 = load i32, i32* @MAP_SHARED
%41 = or i32 %39, %40
%42 = load i32, i32* %8
%43 = call i8* @mmap(i32* null, i64 %35, i32 %38, i32 %41, i32 %42, i32 0)
store i8* %43, i8** %10
%44 = load i32, i32* %7
%45 = call i32 @close(i32 %44)
%46 = load i32, i32* %8
%47 = call i32 @close(i32 %46)
store i32 0, i32* %11
br label %48
48: ; preds = %63, %2
%49 = load i32, i32* %11
%50 = sext i32 %49 to i64
%51 = load i64, i64* %6
%52 = icmp slt i64 %50, %51
br i1 %52, label %53, label %66
53: ; preds = %48
%54 = load i8*, i8** %9
%55 = load i32, i32* %11
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
store i8 -21, i8* %57
%58 = load i8*, i8** %9
%59 = load i32, i32* %11
%60 = add nsw i32 %59, 1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %58, i64 %61
store i8 -2, i8* %62
br label %63
63: ; preds = %53
%64 = load i32, i32* %11
%65 = add nsw i32 %64, 2
store i32 %65, i32* %11
br label %48
66: ; preds = %48
%67 = load i8*, i8** %9
%68 = getelementptr inbounds i8, i8* %67, i64 0
store i8 -21, i8* %68
%69 = load i8*, i8** %9
%70 = getelementptr inbounds i8, i8* %69, i64 1
store i8 -4, i8* %70
%71 = load i8*, i8** %10
%72 = getelementptr inbounds i8, i8* %71, i64 8
%73 = bitcast i8* %72 to void ()*
store void ()* %73, void ()** %12
%74 = load void ()*, void ()** %12
%75 = call i32 @shm_unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%76 = load i32, i32* @EXIT_SUCCESS
ret i32 %76
}

LLVM IR (-O2):
@_SC_PAGESIZE = global i32 0
@.str = [9 x i8] c"/jmploop\00"
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@O_RDWR = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_FILE = global i32 0
@MAP_SHARED = global i32 0
@PROT_EXEC = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @_SC_PAGESIZE
%4 = tail call i64 @sysconf(i32 %3)
%5 = load i32, i32* @O_CREAT
%6 = load i32, i32* @O_TRUNC
%7 = or i32 %6, %5
%8 = load i32, i32* @O_RDWR
%9 = or i32 %7, %8
%10 = tail call i32 @shm_open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %9, i32 493)
%11 = tail call i32 @dup(i32 %10)
%12 = tail call i32 @ftruncate(i32 %10, i64 %4)
%13 = load i32, i32* @PROT_READ
%14 = load i32, i32* @PROT_WRITE
%15 = or i32 %14, %13
%16 = load i32, i32* @MAP_FILE
%17 = load i32, i32* @MAP_SHARED
%18 = or i32 %17, %16
%19 = tail call i8* @mmap(i32* null, i64 %4, i32 %15, i32 %18, i32 %10, i32 0)
%20 = load i32, i32* @PROT_READ
%21 = load i32, i32* @PROT_EXEC
%22 = or i32 %21, %20
%23 = load i32, i32* @MAP_FILE
%24 = load i32, i32* @MAP_SHARED
%25 = or i32 %24, %23
%26 = tail call i8* @mmap(i32* null, i64 %4, i32 %22, i32 %25, i32 %11, i32 0)
%27 = tail call i32 @close(i32 %10)
%28 = tail call i32 @close(i32 %11)
%29 = icmp sgt i64 %4, 0
br i1 %29, label %30, label %117
30: ; preds = %2
%31 = add i64 %4, -1
%32 = lshr i64 %31, 1
%33 = add nuw i64 %32, 1
%34 = icmp ult i64 %31, 30
br i1 %34, label %108, label %35
35: ; preds = %30
%36 = and i64 %33, -16
%37 = shl i64 %36, 1
%38 = add i64 %36, -16
%39 = lshr exact i64 %38, 4
%40 = add nuw nsw i64 %39, 1
%41 = and i64 %40, 3
%42 = icmp ult i64 %38, 48
br i1 %42, label %87, label %43
43: ; preds = %35
%44 = and i64 %40, 2305843009213693948
%45 = getelementptr inbounds i8, i8* %19, i64 -1
%46 = getelementptr inbounds i8, i8* %19, i64 -1
%47 = getelementptr inbounds i8, i8* %19, i64 -1
%48 = getelementptr inbounds i8, i8* %19, i64 -1
%49 = getelementptr inbounds i8, i8* %19, i64 -1
%50 = getelementptr inbounds i8, i8* %19, i64 -1
%51 = getelementptr inbounds i8, i8* %19, i64 -1
%52 = getelementptr inbounds i8, i8* %19, i64 -1
br label %53
53: ; preds = %53, %43
%54 = phi i64 [ 0, %43 ], [ %84, %53 ]
%55 = phi i64 [ 0, %43 ], [ %85, %53 ]
%56 = shl i64 %54, 1
%57 = or i64 %56, 1
%58 = or i64 %56, 17
%59 = getelementptr inbounds i8, i8* %45, i64 %57
%60 = bitcast i8* %59 to <16 x i8>*
%61 = getelementptr inbounds i8, i8* %46, i64 %58
%62 = bitcast i8* %61 to <16 x i8>*
store <16 x i8> <i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2>, <16 x i8>* %60
store <16 x i8> <i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2>, <16 x i8>* %62
%63 = shl i64 %54, 1
%64 = or i64 %63, 33
%65 = or i64 %63, 49
%66 = getelementptr inbounds i8, i8* %47, i64 %64
%67 = bitcast i8* %66 to <16 x i8>*
%68 = getelementptr inbounds i8, i8* %48, i64 %65
%69 = bitcast i8* %68 to <16 x i8>*
store <16 x i8> <i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2>, <16 x i8>* %67
store <16 x i8> <i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2>, <16 x i8>* %69
%70 = shl i64 %54, 1
%71 = or i64 %70, 65
%72 = or i64 %70, 81
%73 = getelementptr inbounds i8, i8* %49, i64 %71
%74 = bitcast i8* %73 to <16 x i8>*
%75 = getelementptr inbounds i8, i8* %50, i64 %72
%76 = bitcast i8* %75 to <16 x i8>*
store <16 x i8> <i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2>, <16 x i8>* %74
store <16 x i8> <i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2>, <16 x i8>* %76
%77 = shl i64 %54, 1
%78 = or i64 %77, 97
%79 = or i64 %77, 113
%80 = getelementptr inbounds i8, i8* %51, i64 %78
%81 = bitcast i8* %80 to <16 x i8>*
%82 = getelementptr inbounds i8, i8* %52, i64 %79
%83 = bitcast i8* %82 to <16 x i8>*
store <16 x i8> <i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2>, <16 x i8>* %81
store <16 x i8> <i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2>, <16 x i8>* %83
%84 = add nuw i64 %54, 64
%85 = add i64 %55, 4
%86 = icmp eq i64 %85, %44
br i1 %86, label %87, label %53
87: ; preds = %53, %35
%88 = phi i64 [ 0, %35 ], [ %84, %53 ]
%89 = icmp eq i64 %41, 0
br i1 %89, label %106, label %90
90: ; preds = %87
%91 = getelementptr inbounds i8, i8* %19, i64 -1
%92 = getelementptr inbounds i8, i8* %19, i64 -1
br label %93
93: ; preds = %93, %90
%94 = phi i64 [ %88, %90 ], [ %103, %93 ]
%95 = phi i64 [ 0, %90 ], [ %104, %93 ]
%96 = shl i64 %94, 1
%97 = or i64 %96, 1
%98 = or i64 %96, 17
%99 = getelementptr inbounds i8, i8* %91, i64 %97
%100 = bitcast i8* %99 to <16 x i8>*
%101 = getelementptr inbounds i8, i8* %92, i64 %98
%102 = bitcast i8* %101 to <16 x i8>*
store <16 x i8> <i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2>, <16 x i8>* %100
store <16 x i8> <i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2, i8 -21, i8 -2>, <16 x i8>* %102
%103 = add nuw i64 %94, 16
%104 = add i64 %95, 1
%105 = icmp eq i64 %104, %41
br i1 %105, label %106, label %93
106: ; preds = %93, %87
%107 = icmp eq i64 %33, %36
br i1 %107, label %117, label %108
108: ; preds = %30, %106
%109 = phi i64 [ 0, %30 ], [ %37, %106 ]
br label %110
110: ; preds = %108, %110
%111 = phi i64 [ %115, %110 ], [ %109, %108 ]
%112 = getelementptr inbounds i8, i8* %19, i64 %111
store i8 -21, i8* %112
%113 = or i64 %111, 1
%114 = getelementptr inbounds i8, i8* %19, i64 %113
store i8 -2, i8* %114
%115 = add nuw nsw i64 %111, 2
%116 = icmp sgt i64 %4, %115
br i1 %116, label %110, label %117
117: ; preds = %110, %106, %2
store i8 -21, i8* %19
%118 = getelementptr inbounds i8, i8* %19, i64 1
store i8 -4, i8* %118
%119 = getelementptr inbounds i8, i8* %26, i64 8
%120 = bitcast i8* %119 to void ()*
tail call void %120()
%121 = tail call i32 @shm_unlink(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%122 = load i32, i32* @EXIT_SUCCESS
ret i32 %122
}