#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 pow(double, double);
void ComputePoly(double ix[], int ndat, double coeff[], int degree,
                 double oy[]) {
  for (int i = 0; i < ndat; i++) {
    oy[i] = 0.0;
    for (int j = 0; j <= degree; j++)
      oy[i] += coeff[j + 2] * pow(ix[i] - coeff[0], (double)j);
    oy[i] += coeff[1];
  }
}


x86 assembly (clang, -O0):
<ComputePoly>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ef <ComputePoly+0xdf>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     11c6 <ComputePoly+0xb6>
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
subsd  (%rax),%xmm0
cvtsi2sdl -0x30(%rbp),%xmm1
call   1030 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1154 <ComputePoly+0x44>
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1131 <ComputePoly+0x21>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ComputePoly>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,0x10(%rsp)
test   %esi,%esi
jle    1278 <ComputePoly+0x168>
mov    %r8,%rbx
mov    %rdx,%r15
mov    %rdi,%r12
mov    0x10(%rsp),%rax
lea    0x1(%rax),%r13d
mov    %esi,%eax
mov    %rax,0x20(%rsp)
mov    %r13,0x18(%rsp)
and    $0xfffffffe,%r13d
xor    %r14d,%r14d
jmp    117f <ComputePoly+0x6f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xorpd  %xmm0,%xmm0
addsd  0x8(%r15),%xmm0
movsd  %xmm0,(%rbx,%r14,8)
add    $0x1,%r14
cmp    0x20(%rsp),%r14
je     1278 <ComputePoly+0x168>
movq   $0x0,(%rbx,%r14,8)
cmpl   $0x0,0x10(%rsp)
js     1160 <ComputePoly+0x50>
je     1230 <ComputePoly+0x120>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
movsd  0x10(%r15,%rbp,8),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%r12,%r14,8),%xmm0
subsd  (%r15),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rbx,%r14,8),%xmm0
movsd  %xmm0,(%rbx,%r14,8)
movsd  (%r12,%r14,8),%xmm0
subsd  (%r15),%xmm0
movsd  0x18(%r15,%rbp,8),%xmm1
movsd  %xmm1,0x8(%rsp)
lea    0x1(%rbp),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rbx,%r14,8),%xmm0
movsd  %xmm0,(%rbx,%r14,8)
add    $0x2,%rbp
cmp    %rbp,%r13
jne    11a0 <ComputePoly+0x90>
testb  $0x1,0x18(%rsp)
je     1164 <ComputePoly+0x54>
jmp    123d <ComputePoly+0x12d>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ebp,%ebp
testb  $0x1,0x18(%rsp)
je     1164 <ComputePoly+0x54>
movsd  0x10(%r15,%rbp,8),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%r12,%r14,8),%xmm0
subsd  (%r15),%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rbx,%r14,8),%xmm0
movsd  %xmm0,(%rbx,%r14,8)
jmp    1164 <ComputePoly+0x54>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ComputePoly(double* %0, i32 %1, double* %2, i32 %3, double* %4) {
%6 = alloca double*
%7 = alloca i32
%8 = alloca double*
%9 = alloca i32
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
store double* %0, double** %6
store i32 %1, i32* %7
store double* %2, double** %8
store i32 %3, i32* %9
store double* %4, double** %10
store i32 0, i32* %11
br label %13
13: ; preds = %64, %5
%14 = load i32, i32* %11
%15 = load i32, i32* %7
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %67
17: ; preds = %13
%18 = load double*, double** %10
%19 = load i32, i32* %11
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds double, double* %18, i64 %20
store double 0.000000e+00, double* %21
store i32 0, i32* %12
br label %22
22: ; preds = %51, %17
%23 = load i32, i32* %12
%24 = load i32, i32* %9
%25 = icmp sle i32 %23, %24
br i1 %25, label %26, label %54
26: ; preds = %22
%27 = load double*, double** %8
%28 = load i32, i32* %12
%29 = add nsw i32 %28, 2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %27, i64 %30
%32 = load double, double* %31
%33 = load double*, double** %6
%34 = load i32, i32* %11
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds double, double* %33, i64 %35
%37 = load double, double* %36
%38 = load double*, double** %8
%39 = getelementptr inbounds double, double* %38, i64 0
%40 = load double, double* %39
%41 = fsub double %37, %40
%42 = load i32, i32* %12
%43 = sitofp i32 %42 to double
%44 = call double @pow(double %41, double %43)
%45 = load double*, double** %10
%46 = load i32, i32* %11
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
%49 = load double, double* %48
%50 = call double @llvm.fmuladd.f64(double %32, double %44, double %49)
store double %50, double* %48
br label %51
51: ; preds = %26
%52 = load i32, i32* %12
%53 = add nsw i32 %52, 1
store i32 %53, i32* %12
br label %22
54: ; preds = %22
%55 = load double*, double** %8
%56 = getelementptr inbounds double, double* %55, i64 1
%57 = load double, double* %56
%58 = load double*, double** %10
%59 = load i32, i32* %11
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds double, double* %58, i64 %60
%62 = load double, double* %61
%63 = fadd double %62, %57
store double %63, double* %61
br label %64
64: ; preds = %54
%65 = load i32, i32* %11
%66 = add nsw i32 %65, 1
store i32 %66, i32* %11
br label %13
67: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @ComputePoly(double* nocapture %0, i32 %1, double* nocapture %2, i32 %3, double* nocapture %4) {
%6 = icmp sgt i32 %1, 0
br i1 %6, label %7, label %17
7: ; preds = %5
%8 = icmp slt i32 %3, 0
%9 = getelementptr inbounds double, double* %2, i64 1
%10 = add i32 %3, 1
%11 = zext i32 %1 to i64
%12 = zext i32 %10 to i64
%13 = and i64 %12, 1
%14 = icmp eq i32 %3, 0
%15 = and i64 %12, 4294967294
%16 = icmp eq i64 %13, 0
br label %18
17: ; preds = %38, %5
ret void
18: ; preds = %7, %38
%19 = phi i64 [ 0, %7 ], [ %42, %38 ]
%20 = getelementptr inbounds double, double* %4, i64 %19
store double 0.000000e+00, double* %20
br i1 %8, label %38, label %21
21: ; preds = %18
%22 = getelementptr inbounds double, double* %0, i64 %19
br i1 %14, label %23, label %44
23: ; preds = %44, %21
%24 = phi double [ undef, %21 ], [ %69, %44 ]
%25 = phi i64 [ 0, %21 ], [ %70, %44 ]
br i1 %16, label %38, label %26
26: ; preds = %23
%27 = add nuw nsw i64 %25, 2
%28 = getelementptr inbounds double, double* %2, i64 %27
%29 = load double, double* %28
%30 = load double, double* %22
%31 = load double, double* %2
%32 = fsub double %30, %31
%33 = trunc i64 %25 to i32
%34 = sitofp i32 %33 to double
%35 = tail call double @pow(double %32, double %34)
%36 = load double, double* %20
%37 = tail call double @llvm.fmuladd.f64(double %29, double %35, double %36)
store double %37, double* %20
br label %38
38: ; preds = %26, %23, %18
%39 = phi double [ 0.000000e+00, %18 ], [ %24, %23 ], [ %37, %26 ]
%40 = load double, double* %9
%41 = fadd double %40, %39
store double %41, double* %20
%42 = add nuw nsw i64 %19, 1
%43 = icmp eq i64 %42, %11
br i1 %43, label %17, label %18
44: ; preds = %21, %44
%45 = phi i64 [ %70, %44 ], [ 0, %21 ]
%46 = phi i64 [ %71, %44 ], [ 0, %21 ]
%47 = add nuw nsw i64 %45, 2
%48 = getelementptr inbounds double, double* %2, i64 %47
%49 = load double, double* %48
%50 = load double, double* %22
%51 = load double, double* %2
%52 = fsub double %50, %51
%53 = trunc i64 %45 to i32
%54 = sitofp i32 %53 to double
%55 = tail call double @pow(double %52, double %54)
%56 = load double, double* %20
%57 = tail call double @llvm.fmuladd.f64(double %49, double %55, double %56)
store double %57, double* %20
%58 = add nuw nsw i64 %45, 3
%59 = getelementptr inbounds double, double* %2, i64 %58
%60 = load double, double* %59
%61 = load double, double* %22
%62 = load double, double* %2
%63 = fsub double %61, %62
%64 = trunc i64 %45 to i32
%65 = or i32 %64, 1
%66 = sitofp i32 %65 to double
%67 = tail call double @pow(double %63, double %66)
%68 = load double, double* %20
%69 = tail call double @llvm.fmuladd.f64(double %60, double %67, double %68)
store double %69, double* %20
%70 = add nuw nsw i64 %45, 2
%71 = add i64 %46, 2
%72 = icmp eq i64 %71, %15
br i1 %72, label %23, label %44
}