// File: /workspace/github_cpp_makefile_star2_O3/istellartech[P]OpenTsiolkovsky/src/rocket.cpp
// Function: RocketStage::update_from_mach_number()
void RocketStage::update_from_mach_number(){
    double angle_sign, angle_abs;
    double alpha, beta;

    if (CA_file_exist) {
        CA = interp_matrix(mach_number, CA_mat);
    } else {
        CA = CA_const;
    }
    CA *= CA_multiplier;

    if (CN_file_exist) {
        alpha = rad2deg(angle_of_attack_[0]);
        beta  = rad2deg(angle_of_attack_[1]);

        // pitch
        angle_abs = abs(alpha);
        if(angle_abs < 1e-9){
            angle_sign = 0.0;
        }else{
            angle_sign = alpha / angle_abs;
        }

        CN_pitch = angle_sign * interp_matrix_2d(mach_number, angle_abs, CN_mat);
        if ( is_consider_neutrality ) {
            pos_CP_pitch = interp_matrix_2d(mach_number, angle_abs, Xcp_mat);
            pos_CP_pitch -= Xcp_offset;     // +X direction = -STA direction
        }

        // yaw
        angle_abs = abs(beta);
        if(angle_abs < 1e-9){
            angle_sign = 0.0;
        }else{
            angle_sign = beta / angle_abs;
        }

        CN_yaw = angle_sign * interp_matrix_2d(mach_number, angle_abs, CN_mat);
        if ( is_consider_neutrality ) {
            pos_CP_yaw = interp_matrix_2d(mach_number, angle_abs, Xcp_mat);
            pos_CP_yaw -= Xcp_offset;       // +X direction = -STA direction
        }
    } else {
        CN_pitch = CN_const;
        CN_yaw   = CN_const;
        if ( is_consider_neutrality ) {
            std::cout << "ERROR: you must specify the non-constant CN when you use neutrality calculation.\n";
            exit(1);
        }
    }
    CN_pitch *= CN_multiplier;
    CN_yaw   *= CN_multiplier;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
cmpb $0x1, 0x570(%rdi)
jne 0x137ad
movsd 0x958(%rbx), %xmm0
movsd %xmm0, (%rsp)
leaq 0x598(%rbx), %r15
movq 0x5a0(%rbx), %rdx
movq 0x5a8(%rbx), %rcx
movq %rcx, %rsi
imulq %rdx, %rsi
leaq 0x90(%rsp), %r14
movq %r14, %rdi
callq 0x69e0
movq %r14, %rdi
movq %r15, %rsi
callq 0x6a4e
leaq 0x90(%rsp), %r14
movsd (%rsp), %xmm0
movq %r14, %rdi
movl $0x1, %esi
callq 0x1a99c
movsd %xmm0, 0x7a0(%rbx)
movq 0x90(%rsp), %rdi
callq 0x5460
movsd 0x7a0(%rbx), %xmm0
jmp 0x137bd
movsd 0x568(%rbx), %xmm0
movsd %xmm0, 0x7a0(%rbx)
mulsd 0x5b0(%rbx), %xmm0
movsd %xmm0, 0x7a0(%rbx)
cmpb $0x1, 0x520(%rbx)
jne 0x13a72
movsd 0x1252e(%rip), %xmm0    # 0x25d10
movsd 0xc30(%rbx), %xmm1
mulsd %xmm0, %xmm1
movapd %xmm1, (%rsp)
mulsd 0xc38(%rbx), %xmm0
movapd %xmm0, 0x10(%rsp)
movsd 0x958(%rbx), %xmm0
movsd %xmm0, 0x20(%rsp)
leaq 0x550(%rbx), %r15
movq 0x558(%rbx), %rdx
movq 0x560(%rbx), %rcx
movq %rcx, %rsi
imulq %rdx, %rsi
leaq 0x78(%rsp), %r14
movq %r14, %rdi
callq 0x69e0
movq %r14, %rdi
movq %r15, %rsi
callq 0x6a4e
movapd (%rsp), %xmm0
divsd 0x124c8(%rip), %xmm0    # 0x25d18
movapd 0x117d8(%rip), %xmm1    # 0x25030
movapd %xmm0, (%rsp)
andpd %xmm0, %xmm1
leaq 0x78(%rsp), %r14
movsd 0x20(%rsp), %xmm0
movapd %xmm1, 0x20(%rsp)
movq %r14, %rdi
callq 0x1aaae
movapd (%rsp), %xmm2
movapd 0x20(%rsp), %xmm1
divsd %xmm1, %xmm2
cmpltsd 0x124c6(%rip), %xmm1    # 0x25d58
andnpd %xmm2, %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x7a8(%rbx)
movq 0x78(%rsp), %rdi
callq 0x5460
cmpb $0x1, 0x680(%rbx)
jne 0x1393c
movsd 0x958(%rbx), %xmm0
movsd %xmm0, (%rsp)
leaq 0x728(%rbx), %r12
movq 0x730(%rbx), %rdx
movq 0x738(%rbx), %rcx
movq %rcx, %rsi
imulq %rdx, %rsi
leaq 0x60(%rsp), %r14
movq %r14, %rdi
callq 0x69e0
movq %r14, %rdi
movq %r12, %rsi
callq 0x6a4e
leaq 0x60(%rsp), %r14
movsd (%rsp), %xmm0
movapd 0x20(%rsp), %xmm1
movq %r14, %rdi
callq 0x1aaae
movsd %xmm0, 0x980(%rbx)
movq 0x60(%rsp), %rdi
callq 0x5460
movsd 0x980(%rbx), %xmm0
subsd 0x6e0(%rbx), %xmm0
movsd %xmm0, 0x980(%rbx)
movsd 0x958(%rbx), %xmm0
movsd %xmm0, (%rsp)
movq 0x558(%rbx), %rdx
movq 0x560(%rbx), %rcx
movq %rcx, %rsi
imulq %rdx, %rsi
leaq 0x48(%rsp), %r14
movq %r14, %rdi
callq 0x69e0
movq %r14, %rdi
movq %r15, %rsi
callq 0x6a4e
movapd 0x10(%rsp), %xmm0
divsd 0x12394(%rip), %xmm0    # 0x25d18
movapd 0x116a4(%rip), %xmm1    # 0x25030
movapd %xmm0, 0x10(%rsp)
andpd %xmm0, %xmm1
leaq 0x48(%rsp), %r14
movsd (%rsp), %xmm0
movapd %xmm1, (%rsp)
movq %r14, %rdi
callq 0x1aaae
movapd 0x10(%rsp), %xmm2
movapd (%rsp), %xmm1
divsd %xmm1, %xmm2
cmpltsd 0x12393(%rip), %xmm1    # 0x25d58
andnpd %xmm2, %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x7b0(%rbx)
movq 0x48(%rsp), %rdi
callq 0x5460
cmpb $0x1, 0x680(%rbx)
jne 0x13a93
movsd 0x958(%rbx), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x728(%rbx), %r15
movq 0x730(%rbx), %rdx
movq 0x738(%rbx), %rcx
movq %rcx, %rsi
imulq %rdx, %rsi
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x69e0
movq %r14, %rdi
movq %r15, %rsi
callq 0x6a4e
leaq 0x30(%rsp), %r14
movsd 0x10(%rsp), %xmm0
movapd (%rsp), %xmm1
movq %r14, %rdi
callq 0x1aaae
movsd %xmm0, 0x988(%rbx)
movq 0x30(%rsp), %rdi
callq 0x5460
movsd 0x988(%rbx), %xmm0
subsd 0x6e0(%rbx), %xmm0
movsd %xmm0, 0x988(%rbx)
jmp 0x13a93
movsd 0x518(%rbx), %xmm0
movsd %xmm0, 0x7a8(%rbx)
movsd %xmm0, 0x7b0(%rbx)
cmpb $0x1, 0x680(%rbx)
je 0x13ac2
movupd 0x548(%rbx), %xmm0
movupd 0x7a8(%rbx), %xmm1
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm1, %xmm0
movupd %xmm0, 0x7a8(%rbx)
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x1e4e7(%rip), %rdi     # 0x31fb0
leaq 0x12ee9(%rip), %rsi     # 0x269b9
callq 0x5380
movl $0x1, %edi
callq 0x5470
jmp 0x13af1
jmp 0x13af1
jmp 0x13af1
jmp 0x13af1
jmp 0x13af1
jmp 0x13af1
jmp 0x13af1
jmp 0x13af1
jmp 0x13af1
movq %rax, %rbx
movq (%r14), %rdi
callq 0x5460
movq %rbx, %rdi
callq 0x5650