// File: jkingan[P]ladyheather/heathmsc.cpp
// Function: getghar_(int*, double*, double*)
int getghar_(int *mjd, double *fmjd, double *ghar)
{
    static double ghad, d;
    static int i;
    static double fmjdutc, tsecgps, tsecutc;

    if(mjd == 0) return (-1); 
    if(fmjd == 0) return (-1); 
    if(ghar == 0) return (-1); 

/* convert mjd/fmjd in GPS time to Greenwich hour angle (in radians) */

/*** "satellite orbits: models, methods, applications" montenbruck & gill(2000) */
/* section 2.3.1, pg. 33 */
/*** need UT to get sidereal time  ("astronomy on the personal computer", 4th ed) 2005) */
    tsecgps = *fmjd * 86400.;
/* *** GPS time (sec of */
    tsecutc = gps2utc_(&tsecgps);
/* *** UTC time (sec of */
    fmjdutc = tsecutc / 86400.;
/* **** d = MJD - 51544.5d0                               !*** footnote */

/* *** UTC time (fract. */
    d = *mjd - 51544 + (fmjdutc - .5);
/* greenwich hour angle for J2000  (12:00:00 on 1 Jan 2000) */
/***** ghad = 100.46061837504d0 + 360.9856473662862d0*d  !*** eq. 2.85 (+d
igits)*/
/* *** days since */
    ghad = d * 360.9856473662862 + 280.46061837504;
/* *** normalize to 0-360 and convert to radians */
/* *** corrn.   (+ */
    i = (int) (ghad / 360.);
    *ghar = (ghad - i * 360.) / stuff_1.rad;
    while(*ghar > stuff_1.pi2) {
       *ghar -= stuff_1.pi2;
    }
    while(*ghar < 0.) {
       *ghar += stuff_1.pi2;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x1469d7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x146b59
cmpq $0x0, -0x18(%rbp)
jne 0x1469ea
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x146b59
cmpq $0x0, -0x20(%rbp)
jne 0x1469fd
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x146b59
movq -0x18(%rbp), %rax
movsd 0x285ff(%rip), %xmm0    # 0x16f008
mulsd (%rax), %xmm0
movsd %xmm0, 0x2942e3(%rip)   # 0x3dacf8
leaq 0x2942dc(%rip), %rdi    # 0x3dacf8
callq 0x146c50
movsd %xmm0, 0x2942d7(%rip)   # 0x3dad00
movsd 0x2942cf(%rip), %xmm0   # 0x3dad00
movsd 0x285cf(%rip), %xmm1    # 0x16f008
divsd %xmm1, %xmm0
movsd %xmm0, 0x2942ab(%rip)   # 0x3dacf0
movq -0x10(%rbp), %rax
movl (%rax), %eax
subl $0xc958, %eax           # imm = 0xC958
cvtsi2sd %eax, %xmm0
movsd 0x294294(%rip), %xmm1   # 0x3dacf0
movsd 0x2862c(%rip), %xmm2    # 0x16f090
subsd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x29426c(%rip)   # 0x3dace0
movsd 0x294264(%rip), %xmm0   # 0x3dace0
movsd 0x4855c(%rip), %xmm1    # 0x18efe0
mulsd %xmm1, %xmm0
movsd 0x48558(%rip), %xmm1    # 0x18efe8
addsd %xmm1, %xmm0
movsd %xmm0, 0x29423c(%rip)   # 0x3dacd8
movsd 0x294234(%rip), %xmm0   # 0x3dacd8
movsd 0x3c084(%rip), %xmm1    # 0x182b30
divsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, 0x29422e(%rip)    # 0x3dace8
movsd 0x294216(%rip), %xmm1   # 0x3dacd8
cvtsi2sdl 0x29421e(%rip), %xmm0 # 0x3dace8
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd 0x3c047(%rip), %xmm2    # 0x182b30
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
divsd 0x293bd7(%rip), %xmm0   # 0x3da6d0
movq -0x20(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x20(%rbp), %rax
movsd (%rax), %xmm0
ucomisd 0x293bcf(%rip), %xmm0   # 0x3da6e0
jbe 0x146b2d
movsd 0x293bc5(%rip), %xmm1   # 0x3da6e0
movq -0x20(%rbp), %rax
movsd (%rax), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%rax)
jmp 0x146b01
jmp 0x146b2f
movq -0x20(%rbp), %rax
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x146b52
movsd 0x293b9c(%rip), %xmm0   # 0x3da6e0
movq -0x20(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
jmp 0x146b2f
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)