#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*/ gets(char *);
scalar_t__ isalpha(char);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main(int argc, char *argv[]) {
  char string[100];
  int i, found = 0;
  printf("Type a string : ");
  gets(string);
  for (i = 0; i < strlen(string); i++)
    if (isalpha(string[i]))
      found++;
  printf("Number of characters: %d\n", found);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x88(%rbp)
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
call   1050 <gets@plt>
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x8c(%rbp)
lea    -0x80(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x8c(%rbp),%eax
cmp    %ecx,%eax
jge    11ec <main+0xac>
movslq -0x84(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
je     11d3 <main+0x93>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    11d8 <main+0x98>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    1184 <main+0x44>
mov    -0x88(%rbp),%esi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
lea    0xeb1(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1050 <gets@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11a3 <main+0x63>
xor    %ebx,%ebx
mov    %rsp,%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
movsbl (%rsp,%rbx,1),%edi
call   1060 <isalpha@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebp
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1180 <main+0x40>
lea    0xe67(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Type a string : \00"
@.str.1 = [26 x i8] c"Number of characters: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
store i32 0, i32* %7
br label %12
12: ; preds = %28, %2
%13 = load i32, i32* %7
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = icmp slt i32 %13, %15
br i1 %16, label %17, label %31
17: ; preds = %12
%18 = load i32, i32* %7
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = call i64 @isalpha(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %17
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %27
27: ; preds = %24, %17
br label %28
28: ; preds = %27
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %12
31: ; preds = %12
%32 = load i32, i32* %8
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"Type a string : \00"
@.str.1 = [26 x i8] c"Number of characters: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @gets(i8* %4)
%7 = call i32 @strlen(i8* %4)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %2, %9
%10 = phi i64 [ %18, %9 ], [ 0, %2 ]
%11 = phi i32 [ %17, %9 ], [ 0, %2 ]
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %10
%13 = load i8, i8* %12
%14 = call i64 @isalpha(i8 signext %13)
%15 = icmp ne i64 %14, 0
%16 = zext i1 %15 to i32
%17 = add nuw nsw i32 %11, %16
%18 = add nuw nsw i64 %10, 1
%19 = call i32 @strlen(i8* %4)
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %18, %20
br i1 %21, label %9, label %22
22: ; preds = %9, %2
%23 = phi i32 [ 0, %2 ], [ %17, %9 ]
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %23)
ret i32 0
}