#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 /*<<< orphan*/ close(int);
int open(char const *, int /*<<< orphan*/);
unsigned int read(int, char *, int);
int /*<<< orphan*/ write(int, char *, unsigned int);
int main(int argc, const char *argv[]) {
  static char ch[(1024 * 256) + 1];
  int fd_in;
  unsigned int len = 0;
  if (argc >= 7) {
    if ((fd_in = open(argv[6], O_RDONLY)) < 0) {
      return (-2);
    }
  } else {
    fd_in = 0;
  }
  while ((len = read(fd_in, ch, (1024 * 256))) > 0) {
    write(1, ch, len);
  }
  if (fd_in)
    close(fd_in);
  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   $0x0,-0x18(%rbp)
cmpl   $0x7,-0x8(%rbp)
jl     119a <main+0x5a>
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1195 <main+0x55>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11f8 <main+0xb8>
jmp    11a1 <main+0x61>
movl   $0x0,-0x14(%rbp)
jmp    11a6 <main+0x66>
mov    -0x14(%rbp),%edi
lea    0x2ea0(%rip),%rsi
mov    $0x40000,%edx
call   1050 <read@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jbe    11df <main+0x9f>
mov    -0x18(%rbp),%edx
mov    $0x1,%edi
lea    0x2e7b(%rip),%rsi
call   1030 <write@plt>
jmp    11a6 <main+0x66>
cmpl   $0x0,-0x14(%rbp)
je     11f1 <main+0xb1>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
cmp    $0x7,%edi
jl     1162 <main+0x22>
mov    0x30(%rsi),%rdi
mov    0x2e93(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,%ebp
test   %eax,%eax
js     11b1 <main+0x71>
lea    0x2ee7(%rip),%rsi
mov    %ebp,%edi
mov    $0x40000,%edx
call   1050 <read@plt>
test   %eax,%eax
je     11a2 <main+0x62>
lea    0x2ed0(%rip),%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x40000,%edx
call   1050 <read@plt>
test   %eax,%eax
jne    1180 <main+0x40>
xor    %ebx,%ebx
test   %ebp,%ebp
je     11b6 <main+0x76>
mov    %ebp,%edi
call   1040 <close@plt>
jmp    11b6 <main+0x76>
mov    $0xfffffffe,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@main.ch = internal global [262145 x i8] zeroinitializer
@O_RDONLY = 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 0, i32* %7
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, 7
br i1 %9, label %10, label %19
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 6
%13 = load i8*, i8** %12
%14 = load i32, i32* @O_RDONLY
%15 = call i32 @open(i8* %13, i32 %14)
store i32 %15, i32* %6
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %10
store i32 -2, i32* %3
br label %35
18: ; preds = %10
br label %20
19: ; preds = %2
store i32 0, i32* %6
br label %20
20: ; preds = %19, %18
br label %21
21: ; preds = %25, %20
%22 = load i32, i32* %6
%23 = call i32 @read(i32 %22, i8* getelementptr inbounds ([262145 x i8], [262145 x i8]* @main.ch, i64 0, i64 0), i32 262144)
store i32 %23, i32* %7
%24 = icmp ugt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i32, i32* %7
%27 = call i32 @write(i32 1, i8* getelementptr inbounds ([262145 x i8], [262145 x i8]* @main.ch, i64 0, i64 0), i32 %26)
br label %21
28: ; preds = %21
%29 = load i32, i32* %6
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* %6
%33 = call i32 @close(i32 %32)
br label %34
34: ; preds = %31, %28
store i32 0, i32* %3
br label %35
35: ; preds = %34, %17
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@main.ch = internal global [262145 x i8] zeroinitializer
@O_RDONLY = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 6
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 6
%6 = load i8*, i8** %5
%7 = load i32, i32* @O_RDONLY
%8 = tail call i32 @open(i8* %6, i32 %7)
%9 = icmp slt i32 %8, 0
br i1 %9, label %23, label %10
10: ; preds = %2, %4
%11 = phi i32 [ %8, %4 ], [ 0, %2 ]
%12 = tail call i32 @read(i32 %11, i8* getelementptr inbounds ([262145 x i8], [262145 x i8]* @main.ch, i64 0, i64 0), i32 262144)
%13 = icmp eq i32 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %10, %14
%15 = phi i32 [ %17, %14 ], [ %12, %10 ]
%16 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([262145 x i8], [262145 x i8]* @main.ch, i64 0, i64 0), i32 %15)
%17 = tail call i32 @read(i32 %11, i8* getelementptr inbounds ([262145 x i8], [262145 x i8]* @main.ch, i64 0, i64 0), i32 262144)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %14
19: ; preds = %14, %10
%20 = icmp eq i32 %11, 0
br i1 %20, label %23, label %21
21: ; preds = %19
%22 = tail call i32 @close(i32 %11)
br label %23
23: ; preds = %19, %21, %4
%24 = phi i32 [ -2, %4 ], [ 0, %21 ], [ 0, %19 ]
ret i32 %24
}