#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 sqrtf(float const);
void vec_sqrt(long N, float *dst, const float *src) {
  for (long i = 0; i < N; i++)
    dst[i] = sqrtf(src[i]);
}


x86 assembly (clang, -O0):
<vec_sqrt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    116a <vec_sqrt+0x5a>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
call   1030 <sqrtf@plt>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    112c <vec_sqrt+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vec_sqrt>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rdi,%rdi
jle    1188 <vec_sqrt+0x78>
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%r15
lea    -0x1(%rdi),%rax
mov    %r15d,%r12d
and    $0x3,%r12d
cmp    $0x3,%rax
jae    1192 <vec_sqrt+0x82>
xor    %ebx,%ebx
test   %r12,%r12
je     1188 <vec_sqrt+0x78>
lea    0x0(,%rbx,4),%r15
add    %r13,%r15
lea    (%r14,%rbx,4),%r14
xor    %ebx,%ebx
xorps  %xmm1,%xmm1
jmp    1177 <vec_sqrt+0x67>
cs nopw 0x0(%rax,%rax,1)
nop
call   1030 <sqrtf@plt>
xorps  %xmm1,%xmm1
movss  %xmm0,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r12
je     1188 <vec_sqrt+0x78>
movss  (%r14,%rbx,4),%xmm0
ucomiss %xmm1,%xmm0
jb     1160 <vec_sqrt+0x50>
sqrtss %xmm0,%xmm0
jmp    1168 <vec_sqrt+0x58>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
and    $0xfffffffffffffffc,%r15
xor    %ebx,%ebx
xorps  %xmm1,%xmm1
jmp    11b8 <vec_sqrt+0xa8>
nopl   (%rax)
call   1030 <sqrtf@plt>
xorps  %xmm1,%xmm1
movss  %xmm0,0xc(%r13,%rbx,4)
add    $0x4,%rbx
cmp    %rbx,%r15
je     113a <vec_sqrt+0x2a>
movss  (%r14,%rbx,4),%xmm0
ucomiss %xmm1,%xmm0
jb     11d0 <vec_sqrt+0xc0>
sqrtss %xmm0,%xmm0
jmp    11d8 <vec_sqrt+0xc8>
nopl   0x0(%rax)
call   1030 <sqrtf@plt>
xorps  %xmm1,%xmm1
movss  %xmm0,0x0(%r13,%rbx,4)
movss  0x4(%r14,%rbx,4),%xmm0
ucomiss %xmm1,%xmm0
jb     1200 <vec_sqrt+0xf0>
sqrtss %xmm0,%xmm0
jmp    1208 <vec_sqrt+0xf8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1030 <sqrtf@plt>
xorps  %xmm1,%xmm1
movss  %xmm0,0x4(%r13,%rbx,4)
movss  0x8(%r14,%rbx,4),%xmm0
ucomiss %xmm1,%xmm0
jb     1230 <vec_sqrt+0x120>
sqrtss %xmm0,%xmm0
jmp    1238 <vec_sqrt+0x128>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1030 <sqrtf@plt>
xorps  %xmm1,%xmm1
movss  %xmm0,0x8(%r13,%rbx,4)
movss  0xc(%r14,%rbx,4),%xmm0
ucomiss %xmm1,%xmm0
jb     11a0 <vec_sqrt+0x90>
sqrtss %xmm0,%xmm0
jmp    11a8 <vec_sqrt+0x98>

LLVM IR (-O0):
define void @vec_sqrt(i64 %0, float* %1, float* %2) {
%4 = alloca i64
%5 = alloca float*
%6 = alloca float*
%7 = alloca i64
store i64 %0, i64* %4
store float* %1, float** %5
store float* %2, float** %6
store i64 0, i64* %7
br label %8
8: ; preds = %21, %3
%9 = load i64, i64* %7
%10 = load i64, i64* %4
%11 = icmp slt i64 %9, %10
br i1 %11, label %12, label %24
12: ; preds = %8
%13 = load float*, float** %6
%14 = load i64, i64* %7
%15 = getelementptr inbounds float, float* %13, i64 %14
%16 = load float, float* %15
%17 = call float @sqrtf(float %16)
%18 = load float*, float** %5
%19 = load i64, i64* %7
%20 = getelementptr inbounds float, float* %18, i64 %19
store float %17, float* %20
br label %21
21: ; preds = %12
%22 = load i64, i64* %7
%23 = add nsw i64 %22, 1
store i64 %23, i64* %7
br label %8
24: ; preds = %8
ret void
}

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