#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 */
typedef int /*<<< orphan*/ mark;

/* Variables and functions */
int EOF;
int getc(int /*<<< orphan*/);
scalar_t__ isprint(unsigned int);
int /*<<< orphan*/ memset(unsigned long long *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, unsigned int, unsigned long long);
int /*<<< orphan*/ stdin;
int main() {
  int c;
  unsigned long long count = 0;
  unsigned int i, used = 0;
  unsigned long long mark[256];
  memset(mark, 0, sizeof(mark));
  while ((c = getc(stdin)) != EOF)
    ++count, ++mark[c];
  for (i = 0; i < 256; ++i) {
    if (mark[i] == 0)
      continue;
    if (isprint(i)) {
      printf("char['%c'] = %llu\n", (char)i, mark[i]);
    } else {
      printf("char[%u] = %llu\n", i, mark[i]);
    }
    ++used;
  }
  printf("Total: %u chars used in %llu bytes.\n", used, count);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1040 <memset@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
call   1060 <getc@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e54(%rip),%rcx
cmp    (%rcx),%eax
je     11bd <main+0x7d>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
movslq -0x8(%rbp),%rax
mov    -0x820(%rbp,%rax,8),%rcx
ff
add    $0x1,%rcx
mov    %rcx,-0x820(%rbp,%rax,8)
ff
jmp    1174 <main+0x34>
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jae    124d <main+0x10d>
mov    -0x14(%rbp),%eax
cmpq   $0x0,-0x820(%rbp,%rax,8)
jne    11e8 <main+0xa8>
jmp    123f <main+0xff>
mov    -0x14(%rbp),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     121c <main+0xdc>
mov    -0x14(%rbp),%eax
movsbl %al,%esi
mov    -0x14(%rbp),%eax
mov    -0x820(%rbp,%rax,8),%rdx
ff
lea    0xdee(%rip),%rdi
call   1030 <printf@plt>
jmp    1236 <main+0xf6>
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%eax
mov    -0x820(%rbp,%rax,8),%rdx
ff
lea    0xde2(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c4 <main+0x84>
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xdc9(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    %rsp,%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x800,%edx
call   1040 <memset@plt>
mov    0x2e7f(%rip),%r14
mov    (%r14),%edi
call   1060 <getc@plt>
mov    0x2e68(%rip),%rbp
cmp    0x0(%rbp),%eax
jne    1182 <main+0x42>
xor    %r13d,%r13d
jmp    11a8 <main+0x68>
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r13
cltq
addq   $0x1,(%rsp,%rax,8)
mov    (%r14),%edi
call   1060 <getc@plt>
cmp    0x0(%rbp),%eax
jne    1190 <main+0x50>
lea    0xe64(%rip),%r14
lea    0xe4a(%rip),%r15
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    11e5 <main+0xa5>
nopl   (%rax)
mov    (%rsp,%rbp,8),%rdx
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%r12d
add    $0x1,%rbp
add    $0x1000000,%ebx
cmp    $0x100,%rbp
je     1206 <main+0xc6>
cmpq   $0x0,(%rsp,%rbp,8)
je     11d2 <main+0x92>
mov    %ebp,%edi
call   1050 <isprint@plt>
test   %rax,%rax
je     11c0 <main+0x80>
mov    %ebx,%esi
sar    $0x18,%esi
mov    (%rsp,%rbp,8),%rdx
mov    %r15,%rdi
jmp    11c9 <main+0x89>
lea    0xe17(%rip),%rdi
mov    %r12d,%esi
mov    %r13,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@stdin = global i32 0
@EOF = global i32 0
@.str = [19 x i8] c"char['%c'] = %llu\0A\00"
@.str.1 = [17 x i8] c"char[%u] = %llu\0A\00"
@.str.2 = [37 x i8] c"Total: %u chars used in %llu bytes.\0A\00"
define i32 @main() {
%1 = alloca [256 x i64]
%2 = bitcast [256 x i64]* %1 to i8*
%3 = getelementptr inbounds [256 x i64], [256 x i64]* %1, i64 0, i64 0
%4 = call i32 @memset(i64* %3, i32 0, i32 2048)
%5 = load i32, i32* @stdin
%6 = call i32 @getc(i32 %5)
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %9, label %11
9: ; preds = %11, %0
%10 = phi i64 [ 0, %0 ], [ %14, %11 ]
br label %23
11: ; preds = %0, %11
%12 = phi i32 [ %20, %11 ], [ %6, %0 ]
%13 = phi i64 [ %14, %11 ], [ 0, %0 ]
%14 = add i64 %13, 1
%15 = sext i32 %12 to i64
%16 = getelementptr inbounds [256 x i64], [256 x i64]* %1, i64 0, i64 %15
%17 = load i64, i64* %16
%18 = add i64 %17, 1
store i64 %18, i64* %16
%19 = load i32, i32* @stdin
%20 = call i32 @getc(i32 %19)
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %9, label %11
23: ; preds = %9, %44
%24 = phi i64 [ 0, %9 ], [ %46, %44 ]
%25 = phi i32 [ 0, %9 ], [ %45, %44 ]
%26 = getelementptr inbounds [256 x i64], [256 x i64]* %1, i64 0, i64 %24
%27 = load i64, i64* %26
%28 = icmp eq i64 %27, 0
br i1 %28, label %44, label %29
29: ; preds = %23
%30 = trunc i64 %24 to i32
%31 = call i64 @isprint(i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %39, label %33
33: ; preds = %29
%34 = trunc i64 %24 to i32
%35 = shl i32 %34, 24
%36 = ashr exact i32 %35, 24
%37 = load i64, i64* %26
%38 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %36, i64 %37)
br label %42
39: ; preds = %29
%40 = load i64, i64* %26
%41 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %30, i64 %40)
br label %42
42: ; preds = %39, %33
%43 = add i32 %25, 1
br label %44
44: ; preds = %23, %42
%45 = phi i32 [ %25, %23 ], [ %43, %42 ]
%46 = add nuw nsw i64 %24, 1
%47 = icmp eq i64 %46, 256
br i1 %47, label %48, label %23
48: ; preds = %44
%49 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %45, i64 %10)
ret i32 0
}