// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heathmsc.cpp
// Function: calc_earth_tide(double)
void calc_earth_tide(double jd_gps)
{
    static double glad, fmjd, glod, tsec, xsta[3];
    static int lout;
    static double rsun[3], tdel2, etide[3];
    static int iloop;
    static double rmoon[3], x0, y0, z0;
    static double ut, vt, wt;
    static double xt, yt, zt;
    static double sec;
    static int mjd;
    static int ihr, imn, imo, idy, iyr;
    static double gla0, eht0, glo0;

    if((lat == 0.0) && (lon == 0)) return;

    stuff_1.pi = PI;
    stuff_1.pi2 = (PI+PI);
    stuff_1.rad = (180. / PI);

    fmjd = jd_gps - JD_MJD;
    mjd0 = (int) (jd_gps - JD_MJD);
    fmjd = fmjd - (double) mjd0;
    mjd = mjd0;

    gla0 = lat;
    glo0 = lon;
    eht0 = alt; // 0.0;

    geoxyz_(&gla0, &glo0, &eht0, &x0, &y0, &z0);
//sprintf(plot_title, "geo:%f %f %f  mjd0:%d  fmjd:%f", x0,y0,z0, mjd0,fmjd);
    xsta[0] = x0;
    xsta[1] = y0;
    xsta[2] = z0;

    sunxyz_(&mjd, &fmjd, rsun);
//sprintf(debug_text, "rsun:%f %f %f", rsun[0],rsun[1],rsun[2]);
    moonxyz_(&mjd, &fmjd, rmoon);
//sprintf(debug_text2, "rmoon:%f %f %f", rmoon[0],rmoon[1],rmoon[2]);
    detide_(xsta, &mjd, &fmjd, rsun, rmoon, etide);
//sprintf(debug_text3, "etide:%f %f %f", etide[0],etide[1],etide[2]);
    xt = etide[0];
    yt = etide[1];
    zt = etide[2];
    /* determine local geodetic horizon components (topocentric) */
    rge_(&gla0, &glo0, &ut, &vt, &wt, &xt, &yt, &zt);

    last_lat_tide = lat_tide;
    last_lon_tide = lon_tide;
    last_alt_tide = alt_tide;

    lat_tide = ut * 1000.0;  // millimeters
    lon_tide = vt * 1000.0;
    alt_tide = wt * 1000.0;
    have_tides = 1;
}

