#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 getc(int /*<<< orphan*/ *);
int *get_file_frequencies(FILE *file, int frequencies[]) {
  int c;
  for (c = 0; c < 256; c++)
    frequencies[c] = 0;
  while (c = getc(file), c != EOF)
    frequencies[c]++;
  return frequencies;
}


x86 assembly (clang, -O0):
<get_file_frequencies>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    1151 <get_file_frequencies+0x41>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <get_file_frequencies+0x17>
jmp    1156 <get_file_frequencies+0x46>
mov    -0x8(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e7c(%rip),%rcx
cmp    (%rcx),%eax
je     118a <get_file_frequencies+0x7a>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
jmp    1156 <get_file_frequencies+0x46>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_file_frequencies>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0x400,%edx
mov    %rsi,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    %r14,%rdi
call   1040 <getc@plt>
mov    0x2e9f(%rip),%r15
cmp    (%r15),%eax
je     1163 <get_file_frequencies+0x43>
xchg   %ax,%ax
cltq
addl   $0x1,(%rbx,%rax,4)
mov    %r14,%rdi
call   1040 <getc@plt>
cmp    (%r15),%eax
jne    1150 <get_file_frequencies+0x30>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32* @get_file_frequencies(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %5
br label %6
6: ; preds = %14, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 256
br i1 %8, label %9, label %17
9: ; preds = %6
%10 = load i32*, i32** %4
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %10, i64 %12
store i32 0, i32* %13
br label %14
14: ; preds = %9
%15 = load i32, i32* %5
%16 = add nsw i32 %15, 1
store i32 %16, i32* %5
br label %6
17: ; preds = %6
br label %18
18: ; preds = %24, %17
%19 = load i32*, i32** %3
%20 = call i32 @getc(i32* %19)
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = load i32, i32* @EOF
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %31
24: ; preds = %18
%25 = load i32*, i32** %4
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1
store i32 %30, i32* %28
br label %18
31: ; preds = %18
%32 = load i32*, i32** %4
ret i32* %32
}

LLVM IR (-O2):
@EOF = global i32 0
define i32* @get_file_frequencies(i32* nocapture %0, i32* returned %1) {
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @getc(i32* %0)
%5 = load i32, i32* @EOF
%6 = icmp eq i32 %4, %5
br i1 %6, label %16, label %7
7: ; preds = %2, %7
%8 = phi i32 [ %13, %7 ], [ %4, %2 ]
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i32, i32* %1, i64 %9
%11 = load i32, i32* %10
%12 = add nsw i32 %11, 1
store i32 %12, i32* %10
%13 = tail call i32 @getc(i32* %0)
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %7
16: ; preds = %7, %2
ret i32* %1
}