#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*/ printf(char *, long);
int main(void) {
  int cur_char;
  int state;
  long words_count;
  state = 0;
  words_count = 0;
  while ((cur_char = getchar()) != EOF) {
    if (state == 0) {
      if (cur_char != '\t' && cur_char != '\n' && cur_char != ' ') {
        words_count++;
        state = 1;
      }
    }
    if (state == 1) {
      if (cur_char == '\t' || cur_char == '\n' || cur_char == ' ') {
        state = 0;
      }
    }
  }
  printf("Count of words is %ld.\n", words_count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e99(%rip),%rcx
cmp    (%rcx),%eax
je     11d0 <main+0xb0>
cmpl   $0x0,-0xc(%rbp)
jne    1197 <main+0x77>
cmpl   $0x9,-0x8(%rbp)
je     1192 <main+0x72>
cmpl   $0xa,-0x8(%rbp)
je     1192 <main+0x72>
cmpl   $0x20,-0x8(%rbp)
je     1192 <main+0x72>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0xc(%rbp)
jmp    1197 <main+0x77>
cmpl   $0x1,-0xc(%rbp)
jne    11cb <main+0xab>
cmpl   $0x9,-0x8(%rbp)
je     11bf <main+0x9f>
cmpl   $0xa,-0x8(%rbp)
je     11bf <main+0x9f>
cmpl   $0x20,-0x8(%rbp)
jne    11c6 <main+0xa6>
movl   $0x0,-0xc(%rbp)
jmp    11cb <main+0xab>
jmp    113e <main+0x1e>
mov    -0x18(%rbp),%rsi
lea    0xe25(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb3(%rip),%rbx
cmp    (%rbx),%eax
jne    1158 <main+0x38>
xor    %r14d,%r14d
lea    0xebd(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
movabs $0x100000600,%r15
xor    %r14d,%r14d
xor    %ebp,%ebp
jmp    117b <main+0x5b>
nopl   0x0(%rax)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%rbx),%eax
je     113c <main+0x1c>
mov    %eax,%ecx
test   %ebp,%ebp
je     11a0 <main+0x80>
mov    $0x1,%ebp
cmp    $0x20,%eax
ja     1170 <main+0x50>
bt     %rcx,%r15
jae    1170 <main+0x50>
xor    %ebp,%ebp
jmp    1170 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x20,%eax
ja     11ad <main+0x8d>
xor    %ebp,%ebp
bt     %rcx,%r15
jb     1170 <main+0x50>
add    $0x1,%r14
jmp    1181 <main+0x61>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [24 x i8] c"Count of words is %ld.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %3
store i64 0, i64* %4
br label %5
5: ; preds = %39, %0
%6 = call i32 (...) @getchar()
store i32 %6, i32* %2
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %40
9: ; preds = %5
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %25
12: ; preds = %9
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 9
br i1 %14, label %15, label %24
15: ; preds = %12
%16 = load i32, i32* %2
%17 = icmp ne i32 %16, 10
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i32, i32* %2
%20 = icmp ne i32 %19, 32
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i64, i64* %4
%23 = add nsw i64 %22, 1
store i64 %23, i64* %4
store i32 1, i32* %3
br label %24
24: ; preds = %21, %18, %15, %12
br label %25
25: ; preds = %24, %9
%26 = load i32, i32* %3
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %39
28: ; preds = %25
%29 = load i32, i32* %2
%30 = icmp eq i32 %29, 9
br i1 %30, label %37, label %31
31: ; preds = %28
%32 = load i32, i32* %2
%33 = icmp eq i32 %32, 10
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = load i32, i32* %2
%36 = icmp eq i32 %35, 32
br i1 %36, label %37, label %38
37: ; preds = %34, %31, %28
store i32 0, i32* %3
br label %38
38: ; preds = %37, %34
br label %39
39: ; preds = %38, %25
br label %5
40: ; preds = %5
%41 = load i64, i64* %4
%42 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i64 %41)
ret i32 0
}

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