#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 *, ...);
main() {
  int i, c;
  int char_hist[26];
  for (i = 0; i < 26; ++i)
    char_hist[i] = 0;
  while ((c = getchar()) != EOF) {
    if (c >= 'a' && c <= 'z')
      ++char_hist[c - 'a'];
    if (c >= 'A' && c <= 'Z')
      ++char_hist[c - 'A'];
  }
  printf("\n\tCharacter Frequency\n");
  for (i = 0; i < 26; ++i) {
    if (char_hist[i])
      printf("\t   %c  %8d\n", 'a' + i, char_hist[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x1a,-0x8(%rbp)
jge    115d <main+0x3d>
movslq -0x8(%rbp),%rax
movl   $0x0,-0x80(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1139 <main+0x19>
jmp    1162 <main+0x42>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e75(%rip),%rcx
cmp    (%rcx),%eax
je     11ce <main+0xae>
cmpl   $0x61,-0xc(%rbp)
jl     11a2 <main+0x82>
cmpl   $0x7a,-0xc(%rbp)
jg     11a2 <main+0x82>
mov    -0xc(%rbp),%eax
sub    $0x61,%eax
cltq
mov    -0x80(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x80(%rbp,%rax,4)
cmpl   $0x41,-0xc(%rbp)
jl     11c9 <main+0xa9>
cmpl   $0x5a,-0xc(%rbp)
jg     11c9 <main+0xa9>
mov    -0xc(%rbp),%eax
sub    $0x41,%eax
cltq
mov    -0x80(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x80(%rbp,%rax,4)
jmp    1162 <main+0x42>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x1a,-0x8(%rbp)
jge    122b <main+0x10b>
movslq -0x8(%rbp),%rax
cmpl   $0x0,-0x80(%rbp,%rax,4)
je     1218 <main+0xf8>
mov    -0x8(%rbp),%esi
add    $0x61,%esi
movslq -0x8(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%edx
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121d <main+0xfd>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e3 <main+0xc3>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x60(%rsp)
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e7a(%rip),%rbx
jmp    117d <main+0x4d>
mov    %ecx,%eax
addl   $0x1,(%rsp,%rax,4)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    (%rbx),%eax
je     1195 <main+0x65>
lea    -0x61(%rax),%ecx
cmp    $0x1a,%ecx
jb     1170 <main+0x40>
add    $0xffffffbf,%eax
mov    %eax,%ecx
cmp    $0x19,%eax
jbe    1170 <main+0x40>
jmp    1176 <main+0x46>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
lea    0xe58(%rip),%r14
xor    %ebx,%ebx
jmp    11ba <main+0x8a>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    $0x1a,%rbx
je     11d0 <main+0xa0>
mov    (%rsp,%rbx,4),%edx
test   %edx,%edx
je     11b0 <main+0x80>
lea    0x61(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11b0 <main+0x80>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@EOF = global i32 0
@.str.1 = [13 x i8] c"\09 %c %8d\0A\00"
@str = [22 x i8] c"\0A\09Character Frequency\00"
define i32 @main() {
%1 = alloca [26 x i32]
%2 = bitcast [26 x i32]* %1 to i8*
%3 = tail call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %23, label %6
6: ; preds = %0, %19
%7 = phi i32 [ %20, %19 ], [ %3, %0 ]
%8 = add i32 %7, -97
%9 = icmp ult i32 %8, 26
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = add i32 %7, -65
%12 = icmp ult i32 %11, 26
br i1 %12, label %13, label %19
13: ; preds = %10, %6
%14 = phi i32 [ %8, %6 ], [ %11, %10 ]
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
store i32 %18, i32* %16
br label %19
19: ; preds = %13, %10
%20 = tail call i32 (...) @getchar()
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %6
23: ; preds = %19, %0
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %25
25: ; preds = %23, %34
%26 = phi i64 [ 0, %23 ], [ %35, %34 ]
%27 = getelementptr inbounds [26 x i32], [26 x i32]* %1, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %25
%31 = trunc i64 %26 to i32
%32 = add i32 %31, 97
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %32, i32 %28)
br label %34
34: ; preds = %25, %30
%35 = add nuw nsw i64 %26, 1
%36 = icmp eq i64 %35, 26
br i1 %36, label %37, label %25
37: ; preds = %34
ret i32 0
}