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


x86 assembly (clang, -O0):
<PT_square_root>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1163 <PT_square_root+0x53>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <sqrt@plt>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <PT_square_root+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PT_square_root>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
jle    118a <PT_square_root+0x7a>
mov    %rsi,%r14
mov    %rdi,%r13
mov    %edx,%r12d
lea    -0x1(%r12),%rax
mov    %r12d,%r15d
and    $0x3,%r15d
cmp    $0x3,%rax
jae    1194 <PT_square_root+0x84>
xor    %ebx,%ebx
test   %r15,%r15
je     118a <PT_square_root+0x7a>
lea    0x0(,%rbx,8),%r12
add    %r13,%r12
lea    (%r14,%rbx,8),%r14
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
jmp    1178 <PT_square_root+0x68>
cs nopw 0x0(%rax,%rax,1)
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
je     118a <PT_square_root+0x7a>
movsd  (%r14,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1160 <PT_square_root+0x50>
sqrtsd %xmm0,%xmm0
jmp    1169 <PT_square_root+0x59>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
and    $0xfffffffc,%r12d
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
jmp    11b9 <PT_square_root+0xa9>
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x18(%r13,%rbx,8)
add    $0x4,%rbx
cmp    %rbx,%r12
je     113a <PT_square_root+0x2a>
movsd  (%r14,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     11d0 <PT_square_root+0xc0>
sqrtsd %xmm0,%xmm0
jmp    11d9 <PT_square_root+0xc9>
nopl   0x0(%rax,%rax,1)
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x0(%r13,%rbx,8)
movsd  0x8(%r14,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1200 <PT_square_root+0xf0>
sqrtsd %xmm0,%xmm0
jmp    1209 <PT_square_root+0xf9>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x8(%r13,%rbx,8)
movsd  0x10(%r14,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1230 <PT_square_root+0x120>
sqrtsd %xmm0,%xmm0
jmp    1239 <PT_square_root+0x129>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x10(%r13,%rbx,8)
movsd  0x18(%r14,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     11a0 <PT_square_root+0x90>
sqrtsd %xmm0,%xmm0
jmp    11a9 <PT_square_root+0x99>

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

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