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


x86 assembly (clang, -O0):
<elliptic_complete_second>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  0xecb(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xebe(%rip),%xmm1
addsd  -0x10(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11cb <elliptic_complete_second+0xab>
movsd  -0x18(%rbp),%xmm1
xorps  %xmm0,%xmm0
movsd  0xe8e(%rip),%xmm2
call   1040 <carlson_elliptic_rf@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm1
xorps  %xmm0,%xmm0
movsd  0xe65(%rip),%xmm2
call   1030 <carlson_elliptic_rd@plt>
movsd  -0x28(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
mulsd  %xmm2,%xmm1
movsd  0xe57(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f8 <elliptic_complete_second+0xd8>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11eb <elliptic_complete_second+0xcb>
movsd  0xe27(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f8 <elliptic_complete_second+0xd8>
movsd  0xe0d(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<elliptic_complete_second>:
sub    $0x18,%rsp
movapd %xmm0,%xmm3
movsd  0xed0(%rip),%xmm1
addsd  %xmm1,%xmm0
subsd  %xmm3,%xmm1
mulsd  %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jbe    11a5 <elliptic_complete_second+0x85>
movsd  0xeb2(%rip),%xmm2
xorpd  %xmm0,%xmm0
movsd  %xmm3,(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1040 <carlson_elliptic_rf@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
mulsd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0xe78(%rip),%xmm2
call   1030 <carlson_elliptic_rd@plt>
mulsd  (%rsp),%xmm0
divsd  0xe6e(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret
xor    %eax,%eax
ucomisd %xmm1,%xmm0
seta   %al
lea    0xe5b(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
add    $0x18,%rsp
ret

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

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