#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 *);
int sectests();
int main(void) {
  int flags = sectests();
  printf("ASLR [%s]\n", (flags & 0x1) ? "ON" : "OFF");
  printf("NX   [%s]\n", (flags & 0x2) ? "ON" : "OFF");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <sectests@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
and    $0x1,%ecx
lea    0xec8(%rip),%rsi
lea    0xebe(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%ecx
and    $0x2,%ecx
lea    0xea1(%rip),%rsi
lea    0xe97(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <sectests@plt>
mov    %eax,%ebp
test   $0x1,%bpl
lea    0xed6(%rip),%r14
lea    0xecc(%rip),%rbx
mov    %rbx,%rsi
cmove  %r14,%rsi
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
test   $0x2,%bpl
cmove  %r14,%rbx
lea    0xeb1(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"ASLR [%s]\0A\00"
@.str.1 = [3 x i8] c"ON\00"
@.str.2 = [4 x i8] c"OFF\00"
@.str.3 = [11 x i8] c"NX [%s]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (...) @sectests()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = and i32 %4, 1
%6 = icmp ne i32 %5, 0
%7 = zext i1 %6 to i64
%8 = select i1 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%9 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* %2
%11 = and i32 %10, 2
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%15 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %14)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"ASLR [%s]\0A\00"
@.str.1 = [3 x i8] c"ON\00"
@.str.2 = [4 x i8] c"OFF\00"
@.str.3 = [11 x i8] c"NX [%s]\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @sectests()
%2 = and i32 %1, 1
%3 = icmp eq i32 %2, 0
%4 = select i1 %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = and i32 %1, 2
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %8)
ret i32 0
}