#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 carlson_elliptic_rf(double, double, double);
double carlson_elliptic_rj(double, double, double, double);
double elliptic_complete_third(double en, double ak) {
  double q;
  q = (1.0 - ak) * (1.0 + ak);
  if (q > 0.0)
    return (carlson_elliptic_rf(0.0, q, 1.0) +
            en * carlson_elliptic_rj(0.0, q, 1.0, 1.0 - en) / 3.0);
  else
    return (-1.0);
}


x86 assembly (clang, -O0):
<elliptic_complete_third>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  0xec6(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  0xeb9(%rip),%xmm1
addsd  -0x18(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11d8 <elliptic_complete_third+0xb8>
movsd  -0x20(%rbp),%xmm1
xorps  %xmm0,%xmm0
movsd  0xe89(%rip),%xmm2
call   1030 <carlson_elliptic_rf@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm1
movsd  0xe68(%rip),%xmm3
subsd  -0x10(%rbp),%xmm3
xorps  %xmm0,%xmm0
movsd  0xe58(%rip),%xmm2
call   1040 <carlson_elliptic_rj@plt>
movsd  -0x30(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm2,%xmm1
movsd  0xe4a(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11e5 <elliptic_complete_third+0xc5>
movsd  0xe28(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<elliptic_complete_third>:
sub    $0x18,%rsp
movaps %xmm0,%xmm3
movsd  0xed1(%rip),%xmm2
movapd %xmm2,%xmm0
subsd  %xmm1,%xmm0
addsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jbe    119b <elliptic_complete_third+0x7b>
xorpd  %xmm0,%xmm0
movsd  %xmm3,(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1030 <carlson_elliptic_rf@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0xe95(%rip),%xmm2
movapd %xmm2,%xmm3
subsd  (%rsp),%xmm3
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
call   1040 <carlson_elliptic_rj@plt>
mulsd  (%rsp),%xmm0
divsd  0xe80(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret
movsd  0xe65(%rip),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @elliptic_complete_third(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
%7 = load double, double* %5
%8 = fsub double 1.000000e+00, %7
%9 = load double, double* %5
%10 = fadd double 1.000000e+00, %9
%11 = fmul double %8, %10
store double %11, double* %6
%12 = load double, double* %6
%13 = fcmp ogt double %12, 0.000000e+00
br i1 %13, label %14, label %25
14: ; preds = %2
%15 = load double, double* %6
%16 = call double @carlson_elliptic_rf(double 0.000000e+00, double %15, double 1.000000e+00)
%17 = load double, double* %4
%18 = load double, double* %6
%19 = load double, double* %4
%20 = fsub double 1.000000e+00, %19
%21 = call double @carlson_elliptic_rj(double 0.000000e+00, double %18, double 1.000000e+00, double %20)
%22 = fmul double %17, %21
%23 = fdiv double %22, 3.000000e+00
%24 = fadd double %16, %23
store double %24, double* %3
br label %26
25: ; preds = %2
store double -1.000000e+00, double* %3
br label %26
26: ; preds = %25, %14
%27 = load double, double* %3
ret double %27
}

LLVM IR (-O2):
define double @elliptic_complete_third(double %0, double %1) {
%3 = fsub double 1.000000e+00, %1
%4 = fadd double %1, 1.000000e+00
%5 = fmul double %3, %4
%6 = fcmp ogt double %5, 0.000000e+00
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = tail call double @carlson_elliptic_rf(double 0.000000e+00, double %5, double 1.000000e+00)
%9 = fsub double 1.000000e+00, %0
%10 = tail call double @carlson_elliptic_rj(double 0.000000e+00, double %5, double 1.000000e+00, double %9)
%11 = fmul double %10, %0
%12 = fdiv double %11, 3.000000e+00
%13 = fadd double %8, %12
br label %14
14: ; preds = %2, %7
%15 = phi double [ %13, %7 ], [ -1.000000e+00, %2 ]
ret double %15
}