#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*/ O_RDONLY;
int STDIN_FILENO;
int /*<<< orphan*/ close(int);
int open(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ print_file_contents(int);
scalar_t__ stdin_non_empty();
int /*<<< orphan*/ usage(char const *);
int main(int argc, char const *argv[]) {
  int i;
  int fd;
  if (argc > 1) {
    for (i = 1; i < argc; i++) {
      fd = open(argv[i], O_RDONLY);
      print_file_contents(fd);
      close(fd);
    }
  } else if (stdin_non_empty()) {
    print_file_contents(STDIN_FILENO);
  } else {
    usage(argv[0]);
  }
  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)
jle    11c3 <main+0x73>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11be <main+0x6e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e52(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1070 <print_file_contents@plt>
mov    -0x18(%rbp),%edi
call   1030 <close@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1177 <main+0x27>
jmp    11f8 <main+0xa8>
mov    $0x0,%al
call   1050 <stdin_non_empty@plt>
cmp    $0x0,%rax
je     11e7 <main+0x97>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1070 <print_file_contents@plt>
jmp    11f3 <main+0xa3>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <usage@plt>
jmp    11f8 <main+0xa8>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
cmp    $0x2,%edi
jl     1198 <main+0x48>
mov    %edi,%r15d
mov    $0x1,%ebx
mov    0x2e79(%rip),%r12
nop
mov    (%r14,%rbx,8),%rdi
mov    (%r12),%esi
call   1060 <open@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1070 <print_file_contents@plt>
mov    %ebp,%edi
call   1030 <close@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1170 <main+0x20>
jmp    11bc <main+0x6c>
xor    %eax,%eax
call   1050 <stdin_non_empty@plt>
test   %rax,%rax
je     11b4 <main+0x64>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1070 <print_file_contents@plt>
jmp    11bc <main+0x6c>
mov    (%r14),%rdi
call   1040 <usage@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@STDIN_FILENO = global i32 0
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 sgt i32 %8, 1
br i1 %9, label %10, label %31
10: ; preds = %2
store i32 1, i32* %6
br label %11
11: ; preds = %27, %10
%12 = load i32, i32* %6
%13 = load i32, i32* %4
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %30
15: ; preds = %11
%16 = load i8**, i8*** %5
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8*, i8** %16, i64 %18
%20 = load i8*, i8** %19
%21 = load i32, i32* @O_RDONLY
%22 = call i32 @open(i8* %20, i32 %21)
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = call i32 @print_file_contents(i32 %23)
%25 = load i32, i32* %7
%26 = call i32 @close(i32 %25)
br label %27
27: ; preds = %15
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %11
30: ; preds = %11
br label %43
31: ; preds = %2
%32 = call i64 (...) @stdin_non_empty()
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32, i32* @STDIN_FILENO
%36 = call i32 @print_file_contents(i32 %35)
br label %42
37: ; preds = %31
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 0
%40 = load i8*, i8** %39
%41 = call i32 @usage(i8* %40)
br label %42
42: ; preds = %37, %34
br label %43
43: ; preds = %42, %30
ret i32 0
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@STDIN_FILENO = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %16
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 1, %4 ], [ %14, %6 ]
%8 = getelementptr inbounds i8*, i8** %1, i64 %7
%9 = load i8*, i8** %8
%10 = load i32, i32* @O_RDONLY
%11 = tail call i32 @open(i8* %9, i32 %10)
%12 = tail call i32 @print_file_contents(i32 %11)
%13 = tail call i32 @close(i32 %11)
%14 = add nuw nsw i64 %7, 1
%15 = icmp eq i64 %14, %5
br i1 %15, label %25, label %6
16: ; preds = %2
%17 = tail call i64 (...) @stdin_non_empty()
%18 = icmp eq i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* @STDIN_FILENO
%21 = tail call i32 @print_file_contents(i32 %20)
br label %25
22: ; preds = %16
%23 = load i8*, i8** %1
%24 = tail call i32 @usage(i8* %23)
br label %25
25: ; preds = %6, %19, %22
ret i32 0
}