#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 log(double);
double ellk(double k) {
  double a0, a1, a2, a3, a4, b0, b1, b2, b3, b4, ellk_val, ek1, ek2, m1;
  m1 = 1.0 - k * k;
  a0 = 1.38629436112;
  a1 = 0.09666344259;
  a2 = 0.03590092383;
  a3 = 0.03742563713;
  a4 = 0.01451196212;
  b0 = 0.5;
  b1 = 0.12498593597;
  b2 = 0.06880248576;
  b3 = 0.03328355346;
  b4 = 0.00441787012;
  ek1 = a0 + m1 * (a1 + m1 * (a2 + m1 * (a3 + m1 * a4)));
  ek2 = (b0 + m1 * (b1 + m1 * (b2 + m1 * (b3 + m1 * b4)))) * log(m1);
  ellk_val = ek1 - ek2;
  return (ellk_val);
}


x86 assembly (clang, -O0):
<ellk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xf03(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xeea(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xed5(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xec0(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xeab(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe96(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe81(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe6c(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe57(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe42(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xe2d(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  -0x78(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm3
movsd  -0x78(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm5
movsd  -0x78(%rbp),%xmm4
movsd  -0x28(%rbp),%xmm7
movsd  -0x78(%rbp),%xmm6
movsd  -0x30(%rbp),%xmm8
mulsd  %xmm8,%xmm6
addsd  %xmm7,%xmm6
mulsd  %xmm6,%xmm4
addsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x78(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm3
movsd  -0x78(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm5
movsd  -0x78(%rbp),%xmm4
movsd  -0x50(%rbp),%xmm7
movsd  -0x78(%rbp),%xmm6
movsd  -0x58(%rbp),%xmm8
mulsd  %xmm8,%xmm6
addsd  %xmm7,%xmm6
mulsd  %xmm6,%xmm4
addsd  %xmm5,%xmm4
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x78(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
subsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ellk>:
sub    $0x18,%rsp
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
movsd  0xedc(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  0xed8(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xed4(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xed0(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xecc(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xec8(%rip),%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xec2(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xebe(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xeba(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xeb6(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  0xeb2(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
call   1030 <log@plt>
mulsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @ellk(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store double %0, double* %2
%17 = load double, double* %2
%18 = load double, double* %2
%19 = fneg double %17
%20 = call double @llvm.fmuladd.f64(double %19, double %18, double 1.000000e+00)
store double %20, double* %16
store double 0x3FF62E42FEFA3BDC, double* %3
store double 0x3FB8BEEF74A49015, double* %4
store double 0x3FA2619B1B7DF892, double* %5
store double 0x3FA32973FF02B86D, double* %6
store double 0x3F8DB87295A64760, double* %7
store double 5.000000e-01, double* %8
store double 0x3FBFFF140B737B4B, double* %9
store double 0x3FB19D0A2A39033E, double* %10
store double 0x3FA10A8ABB35F2BF, double* %11
store double 0x3F721878FAEF1B40, double* %12
%21 = load double, double* %3
%22 = load double, double* %16
%23 = load double, double* %4
%24 = load double, double* %16
%25 = load double, double* %5
%26 = load double, double* %16
%27 = load double, double* %6
%28 = load double, double* %16
%29 = load double, double* %7
%30 = call double @llvm.fmuladd.f64(double %28, double %29, double %27)
%31 = call double @llvm.fmuladd.f64(double %26, double %30, double %25)
%32 = call double @llvm.fmuladd.f64(double %24, double %31, double %23)
%33 = call double @llvm.fmuladd.f64(double %22, double %32, double %21)
store double %33, double* %14
%34 = load double, double* %8
%35 = load double, double* %16
%36 = load double, double* %9
%37 = load double, double* %16
%38 = load double, double* %10
%39 = load double, double* %16
%40 = load double, double* %11
%41 = load double, double* %16
%42 = load double, double* %12
%43 = call double @llvm.fmuladd.f64(double %41, double %42, double %40)
%44 = call double @llvm.fmuladd.f64(double %39, double %43, double %38)
%45 = call double @llvm.fmuladd.f64(double %37, double %44, double %36)
%46 = call double @llvm.fmuladd.f64(double %35, double %45, double %34)
%47 = load double, double* %16
%48 = call double @log(double %47)
%49 = fmul double %46, %48
store double %49, double* %15
%50 = load double, double* %14
%51 = load double, double* %15
%52 = fsub double %50, %51
store double %52, double* %13
%53 = load double, double* %13
ret double %53
}

LLVM IR (-O2):
define double @ellk(double %0) {
%2 = fneg double %0
%3 = tail call double @llvm.fmuladd.f64(double %2, double %0, double 1.000000e+00)
%4 = tail call double @llvm.fmuladd.f64(double %3, double 0x3F8DB87295A64760, double 0x3FA32973FF02B86D)
%5 = tail call double @llvm.fmuladd.f64(double %3, double %4, double 0x3FA2619B1B7DF892)
%6 = tail call double @llvm.fmuladd.f64(double %3, double %5, double 0x3FB8BEEF74A49015)
%7 = tail call double @llvm.fmuladd.f64(double %3, double %6, double 0x3FF62E42FEFA3BDC)
%8 = tail call double @llvm.fmuladd.f64(double %3, double 0x3F721878FAEF1B40, double 0x3FA10A8ABB35F2BF)
%9 = tail call double @llvm.fmuladd.f64(double %3, double %8, double 0x3FB19D0A2A39033E)
%10 = tail call double @llvm.fmuladd.f64(double %3, double %9, double 0x3FBFFF140B737B4B)
%11 = tail call double @llvm.fmuladd.f64(double %3, double %10, double 5.000000e-01)
%12 = tail call double @log(double %3)
%13 = fmul double %11, %12
%14 = fsub double %7, %13
ret double %14
}