// File: istellartech[P]OpenTsiolkovsky/src/coordinate_transform.cpp
// Function: angle_of_attack(Eigen::Matrix<double, 3, 1, 0, 3, 1>)
Vector3d angle_of_attack(Vector3d vel_AIR_BODYframe_){
    double vel_abs = vel_AIR_BODYframe_.norm();
    double alpha;
    double beta;
    double gamma;
    if(abs(vel_AIR_BODYframe_[0]) < 0.001 || vel_abs < 0.01){
        alpha = 0;
        beta = 0;
        gamma = 0;
    }else{
        alpha = atan2(vel_AIR_BODYframe_[2], vel_AIR_BODYframe_[0]);
//        beta = asin(vel_AIR_BODYframe_[1] / vel_abs);
        beta = atan2(vel_AIR_BODYframe_[1], vel_AIR_BODYframe_[0]);
        gamma = atan2(sqrt(vel_AIR_BODYframe_[1] * vel_AIR_BODYframe_[1] +
                      vel_AIR_BODYframe_[2] * vel_AIR_BODYframe_[2]), vel_AIR_BODYframe_[0]);
    }
    Vector3d aoa;
    aoa[0] = alpha;
    aoa[1] = beta;
    aoa[2] = gamma;
    return aoa;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rsi, -0x38(%rbp)
movq %rdi, %rax
movq -0x38(%rbp), %rdi
movq %rax, -0x48(%rbp)
movq %rax, %rcx
movq %rcx, -0x40(%rbp)
movq %rax, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
callq 0x205d0
movq -0x38(%rbp), %rdi
movsd %xmm0, -0x18(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x1de40
movsd (%rax), %xmm0
callq 0x8450
movaps %xmm0, %xmm1
movsd 0xe1ac(%rip), %xmm0     # 0x59ab0
ucomisd %xmm1, %xmm0
ja 0x4b919
movsd 0xe1a6(%rip), %xmm0     # 0x59ab8
ucomisd -0x18(%rbp), %xmm0
jbe 0x4b936
xorps %xmm0, %xmm0
movsd %xmm0, -0x20(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
jmp 0x4ba3c
movq -0x38(%rbp), %rdi
movl $0x2, %esi
callq 0x1de40
movq -0x38(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x78(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x1de40
movsd -0x78(%rbp), %xmm0
movsd (%rax), %xmm1
callq 0x60c0
movq -0x38(%rbp), %rdi
movsd %xmm0, -0x20(%rbp)
movl $0x1, %esi
callq 0x1de40
movq -0x38(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x70(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x1de40
movsd -0x70(%rbp), %xmm0
movsd (%rax), %xmm1
callq 0x60c0
movq -0x38(%rbp), %rdi
movsd %xmm0, -0x28(%rbp)
movl $0x1, %esi
callq 0x1de40
movq -0x38(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
movl $0x1, %esi
callq 0x1de40
movq -0x38(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x58(%rbp)
movl $0x2, %esi
callq 0x1de40
movq -0x38(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
movl $0x2, %esi
callq 0x1de40
movsd -0x68(%rbp), %xmm1
movsd -0x60(%rbp), %xmm0
movsd -0x58(%rbp), %xmm2
mulsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
callq 0x6390
movq -0x38(%rbp), %rdi
movsd %xmm0, -0x50(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x1de40
movsd -0x50(%rbp), %xmm0
movsd (%rax), %xmm1
callq 0x60c0
movsd %xmm0, -0x30(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1d670
movq -0x48(%rbp), %rdi
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x1de40
movsd -0x90(%rbp), %xmm0
movq -0x48(%rbp), %rdi
movsd %xmm0, (%rax)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
movl $0x1, %esi
callq 0x1de40
movsd -0x88(%rbp), %xmm0
movq -0x48(%rbp), %rdi
movsd %xmm0, (%rax)
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
movl $0x2, %esi
callq 0x1de40
movsd -0x80(%rbp), %xmm0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movsd %xmm0, (%rcx)
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)