#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(int argc, char *argv[]) {
  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);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%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(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
store i32 %0, i32* %3
store i8** %1, i8*** %4
%5 = load i32, i32* @O_RDONLY
%6 = call i32 @display_flags(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @O_WRONLY
%8 = call i32 @display_flags(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @O_RDWR
%10 = call i32 @display_flags(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32, i32* @O_APPEND
%13 = call i32 @display_flags(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @O_TRUNC
%15 = call i32 @display_flags(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %14)
%16 = load i32, i32* @O_CREAT
%17 = call i32 @display_flags(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%19 = load i32, i32* @O_WRONLY
%20 = load i32, i32* @O_APPEND
%21 = or i32 %19, %20
%22 = load i32, i32* @O_CREAT
%23 = or i32 %21, %22
%24 = call i32 @display_flags(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %23)
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(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @display_flags(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32, i32* @O_WRONLY
%6 = tail call i32 @display_flags(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @O_RDWR
%8 = tail call i32 @display_flags(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = tail call i32 @putchar(i32 10)
%10 = load i32, i32* @O_APPEND
%11 = tail call i32 @display_flags(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @O_TRUNC
%13 = tail call i32 @display_flags(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @O_CREAT
%15 = tail call i32 @display_flags(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %14)
%16 = tail call i32 @putchar(i32 10)
%17 = load i32, i32* @O_WRONLY
%18 = load i32, i32* @O_APPEND
%19 = or i32 %18, %17
%20 = load i32, i32* @O_CREAT
%21 = or i32 %19, %20
%22 = tail call i32 @display_flags(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %21)
ret i32 0
}