#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int i, c, w;
  char a[1000];
  int testCase;
  scanf("%d ", &testCase);
  int counter;
  for (counter = 1; counter <= testCase; counter++) {
    while (gets(a)) {
      c = 0;
      w = 1;
      for (i = 0; a[i]; i++) {
        if ((a[i] >= 'a' && a[i] <= 'z')) {
          if (w)
            c++;
          w = 0;
        } else
          w = 1;
      }
      printf("%d\n", c);
    }
    return 0;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x404(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0x408(%rbp)
mov    -0x408(%rbp),%eax
cmp    -0x404(%rbp),%eax
jg     1231 <main+0x101>
jmp    1176 <main+0x46>
lea    -0x400(%rbp),%rdi
call   1040 <gets@plt>
cmp    $0x0,%rax
je     122a <main+0xfa>
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
cmpb   $0x0,-0x400(%rbp,%rax,1)
je     1216 <main+0xe6>
movslq -0x8(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%eax
ff
cmp    $0x61,%eax
jl     11fc <main+0xcc>
movslq -0x8(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%eax
ff
cmp    $0x7a,%eax
jg     11fc <main+0xcc>
cmpl   $0x0,-0x10(%rbp)
je     11f0 <main+0xc0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    1203 <main+0xd3>
movl   $0x1,-0x10(%rbp)
jmp    1208 <main+0xd8>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a1 <main+0x71>
mov    -0xc(%rbp),%esi
lea    0xde4(%rip),%rdi
call   1030 <printf@plt>
jmp    1176 <main+0x46>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x3f8,%rsp
lea    0xebc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11ce <main+0x9e>
lea    0x10(%rsp),%rdi
call   1040 <gets@plt>
test   %rax,%rax
je     11ce <main+0x9e>
lea    0x11(%rsp),%r15
lea    0xe94(%rip),%r14
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
jmp    1195 <main+0x65>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <gets@plt>
test   %rax,%rax
je     11ce <main+0x9e>
mov    0x10(%rsp),%al
mov    $0x0,%esi
test   %al,%al
je     1180 <main+0x50>
xor    %esi,%esi
mov    $0x1,%edx
mov    %r15,%rcx
nopl   0x0(%rax)
add    $0x9f,%al
xor    %edi,%edi
cmp    $0x1a,%al
setae  %dil
cmovae %ebp,%edx
add    %edx,%esi
movzbl (%rcx),%eax
add    $0x1,%rcx
mov    %edi,%edx
test   %al,%al
jne    11b0 <main+0x80>
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x3f8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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