#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 */
char EOF;
char getchar();
scalar_t__ isalpha(char);
scalar_t__ islower(char);
int /*<<< orphan*/ printf(char *, ...);
char toupper(char);
main() {
  unsigned long int num_letters = 0;
  unsigned long int letter[26];
  int i;
  char ch;
  for (i = 0; i < 26; i++)
    letter[i] = 0;
  while ((ch = getchar()) != EOF)
    if (isalpha(ch)) {
      num_letters++;
      if (islower(ch))
        ch = toupper(ch);
      letter[ch - 'A']++;
    }
  printf("\nTotal number of letters: %ld\n", num_letters);
  printf("\nFrequency:\n");
  for (i = 0; i < 26; i++)
    printf("%c: %6.3f%%\n", 'A' + i,
           100.0 * (float)letter[i] / (float)num_letters);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0xe4(%rbp)
cmpl   $0x1a,-0xe4(%rbp)
jge    11a8 <main+0x58>
movslq -0xe4(%rbp),%rax
movq   $0x0,-0xe0(%rbp,%rax,8)
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1174 <main+0x24>
jmp    11ad <main+0x5d>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %al,-0xe5(%rbp)
movsbl %al,%eax
mov    0x2e24(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     123e <main+0xee>
movsbl -0xe5(%rbp),%edi
call   1070 <isalpha@plt>
cmp    $0x0,%rax
je     1239 <main+0xe9>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
movsbl -0xe5(%rbp),%edi
call   1030 <islower@plt>
cmp    $0x0,%rax
je     1219 <main+0xc9>
movsbl -0xe5(%rbp),%edi
call   1040 <toupper@plt>
mov    %al,-0xe5(%rbp)
movsbl -0xe5(%rbp),%eax
sub    $0x41,%eax
cltq
mov    -0xe0(%rbp,%rax,8),%rcx
ff
add    $0x1,%rcx
mov    %rcx,-0xe0(%rbp,%rax,8)
ff
jmp    11ad <main+0x5d>
mov    -0x10(%rbp),%rsi
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0xe4(%rbp)
cmpl   $0x1a,-0xe4(%rbp)
jge    137d <main+0x22d>
movslq -0xe4(%rbp),%rax
mov    %eax,%ecx
add    $0x41,%ecx
mov    %ecx,-0xf4(%rbp)
mov    -0xe0(%rbp,%rax,8),%rax
ff
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0xf0(%rbp)
ff
test   %rax,%rax
movss  %xmm0,-0xec(%rbp)
ff
js     12d4 <main+0x184>
movss  -0xf0(%rbp),%xmm0
ff
movss  %xmm0,-0xec(%rbp)
ff
movss  -0xec(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
movsd  0xd18(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x108(%rbp)
ff
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
shr    %rdx
mov    %eax,%ecx
and    $0x1,%ecx
or     %rdx,%rcx
cvtsi2ss %rcx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %rax,%xmm1
movss  %xmm1,-0xfc(%rbp)
ff
test   %rax,%rax
movss  %xmm0,-0xf8(%rbp)
ff
js     133d <main+0x1ed>
movss  -0xfc(%rbp),%xmm0
ff
movss  %xmm0,-0xf8(%rbp)
ff
mov    -0xf4(%rbp),%esi
movsd  -0x108(%rbp),%xmm0
ff
movss  -0xf8(%rbp),%xmm1
ff
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
lea    0xcd2(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1268 <main+0x118>
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xe8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
xor    %r14d,%r14d
xor    %eax,%eax
call   1070 <getchar@plt>
mov    0x2e14(%rip),%r15
cmp    (%r15),%al
jne    1207 <main+0xa7>
lea    0xe28(%rip),%rdi
xor    %ebp,%ebp
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe41(%rip),%rdi
call   1050 <puts@plt>
test   %r14,%r14
js     1255 <main+0xf5>
xorps  %xmm0,%xmm0
cvtsi2ss %r14,%xmm0
jmp    126e <main+0x10e>
mov    %eax,%ebx
xor    %r14d,%r14d
jmp    122f <main+0xcf>
xchg   %ax,%ax
add    $0x1,%r14
movsbq %bl,%rax
addq   $0x1,-0x1f8(%rsp,%rax,8)
ff 01
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %eax,%ebx
cmp    (%r15),%al
je     11d9 <main+0x79>
movsbl %bl,%ebp
mov    %ebp,%edi
call   1080 <isalpha@plt>
test   %rax,%rax
je     1221 <main+0xc1>
mov    %ebp,%edi
call   1030 <islower@plt>
test   %rax,%rax
je     1210 <main+0xb0>
mov    %ebp,%edi
call   1040 <toupper@plt>
mov    %eax,%ebx
jmp    1210 <main+0xb0>
mov    %r14,%rax
shr    %rax
and    $0x1,%r14d
or     %rax,%r14
xorps  %xmm0,%xmm0
cvtsi2ss %r14,%xmm0
addss  %xmm0,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xda8(%rip),%rbx
jmp    12c1 <main+0x161>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xd5c(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
lea    0x41(%rbp),%esi
mov    %rbx,%rdi
mov    $0x1,%al
call   1060 <printf@plt>
add    $0x1,%rbp
cmp    $0x1a,%rbp
je     12e5 <main+0x185>
mov    0x10(%rsp,%rbp,8),%rax
test   %rax,%rax
jns    1290 <main+0x130>
mov    %rax,%rcx
shr    %rcx
and    $0x1,%eax
or     %rcx,%rax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
addss  %xmm0,%xmm0
jmp    1298 <main+0x138>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i8 0
@.str = [31 x i8] c"\0ATotal number of letters: %ld\0A\00"
@.str.1 = [13 x i8] c"\0AFrequency:\0A\00"
@.str.2 = [13 x i8] c"%c: %6.3f%%\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [26 x i64]
%4 = alloca i32
%5 = alloca i8
store i32 0, i32* %1
store i64 0, i64* %2
store i32 0, i32* %4
br label %6
6: ; preds = %13, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 26
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [26 x i64], [26 x i64]* %3, i64 0, i64 %11
store i64 0, i64* %12
br label %13
13: ; preds = %9
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 1
store i32 %15, i32* %4
br label %6
16: ; preds = %6
br label %17
17: ; preds = %44, %16
%18 = call signext i8 (...) @getchar()
store i8 %18, i8* %5
%19 = sext i8 %18 to i32
%20 = load i8, i8* @EOF
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %19, %21
br i1 %22, label %23, label %45
23: ; preds = %17
%24 = load i8, i8* %5
%25 = call i64 @isalpha(i8 signext %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %44
27: ; preds = %23
%28 = load i64, i64* %2
%29 = add i64 %28, 1
store i64 %29, i64* %2
%30 = load i8, i8* %5
%31 = call i64 @islower(i8 signext %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = load i8, i8* %5
%35 = call signext i8 @toupper(i8 signext %34)
store i8 %35, i8* %5
br label %36
36: ; preds = %33, %27
%37 = load i8, i8* %5
%38 = sext i8 %37 to i32
%39 = sub nsw i32 %38, 65
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [26 x i64], [26 x i64]* %3, i64 0, i64 %40
%42 = load i64, i64* %41
%43 = add i64 %42, 1
store i64 %43, i64* %41
br label %44
44: ; preds = %36, %23
br label %17
45: ; preds = %17
%46 = load i64, i64* %2
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i64 %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %49
49: ; preds = %67, %45
%50 = load i32, i32* %4
%51 = icmp slt i32 %50, 26
br i1 %51, label %52, label %70
52: ; preds = %49
%53 = load i32, i32* %4
%54 = add nsw i32 65, %53
%55 = load i32, i32* %4
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [26 x i64], [26 x i64]* %3, i64 0, i64 %56
%58 = load i64, i64* %57
%59 = uitofp i64 %58 to float
%60 = fpext float %59 to double
%61 = fmul double 1.000000e+02, %60
%62 = load i64, i64* %2
%63 = uitofp i64 %62 to float
%64 = fpext float %63 to double
%65 = fdiv double %61, %64
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %54, double %65)
br label %67
67: ; preds = %52
%68 = load i32, i32* %4
%69 = add nsw i32 %68, 1
store i32 %69, i32* %4
br label %49
70: ; preds = %49
%71 = load i32, i32* %1
ret i32 %71
}

LLVM IR (-O2):
@EOF = global i8 0
@.str = [31 x i8] c"\0ATotal number of letters: %ld\0A\00"
@.str.2 = [13 x i8] c"%c: %6.3f%%\0A\00"
@str = [12 x i8] c"\0AFrequency:\00"
define i32 @main() {
%1 = alloca [26 x i64]
%2 = bitcast [26 x i64]* %1 to i8*
%3 = tail call signext i8 (...) @getchar()
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %29, label %6
6: ; preds = %0, %24
%7 = phi i8 [ %26, %24 ], [ %3, %0 ]
%8 = phi i64 [ %25, %24 ], [ 0, %0 ]
%9 = tail call i64 @isalpha(i8 signext %7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %24, label %11
11: ; preds = %6
%12 = add i64 %8, 1
%13 = tail call i64 @islower(i8 signext %7)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = tail call signext i8 @toupper(i8 signext %7)
br label %17
17: ; preds = %15, %11
%18 = phi i8 [ %16, %15 ], [ %7, %11 ]
%19 = sext i8 %18 to i64
%20 = add nsw i64 %19, -65
%21 = getelementptr inbounds [26 x i64], [26 x i64]* %1, i64 0, i64 %20
%22 = load i64, i64* %21
%23 = add i64 %22, 1
store i64 %23, i64* %21
br label %24
24: ; preds = %17, %6
%25 = phi i64 [ %12, %17 ], [ %8, %6 ]
%26 = tail call signext i8 (...) @getchar()
%27 = load i8, i8* @EOF
%28 = icmp eq i8 %26, %27
br i1 %28, label %29, label %6
29: ; preds = %24, %0
%30 = phi i64 [ 0, %0 ], [ %25, %24 ]
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i64 %30)
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%33 = uitofp i64 %30 to float
%34 = fpext float %33 to double
br label %35
35: ; preds = %29, %35
%36 = phi i64 [ 0, %29 ], [ %46, %35 ]
%37 = getelementptr inbounds [26 x i64], [26 x i64]* %1, i64 0, i64 %36
%38 = load i64, i64* %37
%39 = uitofp i64 %38 to float
%40 = fpext float %39 to double
%41 = fmul double %40, 1.000000e+02
%42 = fdiv double %41, %34
%43 = trunc i64 %36 to i32
%44 = add i32 %43, 65
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %44, double %42)
%46 = add nuw nsw i64 %36, 1
%47 = icmp eq i64 %46, 26
br i1 %47, label %48, label %35
48: ; preds = %35
ret i32 0
}