// File: /workspace/github_cpp_makefile_star2_O1/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 0x149f1
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 0x6a8e
movq %r14, %rdi
movq %r15, %rsi
callq 0x6afc
leaq 0x90(%rsp), %r14
movsd (%rsp), %xmm0
movq %r14, %rdi
movl $0x1, %esi
callq 0x1c780
movsd %xmm0, 0x7a0(%rbx)
movq 0x90(%rsp), %rdi
callq 0x5460
jmp 0x14a01
movsd 0x568(%rbx), %xmm0
movsd %xmm0, 0x7a0(%rbx)
movsd 0x5b0(%rbx), %xmm0
mulsd 0x7a0(%rbx), %xmm0
movsd %xmm0, 0x7a0(%rbx)
cmpb $0x1, 0x520(%rbx)
jne 0x14cbe
movsd 0x132b2(%rip), %xmm0    # 0x27ce0
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 0x6a8e
movq %r14, %rdi
movq %r15, %rsi
callq 0x6afc
movapd (%rsp), %xmm0
divsd 0x1324c(%rip), %xmm0    # 0x27ce8
movapd 0x1258c(%rip), %xmm1    # 0x27030
movapd %xmm0, (%rsp)
andpd %xmm0, %xmm1
leaq 0x78(%rsp), %r14
movsd 0x20(%rsp), %xmm0
movapd %xmm1, 0x20(%rsp)
movq %r14, %rdi
callq 0x1c899
movapd (%rsp), %xmm2
movapd 0x20(%rsp), %xmm1
divsd %xmm1, %xmm2
cmpltsd 0x13242(%rip), %xmm1    # 0x27d20
andnpd %xmm2, %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x7a8(%rbx)
movq 0x78(%rsp), %rdi
callq 0x5460
cmpb $0x1, 0x680(%rbx)
jne 0x14b88
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 0x6a8e
movq %r14, %rdi
movq %r12, %rsi
callq 0x6afc
leaq 0x60(%rsp), %r14
movsd (%rsp), %xmm0
movapd 0x20(%rsp), %xmm1
movq %r14, %rdi
callq 0x1c899
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 0x6a8e
movq %r14, %rdi
movq %r15, %rsi
callq 0x6afc
movapd 0x10(%rsp), %xmm0
divsd 0x13118(%rip), %xmm0    # 0x27ce8
movapd 0x12458(%rip), %xmm1    # 0x27030
movapd %xmm0, 0x10(%rsp)
andpd %xmm0, %xmm1
leaq 0x48(%rsp), %r14
movsd (%rsp), %xmm0
movapd %xmm1, (%rsp)
movq %r14, %rdi
callq 0x1c899
movapd 0x10(%rsp), %xmm2
movapd (%rsp), %xmm1
divsd %xmm1, %xmm2
cmpltsd 0x1310f(%rip), %xmm1    # 0x27d20
andnpd %xmm2, %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x7b0(%rbx)
movq 0x48(%rsp), %rdi
callq 0x5460
cmpb $0x1, 0x680(%rbx)
jne 0x14cdf
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 0x6a8e
movq %r14, %rdi
movq %r15, %rsi
callq 0x6afc
leaq 0x30(%rsp), %r14
movsd 0x10(%rsp), %xmm0
movapd (%rsp), %xmm1
movq %r14, %rdi
callq 0x1c899
movsd %xmm0, 0x988(%rbx)
movq 0x30(%rsp), %rdi
callq 0x5460
movsd 0x988(%rbx), %xmm0
subsd 0x6e0(%rbx), %xmm0
movsd %xmm0, 0x988(%rbx)
jmp 0x14cdf
movsd 0x518(%rbx), %xmm0
movsd %xmm0, 0x7a8(%rbx)
movsd %xmm0, 0x7b0(%rbx)
cmpb $0x1, 0x680(%rbx)
je 0x14d1a
movsd 0x548(%rbx), %xmm0
movsd 0x7a8(%rbx), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x7a8(%rbx)
mulsd 0x7b0(%rbx), %xmm0
movsd %xmm0, 0x7b0(%rbx)
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x1e28f(%rip), %rdi     # 0x32fb0
leaq 0x13b91(%rip), %rsi     # 0x288b9
callq 0x5380
movl $0x1, %edi
callq 0x5470
jmp 0x14d49
jmp 0x14d49
jmp 0x14d49
jmp 0x14d49
jmp 0x14d49
jmp 0x14d49
jmp 0x14d49
jmp 0x14d49
jmp 0x14d49
movq %rax, %rbx
movq (%r14), %rdi
callq 0x5460
movq %rbx, %rdi
callq 0x5650