#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 acos(double);
double cos(double);
double sin(double);
int /*<<< orphan*/ solve_sphere(double, double, double, double, double *,
                                double *);
void aaha_aux(double lt, double x, double y, double *p, double *q) {
  static double last_lt = -3434, slt, clt;
  double cap, B;
  if (lt != last_lt) {
    slt = sin(lt);
    clt = cos(lt);
    last_lt = lt;
  }
  solve_sphere(-x, 3.141592653589793 / 2 - y, slt, clt, &cap, &B);
  *p = B;
  *q = 3.141592653589793 / 2 - acos(cap);
}


x86 assembly (clang, -O0):
<aaha_aux>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
ucomisd 0x2ed4(%rip),%xmm0
jne    117d <aaha_aux+0x3d>
jp     117d <aaha_aux+0x3d>
jmp    11ae <aaha_aux+0x6e>
movsd  -0x8(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,0x2ec1(%rip)
movsd  -0x8(%rbp),%xmm0
call   1060 <cos@plt>
movsd  %xmm0,0x2eb7(%rip)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,0x2e92(%rip)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe2e(%rip),%xmm1
subsd  -0x18(%rbp),%xmm1
movsd  0x2e71(%rip),%xmm2
movsd  0x2e71(%rip),%xmm3
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1050 <solve_sphere@plt>
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x30(%rbp),%xmm0
call   1030 <acos@plt>
movaps %xmm0,%xmm1
movsd  0xdea(%rip),%xmm0
subsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aaha_aux>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movaps %xmm1,%xmm4
movsd  0x2ee8(%rip),%xmm1
ucomisd %xmm0,%xmm1
jne    1160 <aaha_aux+0x20>
jnp    11ac <aaha_aux+0x6c>
movaps %xmm4,0x20(%rsp)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm0,(%rsp)
call   1040 <sin@plt>
movsd  %xmm0,0x2ed3(%rip)
movsd  (%rsp),%xmm0
call   1060 <cos@plt>
movsd  0x8(%rsp),%xmm2
movaps 0x20(%rsp),%xmm4
movaps %xmm0,%xmm3
movsd  %xmm0,0x2ebb(%rip)
movsd  (%rsp),%xmm0
movsd  %xmm0,0x2e96(%rip)
jmp    11b4 <aaha_aux+0x74>
movsd  0x2ea4(%rip),%xmm3
xorps  0xe45(%rip),%xmm4
movsd  0xe4d(%rip),%xmm1
subsd  %xmm2,%xmm1
movsd  0x2e81(%rip),%xmm2
lea    0x18(%rsp),%rdi
lea    0x10(%rsp),%rsi
movaps %xmm4,%xmm0
call   1050 <solve_sphere@plt>
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x18(%rsp),%xmm0
call   1030 <acos@plt>
movsd  0xe12(%rip),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@aaha_aux.last_lt = internal global double -3.434000e+03
@aaha_aux.slt = internal global double 0.000000e+00
@aaha_aux.clt = internal global double 0.000000e+00
define void @aaha_aux(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
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
%13 = load double, double* %6
%14 = load double, double* @aaha_aux.last_lt
%15 = fcmp une double %13, %14
br i1 %15, label %16, label %22
16: ; preds = %5
%17 = load double, double* %6
%18 = call double @sin(double %17)
store double %18, double* @aaha_aux.slt
%19 = load double, double* %6
%20 = call double @cos(double %19)
store double %20, double* @aaha_aux.clt
%21 = load double, double* %6
store double %21, double* @aaha_aux.last_lt
br label %22
22: ; preds = %16, %5
%23 = load double, double* %7
%24 = fneg double %23
%25 = load double, double* %8
%26 = fsub double 0x3FF921FB54442D18, %25
%27 = load double, double* @aaha_aux.slt
%28 = load double, double* @aaha_aux.clt
%29 = call i32 @solve_sphere(double %24, double %26, double %27, double %28, double* %11, double* %12)
%30 = load double, double* %12
%31 = load double*, double** %9
store double %30, double* %31
%32 = load double, double* %11
%33 = call double @acos(double %32)
%34 = fsub double 0x3FF921FB54442D18, %33
%35 = load double*, double** %10
store double %34, double* %35
ret void
}

LLVM IR (-O2):
@aaha_aux.last_lt = internal unnamed_addr global double -3.434000e+03
@aaha_aux.slt = internal unnamed_addr global double 0.000000e+00
@aaha_aux.clt = internal unnamed_addr global double 0.000000e+00
define void @aaha_aux(double %0, double %1, double %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = alloca double
%7 = alloca double
%8 = bitcast double* %6 to i8*
%9 = bitcast double* %7 to i8*
%10 = load double, double* @aaha_aux.last_lt
%11 = fcmp une double %10, %0
br i1 %11, label %14, label %12
12: ; preds = %5
%13 = load double, double* @aaha_aux.clt
br label %17
14: ; preds = %5
%15 = tail call double @sin(double %0)
store double %15, double* @aaha_aux.slt
%16 = tail call double @cos(double %0)
store double %16, double* @aaha_aux.clt
store double %0, double* @aaha_aux.last_lt
br label %17
17: ; preds = %12, %14
%18 = phi double [ %13, %12 ], [ %16, %14 ]
%19 = fneg double %1
%20 = fsub double 0x3FF921FB54442D18, %2
%21 = load double, double* @aaha_aux.slt
%22 = call i32 @solve_sphere(double %19, double %20, double %21, double %18, double* %6, double* %7)
%23 = load double, double* %7
store double %23, double* %3
%24 = load double, double* %6
%25 = call double @acos(double %24)
%26 = fsub double 0x3FF921FB54442D18, %25
store double %26, double* %4
ret void
}