#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 EOF;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ ferror(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getc(int /*<<< orphan*/);
int putc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main() {
  int c;
  while ((c = getc(stdin)) != EOF) {
    if (putc(c, stdout) == EOF) {
      fprintf(stderr, "output error\n");
    }
  };
  if (ferror(stdin)) {
    fprintf(stderr, "input error \n");
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
call   1070 <getc@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e69(%rip),%rcx
cmp    (%rcx),%eax
je     11b9 <main+0x69>
mov    -0x8(%rbp),%edi
mov    0x2e3f(%rip),%rax
mov    (%rax),%esi
call   1040 <putc@plt>
mov    0x2e49(%rip),%rcx
cmp    (%rcx),%eax
jne    11b4 <main+0x64>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe51(%rip),%rsi
call   1050 <fprintf@plt>
jmp    115f <main+0xf>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     11e6 <main+0x96>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    0x2e88(%rip),%r15
mov    (%r15),%edi
call   1070 <getc@plt>
mov    0x2e71(%rip),%rbx
cmp    (%rbx),%eax
jne    119c <main+0x4c>
mov    (%r15),%edi
call   1030 <ferror@plt>
test   %rax,%rax
je     1195 <main+0x45>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe7e(%rip),%rsi
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    0x2e25(%rip),%r12
mov    0x2e26(%rip),%r13
lea    0xe4f(%rip),%r14
jmp    11cc <main+0x7c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r15),%edi
call   1070 <getc@plt>
cmp    (%rbx),%eax
je     1173 <main+0x23>
mov    (%r12),%esi
mov    %eax,%edi
call   1040 <putc@plt>
cmp    (%rbx),%eax
jne    11c0 <main+0x70>
mov    0x0(%r13),%edi
mov    %r14,%rsi
call   1050 <fprintf@plt>
jmp    11c0 <main+0x70>

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i32 0
@stdout = global i32 0
@stderr = global i32 0
@.str = [14 x i8] c"output error\0A\00"
@.str.1 = [14 x i8] c"input error \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %17, %0
%4 = load i32, i32* @stdin
%5 = call i32 @getc(i32 %4)
store i32 %5, i32* %2
%6 = load i32, i32* @EOF
%7 = icmp ne i32 %5, %6
br i1 %7, label %8, label %18
8: ; preds = %3
%9 = load i32, i32* %2
%10 = load i32, i32* @stdout
%11 = call i32 @putc(i32 %9, i32 %10)
%12 = load i32, i32* @EOF
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %14, %8
br label %3
18: ; preds = %3
%19 = load i32, i32* @stdin
%20 = call i64 @ferror(i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %22, %18
%26 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i32 0
@stdout = global i32 0
@stderr = global i32 0
@.str = [14 x i8] c"output error\0A\00"
@.str.1 = [14 x i8] c"input error \0A\00"
define i32 @main() {
%1 = load i32, i32* @stdin
%2 = tail call i32 @getc(i32 %1)
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %19, label %5
5: ; preds = %0, %14
%6 = phi i32 [ %16, %14 ], [ %2, %0 ]
%7 = load i32, i32* @stdout
%8 = tail call i32 @putc(i32 %6, i32 %7)
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %5
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %11, %5
%15 = load i32, i32* @stdin
%16 = tail call i32 @getc(i32 %15)
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %5
19: ; preds = %14, %0
%20 = load i32, i32* @stdin
%21 = tail call i64 @ferror(i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %19
%24 = load i32, i32* @stderr
%25 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %23, %19
%27 = tail call i32 @exit(i32 0)
unreachable
}