#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, length, n_chars = '~' - ' ' + 1;
  int counts[n_chars];
  for (i = 0; i < n_chars; i++)
    counts[i] = 0;
  while ((c = getchar()) != EOF)
    if (c >= ' ' && c <= '~')
      counts[c - ' ']++;
  for (i = 0; i < n_chars; i++) {
    printf("%c: ", i + ' ');
    for (j = 0; j < counts[i]; j++)
      printf("#");
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x5f,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    118d <main+0x6d>
mov    -0x30(%rbp),%rax
movslq -0xc(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1164 <main+0x44>
jmp    1192 <main+0x72>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e45(%rip),%rcx
cmp    (%rcx),%eax
je     11da <main+0xba>
cmpl   $0x20,-0x8(%rbp)
jl     11d5 <main+0xb5>
cmpl   $0x7e,-0x8(%rbp)
jg     11d5 <main+0xb5>
mov    -0x30(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x20,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
jmp    1192 <main+0x72>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1254 <main+0x134>
mov    -0xc(%rbp),%esi
add    $0x20,%esi
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%eax
movslq -0xc(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    1238 <main+0x118>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1208 <main+0xe8>
lea    0xdc8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e1 <main+0xc1>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x180,%rsp
mov    %rsp,%rdi
mov    $0x17c,%edx
xor    %esi,%esi
call   1050 <memset@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e80(%rip),%rbx
jmp    1177 <main+0x37>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    (%rbx),%eax
je     118b <main+0x4b>
add    $0xffffffe0,%eax
cmp    $0x5e,%eax
ja     1170 <main+0x30>
mov    %eax,%eax
addl   $0x1,(%rsp,%rax,4)
jmp    1170 <main+0x30>
lea    0xe6e(%rip),%r14
xor    %ebx,%ebx
jmp    11b4 <main+0x74>
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x5f,%rbx
je     11e1 <main+0xa1>
lea    0x20(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp,%rbx,4),%ebp
test   %ebp,%ebp
jle    11a0 <main+0x60>
nopl   0x0(%rax,%rax,1)
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11d0 <main+0x90>
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x180,%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 i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
store i32 0, i32* %1
store i32 95, i32* %6
%9 = load i32, i32* %6
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %7
%12 = alloca i32, i64 %10
store i64 %10, i64* %8
store i32 0, i32* %3
br label %13
13: ; preds = %21, %0
%14 = load i32, i32* %3
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %24
17: ; preds = %13
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %12, i64 %19
store i32 0, i32* %20
br label %21
21: ; preds = %17
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 1
store i32 %23, i32* %3
br label %13
24: ; preds = %13
br label %25
25: ; preds = %42, %24
%26 = call i32 (...) @getchar()
store i32 %26, i32* %2
%27 = load i32, i32* @EOF
%28 = icmp ne i32 %26, %27
br i1 %28, label %29, label %43
29: ; preds = %25
%30 = load i32, i32* %2
%31 = icmp sge i32 %30, 32
br i1 %31, label %32, label %42
32: ; preds = %29
%33 = load i32, i32* %2
%34 = icmp sle i32 %33, 126
br i1 %34, label %35, label %42
35: ; preds = %32
%36 = load i32, i32* %2
%37 = sub nsw i32 %36, 32
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %12, i64 %38
%40 = load i32, i32* %39
%41 = add nsw i32 %40, 1
store i32 %41, i32* %39
br label %42
42: ; preds = %35, %32, %29
br label %25
43: ; preds = %25
store i32 0, i32* %3
br label %44
44: ; preds = %66, %43
%45 = load i32, i32* %3
%46 = load i32, i32* %6
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %69
48: ; preds = %44
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 32
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %50)
store i32 0, i32* %4
br label %52
52: ; preds = %61, %48
%53 = load i32, i32* %4
%54 = load i32, i32* %3
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* %12, i64 %55
%57 = load i32, i32* %56
%58 = icmp slt i32 %53, %57
br i1 %58, label %59, label %64
59: ; preds = %52
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %61
61: ; preds = %59
%62 = load i32, i32* %4
%63 = add nsw i32 %62, 1
store i32 %63, i32* %4
br label %52
64: ; preds = %52
%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
%67 = load i32, i32* %3
%68 = add nsw i32 %67, 1
store i32 %68, i32* %3
br label %44
69: ; preds = %44
%70 = load i8*, i8** %7
%71 = load i32, i32* %1
ret i32 %71
}

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