// File: DoubleString[P]RtConverter/src/Rtklib/rtkcmn.cpp
// Function: bamboo::nmf(bamboo::gtime_t, double const*, double const*, double*)
static double nmf(gtime_t time, const double pos[], const double azel[],
                  double *mapfw)
{
    /* ref [5] table 3 */
    /* hydro-ave-a,b,c, hydro-amp-a,b,c, wet-a,b,c at latitude 15,30,45,60,75 */
    const double coef[][5]={
        { 1.2769934E-3, 1.2683230E-3, 1.2465397E-3, 1.2196049E-3, 1.2045996E-3},
        { 2.9153695E-3, 2.9152299E-3, 2.9288445E-3, 2.9022565E-3, 2.9024912E-3},
        { 62.610505E-3, 62.837393E-3, 63.721774E-3, 63.824265E-3, 64.258455E-3},
        
        { 0.0000000E-0, 1.2709626E-5, 2.6523662E-5, 3.4000452E-5, 4.1202191E-5},
        { 0.0000000E-0, 2.1414979E-5, 3.0160779E-5, 7.2562722E-5, 11.723375E-5},
        { 0.0000000E-0, 9.0128400E-5, 4.3497037E-5, 84.795348E-5, 170.37206E-5},
        
        { 5.8021897E-4, 5.6794847E-4, 5.8118019E-4, 5.9727542E-4, 6.1641693E-4},
        { 1.4275268E-3, 1.5138625E-3, 1.4572752E-3, 1.5007428E-3, 1.7599082E-3},
        { 4.3472961E-2, 4.6729510E-2, 4.3908931E-2, 4.4626982E-2, 5.4736038E-2}
    };
    const double aht[]={ 2.53E-5, 5.49E-3, 1.14E-3}; /* height correction */
    
    double y,cosy,ah[3],aw[3],dm,el=azel[1],lat=pos[0]*R2D,hgt=pos[2];
    int i;
    
    if (el<=0.0) {
        if (mapfw) *mapfw=0.0;
        return 0.0;
    }
    /* year from doy 28, added half a year for southern latitudes */
    y=(time2doy(time)-28.0)/365.25+(lat<0.0?0.5:0.0);
    
    cosy=cos(2.0*pi*y);
    lat=fabs(lat);
    
    for (i=0;i<3;i++) {
        ah[i]=interpc(coef[i  ],lat)-interpc(coef[i+3],lat)*cosy;
        aw[i]=interpc(coef[i+6],lat);
    }
    /* ellipsoidal height is used instead of height above sea level */
    dm=(1.0/sin(el)-mapf(el,aht[0],aht[1],aht[2]))*hgt/1E3;
    
    if (mapfw) *mapfw=mapf(el,aw[0],aw[1],aw[2]);
    
    return mapf(el,ah[0],ah[1],ah[2])+dm;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x18(%rbp)
movsd %xmm0, -0x10(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
leaq -0x1a0(%rbp), %rdi
leaq 0x2f3e2(%rip), %rsi     # 0xc7230
movl $0x168, %edx            # imm = 0x168
callq 0x9610
movq 0x2f541(%rip), %rax     # 0xc73a0
movq %rax, -0x1c0(%rbp)
movq 0x2f53b(%rip), %rax     # 0xc73a8
movq %rax, -0x1b8(%rbp)
movq 0x2f535(%rip), %rax     # 0xc73b0
movq %rax, -0x1b0(%rbp)
movq -0x28(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x220(%rbp)
movq -0x20(%rbp), %rax
movsd 0x28b51(%rip), %xmm0    # 0xc09f0
mulsd (%rax), %xmm0
movsd %xmm0, -0x228(%rbp)
movq -0x20(%rbp), %rax
movsd 0x10(%rax), %xmm0
movsd %xmm0, -0x230(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x220(%rbp), %xmm0
jb 0x97ee8
cmpq $0x0, -0x30(%rbp)
je 0x97edb
movq -0x30(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
xorps %xmm0, %xmm0
movsd %xmm0, -0x8(%rbp)
jmp 0x9815f
movq -0x18(%rbp), %rax
movq %rax, -0x248(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x240(%rbp)
movq -0x248(%rbp), %rdi
movsd -0x240(%rbp), %xmm0
callq 0x8f720
movsd 0x2f746(%rip), %xmm1    # 0xc7660
subsd %xmm1, %xmm0
movsd 0x2f732(%rip), %xmm1    # 0xc7658
divsd %xmm1, %xmm0
movsd -0x228(%rbp), %xmm1
movsd 0x24f46(%rip), %xmm4    # 0xbce80
xorps %xmm3, %xmm3
cmpltsd %xmm3, %xmm1
movaps %xmm1, %xmm2
andpd %xmm4, %xmm2
andnpd %xmm3, %xmm1
orpd %xmm2, %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, -0x1c8(%rbp)
movsd 0x24efb(%rip), %xmm0    # 0xbce60
mulsd -0x1c8(%rbp), %xmm0
callq 0x9e00
movsd %xmm0, -0x1d0(%rbp)
movsd -0x228(%rbp), %xmm0
movaps 0x25297(%rip), %xmm1    # 0xbd220
pand %xmm1, %xmm0
movsd %xmm0, -0x228(%rbp)
movl $0x0, -0x234(%rbp)
cmpl $0x3, -0x234(%rbp)
jge 0x98085
movslq -0x234(%rbp), %rax
leaq -0x1a0(%rbp), %rdi
imulq $0x28, %rax, %rax
addq %rax, %rdi
movsd -0x228(%rbp), %xmm0
callq 0x99b40
movsd %xmm0, -0x250(%rbp)
movl -0x234(%rbp), %eax
addl $0x3, %eax
cltq
leaq -0x1a0(%rbp), %rdi
imulq $0x28, %rax, %rax
addq %rax, %rdi
movsd -0x228(%rbp), %xmm0
callq 0x99b40
movsd -0x250(%rbp), %xmm1
movsd -0x1d0(%rbp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movslq -0x234(%rbp), %rax
movsd %xmm0, -0x1f0(%rbp,%rax,8)
movl -0x234(%rbp), %eax
addl $0x6, %eax
cltq
leaq -0x1a0(%rbp), %rdi
imulq $0x28, %rax, %rax
addq %rax, %rdi
movsd -0x228(%rbp), %xmm0
callq 0x99b40
movslq -0x234(%rbp), %rax
movsd %xmm0, -0x210(%rbp,%rax,8)
movl -0x234(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x234(%rbp)
jmp 0x97f9f
movsd -0x220(%rbp), %xmm0
callq 0x91a0
movaps %xmm0, %xmm1
movsd 0x23dc3(%rip), %xmm0    # 0xbbe60
divsd %xmm1, %xmm0
movsd %xmm0, -0x258(%rbp)
movsd -0x220(%rbp), %xmm0
movsd -0x1c0(%rbp), %xmm1
movsd -0x1b8(%rbp), %xmm2
movsd -0x1b0(%rbp), %xmm3
callq 0x99c10
movaps %xmm0, %xmm1
movsd -0x258(%rbp), %xmm0
subsd %xmm1, %xmm0
mulsd -0x230(%rbp), %xmm0
movsd 0x2533b(%rip), %xmm1    # 0xbd428
divsd %xmm1, %xmm0
movsd %xmm0, -0x218(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x9812d
movsd -0x220(%rbp), %xmm0
movsd -0x210(%rbp), %xmm1
movsd -0x208(%rbp), %xmm2
movsd -0x200(%rbp), %xmm3
callq 0x99c10
movq -0x30(%rbp), %rax
movsd %xmm0, (%rax)
movsd -0x220(%rbp), %xmm0
movsd -0x1f0(%rbp), %xmm1
movsd -0x1e8(%rbp), %xmm2
movsd -0x1e0(%rbp), %xmm3
callq 0x99c10
addsd -0x218(%rbp), %xmm0
movsd %xmm0, -0x8(%rbp)
movsd -0x8(%rbp), %xmm0
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
nopl (%rax)