#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 */
typedef int /*<<< orphan*/ outbuff;
typedef int /*<<< orphan*/ inbuff;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ _IOLBF;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getc(int /*<<< orphan*/);
int putc(int, int /*<<< orphan*/);
scalar_t__ setvbuf(int /*<<< orphan*/, char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(void) {
  int inchar, outchar;
  char inbuff[1024], outbuff[1024];
  if (setvbuf(stdin, inbuff, _IOLBF, sizeof(inbuff))) {
    fprintf(stderr, "grocat: Can't set stdin to line-buffered mode!\n");
    exit(EXIT_FAILURE);
  }
  if (setvbuf(stdout, outbuff, _IOLBF, sizeof(outbuff))) {
    fprintf(stderr, "grocat: Can't set stdout to line-buffered mode!\n");
    exit(EXIT_FAILURE);
  }
  while ((inchar = getc(stdin)) != EOF) {
    outchar = putc(inchar, stdout);
    if (outchar != inchar) {
      fprintf(stderr, "grocat: Error writing to stdout!\n");
      exit(EXIT_FAILURE);
    }
  }
  fflush(stdout);
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
lea    -0x410(%rbp),%rsi
mov    0x2e3f(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%ecx
call   1060 <setvbuf@plt>
cmp    $0x0,%rax
je     11c2 <main+0x62>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe51(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
lea    -0x810(%rbp),%rsi
mov    0x2def(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%ecx
call   1060 <setvbuf@plt>
cmp    $0x0,%rax
je     1212 <main+0xb2>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
lea    0xe31(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    1217 <main+0xb7>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   1080 <getc@plt>
mov    %eax,-0x8(%rbp)
mov    0x2db1(%rip),%rcx
cmp    (%rcx),%eax
je     127f <main+0x11f>
mov    -0x8(%rbp),%edi
mov    0x2d77(%rip),%rax
mov    (%rax),%esi
call   1030 <putc@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     127a <main+0x11a>
mov    0x2d72(%rip),%rax
mov    (%rax),%edi
lea    0xdfa(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2d4d(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    1217 <main+0xb7>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    0x2e73(%rip),%r14
mov    (%r14),%edi
mov    0x2e49(%rip),%rbx
mov    (%rbx),%edx
lea    0x400(%rsp),%rsi
mov    $0x400,%ecx
call   1060 <setvbuf@plt>
test   %rax,%rax
jne    11f0 <main+0x90>
mov    0x2e19(%rip),%r15
mov    (%r15),%edi
mov    (%rbx),%edx
mov    %rsp,%rsi
mov    $0x400,%ecx
call   1060 <setvbuf@plt>
test   %rax,%rax
jne    1202 <main+0xa2>
mov    0x2e23(%rip),%r12
nopl   (%rax)
mov    (%r14),%edi
call   1080 <getc@plt>
mov    (%r15),%esi
cmp    (%r12),%eax
je     1225 <main+0xc5>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <putc@plt>
cmp    %ebx,%eax
je     11c0 <main+0x60>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
lea    0xe73(%rip),%rsi
jmp    1212 <main+0xb2>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
lea    0xe00(%rip),%rsi
jmp    1212 <main+0xb2>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
lea    0xe1e(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    %esi,%edi
call   1050 <fflush@plt>
mov    0x2d7d(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@_IOLBF = global i32 0
@stderr = global i32 0
@.str = [48 x i8] c"grocat: Can't set stdin to line-buffered mode!\0A\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
@.str.1 = [49 x i8] c"grocat: Can't set stdout to line-buffered mode!\0A\00"
@EOF = global i32 0
@.str.2 = [34 x i8] c"grocat: Error writing to stdout!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
store i32 0, i32* %1
%6 = load i32, i32* @stdin
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%8 = load i32, i32* @_IOLBF
%9 = call i64 @setvbuf(i32 %6, i8* %7, i32 %8, i32 1024)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %0
%17 = load i32, i32* @stdout
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%19 = load i32, i32* @_IOLBF
%20 = call i64 @setvbuf(i32 %17, i8* %18, i32 %19, i32 1024)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %16
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %16
br label %28
28: ; preds = %45, %27
%29 = load i32, i32* @stdin
%30 = call i32 @getc(i32 %29)
store i32 %30, i32* %2
%31 = load i32, i32* @EOF
%32 = icmp ne i32 %30, %31
br i1 %32, label %33, label %46
33: ; preds = %28
%34 = load i32, i32* %2
%35 = load i32, i32* @stdout
%36 = call i32 @putc(i32 %34, i32 %35)
store i32 %36, i32* %3
%37 = load i32, i32* %3
%38 = load i32, i32* %2
%39 = icmp ne i32 %37, %38
br i1 %39, label %40, label %45
40: ; preds = %33
%41 = load i32, i32* @stderr
%42 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%43 = load i32, i32* @EXIT_FAILURE
%44 = call i32 @exit(i32 %43)
unreachable
45: ; preds = %33
br label %28
46: ; preds = %28
%47 = load i32, i32* @stdout
%48 = call i32 @fflush(i32 %47)
%49 = load i32, i32* @EXIT_SUCCESS
%50 = call i32 @exit(i32 %49)
unreachable
}

LLVM IR (-O2):
@stdin = global i32 0
@_IOLBF = global i32 0
@stderr = global i32 0
@.str = [48 x i8] c"grocat: Can't set stdin to line-buffered mode!\0A\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
@.str.1 = [49 x i8] c"grocat: Can't set stdout to line-buffered mode!\0A\00"
@EOF = global i32 0
@.str.2 = [34 x i8] c"grocat: Error writing to stdout!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = load i32, i32* @stdin
%6 = load i32, i32* @_IOLBF
%7 = call i64 @setvbuf(i32 %5, i8* %3, i32 %6, i32 1024)
%8 = icmp eq i64 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = load i32, i32* @stdout
%16 = load i32, i32* @_IOLBF
%17 = call i64 @setvbuf(i32 %15, i8* %4, i32 %16, i32 1024)
%18 = icmp eq i64 %17, 0
br i1 %18, label %24, label %19
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %14, %30
%25 = load i32, i32* @stdin
%26 = call i32 @getc(i32 %25)
%27 = load i32, i32* @EOF
%28 = icmp eq i32 %26, %27
%29 = load i32, i32* @stdout
br i1 %28, label %38, label %30
30: ; preds = %24
%31 = call i32 @putc(i32 %26, i32 %29)
%32 = icmp eq i32 %31, %26
br i1 %32, label %24, label %33
33: ; preds = %30
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %24
%39 = call i32 @fflush(i32 %29)
%40 = load i32, i32* @EXIT_SUCCESS
%41 = call i32 @exit(i32 %40)
unreachable
}