#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
int getchar();
int /*<<< orphan*/ printf(char *, int, int);
int main(int argc, char *argv[]) {
  int count[256];
  int i;
  int c;
  for (i = 0; i < 256; i++) {
    count[i] = 0;
  }
  while (EOF != (c = getchar())) {
    count[c] += 1;
  }
  for (i = 0; i < 256; i++) {
    if (count[i] > 0) {
      printf("count[ %d ] = %d\n", i, count[i]);
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x414(%rbp)
cmpl   $0x100,-0x414(%rbp)
jge    1189 <main+0x59>
movslq -0x414(%rbp),%rax
movl   $0x0,-0x410(%rbp,%rax,4)
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    1153 <main+0x23>
jmp    118e <main+0x5e>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x41c(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,%ecx
mov    -0x41c(%rbp),%eax
mov    %ecx,-0x418(%rbp)
cmp    %ecx,%eax
je     11d7 <main+0xa7>
movslq -0x418(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x410(%rbp,%rax,4)
jmp    118e <main+0x5e>
movl   $0x0,-0x414(%rbp)
cmpl   $0x100,-0x414(%rbp)
jge    123f <main+0x10f>
movslq -0x414(%rbp),%rax
cmpl   $0x0,-0x410(%rbp,%rax,4)
jle    1226 <main+0xf6>
mov    -0x414(%rbp),%esi
movslq -0x414(%rbp),%rax
mov    -0x410(%rbp,%rax,4),%edx
lea    0xddf(%rip),%rdi
call   1030 <printf@plt>
jmp    122b <main+0xfb>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    11e1 <main+0xb1>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
mov    %rsp,%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    0x2e87(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    %eax,%ebp
je     1185 <main+0x45>
cltq
addl   $0x1,(%rsp,%rax,4)
jmp    1170 <main+0x30>
xor    %ebx,%ebx
lea    0xe72(%rip),%r14
jmp    119d <main+0x5d>
add    $0x1,%rbx
cmp    $0x100,%rbx
je     11b0 <main+0x70>
mov    (%rsp,%rbx,4),%edx
test   %edx,%edx
jle    1190 <main+0x50>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
jmp    1190 <main+0x50>
xor    %edi,%edi
call   1060 <exit@plt>

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

LLVM IR (-O2):
@EOF = global i32 0
@.str = [18 x i8] c"count[ %d ] = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [256 x i32]
%4 = bitcast [256 x i32]* %3 to i8*
%5 = load i32, i32* @EOF
%6 = tail call i32 (...) @getchar()
%7 = icmp eq i32 %5, %6
br i1 %7, label %17, label %8
8: ; preds = %2, %8
%9 = phi i32 [ %15, %8 ], [ %6, %2 ]
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %10
%12 = load i32, i32* %11
%13 = add nsw i32 %12, 1
store i32 %13, i32* %11
%14 = load i32, i32* @EOF
%15 = tail call i32 (...) @getchar()
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %8
17: ; preds = %8, %2
br label %18
18: ; preds = %17, %26
%19 = phi i64 [ %27, %26 ], [ 0, %17 ]
%20 = getelementptr inbounds [256 x i32], [256 x i32]* %3, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = trunc i64 %19 to i32
%25 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %21)
br label %26
26: ; preds = %18, %23
%27 = add nuw nsw i64 %19, 1
%28 = icmp eq i64 %27, 256
br i1 %28, label %29, label %18
29: ; preds = %26
%30 = tail call i32 @exit(i32 0)
unreachable
}