#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);
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(void) {
  int c;
  while ((c = getc(stdin)) != EOF) {
    if (putc(c, stdout) == EOF) {
      printf("output error\n");
      exit(1);
    }
    if (ferror(stdin)) {
      printf("input error");
      exit(2);
    }
  }
  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     11e8 <main+0x98>
mov    -0x8(%rbp),%edi
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
call   1050 <putc@plt>
mov    0x2e49(%rip),%rcx
cmp    (%rcx),%eax
jne    11b5 <main+0x65>
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     11e3 <main+0x93>
lea    0xe3a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%edi
call   1060 <exit@plt>
jmp    115f <main+0xf>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2e7c(%rip),%r14
mov    0x2e6d(%rip),%rbx
mov    0x2e56(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    (%r14),%edi
call   1080 <getc@plt>
cmp    (%rbx),%eax
je     11bd <main+0x5d>
mov    (%r15),%esi
mov    %eax,%edi
call   1060 <putc@plt>
cmp    (%rbx),%eax
je     11c4 <main+0x64>
mov    (%r14),%edi
call   1040 <ferror@plt>
test   %rax,%rax
je     1180 <main+0x20>
lea    0xe52(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%edi
call   1070 <exit@plt>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xe41(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i32 0
@stdout = global i32 0
@.str = [14 x i8] c"output error\0A\00"
@.str.1 = [12 x i8] c"input error\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %24, %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 %25
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 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %8
%18 = load i32, i32* @stdin
%19 = call i64 @ferror(i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 @exit(i32 2)
unreachable
24: ; preds = %17
br label %3
25: ; preds = %3
%26 = call i32 @exit(i32 0)
unreachable
}

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