#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 */
int power(double, int);
double definiteIntegral(double P[], int degreeP, double a, double b) {
  double integral = 0;
  int term;
  for (term = 0; term <= degreeP; term++) {
    integral += 1 / (double)(term + 1) * P[term] *
                (power(b, term + 1) - power(a, term + 1));
  }
  return integral;
}


x86 assembly (clang, -O0):
<definiteIntegral>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11bf <definiteIntegral+0xaf>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xeaa(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
mov    -0x2c(%rbp),%edi
add    $0x1,%edi
call   1030 <power@plt>
mov    %eax,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x2c(%rbp),%edi
add    $0x1,%edi
call   1030 <power@plt>
movsd  -0x38(%rbp),%xmm0
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1138 <definiteIntegral+0x28>
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<definiteIntegral>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
test   %esi,%esi
js     11ab <definiteIntegral+0x9b>
mov    %esi,%r15d
mov    %rdi,%r14
add    $0x1,%r15d
xorpd  %xmm2,%xmm2
xor    %eax,%eax
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
xchg   %ax,%ax
movsd  %xmm2,0x20(%rsp)
lea    0x1(%rax),%rbx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0xea7(%rip),%xmm2
divsd  %xmm0,%xmm2
mulsd  (%r14,%rax,8),%xmm2
movsd  %xmm2,0x18(%rsp)
movaps %xmm1,%xmm0
mov    %ebx,%edi
call   1030 <power@plt>
mov    %eax,%ebp
movsd  0x8(%rsp),%xmm0
mov    %ebx,%edi
call   1030 <power@plt>
movsd  0x20(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
sub    %eax,%ebp
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0x18(%rsp),%xmm0
addsd  %xmm0,%xmm2
mov    %rbx,%rax
cmp    %rbx,%r15
jne    1140 <definiteIntegral+0x30>
jmp    11af <definiteIntegral+0x9f>
xorpd  %xmm2,%xmm2
movapd %xmm2,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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