#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, unsigned int);
main(int argc, char *argv[]) {
  FILE *FH;
  unsigned char rank;
  unsigned int rankArray[255];
  int i;
  for (i = 0; i <= 255; i++) {
    rankArray[i] = 0;
  };
  if ((FH = fopen(argv[1], "r")) == NULL) {
    perror(argv[1]);
    exit(1);
  }
  while (!feof(FH)) {
    fread(&rank, sizeof(unsigned char), 1, FH);
    ++rankArray[rank];
  }
  fclose(FH);
  for (i = 0; i <= 255; i++) {
    printf("%i %i\n", i, rankArray[i]);
  };
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x424(%rbp)
cmpl   $0xff,-0x424(%rbp)
jg     11c9 <main+0x59>
movslq -0x424(%rbp),%rax
movl   $0x0,-0x420(%rbp,%rax,4)
mov    -0x424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
jmp    1193 <main+0x23>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe28(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1202 <main+0x92>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    1207 <main+0x97>
mov    -0x18(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1225 <main+0xb5>
jmp    1253 <main+0xe3>
mov    -0x18(%rbp),%rcx
lea    -0x19(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
movzbl -0x19(%rbp),%eax
mov    -0x420(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x420(%rbp,%rax,4)
jmp    1207 <main+0x97>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x424(%rbp)
cmpl   $0xff,-0x424(%rbp)
jg     12aa <main+0x13a>
mov    -0x424(%rbp),%esi
movslq -0x424(%rbp),%rax
mov    -0x420(%rbp,%rax,4),%edx
lea    0xd71(%rip),%rdi
call   1050 <printf@plt>
mov    -0x424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
jmp    1266 <main+0xf6>
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%r14
lea    0x10(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    0x8(%r14),%rdi
lea    0xe57(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1238 <main+0xb8>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    11fb <main+0x7b>
lea    0xf(%rsp),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
movzbl 0xf(%rsp),%eax
addl   $0x1,0x10(%rsp,%rax,4)
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
je     11d0 <main+0x50>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %ebx,%ebx
lea    0xdf6(%rip),%r14
nopl   0x0(%rax)
mov    0x10(%rsp,%rbx,4),%edx
mov    %r14,%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1210 <main+0x90>
xor    %eax,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r14
ret
mov    0x8(%r14),%rdi
call   1090 <perror@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"%i %i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8
%8 = alloca [255 x i32]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %9
br label %10
10: ; preds = %17, %2
%11 = load i32, i32* %9
%12 = icmp sle i32 %11, 255
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i32, i32* %9
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [255 x i32], [255 x i32]* %8, i64 0, i64 %15
store i32 0, i32* %16
br label %17
17: ; preds = %13
%18 = load i32, i32* %9
%19 = add nsw i32 %18, 1
store i32 %19, i32* %9
br label %10
20: ; preds = %10
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %24, i32** %6
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %32
26: ; preds = %20
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @perror(i8* %29)
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %20
br label %33
33: ; preds = %38, %32
%34 = load i32*, i32** %6
%35 = call i32 @feof(i32* %34)
%36 = icmp ne i32 %35, 0
%37 = xor i1 %36, true
br i1 %37, label %38, label %46
38: ; preds = %33
%39 = load i32*, i32** %6
%40 = call i32 @fread(i8* %7, i32 1, i32 1, i32* %39)
%41 = load i8, i8* %7
%42 = zext i8 %41 to i64
%43 = getelementptr inbounds [255 x i32], [255 x i32]* %8, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = add i32 %44, 1
store i32 %45, i32* %43
br label %33
46: ; preds = %33
%47 = load i32*, i32** %6
%48 = call i32 @fclose(i32* %47)
store i32 0, i32* %9
br label %49
49: ; preds = %59, %46
%50 = load i32, i32* %9
%51 = icmp sle i32 %50, 255
br i1 %51, label %52, label %62
52: ; preds = %49
%53 = load i32, i32* %9
%54 = load i32, i32* %9
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [255 x i32], [255 x i32]* %8, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %53, i32 %57)
br label %59
59: ; preds = %52
%60 = load i32, i32* %9
%61 = add nsw i32 %60, 1
store i32 %61, i32* %9
br label %49
62: ; preds = %49
%63 = load i32, i32* %3
ret i32 %63
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [7 x i8] c"%i %i\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca [255 x i32]
%5 = bitcast [255 x i32]* %4 to i8*
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = tail call i32 @feof(i32* %8)
%12 = icmp eq i32 %11, 0
br i1 %12, label %17, label %26
13: ; preds = %2
%14 = load i8*, i8** %6
%15 = tail call i32 @perror(i8* %14)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %10, %17
%18 = call i32 @fread(i8* %3, i32 1, i32 1, i32* %8)
%19 = load i8, i8* %3
%20 = zext i8 %19 to i64
%21 = getelementptr inbounds [255 x i32], [255 x i32]* %4, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = add i32 %22, 1
store i32 %23, i32* %21
%24 = tail call i32 @feof(i32* %8)
%25 = icmp eq i32 %24, 0
br i1 %25, label %17, label %26
26: ; preds = %17, %10
%27 = tail call i32 @fclose(i32* %8)
br label %28
28: ; preds = %26, %28
%29 = phi i64 [ 0, %26 ], [ %34, %28 ]
%30 = getelementptr inbounds [255 x i32], [255 x i32]* %4, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = trunc i64 %29 to i32
%33 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %32, i32 %31)
%34 = add nuw nsw i64 %29, 1
%35 = icmp eq i64 %34, 256
br i1 %35, label %36, label %28
36: ; preds = %28
ret i32 0
}