#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*/ *stdin;
int /*<<< orphan*/ strncmp(char *, char *, int);
FILE *filePointer(int argc, char *argv[]) {
  if (argc == 1 || (argc == 2 && !strncmp(argv[1], "-", 2)))
    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     1165 <filePointer+0x45>
cmpl   $0x2,-0xc(%rbp)
jne    1178 <filePointer+0x58>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeae(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1178 <filePointer+0x58>
mov    0x2e7c(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11a7 <filePointer+0x87>
cmpl   $0x2,-0xc(%rbp)
jne    119f <filePointer+0x7f>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe71(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x8(%rbp)
jmp    11a7 <filePointer+0x87>
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     1158 <filePointer+0x38>
cmp    $0x2,%edi
jne    1164 <filePointer+0x44>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xec7(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1158 <filePointer+0x38>
mov    0x8(%rbx),%rdi
lea    0xeb0(%rip),%rsi
pop    %rbx
jmp    1040 <fopen@plt>
mov    0x2e89(%rip),%rax
mov    (%rax),%rax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

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 i32 @strncmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 2)
%16 = icmp ne i32 %15, 0
br i1 %16, label %19, label %17
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 i32 @strncmp(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
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
}