// File: /workspace/github_cpp_makefile_star2_O1/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 0x222cea(%rip), %rax    # 0x30cfd0
movsd (%rax), %xmm1
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm1
leaq 0x222cdf(%rip), %rax    # 0x30cfd8
movsd (%rax), %xmm2
jne 0xea30a
jp 0xea30a
ucomisd %xmm3, %xmm2
jne 0xea30a
jp 0xea30a
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, 0x29114f(%rip)    # 0x37b478
movabsq $0x401921fb54442d18, %rax # imm = 0x401921FB54442D18
movq %rax, 0x291146(%rip)    # 0x37b480
movabsq $0x404ca5dc1a63c1f8, %rax # imm = 0x404CA5DC1A63C1F8
movq %rax, 0x291125(%rip)    # 0x37b470
addsd 0x2151d(%rip), %xmm0    # 0x10b870
leaq 0x291136(%rip), %r15    # 0x37b490
cvttsd2si %xmm0, %eax
movl %eax, 0x291124(%rip)    # 0x37b488
cvttpd2dq %xmm0, %xmm3
cvtdq2pd %xmm3, %xmm3
subsd %xmm3, %xmm0
movsd %xmm0, 0x291118(%rip)   # 0x37b490
movl %eax, 0x2911e2(%rip)    # 0x37b560
leaq 0x2911db(%rip), %r12    # 0x37b560
movsd %xmm1, 0x2911db(%rip)   # 0x37b568
leaq 0x2911d4(%rip), %rdi    # 0x37b568
movsd %xmm2, 0x2911dc(%rip)   # 0x37b578
leaq 0x2911d5(%rip), %rsi    # 0x37b578
leaq 0x222c36(%rip), %rax    # 0x30cfe0
movsd (%rax), %xmm0
movsd %xmm0, 0x2911ba(%rip)   # 0x37b570
leaq 0x2911b3(%rip), %rdx    # 0x37b570
leaq 0x291154(%rip), %rcx    # 0x37b518
leaq 0x291155(%rip), %r8     # 0x37b520
leaq 0x291156(%rip), %r9     # 0x37b528
callq 0xea559
movsd 0x291139(%rip), %xmm0   # 0x37b518
movsd %xmm0, 0x2910b9(%rip)   # 0x37b4a0
leaq 0x2910b2(%rip), %r13    # 0x37b4a0
movsd 0x29112a(%rip), %xmm0   # 0x37b520
movsd %xmm0, 0x2910aa(%rip)   # 0x37b4a8
movsd 0x291122(%rip), %xmm0   # 0x37b528
movsd %xmm0, 0x2910a2(%rip)   # 0x37b4b0
leaq 0x2910ab(%rip), %rbx    # 0x37b4c0
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0xea679
leaq 0x2910d6(%rip), %r14    # 0x37b500
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xea9a3
leaq 0x2910a1(%rip), %r9     # 0x37b4e0
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %rcx
movq %r14, %r8
callq 0xeb37d
movsd 0x291085(%rip), %xmm0   # 0x37b4e0
movsd %xmm0, 0x2910e5(%rip)   # 0x37b548
leaq 0x2910de(%rip), %r9     # 0x37b548
movsd 0x291076(%rip), %xmm0   # 0x37b4e8
movsd %xmm0, 0x2910d6(%rip)   # 0x37b550
leaq 0x2910cf(%rip), %rax    # 0x37b550
movsd 0x291067(%rip), %xmm0   # 0x37b4f0
movsd %xmm0, 0x2910c7(%rip)   # 0x37b558
leaq 0x2910c0(%rip), %r10    # 0x37b558
leaq 0x291091(%rip), %rdx    # 0x37b530
leaq 0x291092(%rip), %rcx    # 0x37b538
leaq 0x291093(%rip), %r8     # 0x37b540
leaq 0x2910b4(%rip), %rdi    # 0x37b568
leaq 0x2910bd(%rip), %rsi    # 0x37b578
pushq %r10
pushq %rax
callq 0xeba5e
addq $0x10, %rsp
leaq 0x222b7a(%rip), %rax    # 0x30d048
movsd (%rax), %xmm0
leaq 0x222b87(%rip), %rcx    # 0x30d060
movsd %xmm0, (%rcx)
leaq 0x222b6c(%rip), %rcx    # 0x30d050
movsd (%rcx), %xmm0
leaq 0x222b79(%rip), %rdx    # 0x30d068
movsd %xmm0, (%rdx)
leaq 0x222b5e(%rip), %rdx    # 0x30d058
movsd (%rdx), %xmm0
leaq 0x222b6b(%rip), %rsi    # 0x30d070
movsd %xmm0, (%rsi)
movsd 0x1eb27(%rip), %xmm0    # 0x109038
movsd 0x291017(%rip), %xmm1   # 0x37b530
mulsd %xmm0, %xmm1
movsd %xmm1, (%rax)
movsd 0x29100f(%rip), %xmm1   # 0x37b538
mulsd %xmm0, %xmm1
mulsd 0x29100b(%rip), %xmm0   # 0x37b540
movsd %xmm1, (%rcx)
movsd %xmm0, (%rdx)
leaq 0x222b34(%rip), %rax    # 0x30d078
movl $0x1, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq