#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 cos(double);
double sin(double);
double triangle_unitcircle_overlap(double, double, double, double, double,
                                   double);
double ellipoverlap(double xmin, double ymin, double xmax, double ymax,
                    double a, double b, double theta) {
  double cos_m_theta, sin_m_theta, scale;
  double x1, y1, x2, y2, x3, y3, x4, y4;
  cos_m_theta = cos(-theta);
  sin_m_theta = sin(-theta);
  scale = a * b;
  x1 = (xmin * cos_m_theta - ymin * sin_m_theta) / a;
  y1 = (xmin * sin_m_theta + ymin * cos_m_theta) / b;
  x2 = (xmax * cos_m_theta - ymin * sin_m_theta) / a;
  y2 = (xmax * sin_m_theta + ymin * cos_m_theta) / b;
  x3 = (xmax * cos_m_theta - ymax * sin_m_theta) / a;
  y3 = (xmax * sin_m_theta + ymax * cos_m_theta) / b;
  x4 = (xmin * cos_m_theta - ymax * sin_m_theta) / a;
  y4 = (xmin * sin_m_theta + ymax * cos_m_theta) / b;
  return scale * (triangle_unitcircle_overlap(x1, y1, x2, y2, x3, y3) +
                  triangle_unitcircle_overlap(x1, y1, x4, y4, x3, y3));
}


