#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();
scalar_t__ isspace(int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int inword = 0;
  int wordcnt = 0;
  int c;
  while ((c = getchar()) != EOF) {
    if (isspace(c)) {
      if (inword) {
        inword = 0;
        wordcnt++;
      }
    } else {
      if (!inword) {
        inword = 1;
      }
    }
  }
  if (inword) {
    wordcnt++;
  }
  printf("%d\n", wordcnt);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%eax
je     11b2 <main+0x82>
mov    -0x10(%rbp),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     1197 <main+0x67>
cmpl   $0x0,-0x8(%rbp)
je     1192 <main+0x62>
movl   $0x0,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ad <main+0x7d>
cmpl   $0x0,-0x8(%rbp)
jne    11a8 <main+0x78>
movl   $0x1,-0x8(%rbp)
jmp    11ad <main+0x7d>
jmp    114d <main+0x1d>
cmpl   $0x0,-0x8(%rbp)
je     11c5 <main+0x95>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe31(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%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   1050 <getchar@plt>
mov    0x2ea1(%rip),%r14
mov    $0x0,%ebp
cmp    (%r14),%eax
jne    1172 <main+0x42>
cmp    $0x1,%ebp
sbb    $0xffffffff,%ebx
lea    0xea2(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%r15d
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    1192 <main+0x62>
xchg   %ax,%ax
test   %ebp,%ebp
cmove  %r15d,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%r14),%eax
je     1151 <main+0x21>
mov    %eax,%edi
call   1040 <isspace@plt>
test   %rax,%rax
je     1180 <main+0x50>
cmp    $0x1,%ebp
sbb    $0xffffffff,%ebx
xor    %ebp,%ebp
jmp    1186 <main+0x56>

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

LLVM IR (-O2):
@EOF = global i32 0
@.str = [4 x i8] c"%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 %23, label %4
4: ; preds = %0, %17
%5 = phi i32 [ %20, %17 ], [ %1, %0 ]
%6 = phi i32 [ %19, %17 ], [ 0, %0 ]
%7 = phi i32 [ %18, %17 ], [ 0, %0 ]
%8 = tail call i64 @isspace(i32 %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %4
%11 = icmp ne i32 %6, 0
%12 = zext i1 %11 to i32
%13 = add nsw i32 %7, %12
br label %17
14: ; preds = %4
%15 = icmp eq i32 %6, 0
%16 = select i1 %15, i32 1, i32 %6
br label %17
17: ; preds = %10, %14
%18 = phi i32 [ %7, %14 ], [ %13, %10 ]
%19 = phi i32 [ %16, %14 ], [ 0, %10 ]
%20 = tail call i32 (...) @getchar()
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %4
23: ; preds = %17, %0
%24 = phi i32 [ 0, %0 ], [ %18, %17 ]
%25 = phi i32 [ 0, %0 ], [ %19, %17 ]
%26 = icmp ne i32 %25, 0
%27 = zext i1 %26 to i32
%28 = add nsw i32 %24, %27
%29 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %28)
ret i32 0
}