#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__ iscntrl(int);
int /*<<< orphan*/ printf(char *, char, ...);
int main(void) {
  unsigned long int count[0x100];
  int i, c;
  for (i = 0; i < 0x100; i++)
    count[i] = 0;
  while ((c = getchar()) != EOF)
    count[c]++;
  for (i = 0; i < 0x100; i++) {
    if (count[i]) {
      printf("0x%02x ", i);
      printf("%c %lu\n", (iscntrl(i) || (i) == 127) ? '.' : i, count[i]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x814(%rbp)
cmpl   $0x100,-0x814(%rbp)
jge    1183 <main+0x53>
movslq -0x814(%rbp),%rax
movq   $0x0,-0x810(%rbp,%rax,8)
mov    -0x814(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x814(%rbp)
jmp    114c <main+0x1c>
jmp    1188 <main+0x58>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x818(%rbp)
mov    0x2e4c(%rip),%rcx
cmp    (%rcx),%eax
je     11c4 <main+0x94>
movslq -0x818(%rbp),%rax
mov    -0x810(%rbp,%rax,8),%rcx
ff
add    $0x1,%rcx
mov    %rcx,-0x810(%rbp,%rax,8)
ff
jmp    1188 <main+0x58>
movl   $0x0,-0x814(%rbp)
cmpl   $0x100,-0x814(%rbp)
jge    1288 <main+0x158>
movslq -0x814(%rbp),%rax
cmpq   $0x0,-0x810(%rbp,%rax,8)
je     126f <main+0x13f>
mov    -0x814(%rbp),%eax
lea    0xdff(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x814(%rbp),%edi
call   1030 <iscntrl@plt>
cmp    $0x0,%rax
jne    122d <main+0xfd>
cmpl   $0x7f,-0x814(%rbp)
jne    123d <main+0x10d>
mov    $0x2e,%eax
mov    %eax,-0x81c(%rbp)
jmp    1249 <main+0x119>
mov    -0x814(%rbp),%eax
mov    %eax,-0x81c(%rbp)
mov    -0x81c(%rbp),%eax
movslq -0x814(%rbp),%rcx
mov    -0x810(%rbp,%rcx,8),%rdx
ff
lea    0xda3(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1274 <main+0x144>
mov    -0x814(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x814(%rbp)
jmp    11ce <main+0x9e>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x800,%rsp
mov    %rsp,%rdi
mov    $0x800,%edx
xor    %esi,%esi
call   1050 <memset@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x2e7c(%rip),%rbx
cmp    (%rbx),%eax
je     1182 <main+0x42>
cltq
addq   $0x1,(%rsp,%rax,8)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    (%rbx),%eax
jne    1170 <main+0x30>
lea    0xe77(%rip),%r14
mov    $0x2e,%ebp
lea    0xe73(%rip),%r15
xor    %ebx,%ebx
jmp    11ad <main+0x6d>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    $0x100,%rbx
je     11eb <main+0xab>
mov    (%rsp,%rbx,8),%r12
test   %r12,%r12
je     11a0 <main+0x60>
movsbl %bl,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
call   1030 <iscntrl@plt>
cmp    $0x7f,%rbx
mov    %ebx,%ecx
cmove  %ebp,%ecx
test   %rax,%rax
cmovne %ebp,%ecx
movsbl %cl,%esi
mov    %r15,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@EOF = global i32 0
@.str = [8 x i8] c"0x%02x \00"
@.str.1 = [8 x i8] c"%c %lu\0A\00"
define i32 @main() {
%1 = alloca [256 x i64]
%2 = bitcast [256 x i64]* %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 i64], [256 x i64]* %1, i64 0, i64 %8
%10 = load i64, i64* %9
%11 = add i64 %10, 1
store i64 %11, i64* %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
br label %16
16: ; preds = %15, %31
%17 = phi i64 [ %32, %31 ], [ 0, %15 ]
%18 = getelementptr inbounds [256 x i64], [256 x i64]* %1, i64 0, i64 %17
%19 = load i64, i64* %18
%20 = icmp eq i64 %19, 0
br i1 %20, label %31, label %21
21: ; preds = %16
%22 = trunc i64 %17 to i32
%23 = trunc i64 %17 to i8
%24 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 signext %23)
%25 = tail call i64 @iscntrl(i32 %22)
%26 = icmp ne i64 %25, 0
%27 = icmp eq i64 %17, 127
%28 = select i1 %26, i1 true, i1 %27
%29 = select i1 %28, i8 46, i8 %23
%30 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8 signext %29, i64 %19)
br label %31
31: ; preds = %16, %21
%32 = add nuw nsw i64 %17, 1
%33 = icmp eq i64 %32, 256
br i1 %33, label %34, label %16
34: ; preds = %31
ret i32 0
}