#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 */
char EOF;
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char c;
  int i, j;
  int char_freq[128] = {0};
  while ((c = getchar()) != EOF)
    ++char_freq[c];
  for (i = 0; i < 128; ++i) {
    if (char_freq[i] == 0)
      continue;
    if (i > 32)
      printf("      %3c ", i);
    else
      printf("ascii:%3d ", i);
    for (j = 0; j < char_freq[i]; ++j)
      printf("*");
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1040 <memset@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e7f(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     118f <main+0x5f>
movsbq -0x5(%rbp),%rax
mov    -0x210(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x210(%rbp,%rax,4)
jmp    1155 <main+0x25>
movl   $0x0,-0xc(%rbp)
cmpl   $0x80,-0xc(%rbp)
jge    123e <main+0x10e>
movslq -0xc(%rbp),%rax
cmpl   $0x0,-0x210(%rbp,%rax,4)
jne    11ba <main+0x8a>
jmp    1230 <main+0x100>
cmpl   $0x20,-0xc(%rbp)
jle    11da <main+0xaa>
mov    -0xc(%rbp),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11eb <main+0xbb>
mov    -0xc(%rbp),%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
movslq -0xc(%rbp),%rcx
cmp    -0x210(%rbp,%rcx,4),%eax
jge    1222 <main+0xf2>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11f2 <main+0xc2>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1196 <main+0x66>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x208,%rsp
mov    %rsp,%rdi
mov    $0x200,%edx
xor    %esi,%esi
call   1050 <memset@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e7e(%rip),%rbx
cmp    (%rbx),%al
je     1183 <main+0x43>
xchg   %ax,%ax
movsbq %al,%rax
addl   $0x1,(%rsp,%rax,4)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    (%rbx),%al
jne    1170 <main+0x30>
lea    0xe76(%rip),%r14
lea    0xe7a(%rip),%r15
xor    %ebx,%ebx
jmp    11b7 <main+0x77>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x80,%rbx
je     11f1 <main+0xb1>
mov    (%rsp,%rbx,4),%ebp
test   %ebp,%ebp
je     11aa <main+0x6a>
cmp    $0x21,%rbx
mov    %r15,%rdi
cmovae %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    11a0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11e0 <main+0xa0>
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x208,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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