#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 */
typedef int /*<<< orphan*/ off_t;

/* Variables and functions */
int O_RDONLY;
int /*<<< orphan*/ printf(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ puts(char *);
void info(int fd, off_t position, int flags) {
  int is_flag;
  printf("  File descriptor %d\n"
         "  File offset %lld\n",
         fd, position);
  is_flag = flags & O_RDONLY;
  if (is_flag == O_RDONLY) {
    puts("  File flag is O_RDONLY");
  } else {
    puts("  File flag is not O_RDONLY");
  }
}


x86 assembly (clang, -O0):
<info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xec2(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
mov    0x2e9b(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%eax
jne    1175 <info+0x55>
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
jmp    1181 <info+0x61>
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<info>:
push   %rbx
mov    %edx,%ebx
mov    %esi,%edx
mov    %edi,%esi
lea    0xed2(%rip),%rdi
call   1040 <printf@plt>
mov    0x2eae(%rip),%rax
not    %ebx
and    (%rax),%ebx
lea    0xee4(%rip),%rax
lea    0xef5(%rip),%rdi
cmove  %rax,%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [41 x i8] c" File descriptor %d\0A File offset %lld\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [24 x i8] c" File flag is O_RDONLY\00"
@.str.2 = [28 x i8] c" File flag is not O_RDONLY\00"
define void @info(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = load i32, i32* %5
%10 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
%11 = load i32, i32* %6
%12 = load i32, i32* @O_RDONLY
%13 = and i32 %11, %12
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = load i32, i32* @O_RDONLY
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %3
%18 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %21
19: ; preds = %3
%20 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c" File descriptor %d\0A File offset %lld\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [24 x i8] c" File flag is O_RDONLY\00"
@.str.2 = [28 x i8] c" File flag is not O_RDONLY\00"
define void @info(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%5 = load i32, i32* @O_RDONLY
%6 = and i32 %5, %2
%7 = icmp eq i32 %6, %5
%8 = select i1 %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0)
%9 = tail call i32 @puts(i8* dereferenceable(1) %8)
ret void
}