#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 */

/* Variables and functions */
int /*<<< orphan*/ fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int scan(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc > 1) {
    return scan(!strcmp(argv[1], "-") ? stdin : fopen(argv[1], "r"));
  } else {
    fprintf(stderr, "%s <expr>\n", argv[0]);
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11b5 <main+0x75>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe91(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    118e <main+0x4e>
mov    0x2e64(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    11a5 <main+0x65>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe65(%rip),%rsi
call   1060 <fopen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <scan@plt>
mov    %eax,-0x4(%rbp)
jmp    11d8 <main+0x98>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe38(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jl     1174 <main+0x34>
mov    0x8(%rsi),%rbx
lea    0xeaf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1193 <main+0x53>
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %eax,%edi
pop    %rbx
jmp    1050 <scan@plt>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe7d(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
ret
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
pop    %rbx
jmp    1050 <scan@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@stdin = global i32 0
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [11 x i8] c"%s <expr>\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %16
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = load i32, i32* @stdin
br label %13
11: ; preds = %4
%12 = tail call i32 @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
%14 = phi i32 [ %10, %9 ], [ %12, %11 ]
%15 = tail call i32 @scan(i32 %14)
br label %20
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %1
%19 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %16, %13
%21 = phi i32 [ %15, %13 ], [ 1, %16 ]
ret i32 %21
}