#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 main(void) {
  int c;
  int i = 0;
  char chars[] =
      "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int cnum = 0;
  while (chars[i] != '\0') {
    cnum += 1;
    ++i;
  }
  int lengths[cnum];
  for (i = 0; i <= cnum; ++i) {
    lengths[i] = 0;
  }
  while ((c = getchar()) != EOF) {
    for (i = 0; i < cnum; ++i) {
      if (c == chars[i]) {
        lengths[i] += 1;
      }
    }
  }
  printf("\nCHARACTER FREQUENCY\n\n         5   10   15   20   25   30   35   "
         "40   45   50   55   60   65   70   75\n");
  int iter = 0;
  while (iter <= cnum) {
    i = lengths[iter];
    if (i > 0) {
      printf("%2c | ", chars[iter]);
      while (i > 0) {
        printf("#");
        i -= 1;
      }
      printf("\n");
    }
    ++iter;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xeac(%rip),%rsi
mov    $0x3f,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x54(%rbp)
movslq -0xc(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     118e <main+0x5e>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1165 <main+0x35>
mov    -0x54(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x60(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x78(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x68(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x54(%rbp),%eax
jg     11e5 <main+0xb5>
mov    -0x78(%rbp),%rax
movslq -0xc(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11bc <main+0x8c>
jmp    11ea <main+0xba>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2ded(%rip),%rcx
cmp    (%rcx),%eax
je     1253 <main+0x123>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    124e <main+0x11e>
mov    -0x8(%rbp),%eax
movslq -0xc(%rbp),%rcx
movsbl -0x50(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    123b <main+0x10b>
mov    -0x78(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
jmp    1240 <main+0x110>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    120a <main+0xda>
jmp    11ea <main+0xba>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x54(%rbp),%eax
jg     12e5 <main+0x1b5>
mov    -0x78(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    12d7 <main+0x1a7>
movslq -0x6c(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%esi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    12c9 <main+0x199>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12a3 <main+0x173>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1268 <main+0x138>
movl   $0x0,-0x4(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xf8,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0xec(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e23(%rip),%r14
cmp    (%r14),%eax
jne    124e <main+0x10e>
lea    0xe71(%rip),%rdi
call   1040 <puts@plt>
lea    0xe1f(%rip),%r14
lea    0xe57(%rip),%r15
xor    %ebx,%ebx
jmp    11fa <main+0xba>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    $0x3f,%rbx
je     123e <main+0xfe>
mov    (%rsp,%rbx,4),%ebp
test   %ebp,%ebp
jle    11f0 <main+0xb0>
movsbl (%rbx,%r14,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x23,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
cmp    $0x1,%ebp
ja     1220 <main+0xe0>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11f0 <main+0xb0>
xor    %eax,%eax
add    $0xf8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdab(%rip),%rbx
jmp    1270 <main+0x130>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    (%r14),%eax
je     11ce <main+0x8e>
mov    $0x1,%ecx
jmp    128a <main+0x14a>
nopw   0x0(%rax,%rax,1)
add    $0x2,%rcx
cmp    $0x3f,%rcx
je     1260 <main+0x120>
movsbl -0x1(%rcx,%rbx,1),%edx
cmp    %edx,%eax
jne    1298 <main+0x158>
addl   $0x1,-0x4(%rsp,%rcx,4)
movsbl (%rcx,%rbx,1),%edx
cmp    %edx,%eax
jne    1280 <main+0x140>
addl   $0x1,(%rsp,%rcx,4)
jmp    1280 <main+0x140>

LLVM IR (-O0):
@__const.main.chars = [63 x i8] c"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\00"
@EOF = global i32 0
@.str = [104 x i8] c"\0ACHARACTER FREQUENCY\0A\0A 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75\0A\00"
@.str.1 = [7 x i8] c"%2c | \00"
@.str.2 = [2 x i8] c"#\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [63 x i8]
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%9 = bitcast [63 x i8]* %4 to i8*
store i32 0, i32* %5
br label %10
10: ; preds = %17, %0
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [63 x i8], [63 x i8]* %4, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %10
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %10
22: ; preds = %10
%23 = load i32, i32* %5
%24 = zext i32 %23 to i64
%25 = call i8* @llvm.stacksave()
store i8* %25, i8** %6
%26 = alloca i32, i64 %24
store i64 %24, i64* %7
store i32 0, i32* %3
br label %27
27: ; preds = %35, %22
%28 = load i32, i32* %3
%29 = load i32, i32* %5
%30 = icmp sle i32 %28, %29
br i1 %30, label %31, label %38
31: ; preds = %27
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %26, i64 %33
store i32 0, i32* %34
br label %35
35: ; preds = %31
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %27
38: ; preds = %27
br label %39
39: ; preds = %66, %38
%40 = call i32 (...) @getchar()
store i32 %40, i32* %2
%41 = load i32, i32* @EOF
%42 = icmp ne i32 %40, %41
br i1 %42, label %43, label %67
43: ; preds = %39
store i32 0, i32* %3
br label %44
44: ; preds = %63, %43
%45 = load i32, i32* %3
%46 = load i32, i32* %5
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %66
48: ; preds = %44
%49 = load i32, i32* %2
%50 = load i32, i32* %3
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [63 x i8], [63 x i8]* %4, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %49, %54
br i1 %55, label %56, label %62
56: ; preds = %48
%57 = load i32, i32* %3
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i32, i32* %26, i64 %58
%60 = load i32, i32* %59
%61 = add nsw i32 %60, 1
store i32 %61, i32* %59
br label %62
62: ; preds = %56, %48
br label %63
63: ; preds = %62
%64 = load i32, i32* %3
%65 = add nsw i32 %64, 1
store i32 %65, i32* %3
br label %44
66: ; preds = %44
br label %39
67: ; preds = %39
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %69
69: ; preds = %96, %67
%70 = load i32, i32* %8
%71 = load i32, i32* %5
%72 = icmp sle i32 %70, %71
br i1 %72, label %73, label %99
73: ; preds = %69
%74 = load i32, i32* %8
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i32, i32* %26, i64 %75
%77 = load i32, i32* %76
store i32 %77, i32* %3
%78 = load i32, i32* %3
%79 = icmp sgt i32 %78, 0
br i1 %79, label %80, label %96
80: ; preds = %73
%81 = load i32, i32* %8
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds [63 x i8], [63 x i8]* %4, i64 0, i64 %82
%84 = load i8, i8* %83
%85 = sext i8 %84 to i32
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %85)
br label %87
87: ; preds = %90, %80
%88 = load i32, i32* %3
%89 = icmp sgt i32 %88, 0
br i1 %89, label %90, label %94
90: ; preds = %87
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%92 = load i32, i32* %3
%93 = sub nsw i32 %92, 1
store i32 %93, i32* %3
br label %87
94: ; preds = %87
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %96
96: ; preds = %94, %73
%97 = load i32, i32* %8
%98 = add nsw i32 %97, 1
store i32 %98, i32* %8
br label %69
99: ; preds = %69
store i32 0, i32* %1
%100 = load i8*, i8** %6
%101 = load i32, i32* %1
ret i32 %101
}

LLVM IR (-O2):
@__const.main.chars = [63 x i8] c"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\00"
@EOF = global i32 0
@.str.1 = [7 x i8] c"%2c | \00"
@str = [103 x i8] c"\0ACHARACTER FREQUENCY\0A\0A 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75\00"
define i32 @main() {
%1 = alloca [62 x i32]
%2 = bitcast [62 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 %35, label %10
6: ; preds = %32
%7 = tail call i32 (...) @getchar()
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %7, %8
br i1 %9, label %35, label %10
10: ; preds = %0, %6
%11 = phi i32 [ %7, %6 ], [ %3, %0 ]
br label %12
12: ; preds = %32, %10
%13 = phi i64 [ 0, %10 ], [ %33, %32 ]
%14 = getelementptr inbounds [63 x i8], [63 x i8]* @__const.main.chars, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %11, %16
br i1 %17, label %18, label %22
18: ; preds = %12
%19 = getelementptr inbounds [62 x i32], [62 x i32]* %1, i64 0, i64 %13
%20 = load i32, i32* %19
%21 = add nsw i32 %20, 1
store i32 %21, i32* %19
br label %22
22: ; preds = %12, %18
%23 = or i64 %13, 1
%24 = getelementptr inbounds [63 x i8], [63 x i8]* @__const.main.chars, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %11, %26
br i1 %27, label %28, label %32
28: ; preds = %22
%29 = getelementptr inbounds [62 x i32], [62 x i32]* %1, i64 0, i64 %23
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1
store i32 %31, i32* %29
br label %32
32: ; preds = %28, %22
%33 = add nuw nsw i64 %13, 2
%34 = icmp eq i64 %33, 62
br i1 %34, label %6, label %12
35: ; preds = %6, %0
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([103 x i8], [103 x i8]* @str, i64 0, i64 0))
br label %37
37: ; preds = %35, %54
%38 = phi i64 [ 0, %35 ], [ %55, %54 ]
%39 = getelementptr inbounds [62 x i32], [62 x i32]* %1, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = icmp sgt i32 %40, 0
br i1 %41, label %42, label %54
42: ; preds = %37
%43 = getelementptr inbounds [63 x i8], [63 x i8]* @__const.main.chars, i64 0, i64 %38
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %42, %47
%48 = phi i32 [ %40, %42 ], [ %50, %47 ]
%49 = tail call i32 @putchar(i32 35)
%50 = add nsw i32 %48, -1
%51 = icmp ugt i32 %48, 1
br i1 %51, label %47, label %52
52: ; preds = %47
%53 = tail call i32 @putchar(i32 10)
br label %54
54: ; preds = %52, %37
%55 = add nuw nsw i64 %38, 1
%56 = icmp eq i64 %55, 63
br i1 %56, label %57, label %37
57: ; preds = %54
ret i32 0
}