#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 EOF;
int fgetc(int /*<<< orphan*/ *);
void getFrequency(int *frequency, FILE *file) {
  int finished = 0;
  int ch;
  frequency[4]++;
  while (finished != 1) {
    ch = fgetc(file);
    if (ch == EOF) {
      finished = 1;
    } else {
      frequency[ch]++;
    }
  }
  for (int iii = 0; iii < 256; iii++) {
    frequency[iii] *= 1000;
    if (frequency[iii] == 0) {
      frequency[iii] = 1;
    }
  }
}


x86 assembly (clang, -O0):
<getFrequency>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%ecx
add    $0x1,%ecx
mov    %ecx,0x10(%rax)
cmpl   $0x1,-0x14(%rbp)
je     117e <getFrequency+0x6e>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e94(%rip),%rcx
cmp    (%rcx),%eax
jne    1168 <getFrequency+0x58>
movl   $0x1,-0x14(%rbp)
jmp    1179 <getFrequency+0x69>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
jmp    1134 <getFrequency+0x24>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x100,-0x1c(%rbp)
jge    11d8 <getFrequency+0xc8>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x3e8,(%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    11c5 <getFrequency+0xb5>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movl   $0x1,(%rax,%rcx,4)
jmp    11ca <getFrequency+0xba>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1185 <getFrequency+0x75>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getFrequency>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x4,%ecx
mov    0x2ec1(%rip),%r15
nopw   0x0(%rax,%rax,1)
addl   $0x1,(%rbx,%rcx,4)
mov    %r14,%rdi
call   1030 <fgetc@plt>
movslq %eax,%rcx
cmp    (%r15),%eax
jne    1130 <getFrequency+0x20>
xor    %eax,%eax
movdqa 0xeb2(%rip),%xmm0
pxor   %xmm8,%xmm8
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movdqu (%rbx,%rax,4),%xmm4
movdqu 0x10(%rbx,%rax,4),%xmm5
movdqu 0x20(%rbx,%rax,4),%xmm3
movdqu 0x30(%rbx,%rax,4),%xmm2
movdqa %xmm4,%xmm6
pmuludq %xmm0,%xmm6
pshufd $0xe8,%xmm6,%xmm6
pshufd $0xf5,%xmm4,%xmm7
pmuludq %xmm0,%xmm7
pshufd $0xe8,%xmm7,%xmm7
punpckldq %xmm7,%xmm6
movdqa %xmm5,%xmm7
pmuludq %xmm0,%xmm7
pshufd $0xe8,%xmm7,%xmm7
pshufd $0xf5,%xmm5,%xmm1
pmuludq %xmm0,%xmm1
pshufd $0xe8,%xmm1,%xmm1
punpckldq %xmm1,%xmm7
pcmpeqd %xmm8,%xmm4
pcmpeqd %xmm8,%xmm5
movdqa %xmm4,%xmm1
pandn  %xmm6,%xmm1
psubd  %xmm4,%xmm1
movdqa %xmm5,%xmm4
pandn  %xmm7,%xmm4
psubd  %xmm5,%xmm4
movdqu %xmm1,(%rbx,%rax,4)
movdqu %xmm4,0x10(%rbx,%rax,4)
movdqa %xmm3,%xmm1
pmuludq %xmm0,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pshufd $0xf5,%xmm3,%xmm4
pmuludq %xmm0,%xmm4
pshufd $0xe8,%xmm4,%xmm4
punpckldq %xmm4,%xmm1
movdqa %xmm2,%xmm4
pmuludq %xmm0,%xmm4
pshufd $0xe8,%xmm4,%xmm4
pshufd $0xf5,%xmm2,%xmm5
pmuludq %xmm0,%xmm5
pshufd $0xe8,%xmm5,%xmm5
punpckldq %xmm5,%xmm4
pcmpeqd %xmm8,%xmm3
pcmpeqd %xmm8,%xmm2
movdqa %xmm3,%xmm5
pandn  %xmm1,%xmm5
psubd  %xmm3,%xmm5
movdqa %xmm2,%xmm1
pandn  %xmm4,%xmm1
psubd  %xmm2,%xmm1
movdqu %xmm5,0x20(%rbx,%rax,4)
movdqu %xmm1,0x30(%rbx,%rax,4)
add    $0x10,%rax
cmp    $0x100,%rax
jne    1160 <getFrequency+0x50>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i32 0
define void @getFrequency(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
%8 = load i32*, i32** %3
%9 = getelementptr inbounds i32, i32* %8, i64 4
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 1
store i32 %11, i32* %9
br label %12
12: ; preds = %29, %2
%13 = load i32, i32* %5
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %30
15: ; preds = %12
%16 = load i32*, i32** %4
%17 = call i32 @fgetc(i32* %16)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = load i32, i32* @EOF
%20 = icmp eq i32 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %15
store i32 1, i32* %5
br label %29
22: ; preds = %15
%23 = load i32*, i32** %3
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
%27 = load i32, i32* %26
%28 = add nsw i32 %27, 1
store i32 %28, i32* %26
br label %29
29: ; preds = %22, %21
br label %12
30: ; preds = %12
store i32 0, i32* %7
br label %31
31: ; preds = %53, %30
%32 = load i32, i32* %7
%33 = icmp slt i32 %32, 256
br i1 %33, label %34, label %56
34: ; preds = %31
%35 = load i32*, i32** %3
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
%40 = mul nsw i32 %39, 1000
store i32 %40, i32* %38
%41 = load i32*, i32** %3
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
%45 = load i32, i32* %44
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %52
47: ; preds = %34
%48 = load i32*, i32** %3
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i32, i32* %48, i64 %50
store i32 1, i32* %51
br label %52
52: ; preds = %47, %34
br label %53
53: ; preds = %52
%54 = load i32, i32* %7
%55 = add nsw i32 %54, 1
store i32 %55, i32* %7
br label %31
56: ; preds = %31
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @getFrequency(i32* nocapture %0, i32* nocapture %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i64 [ %11, %3 ], [ 4, %2 ]
%5 = getelementptr inbounds i32, i32* %0, i64 %4
%6 = load i32, i32* %5
%7 = add nsw i32 %6, 1
store i32 %7, i32* %5
%8 = tail call i32 @fgetc(i32* %1)
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
%11 = sext i32 %8 to i64
br i1 %10, label %12, label %3
12: ; preds = %3, %12
%13 = phi i64 [ %43, %12 ], [ 0, %3 ]
%14 = getelementptr inbounds i32, i32* %0, i64 %13
%15 = bitcast i32* %14 to <4 x i32>*
%16 = load <4 x i32>, <4 x i32>* %15
%17 = getelementptr inbounds i32, i32* %14, i64 4
%18 = bitcast i32* %17 to <4 x i32>*
%19 = load <4 x i32>, <4 x i32>* %18
%20 = mul nsw <4 x i32> %16, <i32 1000, i32 1000, i32 1000, i32 1000>
%21 = mul nsw <4 x i32> %19, <i32 1000, i32 1000, i32 1000, i32 1000>
%22 = icmp eq <4 x i32> %16, zeroinitializer
%23 = icmp eq <4 x i32> %19, zeroinitializer
%24 = select <4 x i1> %22, <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> %20
%25 = select <4 x i1> %23, <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> %21
%26 = bitcast i32* %14 to <4 x i32>*
store <4 x i32> %24, <4 x i32>* %26
%27 = bitcast i32* %17 to <4 x i32>*
store <4 x i32> %25, <4 x i32>* %27
%28 = or i64 %13, 8
%29 = getelementptr inbounds i32, i32* %0, i64 %28
%30 = bitcast i32* %29 to <4 x i32>*
%31 = load <4 x i32>, <4 x i32>* %30
%32 = getelementptr inbounds i32, i32* %29, i64 4
%33 = bitcast i32* %32 to <4 x i32>*
%34 = load <4 x i32>, <4 x i32>* %33
%35 = mul nsw <4 x i32> %31, <i32 1000, i32 1000, i32 1000, i32 1000>
%36 = mul nsw <4 x i32> %34, <i32 1000, i32 1000, i32 1000, i32 1000>
%37 = icmp eq <4 x i32> %31, zeroinitializer
%38 = icmp eq <4 x i32> %34, zeroinitializer
%39 = select <4 x i1> %37, <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> %35
%40 = select <4 x i1> %38, <4 x i32> <i32 1, i32 1, i32 1, i32 1>, <4 x i32> %36
%41 = bitcast i32* %29 to <4 x i32>*
store <4 x i32> %39, <4 x i32>* %41
%42 = bitcast i32* %32 to <4 x i32>*
store <4 x i32> %40, <4 x i32>* %42
%43 = add nuw nsw i64 %13, 16
%44 = icmp eq i64 %43, 256
br i1 %44, label %45, label %12
45: ; preds = %12
ret void
}