#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 */

/* Variables and functions */
int /*<<< orphan*/ cat(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  int fd, i;
  if (argc <= 1) {
    cat(0);
    exit(1);
  }
  for (i = 1; i < argc; i++) {
    if ((fd = open(argv[i], 0)) < 0) {
      printf("cat: cannot open %s\n", argv[i]);
      exit(0);
    }
    cat(fd);
    close(fd);
  }
  exit(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)
jg     1181 <main+0x31>
xor    %edi,%edi
call   1070 <cat@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f0 <main+0xa0>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %esi,%esi
call   1050 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11d2 <main+0x82>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0x14(%rbp),%edi
call   1070 <cat@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1188 <main+0x38>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jge    116d <main+0x1d>
xor    %edi,%edi
call   1070 <cat@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    %rsi,%r14
mov    %edi,%r15d
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdi
xor    %esi,%esi
call   1050 <open@plt>
test   %eax,%eax
js     11af <main+0x5f>
mov    %eax,%ebp
mov    %eax,%edi
call   1070 <cat@plt>
mov    %ebp,%edi
call   1040 <close@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1180 <main+0x30>
xor    %edi,%edi
call   1060 <exit@plt>
mov    (%r14,%rbx,8),%rsi
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"cat: cannot open %s\0A\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 sle i32 %8, 1
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = call i32 @cat(i32 0)
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
store i32 1, i32* %7
br label %14
14: ; preds = %39, %13
%15 = load i32, i32* %7
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %42
18: ; preds = %14
%19 = load i8**, i8*** %5
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 @open(i8* %23, i32 0)
store i32 %24, i32* %6
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %34
26: ; preds = %18
%27 = load i8**, i8*** %5
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %31)
%33 = call i32 @exit(i32 0)
unreachable
34: ; preds = %18
%35 = load i32, i32* %6
%36 = call i32 @cat(i32 %35)
%37 = load i32, i32* %6
%38 = call i32 @close(i32 %37)
br label %39
39: ; preds = %34
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %14
42: ; preds = %14
%43 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [21 x i8] c"cat: cannot open %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %9
6: ; preds = %2
%7 = tail call i32 @cat(i32 0)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %4, %21
%10 = phi i64 [ 1, %4 ], [ %24, %21 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i32 @open(i8* %12, i32 0)
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %9
%16 = and i64 %10, 4294967295
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
%19 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = tail call i32 @exit(i32 0)
unreachable
21: ; preds = %9
%22 = tail call i32 @cat(i32 %13)
%23 = tail call i32 @close(i32 %13)
%24 = add nuw nsw i64 %10, 1
%25 = icmp eq i64 %24, %5
br i1 %25, label %26, label %9
26: ; preds = %21
%27 = tail call i32 @exit(i32 0)
unreachable
}