#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 backup(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ *stdout;
scalar_t__ strcmp(char *, char *);
FILE *select_outfile(char *outfile) {
  FILE *fp;
  if (strcmp(outfile, "-") == 0)
    return stdout;
  else {
    if (backup(outfile) == 1)
      return NULL;
    fp = fopen(outfile, "w");
  }
  return fp;
}


x86 assembly (clang, -O0):
<select_outfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1169 <select_outfile+0x39>
mov    0x2e83(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11a4 <select_outfile+0x74>
mov    -0x10(%rbp),%rdi
call   1040 <backup@plt>
cmp    $0x1,%eax
jne    1188 <select_outfile+0x58>
movq   $0x0,-0x8(%rbp)
jmp    11a4 <select_outfile+0x74>
mov    -0x10(%rbp),%rdi
lea    0xe6f(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<select_outfile>:
push   %rbx
mov    %rdi,%rbx
lea    0xec5(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1156 <select_outfile+0x26>
mov    %rbx,%rdi
call   1040 <backup@plt>
cmp    $0x1,%eax
jne    1162 <select_outfile+0x32>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e83(%rip),%rax
mov    (%rax),%rax
pop    %rbx
ret
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <fopen@plt>

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

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