// File: istellartech[P]OpenTsiolkovsky/src/coordinate_transform.cpp
// Function: posLLH(Eigen::Matrix<double, 3, 1, 0, 3, 1>)
Vector3d posLLH(Vector3d posECEF_){
    
    Vector3d posLLH;
    double a = 6378137.0;               // WGS84の長軸[m]
    double one_f = 298.257223563;       // 扁平率fの1/f（平滑度）
    double b = a * (1.0 - 1.0 / one_f); // WGS84の短軸[m] b = 6356752.314245
    double e2 = (1.0 / one_f) * (2.0 - (1.0 / one_f));  // 第一離心率eの2乗
    double ed2 = (e2 * a * a / (b * b));// 第二離心率e'の2乗
    double p = sqrt(posECEF_(0) * posECEF_(0) + posECEF_(1) * posECEF_(1));    // 現在位置での地球回転軸からの距離[m]
    double theta = atan2(posECEF_(2)*a, p*b);    //[rad]
    posLLH[0] = rad2deg(atan2((posECEF_(2) + ed2 * b * pow(sin(theta),3)), p - e2 * a * pow(cos(theta),3)));
    posLLH[1] = rad2deg(atan2(posECEF_(1),posECEF_(0)));
    posLLH[2] = p / cos(deg2rad(posLLH(0))) - n_posECEF2LLH(posLLH(0), a, e2);
    return posLLH;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rsi, -0x88(%rbp)
movq %rdi, -0x68(%rbp)
movq %rdi, %rax
movq %rax, -0x50(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
callq 0x1d670
movq -0x88(%rbp), %rdi
movsd 0xe907(%rip), %xmm0     # 0x59750
movsd %xmm0, -0x18(%rbp)
movsd 0xe8f2(%rip), %xmm0     # 0x59748
movsd %xmm0, -0x20(%rbp)
movsd -0x18(%rbp), %xmm0
movsd 0x71d8(%rip), %xmm2     # 0x52040
divsd -0x20(%rbp), %xmm2
movsd 0x71cb(%rip), %xmm1     # 0x52040
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movsd 0x71b6(%rip), %xmm0     # 0x52040
divsd -0x20(%rbp), %xmm0
movsd 0x71a9(%rip), %xmm2     # 0x52040
divsd -0x20(%rbp), %xmm2
movsd 0x7fdc(%rip), %xmm1     # 0x52e80
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
mulsd -0x18(%rbp), %xmm0
mulsd -0x18(%rbp), %xmm0
movsd -0x28(%rbp), %xmm1
mulsd -0x28(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x4d640
movq -0x88(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0xc8(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x4d640
movq -0x88(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0xc0(%rbp)
movl $0x1, %esi
callq 0x4d640
movq -0x88(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0xd0(%rbp)
movl $0x1, %esi
callq 0x4d640
movsd -0xd0(%rbp), %xmm1
movsd -0xc8(%rbp), %xmm0
movsd -0xc0(%rbp), %xmm2
mulsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x6390
movq -0x88(%rbp), %rdi
movsd %xmm0, -0x40(%rbp)
movl $0x2, %esi
callq 0x4d640
movsd (%rax), %xmm0
mulsd -0x18(%rbp), %xmm0
movsd -0x40(%rbp), %xmm1
mulsd -0x28(%rbp), %xmm1
callq 0x60c0
movq -0x88(%rbp), %rdi
movsd %xmm0, -0x48(%rbp)
movl $0x2, %esi
callq 0x4d640
movsd (%rax), %xmm0
movsd %xmm0, -0xb8(%rbp)
movsd -0x38(%rbp), %xmm0
mulsd -0x28(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movsd -0x48(%rbp), %xmm0
callq 0x6120
movl $0x3, %edi
callq 0x4d6d0
movsd -0xb8(%rbp), %xmm1
movaps %xmm0, %xmm2
movsd -0xb0(%rbp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0x30(%rbp), %xmm0
mulsd -0x18(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd -0x48(%rbp), %xmm0
callq 0x6810
movl $0x3, %edi
callq 0x4d6d0
movsd -0xa8(%rbp), %xmm1
movsd -0xa0(%rbp), %xmm2
movaps %xmm0, %xmm3
movsd -0x98(%rbp), %xmm0
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm3, %xmm1
addsd %xmm2, %xmm1
callq 0x60c0
callq 0x205a0
movq -0x68(%rbp), %rdi
movsd %xmm0, -0x90(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x1de40
movsd -0x90(%rbp), %xmm0
movq -0x88(%rbp), %rdi
movsd %xmm0, (%rax)
movl $0x1, %esi
callq 0x4d640
movq -0x88(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x80(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x4d640
movsd -0x80(%rbp), %xmm0
movsd (%rax), %xmm1
callq 0x60c0
callq 0x205a0
movq -0x68(%rbp), %rdi
movsd %xmm0, -0x78(%rbp)
movl $0x1, %esi
callq 0x1de40
movsd -0x78(%rbp), %xmm0
movq -0x68(%rbp), %rdi
movsd %xmm0, (%rax)
movsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x4d640
movsd (%rax), %xmm0
callq 0x1e000
callq 0x6810
movq -0x68(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0x70(%rbp), %xmm0
divsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x4d640
movsd (%rax), %xmm0
movsd -0x18(%rbp), %xmm1
movsd -0x30(%rbp), %xmm2
callq 0x4ad70
movq -0x68(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0x60(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movl $0x2, %esi
callq 0x1de40
movsd -0x58(%rbp), %xmm0
movq %rax, %rcx
movq -0x50(%rbp), %rax
movsd %xmm0, (%rcx)
addq $0xd0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)