#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 O_APPEND;
int O_CREAT;
int O_RDONLY;
int O_RDWR;
int O_WRONLY;
int /*<<< orphan*/ printf(char *, ...);
int main() {
  printf("flag     hex  dec  \n");
  printf("------------------ \n");
  printf("O_RDONLY %04x %04d \n", O_RDONLY, O_RDONLY);
  printf("O_WRONLY %04x %04d \n", O_WRONLY, O_WRONLY);
  printf("O_RDWR   %04x %04d \n", O_RDWR, O_RDWR);
  printf("O_CREAT  %04x %04d \n", O_CREAT, O_CREAT);
  printf("O_APPEND %04x %04d \n", O_APPEND, O_APPEND);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e96(%rip),%rax
mov    (%rax),%esi
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%esi
mov    0x2e55(%rip),%rax
mov    (%rax),%edx
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%esi
mov    0x2e55(%rip),%rax
mov    (%rax),%edx
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%esi
mov    0x2e4d(%rip),%rax
mov    (%rax),%edx
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%esi
mov    0x2ded(%rip),%rax
mov    (%rax),%edx
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf41(%rip),%rdi
call   1030 <puts@plt>
lea    0xf49(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e98(%rip),%rax
mov    (%rax),%edx
lea    0xeb7(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edx
lea    0xeb3(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edx
lea    0xeaf(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edx
lea    0xeab(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%edx
lea    0xea7(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"flag hex dec \0A\00"
@.str.1 = [21 x i8] c"------------------ \0A\00"
@.str.2 = [21 x i8] c"O_RDONLY %04x %04d \0A\00"
@O_RDONLY = global i32 0
@.str.3 = [21 x i8] c"O_WRONLY %04x %04d \0A\00"
@O_WRONLY = global i32 0
@.str.4 = [21 x i8] c"O_RDWR %04x %04d \0A\00"
@O_RDWR = global i32 0
@.str.5 = [21 x i8] c"O_CREAT %04x %04d \0A\00"
@O_CREAT = global i32 0
@.str.6 = [21 x i8] c"O_APPEND %04x %04d \0A\00"
@O_APPEND = global i32 0
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%4 = load i32, i32* @O_RDONLY
%5 = load i32, i32* @O_RDONLY
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %5)
%7 = load i32, i32* @O_WRONLY
%8 = load i32, i32* @O_WRONLY
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %7, i32 %8)
%10 = load i32, i32* @O_RDWR
%11 = load i32, i32* @O_RDWR
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %10, i32 %11)
%13 = load i32, i32* @O_CREAT
%14 = load i32, i32* @O_CREAT
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %13, i32 %14)
%16 = load i32, i32* @O_APPEND
%17 = load i32, i32* @O_APPEND
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %16, i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [21 x i8] c"O_RDONLY %04x %04d \0A\00"
@O_RDONLY = global i32 0
@.str.3 = [21 x i8] c"O_WRONLY %04x %04d \0A\00"
@O_WRONLY = global i32 0
@.str.4 = [21 x i8] c"O_RDWR %04x %04d \0A\00"
@O_RDWR = global i32 0
@.str.5 = [21 x i8] c"O_CREAT %04x %04d \0A\00"
@O_CREAT = global i32 0
@.str.6 = [21 x i8] c"O_APPEND %04x %04d \0A\00"
@O_APPEND = global i32 0
@str = [20 x i8] c"flag hex dec \00"
@str.7 = [20 x i8] c"------------------ \00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.7, i64 0, i64 0))
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %3, i32 %3)
%5 = load i32, i32* @O_WRONLY
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %5, i32 %5)
%7 = load i32, i32* @O_RDWR
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %7, i32 %7)
%9 = load i32, i32* @O_CREAT
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %9, i32 %9)
%11 = load i32, i32* @O_APPEND
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %11, i32 %11)
ret i32 0
}