#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, i, j;
  int max = 0;
  int char_freq[128];
  for (i = 0; i < 128; i++)
    char_freq[i] = 0;
  while ((c = getchar()) != EOF) {
    if (c < 128) {
      char_freq[c]++;
    }
  }
  printf("Histogram of character frequencies:\n");
  for (i = 0; i < 128; i++) {
    if (char_freq[i] > 0) {
      printf("ASCII[%d]: ", i);
      for (j = 0; j < char_freq[i]; j++) {
        putchar('.');
      }
      putchar('\n');
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x80,-0xc(%rbp)
jge    117a <main+0x4a>
movslq -0xc(%rbp),%rax
movl   $0x0,-0x220(%rbp,%rax,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1150 <main+0x20>
jmp    117f <main+0x4f>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e58(%rip),%rcx
cmp    (%rcx),%eax
je     11bf <main+0x8f>
cmpl   $0x80,-0x8(%rbp)
jge    11ba <main+0x8a>
movslq -0x8(%rbp),%rax
mov    -0x220(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x220(%rbp,%rax,4)
jmp    117f <main+0x4f>
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x80,-0xc(%rbp)
jge    1254 <main+0x124>
movslq -0xc(%rbp),%rax
cmpl   $0x0,-0x220(%rbp,%rax,4)
jle    1241 <main+0x111>
mov    -0xc(%rbp),%esi
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
movslq -0xc(%rbp),%rcx
cmp    -0x220(%rbp,%rcx,4),%eax
jge    1237 <main+0x107>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    120b <main+0xdb>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1246 <main+0x116>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d4 <main+0xa4>
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %rsp,%rdi
mov    $0x200,%edx
xor    %esi,%esi
call   1060 <memset@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    0x2e70(%rip),%rbx
jmp    1187 <main+0x37>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    (%rbx),%eax
je     1198 <main+0x48>
cmp    $0x7f,%eax
jg     1180 <main+0x30>
cltq
addl   $0x1,(%rsp,%rax,4)
jmp    1180 <main+0x30>
lea    0xe6d(%rip),%rdi
call   1040 <puts@plt>
lea    0xe55(%rip),%r14
xor    %ebx,%ebx
jmp    11bd <main+0x6d>
nop
add    $0x1,%rbx
cmp    $0x80,%rbx
je     11eb <main+0x9b>
mov    (%rsp,%rbx,4),%ebp
test   %ebp,%ebp
jle    11b0 <main+0x60>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2e,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11d0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11b0 <main+0x60>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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