// File: istellartech[P]OpenTsiolkovsky/src/coordinate_transform.cpp
// Function: dcmNED2BODY(double, double, double)
Matrix3d dcmNED2BODY(double azimuth_rad, double elevation_rad, double roll_rad){
    Matrix3d dcm;
    double az = azimuth_rad;
    double el = elevation_rad;
    double ro = roll_rad;

    dcm <<  cos(el)*cos(az), cos(el)*sin(az), -sin(el),
    -cos(ro)*sin(az)+sin(ro)*sin(el)*cos(az), cos(ro)*cos(az)+sin(ro)*sin(el)*sin(az), sin(ro)*cos(el),
    sin(ro)*sin(az)+cos(ro)*sin(el)*cos(az),  -sin(ro)*cos(az)+cos(ro)*sin(el)*sin(az),  cos(ro)*cos(el);

    /*
    auto angleaxis_inv = AngleAxisd(az, Vector3d::UnitZ()) * AngleAxisd(el, Vector3d::UnitY()) * AngleAxisd(ro, Vector3d::UnitX());
    dcm = angleaxis_inv.inverse().toRotationMatrix();
    */

    return dcm;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0xd8(%rbp)
movq %rdi, %rax
movq %rax, -0xe0(%rbp)
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movsd %xmm1, -0x18(%rbp)
movsd %xmm2, -0x20(%rbp)
callq 0x1dbe0
movsd -0x10(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x6810
movsd %xmm0, -0xd0(%rbp)
movsd -0x28(%rbp), %xmm0
callq 0x6810
movq -0xd8(%rbp), %rsi
movaps %xmm0, %xmm1
movsd -0xd0(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x60(%rbp)
leaq -0x58(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
leaq -0x60(%rbp), %rdx
callq 0x49f30
movsd -0x30(%rbp), %xmm0
callq 0x6810
movsd %xmm0, -0xc0(%rbp)
movsd -0x28(%rbp), %xmm0
callq 0x6120
movq -0xc8(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0xc0(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
leaq -0x68(%rbp), %rsi
callq 0x49f70
movq %rax, -0xb8(%rbp)
jmp 0x4bc26
movsd -0x30(%rbp), %xmm0
callq 0x6120
movq -0xb8(%rbp), %rdi
movaps 0x7402(%rip), %xmm1     # 0x53040
pxor %xmm1, %xmm0
movlpd %xmm0, -0x80(%rbp)
leaq -0x80(%rbp), %rsi
callq 0x49f70
movq %rax, -0xe8(%rbp)
jmp 0x4bc59
movsd -0x38(%rbp), %xmm0
callq 0x6810
movsd %xmm0, -0x108(%rbp)
movsd -0x28(%rbp), %xmm0
callq 0x6120
movsd %xmm0, -0x100(%rbp)
movsd -0x38(%rbp), %xmm0
callq 0x6120
movsd %xmm0, -0x110(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x6120
movaps %xmm0, %xmm1
movsd -0x110(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0xf8(%rbp)
movsd -0x28(%rbp), %xmm0
callq 0x6810
movsd -0x108(%rbp), %xmm1
movsd -0x100(%rbp), %xmm2
movq -0xe8(%rbp), %rdi
movaps %xmm0, %xmm3
movsd -0xf8(%rbp), %xmm0
mulsd %xmm3, %xmm0
mulsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x88(%rbp)
leaq -0x88(%rbp), %rsi
callq 0x49f70
movq %rax, -0xf0(%rbp)
jmp 0x4bd05
movsd -0x38(%rbp), %xmm0
callq 0x6810
movsd %xmm0, -0x120(%rbp)
movsd -0x28(%rbp), %xmm0
callq 0x6810
movsd %xmm0, -0x128(%rbp)
movsd -0x38(%rbp), %xmm0
callq 0x6120
movsd %xmm0, -0x138(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x6120
movaps %xmm0, %xmm1
movsd -0x138(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x130(%rbp)
movsd -0x28(%rbp), %xmm0
callq 0x6120
movsd -0x130(%rbp), %xmm1
movsd -0x128(%rbp), %xmm2
movq -0xf0(%rbp), %rdi
movaps %xmm0, %xmm3
movsd -0x120(%rbp), %xmm0
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
leaq -0x90(%rbp), %rsi
callq 0x49f70
movq %rax, -0x118(%rbp)
jmp 0x4bdb1
movsd -0x38(%rbp), %xmm0
callq 0x6120
movsd %xmm0, -0x148(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x6810
movq -0x118(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0x148(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x98(%rbp)
leaq -0x98(%rbp), %rsi
callq 0x49f70
movq %rax, -0x140(%rbp)
jmp 0x4be00
movsd -0x38(%rbp), %xmm0
callq 0x6120
movsd %xmm0, -0x158(%rbp)
movsd -0x28(%rbp), %xmm0
callq 0x6120
movsd %xmm0, -0x160(%rbp)
movsd -0x38(%rbp), %xmm0
callq 0x6810
movsd %xmm0, -0x170(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x6120
movaps %xmm0, %xmm1
movsd -0x170(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x168(%rbp)
movsd -0x28(%rbp), %xmm0
callq 0x6810
movsd -0x168(%rbp), %xmm1
movsd -0x160(%rbp), %xmm2
movq -0x140(%rbp), %rdi
movaps %xmm0, %xmm3
movsd -0x158(%rbp), %xmm0
mulsd %xmm3, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
leaq -0xa0(%rbp), %rsi
callq 0x49f70
movq %rax, -0x150(%rbp)
jmp 0x4beac
movsd -0x38(%rbp), %xmm0
callq 0x6120
movsd %xmm0, -0x190(%rbp)
movsd -0x28(%rbp), %xmm0
callq 0x6810
movsd %xmm0, -0x188(%rbp)
movsd -0x38(%rbp), %xmm0
callq 0x6810
movsd %xmm0, -0x198(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x6120
movaps %xmm0, %xmm1
movsd -0x198(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0x180(%rbp)
movsd -0x28(%rbp), %xmm0
callq 0x6120
movsd -0x190(%rbp), %xmm1
movsd -0x188(%rbp), %xmm2
movq -0x150(%rbp), %rdi
movaps %xmm0, %xmm3
movsd -0x180(%rbp), %xmm0
mulsd %xmm3, %xmm0
mulsd %xmm2, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0xa8(%rbp)
leaq -0xa8(%rbp), %rsi
callq 0x49f70
movq %rax, -0x178(%rbp)
jmp 0x4bf58
movsd -0x38(%rbp), %xmm0
callq 0x6810
movsd %xmm0, -0x1a0(%rbp)
movsd -0x30(%rbp), %xmm0
callq 0x6810
movq -0x178(%rbp), %rdi
movaps %xmm0, %xmm1
movsd -0x1a0(%rbp), %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, -0xb0(%rbp)
leaq -0xb0(%rbp), %rsi
callq 0x49f70
jmp 0x4bfa0
leaq -0x58(%rbp), %rdi
callq 0x4a0e0
movq -0xe0(%rbp), %rax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4a0e0
movq -0x70(%rbp), %rdi
callq 0x67a0
nopw (%rax,%rax)