// Assembly:
leaq 0x220872(%rip), %rax    # 0x2f6fd0
movsd (%rax), %xmm1
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm1
leaq 0x220867(%rip), %rax    # 0x2f6fd8
movsd (%rax), %xmm2
jne 0xd6782
jp 0xd6782
ucomisd %xmm3, %xmm2
jne 0xd6782
jp 0xd6782
retq
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movabsq $0x400921fb54442d18, %rax # imm = 0x400921FB54442D18
movq %rax, 0x28ecd7(%rip)    # 0x365478
movabsq $0x401921fb54442d18, %rax # imm = 0x401921FB54442D18
movq %rax, 0x28ecce(%rip)    # 0x365480
movabsq $0x404ca5dc1a63c1f8, %rax # imm = 0x404CA5DC1A63C1F8
movq %rax, 0x28ecad(%rip)    # 0x365470
addsd 0x1f12d(%rip), %xmm0    # 0xf58f8
cvttsd2si %xmm0, %eax
cvttpd2dq %xmm0, %xmm3
movl %eax, 0x28ecaf(%rip)    # 0x365488
cvtdq2pd %xmm3, %xmm3
subsd %xmm3, %xmm0
movsd %xmm0, 0x28eca7(%rip)   # 0x365490
leaq 0x28eca0(%rip), %r15    # 0x365490
movl %eax, 0x28ed6a(%rip)    # 0x365560
leaq 0x28ed63(%rip), %r12    # 0x365560
movsd %xmm1, 0x28ed63(%rip)   # 0x365568
leaq 0x28ed5c(%rip), %rdi    # 0x365568
movsd %xmm2, 0x28ed64(%rip)   # 0x365578
leaq 0x28ed5d(%rip), %rsi    # 0x365578
leaq 0x2207be(%rip), %rax    # 0x2f6fe0
movsd (%rax), %xmm0
movsd %xmm0, 0x28ed42(%rip)   # 0x365570
leaq 0x28ed3b(%rip), %rdx    # 0x365570
leaq 0x28ecdc(%rip), %rcx    # 0x365518
leaq 0x28ecdd(%rip), %r8     # 0x365520
leaq 0x28ecde(%rip), %r9     # 0x365528
callq 0xd69cf
movsd 0x28ecc1(%rip), %xmm0   # 0x365518
movsd %xmm0, 0x28ec41(%rip)   # 0x3654a0
leaq 0x28ec3a(%rip), %r13    # 0x3654a0
movsd 0x28ecb2(%rip), %xmm0   # 0x365520
movsd %xmm0, 0x28ec32(%rip)   # 0x3654a8
movsd 0x28ecaa(%rip), %xmm0   # 0x365528
movsd %xmm0, 0x28ec2a(%rip)   # 0x3654b0
leaq 0x28ec33(%rip), %rbx    # 0x3654c0
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0xd6aef
leaq 0x28ec5e(%rip), %r14    # 0x365500
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xd6dd9
leaq 0x28ec29(%rip), %r9     # 0x3654e0
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %rcx
movq %r14, %r8
callq 0xd7746
movsd 0x28ec0d(%rip), %xmm0   # 0x3654e0
movsd %xmm0, 0x28ec6d(%rip)   # 0x365548
leaq 0x28ec66(%rip), %r9     # 0x365548
movsd 0x28ebfe(%rip), %xmm0   # 0x3654e8
movsd %xmm0, 0x28ec5e(%rip)   # 0x365550
leaq 0x28ec57(%rip), %rax    # 0x365550
movsd 0x28ebef(%rip), %xmm0   # 0x3654f0
movsd %xmm0, 0x28ec4f(%rip)   # 0x365558
leaq 0x28ec48(%rip), %r10    # 0x365558
leaq 0x28ec19(%rip), %rdx    # 0x365530
leaq 0x28ec1a(%rip), %rcx    # 0x365538
leaq 0x28ec1b(%rip), %r8     # 0x365540
leaq 0x28ec3c(%rip), %rdi    # 0x365568
leaq 0x28ec45(%rip), %rsi    # 0x365578
pushq %r10
pushq %rax
callq 0xd7ddc
popq %rcx
popq %rdx
leaq 0x220704(%rip), %rax    # 0x2f7048
movsd (%rax), %xmm0
leaq 0x220711(%rip), %rcx    # 0x2f7060
movsd %xmm0, (%rcx)
leaq 0x2206f6(%rip), %rcx    # 0x2f7050
movsd (%rcx), %xmm0
leaq 0x220703(%rip), %rdx    # 0x2f7068
movsd %xmm0, (%rdx)
leaq 0x2206e8(%rip), %rdx    # 0x2f7058
movsd (%rdx), %xmm0
leaq 0x2206f5(%rip), %rsi    # 0x2f7070
movsd %xmm0, (%rsi)
movsd 0x1c6b1(%rip), %xmm0    # 0xf3038
movsd 0x28eba1(%rip), %xmm1   # 0x365530
mulsd %xmm0, %xmm1
movsd %xmm1, (%rax)
movsd 0x28eb99(%rip), %xmm1   # 0x365538
mulsd %xmm0, %xmm1
mulsd 0x28eb95(%rip), %xmm0   # 0x365540
movsd %xmm1, (%rcx)
movsd %xmm0, (%rdx)
leaq 0x2206be(%rip), %rax    # 0x2f7078
movl $0x1, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq