#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 hatfldc(double *p, double *x, int m, int n, void *data) {
  register int i;
  x[0] = p[0] - 1.0;
  for (i = 1; i < m - 1; ++i)
    x[i] = p[i - 1] - sqrt(p[i]);
  x[m - 1] = p[m - 1] - 1.0;
}


x86 assembly (clang, -O0):
<hatfldc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xec6(%rip),%xmm1
subsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11ae <hatfldc+0x9e>
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114d <hatfldc+0x3d>
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xe38(%rip),%xmm1
subsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hatfldc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
addsd  0xed6(%rip),%xmm0
mov    %rsi,%r14
movsd  %xmm0,(%rsi)
lea    -0x1(%rdx),%r15d
cmp    $0x3,%edx
jl     123d <hatfldc+0x12d>
mov    %r15d,%r12d
add    $0xffffffffffffffff,%r12
mov    $0x1,%ebp
cmp    $0x2,%r15d
jne    117c <hatfldc+0x6c>
test   $0x1,%r12b
je     123d <hatfldc+0x12d>
movsd  -0x8(%rbx,%rbp,8),%xmm2
movsd  (%rbx,%rbp,8),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1224 <hatfldc+0x114>
sqrtsd %xmm0,%xmm0
jmp    1233 <hatfldc+0x123>
mov    %r12,%r13
and    $0xfffffffffffffffe,%r13
neg    %r13
mov    $0x1,%ebp
xorpd  %xmm1,%xmm1
jmp    11d7 <hatfldc+0xc7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  %xmm2,(%rsp)
call   1030 <sqrt@plt>
movsd  (%rsp),%xmm2
xorpd  %xmm1,%xmm1
subsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%r14,%rbp,8)
lea    0x2(,%rbp,1),%rax
add    %r13,%rax
add    $0x2,%rbp
cmp    $0x1,%rax
je     1150 <hatfldc+0x40>
movsd  -0x8(%rbx,%rbp,8),%xmm2
movsd  (%rbx,%rbp,8),%xmm0
ucomisd %xmm1,%xmm0
jb     11f0 <hatfldc+0xe0>
sqrtsd %xmm0,%xmm0
jmp    1203 <hatfldc+0xf3>
xchg   %ax,%ax
movsd  %xmm2,(%rsp)
call   1030 <sqrt@plt>
movsd  (%rsp),%xmm2
xorpd  %xmm1,%xmm1
subsd  %xmm0,%xmm2
movsd  %xmm2,(%r14,%rbp,8)
movsd  (%rbx,%rbp,8),%xmm2
movsd  0x8(%rbx,%rbp,8),%xmm0
ucomisd %xmm1,%xmm0
jb     11a0 <hatfldc+0x90>
sqrtsd %xmm0,%xmm0
jmp    11b3 <hatfldc+0xa3>
movsd  %xmm2,(%rsp)
call   1030 <sqrt@plt>
movsd  (%rsp),%xmm2
subsd  %xmm0,%xmm2
movsd  %xmm2,(%r14,%rbp,8)
movslq %r15d,%rax
movsd  (%rbx,%rax,8),%xmm0
addsd  0xdb3(%rip),%xmm0
movsd  %xmm0,(%r14,%rax,8)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @hatfldc(double* %0, double* %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%12 = load double*, double** %6
%13 = getelementptr inbounds double, double* %12, i64 0
%14 = load double, double* %13
%15 = fsub double %14, 1.000000e+00
%16 = load double*, double** %7
%17 = getelementptr inbounds double, double* %16, i64 0
store double %15, double* %17
store i32 1, i32* %11
br label %18
18: ; preds = %41, %5
%19 = load i32, i32* %11
%20 = load i32, i32* %8
%21 = sub nsw i32 %20, 1
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %44
23: ; preds = %18
%24 = load double*, double** %6
%25 = load i32, i32* %11
%26 = sub nsw i32 %25, 1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %24, i64 %27
%29 = load double, double* %28
%30 = load double*, double** %6
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds double, double* %30, i64 %32
%34 = load double, double* %33
%35 = call double @sqrt(double %34)
%36 = fsub double %29, %35
%37 = load double*, double** %7
%38 = load i32, i32* %11
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds double, double* %37, i64 %39
store double %36, double* %40
br label %41
41: ; preds = %23
%42 = load i32, i32* %11
%43 = add nsw i32 %42, 1
store i32 %43, i32* %11
br label %18
44: ; preds = %18
%45 = load double*, double** %6
%46 = load i32, i32* %8
%47 = sub nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %45, i64 %48
%50 = load double, double* %49
%51 = fsub double %50, 1.000000e+00
%52 = load double*, double** %7
%53 = load i32, i32* %8
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %52, i64 %55
store double %51, double* %56
ret void
}

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