#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 coefficient(double *, int, int);
double valueAtPoint(double P[], int degreeP, double point) {
  double value = 0;
  int term = degreeP;
  for (term = degreeP; term >= 0; term--) {
    value = coefficient(P, degreeP, term) + point * value;
  }
  return value;
}


x86 assembly (clang, -O0):
<valueAtPoint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jl     1179 <valueAtPoint+0x69>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1030 <coefficient@plt>
movaps %xmm0,%xmm1
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    1138 <valueAtPoint+0x28>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valueAtPoint>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %esi,%esi
js     115c <valueAtPoint+0x4c>
movapd %xmm0,%xmm1
mov    %esi,%ebx
mov    %rdi,%r14
xorpd  %xmm2,%xmm2
mov    %esi,%ebp
movsd  %xmm0,(%rsp)
movsd  %xmm2,0x8(%rsp)
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <coefficient@plt>
movsd  0x8(%rsp),%xmm2
movsd  (%rsp),%xmm1
mulsd  %xmm1,%xmm2
addsd  %xmm0,%xmm2
add    $0xffffffff,%ebp
jb     1130 <valueAtPoint+0x20>
jmp    1160 <valueAtPoint+0x50>
xorpd  %xmm2,%xmm2
movapd %xmm2,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @valueAtPoint(double* %0, i32 %1, double %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
store double %2, double* %6
store double 0.000000e+00, double* %7
%9 = load i32, i32* %5
store i32 %9, i32* %8
%10 = load i32, i32* %5
store i32 %10, i32* %8
br label %11
11: ; preds = %22, %3
%12 = load i32, i32* %8
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %25
14: ; preds = %11
%15 = load double*, double** %4
%16 = load i32, i32* %5
%17 = load i32, i32* %8
%18 = call double @coefficient(double* %15, i32 %16, i32 %17)
%19 = load double, double* %6
%20 = load double, double* %7
%21 = call double @llvm.fmuladd.f64(double %19, double %20, double %18)
store double %21, double* %7
br label %22
22: ; preds = %14
%23 = load i32, i32* %8
%24 = add nsw i32 %23, -1
store i32 %24, i32* %8
br label %11
25: ; preds = %11
%26 = load double, double* %7
ret double %26
}

LLVM IR (-O2):
define double @valueAtPoint(double* %0, i32 %1, double %2) {
%4 = icmp sgt i32 %1, -1
br i1 %4, label %5, label %12
5: ; preds = %3, %5
%6 = phi i32 [ %10, %5 ], [ %1, %3 ]
%7 = phi double [ %9, %5 ], [ 0.000000e+00, %3 ]
%8 = tail call double @coefficient(double* %0, i32 %1, i32 %6)
%9 = tail call double @llvm.fmuladd.f64(double %2, double %7, double %8)
%10 = add nsw i32 %6, -1
%11 = icmp eq i32 %6, 0
br i1 %11, label %12, label %5
12: ; preds = %5, %3
%13 = phi double [ 0.000000e+00, %3 ], [ %9, %5 ]
ret double %13
}