#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 sqrt_m(double *m, int sz) {
  int i = 0;
  for (; i < sz; ++i) {
    m[i] = sqrt(m[i]);
  }
}


x86 assembly (clang, -O0):
<sqrt_m>:
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    115f <sqrt_m+0x4f>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <sqrt@plt>
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 <sqrt_m+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sqrt_m>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    117a <sqrt_m+0x6a>
mov    %rdi,%r12
mov    %esi,%r15d
lea    -0x1(%r15),%rax
mov    %r15d,%r14d
and    $0x3,%r14d
cmp    $0x3,%rax
jae    1186 <sqrt_m+0x76>
xor    %ebx,%ebx
test   %r14,%r14
je     117a <sqrt_m+0x6a>
lea    (%r12,%rbx,8),%r15
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
jmp    1168 <sqrt_m+0x58>
cs nopw 0x0(%rax,%rax,1)
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
je     117a <sqrt_m+0x6a>
movsd  (%r15,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1150 <sqrt_m+0x40>
sqrtsd %xmm0,%xmm0
jmp    1159 <sqrt_m+0x49>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
and    $0xfffffffc,%r15d
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
jmp    11bd <sqrt_m+0xad>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x18(%r12,%rbx,8)
add    $0x4,%rbx
cmp    %rbx,%r15
je     1135 <sqrt_m+0x25>
movsd  (%r12,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     11d0 <sqrt_m+0xc0>
sqrtsd %xmm0,%xmm0
jmp    11d9 <sqrt_m+0xc9>
nop
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,(%r12,%rbx,8)
movsd  0x8(%r12,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1200 <sqrt_m+0xf0>
sqrtsd %xmm0,%xmm0
jmp    1209 <sqrt_m+0xf9>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x8(%r12,%rbx,8)
movsd  0x10(%r12,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     1230 <sqrt_m+0x120>
sqrtsd %xmm0,%xmm0
jmp    1239 <sqrt_m+0x129>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
call   1030 <sqrt@plt>
xorpd  %xmm1,%xmm1
movsd  %xmm0,0x10(%r12,%rbx,8)
movsd  0x18(%r12,%rbx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     11a0 <sqrt_m+0x90>
sqrtsd %xmm0,%xmm0
jmp    11a9 <sqrt_m+0x99>

LLVM IR (-O0):
define void @sqrt_m(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 = %21, %2
%7 = load i32, i32* %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %24
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 double @sqrt(double %15)
%17 = load double*, double** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds double, double* %17, i64 %19
store double %16, double* %20
br label %21
21: ; preds = %10
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %6
24: ; preds = %6
ret void
}

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