#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int errno;
int getc(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, char *);
int putc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
char *strerror(int);
int main(int argc, char *argv[]) {
  int c;
  while ((c = getc(stdin)) != EOF) {
    if (EOF == putc(c, stdout)) {
      printf("putc error[%d][%s]\n", errno, strerror(errno));
      return EXIT_FAILURE;
    }
  }
  return EXIT_SUCCESS;
}


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    0x2e8b(%rip),%rax
mov    (%rax),%edi
call   1060 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e72(%rip),%rcx
cmp    (%rcx),%eax
je     11e2 <main+0xa2>
mov    0x2e63(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2e34(%rip),%rax
mov    (%rax),%esi
call   1040 <putc@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jne    11dd <main+0x9d>
mov    0x2e29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x1c(%rbp),%esi
mov    %rax,%rdx
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
mov    0x2df5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11ee <main+0xae>
jmp    1156 <main+0x16>
mov    0x2dcf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2e99(%rip),%r15
mov    0x2e8a(%rip),%r12
mov    0x2e5b(%rip),%r14
mov    0x2e5c(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15),%edi
call   1060 <getc@plt>
mov    (%r12),%ebp
cmp    %ebp,%eax
je     11b5 <main+0x75>
mov    (%rbx),%esi
mov    %eax,%edi
call   1040 <putc@plt>
cmp    %eax,%ebp
jne    1170 <main+0x30>
mov    0x2e3c(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1050 <strerror@plt>
lea    0xe5c(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1030 <printf@plt>
mov    0x2e13(%rip),%r14
mov    (%r14),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@EOF = global i32 0
@stdout = global i32 0
@.str = [20 x i8] c"putc error[%d][%s]\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
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 = %24, %2
%8 = load i32, i32* @stdin
%9 = call i32 @getc(i32 %8)
store i32 %9, i32* %6
%10 = load i32, i32* @EOF
%11 = icmp ne i32 %9, %10
br i1 %11, label %12, label %25
12: ; preds = %7
%13 = load i32, i32* @EOF
%14 = load i32, i32* %6
%15 = load i32, i32* @stdout
%16 = call i32 @putc(i32 %14, i32 %15)
%17 = icmp eq i32 %13, %16
br i1 %17, label %18, label %24
18: ; preds = %12
%19 = load i32, i32* @errno
%20 = load i32, i32* @errno
%21 = call i8* @strerror(i32 %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %19, i8* %21)
%23 = load i32, i32* @EXIT_FAILURE
store i32 %23, i32* %3
br label %27
24: ; preds = %12
br label %7
25: ; preds = %7
%26 = load i32, i32* @EXIT_SUCCESS
store i32 %26, i32* %3
br label %27
27: ; preds = %25, %18
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i32 0
@stdout = global i32 0
@.str = [20 x i8] c"putc error[%d][%s]\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %8, %2
%4 = load i32, i32* @stdin
%5 = tail call i32 @getc(i32 %4)
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %16, label %8
8: ; preds = %3
%9 = load i32, i32* @stdout
%10 = tail call i32 @putc(i32 %5, i32 %9)
%11 = icmp eq i32 %6, %10
br i1 %11, label %12, label %3
12: ; preds = %8
%13 = load i32, i32* @errno
%14 = tail call i8* @strerror(i32 %13)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %13, i8* %14)
br label %16
16: ; preds = %3, %12
%17 = phi i32* [ @EXIT_FAILURE, %12 ], [ @EXIT_SUCCESS, %3 ]
%18 = load i32, i32* %17
ret i32 %18
}