#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;
scalar_t__ ferror(int /*<<< orphan*/);
int getc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int putc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int c;
  while ((c = getc(stdin)) != EOF) {
    if (putc(c, stdout) == EOF) {
      printf("output error");
    }
  }
  if (ferror(stdin)) {
    printf("input error");
  }
  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)
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
call   1060 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e72(%rip),%rcx
cmp    (%rcx),%eax
je     11a7 <main+0x67>
mov    -0x14(%rbp),%edi
mov    0x2e50(%rip),%rax
mov    (%rax),%esi
call   1050 <putc@plt>
mov    0x2e52(%rip),%rcx
cmp    (%rcx),%eax
jne    11a2 <main+0x62>
lea    0xe63(%rip),%rdi
call   1040 <printf@plt>
jmp    1156 <main+0x16>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     11cb <main+0x8b>
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2e99(%rip),%r15
mov    (%r15),%edi
call   1060 <getc@plt>
mov    0x2e82(%rip),%rbx
cmp    (%rbx),%eax
jne    1189 <main+0x49>
mov    (%r15),%edi
call   1030 <ferror@plt>
test   %rax,%rax
je     117b <main+0x3b>
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2e40(%rip),%r12
lea    0xe69(%rip),%r14
jmp    11ac <main+0x6c>
nopl   0x0(%rax)
mov    (%r15),%edi
call   1060 <getc@plt>
cmp    (%rbx),%eax
je     1162 <main+0x22>
mov    (%r12),%esi
mov    %eax,%edi
call   1050 <putc@plt>
cmp    (%rbx),%eax
jne    11a0 <main+0x60>
mov    %r14,%rdi
call   1040 <printf@plt>
jmp    11a0 <main+0x60>

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

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