#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 */
scalar_t__ equal_cstrings(char *, char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ *stdin;
FILE *filePointer(int argc, char *argv[]) {
  if (argc == 1 || (argc == 2 && equal_cstrings(argv[1], "-")))
    return stdin;
  else if (argc == 2)
    return fopen(argv[1], "r");
  else
    return NULL;
}


x86 assembly (clang, -O0):
<filePointer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
cmpl   $0x1,-0xc(%rbp)
je     1161 <filePointer+0x41>
cmpl   $0x2,-0xc(%rbp)
jne    1174 <filePointer+0x54>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeae(%rip),%rsi
call   1040 <equal_cstrings@plt>
cmp    $0x0,%rax
je     1174 <filePointer+0x54>
mov    0x2e80(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11a3 <filePointer+0x83>
cmpl   $0x2,-0xc(%rbp)
jne    119b <filePointer+0x7b>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe75(%rip),%rsi
call   1030 <fopen@plt>
mov    %rax,-0x8(%rbp)
jmp    11a3 <filePointer+0x83>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filePointer>:
push   %rbx
cmp    $0x1,%edi
je     1143 <filePointer+0x23>
cmp    $0x2,%edi
jne    114f <filePointer+0x2f>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xec7(%rip),%rsi
call   1040 <equal_cstrings@plt>
test   %rax,%rax
je     1153 <filePointer+0x33>
mov    0x2e9e(%rip),%rax
mov    (%rax),%rax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    0x8(%rbx),%rdi
lea    0xea4(%rip),%rsi
pop    %rbx
jmp    1030 <fopen@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.1 = [2 x i8] c"r\00"
define i32* @filePointer(i32 %0, i8** nocapture %1) {
switch i32 %0, label %13 [
i32 1, label %8
i32 2, label %3
]
3: ; preds = %2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i64 @equal_cstrings(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 %10, label %8
8: ; preds = %2, %3
%9 = load i32*, i32** @stdin
br label %13
10: ; preds = %3
%11 = load i8*, i8** %4
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %2, %10, %8
%14 = phi i32* [ %9, %8 ], [ %12, %10 ], [ null, %2 ]
ret i32* %14
}