#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*/ exit(int);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fread(unsigned char *, int, size_t, int /*<<< orphan*/ *);
size_t fwrite(unsigned char *, int, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  unsigned char buffer[100000];
  size_t count, red, avail, trunc;
  unsigned char *p = buffer;
  long i;
  FILE *input = stdin;
  if (argc > 1) {
    input = fopen(argv[1], "r");
  }
  p = buffer;
  red = 0;
  avail = 100000;
  for (;;) {
    count = fread(p, 1, avail, input);
    p += count;
    red += count;
    avail -= count;
    if (feof(input))
      break;
  }
  trunc = red;
  for (i = (red - 1); i >= 0; i--) {
    if (buffer[i] != '\0') {
      trunc = i + 1;
      break;
    }
  }
  p = buffer;
  avail = trunc;
  for (;;) {
    count = fwrite(p, 1, avail, stdout);
    if (count == 0)
      break;
    p += count;
    avail -= count;
    if (avail == 0)
      break;
  }
  if (avail > 0)
    exit(1);
  else
    exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x186f0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x186b0(%rbp),%rax
mov    %rax,-0x186d8(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x186e8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11ad <main+0x5d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5f(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x186e8(%rbp)
lea    -0x186b0(%rbp),%rax
mov    %rax,-0x186d8(%rbp)
movq   $0x0,-0x186c0(%rbp)
movq   $0x186a0,-0x186c8(%rbp)
mov    -0x186d8(%rbp),%rdi
mov    -0x186c8(%rbp),%rdx
mov    -0x186e8(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %rax,-0x186b8(%rbp)
mov    -0x186b8(%rbp),%rax
add    -0x186d8(%rbp),%rax
mov    %rax,-0x186d8(%rbp)
mov    -0x186b8(%rbp),%rax
add    -0x186c0(%rbp),%rax
mov    %rax,-0x186c0(%rbp)
mov    -0x186b8(%rbp),%rcx
mov    -0x186c8(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x186c8(%rbp)
mov    -0x186e8(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%rax
je     1254 <main+0x104>
jmp    1259 <main+0x109>
jmp    11d1 <main+0x81>
mov    -0x186c0(%rbp),%rax
mov    %rax,-0x186d0(%rbp)
mov    -0x186c0(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x186e0(%rbp)
cmpq   $0x0,-0x186e0(%rbp)
jl     12d2 <main+0x182>
mov    -0x186e0(%rbp),%rax
movzbl -0x186b0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     12b6 <main+0x166>
mov    -0x186e0(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x186d0(%rbp)
jmp    12d2 <main+0x182>
jmp    12bb <main+0x16b>
mov    -0x186e0(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x186e0(%rbp)
jmp    1279 <main+0x129>
lea    -0x186b0(%rbp),%rax
mov    %rax,-0x186d8(%rbp)
mov    -0x186d0(%rbp),%rax
mov    %rax,-0x186c8(%rbp)
mov    -0x186d8(%rbp),%rdi
mov    -0x186c8(%rbp),%rdx
mov    0x2cd5(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1070 <fwrite@plt>
mov    %rax,-0x186b8(%rbp)
cmpq   $0x0,-0x186b8(%rbp)
jne    1329 <main+0x1d9>
jmp    136e <main+0x21e>
mov    -0x186b8(%rbp),%rax
add    -0x186d8(%rbp),%rax
mov    %rax,-0x186d8(%rbp)
mov    -0x186b8(%rbp),%rcx
mov    -0x186c8(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x186c8(%rbp)
cmpq   $0x0,-0x186c8(%rbp)
jne    1369 <main+0x219>
jmp    136e <main+0x21e>
jmp    12ee <main+0x19e>
cmpq   $0x0,-0x186c8(%rbp)
jbe    1386 <main+0x236>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x186a8,%rsp
cmp    $0x2,%edi
jl     117b <main+0x2b>
mov    0x8(%rsi),%rdi
lea    0xe8f(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
jmp    1185 <main+0x35>
mov    0x2e66(%rip),%rax
mov    (%rax),%r14
mov    $0x186a0,%r12d
mov    %rsp,%r13
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rbp
mov    %r13,%rdi
mov    $0x1,%esi
mov    %r12,%rdx
mov    %r14,%rcx
call   1030 <fread@plt>
mov    %rax,%rbx
add    %rax,%r13
add    %rax,%r15
sub    %rax,%r12
mov    %r14,%rdi
call   1040 <feof@plt>
test   %rax,%rax
je     11a0 <main+0x50>
lea    (%rbx,%rbp,1),%rax
add    $0xffffffffffffffff,%rax
nopw   0x0(%rax,%rax,1)
test   %rax,%rax
js     11f9 <main+0xa9>
lea    -0x1(%rax),%rcx
cmpb   $0x0,(%rsp,%rax,1)
mov    %rcx,%rax
je     11e0 <main+0x90>
add    $0x2,%rcx
mov    %rcx,%r15
mov    %rsp,%rbx
mov    0x2dd5(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
call   1070 <fwrite@plt>
test   %rax,%rax
je     1232 <main+0xe2>
add    %rax,%rbx
sub    %rax,%r15
jne    1210 <main+0xc0>
jmp    1237 <main+0xe7>
test   %r15,%r15
jne    123e <main+0xee>
xor    %edi,%edi
call   1060 <exit@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100000 x i8]
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = getelementptr inbounds [100000 x i8], [100000 x i8]* %6, i64 0, i64 0
store i8* %14, i8** %11
%15 = load i32*, i32** @stdin
store i32* %15, i32** %13
%16 = load i32, i32* %4
%17 = icmp sgt i32 %16, 1
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %22, i32** %13
br label %23
23: ; preds = %18, %2
%24 = getelementptr inbounds [100000 x i8], [100000 x i8]* %6, i64 0, i64 0
store i8* %24, i8** %11
store i64 0, i64* %8
store i64 100000, i64* %9
br label %25
25: ; preds = %43, %23
%26 = load i8*, i8** %11
%27 = load i64, i64* %9
%28 = load i32*, i32** %13
%29 = call i64 @fread(i8* %26, i32 1, i64 %27, i32* %28)
store i64 %29, i64* %7
%30 = load i64, i64* %7
%31 = load i8*, i8** %11
%32 = getelementptr inbounds i8, i8* %31, i64 %30
store i8* %32, i8** %11
%33 = load i64, i64* %7
%34 = load i64, i64* %8
%35 = add i64 %34, %33
store i64 %35, i64* %8
%36 = load i64, i64* %7
%37 = load i64, i64* %9
%38 = sub i64 %37, %36
store i64 %38, i64* %9
%39 = load i32*, i32** %13
%40 = call i64 @feof(i32* %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %25
br label %44
43: ; preds = %25
br label %25
44: ; preds = %42
%45 = load i64, i64* %8
store i64 %45, i64* %10
%46 = load i64, i64* %8
%47 = sub i64 %46, 1
store i64 %47, i64* %12
br label %48
48: ; preds = %61, %44
%49 = load i64, i64* %12
%50 = icmp sge i64 %49, 0
br i1 %50, label %51, label %64
51: ; preds = %48
%52 = load i64, i64* %12
%53 = getelementptr inbounds [100000 x i8], [100000 x i8]* %6, i64 0, i64 %52
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %60
57: ; preds = %51
%58 = load i64, i64* %12
%59 = add nsw i64 %58, 1
store i64 %59, i64* %10
br label %64
60: ; preds = %51
br label %61
61: ; preds = %60
%62 = load i64, i64* %12
%63 = add nsw i64 %62, -1
store i64 %63, i64* %12
br label %48
64: ; preds = %57, %48
%65 = getelementptr inbounds [100000 x i8], [100000 x i8]* %6, i64 0, i64 0
store i8* %65, i8** %11
%66 = load i64, i64* %10
store i64 %66, i64* %9
br label %67
67: ; preds = %85, %64
%68 = load i8*, i8** %11
%69 = load i64, i64* %9
%70 = load i32, i32* @stdout
%71 = call i64 @fwrite(i8* %68, i32 1, i64 %69, i32 %70)
store i64 %71, i64* %7
%72 = load i64, i64* %7
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %75
74: ; preds = %67
br label %86
75: ; preds = %67
%76 = load i64, i64* %7
%77 = load i8*, i8** %11
%78 = getelementptr inbounds i8, i8* %77, i64 %76
store i8* %78, i8** %11
%79 = load i64, i64* %7
%80 = load i64, i64* %9
%81 = sub i64 %80, %79
store i64 %81, i64* %9
%82 = load i64, i64* %9
%83 = icmp eq i64 %82, 0
br i1 %83, label %84, label %85
84: ; preds = %75
br label %86
85: ; preds = %75
br label %67
86: ; preds = %84, %74
%87 = load i64, i64* %9
%88 = icmp ugt i64 %87, 0
br i1 %88, label %89, label %91
89: ; preds = %86
%90 = call i32 @exit(i32 1)
unreachable
91: ; preds = %86
%92 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100000 x i8]
%4 = getelementptr inbounds [100000 x i8], [100000 x i8]* %3, i64 0, i64 0
%5 = load i32*, i32** @stdin
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %7, %2
%12 = phi i32* [ %10, %7 ], [ %5, %2 ]
br label %13
13: ; preds = %13, %11
%14 = phi i64 [ 0, %11 ], [ %19, %13 ]
%15 = phi i64 [ 100000, %11 ], [ %20, %13 ]
%16 = phi i8* [ %4, %11 ], [ %18, %13 ]
%17 = call i64 @fread(i8* %16, i32 1, i64 %15, i32* %12)
%18 = getelementptr inbounds i8, i8* %16, i64 %17
%19 = add i64 %17, %14
%20 = sub i64 %15, %17
%21 = tail call i64 @feof(i32* %12)
%22 = icmp eq i64 %21, 0
br i1 %22, label %13, label %23
23: ; preds = %13, %27
%24 = phi i64 [ %25, %27 ], [ %19, %13 ]
%25 = add i64 %24, -1
%26 = icmp sgt i64 %25, -1
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = getelementptr inbounds [100000 x i8], [100000 x i8]* %3, i64 0, i64 %25
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %23, label %31
31: ; preds = %27, %23
%32 = phi i64 [ %24, %27 ], [ %19, %23 ]
br label %33
33: ; preds = %31, %39
%34 = phi i64 [ %41, %39 ], [ %32, %31 ]
%35 = phi i8* [ %40, %39 ], [ %4, %31 ]
%36 = load i32, i32* @stdout
%37 = call i64 @fwrite(i8* %35, i32 1, i64 %34, i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %33
%40 = getelementptr inbounds i8, i8* %35, i64 %37
%41 = sub i64 %34, %37
%42 = icmp eq i64 %41, 0
br i1 %42, label %47, label %33
43: ; preds = %33
%44 = icmp eq i64 %34, 0
br i1 %44, label %47, label %45
45: ; preds = %43
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %39, %43
%48 = call i32 @exit(i32 0)
unreachable
}