#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 */
scalar_t__ malloc(int);
float sqrt(float);
float *compute_sqrts(float *input_array, int length) {
  int i;
  float *output_array = (float *)malloc(length * sizeof(float));
  for (i = 0; i < length; i++) {
    output_array[i] = sqrt(input_array[i]);
  }
  return output_array;
}


x86 assembly (clang, -O0):
<compute_sqrts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1182 <compute_sqrts+0x62>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1040 <sqrt@plt>
mov    -0x18(%rbp),%rax
movslq -0x10(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1149 <compute_sqrts+0x29>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_sqrts>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r13
lea    0x0(,%r15,4),%edi
call   1030 <malloc@plt>
mov    %rax,%r14
test   %r15d,%r15d
jle    1199 <compute_sqrts+0x79>
mov    %r15d,%r12d
lea    -0x1(%r12),%rax
mov    %r12d,%r15d
and    $0x3,%r15d
cmp    $0x3,%rax
jae    11a6 <compute_sqrts+0x86>
xor    %ebx,%ebx
test   %r15,%r15
je     1199 <compute_sqrts+0x79>
lea    (%r14,%rbx,4),%r12
lea    0x0(%r13,%rbx,4),%r13
xor    %ebx,%ebx
xorps  %xmm1,%xmm1
jmp    1187 <compute_sqrts+0x67>
call   1040 <sqrt@plt>
xorps  %xmm1,%xmm1
movss  %xmm0,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r15
je     1199 <compute_sqrts+0x79>
movss  0x0(%r13,%rbx,4),%xmm0
ucomiss %xmm1,%xmm0
jb     1170 <compute_sqrts+0x50>
sqrtss %xmm0,%xmm0
jmp    1178 <compute_sqrts+0x58>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
and    $0xfffffffc,%r12d
xor    %ebx,%ebx
xorps  %xmm1,%xmm1
jmp    11d8 <compute_sqrts+0xb8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1040 <sqrt@plt>
xorps  %xmm1,%xmm1
movss  %xmm0,0xc(%r14,%rbx,4)
add    $0x4,%rbx
cmp    %rbx,%r12
je     115b <compute_sqrts+0x3b>
movss  0x0(%r13,%rbx,4),%xmm0
ucomiss %xmm1,%xmm0
jb     11f0 <compute_sqrts+0xd0>
sqrtss %xmm0,%xmm0
jmp    11f8 <compute_sqrts+0xd8>
nopw   0x0(%rax,%rax,1)
call   1040 <sqrt@plt>
xorps  %xmm1,%xmm1
movss  %xmm0,(%r14,%rbx,4)
movss  0x4(%r13,%rbx,4),%xmm0
ucomiss %xmm1,%xmm0
jb     1210 <compute_sqrts+0xf0>
sqrtss %xmm0,%xmm0
jmp    1218 <compute_sqrts+0xf8>
call   1040 <sqrt@plt>
xorps  %xmm1,%xmm1
movss  %xmm0,0x4(%r14,%rbx,4)
movss  0x8(%r13,%rbx,4),%xmm0
ucomiss %xmm1,%xmm0
jb     1240 <compute_sqrts+0x120>
sqrtss %xmm0,%xmm0
jmp    1248 <compute_sqrts+0x128>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1040 <sqrt@plt>
xorps  %xmm1,%xmm1
movss  %xmm0,0x8(%r14,%rbx,4)
movss  0xc(%r13,%rbx,4),%xmm0
ucomiss %xmm1,%xmm0
jb     11c0 <compute_sqrts+0xa0>
sqrtss %xmm0,%xmm0
jmp    11c8 <compute_sqrts+0xa8>

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

LLVM IR (-O2):
define float* @compute_sqrts(float* nocapture %0, i32 %1) {
%3 = shl i32 %1, 2
%4 = tail call i64 @malloc(i32 %3)
%5 = inttoptr i64 %4 to float*
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %52
7: ; preds = %2
%8 = zext i32 %1 to i64
%9 = add nsw i64 %8, -1
%10 = and i64 %8, 3
%11 = icmp ult i64 %9, 3
br i1 %11, label %39, label %12
12: ; preds = %7
%13 = and i64 %8, 4294967292
br label %14
14: ; preds = %14, %12
%15 = phi i64 [ 0, %12 ], [ %36, %14 ]
%16 = phi i64 [ 0, %12 ], [ %37, %14 ]
%17 = getelementptr inbounds float, float* %0, i64 %15
%18 = load float, float* %17
%19 = tail call float @sqrt(float %18)
%20 = getelementptr inbounds float, float* %5, i64 %15
store float %19, float* %20
%21 = or i64 %15, 1
%22 = getelementptr inbounds float, float* %0, i64 %21
%23 = load float, float* %22
%24 = tail call float @sqrt(float %23)
%25 = getelementptr inbounds float, float* %5, i64 %21
store float %24, float* %25
%26 = or i64 %15, 2
%27 = getelementptr inbounds float, float* %0, i64 %26
%28 = load float, float* %27
%29 = tail call float @sqrt(float %28)
%30 = getelementptr inbounds float, float* %5, i64 %26
store float %29, float* %30
%31 = or i64 %15, 3
%32 = getelementptr inbounds float, float* %0, i64 %31
%33 = load float, float* %32
%34 = tail call float @sqrt(float %33)
%35 = getelementptr inbounds float, float* %5, i64 %31
store float %34, float* %35
%36 = add nuw nsw i64 %15, 4
%37 = add i64 %16, 4
%38 = icmp eq i64 %37, %13
br i1 %38, label %39, label %14
39: ; preds = %14, %7
%40 = phi i64 [ 0, %7 ], [ %36, %14 ]
%41 = icmp eq i64 %10, 0
br i1 %41, label %52, label %42
42: ; preds = %39, %42
%43 = phi i64 [ %49, %42 ], [ %40, %39 ]
%44 = phi i64 [ %50, %42 ], [ 0, %39 ]
%45 = getelementptr inbounds float, float* %0, i64 %43
%46 = load float, float* %45
%47 = tail call float @sqrt(float %46)
%48 = getelementptr inbounds float, float* %5, i64 %43
store float %47, float* %48
%49 = add nuw nsw i64 %43, 1
%50 = add i64 %44, 1
%51 = icmp eq i64 %50, %10
br i1 %51, label %52, label %42
52: ; preds = %39, %42, %2
ret float* %5
}