// File: /workspace/github_cpp_makefile_star2_O3/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 0x222277(%rip), %rax    # 0x30cfd0
movsd (%rax), %xmm1
xorpd %xmm3, %xmm3
ucomisd %xmm3, %xmm1
leaq 0x22226c(%rip), %rax    # 0x30cfd8
movsd (%rax), %xmm2
jne 0xead7d
jp 0xead7d
ucomisd %xmm3, %xmm2
jne 0xead7d
jp 0xead7d
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, 0x2906dc(%rip)    # 0x37b478
movabsq $0x401921fb54442d18, %rax # imm = 0x401921FB54442D18
movq %rax, 0x2906d3(%rip)    # 0x37b480
movabsq $0x404ca5dc1a63c1f8, %rax # imm = 0x404CA5DC1A63C1F8
movq %rax, 0x2906b2(%rip)    # 0x37b470
addsd 0x20aba(%rip), %xmm0    # 0x10b880
cvttsd2si %xmm0, %eax
cvttpd2dq %xmm0, %xmm3
movl %eax, 0x2906b4(%rip)    # 0x37b488
cvtdq2pd %xmm3, %xmm3
subsd %xmm3, %xmm0
movsd %xmm0, 0x2906ac(%rip)   # 0x37b490
leaq 0x2906a5(%rip), %r15    # 0x37b490
movl %eax, 0x29076f(%rip)    # 0x37b560
leaq 0x290768(%rip), %r12    # 0x37b560
movsd %xmm1, 0x290768(%rip)   # 0x37b568
leaq 0x290761(%rip), %rdi    # 0x37b568
movsd %xmm2, 0x290769(%rip)   # 0x37b578
leaq 0x290762(%rip), %rsi    # 0x37b578
leaq 0x2221c3(%rip), %rax    # 0x30cfe0
movsd (%rax), %xmm0
movsd %xmm0, 0x290747(%rip)   # 0x37b570
leaq 0x290740(%rip), %rdx    # 0x37b570
leaq 0x2906e1(%rip), %rcx    # 0x37b518
leaq 0x2906e2(%rip), %r8     # 0x37b520
leaq 0x2906e3(%rip), %r9     # 0x37b528
callq 0xeafcc
movsd 0x2906c6(%rip), %xmm0   # 0x37b518
movsd %xmm0, 0x290646(%rip)   # 0x37b4a0
leaq 0x29063f(%rip), %r13    # 0x37b4a0
movsd 0x2906b7(%rip), %xmm0   # 0x37b520
movsd %xmm0, 0x290637(%rip)   # 0x37b4a8
movsd 0x2906af(%rip), %xmm0   # 0x37b528
movsd %xmm0, 0x29062f(%rip)   # 0x37b4b0
leaq 0x290638(%rip), %rbx    # 0x37b4c0
movq %r12, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0xeb0ec
leaq 0x290663(%rip), %r14    # 0x37b500
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0xeb416
leaq 0x29062e(%rip), %r9     # 0x37b4e0
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %rcx
movq %r14, %r8
callq 0xebdf8
movsd 0x290612(%rip), %xmm0   # 0x37b4e0
movsd %xmm0, 0x290672(%rip)   # 0x37b548
leaq 0x29066b(%rip), %r9     # 0x37b548
movsd 0x290603(%rip), %xmm0   # 0x37b4e8
movsd %xmm0, 0x290663(%rip)   # 0x37b550
leaq 0x29065c(%rip), %rax    # 0x37b550
movsd 0x2905f4(%rip), %xmm0   # 0x37b4f0
movsd %xmm0, 0x290654(%rip)   # 0x37b558
leaq 0x29064d(%rip), %r10    # 0x37b558
leaq 0x29061e(%rip), %rdx    # 0x37b530
leaq 0x29061f(%rip), %rcx    # 0x37b538
leaq 0x290620(%rip), %r8     # 0x37b540
leaq 0x290641(%rip), %rdi    # 0x37b568
leaq 0x29064a(%rip), %rsi    # 0x37b578
pushq %r10
pushq %rax
callq 0xec493
addq $0x10, %rsp
leaq 0x222107(%rip), %rax    # 0x30d048
movsd (%rax), %xmm0
leaq 0x222114(%rip), %rcx    # 0x30d060
movsd %xmm0, (%rcx)
leaq 0x2220f9(%rip), %rcx    # 0x30d050
movsd (%rcx), %xmm0
leaq 0x222106(%rip), %rdx    # 0x30d068
movsd %xmm0, (%rdx)
leaq 0x2220eb(%rip), %rdx    # 0x30d058
movsd (%rdx), %xmm0
leaq 0x2220f8(%rip), %rsi    # 0x30d070
movsd %xmm0, (%rsi)
movsd 0x1e0b4(%rip), %xmm0    # 0x109038
movsd 0x2905a4(%rip), %xmm1   # 0x37b530
mulsd %xmm0, %xmm1
movsd %xmm1, (%rax)
movsd 0x29059c(%rip), %xmm1   # 0x37b538
mulsd %xmm0, %xmm1
mulsd 0x290598(%rip), %xmm0   # 0x37b540
movsd %xmm1, (%rcx)
movsd %xmm0, (%rdx)
leaq 0x2220c1(%rip), %rax    # 0x30d078
movl $0x1, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq