#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 getchar();
int /*<<< orphan*/ putchar(int);
int tolower(int);
int toupper(int);
void format_words(void) {
  int c;
  int sp = 1;
  while ((c = getchar()) != EOF) {
    if (c == ' ' || c == '"' || c == '\t') {
      putchar(c);
      sp = 1;
    } else if (sp == 1) {
      putchar(toupper(c));
      sp = 0;
    } else {
      putchar(tolower(c));
    }
  }
}


x86 assembly (clang, -O0):
<format_words>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x8(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e88(%rip),%rcx
cmp    (%rcx),%eax
je     11d8 <format_words+0x98>
cmpl   $0x20,-0x4(%rbp)
je     1186 <format_words+0x46>
cmpl   $0x22,-0x4(%rbp)
je     1186 <format_words+0x46>
cmpl   $0x9,-0x4(%rbp)
jne    119a <format_words+0x5a>
mov    -0x4(%rbp),%edi
call   1030 <putchar@plt>
movl   $0x1,-0x8(%rbp)
jmp    11d3 <format_words+0x93>
cmpl   $0x1,-0x8(%rbp)
jne    11bf <format_words+0x7f>
mov    -0x4(%rbp),%edi
call   1040 <toupper@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x8(%rbp)
jmp    11ce <format_words+0x8e>
mov    -0x4(%rbp),%edi
call   1060 <tolower@plt>
mov    %eax,%edi
call   1030 <putchar@plt>
jmp    11d3 <format_words+0x93>
jmp    114f <format_words+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_words>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e96(%rip),%rbx
cmp    (%rbx),%eax
jne    115b <format_words+0x1b>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x1,%ebp
movabs $0x500000200,%r14
jmp    1187 <format_words+0x47>
nopl   0x0(%rax)
mov    $0x1,%ebp
mov    %eax,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%rbx),%eax
je     1156 <format_words+0x16>
cmp    $0x22,%eax
ja     1194 <format_words+0x54>
mov    %eax,%ecx
bt     %rcx,%r14
jb     1170 <format_words+0x30>
mov    %eax,%edi
cmp    $0x1,%ebp
je     11a2 <format_words+0x62>
call   1060 <tolower@plt>
jmp    11a7 <format_words+0x67>
call   1040 <toupper@plt>
xor    %ebp,%ebp
jmp    1175 <format_words+0x35>

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

LLVM IR (-O2):
@EOF = global i32 0
define void @format_words() {
%1 = tail call i32 (...) @getchar()
%2 = load i32, i32* @EOF
%3 = icmp eq i32 %1, %2
br i1 %3, label %20, label %4
4: ; preds = %0, %13
%5 = phi i32 [ %17, %13 ], [ %1, %0 ]
%6 = phi i32 [ %15, %13 ], [ 1, %0 ]
switch i32 %5, label %7 [
i32 34, label %13
i32 32, label %13
i32 9, label %13
]
7: ; preds = %4
%8 = icmp eq i32 %6, 1
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = tail call i32 @toupper(i32 %5)
br label %13
11: ; preds = %7
%12 = tail call i32 @tolower(i32 %5)
br label %13
13: ; preds = %4, %4, %4, %9, %11
%14 = phi i32 [ %10, %9 ], [ %12, %11 ], [ %5, %4 ], [ %5, %4 ], [ %5, %4 ]
%15 = phi i32 [ 0, %9 ], [ 0, %11 ], [ 1, %4 ], [ 1, %4 ], [ 1, %4 ]
%16 = tail call i32 @putchar(i32 %14)
%17 = tail call i32 (...) @getchar()
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %4
20: ; preds = %13, %0
ret void
}