#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__ malloc(int);
int /*<<< orphan*/ strcpy(char *, char const *);
int countOfAlphaInString(const char *str) {
  int count = 0;
  char *p = (char *)malloc(sizeof(char));
  strcpy(p, str);
  while (*p != '\0') {
    if ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z'))
      count++;
    p++;
  }
  return count;
}


x86 assembly (clang, -O0):
<countOfAlphaInString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b8 <countOfAlphaInString+0x98>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
jl     117e <countOfAlphaInString+0x5e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7a,%eax
jle    119e <countOfAlphaInString+0x7e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x41,%eax
jl     11a7 <countOfAlphaInString+0x87>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5a,%eax
jg     11a7 <countOfAlphaInString+0x87>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    114e <countOfAlphaInString+0x2e>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<countOfAlphaInString>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    (%rbx),%cl
test   %cl,%cl
je     1169 <countOfAlphaInString+0x49>
add    $0x1,%rbx
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
and    $0xdf,%cl
add    $0xbf,%cl
cmp    $0x1a,%cl
adc    $0x0,%eax
movzbl (%rbx),%ecx
add    $0x1,%rbx
test   %cl,%cl
jne    1150 <countOfAlphaInString+0x30>
jmp    116b <countOfAlphaInString+0x4b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @countOfAlphaInString(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = call i64 @malloc(i32 1)
%6 = inttoptr i64 %5 to i8*
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = load i8*, i8** %2
%9 = call i32 @strcpy(i8* %7, i8* %8)
br label %10
10: ; preds = %38, %1
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %41
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp sge i32 %18, 97
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp sle i32 %23, 122
br i1 %24, label %35, label %25
25: ; preds = %20, %15
%26 = load i8*, i8** %4
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp sge i32 %28, 65
br i1 %29, label %30, label %38
30: ; preds = %25
%31 = load i8*, i8** %4
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp sle i32 %33, 90
br i1 %34, label %35, label %38
35: ; preds = %30, %20
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %38
38: ; preds = %35, %30, %25
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %4
br label %10
41: ; preds = %10
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
define i32 @countOfAlphaInString(i8* %0) {
%2 = tail call i64 @malloc(i32 1)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 @strcpy(i8* %3, i8* %0)
%5 = load i8, i8* %3
%6 = icmp eq i8 %5, 0
br i1 %6, label %19, label %7
7: ; preds = %1, %7
%8 = phi i8 [ %17, %7 ], [ %5, %1 ]
%9 = phi i8* [ %16, %7 ], [ %3, %1 ]
%10 = phi i32 [ %15, %7 ], [ 0, %1 ]
%11 = and i8 %8, -33
%12 = add i8 %11, -65
%13 = icmp ult i8 %12, 26
%14 = zext i1 %13 to i32
%15 = add nuw nsw i32 %10, %14
%16 = getelementptr inbounds i8, i8* %9, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %7
19: ; preds = %7, %1
%20 = phi i32 [ 0, %1 ], [ %15, %7 ]
ret i32 %20
}