#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*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
scalar_t__ run_line(int /*<<< orphan*/ *);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  FILE *fp;
  if (argc == 1) {
    fp = stdin;
  } else {
    if (!strcmp(argv[1], "-")) {
      fp = stdin;
    } else {
      fp = fopen(argv[1], "r");
      if (!fp) {
        perror(argv[1]);
        exit(EXIT_FAILURE);
      }
    }
  }
  while (run_line(fp))
    ;
  return EXIT_SUCCESS;
}


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)
jne    1183 <main+0x33>
mov    0x2e71(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    11fb <main+0xab>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11b3 <main+0x63>
mov    0x2e41(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    11f6 <main+0xa6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe40(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f1 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <perror@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    11f6 <main+0xa6>
jmp    11fb <main+0xab>
jmp    1200 <main+0xb0>
mov    -0x18(%rbp),%rdi
call   1040 <run_line@plt>
cmp    $0x0,%rax
je     1218 <main+0xc8>
jmp    1200 <main+0xb0>
mov    0x2db1(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
je     11a1 <main+0x51>
mov    %rsi,%r14
mov    0x8(%rsi),%rbx
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11a1 <main+0x51>
lea    0xe88(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11b0 <main+0x60>
mov    0x8(%r14),%rdi
call   1060 <perror@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    0x2e40(%rip),%rax
mov    (%rax),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <run_line@plt>
test   %rax,%rax
jne    11b0 <main+0x60>
mov    0x2e0c(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdin = global i32* null
@.str = [2 x i8] c"-\00"
@.str.1 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load i32*, i32** @stdin
store i32* %10, i32** %6
br label %35
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %11
%18 = load i32*, i32** @stdin
store i32* %18, i32** %6
br label %34
19: ; preds = %11
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %6
%24 = load i32*, i32** %6
%25 = icmp ne i32* %24, null
br i1 %25, label %33, label %26
26: ; preds = %19
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @perror(i8* %29)
%31 = load i32, i32* @EXIT_FAILURE
%32 = call i32 @exit(i32 %31)
unreachable
33: ; preds = %19
br label %34
34: ; preds = %33, %17
br label %35
35: ; preds = %34, %9
br label %36
36: ; preds = %40, %35
%37 = load i32*, i32** %6
%38 = call i64 @run_line(i32* %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %36
br label %36
41: ; preds = %36
%42 = load i32, i32* @EXIT_SUCCESS
ret i32 %42
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [2 x i8] c"-\00"
@.str.1 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = load i32*, i32** @stdin
br label %21
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = load i32*, i32** @stdin
br label %21
13: ; preds = %6
%14 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i8*, i8** %7
%18 = tail call i32 @perror(i8* %17)
%19 = load i32, i32* @EXIT_FAILURE
%20 = tail call i32 @exit(i32 %19)
unreachable
21: ; preds = %11, %13, %4
%22 = phi i32* [ %5, %4 ], [ %14, %13 ], [ %12, %11 ]
br label %23
23: ; preds = %23, %21
%24 = tail call i64 @run_line(i32* %22)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %23
26: ; preds = %23
%27 = load i32, i32* @EXIT_SUCCESS
ret i32 %27
}