#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ strcmp(char *, char *);
FILE *open_fasta(char filename[], int nomsg, int quiet) {
  FILE *fp;
  if (!strcmp("-", filename)) {
    return stdin;
  }
  fp = fopen(filename, "r");
  if (fp == NULL && !nomsg && !quiet) {
    fprintf(stderr, "Can't open input file %s!\n", filename);
  }
  return fp;
}


x86 assembly (clang, -O0):
<open_fasta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb3(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    116e <open_fasta+0x3e>
mov    0x2e86(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11c2 <open_fasta+0x92>
mov    -0x10(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ba <open_fasta+0x8a>
cmpl   $0x0,-0x14(%rbp)
jne    11ba <open_fasta+0x8a>
cmpl   $0x0,-0x18(%rbp)
jne    11ba <open_fasta+0x8a>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe4f(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_fasta>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xebd(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1184 <open_fasta+0x54>
lea    0xeac(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
or     %r14d,%ebp
jne    118e <open_fasta+0x5e>
test   %rax,%rax
jne    118e <open_fasta+0x5e>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
xor    %eax,%eax
jmp    118e <open_fasta+0x5e>
mov    0x2e5d(%rip),%rax
mov    (%rax),%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [27 x i8] c"Can't open input file %s!\0A\00"
define i32* @open_fasta(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = load i8*, i8** %5
%10 = call i32 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %3
%13 = load i32*, i32** @stdin
store i32* %13, i32** %4
br label %31
14: ; preds = %3
%15 = load i8*, i8** %5
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %8
%17 = load i32*, i32** %8
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %29
19: ; preds = %14
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
br i1 %21, label %29, label %22
22: ; preds = %19
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %5
%28 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %25, %22, %19, %14
%30 = load i32*, i32** %8
store i32* %30, i32** %4
br label %31
31: ; preds = %29, %12
%32 = load i32*, i32** %4
ret i32* %32
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [27 x i8] c"Can't open input file %s!\0A\00"
define i32* @open_fasta(i8* %0, i32 %1, i32 %2) {
%4 = tail call i32 @strcmp(i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = load i32*, i32** @stdin
br label %17
8: ; preds = %3
%9 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp ne i32* %9, null
%11 = or i32 %2, %1
%12 = icmp ne i32 %11, 0
%13 = or i1 %12, %10
br i1 %13, label %17, label %14
14: ; preds = %8
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %17
17: ; preds = %8, %14, %6
%18 = phi i32* [ %7, %6 ], [ null, %14 ], [ %9, %8 ]
ret i32* %18
}