#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 c, i, j;
  int freqs[255] = {0};
  c = i = j = 0;
  while ((c = getchar()) != EOF) {
    ++freqs[c];
  }
  for (i = 0; i < 255; ++i) {
    printf("%c: ", i);
    for (j = 0; j < freqs[i]; ++j) {
      printf("|");
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x3fc,%edx
call   1040 <memset@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e6d(%rip),%rcx
cmp    (%rcx),%eax
je     119d <main+0x6d>
movslq -0x8(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x410(%rbp,%rax,4)
jmp    116a <main+0x3a>
movl   $0x0,-0xc(%rbp)
cmpl   $0xff,-0xc(%rbp)
jge    1215 <main+0xe5>
mov    -0xc(%rbp),%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
movslq -0xc(%rbp),%rcx
cmp    -0x410(%rbp,%rcx,4),%eax
jge    11f9 <main+0xc9>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c9 <main+0x99>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a4 <main+0x74>
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rsp,%rdi
mov    $0x3fc,%edx
xor    %esi,%esi
call   1050 <memset@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e80(%rip),%rbx
cmp    (%rbx),%eax
je     1181 <main+0x41>
nopl   0x0(%rax)
cltq
addl   $0x1,(%rsp,%rax,4)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    (%rbx),%eax
jne    1170 <main+0x30>
lea    0xe78(%rip),%r14
xor    %ebx,%ebx
jmp    11a7 <main+0x67>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0xff,%rbx
je     11d1 <main+0x91>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp,%rbx,4),%ebp
test   %ebp,%ebp
jle    1190 <main+0x50>
nopw   0x0(%rax,%rax,1)
mov    $0x7c,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11c0 <main+0x80>
jmp    1190 <main+0x50>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [5 x i8] c"%c: \00"
@.str.1 = [2 x i8] c"|\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [255 x i32]
store i32 0, i32* %1
%6 = bitcast [255 x i32]* %5 to i8*
store i32 0, i32* %4
store i32 0, i32* %3
store i32 0, i32* %2
br label %7
7: ; preds = %11, %0
%8 = call i32 (...) @getchar()
store i32 %8, i32* %2
%9 = load i32, i32* @EOF
%10 = icmp ne i32 %8, %9
br i1 %10, label %11, label %17
11: ; preds = %7
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [255 x i32], [255 x i32]* %5, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = add nsw i32 %15, 1
store i32 %16, i32* %14
br label %7
17: ; preds = %7
store i32 0, i32* %3
br label %18
18: ; preds = %38, %17
%19 = load i32, i32* %3
%20 = icmp slt i32 %19, 255
br i1 %20, label %21, label %41
21: ; preds = %18
%22 = load i32, i32* %3
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %22)
store i32 0, i32* %4
br label %24
24: ; preds = %33, %21
%25 = load i32, i32* %4
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [255 x i32], [255 x i32]* %5, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = icmp slt i32 %25, %29
br i1 %30, label %31, label %36
31: ; preds = %24
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %31
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %24
36: ; preds = %24
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %36
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %18
41: ; preds = %18
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [5 x i8] c"%c: \00"
define i32 @main() {
%1 = alloca [255 x i32]
%2 = bitcast [255 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 [255 x i32], [255 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
br label %16
16: ; preds = %15, %28
%17 = phi i64 [ %30, %28 ], [ 0, %15 ]
%18 = trunc i64 %17 to i32
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [255 x i32], [255 x i32]* %1, i64 0, i64 %17
%21 = load i32, i32* %20
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %16, %23
%24 = phi i32 [ %26, %23 ], [ 0, %16 ]
%25 = tail call i32 @putchar(i32 124)
%26 = add nuw nsw i32 %24, 1
%27 = icmp eq i32 %26, %21
br i1 %27, label %28, label %23
28: ; preds = %23, %16
%29 = tail call i32 @putchar(i32 10)
%30 = add nuw nsw i64 %17, 1
%31 = icmp eq i64 %30, 255
br i1 %31, label %32, label %16
32: ; preds = %28
ret i32 0
}