#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);
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    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x424(%rbp)
cmpl   $0x100,-0x424(%rbp)
jge    1172 <calc_freq+0x62>
movslq -0x424(%rbp),%rax
movss  -0x420(%rbp,%rax,4),%xmm0
ff ff
call   1030 <sqrt@plt>
mov    %eax,%edx
mov    -0x10(%rbp),%rax
movslq -0x424(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x424(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x424(%rbp)
jmp    1129 <calc_freq+0x19>
mov    -0x4(%rbp),%eax
add    $0x430,%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 i32 @calc_freq(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [257 x float]
%5 = alloca i32
store i32* %0, i32** %3
store i32 0, i32* %5
br label %6
6: ; preds = %19, %1
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 256
br i1 %8, label %9, label %22
9: ; preds = %6
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [257 x float], [257 x float]* %4, i64 0, i64 %11
%13 = load float, float* %12
%14 = call i32 @sqrt(float %13)
%15 = load i32*, i32** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
store i32 %14, i32* %18
br label %19
19: ; preds = %9
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %6
22: ; preds = %6
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
define i32 @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 i32 undef
}