// File: /workspace/github_cpp_makefile_star2_O3/istellartech[P]OpenTsiolkovsky/src/rocket.cpp
// Function: RocketStage::free_flight_aerodynamic_stable(std::array<double, 14ul> const&, double)
void RocketStage::free_flight_aerodynamic_stable(const RocketStage::state& x, double t){
    flight_mode = "free_aero_stable";
    angle_of_attack_ << 0.0, 0.0, 0.0;
    vel_BODY_NEDframe_ = vel_ECEF_NEDframe_ - vel_wind_NEDframe_;
    vel_AIR_BODYframe_ << vel_BODY_NEDframe_.norm(), 0.0, 0.0;
    Vector2d azel;
    azel = azimuth_elevation(vel_BODY_NEDframe_);
    azimuth = azel[0];
    elevation = azel[1];
    // roll = roll;
    dcmNED2BODY_ = dcmNED2BODY(azimuth, elevation, roll);
    dcmECI2BODY_ = dcmECI2BODY(dcmNED2BODY_, dcmECI2NED_);
    dcmBODY2ECI_ = dcmECI2BODY_.transpose();

    //    thrust term
    force_thrust_vector << 0.0, 0.0, 0.0;
    //    aerodynamics term
    vel_AIR_BODYframe_abs = vel_AIR_BODYframe_.norm();
    mach_number = vel_AIR_BODYframe_abs / air.airspeed;
    update_from_mach_number();
    dynamic_pressure = 0.5 * air.density * vel_AIR_BODYframe_abs * vel_AIR_BODYframe_abs;
    force_axial = CA * dynamic_pressure * body_area;
    force_normal_pitch = force_normal_yaw = 0.0;
    force_air_vector_BODYframe << -force_axial, 0.0, 0.0;
    //    dv/dt
    accECI_ = 1/x[0] * (dcmBODY2ECI_ * (force_thrust_vector + force_air_vector_BODYframe))
            + gravityECI_;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x120, %rsp            # imm = 0x120
movq %rsi, %r14
movq %rdi, %rbx
addq $0x230, %rdi            # imm = 0x230
movq 0x238(%rbx), %rdx
leaq 0x14398(%rip), %rcx     # 0x26a49
xorl %r15d, %r15d
movl $0x10, %r8d
xorl %esi, %esi
callq 0x5540
leaq 0xc30(%rbx), %rax
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
movq %r15, 0x8(%rdi)
movl $0x1, %eax
movq %rax, 0x10(%rdi)
movq %rax, 0x18(%rdi)
movq %r15, 0xc30(%rbx)
leaq 0x8(%rsp), %rsi
movq %r15, (%rsi)
callq 0x15520
movq %rsp, %rsi
movq $0x0, (%rsi)
movq %rax, %rdi
callq 0x15520
movq 0x28(%rsp), %rax
addq 0x18(%rsp), %rax
cmpq $0x3, %rax
jne 0x12bd2
cmpq $0x1, 0x20(%rsp)
jne 0x12bd2
movupd 0xbb8(%rbx), %xmm0
subpd 0xbd0(%rbx), %xmm0
movupd %xmm0, 0xc18(%rbx)
movsd 0xbc8(%rbx), %xmm1
subsd 0xbe0(%rbx), %xmm1
movsd %xmm1, 0xc28(%rbx)
leaq 0xbe8(%rbx), %rax
mulpd %xmm0, %xmm0
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
addsd %xmm0, %xmm1
xorps %xmm0, %xmm0
sqrtsd %xmm1, %xmm0
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
xorl %eax, %eax
movq %rax, 0x8(%rdi)
movl $0x1, %ecx
movq %rcx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movsd %xmm0, 0xbe8(%rbx)
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
callq 0x15520
movq %rsp, %rsi
movq $0x0, (%rsi)
movq %rax, %rdi
callq 0x15520
movq 0x28(%rsp), %rax
addq 0x18(%rsp), %rax
cmpq $0x3, %rax
jne 0x12bd2
cmpq $0x1, 0x20(%rsp)
jne 0x12bd2
movups 0xc18(%rbx), %xmm0
leaq 0x60(%rsp), %rsi
movaps %xmm0, (%rsi)
movsd 0xc28(%rbx), %xmm0
movsd %xmm0, 0x10(%rsi)
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x236a2
movaps (%r15), %xmm0
movups %xmm0, 0x928(%rbx)
movsd 0x938(%rbx), %xmm2
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x23304
movaps (%r15), %xmm0
movaps %xmm0, 0xc90(%rbx)
movaps 0x10(%r15), %xmm1
movaps %xmm1, 0xca0(%rbx)
movaps 0x20(%r15), %xmm2
movaps %xmm2, 0xcb0(%rbx)
movaps 0x30(%r15), %xmm3
movaps %xmm3, 0xcc0(%rbx)
movsd 0x40(%r15), %xmm4
movsd %xmm4, 0xcd0(%rbx)
leaq 0xd0(%rsp), %rsi
movaps %xmm0, (%rsi)
movaps %xmm1, 0x10(%rsi)
movaps %xmm2, 0x20(%rsi)
movaps %xmm3, 0x30(%rsi)
movsd %xmm4, 0x40(%rsi)
movups 0xb28(%rbx), %xmm0
leaq 0x80(%rsp), %rdx
movaps %xmm0, (%rdx)
movups 0xb38(%rbx), %xmm0
movaps %xmm0, 0x10(%rdx)
movups 0xb48(%rbx), %xmm0
movaps %xmm0, 0x20(%rdx)
movups 0xb58(%rbx), %xmm0
movaps %xmm0, 0x30(%rdx)
movsd 0xb68(%rbx), %xmm0
movsd %xmm0, 0x40(%rdx)
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x2389b
movapd (%r15), %xmm0
movupd %xmm0, 0xcd8(%rbx)
movapd 0x10(%r15), %xmm1
movupd %xmm1, 0xce8(%rbx)
movapd 0x20(%r15), %xmm2
movupd %xmm2, 0xcf8(%rbx)
movapd 0x30(%r15), %xmm3
movupd %xmm3, 0xd08(%rbx)
movsd 0x40(%r15), %xmm4
movsd %xmm4, 0xd18(%rbx)
movapd %xmm1, %xmm5
movsd %xmm0, %xmm5            # xmm5 = xmm0[0],xmm5[1]
movapd %xmm5, 0xd20(%rbx)
movsd %xmm3, %xmm0            # xmm0 = xmm3[0],xmm0[1]
movapd %xmm0, 0xd30(%rbx)
movsd %xmm2, %xmm3            # xmm3 = xmm2[0],xmm3[1]
movapd %xmm3, 0xd40(%rbx)
movsd %xmm1, %xmm2            # xmm2 = xmm1[0],xmm2[1]
movapd %xmm2, 0xd50(%rbx)
movsd %xmm4, 0xd60(%rbx)
leaq 0xe28(%rbx), %rax
movq %rax, (%r15)
xorl %eax, %eax
movq %rax, 0x8(%r15)
movl $0x1, %ecx
movq %rcx, 0x10(%r15)
movq %rcx, 0x18(%r15)
movq %rax, 0xe28(%rbx)
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x15520
movq %rsp, %rsi
movq $0x0, (%rsi)
movq %rax, %rdi
callq 0x15520
movq 0x28(%rsp), %rax
addq 0x18(%rsp), %rax
cmpq $0x3, %rax
jne 0x12bd2
cmpq $0x1, 0x20(%rsp)
jne 0x12bd2
movsd 0xbe8(%rbx), %xmm0
movsd 0xbf0(%rbx), %xmm1
mulsd %xmm0, %xmm0
mulsd %xmm1, %xmm1
movsd 0xbf8(%rbx), %xmm2
mulsd %xmm2, %xmm2
addsd %xmm1, %xmm2
addsd %xmm0, %xmm2
xorps %xmm0, %xmm0
sqrtsd %xmm2, %xmm0
movsd %xmm0, 0x7c8(%rbx)
divsd 0x900(%rbx), %xmm0
movsd %xmm0, 0x958(%rbx)
movq %rbx, %rdi
callq 0x13716
movsd 0x910(%rbx), %xmm0
mulsd 0x132ff(%rip), %xmm0    # 0x25d20
movsd 0x7c8(%rbx), %xmm1
mulsd %xmm1, %xmm0
mulsd %xmm1, %xmm0
movsd %xmm0, 0x7d8(%rbx)
mulsd 0x7a0(%rbx), %xmm0
mulsd 0x510(%rbx), %xmm0
movsd %xmm0, 0x7e0(%rbx)
xorpd %xmm1, %xmm1
movupd %xmm1, 0x7e8(%rbx)
leaq 0xdf8(%rbx), %rax
xorpd 0x134e4(%rip), %xmm0    # 0x25f50
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
xorl %eax, %eax
movq %rax, 0x8(%rdi)
movl $0x1, %ecx
movq %rcx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movlpd %xmm0, 0xdf8(%rbx)
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
callq 0x15520
movq %rsp, %rsi
movq $0x0, (%rsi)
movq %rax, %rdi
callq 0x15520
movq 0x28(%rsp), %rax
addq 0x18(%rsp), %rax
cmpq $0x3, %rax
jne 0x12bd2
cmpq $0x1, 0x20(%rsp)
jne 0x12bd2
movsd 0x1259a(%rip), %xmm0    # 0x25070
divsd (%r14), %xmm0
movsd 0xe28(%rbx), %xmm3
addsd 0xdf8(%rbx), %xmm3
movsd 0xe30(%rbx), %xmm4
addsd 0xe00(%rbx), %xmm4
movsd 0xe38(%rbx), %xmm1
addsd 0xe08(%rbx), %xmm1
movsd 0xd30(%rbx), %xmm2
mulsd %xmm3, %xmm2
movsd 0xd48(%rbx), %xmm5
mulsd %xmm4, %xmm5
addsd %xmm2, %xmm5
movsd 0xd60(%rbx), %xmm2
mulsd %xmm1, %xmm2
addsd %xmm5, %xmm2
unpcklpd %xmm3, %xmm3            # xmm3 = xmm3[0,0]
mulpd 0xd20(%rbx), %xmm3
movupd 0xd38(%rbx), %xmm5
unpcklpd %xmm4, %xmm4            # xmm4 = xmm4[0,0]
mulpd %xmm5, %xmm4
unpcklpd %xmm1, %xmm1            # xmm1 = xmm1[0,0]
mulpd 0xd50(%rbx), %xmm1
addpd %xmm3, %xmm4
addpd %xmm4, %xmm1
mulsd %xmm0, %xmm2
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm1, %xmm0
movupd 0xe58(%rbx), %xmm1
addpd %xmm0, %xmm1
movapd %xmm1, 0x9f0(%rbx)
addsd 0xe68(%rbx), %xmm2
movsd %xmm2, 0xa00(%rbx)
addq $0x120, %rsp            # imm = 0x120
popq %rbx
popq %r14
popq %r15
retq
jmp 0x12bb2
jmp 0x12bb2
jmp 0x12bb2
jmp 0x12bb2
jmp 0x12bb2
jmp 0x12bb2
jmp 0x12bb2
movq 0x28(%rsp), %rcx
addq 0x18(%rsp), %rcx
cmpq $0x3, %rcx
jne 0x12bd2
cmpq $0x1, 0x20(%rsp)
jne 0x12bd2
movq %rax, %rdi
callq 0x5650
leaq 0x146fb(%rip), %rdi     # 0x272d4
leaq 0x1477b(%rip), %rsi     # 0x2735b
leaq 0x147a1(%rip), %rcx     # 0x27388
movl $0x6a, %edx
callq 0x5250
nop