#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 const *, char const *);
int /*<<< orphan*/ *stdin;
scalar_t__ strcmp(char const *, char *);
FILE *open_filename(const char *filename, const char *opt) {
  FILE *input;
  if (strcmp(filename, "-") == 0) {
    input = stdin;
  } else {
    input = fopen(filename, opt);
    if (!input) {
      do {
      } while (0);
      return NULL;
    }
  }
  return input;
}


x86 assembly (clang, -O0):
<open_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    115d <open_filename+0x3d>
mov    0x2e97(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    1195 <open_filename+0x75>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1190 <open_filename+0x70>
jmp    117e <open_filename+0x5e>
jmp    1183 <open_filename+0x63>
movq   $0x0,-0x8(%rbp)
jmp    119d <open_filename+0x7d>
jmp    1195 <open_filename+0x75>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<open_filename>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xecf(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     114f <open_filename+0x2f>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <fopen@plt>
test   %rax,%rax
jne    1159 <open_filename+0x39>
xor    %eax,%eax
jmp    1159 <open_filename+0x39>
mov    0x2e92(%rip),%rax
mov    (%rax),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@stdin = global i32* null
define i32* @open_filename(i8* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = load i32*, i32** @stdin
store i32* %11, i32** %6
br label %22
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = load i8*, i8** %5
%15 = call i32* @fopen(i8* %13, i8* %14)
store i32* %15, i32** %6
%16 = load i32*, i32** %6
%17 = icmp ne i32* %16, null
br i1 %17, label %21, label %18
18: ; preds = %12
br label %19
19: ; preds = %18
br label %20
20: ; preds = %19
store i32* null, i32** %3
br label %24
21: ; preds = %12
br label %22
22: ; preds = %21, %10
%23 = load i32*, i32** %6
store i32* %23, i32** %3
br label %24
24: ; preds = %22, %20
%25 = load i32*, i32** %3
ret i32* %25
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@stdin = global i32* null
define i32* @open_filename(i8* %0, i8* nocapture %1) {
%3 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = load i32*, i32** @stdin
br label %10
7: ; preds = %2
%8 = tail call i32* @fopen(i8* %0, i8* %1)
%9 = icmp eq i32* %8, null
br i1 %9, label %12, label %10
10: ; preds = %7, %5
%11 = phi i32* [ %6, %5 ], [ %8, %7 ]
br label %12
12: ; preds = %7, %10
%13 = phi i32* [ %11, %10 ], [ null, %7 ]
ret i32* %13
}