#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 EOF;
int getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
main() {
  int c, i, j;
  int letterFrequencies['z'];
  for (i = 'A'; i <= 'z'; ++i) {
    letterFrequencies[i] = 0;
  }
  printf("Enter a string of words to compute the letter frequency. Hit CTRL+D "
         "to compute\n");
  while ((c = getchar()) != EOF) {
    if (c <= 'z' && c >= 'A') {
      ++letterFrequencies[c];
    }
  }
  printf("\n\nFrequency Histogram of inputted letters\n");
  printf("====================================================================="
         "===========\n");
  for (i = 'A'; i <= 'z'; ++i) {
    int frequency = letterFrequencies[i];
    if (frequency > 0) {
      putchar(i);
      printf(": ");
      for (j = 0; j < frequency; ++j) {
        putchar('#');
      }
      putchar('\n');
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x41,-0xc(%rbp)
cmpl   $0x7a,-0xc(%rbp)
jg     1170 <main+0x40>
movslq -0xc(%rbp),%rax
movl   $0x0,-0x200(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1149 <main+0x19>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e5b(%rip),%rcx
cmp    (%rcx),%eax
je     11c3 <main+0x93>
cmpl   $0x7a,-0x8(%rbp)
jg     11be <main+0x8e>
cmpl   $0x41,-0x8(%rbp)
jl     11be <main+0x8e>
movslq -0x8(%rbp),%rax
mov    -0x200(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x200(%rbp,%rax,4)
jmp    117c <main+0x4c>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
movl   $0x41,-0xc(%rbp)
cmpl   $0x7a,-0xc(%rbp)
jg     126c <main+0x13c>
movslq -0xc(%rbp),%rax
mov    -0x200(%rbp,%rax,4),%eax
mov    %eax,-0x204(%rbp)
cmpl   $0x0,-0x204(%rbp)
jle    1259 <main+0x129>
mov    -0xc(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x204(%rbp),%eax
jge    124f <main+0x11f>
mov    $0x23,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1228 <main+0xf8>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    125e <main+0x12e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e2 <main+0xb2>
mov    -0x4(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1f0,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x1d4(%rsp)
movups %xmm0,0x1c4(%rsp)
movups %xmm0,0x1b4(%rsp)
movups %xmm0,0x1a4(%rsp)
movups %xmm0,0x194(%rsp)
movups %xmm0,0x184(%rsp)
movups %xmm0,0x174(%rsp)
movups %xmm0,0x164(%rsp)
movups %xmm0,0x154(%rsp)
movups %xmm0,0x144(%rsp)
movups %xmm0,0x134(%rsp)
movups %xmm0,0x124(%rsp)
movups %xmm0,0x114(%rsp)
movups %xmm0,0x104(%rsp)
movq   $0x0,0x1e4(%rsp)
lea    0xe32(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e04(%rip),%rbx
jmp    11f7 <main+0xb7>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    (%rbx),%eax
je     120b <main+0xcb>
lea    -0x41(%rax),%ecx
cmp    $0x39,%ecx
ja     11f0 <main+0xb0>
mov    %eax,%eax
addl   $0x1,(%rsp,%rax,4)
jmp    11f0 <main+0xb0>
lea    0xe40(%rip),%rdi
call   1040 <puts@plt>
lea    0xe5e(%rip),%rdi
call   1040 <puts@plt>
mov    $0x41,%ebx
lea    0xdd1(%rip),%r14
jmp    124a <main+0x10a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x7b,%rbx
je     128b <main+0x14b>
mov    (%rsp,%rbx,4),%ebp
test   %ebp,%ebp
jle    1240 <main+0x100>
movsbl %bl,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
call   1050 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1270 <main+0x130>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1240 <main+0x100>
xor    %eax,%eax
add    $0x1f0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [80 x i8] c"Enter a string of words to compute the letter frequency. Hit CTRL+D to compute\0A\00"
@EOF = global i32 0
@.str.1 = [43 x i8] c"\0A\0AFrequency Histogram of inputted letters\0A\00"
@.str.2 = [82 x i8] c"================================================================================\0A\00"
@.str.3 = [3 x i8] c": \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [122 x i32]
%6 = alloca i32
store i32 0, i32* %1
store i32 65, i32* %3
br label %7
7: ; preds = %14, %0
%8 = load i32, i32* %3
%9 = icmp sle i32 %8, 122
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [122 x i32], [122 x i32]* %5, i64 0, i64 %12
store i32 0, i32* %13
br label %14
14: ; preds = %10
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %7
17: ; preds = %7
%18 = call i32 @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %35, %17
%20 = call i32 (...) @getchar()
store i32 %20, i32* %2
%21 = load i32, i32* @EOF
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %36
23: ; preds = %19
%24 = load i32, i32* %2
%25 = icmp sle i32 %24, 122
br i1 %25, label %26, label %35
26: ; preds = %23
%27 = load i32, i32* %2
%28 = icmp sge i32 %27, 65
br i1 %28, label %29, label %35
29: ; preds = %26
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [122 x i32], [122 x i32]* %5, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = add nsw i32 %33, 1
store i32 %34, i32* %32
br label %35
35: ; preds = %29, %26, %23
br label %19
36: ; preds = %19
%37 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%38 = call i32 @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0))
store i32 65, i32* %3
br label %39
39: ; preds = %66, %36
%40 = load i32, i32* %3
%41 = icmp sle i32 %40, 122
br i1 %41, label %42, label %69
42: ; preds = %39
%43 = load i32, i32* %3
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [122 x i32], [122 x i32]* %5, i64 0, i64 %44
%46 = load i32, i32* %45
store i32 %46, i32* %6
%47 = load i32, i32* %6
%48 = icmp sgt i32 %47, 0
br i1 %48, label %49, label %65
49: ; preds = %42
%50 = load i32, i32* %3
%51 = trunc i32 %50 to i8
%52 = call i32 @putchar(i8 signext %51)
%53 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %4
br label %54
54: ; preds = %60, %49
%55 = load i32, i32* %4
%56 = load i32, i32* %6
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %63
58: ; preds = %54
%59 = call i32 @putchar(i8 signext 35)
br label %60
60: ; preds = %58
%61 = load i32, i32* %4
%62 = add nsw i32 %61, 1
store i32 %62, i32* %4
br label %54
63: ; preds = %54
%64 = call i32 @putchar(i8 signext 10)
br label %65
65: ; preds = %63, %42
br label %66
66: ; preds = %65
%67 = load i32, i32* %3
%68 = add nsw i32 %67, 1
store i32 %68, i32* %3
br label %39
69: ; preds = %39
%70 = load i32, i32* %1
ret i32 %70
}

LLVM IR (-O2):
@EOF = global i32 0
@.str.3 = [3 x i8] c": \00"
@str = [79 x i8] c"Enter a string of words to compute the letter frequency. Hit CTRL+D to compute\00"
@str.4 = [42 x i8] c"\0A\0AFrequency Histogram of inputted letters\00"
@str.5 = [81 x i8] c"================================================================================\00"
define i32 @main() {
%1 = alloca [122 x i32]
%2 = bitcast [122 x i32]* %1 to i8*
%3 = getelementptr inbounds [122 x i32], [122 x i32]* %1, i64 0, i64 65
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (...) @getchar()
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %22, label %9
9: ; preds = %0, %18
%10 = phi i32 [ %19, %18 ], [ %6, %0 ]
%11 = add i32 %10, -65
%12 = icmp ult i32 %11, 58
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = zext i32 %10 to i64
%15 = getelementptr inbounds [122 x i32], [122 x i32]* %1, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 1
store i32 %17, i32* %15
br label %18
18: ; preds = %13, %9
%19 = tail call i32 (...) @getchar()
%20 = load i32, i32* @EOF
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %9
22: ; preds = %18, %0
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.4, i64 0, i64 0))
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @str.5, i64 0, i64 0))
br label %25
25: ; preds = %22, %41
%26 = phi i64 [ 65, %22 ], [ %42, %41 ]
%27 = getelementptr inbounds [122 x i32], [122 x i32]* %1, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %41
30: ; preds = %25
%31 = trunc i64 %26 to i8
%32 = tail call i32 @putchar(i8 signext %31)
%33 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %30, %34
%35 = phi i32 [ 0, %30 ], [ %37, %34 ]
%36 = tail call i32 @putchar(i8 signext 35)
%37 = add nuw nsw i32 %35, 1
%38 = icmp eq i32 %37, %28
br i1 %38, label %39, label %34
39: ; preds = %34
%40 = tail call i32 @putchar(i8 signext 10)
br label %41
41: ; preds = %39, %25
%42 = add nuw nsw i64 %26, 1
%43 = icmp eq i64 %42, 123
br i1 %43, label %44, label %25
44: ; preds = %41
ret i32 0
}