#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 fgetc(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int fputc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int c;
  while (EOF != (c = fgetc(stdin))) {
    if (EOF == fputc(c, stdout)) {
      fprintf(stderr, "Output error\n");
      exit(1);
    }
  }
  if (ferror(stdin))
    fprintf(stderr, "Input error\n");
  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    0x2e73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
call   1040 <fgetc@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
mov    %ecx,-0x14(%rbp)
cmp    %ecx,%eax
je     11de <main+0x8e>
mov    0x2e49(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2e22(%rip),%rax
mov    (%rax),%esi
call   1050 <fputc@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jne    11d9 <main+0x89>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe36(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1166 <main+0x16>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     120b <main+0xbb>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
lea    0xe08(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e82(%rip),%rbx
mov    0x2e83(%rip),%r14
mov    0x2e5c(%rip),%r15
nopl   0x0(%rax)
mov    (%rbx),%ebp
mov    (%r14),%edi
call   1040 <fgetc@plt>
cmp    %eax,%ebp
je     11ad <main+0x5d>
mov    (%rbx),%ebp
mov    (%r15),%esi
mov    %eax,%edi
call   1050 <fputc@plt>
cmp    %eax,%ebp
jne    1170 <main+0x20>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    0xe62(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    (%r14),%edi
call   1030 <ferror@plt>
test   %rax,%rax
je     11cf <main+0x7f>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
call   1060 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@stdin = global i32 0
@stdout = global i32 0
@stderr = global i32 0
@.str = [14 x i8] c"Output error\0A\00"
@.str.1 = [13 x i8] c"Input error\0A\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 = %22, %2
%8 = load i32, i32* @EOF
%9 = load i32, i32* @stdin
%10 = call i32 @fgetc(i32 %9)
store i32 %10, i32* %6
%11 = icmp ne i32 %8, %10
br i1 %11, label %12, label %23
12: ; preds = %7
%13 = load i32, i32* @EOF
%14 = load i32, i32* %6
%15 = load i32, i32* @stdout
%16 = call i32 @fputc(i32 %14, i32 %15)
%17 = icmp eq i32 %13, %16
br i1 %17, label %18, label %22
18: ; preds = %12
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %12
br label %7
23: ; preds = %7
%24 = load i32, i32* @stdin
%25 = call i64 @ferror(i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %27, %23
ret i32 0
}

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