#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_NONBLOCK;
int O_RDONLY;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int open(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int open_fifo(char *command_fifo_filename) {
  int fifo_fd = open(command_fifo_filename, O_RDONLY | O_NONBLOCK);
  if (fifo_fd < 0) {
    fprintf(stderr, "vegas_fits_writer: Error opening control fifo %s\n",
            command_fifo_filename);
    perror("open");
  }
  printf("Using FITS Control FIFO: %s\n", command_fifo_filename);
  return fifo_fd;
}


x86 assembly (clang, -O0):
<open_fifo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
mov    0x2e88(%rip),%rax
or     (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1199 <open_fifo+0x59>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe78(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe9e(%rip),%rdi
call   1060 <perror@plt>
mov    -0x8(%rbp),%rsi
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_fifo>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e93(%rip),%rax
mov    0x2e94(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
call   1050 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
js     117b <open_fifo+0x3b>
lea    0xecd(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
lea    0xe98(%rip),%rdi
call   1060 <perror@plt>
jmp    1163 <open_fifo+0x23>

LLVM IR (-O0):
@O_RDONLY = global i32 0
@O_NONBLOCK = global i32 0
@stderr = global i32 0
@.str = [50 x i8] c"vegas_fits_writer: Error opening control fifo %s\0A\00"
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [29 x i8] c"Using FITS Control FIFO: %s\0A\00"
define i32 @open_fifo(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i32, i32* @O_RDONLY
%6 = load i32, i32* @O_NONBLOCK
%7 = or i32 %5, %6
%8 = call i32 @open(i8* %4, i32 %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %2
%14 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %11, %1
%17 = load i8*, i8** %2
%18 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = load i32, i32* %3
ret i32 %19
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@O_NONBLOCK = global i32 0
@stderr = global i32 0
@.str = [50 x i8] c"vegas_fits_writer: Error opening control fifo %s\0A\00"
@.str.1 = [5 x i8] c"open\00"
@.str.2 = [29 x i8] c"Using FITS Control FIFO: %s\0A\00"
define i32 @open_fifo(i8* %0) {
%2 = load i32, i32* @O_RDONLY
%3 = load i32, i32* @O_NONBLOCK
%4 = or i32 %3, %2
%5 = tail call i32 @open(i8* %0, i32 %4)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %0)
%10 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %7, %1
%12 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %0)
ret i32 %5
}