#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 kay_(double k) {
  static double a[5] = {1.38629436112, .09666344259, .03590092383, .03742563713,
                        .01451196212};
  static double b[5] = {.5, .12498593597, .06880248576, .03328355346,
                        .00441787012};
  double ret_val;
  double peta;
  long int i;
  double kk, eta;
  ret_val = a[0];
  kk = b[0];
  eta = 1. - k * k;
  peta = eta;
  for (i = 2; i <= 5; ++i) {
    ret_val += a[i - 1] * peta;
    kk += b[i - 1] * peta;
    peta *= eta;
  }
  ret_val -= kk * log(eta);
  return ret_val;
}


x86 assembly (clang, -O0):
<kay_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0x2f0b(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0x2f2e(%rip),%xmm0
movsd  %xmm0,-0x28(%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  0xe9c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movq   $0x2,-0x20(%rbp)
cmpq   $0x5,-0x20(%rbp)
jg     1200 <kay_+0xf0>
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
lea    0x2e97(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
lea    0x2e9c(%rip),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    117f <kay_+0x6f>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kay_>:
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
movsd  0xed4(%rip),%xmm2
mulsd  %xmm0,%xmm2
addsd  0xed0(%rip),%xmm2
movapd %xmm0,%xmm3
mulsd  %xmm0,%xmm3
movsd  0xec8(%rip),%xmm4
mulsd  %xmm3,%xmm4
addsd  %xmm1,%xmm4
movapd %xmm0,%xmm1
mulsd  %xmm3,%xmm1
mulsd  0xeb8(%rip),%xmm3
addsd  %xmm2,%xmm3
movsd  0xeb4(%rip),%xmm2
mulsd  %xmm1,%xmm2
movapd %xmm0,%xmm5
mulsd  %xmm1,%xmm5
mulsd  0xea8(%rip),%xmm1
addsd  %xmm4,%xmm2
addsd  %xmm3,%xmm1
movsd  0xea0(%rip),%xmm3
mulsd  %xmm5,%xmm3
addsd  %xmm2,%xmm3
movsd  %xmm3,0x10(%rsp)
mulsd  0xe92(%rip),%xmm5
addsd  %xmm1,%xmm5
movsd  %xmm5,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):
@kay_.a = internal global [5 x double] [double 0x3FF62E42FEFA3BDC, double 0x3FB8BEEF74A49015, double 0x3FA2619B1B7DF892, double 0x3FA32973FF02B86D, double 0x3F8DB87295A64760]
@kay_.b = internal global [5 x double] [double 5.000000e-01, double 0x3FBFFF140B737B4B, double 0x3FB19D0A2A39033E, double 0x3FA10A8ABB35F2BF, double 0x3F721878FAEF1B40]
define double @kay_(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca i64
%6 = alloca double
%7 = alloca double
store double %0, double* %2
%8 = load double, double* getelementptr inbounds ([5 x double], [5 x double]* @kay_.a, i64 0, i64 0)
store double %8, double* %3
%9 = load double, double* getelementptr inbounds ([5 x double], [5 x double]* @kay_.b, i64 0, i64 0)
store double %9, double* %6
%10 = load double, double* %2
%11 = load double, double* %2
%12 = fneg double %10
%13 = call double @llvm.fmuladd.f64(double %12, double %11, double 1.000000e+00)
store double %13, double* %7
%14 = load double, double* %7
store double %14, double* %4
store i64 2, i64* %5
br label %15
15: ; preds = %36, %1
%16 = load i64, i64* %5
%17 = icmp sle i64 %16, 5
br i1 %17, label %18, label %39
18: ; preds = %15
%19 = load i64, i64* %5
%20 = sub nsw i64 %19, 1
%21 = getelementptr inbounds [5 x double], [5 x double]* @kay_.a, i64 0, i64 %20
%22 = load double, double* %21
%23 = load double, double* %4
%24 = load double, double* %3
%25 = call double @llvm.fmuladd.f64(double %22, double %23, double %24)
store double %25, double* %3
%26 = load i64, i64* %5
%27 = sub nsw i64 %26, 1
%28 = getelementptr inbounds [5 x double], [5 x double]* @kay_.b, i64 0, i64 %27
%29 = load double, double* %28
%30 = load double, double* %4
%31 = load double, double* %6
%32 = call double @llvm.fmuladd.f64(double %29, double %30, double %31)
store double %32, double* %6
%33 = load double, double* %7
%34 = load double, double* %4
%35 = fmul double %34, %33
store double %35, double* %4
br label %36
36: ; preds = %18
%37 = load i64, i64* %5
%38 = add nsw i64 %37, 1
store i64 %38, i64* %5
br label %15
39: ; preds = %15
%40 = load double, double* %6
%41 = load double, double* %7
%42 = call double @log(double %41)
%43 = load double, double* %3
%44 = fneg double %40
%45 = call double @llvm.fmuladd.f64(double %44, double %42, double %43)
store double %45, double* %3
%46 = load double, double* %3
ret double %46
}

LLVM IR (-O2):
define double @kay_(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 0x3FB8BEEF74A49015, double 0x3FF62E42FEFA3BDC)
%5 = tail call double @llvm.fmuladd.f64(double %3, double 0x3FBFFF140B737B4B, double 5.000000e-01)
%6 = fmul double %3, %3
%7 = tail call double @llvm.fmuladd.f64(double %6, double 0x3FA2619B1B7DF892, double %4)
%8 = tail call double @llvm.fmuladd.f64(double %6, double 0x3FB19D0A2A39033E, double %5)
%9 = fmul double %3, %6
%10 = tail call double @llvm.fmuladd.f64(double %9, double 0x3FA32973FF02B86D, double %7)
%11 = tail call double @llvm.fmuladd.f64(double %9, double 0x3FA10A8ABB35F2BF, double %8)
%12 = fmul double %3, %9
%13 = tail call double @llvm.fmuladd.f64(double %12, double 0x3F8DB87295A64760, double %10)
%14 = tail call double @llvm.fmuladd.f64(double %12, double 0x3F721878FAEF1B40, double %11)
%15 = tail call double @log(double %3)
%16 = fneg double %14
%17 = tail call double @llvm.fmuladd.f64(double %16, double %15, double %13)
ret double %17
}