#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 */
int /*<<< orphan*/ cartsph(double, double, double, double *, double *,
                           double *);
double cos(double);
int /*<<< orphan*/ range(double *, int);
double sin(double);
int /*<<< orphan*/ sphcart(double, double, double, double *, double *,
                           double *);
int sqrt(int);
void ta_par(double tha, double tdec, double phi, double ht, double *rho,
            double *aha, double *adec) {
  static double last_phi = 1000.0, last_ht = -1000.0, xobs, zobs;
  double x, y, z;
  if (phi != last_phi || ht != last_ht) {
    double cphi, sphi, robs, e2 = (2 - 1 / 298.257) / 298.257;
    cphi = cos(phi);
    sphi = sin(phi);
    robs = 1 / sqrt(1 - e2 * sphi * sphi);
    xobs = (robs + ht) * cphi;
    zobs = (robs * (1 - e2) + ht) * sphi;
    last_phi = phi;
    last_ht = ht;
  }
  sphcart(-tha, tdec, *rho, &x, &y, &z);
  cartsph(x - xobs, y, z - zobs, aha, adec, rho);
  *aha *= -1;
  range(aha, 2 * 3.141592653589793);
}


x86 assembly (clang, -O0):
<ta_par>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
ucomisd 0x2ebb(%rip),%xmm0
jne    11bf <ta_par+0x5f>
jp     11bf <ta_par+0x5f>
movsd  -0x20(%rbp),%xmm0
ucomisd 0x2eaa(%rip),%xmm0
jne    11bf <ta_par+0x5f>
jp     11bf <ta_par+0x5f>
jmp    1299 <ta_par+0x139>
movsd  0xe41(%rip),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1070 <cos@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x70(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xde4(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1080 <sqrt@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
movsd  %xmm0,0x2e15(%rip)
movsd  -0x68(%rbp),%xmm0
movsd  0xda0(%rip),%xmm2
subsd  -0x70(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  %xmm0,0x2df1(%rip)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,0x2dc4(%rip)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,0x2dbf(%rip)
movsd  -0x8(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm2
lea    -0x40(%rbp),%rdi
lea    -0x48(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1040 <sphcart@plt>
movsd  -0x40(%rbp),%xmm0
subsd  0x2d88(%rip),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
subsd  0x2d7e(%rip),%xmm2
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <cartsph@plt>
mov    -0x30(%rbp),%rax
movsd  0xd01(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rdi
mov    $0x6,%esi
call   1060 <range@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ta_par>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
movaps %xmm0,%xmm4
movsd  0x2ed3(%rip),%xmm0
ucomisd %xmm2,%xmm0
jne    1199 <ta_par+0x39>
jp     1199 <ta_par+0x39>
movsd  0x2ecb(%rip),%xmm0
ucomisd %xmm3,%xmm0
jne    1199 <ta_par+0x39>
jnp    1257 <ta_par+0xf7>
movapd %xmm2,%xmm0
movsd  %xmm1,0x20(%rsp)
movaps %xmm4,0x40(%rsp)
movsd  %xmm3,0x10(%rsp)
movsd  %xmm2,(%rsp)
call   1070 <cos@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm0
call   1050 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xe2a(%rip),%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  0xe22(%rip),%xmm1
cvttsd2si %xmm1,%edi
call   1080 <sqrt@plt>
movaps 0x40(%rsp),%xmm4
lea    0x1(%rax),%ecx
xor    %edx,%edx
cmp    $0x3,%ecx
cmovb  %eax,%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
movapd %xmm0,%xmm1
movsd  0x10(%rsp),%xmm2
addsd  %xmm2,%xmm1
mulsd  0x18(%rsp),%xmm1
movsd  %xmm1,0x2e46(%rip)
movsd  0x20(%rsp),%xmm1
mulsd  0xde0(%rip),%xmm0
addsd  %xmm2,%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x2e2e(%rip)
movsd  (%rsp),%xmm0
movsd  %xmm0,0x2e01(%rip)
movsd  %xmm2,0x2e01(%rip)
xorps  0xdc2(%rip),%xmm4
movsd  (%r15),%xmm2
lea    0x38(%rsp),%rdi
lea    0x30(%rsp),%rsi
lea    0x28(%rsp),%rdx
movaps %xmm4,%xmm0
call   1040 <sphcart@plt>
movsd  0x38(%rsp),%xmm0
subsd  0x2de0(%rip),%xmm0
movsd  0x30(%rsp),%xmm1
movsd  0x28(%rsp),%xmm2
subsd  0x2dd4(%rip),%xmm2
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <cartsph@plt>
movsd  (%rbx),%xmm0
xorps  0xd6b(%rip),%xmm0
movlps %xmm0,(%rbx)
mov    %rbx,%rdi
mov    $0x6,%esi
call   1060 <range@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@ta_par.last_phi = internal global double 1.000000e+03
@ta_par.last_ht = internal global double -1.000000e+03
@ta_par.xobs = internal global double 0.000000e+00
@ta_par.zobs = internal global double 0.000000e+00
define void @ta_par(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
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
%22 = load double, double* %10
%23 = load double, double* @ta_par.last_phi
%24 = fcmp une double %22, %23
br i1 %24, label %29, label %25
25: ; preds = %7
%26 = load double, double* %11
%27 = load double, double* @ta_par.last_ht
%28 = fcmp une double %26, %27
br i1 %28, label %29, label %58
29: ; preds = %25, %7
store double 0x3F7B6B924A3DB2EE, double* %21
%30 = load double, double* %10
%31 = call double @cos(double %30)
store double %31, double* %18
%32 = load double, double* %10
%33 = call double @sin(double %32)
store double %33, double* %19
%34 = load double, double* %21
%35 = load double, double* %19
%36 = fmul double %34, %35
%37 = load double, double* %19
%38 = fneg double %36
%39 = call double @llvm.fmuladd.f64(double %38, double %37, double 1.000000e+00)
%40 = fptosi double %39 to i32
%41 = call i32 @sqrt(i32 %40)
%42 = sdiv i32 1, %41
%43 = sitofp i32 %42 to double
store double %43, double* %20
%44 = load double, double* %20
%45 = load double, double* %11
%46 = fadd double %44, %45
%47 = load double, double* %18
%48 = fmul double %46, %47
store double %48, double* @ta_par.xobs
%49 = load double, double* %20
%50 = load double, double* %21
%51 = fsub double 1.000000e+00, %50
%52 = load double, double* %11
%53 = call double @llvm.fmuladd.f64(double %49, double %51, double %52)
%54 = load double, double* %19
%55 = fmul double %53, %54
store double %55, double* @ta_par.zobs
%56 = load double, double* %10
store double %56, double* @ta_par.last_phi
%57 = load double, double* %11
store double %57, double* @ta_par.last_ht
br label %58
58: ; preds = %29, %25
%59 = load double, double* %8
%60 = fneg double %59
%61 = load double, double* %9
%62 = load double*, double** %12
%63 = load double, double* %62
%64 = call i32 @sphcart(double %60, double %61, double %63, double* %15, double* %16, double* %17)
%65 = load double, double* %15
%66 = load double, double* @ta_par.xobs
%67 = fsub double %65, %66
%68 = load double, double* %16
%69 = load double, double* %17
%70 = load double, double* @ta_par.zobs
%71 = fsub double %69, %70
%72 = load double*, double** %13
%73 = load double*, double** %14
%74 = load double*, double** %12
%75 = call i32 @cartsph(double %67, double %68, double %71, double* %72, double* %73, double* %74)
%76 = load double*, double** %13
%77 = load double, double* %76
%78 = fmul double %77, -1.000000e+00
store double %78, double* %76
%79 = load double*, double** %13
%80 = call i32 @range(double* %79, i32 6)
ret void
}

LLVM IR (-O2):
@ta_par.last_phi = internal unnamed_addr global double 1.000000e+03
@ta_par.last_ht = internal unnamed_addr global double -1.000000e+03
@ta_par.xobs = internal unnamed_addr global double 0.000000e+00
@ta_par.zobs = internal unnamed_addr global double 0.000000e+00
define void @ta_par(double %0, double %1, double %2, double %3, double* %4, double* %5, double* %6) {
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = bitcast double* %8 to i8*
%12 = bitcast double* %9 to i8*
%13 = bitcast double* %10 to i8*
%14 = load double, double* @ta_par.last_phi
%15 = fcmp une double %14, %2
%16 = load double, double* @ta_par.last_ht
%17 = fcmp une double %16, %3
%18 = select i1 %15, i1 true, i1 %17
br i1 %18, label %19, label %34
19: ; preds = %7
%20 = tail call double @cos(double %2)
%21 = tail call double @sin(double %2)
%22 = fmul double %21, 0xBF7B6B924A3DB2EE
%23 = tail call double @llvm.fmuladd.f64(double %22, double %21, double 1.000000e+00)
%24 = fptosi double %23 to i32
%25 = tail call i32 @sqrt(i32 %24)
%26 = add i32 %25, 1
%27 = icmp ult i32 %26, 3
%28 = select i1 %27, i32 %25, i32 0
%29 = sitofp i32 %28 to double
%30 = fadd double %29, %3
%31 = fmul double %20, %30
store double %31, double* @ta_par.xobs
%32 = tail call double @llvm.fmuladd.f64(double %29, double 0x3FEFC928DB6B849A, double %3)
%33 = fmul double %21, %32
store double %33, double* @ta_par.zobs
store double %2, double* @ta_par.last_phi
store double %3, double* @ta_par.last_ht
br label %34
34: ; preds = %7, %19
%35 = fneg double %0
%36 = load double, double* %4
%37 = call i32 @sphcart(double %35, double %1, double %36, double* %8, double* %9, double* %10)
%38 = load double, double* %8
%39 = load double, double* @ta_par.xobs
%40 = fsub double %38, %39
%41 = load double, double* %9
%42 = load double, double* %10
%43 = load double, double* @ta_par.zobs
%44 = fsub double %42, %43
%45 = call i32 @cartsph(double %40, double %41, double %44, double* %5, double* %6, double* %4)
%46 = load double, double* %5
%47 = fneg double %46
store double %47, double* %5
%48 = call i32 @range(double* %5, i32 6)
ret void
}