x86 assembly (clang, -O0):
<ellipoverlap>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
movsd  %xmm6,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x8(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x68(%rbp),%xmm2
movsd  -0x70(%rbp),%xmm3
movsd  -0x78(%rbp),%xmm4
movsd  -0x80(%rbp),%xmm5
call   1040 <triangle_unitcircle_overlap@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x58(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x88(%rbp),%xmm2
ff
movsd  -0x90(%rbp),%xmm3
ff
movsd  -0x78(%rbp),%xmm4
movsd  -0x80(%rbp),%xmm5
call   1040 <triangle_unitcircle_overlap@plt>
movsd  -0xa0(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x98(%rbp),%xmm0
ff
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ellipoverlap>:
sub    $0x68,%rsp
movsd  %xmm6,0x28(%rsp)
movsd  %xmm5,0x48(%rsp)
movsd  %xmm4,0x40(%rsp)
movsd  %xmm3,0x20(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
movaps %xmm6,%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x28(%rsp),%xmm0
call   1030 <sin@plt>
movapd 0xe80(%rip),%xmm13
xorpd  %xmm0,%xmm13
movsd  0x40(%rsp),%xmm6
movapd %xmm6,%xmm1
movsd  0x48(%rsp),%xmm8
mulsd  %xmm8,%xmm1
movsd  %xmm1,0x28(%rsp)
movapd %xmm0,%xmm2
movsd  0x10(%rsp),%xmm3
mulsd  %xmm3,%xmm2
movsd  0x8(%rsp),%xmm10
movapd %xmm10,%xmm5
movsd  0x30(%rsp),%xmm12
mulsd  %xmm12,%xmm5
movapd %xmm5,%xmm11
movapd %xmm5,%xmm9
addsd  %xmm2,%xmm11
divsd  %xmm6,%xmm11
movsd  %xmm11,0x38(%rsp)
mulsd  %xmm12,%xmm3
mulsd  %xmm13,%xmm10
movapd %xmm10,%xmm5
addsd  %xmm3,%xmm5
divsd  %xmm8,%xmm5
movapd %xmm5,%xmm1
movsd  %xmm5,0x10(%rsp)
movsd  0x18(%rsp),%xmm7
movapd %xmm7,%xmm5
mulsd  %xmm12,%xmm5
addsd  %xmm5,%xmm2
divsd  %xmm6,%xmm2
mulsd  %xmm7,%xmm13
addsd  %xmm13,%xmm3
divsd  %xmm8,%xmm3
movsd  0x20(%rsp),%xmm7
mulsd  %xmm7,%xmm0
addsd  %xmm0,%xmm5
divsd  %xmm6,%xmm5
movapd %xmm5,%xmm4
movsd  %xmm5,0x8(%rsp)
mulsd  %xmm7,%xmm12
addsd  %xmm12,%xmm13
divsd  %xmm8,%xmm13
movapd %xmm13,%xmm5
movapd %xmm13,0x50(%rsp)
addsd  %xmm0,%xmm9
divsd  %xmm6,%xmm9
movsd  %xmm9,0x20(%rsp)
addsd  %xmm10,%xmm12
divsd  %xmm8,%xmm12
movsd  %xmm12,0x30(%rsp)
movapd %xmm11,%xmm0
call   1040 <triangle_unitcircle_overlap@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x38(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
movsd  0x30(%rsp),%xmm3
movsd  0x8(%rsp),%xmm4
movaps 0x50(%rsp),%xmm5
call   1040 <triangle_unitcircle_overlap@plt>
addsd  0x18(%rsp),%xmm0
mulsd  0x28(%rsp),%xmm0
add    $0x68,%rsp
ret

LLVM IR (-O0):
define double @ellipoverlap(double %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%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
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca double
%23 = alloca double
%24 = alloca double
%25 = alloca double
store double %0, double* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
store double %6, double* %14
%26 = load double, double* %14
%27 = fneg double %26
%28 = call double @cos(double %27)
store double %28, double* %15
%29 = load double, double* %14
%30 = fneg double %29
%31 = call double @sin(double %30)
store double %31, double* %16
%32 = load double, double* %12
%33 = load double, double* %13
%34 = fmul double %32, %33
store double %34, double* %17
%35 = load double, double* %8
%36 = load double, double* %15
%37 = load double, double* %9
%38 = load double, double* %16
%39 = fmul double %37, %38
%40 = fneg double %39
%41 = call double @llvm.fmuladd.f64(double %35, double %36, double %40)
%42 = load double, double* %12
%43 = fdiv double %41, %42
store double %43, double* %18
%44 = load double, double* %8
%45 = load double, double* %16
%46 = load double, double* %9
%47 = load double, double* %15
%48 = fmul double %46, %47
%49 = call double @llvm.fmuladd.f64(double %44, double %45, double %48)
%50 = load double, double* %13
%51 = fdiv double %49, %50
store double %51, double* %19
%52 = load double, double* %10
%53 = load double, double* %15
%54 = load double, double* %9
%55 = load double, double* %16
%56 = fmul double %54, %55
%57 = fneg double %56
%58 = call double @llvm.fmuladd.f64(double %52, double %53, double %57)
%59 = load double, double* %12
%60 = fdiv double %58, %59
store double %60, double* %20
%61 = load double, double* %10
%62 = load double, double* %16
%63 = load double, double* %9
%64 = load double, double* %15
%65 = fmul double %63, %64
%66 = call double @llvm.fmuladd.f64(double %61, double %62, double %65)
%67 = load double, double* %13
%68 = fdiv double %66, %67
store double %68, double* %21
%69 = load double, double* %10
%70 = load double, double* %15
%71 = load double, double* %11
%72 = load double, double* %16
%73 = fmul double %71, %72
%74 = fneg double %73
%75 = call double @llvm.fmuladd.f64(double %69, double %70, double %74)
%76 = load double, double* %12
%77 = fdiv double %75, %76
store double %77, double* %22
%78 = load double, double* %10
%79 = load double, double* %16
%80 = load double, double* %11
%81 = load double, double* %15
%82 = fmul double %80, %81
%83 = call double @llvm.fmuladd.f64(double %78, double %79, double %82)
%84 = load double, double* %13
%85 = fdiv double %83, %84
store double %85, double* %23
%86 = load double, double* %8
%87 = load double, double* %15
%88 = load double, double* %11
%89 = load double, double* %16
%90 = fmul double %88, %89
%91 = fneg double %90
%92 = call double @llvm.fmuladd.f64(double %86, double %87, double %91)
%93 = load double, double* %12
%94 = fdiv double %92, %93
store double %94, double* %24
%95 = load double, double* %8
%96 = load double, double* %16
%97 = load double, double* %11
%98 = load double, double* %15
%99 = fmul double %97, %98
%100 = call double @llvm.fmuladd.f64(double %95, double %96, double %99)
%101 = load double, double* %13
%102 = fdiv double %100, %101
store double %102, double* %25
%103 = load double, double* %17
%104 = load double, double* %18
%105 = load double, double* %19
%106 = load double, double* %20
%107 = load double, double* %21
%108 = load double, double* %22
%109 = load double, double* %23
%110 = call double @triangle_unitcircle_overlap(double %104, double %105, double %106, double %107, double %108, double %109)
%111 = load double, double* %18
%112 = load double, double* %19
%113 = load double, double* %24
%114 = load double, double* %25
%115 = load double, double* %22
%116 = load double, double* %23
%117 = call double @triangle_unitcircle_overlap(double %111, double %112, double %113, double %114, double %115, double %116)
%118 = fadd double %110, %117
%119 = fmul double %103, %118
ret double %119
}

LLVM IR (-O2):
define double @ellipoverlap(double %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = tail call double @cos(double %6)
%9 = tail call double @sin(double %6)
%10 = fneg double %9
%11 = fmul double %4, %5
%12 = fmul double %9, %1
%13 = tail call double @llvm.fmuladd.f64(double %0, double %8, double %12)
%14 = fdiv double %13, %4
%15 = fmul double %8, %1
%16 = tail call double @llvm.fmuladd.f64(double %0, double %10, double %15)
%17 = fdiv double %16, %5
%18 = tail call double @llvm.fmuladd.f64(double %2, double %8, double %12)
%19 = fdiv double %18, %4
%20 = tail call double @llvm.fmuladd.f64(double %2, double %10, double %15)
%21 = fdiv double %20, %5
%22 = fmul double %9, %3
%23 = tail call double @llvm.fmuladd.f64(double %2, double %8, double %22)
%24 = fdiv double %23, %4
%25 = fmul double %8, %3
%26 = tail call double @llvm.fmuladd.f64(double %2, double %10, double %25)
%27 = fdiv double %26, %5
%28 = tail call double @llvm.fmuladd.f64(double %0, double %8, double %22)
%29 = fdiv double %28, %4
%30 = tail call double @llvm.fmuladd.f64(double %0, double %10, double %25)
%31 = fdiv double %30, %5
%32 = tail call double @triangle_unitcircle_overlap(double %14, double %17, double %19, double %21, double %24, double %27)
%33 = tail call double @triangle_unitcircle_overlap(double %14, double %17, double %29, double %31, double %24, double %27)
%34 = fadd double %32, %33
%35 = fmul double %11, %34
ret double %35
}