#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*/ exit(int);
scalar_t__ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stdout;
int main(int ac, char **av) {
  int exit_status = EXIT_SUCCESS;
  FILE *input;
  char ch;
  while (*++av != NULL) {
    input = fopen(*av, "r");
    if (input == NULL) {
      perror(*av);
      exit_status = EXIT_FAILURE;
      continue;
    }
    while ((ch = fgetc(input)) != EOF) {
      fputc(ch, stdout);
    }
    if (fclose(input) != 0) {
      perror("fclose");
      exit(EXIT_FAILURE);
    }
  }
  return (exit_status);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
cmpq   $0x0,0x8(%rax)
je     124c <main+0xec>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe56(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11db <main+0x7b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <perror@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    1182 <main+0x22>
jmp    11e0 <main+0x80>
mov    -0x20(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
mov    0x2df2(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     121a <main+0xba>
mov    -0x21(%rbp),%al
mov    0x2dc5(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1050 <fputc@plt>
jmp    11e0 <main+0x80>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
cmp    $0x0,%rax
je     1247 <main+0xe7>
lea    0xdce(%rip),%rdi
call   1070 <perror@plt>
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
jmp    1182 <main+0x22>
mov    -0x14(%rbp),%eax
add    $0x30,%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,%r13
mov    0x2e53(%rip),%rax
lea    0xe84(%rip),%r14
mov    0x2e65(%rip),%rbx
mov    0x2e46(%rip),%r12
mov    (%rax),%r15d
jmp    119d <main+0x3d>
nop
mov    %rbp,%rdi
call   1030 <fclose@plt>
test   %rax,%rax
jne    11fe <main+0x9e>
mov    0x8(%r13),%rdi
test   %rdi,%rdi
je     11ec <main+0x8c>
add    $0x8,%r13
mov    %r14,%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11da <main+0x7a>
mov    %rax,%rbp
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1040 <fgetc@plt>
cmp    (%rbx),%al
je     1190 <main+0x30>
mov    (%r12),%esi
movsbl %al,%edi
call   1050 <fputc@plt>
jmp    11c0 <main+0x60>
mov    0x0(%r13),%rdi
call   1070 <perror@plt>
mov    0x2dee(%rip),%rax
jmp    118a <main+0x2a>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdfd(%rip),%rdi
call   1070 <perror@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

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

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