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


x86 assembly (clang, -O0):
<IncopyOut1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
call   1080 <getc@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%eax
je     11b9 <IncopyOut1+0x59>
mov    -0x4(%rbp),%edi
mov    0x2e3e(%rip),%rax
mov    (%rax),%esi
call   1050 <putc@plt>
mov    0x2e40(%rip),%rcx
cmp    (%rcx),%eax
jne    11b4 <IncopyOut1+0x54>
lea    0xe51(%rip),%rdi
call   1040 <printf@plt>
jmp    1168 <IncopyOut1+0x8>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     11dd <IncopyOut1+0x7d>
lea    0xe36(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <fflush@plt>
mov    0x2df3(%rip),%rcx
cmp    (%rcx),%eax
jne    1201 <IncopyOut1+0xa1>
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<IncopyOut1>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2e79(%rip),%r15
mov    (%r15),%edi
call   1080 <getc@plt>
mov    0x2e62(%rip),%rbx
cmp    (%rbx),%eax
jne    11b9 <IncopyOut1+0x59>
mov    (%r15),%edi
call   1040 <ferror@plt>
test   %rax,%rax
je     119b <IncopyOut1+0x3b>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <fflush@plt>
cmp    (%rbx),%eax
jne    11b2 <IncopyOut1+0x52>
lea    0xe53(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    0x2e10(%rip),%r12
lea    0xe52(%rip),%r14
jmp    11dc <IncopyOut1+0x7c>
nopl   0x0(%rax)
mov    (%r15),%edi
call   1080 <getc@plt>
cmp    (%rbx),%eax
je     1182 <IncopyOut1+0x22>
mov    (%r12),%esi
mov    %eax,%edi
call   1050 <putc@plt>
cmp    (%rbx),%eax
jne    11d0 <IncopyOut1+0x70>
mov    %r14,%rdi
call   1030 <puts@plt>
jmp    11d0 <IncopyOut1+0x70>

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 = [13 x i8] c"input error\0A\00"
@.str.2 = [14 x i8] c"fflush error\0A\00"
define i32 @IncopyOut1() {
%1 = alloca i32
br label %2
2: ; preds = %15, %0
%3 = load i32, i32* @stdin
%4 = call i32 @getc(i32 %3)
store i32 %4, i32* %1
%5 = load i32, i32* @EOF
%6 = icmp ne i32 %4, %5
br i1 %6, label %7, label %16
7: ; preds = %2
%8 = load i32, i32* %1
%9 = load i32, i32* @stdout
%10 = 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 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %7
br label %2
16: ; preds = %2
%17 = load i32, i32* @stdin
%18 = call i64 @ferror(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = call i32 @fflush(i32* null)
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
%29 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i32 0
@stdout = global i32 0
@str = [13 x i8] c"fflush error\00"
@str.3 = [12 x i8] c"input error\00"
@str.4 = [13 x i8] c"output error\00"
define i32 @IncopyOut1() {
%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 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.4, 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 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.3, i64 0, i64 0))
br label %24
24: ; preds = %22, %18
%25 = tail call i32 @fflush(i32* null)
%26 = load i32, i32* @EOF
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %30
30: ; preds = %28, %24
%31 = tail call i32 @exit(i32 0)
unreachable
}