#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();
scalar_t__ isprint(int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i, j;
  int c;
  int histogram[256];
  for (i = 0; i < 256; ++i)
    histogram[i] = 0;
  while ((c = getchar()) != EOF)
    ++histogram[c];
  printf("Characters frequencies histogram\n");
  printf("--------------------------------\n");
  for (i = 0; i < 256; ++i) {
    if (histogram[i]) {
      if (isprint(i))
        printf("'%c'(\\x%02x): ", i, i);
      else
        printf("' '(\\x%02x): ", i);
      for (j = 1; j <= histogram[i]; ++j)
        printf("=");
      printf("\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    1173 <main+0x43>
movslq -0x8(%rbp),%rax
movl   $0x0,-0x410(%rbp,%rax,4)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1149 <main+0x19>
jmp    1178 <main+0x48>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e5f(%rip),%rcx
cmp    (%rcx),%eax
je     11ab <main+0x7b>
movslq -0x10(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x410(%rbp,%rax,4)
jmp    1178 <main+0x48>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    1281 <main+0x151>
movslq -0x8(%rbp),%rax
cmpl   $0x0,-0x410(%rbp,%rax,4)
je     126e <main+0x13e>
mov    -0x8(%rbp),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     1218 <main+0xe8>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1229 <main+0xf9>
mov    -0x8(%rbp),%esi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
movslq -0x8(%rbp),%rcx
cmp    -0x410(%rbp,%rcx,4),%eax
jg     1260 <main+0x130>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1230 <main+0x100>
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1273 <main+0x143>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ce <main+0x9e>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsp,%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1060 <memset@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    0x2e5e(%rip),%rbx
cmp    (%rbx),%eax
je     11a1 <main+0x41>
xchg   %ax,%ax
cltq
addl   $0x1,(%rsp,%rax,4)
xor    %eax,%eax
call   1070 <getchar@plt>
cmp    (%rbx),%eax
jne    1190 <main+0x30>
lea    0xe75(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe4f(%rip),%r14
lea    0xe39(%rip),%r15
xor    %ebx,%ebx
jmp    11e7 <main+0x87>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
je     1231 <main+0xd1>
mov    (%rsp,%rbx,4),%ebp
test   %ebp,%ebp
je     11da <main+0x7a>
mov    %ebx,%edi
call   1080 <isprint@plt>
test   %rax,%rax
je     1210 <main+0xb0>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
jg     1220 <main+0xc0>
jmp    11d0 <main+0x70>
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebp,%ebp
jle    11d0 <main+0x70>
mov    $0x3d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1220 <main+0xc0>
jmp    11d0 <main+0x70>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EOF = global i32 0
@.str.2 = [15 x i8] c"'%c'(\\x%02x): \00"
@.str.3 = [14 x i8] c"' '(\\x%02x): \00"
@str = [33 x i8] c"Characters frequencies histogram\00"
@str.6 = [33 x i8] c"--------------------------------\00"
define i32 @main() {
%1 = alloca [256 x i32]
%2 = bitcast [256 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 %15, label %6
6: ; preds = %0, %6
%7 = phi i32 [ %12, %6 ], [ %3, %0 ]
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [256 x i32], [256 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 i32 (...) @getchar()
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %6
15: ; preds = %6, %0
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.6, i64 0, i64 0))
br label %18
18: ; preds = %15, %40
%19 = phi i64 [ 0, %15 ], [ %41, %40 ]
%20 = getelementptr inbounds [256 x i32], [256 x i32]* %1, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %40, label %23
23: ; preds = %18
%24 = trunc i64 %19 to i32
%25 = tail call i64 @isprint(i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %23
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %24)
br label %31
29: ; preds = %23
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %31
31: ; preds = %29, %27
%32 = icmp slt i32 %21, 1
br i1 %32, label %38, label %33
33: ; preds = %31, %33
%34 = phi i32 [ %36, %33 ], [ 1, %31 ]
%35 = tail call i32 @putchar(i32 61)
%36 = add nuw i32 %34, 1
%37 = icmp eq i32 %34, %21
br i1 %37, label %38, label %33
38: ; preds = %33, %31
%39 = tail call i32 @putchar(i32 10)
br label %40
40: ; preds = %18, %38
%41 = add nuw nsw i64 %19, 1
%42 = icmp eq i64 %41, 256
br i1 %42, label %43, label %18
43: ; preds = %40
ret i32 0
}