#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 *, int);
main() {
  int c, nw, state;
  state = 0;
  nw = 0;
  while ((c = getchar()) != EOF) {
    if (c == ' ' || c == '\n' || c == '\t') {
      state = 0;
    } else if (state == 0) {
      state = 1;
      ++nw;
    }
  }
  printf("Word count -> %d\n", nw);
}


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)
mov    0x2e9a(%rip),%rcx
cmp    (%rcx),%eax
je     11a4 <main+0x84>
cmpl   $0x20,-0x8(%rbp)
je     1174 <main+0x54>
cmpl   $0xa,-0x8(%rbp)
je     1174 <main+0x54>
cmpl   $0x9,-0x8(%rbp)
jne    1180 <main+0x60>
movl   $0x0,-0x10(%rbp)
jmp    119f <main+0x7f>
cmpl   $0x0,-0x10(%rbp)
jne    119a <main+0x7a>
movl   $0x1,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119f <main+0x7f>
jmp    113d <main+0x1d>
mov    -0xc(%rbp),%esi
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb1(%rip),%r14
cmp    (%r14),%eax
jne    1157 <main+0x37>
lea    0xebd(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
movabs $0x100000600,%r15
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1187 <main+0x67>
nopw   0x0(%rax,%rax,1)
cmp    $0x1,%ebp
adc    $0x0,%ebx
mov    $0x1,%ebp
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%eax
je     113c <main+0x1c>
cmp    $0x20,%eax
ja     1170 <main+0x50>
mov    %eax,%eax
bt     %rax,%r15
jae    1170 <main+0x50>
xor    %ebp,%ebp
jmp    117b <main+0x5b>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [18 x i8] c"Word 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 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %27
9: ; preds = %5
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 32
br i1 %11, label %18, label %12
12: ; preds = %9
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 10
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 9
br i1 %17, label %18, label %19
18: ; preds = %15, %12, %9
store i32 0, i32* %4
br label %26
19: ; preds = %15
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %25
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 ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [18 x i8] c"Word count -> %d\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 %18, label %4
4: ; preds = %0, %12
%5 = phi i32 [ %15, %12 ], [ %1, %0 ]
%6 = phi i32 [ %14, %12 ], [ 0, %0 ]
%7 = phi i32 [ %13, %12 ], [ 0, %0 ]
switch i32 %5, label %8 [
i32 32, label %12
i32 10, label %12
i32 9, label %12
]
8: ; preds = %4
%9 = icmp eq i32 %6, 0
%10 = zext i1 %9 to i32
%11 = add nsw i32 %7, %10
br label %12
12: ; preds = %8, %4, %4, %4
%13 = phi i32 [ %7, %4 ], [ %7, %4 ], [ %7, %4 ], [ %11, %8 ]
%14 = phi i32 [ 0, %4 ], [ 0, %4 ], [ 0, %4 ], [ 1, %8 ]
%15 = tail call i32 (...) @getchar()
%16 = load i32, i32* @EOF
%17 = icmp eq i32 %15, %16
br i1 %17, label %18, label %4
18: ; preds = %12, %0
%19 = phi i32 [ 0, %0 ], [ %13, %12 ]
%20 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %19)
ret i32 0
}