#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 getchar();
int /*<<< orphan*/ printf(char *, ...);
main() {
  int symbols['z' - 'a'];
  int c, i, j;
  int end = getchar();
  for (i = 0; i < 'z' - 'a'; ++i) {
    symbols[i] = 0;
  }
  while ((c = getchar()) != end)
    if (c >= 'a' && c <= 'z')
      ++symbols[c - 'a'];
  printf("Symbols gistogram\n");
  for (i = 0; i < 'z' - 'a'; ++i) {
    if (symbols[i] != 0) {
      printf("\n");
    }
    for (j = 0; j < symbols[i]; ++j) {
      printf("%c", i + 'a');
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x80(%rbp)
movl   $0x0,-0x78(%rbp)
cmpl   $0x19,-0x78(%rbp)
jge    1167 <main+0x47>
movslq -0x78(%rbp),%rax
movl   $0x0,-0x70(%rbp,%rax,4)
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1143 <main+0x23>
jmp    116c <main+0x4c>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x74(%rbp)
cmp    -0x80(%rbp),%eax
je     11ab <main+0x8b>
cmpl   $0x61,-0x74(%rbp)
jl     11a6 <main+0x86>
cmpl   $0x7a,-0x74(%rbp)
jg     11a6 <main+0x86>
mov    -0x74(%rbp),%eax
sub    $0x61,%eax
cltq
mov    -0x70(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x70(%rbp,%rax,4)
jmp    116c <main+0x4c>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x78(%rbp)
cmpl   $0x19,-0x78(%rbp)
jge    1234 <main+0x114>
movslq -0x78(%rbp),%rax
cmpl   $0x0,-0x70(%rbp,%rax,4)
je     11e7 <main+0xc7>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
movslq -0x78(%rbp),%rcx
cmp    -0x70(%rbp,%rcx,4),%eax
jge    1221 <main+0x101>
mov    -0x78(%rbp),%esi
add    $0x61,%esi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    11ee <main+0xce>
jmp    1226 <main+0x106>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    11c0 <main+0xa0>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
xor    %eax,%eax
call   1050 <getchar@plt>
mov    %eax,%ebx
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movl   $0x0,0x60(%rsp)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    %ebx,%eax
je     118b <main+0x5b>
add    $0xffffff9f,%eax
cmp    $0x19,%eax
ja     1170 <main+0x40>
mov    %eax,%eax
addl   $0x1,(%rsp,%rax,4)
jmp    1170 <main+0x40>
lea    0xe6e(%rip),%rdi
call   1040 <puts@plt>
xor    %r14d,%r14d
jmp    11aa <main+0x7a>
nopl   0x0(%rax)
add    $0x1,%r14
cmp    $0x19,%r14
je     11de <main+0xae>
mov    (%rsp,%r14,4),%ebp
test   %ebp,%ebp
je     11a0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %ebp,%ebp
jle    11a0 <main+0x70>
lea    0x61(%r14),%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11d0 <main+0xa0>
jmp    11a0 <main+0x70>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Symbols gistogram\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [25 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (...) @getchar()
store i32 %7, i32* %6
store i32 0, i32* %4
br label %8
8: ; preds = %15, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 25
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [25 x i32], [25 x i32]* %2, 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* %3
%21 = load i32, i32* %6
%22 = icmp ne i32 %20, %21
br i1 %22, label %23, label %37
23: ; preds = %19
%24 = load i32, i32* %3
%25 = icmp sge i32 %24, 97
br i1 %25, label %26, label %36
26: ; preds = %23
%27 = load i32, i32* %3
%28 = icmp sle i32 %27, 122
br i1 %28, label %29, label %36
29: ; preds = %26
%30 = load i32, i32* %3
%31 = sub nsw i32 %30, 97
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [25 x i32], [25 x i32]* %2, 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 ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %39
39: ; preds = %66, %37
%40 = load i32, i32* %4
%41 = icmp slt i32 %40, 25
br i1 %41, label %42, label %69
42: ; preds = %39
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [25 x i32], [25 x i32]* %2, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %42
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %50
50: ; preds = %48, %42
store i32 0, i32* %5
br label %51
51: ; preds = %62, %50
%52 = load i32, i32* %5
%53 = load i32, i32* %4
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [25 x i32], [25 x i32]* %2, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = icmp slt i32 %52, %56
br i1 %57, label %58, label %65
58: ; preds = %51
%59 = load i32, i32* %4
%60 = add nsw i32 %59, 97
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %60)
br label %62
62: ; preds = %58
%63 = load i32, i32* %5
%64 = add nsw i32 %63, 1
store i32 %64, i32* %5
br label %51
65: ; preds = %51
br label %66
66: ; preds = %65
%67 = load i32, i32* %4
%68 = add nsw i32 %67, 1
store i32 %68, i32* %4
br label %39
69: ; preds = %39
%70 = load i32, i32* %1
ret i32 %70
}

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