#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, int);
double earth_values(double term_sum[], int count, double jme) {
  int i;
  double sum = 0;
  for (i = 0; i < count; i++)
    sum += term_sum[i] * pow(jme, i);
  sum /= 1.0e8;
  return sum;
}


x86 assembly (clang, -O0):
<earth_values>:
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,-0x28(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1186 <earth_values+0x76>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x1c(%rbp),%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1133 <earth_values+0x23>
movsd  -0x28(%rbp),%xmm0
movsd  0xe6d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<earth_values>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %esi,%esi
jle    1148 <earth_values+0x38>
mov    %rdi,%r14
mov    %esi,%r12d
lea    -0x1(%r12),%rax
mov    %r12d,%r15d
and    $0x3,%r15d
cmp    $0x3,%rax
movsd  %xmm0,0x10(%rsp)
jae    1151 <earth_values+0x41>
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
jmp    1217 <earth_values+0x107>
xorpd  %xmm0,%xmm0
jmp    1261 <earth_values+0x151>
and    $0xfffffffc,%r12d
xorpd  %xmm0,%xmm0
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,(%rsp)
movsd  (%r14,%rbx,8),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    %ebx,%edi
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x8(%r14,%rbx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x1(%rbx),%edi
movsd  0x10(%rsp),%xmm0
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%r14,%rbx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x2(%rbx),%edi
movsd  0x10(%rsp),%xmm0
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%r14,%rbx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0x3(%rbx),%edi
movsd  0x10(%rsp),%xmm0
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
addsd  (%rsp),%xmm0
add    $0x4,%rbx
cmp    %r12,%rbx
jne    1160 <earth_values+0x50>
test   %r15,%r15
je     1261 <earth_values+0x151>
nopl   0x0(%rax)
movsd  %xmm0,(%rsp)
movsd  (%r14,%rbx,8),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    %ebx,%edi
call   1030 <pow@plt>
mulsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0x1,%rbx
add    $0xffffffffffffffff,%r15
jne    1220 <earth_values+0x110>
divsd  0xd97(%rip),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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