#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 freqs[256], c;
  for (c = 0; c < 256; ++c)
    freqs[c] = 0;
  while ((c = getchar()) != EOF)
    if (c >= 0 && c < 256)
      ++freqs[c];
  for (c = 0; c < 256; ++c)
    if (freqs[c] > 0) {
      printf("%1c (%3d) %3d: ", c, c, freqs[c]);
      for (; freqs[c] > 0; --freqs[c])
        printf("#");
      printf("\n");
    }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x414(%rbp)
cmpl   $0x100,-0x414(%rbp)
jge    1172 <main+0x52>
movslq -0x414(%rbp),%rax
movl   $0x0,-0x410(%rbp,%rax,4)
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    113c <main+0x1c>
jmp    1177 <main+0x57>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x414(%rbp)
mov    0x2e5d(%rip),%rcx
cmp    (%rcx),%eax
je     11cd <main+0xad>
cmpl   $0x0,-0x414(%rbp)
jl     11c8 <main+0xa8>
cmpl   $0x100,-0x414(%rbp)
jge    11c8 <main+0xa8>
movslq -0x414(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x410(%rbp,%rax,4)
jmp    1177 <main+0x57>
movl   $0x0,-0x414(%rbp)
cmpl   $0x100,-0x414(%rbp)
jge    128b <main+0x16b>
movslq -0x414(%rbp),%rax
cmpl   $0x0,-0x410(%rbp,%rax,4)
jle    1272 <main+0x152>
mov    -0x414(%rbp),%esi
mov    -0x414(%rbp),%edx
movslq -0x414(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%ecx
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x414(%rbp),%rax
cmpl   $0x0,-0x410(%rbp,%rax,4)
jle    1264 <main+0x144>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x414(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x410(%rbp,%rax,4)
jmp    1224 <main+0x104>
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1277 <main+0x157>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    11d7 <main+0xb7>
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rsp,%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1050 <memset@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e7f(%rip),%rbx
jmp    1177 <main+0x37>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    (%rbx),%eax
je     118a <main+0x4a>
cmp    $0xff,%eax
ja     1170 <main+0x30>
mov    %eax,%eax
addl   $0x1,(%rsp,%rax,4)
jmp    1170 <main+0x30>
lea    0xe6f(%rip),%r14
xor    %r15d,%r15d
jmp    11ad <main+0x6d>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%r15
cmp    $0x100,%r15
je     11f5 <main+0xb5>
mov    (%rsp,%r15,4),%ebx
test   %ebx,%ebx
jle    11a0 <main+0x60>
mov    %r14,%rdi
mov    %r15d,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x23,%edi
call   1030 <putchar@plt>
lea    -0x2(%rbx),%eax
mov    %eax,(%rsp,%r15,4)
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     11d0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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