#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ output_file(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int arg_count = argc;
  char **arguments = argv;
  if (arg_count == 1) {
    output_file(stdin, stdout);
    return 0;
  }
  FILE *read_file;
  while (--arg_count > 0) {
    read_file = fopen(*++arguments, "r");
    if (read_file == NULL) {
      perror(*arguments);
      return 1;
    }
    output_file(read_file, stdout);
    fclose(read_file);
  }
}


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    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1192 <main+0x52>
mov    0x2e73(%rip),%rax
mov    (%rax),%rdi
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
call   1030 <output_file@plt>
movl   $0x0,-0x4(%rbp)
jmp    120f <main+0xcf>
jmp    1197 <main+0x57>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    120f <main+0xcf>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
mov    0x8(%rax),%rdi
lea    0xe3d(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11ef <main+0xaf>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1060 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    120f <main+0xcf>
mov    -0x28(%rbp),%rdi
mov    0x2dde(%rip),%rax
mov    (%rax),%esi
call   1030 <output_file@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1197 <main+0x57>
mov    -0x4(%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
cmp    $0x1,%edi
jne    116d <main+0x2d>
mov    0x2e91(%rip),%rax
mov    (%rax),%rdi
mov    0x2e77(%rip),%rax
mov    (%rax),%esi
call   1030 <output_file@plt>
xor    %r14d,%r14d
jmp    11c4 <main+0x84>
mov    %edi,%ebp
xor    %r14d,%r14d
cmp    $0x2,%edi
jl     11c4 <main+0x84>
mov    %rsi,%r12
add    $0x1,%ebp
add    $0x8,%r12
lea    0xe78(%rip),%r15
mov    0x2e49(%rip),%r13
nop
mov    (%r12),%rdi
mov    %r15,%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11d6 <main+0x96>
mov    %rax,%rbx
mov    0x0(%r13),%esi
mov    %rax,%rdi
call   1030 <output_file@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0xffffffff,%ebp
add    $0x8,%r12
cmp    $0x2,%ebp
jg     1190 <main+0x50>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%r12),%rdi
call   1060 <perror@plt>
mov    $0x1,%r14d
jmp    11c4 <main+0x84>

LLVM IR (-O0):
@stdin = global i32* null
@stdout = global i32 0
@.str = [2 x i8] c"r\00"
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
%9 = load i32, i32* %4
store i32 %9, i32* %6
%10 = load i8**, i8*** %5
store i8** %10, i8*** %7
%11 = load i32, i32* %6
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32*, i32** @stdin
%15 = load i32, i32* @stdout
%16 = call i32 @output_file(i32* %14, i32 %15)
store i32 0, i32* %3
br label %39
17: ; preds = %2
br label %18
18: ; preds = %33, %17
%19 = load i32, i32* %6
%20 = add nsw i32 %19, -1
store i32 %20, i32* %6
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %39
22: ; preds = %18
%23 = load i8**, i8*** %7
%24 = getelementptr inbounds i8*, i8** %23, i32 1
store i8** %24, i8*** %7
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %26, i32** %8
%27 = load i32*, i32** %8
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %33
29: ; preds = %22
%30 = load i8**, i8*** %7
%31 = load i8*, i8** %30
%32 = call i32 @perror(i8* %31)
store i32 1, i32* %3
br label %39
33: ; preds = %22
%34 = load i32*, i32** %8
%35 = load i32, i32* @stdout
%36 = call i32 @output_file(i32* %34, i32 %35)
%37 = load i32*, i32** %8
%38 = call i32 @fclose(i32* %37)
br label %18
39: ; preds = %13, %29, %18
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@stdin = global i32* null
@stdout = global i32 0
@.str = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = icmp sgt i32 %0, 1
br i1 %5, label %10, label %26
6: ; preds = %2
%7 = load i32*, i32** @stdin
%8 = load i32, i32* @stdout
%9 = tail call i32 @output_file(i32* %7, i32 %8)
br label %26
10: ; preds = %4, %20
%11 = phi i32 [ %21, %20 ], [ %0, %4 ]
%12 = phi i8** [ %13, %20 ], [ %1, %4 ]
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = load i8*, i8** %13
%19 = tail call i32 @perror(i8* %18)
br label %26
20: ; preds = %10
%21 = add nsw i32 %11, -1
%22 = load i32, i32* @stdout
%23 = tail call i32 @output_file(i32* %15, i32 %22)
%24 = tail call i32 @fclose(i32* %15)
%25 = icmp sgt i32 %11, 2
br i1 %25, label %10, label %26
26: ; preds = %20, %4, %17, %6
%27 = phi i32 [ 0, %6 ], [ 1, %17 ], [ 0, %4 ], [ 0, %20 ]
ret i32 %27
}