#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 getchar();
int /*<<< orphan*/ printf(char *, int);
main() {
  int c, count, on_word;
  on_word = 0;
  count = 0;
  while ((c = getchar()) != '\n') {
    if (c == ' ' || c == '\t') {
      if (on_word)
        on_word = 0;
    } else {
      if (!on_word) {
        on_word = 1;
        ++count;
      }
    }
  }
  printf("Words count: %d\n", count);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xa,%eax
je     119e <main+0x7e>
cmpl   $0x20,-0x8(%rbp)
je     1164 <main+0x44>
cmpl   $0x9,-0x8(%rbp)
jne    117a <main+0x5a>
cmpl   $0x0,-0x10(%rbp)
je     1175 <main+0x55>
movl   $0x0,-0x10(%rbp)
jmp    1199 <main+0x79>
cmpl   $0x0,-0x10(%rbp)
jne    1194 <main+0x74>
movl   $0x1,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1199 <main+0x79>
jmp    113d <main+0x1d>
mov    -0xc(%rbp),%esi
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ecx
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ecx,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
mov    $0x1,%ecx
cmp    $0x9,%eax
je     1130 <main+0x10>
cmp    $0x20,%eax
je     1130 <main+0x10>
cmp    $0xa,%eax
je     1153 <main+0x33>
add    %ebp,%ebx
xor    %ecx,%ecx
jmp    1130 <main+0x10>
lea    0xea6(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [17 x i8] c"Words count: %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %8, %0
%2 = phi i32 [ %9, %8 ], [ 0, %0 ]
%3 = phi i32 [ 0, %8 ], [ 1, %0 ]
br label %4
4: ; preds = %7, %1
%5 = phi i32 [ %3, %1 ], [ 1, %7 ]
%6 = tail call i32 (...) @getchar()
switch i32 %6, label %8 [
i32 10, label %10
i32 32, label %7
i32 9, label %7
]
7: ; preds = %4, %4
br label %4
8: ; preds = %4
%9 = add nsw i32 %2, %5
br label %1
10: ; preds = %4
%11 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %2)
ret i32 0
}