#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 ellipse1(double, double);
double fabs(double);
double ellipseintegral1(double k, double f) {
  int n;
  double y, e, ff;
  k = fabs(k);
  if (k > 1.0)
    k = 1.0 / k;
  n = 0;
  y = fabs(f);
  while (y >= 3.1415926) {
    n++;
    y -= 3.1415926;
  }
  e = 1.0;
  if (y >= 3.1415926 / 2.0) {
    n++;
    e = -e;
    y = 3.1415926 - y;
  }
  if (n == 0)
    ff = ellipse1(k, y);
  else {
    ff = ellipse1(k, 3.1415926 / 2.0);
    ff = 2.0 * n * ff + e * ellipse1(k, y);
  }
  if (f < 0.0)
    ff = -ff;
  return ff;
}


x86 assembly (clang, -O0):
<ellipseintegral1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xef2(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xebc(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1160 <ellipseintegral1+0x50>
movsd  0xeaa(%rip),%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xead(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe7f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11b7 <ellipseintegral1+0xa7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe5f(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    117c <ellipseintegral1+0x6c>
movsd  0xe41(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe3f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1217 <ellipseintegral1+0x107>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xdfb(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    123a <ellipseintegral1+0x12a>
movsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <ellipse1@plt>
movsd  %xmm0,-0x30(%rbp)
jmp    12ad <ellipseintegral1+0x19d>
movsd  -0x8(%rbp),%xmm0
movsd  0xdc9(%rip),%xmm1
call   1030 <ellipse1@plt>
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xdba(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <ellipse1@plt>
movsd  -0x48(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    12dc <ellipseintegral1+0x1cc>
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ellipseintegral1>:
push   %rbx
sub    $0x60,%rsp
andpd  0xee3(%rip),%xmm0
ucomisd 0xefb(%rip),%xmm0
jbe    1137 <ellipseintegral1+0x27>
movsd  0xef1(%rip),%xmm2
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
movapd 0xec1(%rip),%xmm4
andpd  %xmm1,%xmm4
xor    %eax,%eax
ucomisd 0xedb(%rip),%xmm4
movapd %xmm1,0x50(%rsp)
jb     117d <ellipseintegral1+0x6d>
xor    %eax,%eax
movsd  0xed1(%rip),%xmm2
movsd  0xec1(%rip),%xmm1
nopw   0x0(%rax,%rax,1)
add    $0x1,%eax
addsd  %xmm2,%xmm4
ucomisd %xmm1,%xmm4
jae    1170 <ellipseintegral1+0x60>
movsd  0xeb3(%rip),%xmm1
xor    %ebx,%ebx
ucomisd %xmm1,%xmm4
setae  %bl
movsd  0xe92(%rip),%xmm3
subsd  %xmm4,%xmm3
movapd %xmm1,%xmm5
cmpnlesd %xmm4,%xmm5
movapd %xmm5,%xmm2
andnpd %xmm3,%xmm2
andpd  %xmm5,%xmm4
orpd   %xmm2,%xmm4
add    %eax,%ebx
je     1225 <ellipseintegral1+0x115>
movapd %xmm0,0x20(%rsp)
movapd %xmm4,0x30(%rsp)
movapd %xmm5,0x40(%rsp)
call   1030 <ellipse1@plt>
movsd  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
addsd  %xmm0,%xmm0
movapd %xmm0,0x10(%rsp)
movapd 0x20(%rsp),%xmm0
movaps 0x30(%rsp),%xmm1
call   1030 <ellipse1@plt>
movapd 0x10(%rsp),%xmm3
movapd 0x40(%rsp),%xmm2
movapd %xmm2,%xmm1
andpd  %xmm0,%xmm1
xorpd  0xdff(%rip),%xmm0
andnpd %xmm0,%xmm2
orpd   %xmm1,%xmm2
mulsd  0x8(%rsp),%xmm3
addsd  %xmm2,%xmm3
jmp    1232 <ellipseintegral1+0x122>
movapd %xmm4,%xmm1
call   1030 <ellipse1@plt>
movapd %xmm0,%xmm3
movapd 0xdd6(%rip),%xmm2
xorpd  %xmm3,%xmm2
xorpd  %xmm1,%xmm1
movapd 0x50(%rsp),%xmm0
cmpltsd %xmm1,%xmm0
andpd  %xmm0,%xmm2
andnpd %xmm3,%xmm0
orpd   %xmm2,%xmm0
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @ellipseintegral1(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
store double %0, double* %3
store double %1, double* %4
%9 = load double, double* %3
%10 = call double @llvm.fabs.f64(double %9)
store double %10, double* %3
%11 = load double, double* %3
%12 = fcmp ogt double %11, 1.000000e+00
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load double, double* %3
%15 = fdiv double 1.000000e+00, %14
store double %15, double* %3
br label %16
16: ; preds = %13, %2
store i32 0, i32* %5
%17 = load double, double* %4
%18 = call double @llvm.fabs.f64(double %17)
store double %18, double* %6
br label %19
19: ; preds = %22, %16
%20 = load double, double* %6
%21 = fcmp oge double %20, 0x400921FB4D12D84A
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
%25 = load double, double* %6
%26 = fsub double %25, 0x400921FB4D12D84A
store double %26, double* %6
br label %19
27: ; preds = %19
store double 1.000000e+00, double* %7
%28 = load double, double* %6
%29 = fcmp oge double %28, 0x3FF921FB4D12D84A
br i1 %29, label %30, label %37
30: ; preds = %27
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
%33 = load double, double* %7
%34 = fneg double %33
store double %34, double* %7
%35 = load double, double* %6
%36 = fsub double 0x400921FB4D12D84A, %35
store double %36, double* %6
br label %37
37: ; preds = %30, %27
%38 = load i32, i32* %5
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %37
%41 = load double, double* %3
%42 = load double, double* %6
%43 = call double @ellipse1(double %41, double %42)
store double %43, double* %8
br label %57
44: ; preds = %37
%45 = load double, double* %3
%46 = call double @ellipse1(double %45, double 0x3FF921FB4D12D84A)
store double %46, double* %8
%47 = load i32, i32* %5
%48 = sitofp i32 %47 to double
%49 = fmul double 2.000000e+00, %48
%50 = load double, double* %8
%51 = load double, double* %7
%52 = load double, double* %3
%53 = load double, double* %6
%54 = call double @ellipse1(double %52, double %53)
%55 = fmul double %51, %54
%56 = call double @llvm.fmuladd.f64(double %49, double %50, double %55)
store double %56, double* %8
br label %57
57: ; preds = %44, %40
%58 = load double, double* %4
%59 = fcmp olt double %58, 0.000000e+00
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = load double, double* %8
%62 = fneg double %61
store double %62, double* %8
br label %63
63: ; preds = %60, %57
%64 = load double, double* %8
ret double %64
}

LLVM IR (-O2):
define double @ellipseintegral1(double %0, double %1) {
%3 = tail call double @llvm.fabs.f64(double %0)
%4 = fcmp ogt double %3, 1.000000e+00
%5 = fdiv double 1.000000e+00, %3
%6 = select i1 %4, double %5, double %3
%7 = tail call double @llvm.fabs.f64(double %1)
%8 = fcmp ult double %7, 0x400921FB4D12D84A
br i1 %8, label %15, label %9
9: ; preds = %2, %9
%10 = phi double [ %13, %9 ], [ %7, %2 ]
%11 = phi i32 [ %12, %9 ], [ 0, %2 ]
%12 = add nuw nsw i32 %11, 1
%13 = fadd double %10, 0xC00921FB4D12D84A
%14 = fcmp ult double %13, 0x400921FB4D12D84A
br i1 %14, label %15, label %9
15: ; preds = %9, %2
%16 = phi i32 [ 0, %2 ], [ %12, %9 ]
%17 = phi double [ %7, %2 ], [ %13, %9 ]
%18 = fcmp ult double %17, 0x3FF921FB4D12D84A
%19 = fsub double 0x400921FB4D12D84A, %17
%20 = xor i1 %18, true
%21 = zext i1 %20 to i32
%22 = add nuw nsw i32 %16, %21
%23 = select i1 %18, double %17, double %19
%24 = icmp eq i32 %22, 0
br i1 %24, label %25, label %27
25: ; preds = %15
%26 = tail call double @ellipse1(double %6, double %23)
br label %35
27: ; preds = %15
%28 = tail call double @ellipse1(double %6, double 0x3FF921FB4D12D84A)
%29 = sitofp i32 %22 to double
%30 = fmul double %29, 2.000000e+00
%31 = tail call double @ellipse1(double %6, double %23)
%32 = fneg double %31
%33 = select i1 %18, double %31, double %32
%34 = tail call double @llvm.fmuladd.f64(double %30, double %28, double %33)
br label %35
35: ; preds = %27, %25
%36 = phi double [ %26, %25 ], [ %34, %27 ]
%37 = fcmp olt double %1, 0.000000e+00
%38 = fneg double %36
%39 = select i1 %37, double %38, double %36
ret double %39
}