#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*/ cat(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  if (argc == 1) {
    cat(stdin, stdout);
  } else {
    FILE *fp;
    int i;
    for (i = 1; i < argc; ++i) {
      printf("reding %s now.\n", argv[i]);
      fp = fopen(argv[i], "rb");
      if (NULL == fp) {
        perror("Cant't open file");
        continue;
      }
      cat(fp, stdout);
      fclose(fp);
    }
  }
  return 0;
}


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)
cmpl   $0x1,-0x8(%rbp)
jne    118d <main+0x3d>
mov    0x2e71(%rip),%rax
mov    (%rax),%rdi
mov    0x2e57(%rip),%rax
mov    (%rax),%esi
call   1070 <cat@plt>
jmp    121f <main+0xcf>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121a <main+0xca>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe4d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe45(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    11f1 <main+0xa1>
lea    0xe2c(%rip),%rdi
call   1060 <perror@plt>
jmp    120c <main+0xbc>
mov    -0x18(%rbp),%rdi
mov    0x2ddc(%rip),%rax
mov    (%rax),%esi
call   1070 <cat@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1194 <main+0x44>
jmp    121f <main+0xcf>
xor    %eax,%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
cmp    $0x1,%edi
jne    117a <main+0x2a>
mov    0x2e81(%rip),%rax
mov    (%rax),%rdi
mov    0x2e67(%rip),%rax
mov    (%rax),%esi
call   1070 <cat@plt>
jmp    11f4 <main+0xa4>
jle    11f4 <main+0xa4>
mov    %rsi,%r13
mov    %edi,%ebp
mov    $0x1,%r12d
lea    0xe72(%rip),%r14
lea    0xe7b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%r13,%r12,8),%rsi
mov    %r14,%rdi
call   1040 <printf@plt>
mov    0x0(%r13,%r12,8),%rdi
mov    %r15,%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11e6 <main+0x96>
mov    %rax,%rbx
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1070 <cat@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x1,%r12
cmp    %r12,%rbp
jne    11a0 <main+0x50>
jmp    11f4 <main+0xa4>
lea    0xe26(%rip),%rdi
call   1060 <perror@plt>
jmp    11db <main+0x8b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32* null
@stdout = global i32 0
@.str = [16 x i8] c"reding %s now.\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [17 x i8] c"Cant't open file\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* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32*, i32** @stdin
%12 = load i32, i32* @stdout
%13 = call i32 @cat(i32* %11, i32 %12)
br label %46
14: ; preds = %2
store i32 1, i32* %7
br label %15
15: ; preds = %42, %14
%16 = load i32, i32* %7
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %45
19: ; preds = %15
%20 = load i8**, i8*** %5
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = load i8**, i8*** %5
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %31, i32** %6
%32 = load i32*, i32** %6
%33 = icmp eq i32* null, %32
br i1 %33, label %34, label %36
34: ; preds = %19
%35 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %42
36: ; preds = %19
%37 = load i32*, i32** %6
%38 = load i32, i32* @stdout
%39 = call i32 @cat(i32* %37, i32 %38)
%40 = load i32*, i32** %6
%41 = call i32 @fclose(i32* %40)
br label %42
42: ; preds = %36, %34
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %15
45: ; preds = %15
br label %46
46: ; preds = %45, %10
ret i32 0
}

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