#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();
scalar_t__ isalpha(char);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int isWord;
  int count;
  char ch;
  isWord = 0;
  count = 0;
  while ((ch = getchar()) != EOF) {
    if (isWord == 0 && isalpha(ch)) {
      isWord = 1;
      count++;
    } else if (isWord == 1 && !isalpha(ch)) {
      isWord = 0;
    }
    if (ch == '\n') {
      printf("%d\n", count);
      count = 0;
    }
  }
  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   1040 <getchar@plt>
mov    %al,-0xd(%rbp)
movsbl %al,%eax
mov    0x2e87(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11ef <main+0xbf>
cmpl   $0x0,-0x8(%rbp)
jne    119e <main+0x6e>
movsbl -0xd(%rbp),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%rax
je     119e <main+0x6e>
movl   $0x1,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c7 <main+0x97>
cmpl   $0x1,-0x8(%rbp)
jne    11c2 <main+0x92>
movsbl -0xd(%rbp),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%rax
jne    11c2 <main+0x92>
movl   $0x0,-0x8(%rbp)
jmp    11c7 <main+0x97>
movsbl -0xd(%rbp),%eax
cmp    $0xa,%eax
jne    11ea <main+0xba>
mov    -0xc(%rbp),%esi
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
jmp    114d <main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2e9f(%rip),%r15
cmp    (%r15),%al
jne    115f <main+0x2f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r12d,%r12d
xor    %r14d,%r14d
jmp    117f <main+0x4f>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %ebp,%r14d
cmp    (%r15),%al
je     114e <main+0x1e>
mov    %r12d,%ebx
movsbl %al,%r13d
mov    %r13d,%edi
call   1050 <isalpha@plt>
test   %rax,%rax
setne  %r12b
not    %bl
and    %r12b,%bl
movzbl %bl,%ebp
add    %r14d,%ebp
cmp    $0xa,%r13b
jne    1170 <main+0x40>
lea    0xe53(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
xor    %ebp,%ebp
jmp    1170 <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 i32
%3 = alloca i32
%4 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %37, %0
%6 = call signext i8 (...) @getchar()
store i8 %6, i8* %4
%7 = sext i8 %6 to i32
%8 = load i8, i8* @EOF
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %7, %9
br i1 %10, label %11, label %38
11: ; preds = %5
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i8, i8* %4
%16 = call i64 @isalpha(i8 signext %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
store i32 1, i32* %2
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 1
store i32 %20, i32* %3
br label %30
21: ; preds = %14, %11
%22 = load i32, i32* %2
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = load i8, i8* %4
%26 = call i64 @isalpha(i8 signext %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %24
store i32 0, i32* %2
br label %29
29: ; preds = %28, %24, %21
br label %30
30: ; preds = %29, %18
%31 = load i8, i8* %4
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 10
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load i32, i32* %3
%36 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %35)
store i32 0, i32* %3
br label %37
37: ; preds = %34, %30
br label %5
38: ; preds = %5
ret i32 0
}

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 %22, label %4
4: ; preds = %0, %17
%5 = phi i8 [ %19, %17 ], [ %1, %0 ]
%6 = phi i1 [ %9, %17 ], [ false, %0 ]
%7 = phi i32 [ %18, %17 ], [ 0, %0 ]
%8 = tail call i64 @isalpha(i8 signext %5)
%9 = icmp ne i64 %8, 0
%10 = xor i1 %6, true
%11 = select i1 %10, i1 %9, i1 false
%12 = zext i1 %11 to i32
%13 = add nsw i32 %7, %12
%14 = icmp eq i8 %5, 10
br i1 %14, label %15, label %17
15: ; preds = %4
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %17
17: ; preds = %15, %4
%18 = phi i32 [ 0, %15 ], [ %13, %4 ]
%19 = tail call signext i8 (...) @getchar()
%20 = load i8, i8* @EOF
%21 = icmp eq i8 %19, %20
br i1 %21, label %22, label %4
22: ; preds = %17, %0
ret i32 0
}