#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 */
unsigned int EOF;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
scalar_t__ ftell(int /*<<< orphan*/ *);
unsigned int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int main(int argc, char *argv[]) {
  if (argc == 1) {
    printf("Usage: %s <filename>\n", argv[0]);
    exit(-1);
  }
  char *filename = argv[1];
  FILE *infile = fopen(filename, "rb");
  if (infile == NULL) {
    printf("Unable to open file %s\n", filename);
    exit(-1);
  } else {
    fseek(infile, 0L, SEEK_END);
    if (ftell(infile) == 0) {
      printf("Nothing to read (zero-length): %s\n", filename);
      exit(-1);
    }
    fseek(infile, 0L, SEEK_SET);
  }
  unsigned int c;
  int i;
  unsigned int uniques = 0;
  char missing[1280] = "";
  unsigned char most;
  unsigned long bytes[256];
  for (i = 0; i < 256; i++)
    bytes[i] = 0;
  while ((c = getc(infile)) != EOF)
    bytes[c]++;
  for (i = 0; i < 256; i++) {
    if (bytes[i] > 0) {
      uniques++;
      printf("Number of 0x%02Xs: %lu\n", i, bytes[i]);
    } else {
      sprintf(missing, "%s 0x%02X", missing, i);
    }
  }
  printf("\n");
  printf("Number of unique bytes: %d\n", uniques);
  if (uniques < 256)
    printf("Bytes not appearing in this file:%s\n", missing);
  else
    printf("All possible byte values exist in this file.\n");
  fclose(infile);
  exit(1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11d2 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1219 <main+0x89>
mov    -0x18(%rbp),%rsi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    0x2dc4(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1070 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1060 <ftell@plt>
cmp    $0x0,%rax
jne    125e <main+0xce>
mov    -0x18(%rbp),%rsi
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    0x2d67(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1070 <fseek@plt>
movl   $0x0,-0x2c(%rbp)
lea    -0x530(%rbp),%rdi
xor    %esi,%esi
mov    $0x500,%edx
call   1050 <memset@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x100,-0x28(%rbp)
jge    12c0 <main+0x130>
movslq -0x28(%rbp),%rax
movq   $0x0,-0xd40(%rbp,%rax,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1295 <main+0x105>
jmp    12c5 <main+0x135>
mov    -0x20(%rbp),%rdi
call   10b0 <getc@plt>
mov    %eax,-0x24(%rbp)
mov    0x2d08(%rip),%rcx
cmp    (%rcx),%eax
je     12fc <main+0x16c>
mov    -0x24(%rbp),%eax
mov    -0xd40(%rbp,%rax,8),%rcx
ff
add    $0x1,%rcx
mov    %rcx,-0xd40(%rbp,%rax,8)
ff
jmp    12c5 <main+0x135>
movl   $0x0,-0x28(%rbp)
cmpl   $0x100,-0x28(%rbp)
jge    137e <main+0x1ee>
movslq -0x28(%rbp),%rax
cmpq   $0x0,-0xd40(%rbp,%rax,8)
jbe    134e <main+0x1be>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%esi
movslq -0x28(%rbp),%rax
mov    -0xd40(%rbp,%rax,8),%rdx
ff
lea    0xd12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    136b <main+0x1db>
lea    -0x530(%rbp),%rdi
lea    -0x530(%rbp),%rdx
mov    -0x28(%rbp),%ecx
lea    0xd06(%rip),%rsi
call   1090 <sprintf@plt>
jmp    1370 <main+0x1e0>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1303 <main+0x173>
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xce0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x100,-0x2c(%rbp)
jae    13c4 <main+0x234>
lea    -0x530(%rbp),%rsi
lea    0xcda(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13d2 <main+0x242>
lea    0xcec(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd08,%rsp
cmp    $0x1,%edi
jne    11d2 <main+0x22>
mov    (%rsi),%rsi
lea    0xe30(%rip),%rdi
jmp    1220 <main+0x70>
mov    0x8(%rsi),%rbx
lea    0xe39(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
jne    11f3 <main+0x43>
lea    0xe28(%rip),%rdi
jmp    121d <main+0x6d>
mov    %rax,%r14
mov    0x2deb(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %r14,%rdi
call   1080 <ftell@plt>
test   %rax,%rax
jne    1231 <main+0x81>
lea    0xe14(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
mov    0x2d98(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rsp,%rdi
mov    $0x500,%edx
xor    %esi,%esi
call   1070 <memset@plt>
lea    0x500(%rsp),%rdi
mov    $0x800,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    %r14,%rdi
call   10d0 <getc@plt>
mov    0x2d6a(%rip),%rbx
cmp    (%rbx),%eax
je     1297 <main+0xe7>
nopw   0x0(%rax,%rax,1)
mov    %eax,%eax
addq   $0x1,0x500(%rsp,%rax,8)
mov    %r14,%rdi
call   10d0 <getc@plt>
cmp    (%rbx),%eax
jne    1280 <main+0xd0>
lea    0xdce(%rip),%r15
mov    %rsp,%r13
lea    0xdac(%rip),%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    12cd <main+0x11d>
xchg   %ax,%ax
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
mov    %ebx,%ecx
call   10b0 <sprintf@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
je     12eb <main+0x13b>
mov    0x500(%rsp,%rbx,8),%rdx
test   %rdx,%rdx
je     12b0 <main+0x100>
add    $0x1,%ebp
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    12c0 <main+0x110>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd7a(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0xff,%ebp
ja     1320 <main+0x170>
lea    0xd7e(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    132c <main+0x17c>
lea    0xd90(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Usage: %s <filename>\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [24 x i8] c"Unable to open file %s\0A\00"
@SEEK_END = global i32 0
@.str.3 = [35 x i8] c"Nothing to read (zero-length): %s\0A\00"
@SEEK_SET = global i32 0
@EOF = global i32 0
@.str.4 = [24 x i8] c"Number of 0x%02Xs: %lu\0A\00"
@.str.5 = [10 x i8] c"%s 0x%02X\00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [28 x i8] c"Number of unique bytes: %d\0A\00"
@.str.8 = [37 x i8] c"Bytes not appearing in this file:%s\0A\00"
@.str.9 = [46 x i8] c"All possible byte values exist in this file.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [1280 x i8]
%12 = alloca i8
%13 = alloca [256 x i64]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %22
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 -1)
unreachable
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
store i8* %25, i8** %6
%26 = load i8*, i8** %6
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %7
%28 = load i32*, i32** %7
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %34
30: ; preds = %22
%31 = load i8*, i8** %6
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %31)
%33 = call i32 @exit(i32 -1)
unreachable
34: ; preds = %22
%35 = load i32*, i32** %7
%36 = load i32, i32* @SEEK_END
%37 = call i32 @fseek(i32* %35, i64 0, i32 %36)
%38 = load i32*, i32** %7
%39 = call i64 @ftell(i32* %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %34
%42 = load i8*, i8** %6
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* %42)
%44 = call i32 @exit(i32 -1)
unreachable
45: ; preds = %34
%46 = load i32*, i32** %7
%47 = load i32, i32* @SEEK_SET
%48 = call i32 @fseek(i32* %46, i64 0, i32 %47)
br label %49
49: ; preds = %45
store i32 0, i32* %10
%50 = bitcast [1280 x i8]* %11 to i8*
store i32 0, i32* %9
br label %51
51: ; preds = %58, %49
%52 = load i32, i32* %9
%53 = icmp slt i32 %52, 256
br i1 %53, label %54, label %61
54: ; preds = %51
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [256 x i64], [256 x i64]* %13, i64 0, i64 %56
store i64 0, i64* %57
br label %58
58: ; preds = %54
%59 = load i32, i32* %9
%60 = add nsw i32 %59, 1
store i32 %60, i32* %9
br label %51
61: ; preds = %51
br label %62
62: ; preds = %67, %61
%63 = load i32*, i32** %7
%64 = call i32 @getc(i32* %63)
store i32 %64, i32* %8
%65 = load i32, i32* @EOF
%66 = icmp ne i32 %64, %65
br i1 %66, label %67, label %73
67: ; preds = %62
%68 = load i32, i32* %8
%69 = zext i32 %68 to i64
%70 = getelementptr inbounds [256 x i64], [256 x i64]* %13, i64 0, i64 %69
%71 = load i64, i64* %70
%72 = add i64 %71, 1
store i64 %72, i64* %70
br label %62
73: ; preds = %62
store i32 0, i32* %9
br label %74
74: ; preds = %98, %73
%75 = load i32, i32* %9
%76 = icmp slt i32 %75, 256
br i1 %76, label %77, label %101
77: ; preds = %74
%78 = load i32, i32* %9
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [256 x i64], [256 x i64]* %13, i64 0, i64 %79
%81 = load i64, i64* %80
%82 = icmp ugt i64 %81, 0
br i1 %82, label %83, label %92
83: ; preds = %77
%84 = load i32, i32* %10
%85 = add i32 %84, 1
store i32 %85, i32* %10
%86 = load i32, i32* %9
%87 = load i32, i32* %9
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [256 x i64], [256 x i64]* %13, i64 0, i64 %88
%90 = load i64, i64* %89
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %86, i64 %90)
br label %97
92: ; preds = %77
%93 = getelementptr inbounds [1280 x i8], [1280 x i8]* %11, i64 0, i64 0
%94 = getelementptr inbounds [1280 x i8], [1280 x i8]* %11, i64 0, i64 0
%95 = load i32, i32* %9
%96 = call i32 @sprintf(i8* %93, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %94, i32 %95)
br label %97
97: ; preds = %92, %83
br label %98
98: ; preds = %97
%99 = load i32, i32* %9
%100 = add nsw i32 %99, 1
store i32 %100, i32* %9
br label %74
101: ; preds = %74
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%103 = load i32, i32* %10
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 %103)
%105 = load i32, i32* %10
%106 = icmp ult i32 %105, 256
br i1 %106, label %107, label %110
107: ; preds = %101
%108 = getelementptr inbounds [1280 x i8], [1280 x i8]* %11, i64 0, i64 0
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %108)
br label %112
110: ; preds = %101
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.9, i64 0, i64 0))
br label %112
112: ; preds = %110, %107
%113 = load i32*, i32** %7
%114 = call i32 @fclose(i32* %113)
%115 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [22 x i8] c"Usage: %s <filename>\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [24 x i8] c"Unable to open file %s\0A\00"
@SEEK_END = global i32 0
@.str.3 = [35 x i8] c"Nothing to read (zero-length): %s\0A\00"
@SEEK_SET = global i32 0
@EOF = global i32 0
@.str.4 = [24 x i8] c"Number of 0x%02Xs: %lu\0A\00"
@.str.5 = [10 x i8] c"%s 0x%02X\00"
@.str.7 = [28 x i8] c"Number of unique bytes: %d\0A\00"
@.str.8 = [37 x i8] c"Bytes not appearing in this file:%s\0A\00"
@str = [45 x i8] c"All possible byte values exist in this file.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1280 x i8]
%4 = alloca [256 x i64]
%5 = bitcast [256 x i64]* %4 to i8*
%6 = icmp eq i32 %0, 1
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 -1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%18 = tail call i32 @exit(i32 -1)
unreachable
19: ; preds = %11
%20 = load i32, i32* @SEEK_END
%21 = tail call i32 @fseek(i32* %14, i64 0, i32 %20)
%22 = tail call i64 @ftell(i32* %14)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%26 = tail call i32 @exit(i32 -1)
unreachable
27: ; preds = %19
%28 = load i32, i32* @SEEK_SET
%29 = tail call i32 @fseek(i32* %14, i64 0, i32 %28)
%30 = getelementptr inbounds [1280 x i8], [1280 x i8]* %3, i64 0, i64 0
%31 = tail call i32 @getc(i32* %14)
%32 = load i32, i32* @EOF
%33 = icmp eq i32 %31, %32
br i1 %33, label %43, label %34
34: ; preds = %27, %34
%35 = phi i32 [ %40, %34 ], [ %31, %27 ]
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds [256 x i64], [256 x i64]* %4, i64 0, i64 %36
%38 = load i64, i64* %37
%39 = add i64 %38, 1
store i64 %39, i64* %37
%40 = tail call i32 @getc(i32* %14)
%41 = load i32, i32* @EOF
%42 = icmp eq i32 %40, %41
br i1 %42, label %43, label %34
43: ; preds = %34, %27
br label %44
44: ; preds = %43, %57
%45 = phi i64 [ %59, %57 ], [ 0, %43 ]
%46 = phi i32 [ %58, %57 ], [ 0, %43 ]
%47 = getelementptr inbounds [256 x i64], [256 x i64]* %4, i64 0, i64 %45
%48 = load i64, i64* %47
%49 = icmp eq i64 %48, 0
br i1 %49, label %54, label %50
50: ; preds = %44
%51 = add i32 %46, 1
%52 = trunc i64 %45 to i32
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %52, i64 %48)
br label %57
54: ; preds = %44
%55 = trunc i64 %45 to i32
%56 = call i32 @sprintf(i8* %30, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %30, i32 %55)
br label %57
57: ; preds = %50, %54
%58 = phi i32 [ %51, %50 ], [ %46, %54 ]
%59 = add nuw nsw i64 %45, 1
%60 = icmp eq i64 %59, 256
br i1 %60, label %61, label %44
61: ; preds = %57
%62 = call i32 @putchar(i32 10)
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 %58)
%64 = icmp ult i32 %58, 256
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %30)
br label %69
67: ; preds = %61
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
br label %69
69: ; preds = %67, %65
%70 = call i32 @fclose(i32* %14)
%71 = call i32 @exit(i32 1)
unreachable
}