// File: /workspace/github_cpp_makefile_star2_O2/DoubleString[P]RtConverter/src/Rtklib/rtkcmn.cpp
// Function: bamboo::eci2ecef(bamboo::gtime_t, double const*, double*, double*)
extern void eci2ecef(gtime_t tutc, const double *erpv, double *U, double *gmst)
{
    const double ep2000[]={2000,1,1,12,0,0};
    static gtime_t tutc_;
    static double U_[9],gmst_;
    gtime_t tgps;
    double eps,ze,th,z,t,t2,t3,dpsi,deps,gast,f[5];
    double R1[9],R2[9],R3[9],R[9],W[9],N[9],P[9],NP[9];
    int i;
    
    trace(4,"eci2ecef: tutc=%s\n",time_str(tutc,3));
    
    if (fabs(timediff(tutc,tutc_))<0.01) { /* read cache */
        for (i=0;i<9;i++) U[i]=U_[i];
        if (gmst) *gmst=gmst_; 
        return;
    }
    tutc_=tutc;
    
    /* terrestrial time */
    tgps=utc2gpst(tutc_);
    t=(timediff(tgps,epoch2time(ep2000))+19.0+32.184)/86400.0/36525.0;
    t2=t*t; t3=t2*t;
    
    /* astronomical arguments */
    ast_args(t,f);
    
    /* iau 1976 precession */
    ze=(2306.2181*t+0.30188*t2+0.017998*t3)*AS2R;
    th=(2004.3109*t-0.42665*t2-0.041833*t3)*AS2R;
    z =(2306.2181*t+1.09468*t2+0.018203*t3)*AS2R;
    eps=(84381.448-46.8150*t-0.00059*t2+0.001813*t3)*AS2R;
    Rz(-z,R1); Ry(th,R2); Rz(-ze,R3);
    matmul("NN",3,3,3,1.0,R1,R2,0.0,R);
    matmul("NN",3,3,3,1.0,R, R3,0.0,P); /* P=Rz(-z)*Ry(th)*Rz(-ze) */
    
    /* iau 1980 nutation */
    nut_iau1980(t,f,&dpsi,&deps);
    Rx(-eps-deps,R1); Rz(-dpsi,R2); Rx(eps,R3);
    matmul("NN",3,3,3,1.0,R1,R2,0.0,R);
    matmul("NN",3,3,3,1.0,R ,R3,0.0,N); /* N=Rx(-eps)*Rz(-dspi)*Rx(eps) */
    
    /* greenwich aparent sidereal time (rad) */
    gmst_=utc2gmst(tutc_,erpv[2]);
    gast=gmst_+dpsi*cos(eps);
    gast+=(0.00264*sin(f[4])+0.000063*sin(2.0*f[4]))*AS2R;
    
    /* eci to ecef transformation matrix */
    Ry(-erpv[0],R1); Rx(-erpv[1],R2); Rz(gast,R3);
    matmul("NN",3,3,3,1.0,R1,R2,0.0,W );
    matmul("NN",3,3,3,1.0,W ,R3,0.0,R ); /* W=Ry(-xp)*Rx(-yp) */
    matmul("NN",3,3,3,1.0,N ,P ,0.0,NP);
    matmul("NN",3,3,3,1.0,R ,NP,0.0,U_); /* U=W*Rz(gast)*N*P */
    
    for (i=0;i<9;i++) U[i]=U_[i];
    if (gmst) *gmst=gmst_; 
    
    trace(5,"gmst=%.12f gast=%.12f\n",gmst_,gast);
    trace(5,"P=\n"); tracemat(5,P,3,3,15,12);
    trace(5,"N=\n"); tracemat(5,N,3,3,15,12);
    trace(5,"W=\n"); tracemat(5,W,3,3,15,12);
    trace(5,"U=\n"); tracemat(5,U,3,3,15,12);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x348, %rsp            # imm = 0x348
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %r13
movsd %xmm0, -0x40(%rbp)
movq %rdi, %rbx
xorps %xmm1, %xmm1
movaps %xmm1, -0x90(%rbp)
movabsq $0x409f400000000000, %rax # imm = 0x409F400000000000
movq %rax, -0xb0(%rbp)
movabsq $0x3ff0000000000000, %r12 # imm = 0x3FF0000000000000
movq %r12, -0xa8(%rbp)
movq %r12, -0xa0(%rbp)
movabsq $0x4028000000000000, %rax # imm = 0x4028000000000000
movq %rax, -0x98(%rbp)
pushq $0x3
popq %rsi
callq 0x47b0e
movq 0x41c9a(%rip), %rsi     # 0x8a040
movsd 0x41c9a(%rip), %xmm0    # 0x8a048
movsd %xmm0, -0x30(%rbp)
movq %rbx, %rdi
callq 0x8340
movsd -0x40(%rbp), %xmm2
addsd %xmm2, %xmm0
subsd -0x30(%rbp), %xmm0
andpd 0x1755f(%rip), %xmm0    # 0x5f930
movsd 0x193df(%rip), %xmm1    # 0x617b8
ucomisd %xmm0, %xmm1
jbe 0x48403
xorl %eax, %eax
leaq 0x41c68(%rip), %rcx     # 0x8a050
cmpq $0x48, %rax
je 0x48bdf
movsd (%rax,%rcx), %xmm0
movsd %xmm0, (%r14,%rax)
addq $0x8, %rax
jmp 0x483e8
movq %r13, -0x70(%rbp)
movq %r15, -0x78(%rbp)
movq %rbx, 0x41c2e(%rip)     # 0x8a040
movsd %xmm2, 0x41c2e(%rip)    # 0x8a048
movq %rbx, %rdi
movapd %xmm2, %xmm0
callq 0x477da
movq %rax, %rbx
movsd %xmm0, -0x30(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x46ee2
movsd %xmm0, -0x40(%rbp)
movq %rbx, %rdi
movq %rax, %rsi
callq 0x8340
addsd -0x30(%rbp), %xmm0
subsd -0x40(%rbp), %xmm0
addsd 0x1845c(%rip), %xmm0    # 0x608b8
addsd 0x2278c(%rip), %xmm0    # 0x6abf0
divsd 0x18454(%rip), %xmm0    # 0x608c0
divsd 0x2272c(%rip), %xmm0    # 0x6aba0
movsd %xmm0, -0x40(%rbp)
movapd %xmm0, %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x50(%rbp)
movapd %xmm0, %xmm2
mulsd %xmm1, %xmm2
movapd %xmm2, -0x60(%rbp)
leaq -0x180(%rbp), %rdi
callq 0x48c03
movsd 0x22751(%rip), %xmm0    # 0x6abf8
movsd -0x50(%rbp), %xmm5
mulsd %xmm5, %xmm0
movsd 0x22748(%rip), %xmm1    # 0x6ac00
movsd -0x40(%rbp), %xmm7
mulsd %xmm7, %xmm1
addsd %xmm1, %xmm0
movsd 0x2273b(%rip), %xmm2    # 0x6ac08
movapd -0x60(%rbp), %xmm6
mulsd %xmm6, %xmm2
movapd %xmm2, %xmm4
movsd 0x2272e(%rip), %xmm2    # 0x6ac10
mulsd %xmm5, %xmm2
movsd 0x2272a(%rip), %xmm3    # 0x6ac18
mulsd %xmm7, %xmm3
addsd %xmm2, %xmm3
movsd 0x22722(%rip), %xmm2    # 0x6ac20
mulsd %xmm6, %xmm2
addsd %xmm3, %xmm2
mulsd 0x2271a(%rip), %xmm2    # 0x6ac28
movsd %xmm2, -0x48(%rbp)
addsd %xmm0, %xmm4
movsd %xmm4, -0x30(%rbp)
movsd 0x2270c(%rip), %xmm0    # 0x6ac30
mulsd %xmm5, %xmm0
addsd %xmm1, %xmm0
movsd 0x22704(%rip), %xmm3    # 0x6ac38
mulsd %xmm6, %xmm3
movsd 0x22700(%rip), %xmm1    # 0x6ac40
mulsd %xmm7, %xmm1
addsd 0x226fc(%rip), %xmm1    # 0x6ac48
mulsd 0x226fc(%rip), %xmm5    # 0x6ac50
addsd %xmm0, %xmm3
movapd %xmm6, %xmm0
mulsd 0x226f4(%rip), %xmm0    # 0x6ac58
leaq -0x218(%rbp), %r15
movq %r12, 0x38(%r15)
andq $0x0, 0x8(%r15)
addsd %xmm1, %xmm5
addsd %xmm5, %xmm0
movapd %xmm0, -0x60(%rbp)
movapd %xmm3, %xmm0
mulsd 0x226d3(%rip), %xmm0    # 0x6ac60
movsd %xmm0, -0x50(%rbp)
xorpd %xmm1, %xmm1
movupd %xmm1, 0x20(%r15)
andq $0x0, 0x30(%r15)
callq 0x8bf0
movsd %xmm0, 0x18(%r15)
movsd %xmm0, -0x8(%r15)
movsd -0x50(%rbp), %xmm0
callq 0x8160
movsd %xmm0, 0x10(%r15)
leaq -0x128(%rbp), %rbx
movq %r12, -0x8(%rbx)
andq $0x0, 0x10(%rbx)
andq $0x0, (%rbx)
xorps 0x184e3(%rip), %xmm0    # 0x60ac0
andq $0x0, -0x10(%rbx)
movlps %xmm0, (%r15)
andq $0x0, -0x20(%rbx)
movsd -0x48(%rbp), %xmm0
callq 0x8bf0
movsd %xmm0, 0x18(%rbx)
movsd %xmm0, -0x28(%rbx)
movsd -0x48(%rbp), %xmm0
callq 0x8160
movsd %xmm0, -0x18(%rbx)
xorps 0x184ab(%rip), %xmm0    # 0x60ac0
movlps %xmm0, 0x8(%rbx)
leaq -0xd8(%rbp), %rbx
movq %r12, 0x18(%rbx)
andq $0x0, -0x18(%rbx)
movsd -0x30(%rbp), %xmm0
mulsd 0x2262a(%rip), %xmm0    # 0x6ac60
movsd %xmm0, -0x30(%rbp)
xorpd %xmm1, %xmm1
movupd %xmm1, (%rbx)
andq $0x0, 0x10(%rbx)
callq 0x8bf0
movsd %xmm0, -0x8(%rbx)
movsd %xmm0, -0x28(%rbx)
movsd -0x30(%rbp), %xmm0
callq 0x8160
movsd %xmm0, -0x10(%rbx)
xorps 0x18453(%rip), %xmm0    # 0x60ac0
movlps %xmm0, -0x20(%rbx)
leaq -0x1d0(%rbp), %r12
movq %r12, (%rsp)
leaq 0x229fa(%rip), %r15     # 0x6b07d
pushq $0x3
popq %rbx
movsd 0x17292(%rip), %xmm2    # 0x5f920
leaq -0x220(%rbp), %r8
leaq -0x150(%rbp), %r9
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
xorpd %xmm1, %xmm1
movq %r15, %rdi
movl %ebx, %esi
movl %ebx, %edx
movl %ebx, %ecx
movaps %xmm2, %xmm0
callq 0x45f19
leaq -0x270(%rbp), %rax
movq %rax, (%rsp)
leaq -0x100(%rbp), %r9
xorpd %xmm1, %xmm1
movq %r15, %rdi
movl %ebx, %esi
movl %ebx, %edx
movl %ebx, %ecx
movsd 0x17240(%rip), %xmm0    # 0x5f920
movq %r12, %r8
callq 0x45f19
leaq 0x20181(%rip), %rbx     # 0x68870
xorl %r15d, %r15d
movq %rbx, %r13
xorpd %xmm3, %xmm3
cmpq $0x6a, %r15
je 0x487a2
xorpd %xmm0, %xmm0
xorl %eax, %eax
cmpq $0x5, %rax
je 0x48728
movsd (%r13,%rax,8), %xmm1
mulsd -0x180(%rbp,%rax,8), %xmm1
addsd %xmm1, %xmm0
incq %rax
jmp 0x48709
imulq $0x50, %r15, %r12
movsd 0x38(%r12,%rbx), %xmm1
mulsd -0x40(%rbp), %xmm1
addsd 0x30(%r12,%rbx), %xmm1
movsd %xmm1, -0x68(%rbp)
movsd %xmm3, -0x48(%rbp)
movsd %xmm0, -0x50(%rbp)
callq 0x8160
mulsd -0x68(%rbp), %xmm0
movsd -0x30(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
movsd 0x48(%r12,%rbx), %xmm0
mulsd -0x40(%rbp), %xmm0
addsd 0x40(%r12,%rbx), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x50(%rbp), %xmm0
callq 0x8bf0
movsd -0x48(%rbp), %xmm3
mulsd -0x68(%rbp), %xmm0
addsd %xmm0, %xmm3
incq %r15
addq $0x50, %r13
jmp 0x486f9
movapd -0x60(%rbp), %xmm2
mulsd 0x22479(%rip), %xmm2    # 0x6ac28
movapd %xmm2, -0x60(%rbp)
movsd 0x224ac(%rip), %xmm0    # 0x6ac68
movsd -0x30(%rbp), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, -0x30(%rbp)
mulsd %xmm0, %xmm3
leaq -0x220(%rbp), %r13
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, (%r13)
movq %rax, %r15
andq $0x0, 0x30(%r13)
movapd 0x182cd(%rip), %xmm0    # 0x60ac0
xorpd %xmm0, %xmm2
subsd %xmm3, %xmm2
movapd %xmm2, -0x40(%rbp)
xorpd %xmm0, %xmm0
leaq -0x218(%rbp), %rax
movupd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movapd %xmm2, %xmm0
callq 0x8bf0
movsd %xmm0, 0x40(%r13)
movsd %xmm0, 0x20(%r13)
movaps -0x40(%rbp), %xmm0
callq 0x8160
movsd %xmm0, 0x38(%r13)
xorps 0x18281(%rip), %xmm0    # 0x60ac0
movlps %xmm0, 0x28(%r13)
leaq -0x150(%rbp), %rbx
movq %r15, 0x40(%rbx)
andq $0x0, 0x10(%rbx)
leaq -0x128(%rbp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movsd -0x30(%rbp), %xmm0
callq 0x8bf0
movsd %xmm0, 0x20(%rbx)
movsd %xmm0, (%rbx)
movsd -0x30(%rbp), %xmm0
callq 0x8160
movaps %xmm0, %xmm1
xorps 0x18233(%rip), %xmm1    # 0x60ac0
movlps %xmm1, 0x18(%rbx)
movsd %xmm0, 0x8(%rbx)
leaq -0x100(%rbp), %rbx
movq %r15, (%rbx)
andq $0x0, 0x30(%rbx)
leaq -0xd8(%rbp), %rax
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
andq $0x0, -0x10(%rax)
movaps -0x60(%rbp), %xmm0
callq 0x8bf0
movsd %xmm0, 0x40(%rbx)
movsd %xmm0, 0x20(%rbx)
movaps -0x60(%rbp), %xmm0
callq 0x8160
movsd %xmm0, 0x38(%rbx)
xorps 0x181e0(%rip), %xmm0    # 0x60ac0
movlps %xmm0, 0x28(%rbx)
leaq -0x1d0(%rbp), %r15
movq %r15, (%rsp)
leaq 0x22787(%rip), %r12     # 0x6b07d
pushq $0x3
popq %rbx
movsd 0x1701f(%rip), %xmm0    # 0x5f920
xorps %xmm1, %xmm1
movq %r12, %rdi
movl %ebx, %esi
movl %ebx, %edx
movl %ebx, %ecx
movq %r13, %r8
leaq -0x150(%rbp), %r9
callq 0x45f19
leaq -0x2c0(%rbp), %rax
movq %rax, (%rsp)
xorps %xmm1, %xmm1
movq %r12, %rdi
movl %ebx, %esi
movl %ebx, %edx
movl %ebx, %ecx
movsd 0x16fe5(%rip), %xmm0    # 0x5f920
movq %r15, %r8
leaq -0x100(%rbp), %r9
callq 0x45f19
movq 0x416ef(%rip), %rdi     # 0x8a040
movsd 0x416ef(%rip), %xmm0    # 0x8a048
movq -0x70(%rbp), %r15
movsd 0x10(%r15), %xmm1
callq 0x478e1
movsd %xmm0, -0x40(%rbp)
movsd %xmm0, 0x41723(%rip)    # 0x8a098
movapd -0x60(%rbp), %xmm0
callq 0x8bf0
mulsd -0x30(%rbp), %xmm0
addsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x160(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
callq 0x8160
movsd %xmm0, -0x40(%rbp)
movsd -0x48(%rbp), %xmm0
addsd %xmm0, %xmm0
callq 0x8160
mulsd 0x222b5(%rip), %xmm0    # 0x6ac70
movsd -0x40(%rbp), %xmm1
mulsd 0x222b0(%rip), %xmm1    # 0x6ac78
addsd %xmm1, %xmm0
movabsq $0x3ff0000000000000, %r12 # imm = 0x3FF0000000000000
movq %r12, 0x20(%r13)
andq $0x0, 0x38(%r13)
mulsd 0x22241(%rip), %xmm0    # 0x6ac28
andq $0x0, 0x28(%r13)
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
andq $0x0, 0x18(%r13)
andq $0x0, 0x8(%r13)
movsd (%r15), %xmm0
callq 0x8bf0
movsd %xmm0, 0x40(%r13)
movsd %xmm0, (%r13)
movsd (%r15), %xmm0
callq 0x8160
movaps %xmm0, %xmm1
xorps 0x18096(%rip), %xmm1    # 0x60ac0
movlps %xmm1, 0x10(%r13)
movsd %xmm0, 0x30(%r13)
leaq -0x150(%rbp), %rax
movq %r12, (%rax)
andq $0x0, 0x30(%rax)
movq %rax, %r12
xorps %xmm0, %xmm0
leaq -0x128(%rbp), %rax
movups %xmm0, -0x20(%rax)
andq $0x0, -0x10(%rax)
movsd 0x8(%r15), %xmm0
callq 0x8bf0
movsd %xmm0, 0x40(%r12)
movsd %xmm0, 0x20(%r12)
movsd 0x8(%r15), %xmm0
callq 0x8160
movapd %xmm0, %xmm1
xorpd 0x18036(%rip), %xmm1    # 0x60ac0
movlpd %xmm1, 0x38(%r12)
movsd %xmm0, 0x28(%r12)
leaq -0x100(%rbp), %r15
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x40(%r15)
andq $0x0, 0x10(%r15)
xorpd %xmm0, %xmm0
leaq -0xd8(%rbp), %rax
movupd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movsd -0x30(%rbp), %xmm0
callq 0x8bf0
movsd %xmm0, 0x20(%r15)
movsd %xmm0, (%r15)
movsd -0x30(%rbp), %xmm0
callq 0x8160
movsd %xmm0, 0x18(%r15)
xorps 0x17fce(%rip), %xmm0    # 0x60ac0
movlps %xmm0, 0x8(%r15)
leaq -0x360(%rbp), %r12
movq %r12, (%rsp)
xorpd %xmm1, %xmm1
leaq 0x22570(%rip), %r15     # 0x6b07d
movq %r15, %rdi
movl %ebx, %esi
movl %ebx, %edx
movl %ebx, %ecx
movsd 0x16e02(%rip), %xmm0    # 0x5f920
movq %r13, %r8
leaq -0x150(%rbp), %r9
callq 0x45f19
leaq -0x1d0(%rbp), %rax
movq %rax, (%rsp)
xorpd %xmm1, %xmm1
movq %r15, %rdi
movq %r15, %r13
movl %ebx, %esi
movl %ebx, %edx
movl %ebx, %ecx
movsd 0x16dd0(%rip), %xmm0    # 0x5f920
movq %r12, %r8
leaq -0x100(%rbp), %r9
callq 0x45f19
leaq -0x310(%rbp), %r15
movq %r15, (%rsp)
leaq -0x270(%rbp), %r9
xorpd %xmm1, %xmm1
movq %r13, %rdi
movl %ebx, %esi
movl %ebx, %edx
movl %ebx, %ecx
movsd 0x16d9a(%rip), %xmm0    # 0x5f920
leaq -0x2c0(%rbp), %r8
callq 0x45f19
leaq 0x414b7(%rip), %r12     # 0x8a050
movq %r12, (%rsp)
xorpd %xmm1, %xmm1
movq %r13, %rdi
movl %ebx, %esi
movl %ebx, %edx
movl %ebx, %ecx
movsd 0x16d6e(%rip), %xmm0    # 0x5f920
leaq -0x1d0(%rbp), %r8
movq %r15, %r9
callq 0x45f19
xorl %eax, %eax
movq -0x78(%rbp), %r15
cmpq $0x48, %rax
je 0x48bdf
movsd (%rax,%r12), %xmm0
movsd %xmm0, (%r14,%rax)
addq $0x8, %rax
jmp 0x48bc7
testq %r15, %r15
je 0x48bf1
movsd 0x414ac(%rip), %xmm0    # 0x8a098
movsd %xmm0, (%r15)
addq $0x348, %rsp            # imm = 0x348
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq