#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
void main() {
  int i = 0, count = 0;
  char str[100];
  printf("Enter a string\n");
  scanf("%[^\n]s", str);
  for (i = 0; str[i] != '\0'; i++) {
    if (str[i] >= 65 && str[i] <= 90) {
      if (str[i + 1] >= 97 && str[i + 1] <= 122) {
        count++;
      }
    }
  }
  printf("The number of words starting with capital are \"%d\"", count);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xec1(%rip),%rdi
call   1040 <scanf@plt>
movl   $0x0,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11de <main+0xbe>
movslq -0x4(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x41,%eax
jl     11cb <main+0xab>
movslq -0x4(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x5a,%eax
jg     11cb <main+0xab>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x61,%eax
jl     11c6 <main+0xa6>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x7a,%eax
jg     11c6 <main+0xa6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11cb <main+0xab>
jmp    11d0 <main+0xb0>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    115b <main+0x3b>
mov    -0x8(%rbp),%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x68,%rsp
lea    0xeff(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb9(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%al
test   %al,%al
je     1187 <main+0x57>
lea    0x1(%rsp),%rcx
xor    %esi,%esi
nopl   (%rax)
add    $0xbf,%al
cmp    $0x1a,%al
setb   %r8b
movzbl (%rcx),%eax
lea    -0x61(%rax),%edi
cmp    $0x1a,%dil
setb   %dl
and    %r8b,%dl
movzbl %dl,%edx
add    %edx,%esi
add    $0x1,%rcx
test   %al,%al
jne    1160 <main+0x30>
jmp    1189 <main+0x59>
xor    %esi,%esi
lea    0xe77(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x68,%rsp
ret

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

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%[^\0A]s\00"
@.str.2 = [51 x i8] c"The number of words starting with capital are \22%d\22\00"
@str = [15 x i8] c"Enter a string\00"
define void @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 0
br i1 %6, label %22, label %7
7: ; preds = %0, %7
%8 = phi i64 [ %13, %7 ], [ 0, %0 ]
%9 = phi i8 [ %15, %7 ], [ %5, %0 ]
%10 = phi i32 [ %20, %7 ], [ 0, %0 ]
%11 = add i8 %9, -65
%12 = icmp ult i8 %11, 26
%13 = add nuw i64 %8, 1
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = add i8 %15, -97
%17 = icmp ult i8 %16, 26
%18 = select i1 %12, i1 %17, i1 false
%19 = zext i1 %18 to i32
%20 = add nuw nsw i32 %10, %19
%21 = icmp eq i8 %15, 0
br i1 %21, label %22, label %7
22: ; preds = %7, %0
%23 = phi i32 [ 0, %0 ], [ %20, %7 ]
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i32 %23)
ret void
}