#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;
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(char const *, char *);
FILE *aacenc_fopen(const char *name, const char *mode) {
  FILE *fp;
  if (strcmp(name, "-") == 0)
    fp = (mode[0] == 'r') ? stdin : stdout;
  else
    fp = fopen(name, mode);
  return fp;
}


x86 assembly (clang, -O0):
<aacenc_fopen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1188 <aacenc_fopen+0x68>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x72,%eax
jne    116d <aacenc_fopen+0x4d>
mov    0x2e87(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    117b <aacenc_fopen+0x5b>
mov    0x2e64(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1199 <aacenc_fopen+0x79>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aacenc_fopen>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xecf(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     114d <aacenc_fopen+0x2d>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fopen@plt>
cmpb   $0x72,(%r14)
jne    115c <aacenc_fopen+0x3c>
mov    0x2e8e(%rip),%rax
jmp    1163 <aacenc_fopen+0x43>
mov    0x2e75(%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
@stdout = global i32* null
define i32* @aacenc_fopen(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %21
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 114
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = load i32*, i32** @stdin
br label %19
17: ; preds = %9
%18 = load i32*, i32** @stdout
br label %19
19: ; preds = %17, %15
%20 = phi i32* [ %16, %15 ], [ %18, %17 ]
store i32* %20, i32** %5
br label %25
21: ; preds = %2
%22 = load i8*, i8** %3
%23 = load i8*, i8** %4
%24 = call i32* @fopen(i8* %22, i8* %23)
store i32* %24, i32** %5
br label %25
25: ; preds = %21, %19
%26 = load i32*, i32** %5
ret i32* %26
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@stdin = global i32* null
@stdout = global i32* null
define i32* @aacenc_fopen(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 %11
5: ; preds = %2
%6 = load i8, i8* %1
%7 = icmp eq i8 %6, 114
%8 = load i32*, i32** @stdin
%9 = load i32*, i32** @stdout
%10 = select i1 %7, i32* %8, i32* %9
br label %13
11: ; preds = %2
%12 = tail call i32* @fopen(i8* %0, i8* %1)
br label %13
13: ; preds = %11, %5
%14 = phi i32* [ %10, %5 ], [ %12, %11 ]
ret i32* %14
}