// File: /workspace/github_cpp_makefile_star2_O1/istellartech[P]OpenTsiolkovsky/src/rocket.cpp
// Function: RocketStage::update_from_time_and_altitude(double, double)
void RocketStage::update_from_time_and_altitude(double time, double altitude){
    Air air;
    //    air = air.altitude(altitude);
    if (air_density_file_exist){
        air = air.altitude_with_variation_table(posLLH_[2], air_density_mat);
    } else{
        air = air.altitude_with_variation(altitude, variation_ratio_of_air_density);
    }

    if (Isp_file_exist){
        Isp_vac = interp_matrix((time - previous_stage_separation_time) * thrust_coeff, Isp_mat);  // Isp vac
    } else {
        Isp_vac = Isp_const;  // Isp vac
    }
    if (thrust_file_exist){
        thrust_vac = interp_matrix((time - previous_stage_separation_time) * thrust_coeff, thrust_mat, 1);
        // nozzle_exhaust_pressure = interp_matrix((time - previous_stage_separation_time) * thrust_coeff, thrust_mat, 2);
        if (thrust_vac != 0 &&
            time >= previous_stage_separation_time + burn_start_time &&
            time < previous_stage_separation_time + burn_start_time + burn_time / thrust_coeff &&
            time < previous_stage_separation_time + forced_cutoff_time) {
            is_powered = true;
        } else {
            is_powered = false;
        }
    } else {
        if (time >= previous_stage_separation_time + burn_start_time &&
            time < previous_stage_separation_time + burn_start_time + burn_time / thrust_coeff &&
            time < previous_stage_separation_time + forced_cutoff_time){
            thrust_vac = thrust_const;
            is_powered = true;
        } else {
            is_powered = false;
        }
    }
    if (is_powered){ // ---- powered flight ----
        Isp_vac                 *= Isp_coeff;
        thrust_vac              *= Isp_coeff * thrust_coeff;
        // nozzle_exhaust_pressure *= Isp_coeff * thrust_coeff;

        m_dot = thrust_vac / Isp_vac / g0;
        // thrust_momentum = thrust_vac - nozzle_exhaust_area * nozzle_exhaust_pressure;
        thrust = thrust_vac - nozzle_exhaust_area * air.pressure;
        if (m_dot > 0.0001) {
            Isp = thrust / m_dot / g0;
        } else {
            Isp = 0.0;
        }
    } else {
        thrust = 0.0;
        m_dot = 0.0;
        Isp = 0.0;
    }

    if (attitude_file_exist) {
        azimuth_target = deg2rad(interp_matrix(time, attitude_mat, 1));
        elevation_target = deg2rad(interp_matrix(time, attitude_mat, 2));
        if (attitude_mat.cols() == 4) {
            roll_target = deg2rad(interp_matrix(time, attitude_mat, 3));
        } else {
            roll_target = deg2rad(attitude_roll_const_deg);
        }
    } else {
        azimuth_target = deg2rad(attitude_azimuth_const_deg);
        elevation_target = deg2rad(attitude_elevation_const_deg);
        roll_target = deg2rad(attitude_roll_const_deg);
    }

    if (wind_file_exist) {
        double wind_u = interp_matrix(altitude, wind_mat_uv, 1);
        double wind_v = interp_matrix(altitude, wind_mat_uv, 2);
        wind_speed = sqrt(wind_u * wind_u + wind_v * wind_v);
        wind_direction = rad2deg(atan2(wind_u, wind_v)) + 180.;
    } else {
        wind_speed = wind_const[0];
        wind_direction = wind_const[1];
    }

    if (is_consider_neutrality) {
        pos_CG         = interp_matrix(time, CGXt_mat, 1);
        pos_Controller = interp_matrix(time, CGXt_mat, 2);

        pos_CG -= Xcg_offset;               // +X direction = -STA direction
        pos_Controller -= Xt_offset;        // +X direction = -STA direction
    }

    if (time >= later_stage_separation_time && is_separated == false){
        is_separated = true;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x350, %rsp            # imm = 0x350
movsd %xmm0, (%rsp)
movq %rdi, %rbx
movabsq $0x40239cf41f212d77, %rax # imm = 0x40239CF41F212D77
movq %rax, 0x110(%rsp)
movabsq $0x3ff6666666666666, %rax # imm = 0x3FF6666666666666
movq %rax, 0x118(%rsp)
movabsq $0x4071f0d97f62b6ae, %rax # imm = 0x4071F0D97F62B6AE
movq %rax, 0x120(%rsp)
movups 0x15cdb(%rip), %xmm0    # 0x277c0
movups %xmm0, 0x128(%rsp)
movups 0x15cdc(%rip), %xmm0    # 0x277d0
movups %xmm0, 0x138(%rsp)
movups 0x1643d(%rip), %xmm0    # 0x27f40
movups %xmm0, 0x148(%rsp)
movups 0x1643e(%rip), %xmm0    # 0x27f50
movups %xmm0, 0x158(%rsp)
movups 0x1643f(%rip), %xmm0    # 0x27f60
movups %xmm0, 0x168(%rsp)
movups 0x16440(%rip), %xmm0    # 0x27f70
movups %xmm0, 0x178(%rsp)
movups 0x16441(%rip), %xmm0    # 0x27f80
movups %xmm0, 0x188(%rsp)
movups 0x16442(%rip), %xmm0    # 0x27f90
movups %xmm0, 0x198(%rsp)
movups 0x16443(%rip), %xmm0    # 0x27fa0
movups %xmm0, 0x1a8(%rsp)
movups 0x16444(%rip), %xmm0    # 0x27fb0
movups %xmm0, 0x1b8(%rsp)
movups 0x16475(%rip), %xmm0    # 0x27ff0
movups %xmm0, 0x1f8(%rsp)
movups 0x16456(%rip), %xmm0    # 0x27fe0
movups %xmm0, 0x1e8(%rsp)
movups 0x16437(%rip), %xmm0    # 0x27fd0
movups %xmm0, 0x1d8(%rsp)
movups 0x16418(%rip), %xmm0    # 0x27fc0
movups %xmm0, 0x1c8(%rsp)
movl $0x0, 0x208(%rsp)
movabsq $0x4072c00000000000, %rax # imm = 0x4072C00000000000
movq %rax, 0x210(%rsp)
movabsq $0x4092c00000000000, %rax # imm = 0x4092C00000000000
movq %rax, 0x218(%rsp)
movabsq $0x40f8bb4000000000, %rax # imm = 0x40F8BB4000000000
movq %rax, 0x220(%rsp)
movabsq $0x3ff3333333333333, %rax # imm = 0x3FF3333333333333
movq %rax, 0x228(%rsp)
cmpb $0x1, 0x290(%rdi)
movsd %xmm1, 0x10(%rsp)
jne 0x11ca7
movsd 0xa90(%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x2b8(%rbx), %r14
movq 0x2c0(%rbx), %rdx
movq 0x2c8(%rbx), %rcx
movq %rcx, %rsi
imulq %rdx, %rsi
leaq 0xf8(%rsp), %r15
movq %r15, %rdi
callq 0x6a8e
movq %r15, %rdi
movq %r14, %rsi
callq 0x6afc
leaq 0x230(%rsp), %rdi
leaq 0x110(%rsp), %rsi
leaq 0xf8(%rsp), %rdx
movsd 0x8(%rsp), %xmm0
callq 0x6296
leaq 0x110(%rsp), %rdi
leaq 0x230(%rsp), %rsi
movl $0x120, %edx            # imm = 0x120
callq 0x52f0
movq 0xf8(%rsp), %rdi
callq 0x5460
jmp 0x11ce2
movapd %xmm1, %xmm2
movsd 0x270(%rbx), %xmm1
leaq 0x230(%rsp), %r14
leaq 0x110(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
movapd %xmm2, %xmm0
callq 0x5f08
movl $0x120, %edx            # imm = 0x120
movq %r15, %rdi
movq %r14, %rsi
callq 0x52f0
cmpb $0x1, 0x430(%rbx)
jne 0x11d7c
movsd 0x748(%rbx), %xmm0
movsd %xmm0, 0x18(%rsp)
movsd 0x4c0(%rbx), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x458(%rbx), %r14
movq 0x460(%rbx), %rdx
movq 0x468(%rbx), %rcx
movq %rcx, %rsi
imulq %rdx, %rsi
leaq 0xe0(%rsp), %r15
movq %r15, %rdi
callq 0x6a8e
movq %r15, %rdi
movq %r14, %rsi
callq 0x6afc
movsd (%rsp), %xmm0
subsd 0x18(%rsp), %xmm0
mulsd 0x8(%rsp), %xmm0
leaq 0xe0(%rsp), %rdi
movl $0x1, %esi
callq 0x1c780
movsd %xmm0, 0x788(%rbx)
movq 0xe0(%rsp), %rdi
callq 0x5460
jmp 0x11d8c
movsd 0x478(%rbx), %xmm0
movsd %xmm0, 0x788(%rbx)
movsd 0x748(%rbx), %xmm3
cmpb $0x1, 0x480(%rbx)
jne 0x11e8d
movsd %xmm3, 0x8(%rsp)
movsd 0x4c0(%rbx), %xmm0
movsd %xmm0, 0x18(%rsp)
leaq 0x4a8(%rbx), %r14
movq 0x4b0(%rbx), %rdx
movq 0x4b8(%rbx), %rcx
movq %rcx, %rsi
imulq %rdx, %rsi
leaq 0xc8(%rsp), %r15
movq %r15, %rdi
callq 0x6a8e
movq %r15, %rdi
movq %r14, %rsi
callq 0x6afc
movsd (%rsp), %xmm0
subsd 0x8(%rsp), %xmm0
mulsd 0x18(%rsp), %xmm0
leaq 0xc8(%rsp), %rdi
movl $0x1, %esi
callq 0x1c780
movsd %xmm0, 0x778(%rbx)
movq 0xc8(%rsp), %rdi
callq 0x5460
movsd 0x778(%rbx), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x11e3c
jnp 0x11ee0
movsd 0x748(%rbx), %xmm0
movsd 0x4d0(%rbx), %xmm1
addsd %xmm0, %xmm1
movsd (%rsp), %xmm2
ucomisd %xmm1, %xmm2
jb 0x11ee0
movsd 0x4e0(%rbx), %xmm2
divsd 0x4c0(%rbx), %xmm2
addsd %xmm2, %xmm1
ucomisd (%rsp), %xmm1
jbe 0x11ee0
addsd 0x4e8(%rbx), %xmm0
movb $0x1, %al
ucomisd (%rsp), %xmm0
jbe 0x11ee0
jmp 0x11ee2
movsd 0x4d0(%rbx), %xmm0
addsd %xmm3, %xmm0
movsd (%rsp), %xmm2
ucomisd %xmm0, %xmm2
jb 0x11ee0
movsd 0x4e0(%rbx), %xmm1
divsd 0x4c0(%rbx), %xmm1
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jbe 0x11ee0
addsd 0x4e8(%rbx), %xmm3
ucomisd %xmm2, %xmm3
jbe 0x11ee0
movsd 0x4c8(%rbx), %xmm0
movsd %xmm0, 0x778(%rbx)
movb $0x1, %al
jmp 0x11ee2
xorl %eax, %eax
movb %al, 0x254(%rbx)
testb %al, %al
je 0x11f79
movsd 0x470(%rbx), %xmm0
movsd 0x788(%rbx), %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x788(%rbx)
mulsd 0x4c0(%rbx), %xmm0
mulsd 0x778(%rbx), %xmm0
movsd %xmm0, 0x778(%rbx)
movapd %xmm0, %xmm2
divsd %xmm1, %xmm2
movsd 0x758(%rbx), %xmm1
divsd %xmm1, %xmm2
movsd %xmm2, 0x790(%rbx)
movsd 0x798(%rbx), %xmm3
mulsd 0x220(%rsp), %xmm3
subsd %xmm3, %xmm0
movsd %xmm0, 0x760(%rbx)
xorpd %xmm3, %xmm3
ucomisd 0x15da7(%rip), %xmm2    # 0x27d10
jbe 0x11f8d
divsd %xmm2, %xmm0
divsd %xmm1, %xmm0
movapd %xmm0, %xmm3
jmp 0x11f8d
xorl %eax, %eax
movq %rax, 0x760(%rbx)
movq %rax, 0x790(%rbx)
xorpd %xmm3, %xmm3
movsd %xmm3, 0x780(%rbx)
cmpb $0x1, 0x5b8(%rbx)
jne 0x120f9
leaq 0x5e0(%rbx), %r14
movq 0x5e8(%rbx), %rdx
movq 0x5f0(%rbx), %rcx
movq %rcx, %rsi
imulq %rdx, %rsi
leaq 0xb0(%rsp), %r15
movq %r15, %rdi
callq 0x6a8e
movq %r15, %rdi
movq %r14, %rsi
callq 0x6afc
leaq 0xb0(%rsp), %rdi
movsd (%rsp), %xmm0
movl $0x1, %esi
callq 0x1c780
divsd 0x15ce8(%rip), %xmm0    # 0x27ce0
mulsd 0x15ce8(%rip), %xmm0    # 0x27ce8
movsd %xmm0, 0x940(%rbx)
movq 0xb0(%rsp), %rdi
callq 0x5460
movq 0x5e8(%rbx), %rdx
movq 0x5f0(%rbx), %rcx
movq %rcx, %rsi
imulq %rdx, %rsi
leaq 0x98(%rsp), %r15
movq %r15, %rdi
callq 0x6a8e
movq %r15, %rdi
movq %r14, %rsi
callq 0x6afc
leaq 0x98(%rsp), %rdi
movsd (%rsp), %xmm0
movl $0x2, %esi
callq 0x1c780
divsd 0x15c7c(%rip), %xmm0    # 0x27ce0
mulsd 0x15c7c(%rip), %xmm0    # 0x27ce8
movsd %xmm0, 0x948(%rbx)
movq 0x98(%rsp), %rdi
callq 0x5460
movq 0x5f0(%rbx), %rcx
cmpq $0x4, %rcx
jne 0x1214b
movq 0x5e8(%rbx), %rdx
movq %rdx, %rsi
imulq %rcx, %rsi
leaq 0x80(%rsp), %r15
movq %r15, %rdi
callq 0x6a8e
movq %r15, %rdi
movq %r14, %rsi
callq 0x6afc
leaq 0x80(%rsp), %rdi
movsd (%rsp), %xmm0
movl $0x3, %esi
callq 0x1c780
divsd 0x15c06(%rip), %xmm0    # 0x27ce0
mulsd 0x15c06(%rip), %xmm0    # 0x27ce8
movsd %xmm0, 0x950(%rbx)
movq 0x80(%rsp), %rdi
callq 0x5460
jmp 0x1216b
movsd 0x5f8(%rbx), %xmm0
movsd 0x600(%rbx), %xmm1
movsd 0x15bcf(%rip), %xmm2    # 0x27ce0
divsd %xmm2, %xmm0
movsd 0x15bcb(%rip), %xmm3    # 0x27ce8
mulsd %xmm3, %xmm0
movsd %xmm0, 0x940(%rbx)
divsd %xmm2, %xmm1
mulsd %xmm3, %xmm1
movsd %xmm1, 0x948(%rbx)
movsd 0x608(%rbx), %xmm0
divsd %xmm2, %xmm0
mulsd %xmm3, %xmm0
jmp 0x12163
movsd 0x608(%rbx), %xmm0
divsd 0x15b85(%rip), %xmm0    # 0x27ce0
mulsd 0x15b85(%rip), %xmm0    # 0x27ce8
movsd %xmm0, 0x950(%rbx)
cmpb $0x1, 0x2d0(%rbx)
jne 0x12253
leaq 0x328(%rbx), %r14
movq 0x330(%rbx), %rdx
movq 0x338(%rbx), %rcx
movq %rcx, %rsi
imulq %rdx, %rsi
leaq 0x68(%rsp), %r15
movq %r15, %rdi
callq 0x6a8e
movq %r15, %rdi
movq %r14, %rsi
callq 0x6afc
leaq 0x68(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
movl $0x1, %esi
callq 0x1c780
movsd %xmm0, 0x8(%rsp)
movq 0x68(%rsp), %rdi
callq 0x5460
movq 0x330(%rbx), %rdx
movq 0x338(%rbx), %rcx
movq %rcx, %rsi
imulq %rdx, %rsi
leaq 0x50(%rsp), %r15
movq %r15, %rdi
callq 0x6a8e
movq %r15, %rdi
movq %r14, %rsi
callq 0x6afc
leaq 0x50(%rsp), %rdi
movsd 0x10(%rsp), %xmm0
movl $0x2, %esi
callq 0x1c780
movsd %xmm0, 0x10(%rsp)
movq 0x50(%rsp), %rdi
callq 0x5460
movsd 0x10(%rsp), %xmm2
movapd %xmm2, %xmm1
mulsd %xmm2, %xmm1
movsd 0x8(%rsp), %xmm0
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x1226d
movapd %xmm2, %xmm1
sqrtsd %xmm0, %xmm0
jmp 0x12278
movsd 0x2f8(%rbx), %xmm1
movsd 0x300(%rbx), %xmm0
movsd %xmm1, 0x918(%rbx)
jmp 0x122a3
callq 0x52e0
movsd 0x10(%rsp), %xmm1
movsd %xmm0, 0x918(%rbx)
movsd 0x8(%rsp), %xmm0
callq 0x50a0
movsd 0x15a4d(%rip), %xmm1    # 0x27ce0
mulsd %xmm1, %xmm0
divsd 0x15a49(%rip), %xmm0    # 0x27ce8
addsd %xmm1, %xmm0
movsd %xmm0, 0x920(%rbx)
cmpb $0x1, 0x680(%rbx)
jne 0x12395
leaq 0x710(%rbx), %r14
movq 0x718(%rbx), %rdx
movq 0x720(%rbx), %rcx
movq %rcx, %rsi
imulq %rdx, %rsi
leaq 0x38(%rsp), %r15
movq %r15, %rdi
callq 0x6a8e
movq %r15, %rdi
movq %r14, %rsi
callq 0x6afc
leaq 0x38(%rsp), %rdi
movsd (%rsp), %xmm0
movl $0x1, %esi
callq 0x1c780
movsd %xmm0, 0x978(%rbx)
movq 0x38(%rsp), %rdi
callq 0x5460
movq 0x718(%rbx), %rdx
movq 0x720(%rbx), %rcx
movq %rcx, %rsi
imulq %rdx, %rsi
leaq 0x20(%rsp), %r15
movq %r15, %rdi
callq 0x6a8e
movq %r15, %rdi
movq %r14, %rsi
callq 0x6afc
leaq 0x20(%rsp), %rdi
movsd (%rsp), %xmm0
movl $0x2, %esi
callq 0x1c780
movsd %xmm0, 0x990(%rbx)
movq 0x20(%rsp), %rdi
callq 0x5460
movsd 0x978(%rbx), %xmm0
movsd 0x990(%rbx), %xmm1
subsd 0x6c8(%rbx), %xmm0
movsd %xmm0, 0x978(%rbx)
subsd 0x6f8(%rbx), %xmm1
movsd %xmm1, 0x990(%rbx)
movsd (%rsp), %xmm0
ucomisd 0x750(%rbx), %xmm0
jb 0x123b4
cmpb $0x0, 0x255(%rbx)
jne 0x123b4
movb $0x1, 0x255(%rbx)
addq $0x350, %rsp            # imm = 0x350
popq %rbx
popq %r14
popq %r15
retq
jmp 0x123c3
movq %rax, %rbx
movq 0x80(%rsp), %rdi
jmp 0x12449
jmp 0x123d2
movq %rax, %rbx
movq 0x20(%rsp), %rdi
jmp 0x12449
jmp 0x123e0
jmp 0x123ea
movq %rax, %rbx
movq 0x38(%rsp), %rdi
jmp 0x12449
movq %rax, %rbx
movq 0x50(%rsp), %rdi
jmp 0x12449
jmp 0x123f8
jmp 0x12402
movq %rax, %rbx
movq 0x68(%rsp), %rdi
jmp 0x12449
movq %rax, %rbx
movq 0x98(%rsp), %rdi
jmp 0x12449
jmp 0x12411
movq %rax, %rbx
movq 0xb0(%rsp), %rdi
jmp 0x12449
jmp 0x12420
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
jmp 0x12449
jmp 0x1242f
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
jmp 0x12449
jmp 0x1243e
movq %rax, %rbx
movq 0xf8(%rsp), %rdi
callq 0x5460
movq %rbx, %rdi
callq 0x5650