#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*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int getchar();
scalar_t__ isupper(int);
int /*<<< orphan*/ printf(char *);
int putchar(int);
int /*<<< orphan*/ stdout;
int tolower(int);
int main() {
  int c;
  while ((c = getchar()) != EOF) {
    if (isupper(c)) {
      c = tolower(c);
    }
    if (putchar(c) == EOF) {
      printf("error: putchar\n");
    }
    if (c == '\n') {
      fflush(stdout);
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e58(%rip),%rcx
cmp    (%rcx),%eax
je     11f5 <main+0x85>
mov    -0x8(%rbp),%edi
call   1080 <isupper@plt>
cmp    $0x0,%rax
je     11b5 <main+0x45>
mov    -0x8(%rbp),%edi
call   1060 <tolower@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <putchar@plt>
mov    0x2e24(%rip),%rcx
cmp    (%rcx),%eax
jne    11d8 <main+0x68>
lea    0xe2d(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0xa,-0x8(%rbp)
jne    11f0 <main+0x80>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
jmp    117f <main+0xf>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e63(%rip),%rbx
cmp    (%rbx),%eax
jne    1190 <main+0x20>
xor    %edi,%edi
call   1090 <exit@plt>
mov    %eax,%ebp
lea    0xe67(%rip),%r14
mov    0x2e38(%rip),%r15
jmp    11bd <main+0x4d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebp
cmp    (%rbx),%eax
je     1189 <main+0x19>
mov    %ebp,%edi
call   1080 <isupper@plt>
test   %rax,%rax
je     11d2 <main+0x62>
mov    %ebp,%edi
call   1060 <tolower@plt>
mov    %eax,%ebp
mov    %ebp,%edi
call   1030 <putchar@plt>
cmp    (%rbx),%eax
jne    11e5 <main+0x75>
mov    %r14,%rdi
call   1040 <puts@plt>
cmp    $0xa,%ebp
jne    11b0 <main+0x40>
mov    (%r15),%edi
call   1070 <fflush@plt>
jmp    11b0 <main+0x40>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [16 x i8] c"error: putchar\0A\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %27, %0
%4 = call i32 (...) @getchar()
store i32 %4, i32* %2
%5 = load i32, i32* @EOF
%6 = icmp ne i32 %4, %5
br i1 %6, label %7, label %28
7: ; preds = %3
%8 = load i32, i32* %2
%9 = call i64 @isupper(i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = load i32, i32* %2
%13 = call i32 @tolower(i32 %12)
store i32 %13, i32* %2
br label %14
14: ; preds = %11, %7
%15 = load i32, i32* %2
%16 = call i32 @putchar(i32 %15)
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %14
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 10
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i32, i32* @stdout
%26 = call i32 @fflush(i32 %25)
br label %27
27: ; preds = %24, %21
br label %3
28: ; preds = %3
%29 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@EOF = global i32 0
@stdout = global i32 0
@str = [15 x i8] c"error: putchar\00"
define i32 @main() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %26, label %4
4: ; preds = %0, %22
%5 = phi i32 [ %23, %22 ], [ %1, %0 ]
%6 = tail call i64 @isupper(i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = tail call i32 @tolower(i32 %5)
br label %10
10: ; preds = %8, %4
%11 = phi i32 [ %9, %8 ], [ %5, %4 ]
%12 = tail call i32 @putchar(i32 %11)
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %17
17: ; preds = %15, %10
%18 = icmp eq i32 %11, 10
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = load i32, i32* @stdout
%21 = tail call i32 @fflush(i32 %20)
br label %22
22: ; preds = %19, %17
%23 = tail call i32 (...) @getchar()
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %4
26: ; preds = %22, %0
%27 = tail call i32 @exit(i32 0)
unreachable
}