#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 */
scalar_t__ gets(char *);
int /*<<< orphan*/ printf(char *, int);
int strlen(char *);
int main() {
  char s[200005];
  int word, i, count;
  while (gets(s)) {
    count = 0;
    word = 0;
    for (i = 0; i <= strlen(s); i++) {
      if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z')) {
        word = 1;
      } else if (word == 1) {
        count++;
        word = 0;
      }
    }
    printf("%d\n", count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30d60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30d50(%rbp),%rdi
call   1050 <gets@plt>
cmp    $0x0,%rax
je     1268 <main+0x138>
movl   $0x0,-0x30d5c(%rbp)
movl   $0x0,-0x30d54(%rbp)
movl   $0x0,-0x30d58(%rbp)
mov    -0x30d58(%rbp),%eax
mov    %eax,-0x30d60(%rbp)
lea    -0x30d50(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30d60(%rbp),%eax
cmp    %ecx,%eax
jg     1251 <main+0x121>
movslq -0x30d58(%rbp),%rax
movsbl -0x30d50(%rbp,%rax,1),%eax
ff
cmp    $0x61,%eax
jl     11ce <main+0x9e>
movslq -0x30d58(%rbp),%rax
movsbl -0x30d50(%rbp,%rax,1),%eax
ff
cmp    $0x7a,%eax
jle    11fe <main+0xce>
movslq -0x30d58(%rbp),%rax
movsbl -0x30d50(%rbp,%rax,1),%eax
ff
cmp    $0x41,%eax
jl     120d <main+0xdd>
movslq -0x30d58(%rbp),%rax
movsbl -0x30d50(%rbp,%rax,1),%eax
ff
cmp    $0x5a,%eax
jg     120d <main+0xdd>
movl   $0x1,-0x30d54(%rbp)
jmp    1238 <main+0x108>
cmpl   $0x1,-0x30d54(%rbp)
jne    1233 <main+0x103>
mov    -0x30d5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30d5c(%rbp)
movl   $0x0,-0x30d54(%rbp)
jmp    1238 <main+0x108>
jmp    123d <main+0x10d>
mov    -0x30d58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30d58(%rbp)
jmp    1176 <main+0x46>
mov    -0x30d5c(%rbp),%esi
lea    0xda2(%rip),%rdi
call   1040 <printf@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0x30d60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30d48,%rsp
mov    %rsp,%rdi
call   1050 <gets@plt>
test   %rax,%rax
je     11e3 <main+0xb3>
mov    %rsp,%r12
lea    0xea4(%rip),%r14
xor    %r15d,%r15d
jmp    1188 <main+0x58>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r13d,%esi
call   1040 <printf@plt>
mov    %r12,%rdi
call   1050 <gets@plt>
test   %rax,%rax
je     11e3 <main+0xb3>
mov    %r12,%rdi
call   1030 <strlen@plt>
mov    $0x0,%r13d
test   %eax,%eax
js     1170 <main+0x40>
xor    %r13d,%r13d
mov    $0xffffffffffffffff,%rbx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movzbl 0x1(%rsp,%rbx,1),%ecx
and    $0xdf,%cl
add    $0xbf,%cl
xor    %ebp,%ebp
cmp    $0x1a,%cl
setb   %bpl
cmovb  %r15d,%eax
add    %eax,%r13d
mov    %r12,%rdi
call   1030 <strlen@plt>
movslq %eax,%rcx
add    $0x1,%rbx
mov    %ebp,%eax
cmp    %rcx,%rbx
jl     11b0 <main+0x80>
jmp    1170 <main+0x40>
xor    %eax,%eax
add    $0x30d48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [200005 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %56, %0
%7 = getelementptr inbounds [200005 x i8], [200005 x i8]* %2, i64 0, i64 0
%8 = call i64 @gets(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %59
10: ; preds = %6
store i32 0, i32* %5
store i32 0, i32* %3
store i32 0, i32* %4
br label %11
11: ; preds = %53, %10
%12 = load i32, i32* %4
%13 = getelementptr inbounds [200005 x i8], [200005 x i8]* %2, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = icmp sle i32 %12, %14
br i1 %15, label %16, label %56
16: ; preds = %11
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [200005 x i8], [200005 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp sge i32 %21, 97
br i1 %22, label %23, label %30
23: ; preds = %16
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [200005 x i8], [200005 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp sle i32 %28, 122
br i1 %29, label %44, label %30
30: ; preds = %23, %16
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [200005 x i8], [200005 x i8]* %2, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp sge i32 %35, 65
br i1 %36, label %37, label %45
37: ; preds = %30
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [200005 x i8], [200005 x i8]* %2, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp sle i32 %42, 90
br i1 %43, label %44, label %45
44: ; preds = %37, %23
store i32 1, i32* %3
br label %52
45: ; preds = %37, %30
%46 = load i32, i32* %3
%47 = icmp eq i32 %46, 1
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
store i32 %50, i32* %5
store i32 0, i32* %3
br label %51
51: ; preds = %48, %45
br label %52
52: ; preds = %51, %44
br label %53
53: ; preds = %52
%54 = load i32, i32* %4
%55 = add nsw i32 %54, 1
store i32 %55, i32* %4
br label %11
56: ; preds = %11
%57 = load i32, i32* %5
%58 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %57)
br label %6
59: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [200005 x i8]
%2 = getelementptr inbounds [200005 x i8], [200005 x i8]* %1, i64 0, i64 0
%3 = call i64 @gets(i8* %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %29, label %5
5: ; preds = %0, %24
%6 = call i32 @strlen(i8* %2)
%7 = icmp slt i32 %6, 0
br i1 %7, label %24, label %8
8: ; preds = %5, %8
%9 = phi i64 [ %20, %8 ], [ 0, %5 ]
%10 = phi i32 [ %19, %8 ], [ 0, %5 ]
%11 = phi i32 [ %17, %8 ], [ 0, %5 ]
%12 = getelementptr inbounds [200005 x i8], [200005 x i8]* %1, i64 0, i64 %9
%13 = load i8, i8* %12
%14 = and i8 %13, -33
%15 = add i8 %14, -65
%16 = icmp ult i8 %15, 26
%17 = zext i1 %16 to i32
%18 = select i1 %16, i32 0, i32 %11
%19 = add nuw nsw i32 %10, %18
%20 = add nuw nsw i64 %9, 1
%21 = call i32 @strlen(i8* %2)
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %9, %22
br i1 %23, label %8, label %24
24: ; preds = %8, %5
%25 = phi i32 [ 0, %5 ], [ %19, %8 ]
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = call i64 @gets(i8* %2)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %5
29: ; preds = %24, %0
ret i32 0
}