#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 /*<<< orphan*/ putesc(size_t);
int main(int argc, char **argv) {
  int c;
  size_t chars[256];
  size_t i = 0;
  for (i = 0; i < 256; ++i)
    chars[i] = 0;
  while ((c = getchar()) != EOF) {
    chars[c]++;
  }
  for (i = 0; i < 256; ++i) {
    if (chars[i] > 0) {
      size_t j;
      putesc(i);
      printf(": ");
      for (j = 0; j < chars[i]; ++j)
        putchar('#');
      putchar('\n');
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x828(%rbp)
movq   $0x0,-0x828(%rbp)
cmpq   $0x100,-0x828(%rbp)
jae    11aa <main+0x6a>
mov    -0x828(%rbp),%rax
movq   $0x0,-0x820(%rbp,%rax,8)
mov    -0x828(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x828(%rbp)
jmp    116f <main+0x2f>
jmp    11af <main+0x6f>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e28(%rip),%rcx
cmp    (%rcx),%eax
je     11e5 <main+0xa5>
movslq -0x14(%rbp),%rax
mov    -0x820(%rbp,%rax,8),%rcx
ff
add    $0x1,%rcx
mov    %rcx,-0x820(%rbp,%rax,8)
ff
jmp    11af <main+0x6f>
movq   $0x0,-0x828(%rbp)
cmpq   $0x100,-0x828(%rbp)
jae    129d <main+0x15d>
mov    -0x828(%rbp),%rax
cmpq   $0x0,-0x820(%rbp,%rax,8)
jbe    1281 <main+0x141>
mov    -0x828(%rbp),%rdi
call   1050 <putesc@plt>
lea    0xdd6(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,-0x830(%rbp)
mov    -0x830(%rbp),%rax
mov    -0x828(%rbp),%rcx
cmp    -0x820(%rbp,%rcx,8),%rax
ff
jae    1277 <main+0x137>
mov    $0x23,%edi
call   1030 <putchar@plt>
mov    -0x830(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x830(%rbp)
jmp    123a <main+0xfa>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1286 <main+0x146>
mov    -0x828(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x828(%rbp)
jmp    11f0 <main+0xb0>
xor    %eax,%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    %rsp,%rdi
mov    $0x800,%edx
xor    %esi,%esi
call   1050 <memset@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    0x2e6f(%rip),%rbx
cmp    (%rbx),%eax
je     1192 <main+0x42>
nopl   (%rax)
cltq
addq   $0x1,(%rsp,%rax,8)
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    (%rbx),%eax
jne    1180 <main+0x30>
xor    %r15d,%r15d
lea    0xe64(%rip),%r14
jmp    11ad <main+0x5d>
xchg   %ax,%ax
add    $0x1,%r15
cmp    $0x100,%r15
je     11ec <main+0x9c>
mov    (%rsp,%r15,8),%rbx
test   %rbx,%rbx
je     11a0 <main+0x50>
mov    %r15,%rdi
call   1060 <putesc@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
jne    11d0 <main+0x80>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11a0 <main+0x50>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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