#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*/ STDOUT_FILENO;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ get_file_tail(char *);
scalar_t__ get_stdin_tail();
int /*<<< orphan*/ print_filename(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
int main(int argc, char *argv[]) {
  if (argc == 1) {
    if (get_stdin_tail() < 0) {
      exit(0);
    }
  } else {
    int has_multiple_args = (argc > 2) ? 1 : 0;
    if (!has_multiple_args) {
      if (strcmp(argv[1], "-") == 0) {
        if (get_stdin_tail() < 0) {
          exit(0);
        }
      } else {
        if (get_file_tail(argv[1])) {
          exit(0);
        }
      }
    } else {
      for (int i = 1; i < argc; i++) {
        if (strcmp(argv[i], "-") == 0) {
          print_filename("standard input");
          if (get_stdin_tail() < 0) {
            exit(0);
          }
        } else {
          print_filename(argv[i]);
          if (get_file_tail(argv[i]) < 0) {
            exit(0);
          }
        }
        write(STDOUT_FILENO, "\n", 1);
      }
    }
  }
  return 0;
}


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    119d <main+0x3d>
mov    $0x0,%al
call   1040 <get_stdin_tail@plt>
cmp    $0x0,%rax
jge    1198 <main+0x38>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    12e5 <main+0x185>
mov    -0x8(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x2,%edx
cmovg  %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    121d <main+0xbd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe37(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11f5 <main+0x95>
mov    $0x0,%al
call   1040 <get_stdin_tail@plt>
cmp    $0x0,%rax
jge    11f0 <main+0x90>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    1218 <main+0xb8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <get_file_tail@plt>
cmp    $0x0,%rax
je     1213 <main+0xb3>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    1218 <main+0xb8>
jmp    12e0 <main+0x180>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12db <main+0x17b>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdbd(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    127b <main+0x11b>
lea    0xda9(%rip),%rdi
call   1080 <print_filename@plt>
mov    $0x0,%al
call   1040 <get_stdin_tail@plt>
cmp    $0x0,%rax
jge    1276 <main+0x116>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    12b3 <main+0x153>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <print_filename@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1060 <get_file_tail@plt>
cmp    $0x0,%rax
jge    12ae <main+0x14e>
xor    %edi,%edi
call   1070 <exit@plt>
jmp    12b3 <main+0x153>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
lea    0xd4e(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1224 <main+0xc4>
jmp    12e0 <main+0x180>
jmp    12e5 <main+0x185>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    1185 <main+0x25>
xor    %eax,%eax
call   1040 <get_stdin_tail@plt>
test   %rax,%rax
jns    123a <main+0xda>
jmp    124b <main+0xeb>
mov    %rsi,%rbx
cmp    $0x3,%edi
jl     1213 <main+0xb3>
mov    %edi,%r13d
mov    $0x1,%ebp
lea    0xe60(%rip),%r14
mov    0x2e49(%rip),%r15
lea    0xe63(%rip),%r12
xchg   %ax,%ax
mov    (%rbx,%rbp,8),%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11e0 <main+0x80>
mov    (%rbx,%rbp,8),%rdi
call   1080 <print_filename@plt>
mov    (%rbx,%rbp,8),%rdi
call   1060 <get_file_tail@plt>
test   %rax,%rax
jns    11f8 <main+0x98>
jmp    124b <main+0xeb>
nopw   0x0(%rax,%rax,1)
lea    0xe1b(%rip),%rdi
call   1080 <print_filename@plt>
xor    %eax,%eax
call   1040 <get_stdin_tail@plt>
test   %rax,%rax
js     124b <main+0xeb>
mov    (%r15),%edi
mov    %r12,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    11b0 <main+0x50>
jmp    123a <main+0xda>
mov    0x8(%rbx),%rdi
lea    0xde2(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1170 <main+0x10>
mov    0x8(%rbx),%rdi
call   1060 <get_file_tail@plt>
test   %rax,%rax
jne    124b <main+0xeb>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [15 x i8] c"standard input\00"
@STDOUT_FILENO = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = call i64 (...) @get_stdin_tail()
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @exit(i32 0)
unreachable
15: ; preds = %10
br label %90
16: ; preds = %2
%17 = load i32, i32* %4
%18 = icmp sgt i32 %17, 2
%19 = zext i1 %18 to i64
%20 = select i1 %18, i32 1, i32 0
store i32 %20, i32* %6
%21 = load i32, i32* %6
%22 = icmp ne i32 %21, 0
br i1 %22, label %45, label %23
23: ; preds = %16
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %23
%30 = call i64 (...) @get_stdin_tail()
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 @exit(i32 0)
unreachable
34: ; preds = %29
br label %44
35: ; preds = %23
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i64 @get_file_tail(i8* %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = call i32 @exit(i32 0)
unreachable
43: ; preds = %35
br label %44
44: ; preds = %43, %34
br label %89
45: ; preds = %16
store i32 1, i32* %7
br label %46
46: ; preds = %85, %45
%47 = load i32, i32* %7
%48 = load i32, i32* %4
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %88
50: ; preds = %46
%51 = load i8**, i8*** %5
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %51, i64 %53
%55 = load i8*, i8** %54
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %65
58: ; preds = %50
%59 = call i32 @print_filename(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%60 = call i64 (...) @get_stdin_tail()
%61 = icmp slt i64 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %58
%63 = call i32 @exit(i32 0)
unreachable
64: ; preds = %58
br label %82
65: ; preds = %50
%66 = load i8**, i8*** %5
%67 = load i32, i32* %7
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %66, i64 %68
%70 = load i8*, i8** %69
%71 = call i32 @print_filename(i8* %70)
%72 = load i8**, i8*** %5
%73 = load i32, i32* %7
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8*, i8** %72, i64 %74
%76 = load i8*, i8** %75
%77 = call i64 @get_file_tail(i8* %76)
%78 = icmp slt i64 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %65
%80 = call i32 @exit(i32 0)
unreachable
81: ; preds = %65
br label %82
82: ; preds = %81, %64
%83 = load i32, i32* @STDOUT_FILENO
%84 = call i32 @write(i32 %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
br label %85
85: ; preds = %82
%86 = load i32, i32* %7
%87 = add nsw i32 %86, 1
store i32 %87, i32* %7
br label %46
88: ; preds = %46
br label %89
89: ; preds = %88, %44
br label %90
90: ; preds = %89, %15
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@.str.1 = [15 x i8] c"standard input\00"
@STDOUT_FILENO = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = tail call i64 (...) @get_stdin_tail()
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %54
7: ; preds = %4
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %2
%10 = icmp sgt i32 %0, 2
br i1 %10, label %11, label %13
11: ; preds = %9
%12 = zext i32 %0 to i64
br label %29
13: ; preds = %9
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %13
%19 = tail call i64 (...) @get_stdin_tail()
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %54
21: ; preds = %18
%22 = tail call i32 @exit(i32 0)
unreachable
23: ; preds = %13
%24 = load i8*, i8** %14
%25 = tail call i64 @get_file_tail(i8* %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %54, label %27
27: ; preds = %23
%28 = tail call i32 @exit(i32 0)
unreachable
29: ; preds = %11, %49
%30 = phi i64 [ 1, %11 ], [ %52, %49 ]
%31 = getelementptr inbounds i8*, i8** %1, i64 %30
%32 = load i8*, i8** %31
%33 = tail call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %29
%36 = tail call i32 @print_filename(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%37 = tail call i64 (...) @get_stdin_tail()
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %49
39: ; preds = %35
%40 = tail call i32 @exit(i32 0)
unreachable
41: ; preds = %29
%42 = load i8*, i8** %31
%43 = tail call i32 @print_filename(i8* %42)
%44 = load i8*, i8** %31
%45 = tail call i64 @get_file_tail(i8* %44)
%46 = icmp slt i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %41
%48 = tail call i32 @exit(i32 0)
unreachable
49: ; preds = %41, %35
%50 = load i32, i32* @STDOUT_FILENO
%51 = tail call i32 @write(i32 %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 1)
%52 = add nuw nsw i64 %30, 1
%53 = icmp eq i64 %52, %12
br i1 %53, label %54, label %29
54: ; preds = %49, %23, %18, %4
ret i32 0
}