#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int get_freq(int, int);
int /*<<< orphan*/ stderr;
void get_character_counts(int fd, int freq[256], int num_bytes,
                          unsigned char bit_vector[32],
                          const char *const ASCII[]) {
  int i = 0;
  for (i = 0; i < 256; i++) {
    if ((bit_vector[i / 8] >> (i % 8)) & 0x01) {
      if (i < 33) {
        fprintf(stderr, "Character %3s (0x%02x) is in the file\n", ASCII[i], i);
      } else if (i < 127) {
        fprintf(stderr, "Character %3c (0x%x) is in the file\n", i, i);
      } else if (i == 127) {
        fprintf(stderr, "Character DEL (0x%x) is in the file\n", i);
      } else {
        fprintf(stderr, "Character     (0x%x) is in the file\n", i);
      }
      freq[i] = get_freq(fd, num_bytes);
    }
  }
  fprintf(stderr, "Each char frequency count will be %d %s long\n", num_bytes,
          (num_bytes == 1) ? "byte" : "bytes");
  return;
}


x86 assembly (clang, -O0):
<get_character_counts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x100,-0x2c(%rbp)
jge    126f <get_character_counts+0x14f>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x30(%rbp),%eax
mov    %edx,%ecx
sar    %cl,%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     125c <get_character_counts+0x13c>
cmpl   $0x21,-0x2c(%rbp)
jge    11cb <get_character_counts+0xab>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x2c(%rbp),%ecx
lea    0xe41(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1244 <get_character_counts+0x124>
cmpl   $0x7f,-0x2c(%rbp)
jge    11f7 <get_character_counts+0xd7>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
mov    -0x2c(%rbp),%ecx
lea    0xe3c(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    123f <get_character_counts+0x11f>
cmpl   $0x7f,-0x2c(%rbp)
jne    1220 <get_character_counts+0x100>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xe38(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    123a <get_character_counts+0x11a>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    123f <get_character_counts+0x11f>
jmp    1244 <get_character_counts+0x124>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <get_freq@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1261 <get_character_counts+0x141>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1148 <get_character_counts+0x28>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x14(%rbp),%esi
lea    0xe44(%rip),%rcx
lea    0xe38(%rip),%rax
cmp    $0x1,%esi
cmove  %rax,%rcx
lea    0xdfc(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_character_counts>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,(%rsp)
mov    %rcx,%rbx
mov    %edx,%r15d
mov    %rsi,%r12
mov    %edi,%ebp
mov    0x2e9f(%rip),%r14
xor    %r13d,%r13d
jmp    1187 <get_character_counts+0x67>
cs nopw 0x0(%rax,%rax,1)
mov    (%r14),%edi
mov    (%rsp),%rax
mov    (%rax,%r13,8),%rdx
lea    0xe9e(%rip),%rsi
mov    %r13d,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %ebp,%edi
mov    %r15d,%esi
call   1040 <get_freq@plt>
mov    %eax,(%r12,%r13,4)
add    $0x1,%r13
cmp    $0x100,%r13
je     11f1 <get_character_counts+0xd1>
mov    %r13d,%eax
shr    $0x3,%eax
movzbl (%rbx,%rax,1),%eax
mov    %r13d,%ecx
and    $0x7,%cl
movzbl %cl,%ecx
bt     %ecx,%eax
jae    117a <get_character_counts+0x5a>
cmp    $0x20,%r13
jbe    1150 <get_character_counts+0x30>
cmp    $0x7e,%r13
ja     11c4 <get_character_counts+0xa4>
mov    (%r14),%edi
lea    0xe72(%rip),%rsi
mov    %r13d,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    116c <get_character_counts+0x4c>
mov    (%r14),%edi
cmp    $0x7f,%r13
jne    11db <get_character_counts+0xbb>
lea    0xe78(%rip),%rsi
mov    $0x7f,%edx
jmp    11e5 <get_character_counts+0xc5>
lea    0xe8f(%rip),%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    116c <get_character_counts+0x4c>
mov    (%r14),%edi
cmp    $0x1,%r15d
lea    0xec5(%rip),%rax
lea    0xec3(%rip),%rcx
cmove  %rax,%rcx
lea    0xe85(%rip),%rsi
mov    %r15d,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"Character %3s (0x%02x) is in the file\0A\00"
@.str.1 = [37 x i8] c"Character %3c (0x%x) is in the file\0A\00"
@.str.2 = [37 x i8] c"Character DEL (0x%x) is in the file\0A\00"
@.str.3 = [37 x i8] c"Character (0x%x) is in the file\0A\00"
@.str.4 = [46 x i8] c"Each char frequency count will be %d %s long\0A\00"
@.str.5 = [5 x i8] c"byte\00"
@.str.6 = [6 x i8] c"bytes\00"
define void @get_character_counts(i32 %0, i32* %1, i32 %2, i8* %3, i8** %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8**
%11 = alloca i32
store i32 %0, i32* %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i8** %4, i8*** %10
store i32 0, i32* %11
store i32 0, i32* %11
br label %12
12: ; preds = %70, %5
%13 = load i32, i32* %11
%14 = icmp slt i32 %13, 256
br i1 %14, label %15, label %73
15: ; preds = %12
%16 = load i8*, i8** %9
%17 = load i32, i32* %11
%18 = sdiv i32 %17, 8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = load i32, i32* %11
%24 = srem i32 %23, 8
%25 = ashr i32 %22, %24
%26 = and i32 %25, 1
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %69
28: ; preds = %15
%29 = load i32, i32* %11
%30 = icmp slt i32 %29, 33
br i1 %30, label %31, label %40
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = load i8**, i8*** %10
%34 = load i32, i32* %11
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8*, i8** %33, i64 %35
%37 = load i8*, i8** %36
%38 = load i32, i32* %11
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %37, i32 %38)
br label %61
40: ; preds = %28
%41 = load i32, i32* %11
%42 = icmp slt i32 %41, 127
br i1 %42, label %43, label %48
43: ; preds = %40
%44 = load i32, i32* @stderr
%45 = load i32, i32* %11
%46 = load i32, i32* %11
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %45, i32 %46)
br label %60
48: ; preds = %40
%49 = load i32, i32* %11
%50 = icmp eq i32 %49, 127
br i1 %50, label %51, label %55
51: ; preds = %48
%52 = load i32, i32* @stderr
%53 = load i32, i32* %11
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %53)
br label %59
55: ; preds = %48
%56 = load i32, i32* @stderr
%57 = load i32, i32* %11
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %57)
br label %59
59: ; preds = %55, %51
br label %60
60: ; preds = %59, %43
br label %61
61: ; preds = %60, %31
%62 = load i32, i32* %6
%63 = load i32, i32* %8
%64 = call i32 @get_freq(i32 %62, i32 %63)
%65 = load i32*, i32** %7
%66 = load i32, i32* %11
%67 = sext i32 %66 to i64
%68 = getelementptr inbounds i32, i32* %65, i64 %67
store i32 %64, i32* %68
br label %69
69: ; preds = %61, %15
br label %70
70: ; preds = %69
%71 = load i32, i32* %11
%72 = add nsw i32 %71, 1
store i32 %72, i32* %11
br label %12
73: ; preds = %12
%74 = load i32, i32* @stderr
%75 = load i32, i32* %8
%76 = load i32, i32* %8
%77 = icmp eq i32 %76, 1
%78 = zext i1 %77 to i64
%79 = select i1 %77, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0)
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i32 %75, i8* %79)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"Character %3s (0x%02x) is in the file\0A\00"
@.str.1 = [37 x i8] c"Character %3c (0x%x) is in the file\0A\00"
@.str.2 = [37 x i8] c"Character DEL (0x%x) is in the file\0A\00"
@.str.3 = [37 x i8] c"Character (0x%x) is in the file\0A\00"
@.str.4 = [46 x i8] c"Each char frequency count will be %d %s long\0A\00"
@.str.5 = [5 x i8] c"byte\00"
@.str.6 = [6 x i8] c"bytes\00"
define void @get_character_counts(i32 %0, i32* nocapture writeonly %1, i32 %2, i8* nocapture %3, i8** nocapture %4) {
br label %6
6: ; preds = %5, %40
%7 = phi i64 [ 0, %5 ], [ %41, %40 ]
%8 = trunc i64 %7 to i32
%9 = lshr i64 %7, 3
%10 = and i64 %9, 536870911
%11 = getelementptr inbounds i8, i8* %3, i64 %10
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = and i32 %8, 7
%15 = shl nuw nsw i32 1, %14
%16 = and i32 %15, %13
%17 = icmp eq i32 %16, 0
br i1 %17, label %40, label %18
18: ; preds = %6
%19 = icmp ult i64 %7, 33
br i1 %19, label %20, label %25
20: ; preds = %18
%21 = load i32, i32* @stderr
%22 = getelementptr inbounds i8*, i8** %4, i64 %7
%23 = load i8*, i8** %22
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %23, i32 %8)
br label %37
25: ; preds = %18
%26 = icmp ult i64 %7, 127
br i1 %26, label %27, label %30
27: ; preds = %25
%28 = load i32, i32* @stderr
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %8)
br label %37
30: ; preds = %25
%31 = icmp eq i64 %7, 127
%32 = load i32, i32* @stderr
br i1 %31, label %33, label %35
33: ; preds = %30
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 127)
br label %37
35: ; preds = %30
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %8)
br label %37
37: ; preds = %27, %35, %33, %20
%38 = tail call i32 @get_freq(i32 %0, i32 %2)
%39 = getelementptr inbounds i32, i32* %1, i64 %7
store i32 %38, i32* %39
br label %40
40: ; preds = %6, %37
%41 = add nuw nsw i64 %7, 1
%42 = icmp eq i64 %41, 256
br i1 %42, label %43, label %6
43: ; preds = %40
%44 = load i32, i32* @stderr
%45 = icmp eq i32 %2, 1
%46 = select i1 %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0)
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i32 %2, i8* %46)
ret void
}