#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 acos(double const);
double const cos(double const);
double sin(double const);
double sphere_fuzz_lon(const double lat, const double fuzz) {
  const double clat = cos(lat);
  if (clat == 0)
    return M_PI;
  const double slat = sin(lat);
  return acos((cos(fuzz) - slat * slat) / (clat * clat));
}


x86 assembly (clang, -O0):
<sphere_fuzz_lon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    117e <sphere_fuzz_lon+0x4e>
jp     117e <sphere_fuzz_lon+0x4e>
mov    0x2e78(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11db <sphere_fuzz_lon+0xab>
movsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1030 <acos@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sphere_fuzz_lon>:
sub    $0x18,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,(%rsp)
call   1050 <cos@plt>
movapd %xmm0,%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1164 <sphere_fuzz_lon+0x34>
jp     1164 <sphere_fuzz_lon+0x34>
mov    0x2e8d(%rip),%rax
movsd  (%rax),%xmm0
add    $0x18,%rsp
ret
movsd  (%rsp),%xmm0
movsd  %xmm1,(%rsp)
call   1040 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <cos@plt>
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  (%rsp),%xmm1
mulsd  %xmm1,%xmm1
divsd  %xmm1,%xmm0
add    $0x18,%rsp
jmp    1030 <acos@plt>

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @sphere_fuzz_lon(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
%8 = load double, double* %4
%9 = call double @cos(double %8)
store double %9, double* %6
%10 = load double, double* %6
%11 = fcmp oeq double %10, 0.000000e+00
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load double, double* @M_PI
store double %13, double* %3
br label %28
14: ; preds = %2
%15 = load double, double* %4
%16 = call double @sin(double %15)
store double %16, double* %7
%17 = load double, double* %5
%18 = call double @cos(double %17)
%19 = load double, double* %7
%20 = load double, double* %7
%21 = fneg double %19
%22 = call double @llvm.fmuladd.f64(double %21, double %20, double %18)
%23 = load double, double* %6
%24 = load double, double* %6
%25 = fmul double %23, %24
%26 = fdiv double %22, %25
%27 = call double @acos(double %26)
store double %27, double* %3
br label %28
28: ; preds = %14, %12
%29 = load double, double* %3
ret double %29
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @sphere_fuzz_lon(double %0, double %1) {
%3 = tail call double @cos(double %0)
%4 = fcmp oeq double %3, 0.000000e+00
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = load double, double* @M_PI
br label %15
7: ; preds = %2
%8 = tail call double @sin(double %0)
%9 = tail call double @cos(double %1)
%10 = fneg double %8
%11 = tail call double @llvm.fmuladd.f64(double %10, double %8, double %9)
%12 = fmul double %3, %3
%13 = fdiv double %11, %12
%14 = tail call double @acos(double %13)
br label %15
15: ; preds = %7, %5
%16 = phi double [ %6, %5 ], [ %14, %7 ]
ret double %16
}