#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();
int /*<<< orphan*/ putchar(char);
scalar_t__ spaceisupper(char);
char tolower(char);
char toupper(char);
int main(int argc, char **argv) {
  char ch;
  while ((ch = getchar()) != EOF) {
    if (((ch) >= 'A' && (ch) <= 'Z')) {
      putchar(tolower(ch));
    }
    if (spaceisupper(ch)) {
      putchar(toupper(ch));
    }
  }
  putchar('\n');
  return 0;
}


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    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e6e(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11d9 <main+0x89>
movsbl -0x11(%rbp),%eax
cmp    $0x41,%eax
jl     11b0 <main+0x60>
movsbl -0x11(%rbp),%eax
cmp    $0x5a,%eax
jg     11b0 <main+0x60>
movsbl -0x11(%rbp),%edi
call   1070 <tolower@plt>
movsbl %al,%edi
call   1030 <putchar@plt>
movsbl -0x11(%rbp),%edi
call   1050 <spaceisupper@plt>
cmp    $0x0,%rax
je     11d4 <main+0x84>
movsbl -0x11(%rbp),%edi
call   1040 <toupper@plt>
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    1166 <main+0x16>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e86(%rip),%r14
jmp    1177 <main+0x27>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    (%r14),%al
je     11b3 <main+0x63>
lea    -0x41(%rax),%ecx
movsbl %al,%ebx
cmp    $0x19,%cl
ja     1196 <main+0x46>
mov    %ebx,%edi
call   1070 <tolower@plt>
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
call   1050 <spaceisupper@plt>
test   %rax,%rax
je     1170 <main+0x20>
mov    %ebx,%edi
call   1040 <toupper@plt>
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    1170 <main+0x20>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EOF = global i8 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %33, %2
%8 = call signext i8 (...) @getchar()
store i8 %8, i8* %6
%9 = sext i8 %8 to i32
%10 = load i8, i8* @EOF
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %9, %11
br i1 %12, label %13, label %34
13: ; preds = %7
%14 = load i8, i8* %6
%15 = sext i8 %14 to i32
%16 = icmp sge i32 %15, 65
br i1 %16, label %17, label %25
17: ; preds = %13
%18 = load i8, i8* %6
%19 = sext i8 %18 to i32
%20 = icmp sle i32 %19, 90
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i8, i8* %6
%23 = call signext i8 @tolower(i8 signext %22)
%24 = call i32 @putchar(i8 signext %23)
br label %25
25: ; preds = %21, %17, %13
%26 = load i8, i8* %6
%27 = call i64 @spaceisupper(i8 signext %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = load i8, i8* %6
%31 = call signext i8 @toupper(i8 signext %30)
%32 = call i32 @putchar(i8 signext %31)
br label %33
33: ; preds = %29, %25
br label %7
34: ; preds = %7
%35 = call i32 @putchar(i8 signext 10)
ret i32 0
}

LLVM IR (-O2):
@EOF = global i8 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call signext i8 (...) @getchar()
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %23, label %6
6: ; preds = %2, %19
%7 = phi i8 [ %20, %19 ], [ %3, %2 ]
%8 = add i8 %7, -65
%9 = icmp ult i8 %8, 26
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = tail call signext i8 @tolower(i8 signext %7)
%12 = tail call i32 @putchar(i8 signext %11)
br label %13
13: ; preds = %10, %6
%14 = tail call i64 @spaceisupper(i8 signext %7)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = tail call signext i8 @toupper(i8 signext %7)
%18 = tail call i32 @putchar(i8 signext %17)
br label %19
19: ; preds = %16, %13
%20 = tail call signext i8 (...) @getchar()
%21 = load i8, i8* @EOF
%22 = icmp eq i8 %20, %21
br i1 %22, label %23, label %6
23: ; preds = %19, %2
%24 = tail call i32 @putchar(i8 signext 10)
ret i32 0
}