#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 */
char EOF;
char getchar();
scalar_t__ isupper(char);
int /*<<< orphan*/ putchar(char);
char tolower(char);
main() {
  char ch;
  while ((ch = getchar()) != EOF) {
    if (isupper(ch))
      ch = tolower(ch);
    putchar(ch);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e85(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     119b <main+0x5b>
movsbl -0x5(%rbp),%edi
call   1060 <isupper@plt>
cmp    $0x0,%rax
je     118d <main+0x4d>
movsbl -0x5(%rbp),%edi
call   1050 <tolower@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
jmp    114f <main+0xf>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2e96(%rip),%r14
cmp    (%r14),%al
jne    115e <main+0x1e>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %eax,%ebx
jmp    1186 <main+0x46>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %bl,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebx
cmp    (%r14),%al
je     1157 <main+0x17>
movsbl %bl,%ebp
mov    %ebp,%edi
call   1060 <isupper@plt>
test   %rax,%rax
je     1170 <main+0x30>
mov    %ebp,%edi
call   1050 <tolower@plt>
mov    %eax,%ebx
jmp    1170 <main+0x30>

LLVM IR (-O0):
@EOF = global i8 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
br label %3
3: ; preds = %16, %0
%4 = call signext i8 (...) @getchar()
store i8 %4, i8* %2
%5 = sext i8 %4 to i32
%6 = load i8, i8* @EOF
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %5, %7
br i1 %8, label %9, label %19
9: ; preds = %3
%10 = load i8, i8* %2
%11 = call i64 @isupper(i8 signext %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i8, i8* %2
%15 = call signext i8 @tolower(i8 signext %14)
store i8 %15, i8* %2
br label %16
16: ; preds = %13, %9
%17 = load i8, i8* %2
%18 = call i32 @putchar(i8 signext %17)
br label %3
19: ; preds = %3
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@EOF = global i8 0
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = load i8, i8* @EOF
%3 = icmp eq i8 %1, %2
br i1 %3, label %16, label %4
4: ; preds = %0, %10
%5 = phi i8 [ %13, %10 ], [ %1, %0 ]
%6 = tail call i64 @isupper(i8 signext %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = tail call signext i8 @tolower(i8 signext %5)
br label %10
10: ; preds = %8, %4
%11 = phi i8 [ %9, %8 ], [ %5, %4 ]
%12 = tail call i32 @putchar(i8 signext %11)
%13 = tail call signext i8 (...) @getchar()
%14 = load i8, i8* @EOF
%15 = icmp eq i8 %13, %14
br i1 %15, label %16, label %4
16: ; preds = %10, %0
ret i32 0
}