#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 /*<<< orphan*/ F_GETFL;
int O_RDONLY;
int /*<<< orphan*/ SEEK_CUR;
int fcntl(int, int /*<<< orphan*/);
int /*<<< orphan*/ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ puts(char *);
void info(int fd) {
  off_t position;
  int flags, is_flag;
  flags = fcntl(fd, F_GETFL);
  position = lseek(fd, 0, SEEK_CUR);
  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    -0x4(%rbp),%edi
mov    0x2e7b(%rip),%rax
mov    (%rax),%esi
call   1040 <fcntl@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e7f(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <lseek@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe7e(%rip),%rdi
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
mov    0x2e4f(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    0x2e40(%rip),%rcx
cmp    (%rcx),%eax
jne    11b9 <info+0x79>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
jmp    11c5 <info+0x85>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<info>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
call   1040 <fcntl@plt>
mov    %eax,%ebp
mov    0x2e8c(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1060 <lseek@plt>
lea    0xe92(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1050 <printf@plt>
mov    0x2e62(%rip),%rax
not    %ebp
and    (%rax),%ebp
lea    0xea0(%rip),%rax
lea    0xeb1(%rip),%rdi
cmove  %rax,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@F_GETFL = global i32 0
@SEEK_CUR = global i32 0
@.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) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = load i32, i32* @F_GETFL
%8 = call i32 @fcntl(i32 %6, i32 %7)
store i32 %8, i32* %4
%9 = load i32, i32* %2
%10 = load i32, i32* @SEEK_CUR
%11 = call i32 @lseek(i32 %9, i32 0, i32 %10)
store i32 %11, i32* %3
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13)
%15 = load i32, i32* %4
%16 = load i32, i32* @O_RDONLY
%17 = and i32 %15, %16
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = load i32, i32* @O_RDONLY
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %1
%22 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %25
23: ; preds = %1
%24 = call i32 @puts(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %23, %21
ret void
}

LLVM IR (-O2):
@F_GETFL = global i32 0
@SEEK_CUR = global i32 0
@.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) {
%2 = load i32, i32* @F_GETFL
%3 = tail call i32 @fcntl(i32 %0, i32 %2)
%4 = load i32, i32* @SEEK_CUR
%5 = tail call i32 @lseek(i32 %0, i32 0, i32 %4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %5)
%7 = load i32, i32* @O_RDONLY
%8 = and i32 %7, %3
%9 = icmp eq i32 %8, %7
%10 = select i1 %9, 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)
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
ret void
}