#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__ EOF;
scalar_t__ isupper(char);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, char *);
int main() {
  char ar[2000];
  int i, j, k, n, m, count;
  while (scanf("%s", ar) != EOF) {
    count = 0;
    for (i = 0; ar[i] != '\0'; i++) {
      if (isupper(ar[i])) {
        count++;
      }
    }
    printf("%d\n", count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x800,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x7e0(%rbp),%rsi
lea    0xeb0(%rip),%rdi
call   1050 <scanf@plt>
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%rax
je     11ee <main+0xbe>
movl   $0x0,-0x7f8(%rbp)
movl   $0x0,-0x7e4(%rbp)
movslq -0x7e4(%rbp),%rax
movsbl -0x7e0(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     11d7 <main+0xa7>
movslq -0x7e4(%rbp),%rax
movsbl -0x7e0(%rbp,%rax,1),%edi
ff
call   1040 <isupper@plt>
cmp    $0x0,%rax
je     11be <main+0x8e>
mov    -0x7f8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7f8(%rbp)
jmp    11c3 <main+0x93>
mov    -0x7e4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7e4(%rbp)
jmp    1179 <main+0x49>
mov    -0x7f8(%rbp),%esi
lea    0xe1f(%rip),%rdi
call   1030 <printf@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7d8,%rsp
lea    0xeb8(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    0x2e91(%rip),%r12
cmp    (%r12),%rax
jne    1171 <main+0x41>
xor    %eax,%eax
add    $0x7d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe8b(%rip),%r14
lea    0xe81(%rip),%r15
mov    %rsp,%rbx
jmp    11ab <main+0x7b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmp    (%r12),%rax
je     115d <main+0x2d>
mov    (%rsp),%al
xor    %ebp,%ebp
test   %al,%al
je     1190 <main+0x60>
lea    0x1(%rsp),%r13
nopl   0x0(%rax)
movsbl %al,%edi
call   1040 <isupper@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
movzbl 0x0(%r13),%eax
add    $0x1,%r13
test   %al,%al
jne    11c0 <main+0x90>
jmp    1190 <main+0x60>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2000 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
br label %9
9: ; preds = %36, %0
%10 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 0
%11 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i64, i64* @EOF
%13 = icmp ne i64 %11, %12
br i1 %13, label %14, label %39
14: ; preds = %9
store i32 0, i32* %8
store i32 0, i32* %3
br label %15
15: ; preds = %33, %14
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %36
22: ; preds = %15
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [2000 x i8], [2000 x i8]* %2, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = call i64 @isupper(i8 signext %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %22
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %32
32: ; preds = %29, %22
br label %33
33: ; preds = %32
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %15
36: ; preds = %15
%37 = load i32, i32* %8
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %37)
br label %9
39: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [2000 x i8]
%2 = getelementptr inbounds [2000 x i8], [2000 x i8]* %1, i64 0, i64 0
%3 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = load i64, i64* @EOF
%5 = icmp eq i64 %3, %4
br i1 %5, label %27, label %6
6: ; preds = %0, %21
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 0
br i1 %8, label %21, label %9
9: ; preds = %6, %9
%10 = phi i64 [ %17, %9 ], [ 0, %6 ]
%11 = phi i8 [ %19, %9 ], [ %7, %6 ]
%12 = phi i32 [ %16, %9 ], [ 0, %6 ]
%13 = call i64 @isupper(i8 signext %11)
%14 = icmp ne i64 %13, 0
%15 = zext i1 %14 to i32
%16 = add nuw nsw i32 %12, %15
%17 = add nuw i64 %10, 1
%18 = getelementptr inbounds [2000 x i8], [2000 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %9
21: ; preds = %9, %6
%22 = phi i32 [ 0, %6 ], [ %16, %9 ]
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%25 = load i64, i64* @EOF
%26 = icmp eq i64 %24, %25
br i1 %26, label %27, label %6
27: ; preds = %21, %0
ret i32 0
}