#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 M_PI;
double abs(double);
double cos(double);
double sin(double);
double box_ctrlon(double ll_lon, double ll_lat, double ur_lon, double ur_lat,
                  double clon) {
  double phi1, phi2, dphi, lat1, lat2, dphi1, dphi2;
  double f1, f2, fac, fint;
  double ctrlon = 0.0;
  int i;
  clon = clon;
  for (i = 0; i < 2; i++) {
    if (i == 0) {
      phi1 = ur_lon;
      phi2 = ll_lon;
      lat1 = lat2 = ll_lat;
    } else {
      phi1 = ll_lon;
      phi2 = ur_lon;
      lat1 = lat2 = ur_lat;
    }
    dphi = phi1 - phi2;
    f1 = 0.5 * (cos(lat1) * sin(lat1) + lat1);
    f2 = 0.5 * (cos(lat2) * sin(lat2) + lat2);
    if (dphi > M_PI)
      dphi = dphi - 2.0 * M_PI;
    if (dphi < -M_PI)
      dphi = dphi + 2.0 * M_PI;
    dphi1 = phi1 - clon;
    if (dphi1 > M_PI)
      dphi1 -= 2.0 * M_PI;
    if (dphi1 < -M_PI)
      dphi1 += 2.0 * M_PI;
    dphi2 = phi2 - clon;
    if (dphi2 > M_PI)
      dphi2 -= 2.0 * M_PI;
    if (dphi2 < -M_PI)
      dphi2 += 2.0 * M_PI;
    if (abs(dphi2 - dphi1) < M_PI) {
      ctrlon -= dphi * (dphi1 * f1 + dphi2 * f2) / 2.0;
    } else {
      if (dphi1 > 0.0)
        fac = M_PI;
      else
        fac = -M_PI;
      fint = f1 + (f2 - f1) * (fac - dphi1) / abs(dphi);
      ctrlon -= 0.5 * dphi1 * (dphi1 - fac) * f1 -
                0.5 * dphi2 * (dphi2 + fac) * f2 +
                0.5 * fac * (dphi1 + dphi2) * fint;
    }
  }
  return (ctrlon * (6371000.) * (6371000.));
}


