#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 /*<<< orphan*/ printf(char *, char *, char *, char *, char *, char *,
                          char *);
void print_flags(unsigned long flags) {
  printf(" * Paging based PAGE_EXEC       : %s \n"
         " * Trampolines                  : %s \n"
         " * mprotect()                   : %s \n"
         " * mmap() base                  : %s \n"
         " * ET_EXEC base                 : %s \n"
         " * Segmentation based PAGE_EXEC : %s \n",
         flags & 1    ? "disabled"
         : flags & 32 ? "enabled"
                      : "enabled (overridden)",
         flags & 2 ? "emulated" : "not emulated",
         flags & 4 ? "not restricted" : "restricted",
         flags & 8 ? "not randomized" : "randomized",
         flags & 16 ? "randomized" : "not randomized",
         flags & 32 ? "disabled" : "enabled");
}


x86 assembly (clang, -O0):
<print_flags>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     113e <print_flags+0x2e>
lea    0xfb0(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1160 <print_flags+0x50>
mov    -0x8(%rbp),%rdx
and    $0x20,%rdx
lea    0xfa9(%rip),%rax
lea    0xf9a(%rip),%rcx
cmp    $0x0,%rdx
cmovne %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rcx
and    $0x2,%rcx
lea    0xf98(%rip),%rdx
lea    0xf95(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
mov    -0x8(%rbp),%rdi
and    $0x4,%rdi
lea    0xf8b(%rip),%rcx
lea    0xf80(%rip),%rax
cmp    $0x0,%rdi
cmovne %rax,%rcx
mov    -0x8(%rbp),%rdi
and    $0x8,%rdi
lea    0xf7c(%rip),%r8
lea    0xf71(%rip),%rax
cmp    $0x0,%rdi
cmovne %rax,%r8
mov    -0x8(%rbp),%rdi
and    $0x10,%rdi
lea    0xf5a(%rip),%r9
lea    0xf57(%rip),%rax
cmp    $0x0,%rdi
cmovne %rax,%r9
mov    -0x8(%rbp),%r10
and    $0x20,%r10
lea    0xf03(%rip),%rax
lea    0xef3(%rip),%rdi
cmp    $0x0,%r10
cmovne %rdi,%rax
lea    0xdff(%rip),%rdi
mov    %rax,(%rsp)
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_flags>:
push   %rax
test   $0x20,%dil
lea    0xfda(%rip),%rsi
lea    0xfcb(%rip),%rax
cmovne %rax,%rsi
lea    0xfb7(%rip),%rcx
cmovne %rcx,%rax
test   $0x1,%dil
cmovne %rcx,%rsi
test   $0x2,%dil
lea    0xfc6(%rip),%rcx
lea    0xfc3(%rip),%rdx
cmove  %rcx,%rdx
test   $0x4,%dil
lea    0xfc1(%rip),%r8
lea    0xfb6(%rip),%rcx
cmove  %r8,%rcx
test   $0x8,%dil
lea    0xfba(%rip),%r9
lea    0xfaf(%rip),%r10
mov    %r10,%r8
cmove  %r9,%r8
test   $0x10,%dil
cmove  %r10,%r9
mov    %rax,(%rsp)
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [229 x i8] c" * Paging based PAGE_EXEC : %s \0A * Trampolines : %s \0A * mprotect() : %s \0A * mmap() base : %s \0A * ET_EXEC base : %s \0A * Segmentation based PAGE_EXEC : %s \0A\00"
@.str.1 = [9 x i8] c"disabled\00"
@.str.2 = [8 x i8] c"enabled\00"
@.str.3 = [21 x i8] c"enabled (overridden)\00"
@.str.4 = [9 x i8] c"emulated\00"
@.str.5 = [13 x i8] c"not emulated\00"
@.str.6 = [15 x i8] c"not restricted\00"
@.str.7 = [11 x i8] c"restricted\00"
@.str.8 = [15 x i8] c"not randomized\00"
@.str.9 = [11 x i8] c"randomized\00"
define void @print_flags(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = and i64 %3, 1
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
br label %13
7: ; preds = %1
%8 = load i64, i64* %2
%9 = and i64 %8, 32
%10 = icmp ne i64 %9, 0
%11 = zext i1 %10 to i64
%12 = select i1 %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0)
br label %13
13: ; preds = %7, %6
%14 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %6 ], [ %12, %7 ]
%15 = load i64, i64* %2
%16 = and i64 %15, 2
%17 = icmp ne i64 %16, 0
%18 = zext i1 %17 to i64
%19 = select i1 %17, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0)
%20 = load i64, i64* %2
%21 = and i64 %20, 4
%22 = icmp ne i64 %21, 0
%23 = zext i1 %22 to i64
%24 = select i1 %22, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0)
%25 = load i64, i64* %2
%26 = and i64 %25, 8
%27 = icmp ne i64 %26, 0
%28 = zext i1 %27 to i64
%29 = select i1 %27, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0)
%30 = load i64, i64* %2
%31 = and i64 %30, 16
%32 = icmp ne i64 %31, 0
%33 = zext i1 %32 to i64
%34 = select i1 %32, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0)
%35 = load i64, i64* %2
%36 = and i64 %35, 32
%37 = icmp ne i64 %36, 0
%38 = zext i1 %37 to i64
%39 = select i1 %37, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0)
%40 = call i32 @printf(i8* getelementptr inbounds ([229 x i8], [229 x i8]* @.str, i64 0, i64 0), i8* %14, i8* %19, i8* %24, i8* %29, i8* %34, i8* %39)
ret void
}

LLVM IR (-O2):
@.str = [229 x i8] c" * Paging based PAGE_EXEC : %s \0A * Trampolines : %s \0A * mprotect() : %s \0A * mmap() base : %s \0A * ET_EXEC base : %s \0A * Segmentation based PAGE_EXEC : %s \0A\00"
@.str.1 = [9 x i8] c"disabled\00"
@.str.2 = [8 x i8] c"enabled\00"
@.str.3 = [21 x i8] c"enabled (overridden)\00"
@.str.4 = [9 x i8] c"emulated\00"
@.str.5 = [13 x i8] c"not emulated\00"
@.str.6 = [15 x i8] c"not restricted\00"
@.str.7 = [11 x i8] c"restricted\00"
@.str.8 = [15 x i8] c"not randomized\00"
@.str.9 = [11 x i8] c"randomized\00"
define void @print_flags(i64 %0) {
%2 = and i64 %0, 1
%3 = icmp eq i64 %2, 0
%4 = and i64 %0, 32
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0)
%7 = select i1 %3, i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0)
%8 = and i64 %0, 2
%9 = icmp eq i64 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0)
%11 = and i64 %0, 4
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0)
%14 = and i64 %0, 8
%15 = icmp eq i64 %14, 0
%16 = select i1 %15, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0)
%17 = and i64 %0, 16
%18 = icmp eq i64 %17, 0
%19 = select i1 %18, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0)
%20 = select i1 %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0)
%21 = tail call i32 @printf(i8* getelementptr inbounds ([229 x i8], [229 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %10, i8* %13, i8* %16, i8* %19, i8* %20)
ret void
}