#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 */
char EOF;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  int i;
  char c;
  FILE *fptr;
  for (i = 1; i < argc; ++i) {
    if (strcmp(argv[i], "--help") == 0) {
      printf("Usage: cat-lite [--help] [FILE]...\n"
             "With no FILE, or when FILE is -, read standard input.\n\n"
             "Examples:\n"
             "cat-lite README   Print the file README to standard output.\n"
             "cat-lite f - g    Print f's contents, then standard input, \n"
             "                  then g's contents.\n"
             "cat-lite          Copy standard input to standard output.\n");
      return EXIT_SUCCESS;
    }
  }
  for (i = 1; i < argc; ++i) {
    if (strcmp(argv[i], "-") == 0) {
      while ((c = fgetc(stdin)) != EOF) {
        fputc(c, stdout);
      }
    } else {
      fptr = fopen(argv[i], "r");
      if (!fptr) {
        fprintf(stderr, "cat cannot open %s\n", argv[i]);
        return EXIT_FAILURE;
      }
      while ((c = fgetc(fptr)) != EOF) {
        fputc(c, stdout);
      }
      fclose(fptr);
    }
  }
  if (argc == 1) {
    while ((c = fgetc(stdin)) != EOF) {
      fputc(c, stdout);
    }
  }
  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)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11eb <main+0x7b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe54(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    11d8 <main+0x68>
lea    0xe45(%rip),%rdi
call   1040 <printf@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    137e <main+0x20e>
jmp    11dd <main+0x6d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118d <main+0x1d>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    131e <main+0x1ae>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xf32(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    126a <main+0xfa>
jmp    1225 <main+0xb5>
mov    0x2dbc(%rip),%rax
mov    (%rax),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x15(%rbp)
movsbl %al,%eax
mov    0x2d9f(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1265 <main+0xf5>
mov    -0x15(%rbp),%al
mov    0x2d6a(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1060 <fputc@plt>
jmp    1225 <main+0xb5>
jmp    130b <main+0x19b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xec8(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12c3 <main+0x153>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe9a(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2d0f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    137e <main+0x20e>
jmp    12c8 <main+0x158>
mov    -0x20(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x15(%rbp)
movsbl %al,%eax
mov    0x2d02(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1302 <main+0x192>
mov    -0x15(%rbp),%al
mov    0x2ccd(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1060 <fputc@plt>
jmp    12c8 <main+0x158>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1310 <main+0x1a0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f2 <main+0x82>
cmpl   $0x1,-0x8(%rbp)
jne    1372 <main+0x202>
jmp    132d <main+0x1bd>
mov    0x2cb4(%rip),%rax
mov    (%rax),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x15(%rbp)
movsbl %al,%eax
mov    0x2c97(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     136d <main+0x1fd>
mov    -0x15(%rbp),%al
mov    0x2c62(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1060 <fputc@plt>
jmp    132d <main+0x1bd>
jmp    1372 <main+0x202>
mov    0x2c3f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,0xc(%rsp)
cmp    $0x2,%edi
jl     128e <main+0x11e>
mov    %rsi,%r13
mov    0xc(%rsp),%eax
mov    %eax,%r14d
mov    %eax,%ebp
mov    $0x1,%ebx
lea    0xe5d(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13,%rbx,8),%rdi
mov    %r15,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12d9 <main+0x169>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11b0 <main+0x40>
mov    %rbp,0x10(%rsp)
cmp    $0x2,%r14d
jl     128e <main+0x11e>
mov    $0x1,%r15d
mov    0x2dfd(%rip),%rbx
mov    0x2dee(%rip),%r12
mov    0x2dc7(%rip),%r14
jmp    1213 <main+0xa3>
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1040 <fclose@plt>
add    $0x1,%r15
cmp    0x10(%rsp),%r15
je     128e <main+0x11e>
mov    0x0(%r13,%r15,8),%rdi
lea    0xde8(%rip),%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     127b <main+0x10b>
mov    0x0(%r13,%r15,8),%rdi
lea    0xdd4(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12fe <main+0x18e>
mov    %rax,%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1050 <fgetc@plt>
cmp    (%r12),%al
je     1200 <main+0x90>
mov    (%r14),%esi
movsbl %al,%edi
call   1060 <fputc@plt>
jmp    1250 <main+0xe0>
nopl   0x0(%rax,%rax,1)
mov    (%r14),%esi
movsbl %al,%edi
call   1060 <fputc@plt>
mov    (%rbx),%rdi
call   1050 <fgetc@plt>
cmp    (%r12),%al
jne    1270 <main+0x100>
jmp    1208 <main+0x98>
mov    0x2d23(%rip),%r14
cmpl   $0x1,0xc(%rsp)
jne    12ec <main+0x17c>
mov    0x2d45(%rip),%r15
mov    (%r15),%rdi
call   1050 <fgetc@plt>
mov    0x2d2e(%rip),%rbx
cmp    (%rbx),%al
je     12ec <main+0x17c>
mov    0x2d03(%rip),%rbp
nopl   (%rax)
mov    0x0(%rbp),%esi
movsbl %al,%edi
call   1060 <fputc@plt>
mov    (%r15),%rdi
call   1050 <fgetc@plt>
cmp    (%rbx),%al
jne    12c0 <main+0x150>
jmp    12ec <main+0x17c>
lea    0xd3f(%rip),%rdi
call   1030 <puts@plt>
mov    0x2ccc(%rip),%r14
mov    (%r14),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ccb(%rip),%rax
mov    (%rax),%edi
mov    0x0(%r13,%r15,8),%rdx
lea    0xcf8(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2ca9(%rip),%r14
jmp    12ec <main+0x17c>

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@.str.1 = [316 x i8] c"Usage: cat-lite [--help] [FILE]...\0AWith no FILE, or when FILE is -, read standard input.\0A\0AExamples:\0Acat-lite README Print the file README to standard output.\0Acat-lite f - g Print f's contents, then standard input, \0A then g's contents.\0Acat-lite Copy standard input to standard output.\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.2 = [2 x i8] c"-\00"
@stdin = global i32* null
@EOF = global i8 0
@stdout = global i32 0
@.str.3 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.4 = [20 x i8] c"cat cannot open %s\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %9
9: ; preds = %25, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %28
13: ; preds = %9
%14 = load i8**, i8*** %5
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %13
%22 = call i32 @printf(i8* getelementptr inbounds ([316 x i8], [316 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* @EXIT_SUCCESS
store i32 %23, i32* %3
br label %109
24: ; preds = %13
br label %25
25: ; preds = %24
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
br label %9
28: ; preds = %9
store i32 1, i32* %6
br label %29
29: ; preds = %88, %28
%30 = load i32, i32* %6
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %91
33: ; preds = %29
%34 = load i8**, i8*** %5
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %54
41: ; preds = %33
br label %42
42: ; preds = %49, %41
%43 = load i32*, i32** @stdin
%44 = call signext i8 @fgetc(i32* %43)
store i8 %44, i8* %7
%45 = sext i8 %44 to i32
%46 = load i8, i8* @EOF
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %45, %47
br i1 %48, label %49, label %53
49: ; preds = %42
%50 = load i8, i8* %7
%51 = load i32, i32* @stdout
%52 = call i32 @fputc(i8 signext %50, i32 %51)
br label %42
53: ; preds = %42
br label %87
54: ; preds = %33
%55 = load i8**, i8*** %5
%56 = load i32, i32* %6
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %55, i64 %57
%59 = load i8*, i8** %58
%60 = call i32* @fopen(i8* %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %60, i32** %8
%61 = load i32*, i32** %8
%62 = icmp ne i32* %61, null
br i1 %62, label %72, label %63
63: ; preds = %54
%64 = load i32, i32* @stderr
%65 = load i8**, i8*** %5
%66 = load i32, i32* %6
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i8*, i8** %65, i64 %67
%69 = load i8*, i8** %68
%70 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %69)
%71 = load i32, i32* @EXIT_FAILURE
store i32 %71, i32* %3
br label %109
72: ; preds = %54
br label %73
73: ; preds = %80, %72
%74 = load i32*, i32** %8
%75 = call signext i8 @fgetc(i32* %74)
store i8 %75, i8* %7
%76 = sext i8 %75 to i32
%77 = load i8, i8* @EOF
%78 = sext i8 %77 to i32
%79 = icmp ne i32 %76, %78
br i1 %79, label %80, label %84
80: ; preds = %73
%81 = load i8, i8* %7
%82 = load i32, i32* @stdout
%83 = call i32 @fputc(i8 signext %81, i32 %82)
br label %73
84: ; preds = %73
%85 = load i32*, i32** %8
%86 = call i32 @fclose(i32* %85)
br label %87
87: ; preds = %84, %53
br label %88
88: ; preds = %87
%89 = load i32, i32* %6
%90 = add nsw i32 %89, 1
store i32 %90, i32* %6
br label %29
91: ; preds = %29
%92 = load i32, i32* %4
%93 = icmp eq i32 %92, 1
br i1 %93, label %94, label %107
94: ; preds = %91
br label %95
95: ; preds = %102, %94
%96 = load i32*, i32** @stdin
%97 = call signext i8 @fgetc(i32* %96)
store i8 %97, i8* %7
%98 = sext i8 %97 to i32
%99 = load i8, i8* @EOF
%100 = sext i8 %99 to i32
%101 = icmp ne i32 %98, %100
br i1 %101, label %102, label %106
102: ; preds = %95
%103 = load i8, i8* %7
%104 = load i32, i32* @stdout
%105 = call i32 @fputc(i8 signext %103, i32 %104)
br label %95
106: ; preds = %95
br label %107
107: ; preds = %106, %91
%108 = load i32, i32* @EXIT_SUCCESS
store i32 %108, i32* %3
br label %109
109: ; preds = %107, %63, %21
%110 = load i32, i32* %3
ret i32 %110
}

LLVM IR (-O2):
@.str = [7 x i8] c"--help\00"
@EXIT_SUCCESS = global i32 0
@.str.2 = [2 x i8] c"-\00"
@stdin = global i32* null
@EOF = global i8 0
@stdout = global i32 0
@.str.3 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.4 = [20 x i8] c"cat cannot open %s\0A\00"
@EXIT_FAILURE = global i32 0
@str = [315 x i8] c"Usage: cat-lite [--help] [FILE]...\0AWith no FILE, or when FILE is -, read standard input.\0A\0AExamples:\0Acat-lite README Print the file README to standard output.\0Acat-lite f - g Print f's contents, then standard input, \0A then g's contents.\0Acat-lite Copy standard input to standard output.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %63
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %11
6: ; preds = %11
%7 = icmp eq i64 %17, %5
br i1 %7, label %8, label %11
8: ; preds = %6
br i1 %3, label %9, label %63
9: ; preds = %8
%10 = zext i32 %0 to i64
br label %20
11: ; preds = %4, %6
%12 = phi i64 [ 1, %4 ], [ %17, %6 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
%17 = add nuw nsw i64 %12, 1
br i1 %16, label %18, label %6
18: ; preds = %11
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([315 x i8], [315 x i8]* @str, i64 0, i64 0))
br label %78
20: ; preds = %9, %60
%21 = phi i64 [ 1, %9 ], [ %61, %60 ]
%22 = getelementptr inbounds i8*, i8** %1, i64 %21
%23 = load i8*, i8** %22
%24 = tail call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %39
26: ; preds = %20
%27 = load i32*, i32** @stdin
%28 = tail call signext i8 @fgetc(i32* %27)
%29 = load i8, i8* @EOF
%30 = icmp eq i8 %28, %29
br i1 %30, label %60, label %31
31: ; preds = %26, %31
%32 = phi i8 [ %36, %31 ], [ %28, %26 ]
%33 = load i32, i32* @stdout
%34 = tail call i32 @fputc(i8 signext %32, i32 %33)
%35 = load i32*, i32** @stdin
%36 = tail call signext i8 @fgetc(i32* %35)
%37 = load i8, i8* @EOF
%38 = icmp eq i8 %36, %37
br i1 %38, label %60, label %31
39: ; preds = %20
%40 = load i8*, i8** %22
%41 = tail call i32* @fopen(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%42 = icmp eq i32* %41, null
br i1 %42, label %47, label %43
43: ; preds = %39
%44 = tail call signext i8 @fgetc(i32* %41)
%45 = load i8, i8* @EOF
%46 = icmp eq i8 %44, %45
br i1 %46, label %58, label %51
47: ; preds = %39
%48 = load i32, i32* @stderr
%49 = load i8*, i8** %22
%50 = tail call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i8* %49)
br label %78
51: ; preds = %43, %51
%52 = phi i8 [ %55, %51 ], [ %44, %43 ]
%53 = load i32, i32* @stdout
%54 = tail call i32 @fputc(i8 signext %52, i32 %53)
%55 = tail call signext i8 @fgetc(i32* %41)
%56 = load i8, i8* @EOF
%57 = icmp eq i8 %55, %56
br i1 %57, label %58, label %51
58: ; preds = %51, %43
%59 = tail call i32 @fclose(i32* %41)
br label %60
60: ; preds = %31, %26, %58
%61 = add nuw nsw i64 %21, 1
%62 = icmp eq i64 %61, %10
br i1 %62, label %63, label %20
63: ; preds = %60, %2, %8
%64 = icmp eq i32 %0, 1
br i1 %64, label %65, label %78
65: ; preds = %63
%66 = load i32*, i32** @stdin
%67 = tail call signext i8 @fgetc(i32* %66)
%68 = load i8, i8* @EOF
%69 = icmp eq i8 %67, %68
br i1 %69, label %78, label %70
70: ; preds = %65, %70
%71 = phi i8 [ %75, %70 ], [ %67, %65 ]
%72 = load i32, i32* @stdout
%73 = tail call i32 @fputc(i8 signext %71, i32 %72)
%74 = load i32*, i32** @stdin
%75 = tail call signext i8 @fgetc(i32* %74)
%76 = load i8, i8* @EOF
%77 = icmp eq i8 %75, %76
br i1 %77, label %78, label %70
78: ; preds = %70, %65, %63, %47, %18
%79 = phi i32* [ @EXIT_SUCCESS, %18 ], [ @EXIT_FAILURE, %47 ], [ @EXIT_SUCCESS, %63 ], [ @EXIT_SUCCESS, %65 ], [ @EXIT_SUCCESS, %70 ]
%80 = load i32, i32* %79
ret i32 %80
}