x86 assembly (clang, -O0):
<box_ctrlon>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x8c(%rbp)
cmpl   $0x2,-0x8c(%rbp)
jge    15dc <box_ctrlon+0x4ac>
cmpl   $0x0,-0x8c(%rbp)
jne    11b5 <box_ctrlon+0x85>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  %xmm0,-0x48(%rbp)
jmp    11d8 <box_ctrlon+0xa8>
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  %xmm0,-0x48(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x48(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0xa0(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xde5(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
call   1040 <sin@plt>
movsd  -0x98(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xda0(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x40(%rbp),%xmm0
mov    0x2d6b(%rip),%rax
ucomisd (%rax),%xmm0
jbe    12a4 <box_ctrlon+0x174>
movsd  -0x40(%rbp),%xmm0
mov    0x2d55(%rip),%rax
movsd  (%rax),%xmm1
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm1
mov    0x2d38(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jbe    12f2 <box_ctrlon+0x1c2>
movsd  -0x40(%rbp),%xmm1
mov    0x2d07(%rip),%rax
movsd  (%rax),%xmm0
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    0x2cdb(%rip),%rax
ucomisd (%rax),%xmm0
jbe    1334 <box_ctrlon+0x204>
mov    0x2cca(%rip),%rax
movsd  (%rax),%xmm1
movsd  -0x58(%rbp),%xmm0
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm1
mov    0x2ca8(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jbe    1382 <box_ctrlon+0x252>
mov    0x2c7c(%rip),%rax
movsd  (%rax),%xmm0
movsd  -0x58(%rbp),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
mov    0x2c4b(%rip),%rax
ucomisd (%rax),%xmm0
jbe    13c4 <box_ctrlon+0x294>
mov    0x2c3a(%rip),%rax
movsd  (%rax),%xmm1
movsd  -0x60(%rbp),%xmm0
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm1
mov    0x2c18(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jbe    1412 <box_ctrlon+0x2e2>
mov    0x2bec(%rip),%rax
movsd  (%rax),%xmm0
movsd  -0x60(%rbp),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
call   1030 <abs@plt>
movaps %xmm0,%xmm1
mov    0x2bbd(%rip),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    1483 <box_ctrlon+0x353>
movsd  -0x40(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm3
movsd  -0x60(%rbp),%xmm2
mulsd  -0x70(%rbp),%xmm2
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
mulsd  %xmm0,%xmm1
movsd  0xbaa(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    15c3 <box_ctrlon+0x493>
movsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    14aa <box_ctrlon+0x37a>
mov    0x2b4c(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x78(%rbp)
jmp    14d1 <box_ctrlon+0x3a1>
mov    0x2b37(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x70(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm1
subsd  -0x58(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x40(%rbp),%xmm0
call   1030 <abs@plt>
movsd  -0xb0(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0xa8(%rbp),%xmm0
ff
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xad8(%rip),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
subsd  -0x78(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x68(%rbp),%xmm2
movsd  0xab8(%rip),%xmm1
mulsd  -0x60(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm3
addsd  -0x78(%rbp),%xmm3
mulsd  %xmm3,%xmm1
mulsd  -0x70(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xa79(%rip),%xmm1
mulsd  -0x78(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
addsd  -0x60(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  -0x80(%rbp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x88(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
jmp    15c8 <box_ctrlon+0x498>
mov    -0x8c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8c(%rbp)
jmp    1173 <box_ctrlon+0x43>
movsd  0xa1c(%rip),%xmm0
mulsd  -0x88(%rbp),%xmm0
ff
movsd  0xa0c(%rip),%xmm1
mulsd  %xmm1,%xmm0
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<box_ctrlon>:
push   %r14
push   %rbx
sub    $0xa8,%rsp
movsd  %xmm4,0x88(%rsp)
movsd  %xmm3,0x78(%rsp)
movsd  %xmm2,0x30(%rsp)
movsd  %xmm1,0x80(%rsp)
movsd  %xmm0,0x28(%rsp)
xorpd  %xmm0,%xmm0
mov    $0x1,%bl
mov    0x2e7d(%rip),%r14
jmp    1266 <box_ctrlon+0x136>
xorpd  %xmm2,%xmm2
movapd 0x10(%rsp),%xmm0
cmpltsd %xmm0,%xmm2
movapd %xmm0,%xmm3
movapd %xmm2,%xmm0
andpd  %xmm1,%xmm0
xorpd  0xe8d(%rip),%xmm1
andnpd %xmm1,%xmm2
orpd   %xmm0,%xmm2
movapd %xmm2,0x60(%rsp)
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
subsd  %xmm3,%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm2,0x90(%rsp)
movapd 0x40(%rsp),%xmm0
call   1030 <abs@plt>
movapd 0x90(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm7
addsd  %xmm7,%xmm1
movapd %xmm1,%xmm5
movapd 0x10(%rsp),%xmm4
movapd %xmm4,%xmm0
movsd  0xe0b(%rip),%xmm2
mulsd  %xmm2,%xmm0
movapd %xmm4,%xmm1
movapd 0x60(%rsp),%xmm6
subsd  %xmm6,%xmm1
mulsd  %xmm0,%xmm1
movapd 0x50(%rsp),%xmm3
addsd  %xmm3,%xmm4
movapd %xmm3,%xmm0
addsd  %xmm6,%xmm0
mulsd  0xdeb(%rip),%xmm3
mulsd  %xmm0,%xmm3
mulsd  (%rsp),%xmm3
mulsd  %xmm7,%xmm1
addsd  %xmm3,%xmm1
movapd %xmm6,%xmm0
mulsd  %xmm2,%xmm0
mulsd  %xmm4,%xmm0
mulsd  %xmm5,%xmm0
addsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
movsd  0x38(%rsp),%xmm0
subsd  %xmm1,%xmm0
test   $0x1,%bl
mov    $0x0,%ebx
je     1487 <box_ctrlon+0x357>
movsd  %xmm0,0x38(%rsp)
movsd  0x80(%rsp),%xmm0
movsd  0x28(%rsp),%xmm2
movsd  0x30(%rsp),%xmm1
test   $0x1,%bl
jne    1298 <box_ctrlon+0x168>
movsd  0x78(%rsp),%xmm0
movsd  0x30(%rsp),%xmm2
movsd  0x28(%rsp),%xmm1
movsd  %xmm0,(%rsp)
movapd %xmm1,0x10(%rsp)
movapd %xmm2,0x50(%rsp)
subsd  %xmm2,%xmm1
movapd %xmm1,0x40(%rsp)
call   1050 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
movapd %xmm0,%xmm1
mulsd  0x8(%rsp),%xmm1
movsd  (%rsp),%xmm2
addsd  %xmm2,%xmm1
movsd  0xd1d(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movapd %xmm2,%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x60(%rsp)
movsd  (%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x60(%rsp),%xmm0
addsd  (%rsp),%xmm0
mulsd  0xce7(%rip),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%r14),%xmm0
movapd %xmm0,%xmm1
mulsd  0xcd9(%rip),%xmm1
movapd %xmm1,%xmm2
movapd 0x40(%rsp),%xmm3
addsd  %xmm3,%xmm2
movapd %xmm0,%xmm4
cmpltsd %xmm3,%xmm4
movapd %xmm3,%xmm5
movapd %xmm4,%xmm3
andnpd %xmm5,%xmm3
andpd  %xmm2,%xmm4
orpd   %xmm3,%xmm4
movapd %xmm0,%xmm3
movapd 0xcba(%rip),%xmm2
xorpd  %xmm2,%xmm3
movapd %xmm0,%xmm2
addsd  %xmm0,%xmm2
movapd %xmm2,%xmm5
addsd  %xmm4,%xmm5
movapd %xmm4,%xmm6
cmpltsd %xmm3,%xmm6
andpd  %xmm6,%xmm5
andnpd %xmm4,%xmm6
orpd   %xmm5,%xmm6
movapd %xmm6,0x40(%rsp)
movsd  0x88(%rsp),%xmm8
movapd 0x10(%rsp),%xmm6
subsd  %xmm8,%xmm6
movapd %xmm1,%xmm4
addsd  %xmm6,%xmm4
movapd %xmm0,%xmm5
cmpltsd %xmm6,%xmm5
movapd %xmm6,%xmm7
movapd %xmm5,%xmm6
andnpd %xmm7,%xmm6
andpd  %xmm4,%xmm5
orpd   %xmm6,%xmm5
movapd %xmm2,%xmm4
addsd  %xmm5,%xmm4
movapd %xmm5,%xmm6
cmpltsd %xmm3,%xmm6
andpd  %xmm6,%xmm4
andnpd %xmm5,%xmm6
orpd   %xmm4,%xmm6
movapd 0x50(%rsp),%xmm4
subsd  %xmm8,%xmm4
addsd  %xmm4,%xmm1
cmpltsd %xmm4,%xmm0
movapd %xmm4,%xmm5
movapd %xmm0,%xmm4
andnpd %xmm5,%xmm4
andpd  %xmm1,%xmm0
orpd   %xmm4,%xmm0
addsd  %xmm0,%xmm2
movapd %xmm0,%xmm1
cmpltsd %xmm3,%xmm1
andpd  %xmm1,%xmm2
andnpd %xmm0,%xmm1
orpd   %xmm2,%xmm1
movapd %xmm1,0x50(%rsp)
movapd %xmm1,%xmm0
movapd %xmm6,0x10(%rsp)
subsd  %xmm6,%xmm0
call   1030 <abs@plt>
movsd  (%r14),%xmm1
ucomisd %xmm0,%xmm1
jbe    1170 <box_ctrlon+0x40>
movsd  (%rsp),%xmm1
mulsd  0x50(%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
movapd 0x40(%rsp),%xmm1
mulsd  %xmm0,%xmm1
mulsd  0xb7e(%rip),%xmm1
jmp    124e <box_ctrlon+0x11e>
movsd  0xb89(%rip),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
add    $0xa8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @box_ctrlon(double %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%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 i32
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
store double 0.000000e+00, double* %22
%24 = load double, double* %10
store double %24, double* %10
store i32 0, i32* %23
br label %25
25: ; preds = %181, %5
%26 = load i32, i32* %23
%27 = icmp slt i32 %26, 2
br i1 %27, label %28, label %184
28: ; preds = %25
%29 = load i32, i32* %23
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %28
%32 = load double, double* %8
store double %32, double* %11
%33 = load double, double* %6
store double %33, double* %12
%34 = load double, double* %7
store double %34, double* %15
store double %34, double* %14
br label %39
35: ; preds = %28
%36 = load double, double* %6
store double %36, double* %11
%37 = load double, double* %8
store double %37, double* %12
%38 = load double, double* %9
store double %38, double* %15
store double %38, double* %14
br label %39
39: ; preds = %35, %31
%40 = load double, double* %11
%41 = load double, double* %12
%42 = fsub double %40, %41
store double %42, double* %13
%43 = load double, double* %14
%44 = call double @cos(double %43)
%45 = load double, double* %14
%46 = call double @sin(double %45)
%47 = load double, double* %14
%48 = call double @llvm.fmuladd.f64(double %44, double %46, double %47)
%49 = fmul double 5.000000e-01, %48
store double %49, double* %18
%50 = load double, double* %15
%51 = call double @cos(double %50)
%52 = load double, double* %15
%53 = call double @sin(double %52)
%54 = load double, double* %15
%55 = call double @llvm.fmuladd.f64(double %51, double %53, double %54)
%56 = fmul double 5.000000e-01, %55
store double %56, double* %19
%57 = load double, double* %13
%58 = load double, double* @M_PI
%59 = fcmp ogt double %57, %58
br i1 %59, label %60, label %64
60: ; preds = %39
%61 = load double, double* %13
%62 = load double, double* @M_PI
%63 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %62, double %61)
store double %63, double* %13
br label %64
64: ; preds = %60, %39
%65 = load double, double* %13
%66 = load double, double* @M_PI
%67 = fneg double %66
%68 = fcmp olt double %65, %67
br i1 %68, label %69, label %73
69: ; preds = %64
%70 = load double, double* %13
%71 = load double, double* @M_PI
%72 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %71, double %70)
store double %72, double* %13
br label %73
73: ; preds = %69, %64
%74 = load double, double* %11
%75 = load double, double* %10
%76 = fsub double %74, %75
store double %76, double* %16
%77 = load double, double* %16
%78 = load double, double* @M_PI
%79 = fcmp ogt double %77, %78
br i1 %79, label %80, label %84
80: ; preds = %73
%81 = load double, double* @M_PI
%82 = load double, double* %16
%83 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %81, double %82)
store double %83, double* %16
br label %84
84: ; preds = %80, %73
%85 = load double, double* %16
%86 = load double, double* @M_PI
%87 = fneg double %86
%88 = fcmp olt double %85, %87
br i1 %88, label %89, label %93
89: ; preds = %84
%90 = load double, double* @M_PI
%91 = load double, double* %16
%92 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %90, double %91)
store double %92, double* %16
br label %93
93: ; preds = %89, %84
%94 = load double, double* %12
%95 = load double, double* %10
%96 = fsub double %94, %95
store double %96, double* %17
%97 = load double, double* %17
%98 = load double, double* @M_PI
%99 = fcmp ogt double %97, %98
br i1 %99, label %100, label %104
100: ; preds = %93
%101 = load double, double* @M_PI
%102 = load double, double* %17
%103 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %101, double %102)
store double %103, double* %17
br label %104
104: ; preds = %100, %93
%105 = load double, double* %17
%106 = load double, double* @M_PI
%107 = fneg double %106
%108 = fcmp olt double %105, %107
br i1 %108, label %109, label %113
109: ; preds = %104
%110 = load double, double* @M_PI
%111 = load double, double* %17
%112 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %110, double %111)
store double %112, double* %17
br label %113
113: ; preds = %109, %104
%114 = load double, double* %17
%115 = load double, double* %16
%116 = fsub double %114, %115
%117 = call double @abs(double %116)
%118 = load double, double* @M_PI
%119 = fcmp olt double %117, %118
br i1 %119, label %120, label %132
120: ; preds = %113
%121 = load double, double* %13
%122 = load double, double* %16
%123 = load double, double* %18
%124 = load double, double* %17
%125 = load double, double* %19
%126 = fmul double %124, %125
%127 = call double @llvm.fmuladd.f64(double %122, double %123, double %126)
%128 = fmul double %121, %127
%129 = fdiv double %128, 2.000000e+00
%130 = load double, double* %22
%131 = fsub double %130, %129
store double %131, double* %22
br label %180
132: ; preds = %113
%133 = load double, double* %16
%134 = fcmp ogt double %133, 0.000000e+00
br i1 %134, label %135, label %137
135: ; preds = %132
%136 = load double, double* @M_PI
store double %136, double* %20
br label %140
137: ; preds = %132
%138 = load double, double* @M_PI
%139 = fneg double %138
store double %139, double* %20
br label %140
140: ; preds = %137, %135
%141 = load double, double* %18
%142 = load double, double* %19
%143 = load double, double* %18
%144 = fsub double %142, %143
%145 = load double, double* %20
%146 = load double, double* %16
%147 = fsub double %145, %146
%148 = fmul double %144, %147
%149 = load double, double* %13
%150 = call double @abs(double %149)
%151 = fdiv double %148, %150
%152 = fadd double %141, %151
store double %152, double* %21
%153 = load double, double* %16
%154 = fmul double 5.000000e-01, %153
%155 = load double, double* %16
%156 = load double, double* %20
%157 = fsub double %155, %156
%158 = fmul double %154, %157
%159 = load double, double* %18
%160 = load double, double* %17
%161 = fmul double 5.000000e-01, %160
%162 = load double, double* %17
%163 = load double, double* %20
%164 = fadd double %162, %163
%165 = fmul double %161, %164
%166 = load double, double* %19
%167 = fmul double %165, %166
%168 = fneg double %167
%169 = call double @llvm.fmuladd.f64(double %158, double %159, double %168)
%170 = load double, double* %20
%171 = fmul double 5.000000e-01, %170
%172 = load double, double* %16
%173 = load double, double* %17
%174 = fadd double %172, %173
%175 = fmul double %171, %174
%176 = load double, double* %21
%177 = call double @llvm.fmuladd.f64(double %175, double %176, double %169)
%178 = load double, double* %22
%179 = fsub double %178, %177
store double %179, double* %22
br label %180
180: ; preds = %140, %120
br label %181
181: ; preds = %180
%182 = load i32, i32* %23
%183 = add nsw i32 %182, 1
store i32 %183, i32* %23
br label %25
184: ; preds = %25
%185 = load double, double* %22
%186 = fmul double %185, 6.371000e+06
%187 = fmul double %186, 6.371000e+06
ret double %187
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @box_ctrlon(double %0, double %1, double %2, double %3, double %4) {
br label %6
6: ; preds = %5, %74
%7 = phi i1 [ true, %5 ], [ false, %74 ]
%8 = phi double [ 0.000000e+00, %5 ], [ %76, %74 ]
%9 = select i1 %7, double %1, double %3
%10 = select i1 %7, double %0, double %2
%11 = select i1 %7, double %2, double %0
%12 = fsub double %11, %10
%13 = tail call double @cos(double %9)
%14 = tail call double @sin(double %9)
%15 = tail call double @llvm.fmuladd.f64(double %13, double %14, double %9)
%16 = fmul double %15, 5.000000e-01
%17 = tail call double @cos(double %9)
%18 = tail call double @sin(double %9)
%19 = tail call double @llvm.fmuladd.f64(double %17, double %18, double %9)
%20 = fmul double %19, 5.000000e-01
%21 = load double, double* @M_PI
%22 = fcmp ogt double %12, %21
%23 = tail call double @llvm.fmuladd.f64(double %21, double -2.000000e+00, double %12)
%24 = select i1 %22, double %23, double %12
%25 = fneg double %21
%26 = fcmp olt double %24, %25
%27 = tail call double @llvm.fmuladd.f64(double %21, double 2.000000e+00, double %24)
%28 = select i1 %26, double %27, double %24
%29 = fsub double %11, %4
%30 = fcmp ogt double %29, %21
%31 = tail call double @llvm.fmuladd.f64(double %21, double -2.000000e+00, double %29)
%32 = select i1 %30, double %31, double %29
%33 = fcmp olt double %32, %25
%34 = tail call double @llvm.fmuladd.f64(double %21, double 2.000000e+00, double %32)
%35 = select i1 %33, double %34, double %32
%36 = fsub double %10, %4
%37 = fcmp ogt double %36, %21
%38 = tail call double @llvm.fmuladd.f64(double %21, double -2.000000e+00, double %36)
%39 = select i1 %37, double %38, double %36
%40 = fcmp olt double %39, %25
%41 = tail call double @llvm.fmuladd.f64(double %21, double 2.000000e+00, double %39)
%42 = select i1 %40, double %41, double %39
%43 = fsub double %42, %35
%44 = tail call double @abs(double %43)
%45 = load double, double* @M_PI
%46 = fcmp olt double %44, %45
br i1 %46, label %47, label %52
47: ; preds = %6
%48 = fmul double %20, %42
%49 = tail call double @llvm.fmuladd.f64(double %35, double %16, double %48)
%50 = fmul double %28, %49
%51 = fmul double %50, 5.000000e-01
br label %74
52: ; preds = %6
%53 = fcmp ogt double %35, 0.000000e+00
%54 = fneg double %45
%55 = select i1 %53, double %45, double %54
%56 = fsub double %20, %16
%57 = fsub double %55, %35
%58 = fmul double %56, %57
%59 = tail call double @abs(double %28)
%60 = fdiv double %58, %59
%61 = fadd double %16, %60
%62 = fmul double %35, 5.000000e-01
%63 = fsub double %35, %55
%64 = fmul double %62, %63
%65 = fadd double %42, %55
%66 = fmul double %42, -5.000000e-01
%67 = fmul double %66, %65
%68 = fmul double %20, %67
%69 = tail call double @llvm.fmuladd.f64(double %64, double %16, double %68)
%70 = fmul double %55, 5.000000e-01
%71 = fadd double %35, %42
%72 = fmul double %71, %70
%73 = tail call double @llvm.fmuladd.f64(double %72, double %61, double %69)
br label %74
74: ; preds = %47, %52
%75 = phi double [ %51, %47 ], [ %73, %52 ]
%76 = fsub double %8, %75
br i1 %7, label %6, label %77
77: ; preds = %74
%78 = fmul double %76, 6.371000e+06
%79 = fmul double %78, 6.371000e+06
ret double %79
}