#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(void) {
  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    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
call   1060 <getc@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e79(%rip),%rcx
cmp    (%rcx),%eax
je     11a0 <main+0x60>
mov    -0x8(%rbp),%edi
mov    0x2e57(%rip),%rax
mov    (%rax),%esi
call   1050 <putc@plt>
mov    0x2e59(%rip),%rcx
cmp    (%rcx),%eax
jne    119b <main+0x5b>
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
jmp    114f <main+0xf>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     11c4 <main+0x84>
lea    0xe4e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%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() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %16, %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 %17
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 %16
14: ; preds = %8
%15 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %8
br label %3
17: ; preds = %3
%18 = load i32, i32* @stdin
%19 = call i64 @ferror(i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %17
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() {
%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 %18, label %5
5: ; preds = %0, %13
%6 = phi i32 [ %15, %13 ], [ %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 %13
11: ; preds = %5
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %5
%14 = load i32, i32* @stdin
%15 = tail call i32 @getc(i32 %14)
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %5
18: ; preds = %13, %0
%19 = load i32, i32* @stdin
%20 = tail call i64 @ferror(i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %18
%23 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %18
ret i32 0
}