#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ cat(int /*<<< orphan*/ *, int *);
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char **argv) {
  int err = EXIT_SUCCESS;
  FILE *f;
  if (argc == 1) {
    cat(stdin, &err);
  }
  for (argv++; *argv; argv++) {
    if (!strcmp(*argv, "-")) {
      cat(stdin, &err);
    } else {
      if ((f = fopen(*argv, "rb")) == NULL) {
        perror("cat: fopen");
        err = EXIT_FAILURE;
        continue;
      }
      cat(f, &err);
      if (fclose(f)) {
        perror("cat: fclose");
        err = EXIT_FAILURE;
        continue;
      }
    }
  }
  return err;
}


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)
mov    0x2e63(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    118f <main+0x3f>
mov    0x2e65(%rip),%rax
mov    (%rax),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <cat@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1273 <main+0x123>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe49(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11dd <main+0x8d>
mov    0x2e1c(%rip),%rax
mov    (%rax),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <cat@plt>
jmp    125d <main+0x10d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe17(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    121b <main+0xcb>
lea    0xe00(%rip),%rdi
call   1060 <perror@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    1262 <main+0x112>
mov    -0x20(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <cat@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
cmp    $0x0,%rax
je     1258 <main+0x108>
lea    0xdce(%rip),%rdi
call   1060 <perror@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    1262 <main+0x112>
jmp    125d <main+0x10d>
jmp    1262 <main+0x112>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    119b <main+0x4b>
mov    -0x14(%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
push   %rax
mov    %rsi,%rbx
mov    0x2e6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
cmp    $0x1,%edi
jne    1184 <main+0x34>
mov    0x2e71(%rip),%rax
mov    (%rax),%rdi
lea    0x4(%rsp),%rsi
call   1070 <cat@plt>
mov    0x8(%rbx),%r13
test   %r13,%r13
je     122c <main+0xdc>
add    $0x10,%rbx
lea    0xe64(%rip),%r14
lea    0x4(%rsp),%r15
lea    0xe5a(%rip),%r12
jmp    11ce <main+0x7e>
nopw   0x0(%rax,%rax,1)
mov    0x2e31(%rip),%rax
mov    (%rax),%rdi
mov    %r15,%rsi
call   1070 <cat@plt>
mov    (%rbx),%r13
add    $0x8,%rbx
test   %r13,%r13
je     122c <main+0xdc>
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11b0 <main+0x60>
mov    %r13,%rdi
mov    %r12,%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1211 <main+0xc1>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r15,%rsi
call   1070 <cat@plt>
mov    %rbp,%rdi
call   1030 <fclose@plt>
test   %rax,%rax
je     11c2 <main+0x72>
lea    0xe01(%rip),%rdi
jmp    1218 <main+0xc8>
lea    0xded(%rip),%rdi
call   1060 <perror@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
jmp    11c2 <main+0x72>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@stdin = global i32* null
@.str = [2 x i8] c"-\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [11 x i8] c"cat: fopen\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [12 x i8] c"cat: fclose\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* @EXIT_SUCCESS
store i32 %8, i32* %6
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32*, i32** @stdin
%13 = call i32 @cat(i32* %12, i32* %6)
br label %14
14: ; preds = %11, %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i32 1
store i8** %16, i8*** %5
br label %17
17: ; preds = %48, %14
%18 = load i8**, i8*** %5
%19 = load i8*, i8** %18
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %51
21: ; preds = %17
%22 = load i8**, i8*** %5
%23 = load i8*, i8** %22
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %21
%27 = load i32*, i32** @stdin
%28 = call i32 @cat(i32* %27, i32* %6)
br label %47
29: ; preds = %21
%30 = load i8**, i8*** %5
%31 = load i8*, i8** %30
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %32, i32** %7
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %37
34: ; preds = %29
%35 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
store i32 %36, i32* %6
br label %48
37: ; preds = %29
%38 = load i32*, i32** %7
%39 = call i32 @cat(i32* %38, i32* %6)
%40 = load i32*, i32** %7
%41 = call i64 @fclose(i32* %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %37
%44 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%45 = load i32, i32* @EXIT_FAILURE
store i32 %45, i32* %6
br label %48
46: ; preds = %37
br label %47
47: ; preds = %46, %26
br label %48
48: ; preds = %47, %43, %34
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i32 1
store i8** %50, i8*** %5
br label %17
51: ; preds = %17
%52 = load i32, i32* %6
ret i32 %52
}

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