#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 */
float *malloc(int);
float *freq_table(int *count_table, int total) {
  int i;
  float *result = malloc(256 * sizeof(float));
  for (i = 0; i < 256; ++i) {
    if (count_table[i] == 0) {
      result[i] = -1.0;
    } else {
      result[i] = (float)count_table[i] / total;
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<freq_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x400,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x100,-0x10(%rbp)
jge    11a3 <freq_table+0x93>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    116d <freq_table+0x5d>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  0xe9d(%rip),%xmm0
movss  %xmm0,(%rax,%rcx,4)
jmp    1190 <freq_table+0x80>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cvtsi2ssl (%rax,%rcx,4),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
jmp    1195 <freq_table+0x85>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <freq_table+0x24>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<freq_table>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    $0x400,%edi
call   1030 <malloc@plt>
cvtsi2ss %ebp,%xmm0
shufps $0x0,%xmm0,%xmm0
mov    $0x4,%ecx
pxor   %xmm1,%xmm1
movdqa 0xec5(%rip),%xmm2
nopl   0x0(%rax,%rax,1)
movups -0x10(%rbx,%rcx,4),%xmm3
cvtdq2ps %xmm3,%xmm4
pcmpeqd %xmm1,%xmm3
divps  %xmm0,%xmm4
movdqa %xmm2,%xmm5
pand   %xmm3,%xmm5
pandn  %xmm4,%xmm3
por    %xmm5,%xmm3
movdqu %xmm3,-0x10(%rax,%rcx,4)
movups (%rbx,%rcx,4),%xmm3
cvtdq2ps %xmm3,%xmm4
pcmpeqd %xmm1,%xmm3
divps  %xmm0,%xmm4
movdqa %xmm2,%xmm5
pand   %xmm3,%xmm5
pandn  %xmm4,%xmm3
por    %xmm5,%xmm3
movdqu %xmm3,(%rax,%rcx,4)
add    $0x8,%rcx
cmp    $0x104,%rcx
jne    1140 <freq_table+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define float* @freq_table(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca float*
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = call float* @malloc(i32 1024)
store float* %7, float** %6
store i32 0, i32* %5
br label %8
8: ; preds = %38, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 256
br i1 %10, label %11, label %41
11: ; preds = %8
%12 = load i32*, i32** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32, i32* %15
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %11
%19 = load float*, float** %6
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds float, float* %19, i64 %21
store float -1.000000e+00, float* %22
br label %37
23: ; preds = %11
%24 = load i32*, i32** %3
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = sitofp i32 %28 to float
%30 = load i32, i32* %4
%31 = sitofp i32 %30 to float
%32 = fdiv float %29, %31
%33 = load float*, float** %6
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds float, float* %33, i64 %35
store float %32, float* %36
br label %37
37: ; preds = %23, %18
br label %38
38: ; preds = %37
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %8
41: ; preds = %8
%42 = load float*, float** %6
ret float* %42
}

LLVM IR (-O2):
define noalias float* @freq_table(i32* nocapture %0, i32 %1) {
%3 = tail call float* @malloc(i32 1024)
%4 = sitofp i32 %1 to float
%5 = insertelement <4 x float> poison, float %4, i64 0
%6 = shufflevector <4 x float> %5, <4 x float> poison, <4 x i32> zeroinitializer
br label %7
7: ; preds = %7, %2
%8 = phi i64 [ 0, %2 ], [ %28, %7 ]
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = bitcast i32* %9 to <4 x i32>*
%11 = load <4 x i32>, <4 x i32>* %10
%12 = icmp eq <4 x i32> %11, zeroinitializer
%13 = sitofp <4 x i32> %11 to <4 x float>
%14 = fdiv <4 x float> %13, %6
%15 = select <4 x i1> %12, <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, <4 x float> %14
%16 = getelementptr inbounds float, float* %3, i64 %8
%17 = bitcast float* %16 to <4 x float>*
store <4 x float> %15, <4 x float>* %17
%18 = or i64 %8, 4
%19 = getelementptr inbounds i32, i32* %0, i64 %18
%20 = bitcast i32* %19 to <4 x i32>*
%21 = load <4 x i32>, <4 x i32>* %20
%22 = icmp eq <4 x i32> %21, zeroinitializer
%23 = sitofp <4 x i32> %21 to <4 x float>
%24 = fdiv <4 x float> %23, %6
%25 = select <4 x i1> %22, <4 x float> <float -1.000000e+00, float -1.000000e+00, float -1.000000e+00, float -1.000000e+00>, <4 x float> %24
%26 = getelementptr inbounds float, float* %3, i64 %18
%27 = bitcast float* %26 to <4 x float>*
store <4 x float> %25, <4 x float>* %27
%28 = add nuw nsw i64 %8, 8
%29 = icmp eq i64 %28, 256
br i1 %29, label %30, label %7
30: ; preds = %7
ret float* %3
}