// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
movq %rsi, %r14
movq %rdi, %rbx
addq $0x230, %rdi            # imm = 0x230
leaq 0x12f6e(%rip), %rsi     # 0x20add
callq 0x56a0
leaq 0xc30(%rbx), %rax
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
pushq $0x1
popq %rbp
movq %rbp, 0x10(%rdi)
movq %rbp, 0x18(%rdi)
andq $0x0, 0xc30(%rbx)
leaq 0x78(%rsp), %rsi
andq $0x0, (%rsi)
callq 0xfd60
leaq 0x60(%rsp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0xfd60
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0xfe08
leaq 0xbb8(%rbx), %rax
leaq 0xbd0(%rbx), %rcx
movq %rax, (%r15)
movq %rcx, 0x8(%r15)
leaq 0xc18(%rbx), %r12
leaq 0x10(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x15cd4
leaq 0xbe8(%rbx), %r15
movq %r12, %rdi
callq 0x10c94
movq %r15, (%r13)
andq $0x0, 0x8(%r13)
movq %rbp, 0x10(%r13)
movq %rbp, 0x18(%r13)
movsd %xmm0, 0xbe8(%rbx)
leaq 0x78(%rsp), %rsi
andq $0x0, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0xfd60
leaq 0x60(%rsp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0xfd60
leaq 0x10(%rsp), %rdi
callq 0xfe08
leaq 0xa0(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x129c6
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x1d71b
movapd (%r12), %xmm0
movupd %xmm0, 0x928(%rbx)
movsd 0x938(%rbx), %xmm2
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
leaq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x1d3c3
leaq 0xc90(%rbx), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x151a4
leaq 0x100(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x152a2
leaq 0xb28(%rbx), %rsi
leaq 0xb8(%rsp), %r13
movq %r13, %rdi
callq 0x152a2
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1d862
leaq 0xcd8(%rbx), %r12
movq %rbp, %rdi
movq %r12, %rsi
callq 0x151a4
movq %r12, (%rbp)
leaq 0xd20(%rbx), %r12
leaq 0x10(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x1536a
leaq 0xe28(%rbx), %rbp
movq %rbp, (%r13)
andq $0x0, 0x8(%r13)
pushq $0x1
popq %rax
movq %rax, 0x10(%r13)
movq %rax, 0x18(%r13)
andq $0x0, 0xe28(%rbx)
leaq 0x78(%rsp), %rsi
andq $0x0, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0xfd60
movq %r14, 0x8(%rsp)
leaq 0x60(%rsp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0xfd60
leaq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0xfe08
movq %r15, %rdi
callq 0x10c94
movsd %xmm0, 0x7c8(%rbx)
divsd 0x900(%rbx), %xmm0
movsd %xmm0, 0x958(%rbx)
movq %rbx, %rdi
callq 0xe4a6
movsd 0x7c8(%rbx), %xmm0
movsd 0x910(%rbx), %xmm1
mulsd 0x1208c(%rip), %xmm1    # 0x1fe38
mulsd %xmm0, %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x7d8(%rbx)
mulsd 0x7a0(%rbx), %xmm1
mulsd 0x510(%rbx), %xmm1
movsd %xmm1, 0x7e0(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x7e8(%rbx)
leaq 0xdf8(%rbx), %r14
xorpd 0x11221(%rip), %xmm1    # 0x1f010
movq %r14, (%r13)
andq $0x0, 0x8(%r13)
pushq $0x1
popq %rax
movq %rax, 0x10(%r13)
movq %rax, 0x18(%r13)
movlpd %xmm1, 0xdf8(%rbx)
leaq 0x78(%rsp), %rsi
andq $0x0, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0xfd60
leaq 0x60(%rsp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0xfd60
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0xfe08
movsd 0x1121c(%rip), %xmm0    # 0x1f060
movq 0x8(%rsp), %rax
divsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x60(%rsp), %rsi
movq %rbp, (%rsi)
movq %r14, 0x8(%rsi)
movq %r12, (%r15)
leaq 0x18(%rsp), %rdi
callq 0x15aec
leaq 0x10(%rsp), %rdi
callq 0x15b5c
leaq 0xe58(%rbx), %rcx
leaq 0x78(%rsp), %rsi
movq %rax, 0x8(%rsi)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x10(%rsi)
movq %rcx, 0x18(%rsi)
addq $0x9f0, %rbx            # imm = 0x9F0
movq %rbx, %rdi
callq 0x15c52
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xdec4
jmp 0xdec4
jmp 0xdec4
jmp 0xdec4
jmp 0xdec4
jmp 0xdec4
jmp 0xdec4
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xfe08
movq %rbx, %rdi
callq 0x5640
nop