#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);
int main() {
  int c;
  int freq[127];
  int i, j;
  for (i = 0; i < 127; i++) {
    freq[i] = 0;
  }
  while ((c = getchar()) != EOF) {
    ++freq[c];
  }
  printf("Char\tCount\n");
  for (i = 0; i < 127; i++) {
    if (freq[i] > 0) {
      printf("%4c\t", i);
      for (j = 0; j < freq[i]; j++)
        putchar('=');
      printf("[%d]\n", freq[i]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x214(%rbp)
cmpl   $0x7f,-0x214(%rbp)
jge    117f <main+0x4f>
movslq -0x214(%rbp),%rax
movl   $0x0,-0x210(%rbp,%rax,4)
mov    -0x214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x214(%rbp)
jmp    114c <main+0x1c>
jmp    1184 <main+0x54>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e53(%rip),%rcx
cmp    (%rcx),%eax
je     11b7 <main+0x87>
movslq -0x8(%rbp),%rax
mov    -0x210(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x210(%rbp,%rax,4)
jmp    1184 <main+0x54>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x214(%rbp)
cmpl   $0x7f,-0x214(%rbp)
jge    127c <main+0x14c>
movslq -0x214(%rbp),%rax
cmpl   $0x0,-0x210(%rbp,%rax,4)
jle    1263 <main+0x133>
mov    -0x214(%rbp),%esi
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x218(%rbp)
mov    -0x218(%rbp),%eax
movslq -0x214(%rbp),%rcx
cmp    -0x210(%rbp,%rcx,4),%eax
jge    1247 <main+0x117>
mov    $0x3d,%edi
call   1030 <putchar@plt>
mov    -0x218(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x218(%rbp)
jmp    120f <main+0xdf>
movslq -0x214(%rbp),%rax
mov    -0x210(%rbp,%rax,4),%esi
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1268 <main+0x138>
mov    -0x214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x214(%rbp)
jmp    11cf <main+0x9f>
xor    %eax,%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    %rsp,%rdi
mov    $0x1fc,%edx
xor    %esi,%esi
call   1060 <memset@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    0x2e6c(%rip),%rbx
cmp    (%rbx),%eax
je     1191 <main+0x41>
cltq
addl   $0x1,(%rsp,%rax,4)
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    (%rbx),%eax
jne    1180 <main+0x30>
lea    0xe73(%rip),%rdi
call   1040 <puts@plt>
lea    0xe5c(%rip),%r14
lea    0xe5a(%rip),%r15
xor    %ebx,%ebx
jmp    11ba <main+0x6a>
nop
add    $0x1,%rbx
cmp    $0x7f,%rbx
je     11fe <main+0xae>
mov    (%rsp,%rbx,4),%r12d
test   %r12d,%r12d
jle    11b0 <main+0x60>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x3d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11e0 <main+0x90>
mov    %r15,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11b0 <main+0x60>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [12 x i8] c"Char\09Count\0A\00"
@.str.1 = [5 x i8] c"%4c\09\00"
@.str.2 = [6 x i8] c"[%d]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [127 x i32]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %6
6: ; preds = %13, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 127
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [127 x i32], [127 x i32]* %3, i64 0, i64 %11
store i32 0, i32* %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 = %21, %16
%18 = call i32 (...) @getchar()
store i32 %18, i32* %2
%19 = load i32, i32* @EOF
%20 = icmp ne i32 %18, %19
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [127 x i32], [127 x i32]* %3, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = add nsw i32 %25, 1
store i32 %26, i32* %24
br label %17
27: ; preds = %17
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %29
29: ; preds = %60, %27
%30 = load i32, i32* %4
%31 = icmp slt i32 %30, 127
br i1 %31, label %32, label %63
32: ; preds = %29
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [127 x i32], [127 x i32]* %3, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %59
38: ; preds = %32
%39 = load i32, i32* %4
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %39)
store i32 0, i32* %5
br label %41
41: ; preds = %50, %38
%42 = load i32, i32* %5
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [127 x i32], [127 x i32]* %3, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = icmp slt i32 %42, %46
br i1 %47, label %48, label %53
48: ; preds = %41
%49 = call i32 @putchar(i8 signext 61)
br label %50
50: ; preds = %48
%51 = load i32, i32* %5
%52 = add nsw i32 %51, 1
store i32 %52, i32* %5
br label %41
53: ; preds = %41
%54 = load i32, i32* %4
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [127 x i32], [127 x i32]* %3, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %57)
br label %59
59: ; preds = %53, %32
br label %60
60: ; preds = %59
%61 = load i32, i32* %4
%62 = add nsw i32 %61, 1
store i32 %62, i32* %4
br label %29
63: ; preds = %29
ret i32 0
}

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