#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 hist[128];
  int i;
  for (i = 0; i < 127; ++i)
    hist[i] = 0;
  while ((c = getchar()) != EOF)
    ++hist[c];
  for (c = 0; c < 127; ++c)
    if (hist[c] > 0) {
      printf("%c: ", c);
      for (i = 0; i < hist[c]; ++i)
        printf("*");
      printf("\n");
    }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x214(%rbp)
cmpl   $0x7f,-0x214(%rbp)
jge    116f <main+0x4f>
movslq -0x214(%rbp),%rax
movl   $0x0,-0x210(%rbp,%rax,4)
mov    -0x214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x214(%rbp)
jmp    113c <main+0x1c>
jmp    1174 <main+0x54>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
mov    0x2e60(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11ae <main+0x8e>
movsbq -0x5(%rbp),%rax
mov    -0x210(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x210(%rbp,%rax,4)
jmp    1174 <main+0x54>
movb   $0x0,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x7f,%eax
jge    1248 <main+0x128>
movsbq -0x5(%rbp),%rax
cmpl   $0x0,-0x210(%rbp,%rax,4)
jle    1236 <main+0x116>
movsbl -0x5(%rbp),%esi
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x214(%rbp)
mov    -0x214(%rbp),%eax
movsbq -0x5(%rbp),%rcx
cmp    -0x210(%rbp,%rcx,4),%eax
jge    1228 <main+0x108>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x214(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x214(%rbp)
jmp    11ee <main+0xce>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123b <main+0x11b>
mov    -0x5(%rbp),%al
add    $0x1,%al
mov    %al,-0x5(%rbp)
jmp    11b2 <main+0x92>
xor    %eax,%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %rsp,%rdi
mov    $0x1fc,%edx
xor    %esi,%esi
call   1050 <memset@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e80(%rip),%rbx
cmp    (%rbx),%al
je     1183 <main+0x43>
nopl   0x0(%rax)
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
xor    %ebx,%ebx
jmp    119a <main+0x5a>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    $0x7f,%rbx
je     11cb <main+0x8b>
mov    (%rsp,%rbx,4),%ebp
test   %ebp,%ebp
jle    1190 <main+0x50>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
nopl   (%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11b0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    1190 <main+0x50>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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