#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*/ printf(char *, unsigned long);
main() {
  unsigned long int words = 0;
  char ch;
  while ((ch = getchar()) != EOF)
    if ((ch == ' ') || (ch == '\t') || (ch == '\n'))
      words++;
  printf("%d\n", words);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e9d(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     118e <main+0x6e>
movsbl -0x11(%rbp),%eax
cmp    $0x20,%eax
je     117d <main+0x5d>
movsbl -0x11(%rbp),%eax
cmp    $0x9,%eax
je     117d <main+0x5d>
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
jne    1189 <main+0x69>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1137 <main+0x17>
mov    -0x10(%rbp),%rsi
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb3(%rip),%r14
cmp    (%r14),%al
jne    1151 <main+0x31>
lea    0xebf(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
movabs $0x100000600,%r15
xor    %ebx,%ebx
jmp    116c <main+0x4c>
nop
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%al
je     113a <main+0x1a>
cmp    $0x20,%al
ja     1160 <main+0x40>
movzbl %al,%eax
bt     %rax,%r15
jae    1160 <main+0x40>
add    $0x1,%rbx
jmp    1160 <main+0x40>

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

LLVM IR (-O2):
@EOF = global i8 0
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call signext i8 (...) @getchar()
%2 = load i8, i8* @EOF
%3 = icmp eq i8 %1, %2
br i1 %3, label %14, label %4
4: ; preds = %0, %9
%5 = phi i8 [ %11, %9 ], [ %1, %0 ]
%6 = phi i64 [ %10, %9 ], [ 0, %0 ]
switch i8 %5, label %9 [
i8 32, label %7
i8 10, label %7
i8 9, label %7
]
7: ; preds = %4, %4, %4
%8 = add i64 %6, 1
br label %9
9: ; preds = %4, %7
%10 = phi i64 [ %8, %7 ], [ %6, %4 ]
%11 = tail call signext i8 (...) @getchar()
%12 = load i8, i8* @EOF
%13 = icmp eq i8 %11, %12
br i1 %13, label %14, label %4
14: ; preds = %9, %0
%15 = phi i64 [ 0, %0 ], [ %10, %9 ]
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %15)
ret i32 0
}