#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 intpow(double, int);
double P_evaluate(double x, long *coefficients, int degree) {
  double result;
  register int i;
  result = 0.;
  for (i = 0; i < degree + 1; i++)
    result += (double)coefficients[i] * intpow(x, degree - i);
  return (result);
}


x86 assembly (clang, -O0):
<P_evaluate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    118f <P_evaluate+0x7f>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
cvtsi2sdq (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x14(%rbp),%edi
sub    -0x24(%rbp),%edi
call   1030 <intpow@plt>
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1133 <P_evaluate+0x23>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<P_evaluate>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
js     1181 <P_evaluate+0x71>
mov    %esi,%r12d
mov    %rdi,%r14
lea    0x1(%r12),%r15d
xorpd  %xmm1,%xmm1
xor    %ebx,%ebx
movsd  %xmm0,(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm1,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sdq (%r14,%rbx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
mov    %r12d,%edi
call   1030 <intpow@plt>
movsd  0x10(%rsp),%xmm1
mulsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm1
add    $0x1,%rbx
add    $0xffffffff,%r12d
cmp    %rbx,%r15
jne    1140 <P_evaluate+0x30>
jmp    1185 <P_evaluate+0x75>
xorpd  %xmm1,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @P_evaluate(double %0, i64* %1, i32 %2) {
%4 = alloca double
%5 = alloca i64*
%6 = alloca i32
%7 = alloca double
%8 = alloca i32
store double %0, double* %4
store i64* %1, i64** %5
store i32 %2, i32* %6
store double 0.000000e+00, double* %7
store i32 0, i32* %8
br label %9
9: ; preds = %28, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %6
%12 = add nsw i32 %11, 1
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %31
14: ; preds = %9
%15 = load i64*, i64** %5
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i64, i64* %15, i64 %17
%19 = load i64, i64* %18
%20 = sitofp i64 %19 to double
%21 = load double, double* %4
%22 = load i32, i32* %6
%23 = load i32, i32* %8
%24 = sub nsw i32 %22, %23
%25 = call double @intpow(double %21, i32 %24)
%26 = load double, double* %7
%27 = call double @llvm.fmuladd.f64(double %20, double %25, double %26)
store double %27, double* %7
br label %28
28: ; preds = %14
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %9
31: ; preds = %9
%32 = load double, double* %7
ret double %32
}

LLVM IR (-O2):
define double @P_evaluate(double %0, i64* nocapture %1, i32 %2) {
%4 = icmp slt i32 %2, 0
br i1 %4, label %20, label %5
5: ; preds = %3
%6 = add nuw i32 %2, 1
%7 = zext i32 %6 to i64
br label %8
8: ; preds = %5, %8
%9 = phi i64 [ 0, %5 ], [ %18, %8 ]
%10 = phi double [ 0.000000e+00, %5 ], [ %17, %8 ]
%11 = getelementptr inbounds i64, i64* %1, i64 %9
%12 = load i64, i64* %11
%13 = sitofp i64 %12 to double
%14 = trunc i64 %9 to i32
%15 = sub nsw i32 %2, %14
%16 = tail call double @intpow(double %0, i32 %15)
%17 = tail call double @llvm.fmuladd.f64(double %13, double %16, double %10)
%18 = add nuw nsw i64 %9, 1
%19 = icmp eq i64 %18, %7
br i1 %19, label %20, label %8
20: ; preds = %8, %3
%21 = phi double [ 0.000000e+00, %3 ], [ %17, %8 ]
ret double %21
}