#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 /*<<< orphan*/ nonblocking_cat(int);
int open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int i;
  int fd;
  for (i = 1; i < argc; i++) {
    fd = open(argv[i], O_RDONLY, 0);
    if (fd < 0)
      continue;
    nonblocking_cat(fd);
    close(fd);
  }
  if (argc == 1)
    nonblocking_cat(STDIN_FILENO);
  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)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a5 <main+0x75>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e7c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1187 <main+0x57>
jmp    1197 <main+0x67>
mov    -0x18(%rbp),%edi
call   1040 <nonblocking_cat@plt>
mov    -0x18(%rbp),%edi
call   1030 <close@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x1d>
cmpl   $0x1,-0x8(%rbp)
jne    11bd <main+0x8d>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
call   1040 <nonblocking_cat@plt>
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
mov    %edi,%r14d
cmp    $0x2,%edi
jl     118e <main+0x5e>
mov    %rsi,%r15
mov    %r14d,%r12d
mov    $0x1,%ebx
mov    0x2e93(%rip),%r13
jmp    1169 <main+0x39>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %rbx,%r12
je     118e <main+0x5e>
mov    (%r15,%rbx,8),%rdi
mov    0x0(%r13),%esi
xor    %edx,%edx
call   1050 <open@plt>
test   %eax,%eax
js     1160 <main+0x30>
mov    %eax,%ebp
mov    %eax,%edi
call   1040 <nonblocking_cat@plt>
mov    %ebp,%edi
call   1030 <close@plt>
jmp    1160 <main+0x30>
cmp    $0x1,%r14d
jne    11a2 <main+0x72>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1040 <nonblocking_cat@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
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
store i32 1, i32* %6
br label %8
8: ; preds = %28, %2
%9 = load i32, i32* %6
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %31
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8*, i8** %13, i64 %15
%17 = load i8*, i8** %16
%18 = load i32, i32* @O_RDONLY
%19 = call i32 @open(i8* %17, i32 %18, i32 0)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %12
br label %28
23: ; preds = %12
%24 = load i32, i32* %7
%25 = call i32 @nonblocking_cat(i32 %24)
%26 = load i32, i32* %7
%27 = call i32 @close(i32 %26)
br label %28
28: ; preds = %23, %22
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %8
31: ; preds = %8
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32, i32* @STDIN_FILENO
%36 = call i32 @nonblocking_cat(i32 %35)
br label %37
37: ; preds = %34, %31
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 %19
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %16
%7 = phi i64 [ 1, %4 ], [ %17, %16 ]
%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, i32 0)
%12 = icmp slt i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %6
%14 = tail call i32 @nonblocking_cat(i32 %11)
%15 = tail call i32 @close(i32 %11)
br label %16
16: ; preds = %6, %13
%17 = add nuw nsw i64 %7, 1
%18 = icmp eq i64 %17, %5
br i1 %18, label %19, label %6
19: ; preds = %16, %2
%20 = icmp eq i32 %0, 1
br i1 %20, label %21, label %24
21: ; preds = %19
%22 = load i32, i32* @STDIN_FILENO
%23 = tail call i32 @nonblocking_cat(i32 %22)
br label %24
24: ; preds = %21, %19
ret i32 0
}