#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 /*<<< orphan*/ assert(double const *);
double sqrt(double const);
void vectord_sqrt(const double *self, size_t size, double *output) {
  assert(self);
  assert(output);
  for (size_t i = 0; i < size; i++)
    output[i] = sqrt(self[i]);
}


x86 assembly (clang, -O0):
<vectord_sqrt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1030 <assert@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    118c <vectord_sqrt+0x6c>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <sqrt@plt>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    114e <vectord_sqrt+0x2e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vectord_sqrt>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r13
call   1030 <assert@plt>
mov    %r14,%rdi
call   1030 <assert@plt>
test   %r15,%r15
je     11aa <vectord_sqrt+0x8a>
lea    -0x1(%r15),%rax
mov    %r15d,%r12d
and    $0x3,%r12d
cmp    $0x3,%rax
jae    11b4 <vectord_sqrt+0x94>
xor    %ebx,%ebx
test   %r12,%r12
je     11aa <vectord_sqrt+0x8a>
lea    (%r14,%rbx,8),%r14
lea    0x0(,%rbx,8),%r15
add    %r13,%r15
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
jmp    1198 <vectord_sqrt+0x78>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1040 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r12
je     11aa <vectord_sqrt+0x8a>
movsd  (%r15,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1180 <vectord_sqrt+0x60>
sqrtsd %xmm0,%xmm0
jmp    1189 <vectord_sqrt+0x69>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
and    $0xfffffffffffffffc,%r15
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
jmp    11dd <vectord_sqrt+0xbd>
call   1040 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x18(%r14,%rbx,8)
add    $0x4,%rbx
cmp    %rbx,%r15
je     1157 <vectord_sqrt+0x37>
movsd  0x0(%r13,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     11f0 <vectord_sqrt+0xd0>
sqrtsd %xmm0,%xmm0
jmp    11f9 <vectord_sqrt+0xd9>
call   1040 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,(%r14,%rbx,8)
movsd  0x8(%r13,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1220 <vectord_sqrt+0x100>
sqrtsd %xmm0,%xmm0
jmp    1229 <vectord_sqrt+0x109>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1040 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x8(%r14,%rbx,8)
movsd  0x10(%r13,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1250 <vectord_sqrt+0x130>
sqrtsd %xmm0,%xmm0
jmp    1259 <vectord_sqrt+0x139>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1040 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x10(%r14,%rbx,8)
movsd  0x18(%r13,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     11c0 <vectord_sqrt+0xa0>
sqrtsd %xmm0,%xmm0
jmp    11c9 <vectord_sqrt+0xa9>

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

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