#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 main() {
  int c, frequency[95];
  for (int i = 0; i < 95; i++) {
    frequency[i] = 0;
  }
  while ((c = getchar()) != EOF) {
    if (c >= ' ' && c <= '~') {
      frequency[c - ' ']++;
    }
  }
  printf("\nCharacter Frequency Histogram\nFrequency\n* = 1 instance\n");
  for (int i = 0; i < 95; i++) {
    int character = 32 + i;
    if (character == 32) {
      printf("space\t");
    } else {
      printf("%c\t", 32 + i);
    }
    for (int index = frequency[i]; index > 0; index--) {
      putchar('*');
    }
    putchar('\n');
  }
  printf("============================\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x194(%rbp)
cmpl   $0x5f,-0x194(%rbp)
jge    117f <main+0x4f>
movslq -0x194(%rbp),%rax
movl   $0x0,-0x190(%rbp,%rax,4)
mov    -0x194(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x194(%rbp)
jmp    114c <main+0x1c>
jmp    1184 <main+0x54>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e53(%rip),%rcx
cmp    (%rcx),%eax
je     11cf <main+0x9f>
cmpl   $0x20,-0x8(%rbp)
jl     11ca <main+0x9a>
cmpl   $0x7e,-0x8(%rbp)
jg     11ca <main+0x9a>
mov    -0x8(%rbp),%eax
sub    $0x20,%eax
cltq
mov    -0x190(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x190(%rbp,%rax,4)
jmp    1184 <main+0x54>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x198(%rbp)
cmpl   $0x5f,-0x198(%rbp)
jge    1297 <main+0x167>
mov    -0x198(%rbp),%eax
add    $0x20,%eax
mov    %eax,-0x19c(%rbp)
cmpl   $0x20,-0x19c(%rbp)
jne    1223 <main+0xf3>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    123a <main+0x10a>
mov    -0x198(%rbp),%esi
add    $0x20,%esi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movslq -0x198(%rbp),%rax
mov    -0x190(%rbp,%rax,4),%eax
mov    %eax,-0x1a0(%rbp)
cmpl   $0x0,-0x1a0(%rbp)
jle    1279 <main+0x149>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    -0x1a0(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1a0(%rbp)
jmp    124e <main+0x11e>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x198(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x198(%rbp)
jmp    11e7 <main+0xb7>
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x188,%rsp
mov    %rsp,%rdi
mov    $0x17c,%edx
xor    %esi,%esi
call   1060 <memset@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    0x2e6e(%rip),%rbx
jmp    1187 <main+0x37>
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    (%rbx),%eax
je     119b <main+0x4b>
add    $0xffffffe0,%eax
cmp    $0x5e,%eax
ja     1180 <main+0x30>
mov    %eax,%eax
addl   $0x1,(%rsp,%rax,4)
jmp    1180 <main+0x30>
lea    0xe69(%rip),%rdi
call   1040 <puts@plt>
lea    0xe52(%rip),%r14
lea    0xe52(%rip),%r15
xor    %ebx,%ebx
jmp    11d4 <main+0x84>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x5f,%rbx
je     1224 <main+0xd4>
test   %rbx,%rbx
je     11f0 <main+0xa0>
lea    0x20(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11fa <main+0xaa>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp,%rbx,4),%ebp
test   %ebp,%ebp
jle    11c0 <main+0x70>
add    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1210 <main+0xc0>
jmp    11c0 <main+0x70>
lea    0xe18(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x188,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EOF = global i32 0
@.str.1 = [7 x i8] c"space\09\00"
@.str.2 = [4 x i8] c"%c\09\00"
@str = [56 x i8] c"\0ACharacter Frequency Histogram\0AFrequency\0A* = 1 instance\00"
@str.4 = [29 x i8] 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
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
br label %23
21: ; preds = %36
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.4, i64 0, i64 0))
ret i32 0
23: ; preds = %19, %36
%24 = phi i64 [ 0, %19 ], [ %38, %36 ]
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %32
28: ; preds = %23
%29 = trunc i64 %24 to i32
%30 = add i32 %29, 32
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %28, %26
%33 = getelementptr inbounds [95 x i32], [95 x i32]* %1, i64 0, i64 %24
%34 = load i32, i32* %33
%35 = icmp sgt i32 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %40, %32
%37 = tail call i32 @putchar(i8 signext 10)
%38 = add nuw nsw i64 %24, 1
%39 = icmp eq i64 %38, 95
br i1 %39, label %21, label %23
40: ; preds = %32, %40
%41 = phi i32 [ %43, %40 ], [ %34, %32 ]
%42 = tail call i32 @putchar(i8 signext 42)
%43 = add nsw i32 %41, -1
%44 = icmp ugt i32 %41, 1
br i1 %44, label %40, label %36
}