#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 ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ errno;
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
scalar_t__ strcmp(char *, char const *);
char *strerror(scalar_t__);
int main(const int argc, const char **argv) {
  char *line = NULL;
  size_t lineLength = 0;
  ssize_t read;
  int i = 1;
  int returnValue = 0;
  FILE *file = NULL;
  if (1 == argc) {
    file = stdin;
  }
  do {
    if (i < argc) {
      if (0 == strcmp("-", argv[i])) {
        file = stdin;
      } else {
        file = fopen(argv[i], "r");
        if (NULL == file) {
          fprintf(stderr, "Error cannot open file %s for reading: %s\n",
                  argv[i], strerror(errno));
          returnValue = 1;
          i++;
          continue;
        }
      }
    }
    errno = 0;
    while (-1 != (read = getline(&line, &lineLength, file))) {
      printf("%s", line);
    }
    if (0 != errno) {
      fprintf(stderr, "Error during file %s reading: %s\n", argv[i],
              strerror(errno));
      returnValue = 1;
    }
    if (file != stdin) {
      if (0 != fclose(file)) {
        fprintf(stderr, "Error closing file %s: %s\n", argv[i],
                strerror(errno));
        returnValue = 1;
      }
    }
    i++;
  } while (i < argc);
  free(line);
  return returnValue;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x1,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movq   $0x0,-0x38(%rbp)
mov    $0x1,%eax
cmp    -0x8(%rbp),%eax
jne    11d8 <main+0x58>
mov    0x2e17(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    11dd <main+0x5d>
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12aa <main+0x12a>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe04(%rip),%rdi
call   1060 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1222 <main+0xa2>
mov    0x2dd2(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    12a5 <main+0x125>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdcd(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x38(%rbp)
xor    %eax,%eax
cmp    -0x38(%rbp),%rax
jne    12a0 <main+0x120>
mov    0x2d87(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
mov    0x2d63(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rdx
mov    %rax,%rcx
lea    0xd7e(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    13cb <main+0x24b>
jmp    12a5 <main+0x125>
jmp    12aa <main+0x12a>
mov    0x2d1f(%rip),%rax
movq   $0x0,(%rax)
mov    -0x38(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1090 <getline@plt>
mov    %eax,%ecx
mov    %ecx,-0x24(%rbp)
mov    $0xffffffff,%eax
cmp    %ecx,%eax
je     12f0 <main+0x170>
mov    -0x18(%rbp),%rsi
lea    0xd49(%rip),%rdi
call   1050 <printf@plt>
jmp    12b8 <main+0x138>
xor    %eax,%eax
mov    0x2cd7(%rip),%rcx
cmp    (%rcx),%rax
je     134a <main+0x1ca>
mov    0x2ccf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x50(%rbp)
mov    0x2cab(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    -0x54(%rbp),%edi
mov    -0x50(%rbp),%rdx
mov    %rax,%rcx
lea    0xcf4(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x2c(%rbp)
mov    -0x38(%rbp),%rax
mov    0x2c93(%rip),%rcx
cmp    (%rcx),%rax
je     13c2 <main+0x242>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     13bd <main+0x23d>
mov    0x2c5c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x60(%rbp)
mov    0x2c38(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%rdx
mov    %rax,%rcx
lea    0xca3(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x2c(%rbp)
jmp    13c2 <main+0x242>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     11dd <main+0x5d>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,0x8(%rsp)
movq   $0x0,0x18(%rsp)
movq   $0x0,0x30(%rsp)
xor    %r14d,%r14d
mov    0x2e39(%rip),%rax
cmp    $0x1,%edi
jne    11b9 <main+0x39>
mov    (%rax),%r15
jmp    11bc <main+0x3c>
xor    %r15d,%r15d
cmp    $0x3,%edi
mov    $0x2,%eax
cmovge %edi,%eax
mov    %rax,0x28(%rsp)
movslq %edi,%rax
mov    %rax,0x20(%rsp)
mov    $0x1,%r13d
lea    0x18(%rsp),%rbx
lea    0x30(%rsp),%rbp
lea    0xe44(%rip),%r12
jmp    123f <main+0xbf>
mov    0x2de4(%rip),%rax
mov    (%rax),%r14d
mov    0x8(%rsp),%rax
mov    (%rax,%r13,8),%r15
mov    0x2dc9(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    %r14d,%edi
lea    0xdeb(%rip),%rsi
mov    %r15,%rdx
mov    %rax,%rcx
call   1070 <fprintf@plt>
mov    $0x1,%r14d
xor    %r15d,%r15d
nopl   (%rax)
add    $0x1,%r13
cmp    0x28(%rsp),%r13
je     1383 <main+0x203>
cmp    0x20(%rsp),%r13
jge    1287 <main+0x107>
mov    0x8(%rsp),%r15
mov    (%r15,%r13,8),%rsi
lea    0xdaa(%rip),%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     127d <main+0xfd>
mov    (%r15,%r13,8),%rdi
lea    0xd97(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1287 <main+0x107>
jmp    11ed <main+0x6d>
mov    0x2d64(%rip),%rax
mov    (%rax),%r15
mov    0x2d42(%rip),%rax
movq   $0x0,(%rax)
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   1090 <getline@plt>
cmp    $0xffffffff,%eax
je     12d0 <main+0x150>
mov    0x18(%rsp),%rsi
mov    %r12,%rdi
call   1050 <printf@plt>
jmp    12a0 <main+0x120>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x2cf9(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     1319 <main+0x199>
mov    0x2cf2(%rip),%rax
mov    (%rax),%r14d
mov    0x8(%rsp),%rax
mov    (%rax,%r13,8),%rax
mov    %rax,0x10(%rsp)
call   10a0 <strerror@plt>
mov    %r14d,%edi
lea    0xd2c(%rip),%rsi
mov    0x10(%rsp),%rdx
mov    %rax,%rcx
call   1070 <fprintf@plt>
mov    $0x1,%r14d
mov    0x2cc8(%rip),%rax
cmp    (%rax),%r15
je     1230 <main+0xb0>
mov    %r15,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
je     1230 <main+0xb0>
mov    0x2c97(%rip),%rax
mov    (%rax),%r14d
mov    0x8(%rsp),%rax
mov    (%rax,%r13,8),%rax
mov    %rax,0x10(%rsp)
mov    0x2c77(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    %r14d,%edi
lea    0xce9(%rip),%rsi
mov    0x10(%rsp),%rdx
mov    %rax,%rcx
call   1070 <fprintf@plt>
mov    $0x1,%r14d
jmp    1230 <main+0xb0>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    %r14d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32* null
@.str = [2 x i8] c"-\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [43 x i8] c"Error cannot open file %s for reading: %s\0A\00"
@errno = global i64 0
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [34 x i8] c"Error during file %s reading: %s\0A\00"
@.str.5 = [27 x i8] c"Error closing file %s: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i64 0, i64* %7
store i32 1, i32* %9
store i32 0, i32* %10
store i32* null, i32** %11
%12 = load i32, i32* %4
%13 = icmp eq i32 1, %12
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = load i32*, i32** @stdin
store i32* %15, i32** %11
br label %16
16: ; preds = %14, %2
br label %17
17: ; preds = %97, %16
%18 = load i32, i32* %9
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %54
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = load i32, i32* %9
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = icmp eq i64 0, %27
br i1 %28, label %29, label %31
29: ; preds = %21
%30 = load i32*, i32** @stdin
store i32* %30, i32** %11
br label %53
31: ; preds = %21
%32 = load i8**, i8*** %5
%33 = load i32, i32* %9
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8*, i8** %32, i64 %34
%36 = load i8*, i8** %35
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %37, i32** %11
%38 = load i32*, i32** %11
%39 = icmp eq i32* null, %38
br i1 %39, label %40, label %52
40: ; preds = %31
%41 = load i32, i32* @stderr
%42 = load i8**, i8*** %5
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = load i8*, i8** %45
%47 = load i64, i64* @errno
%48 = call i8* @strerror(i64 %47)
%49 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %46, i8* %48)
store i32 1, i32* %10
%50 = load i32, i32* %9
%51 = add nsw i32 %50, 1
store i32 %51, i32* %9
br label %97
52: ; preds = %31
br label %53
53: ; preds = %52, %29
br label %54
54: ; preds = %53, %17
store i64 0, i64* @errno
br label %55
55: ; preds = %59, %54
%56 = load i32*, i32** %11
%57 = call i32 @getline(i8** %6, i64* %7, i32* %56)
store i32 %57, i32* %8
%58 = icmp ne i32 -1, %57
br i1 %58, label %59, label %62
59: ; preds = %55
%60 = load i8*, i8** %6
%61 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %60)
br label %55
62: ; preds = %55
%63 = load i64, i64* @errno
%64 = icmp ne i64 0, %63
br i1 %64, label %65, label %75
65: ; preds = %62
%66 = load i32, i32* @stderr
%67 = load i8**, i8*** %5
%68 = load i32, i32* %9
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8*, i8** %67, i64 %69
%71 = load i8*, i8** %70
%72 = load i64, i64* @errno
%73 = call i8* @strerror(i64 %72)
%74 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %71, i8* %73)
store i32 1, i32* %10
br label %75
75: ; preds = %65, %62
%76 = load i32*, i32** %11
%77 = load i32*, i32** @stdin
%78 = icmp ne i32* %76, %77
br i1 %78, label %79, label %94
79: ; preds = %75
%80 = load i32*, i32** %11
%81 = call i64 @fclose(i32* %80)
%82 = icmp ne i64 0, %81
br i1 %82, label %83, label %93
83: ; preds = %79
%84 = load i32, i32* @stderr
%85 = load i8**, i8*** %5
%86 = load i32, i32* %9
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8*, i8** %85, i64 %87
%89 = load i8*, i8** %88
%90 = load i64, i64* @errno
%91 = call i8* @strerror(i64 %90)
%92 = call i32 @fprintf(i32 %84, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %89, i8* %91)
store i32 1, i32* %10
br label %93
93: ; preds = %83, %79
br label %94
94: ; preds = %93, %75
%95 = load i32, i32* %9
%96 = add nsw i32 %95, 1
store i32 %96, i32* %9
br label %97
97: ; preds = %94, %40
%98 = load i32, i32* %9
%99 = load i32, i32* %4
%100 = icmp slt i32 %98, %99
br i1 %100, label %17, label %101
101: ; preds = %97
%102 = load i8*, i8** %6
%103 = call i32 @free(i8* %102)
%104 = load i32, i32* %10
ret i32 %104
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [2 x i8] c"-\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [43 x i8] c"Error cannot open file %s for reading: %s\0A\00"
@errno = global i64 0
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [34 x i8] c"Error during file %s reading: %s\0A\00"
@.str.5 = [27 x i8] c"Error closing file %s: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%7 = icmp eq i32 %0, 1
%8 = load i32*, i32** @stdin
%9 = select i1 %7, i32* %8, i32* null
%10 = sext i32 %0 to i64
%11 = call i32 @llvm.smax.i32(i32 %0, i32 2)
%12 = zext i32 %11 to i64
br label %13
13: ; preds = %67, %2
%14 = phi i64 [ %70, %67 ], [ 1, %2 ]
%15 = phi i32 [ %68, %67 ], [ 0, %2 ]
%16 = phi i32* [ %69, %67 ], [ %9, %2 ]
%17 = icmp slt i64 %14, %10
br i1 %17, label %18, label %35
18: ; preds = %13
%19 = getelementptr inbounds i8*, i8** %1, i64 %14
%20 = load i8*, i8** %19
%21 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = load i32*, i32** @stdin
br label %35
25: ; preds = %18
%26 = load i8*, i8** %19
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = load i32, i32* @stderr
%31 = load i8*, i8** %19
%32 = load i64, i64* @errno
%33 = call i8* @strerror(i64 %32)
%34 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %33)
br label %67
35: ; preds = %23, %25, %13
%36 = phi i32* [ %24, %23 ], [ %27, %25 ], [ %16, %13 ]
store i64 0, i64* @errno
%37 = call i32 @getline(i8** %3, i64* %4, i32* %36)
%38 = icmp eq i32 %37, -1
br i1 %38, label %44, label %39
39: ; preds = %35, %39
%40 = load i8*, i8** %3
%41 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %40)
%42 = call i32 @getline(i8** %3, i64* %4, i32* %36)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %39
44: ; preds = %39, %35
%45 = load i64, i64* @errno
%46 = icmp eq i64 %45, 0
br i1 %46, label %53, label %47
47: ; preds = %44
%48 = load i32, i32* @stderr
%49 = getelementptr inbounds i8*, i8** %1, i64 %14
%50 = load i8*, i8** %49
%51 = call i8* @strerror(i64 %45)
%52 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %50, i8* %51)
br label %53
53: ; preds = %47, %44
%54 = phi i32 [ 1, %47 ], [ %15, %44 ]
%55 = load i32*, i32** @stdin
%56 = icmp eq i32* %36, %55
br i1 %56, label %67, label %57
57: ; preds = %53
%58 = call i64 @fclose(i32* %36)
%59 = icmp eq i64 %58, 0
br i1 %59, label %67, label %60
60: ; preds = %57
%61 = load i32, i32* @stderr
%62 = getelementptr inbounds i8*, i8** %1, i64 %14
%63 = load i8*, i8** %62
%64 = load i64, i64* @errno
%65 = call i8* @strerror(i64 %64)
%66 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %63, i8* %65)
br label %67
67: ; preds = %53, %60, %57, %29
%68 = phi i32 [ 1, %29 ], [ 1, %60 ], [ %54, %57 ], [ %54, %53 ]
%69 = phi i32* [ null, %29 ], [ %36, %60 ], [ %36, %57 ], [ %36, %53 ]
%70 = add nuw nsw i64 %14, 1
%71 = icmp eq i64 %70, %12
br i1 %71, label %72, label %13
72: ; preds = %67
%73 = load i8*, i8** %3
%74 = call i32 @free(i8* %73)
ret i32 %68
}