#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 _f(double);
double dglg3(void) {
  int i;
  static double g[3] = {0.41577455678348, 2.294280360279, 6.2899450829375};
  static double w[3] = {0.711093009929, 0.27851773356924, 0.010389256501586};
  double s;
  for (i = 0, s = 0.; i < 3; i++)
    s += _f(g[i]) * w[i];
  return s;
}


x86 assembly (clang, -O0):
<dglg3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x3,-0x4(%rbp)
jge    1176 <dglg3+0x66>
movslq -0x4(%rbp),%rcx
lea    0x2ef4(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
call   1030 <_f@plt>
movslq -0x4(%rbp),%rcx
lea    0x2eff(%rip),%rax
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1127 <dglg3+0x17>
movsd  -0x10(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dglg3>:
push   %rax
movsd  0xee7(%rip),%xmm0
call   1030 <_f@plt>
mulsd  0xee2(%rip),%xmm0
xorpd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
movsd  0xed5(%rip),%xmm0
call   1030 <_f@plt>
mulsd  0xed0(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0xec6(%rip),%xmm0
call   1030 <_f@plt>
mulsd  0xec1(%rip),%xmm0
addsd  (%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@dglg3.g = internal global [3 x double] [double 0x3FDA9C0CE2F93657, double 0x40025AAFA95A06F8, double 0x401928E75D236908]
@dglg3.w = internal global [3 x double] [double 0x3FE6C14620C1E572, double 0x3FD1D33C0B424CA1, double 0x3F8546F6673B879B]
define double @dglg3() {
%1 = alloca i32
%2 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %2
br label %3
3: ; preds = %18, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 3
br i1 %5, label %6, label %21
6: ; preds = %3
%7 = load i32, i32* %1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [3 x double], [3 x double]* @dglg3.g, i64 0, i64 %8
%10 = load double, double* %9
%11 = call double @_f(double %10)
%12 = load i32, i32* %1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [3 x double], [3 x double]* @dglg3.w, i64 0, i64 %13
%15 = load double, double* %14
%16 = load double, double* %2
%17 = call double @llvm.fmuladd.f64(double %11, double %15, double %16)
store double %17, double* %2
br label %18
18: ; preds = %6
%19 = load i32, i32* %1
%20 = add nsw i32 %19, 1
store i32 %20, i32* %1
br label %3
21: ; preds = %3
%22 = load double, double* %2
ret double %22
}

LLVM IR (-O2):
define double @dglg3() {
%1 = tail call double @_f(double 0x3FDA9C0CE2F93657)
%2 = tail call double @llvm.fmuladd.f64(double %1, double 0x3FE6C14620C1E572, double 0.000000e+00)
%3 = tail call double @_f(double 0x40025AAFA95A06F8)
%4 = tail call double @llvm.fmuladd.f64(double %3, double 0x3FD1D33C0B424CA1, double %2)
%5 = tail call double @_f(double 0x401928E75D236908)
%6 = tail call double @llvm.fmuladd.f64(double %5, double 0x3F8546F6673B879B, double %4)
ret double %6
}