#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 sqrt(float);
void calc_freq(int *dest) {
  float tmp_out[257];
  int i;
  for (i = 0; i < 256; i++)
    dest[i] = sqrt(tmp_out[i]);
}


x86 assembly (clang, -O0):
<calc_freq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x414(%rbp)
cmpl   $0x100,-0x414(%rbp)
jge    1172 <calc_freq+0x62>
movslq -0x414(%rbp),%rax
movss  -0x410(%rbp,%rax,4),%xmm0
ff ff
call   1030 <sqrt@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x414(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    1129 <calc_freq+0x19>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_freq>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%r14
xor    %ebx,%ebx
nop
movss  (%rsp,%rbx,4),%xmm0
call   1030 <sqrt@plt>
mov    %eax,(%r14,%rbx,4)
movss  0x4(%rsp,%rbx,4),%xmm0
call   1030 <sqrt@plt>
mov    %eax,0x4(%r14,%rbx,4)
movss  0x8(%rsp,%rbx,4),%xmm0
call   1030 <sqrt@plt>
mov    %eax,0x8(%r14,%rbx,4)
movss  0xc(%rsp,%rbx,4),%xmm0
call   1030 <sqrt@plt>
mov    %eax,0xc(%r14,%rbx,4)
add    $0x4,%rbx
cmp    $0x100,%rbx
jne    1120 <calc_freq+0x10>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @calc_freq(i32* %0) {
%2 = alloca i32*
%3 = alloca [257 x float]
%4 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %4
br label %5
5: ; preds = %18, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 256
br i1 %7, label %8, label %21
8: ; preds = %5
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [257 x float], [257 x float]* %3, i64 0, i64 %10
%12 = load float, float* %11
%13 = call i32 @sqrt(float %12)
%14 = load i32*, i32** %2
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
store i32 %13, i32* %17
br label %18
18: ; preds = %8
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %5
21: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @calc_freq(i32* nocapture writeonly %0) {
%2 = alloca [257 x float]
%3 = bitcast [257 x float]* %2 to i8*
br label %4
4: ; preds = %4, %1
%5 = phi i64 [ 0, %1 ], [ %25, %4 ]
%6 = getelementptr inbounds [257 x float], [257 x float]* %2, i64 0, i64 %5
%7 = load float, float* %6
%8 = tail call i32 @sqrt(float %7)
%9 = getelementptr inbounds i32, i32* %0, i64 %5
store i32 %8, i32* %9
%10 = or i64 %5, 1
%11 = getelementptr inbounds [257 x float], [257 x float]* %2, i64 0, i64 %10
%12 = load float, float* %11
%13 = tail call i32 @sqrt(float %12)
%14 = getelementptr inbounds i32, i32* %0, i64 %10
store i32 %13, i32* %14
%15 = or i64 %5, 2
%16 = getelementptr inbounds [257 x float], [257 x float]* %2, i64 0, i64 %15
%17 = load float, float* %16
%18 = tail call i32 @sqrt(float %17)
%19 = getelementptr inbounds i32, i32* %0, i64 %15
store i32 %18, i32* %19
%20 = or i64 %5, 3
%21 = getelementptr inbounds [257 x float], [257 x float]* %2, i64 0, i64 %20
%22 = load float, float* %21
%23 = tail call i32 @sqrt(float %22)
%24 = getelementptr inbounds i32, i32* %0, i64 %20
store i32 %23, i32* %24
%25 = add nuw nsw i64 %5, 4
%26 = icmp eq i64 %25, 256
br i1 %26, label %27, label %4
27: ; preds = %4
ret void
}