#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_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ display_flags(char *, int);
int /*<<< orphan*/ printf(char *);
int main() {
  display_flags("O_RDONLY\t\t", O_RDONLY);
  display_flags("O_WRONLY\t\t", O_WRONLY);
  display_flags("O_RDWR\t\t\t", O_RDWR);
  printf("\n");
  display_flags("O_APPEND\t\t", O_APPEND);
  display_flags("O_TRUNC\t\t\t", O_TRUNC);
  display_flags("O_CREAT\t\t\t", O_CREAT);
  printf("\n");
  display_flags("O_WRONLY|O_APPEND|O_CREAT", O_WRONLY | O_APPEND | O_CREAT);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%esi
lea    0xec1(%rip),%rdi
call   1040 <display_flags@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%esi
lea    0xeb7(%rip),%rdi
call   1040 <display_flags@plt>
mov    0x2e78(%rip),%rax
mov    (%rax),%esi
lea    0xead(%rip),%rdi
call   1040 <display_flags@plt>
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%esi
lea    0xe98(%rip),%rdi
call   1040 <display_flags@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
lea    0xe8e(%rip),%rdi
call   1040 <display_flags@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%esi
lea    0xe84(%rip),%rdi
call   1040 <display_flags@plt>
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%esi
mov    0x2ddb(%rip),%rax
or     (%rax),%esi
mov    0x2e1a(%rip),%rax
or     (%rax),%esi
lea    0xe5c(%rip),%rdi
call   1040 <display_flags@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2ea4(%rip),%rax
mov    (%rax),%esi
lea    0xecb(%rip),%rdi
call   1040 <display_flags@plt>
mov    0x2e77(%rip),%r14
mov    (%r14),%esi
lea    0xec0(%rip),%rdi
call   1040 <display_flags@plt>
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
lea    0xeb6(%rip),%rdi
call   1040 <display_flags@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2e3a(%rip),%r15
mov    (%r15),%esi
lea    0xea0(%rip),%rdi
call   1040 <display_flags@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%esi
lea    0xe96(%rip),%rdi
call   1040 <display_flags@plt>
mov    0x2e57(%rip),%rbx
mov    (%rbx),%esi
lea    0xe8c(%rip),%rdi
call   1040 <display_flags@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%r15),%esi
or     (%r14),%esi
or     (%rbx),%esi
lea    0xe79(%rip),%rdi
call   1040 <display_flags@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"O_RDONLY\09\09\00"
@O_RDONLY = global i32 0
@.str.1 = [11 x i8] c"O_WRONLY\09\09\00"
@O_WRONLY = global i32 0
@.str.2 = [10 x i8] c"O_RDWR\09\09\09\00"
@O_RDWR = global i32 0
@.str.4 = [11 x i8] c"O_APPEND\09\09\00"
@O_APPEND = global i32 0
@.str.5 = [11 x i8] c"O_TRUNC\09\09\09\00"
@O_TRUNC = global i32 0
@.str.6 = [11 x i8] c"O_CREAT\09\09\09\00"
@O_CREAT = global i32 0
@.str.7 = [26 x i8] c"O_WRONLY|O_APPEND|O_CREAT\00"
define i32 @main() {
%1 = load i32, i32* @O_RDONLY
%2 = tail call i32 @display_flags(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = load i32, i32* @O_WRONLY
%4 = tail call i32 @display_flags(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = load i32, i32* @O_RDWR
%6 = tail call i32 @display_flags(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%7 = tail call i32 @putchar(i32 10)
%8 = load i32, i32* @O_APPEND
%9 = tail call i32 @display_flags(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @O_TRUNC
%11 = tail call i32 @display_flags(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @O_CREAT
%13 = tail call i32 @display_flags(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %12)
%14 = tail call i32 @putchar(i32 10)
%15 = load i32, i32* @O_WRONLY
%16 = load i32, i32* @O_APPEND
%17 = or i32 %16, %15
%18 = load i32, i32* @O_CREAT
%19 = or i32 %17, %18
%20 = tail call i32 @display_flags(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %19)
ret i32 0
}