#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__ sqrt(double);
void tml_dr_vSqrt1(double *vec, int n) {
  int i;
  for (i = 0; i < n; i++)
    vec[i] = (double)sqrt(vec[i]);
}


x86 assembly (clang, -O0):
<tml_dr_vSqrt1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1164 <tml_dr_vSqrt1+0x54>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <sqrt@plt>
cvtsi2sd %rax,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <tml_dr_vSqrt1+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tml_dr_vSqrt1>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    11f2 <tml_dr_vSqrt1+0xe2>
mov    %rdi,%r12
mov    %esi,%r15d
lea    -0x1(%r15),%rax
mov    %r15d,%r14d
and    $0x3,%r14d
cmp    $0x3,%rax
jae    113e <tml_dr_vSqrt1+0x2e>
xor    %ebx,%ebx
jmp    11c3 <tml_dr_vSqrt1+0xb3>
and    $0xfffffffc,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%r12,%rbx,8),%xmm0
call   1030 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,(%r12,%rbx,8)
movsd  0x8(%r12,%rbx,8),%xmm0
call   1030 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,0x8(%r12,%rbx,8)
movsd  0x10(%r12,%rbx,8),%xmm0
call   1030 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,0x10(%r12,%rbx,8)
movsd  0x18(%r12,%rbx,8),%xmm0
call   1030 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,0x18(%r12,%rbx,8)
add    $0x4,%rbx
cmp    %rbx,%r15
jne    1150 <tml_dr_vSqrt1+0x40>
test   %r14,%r14
je     11f2 <tml_dr_vSqrt1+0xe2>
lea    (%r12,%rbx,8),%r15
xor    %ebx,%ebx
xchg   %ax,%ax
movsd  (%r15,%rbx,8),%xmm0
call   1030 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11d0 <tml_dr_vSqrt1+0xc0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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