// File: /workspace/github_cpp_makefile_star2_O2/sus304[P]ForRocket/src/solver/rocket_stage.cpp
// Function: forrocket::RocketStage::FlightSequence(forrocket::SequenceClock*, forrocket::EnvironmentWind*, std::array<double, 14ul>&)
void forrocket::RocketStage::FlightSequence(SequenceClock* master_clock, EnvironmentWind* wind, DynamicsBase::state& x0) {
    namespace odeint = boost::numeric::odeint;

    // Sterpper Select
    ////////////////////////////////////
    double eps_abs = 1.0e-12;
    double eps_rel = 1.0e-7;
    // 4th Order Runge-Kutta Method
    // odeint::runge_kutta4<forrocket::DynamicsBase::state> stepper;

    // 5th Order Runge-Kutta-Dormand-Prince Method : Controled : Dense output : Internal info
    using base_stepper_type = odeint::runge_kutta_dopri5<forrocket::DynamicsBase::state>;
    auto stepper = make_controlled( eps_abs , eps_rel , base_stepper_type());

    // 8th Order Runge-Kutta-Fehlberg Method : Controled
    // using base_stepper_type = odeint::runge_kutta_fehlberg78<forrocket::DynamicsBase::state>;
    // auto stepper = make_controlled( eps_abs , eps_rel , base_stepper_type());

    // Dynamics6dofAero dynamics_6dof_aero(&rocket, master_clock, wind);
    // Dynamics6dofProgramRate dynamics_6dof_programrate(&rocket, master_clock, wind);
    DynamicsBase* p_dynamics;
    p_dynamics = new Dynamics6dofAero(&rocket, master_clock, wind);

    double start, end;
    double time_step_on_launcher = 0.001;  // 1000 Hz
    double time_step_decent_parachute = 0.1;  // 10 Hz
    fdr.ReserveCapacity(static_cast<int>((time_end - time_start) / time_step) * 1.3);

    DynamicsBase::state x0_in_stage = x0;  // x0はソルバで次段のために共有するので内部用にコピー

    if (time_ignittion <= time_start) {
        // 計算開始と同時に点火する場合
        rocket.IgnitionEngine(master_clock->UTC_date_init, master_clock->countup_time);
        start = time_start;
    } else {
        // 点火が計算開始より後の場合
        // Flight start から engine ignittion まで
        SwitchDynamics(time_start, &p_dynamics, master_clock, wind);
        odeint::integrate_const(stepper, std::ref(*p_dynamics), x0_in_stage, time_start, time_ignittion, time_step, std::ref(fdr)); // 点火までの慣性飛行計算
        start = time_ignittion;
        rocket.IgnitionEngine(master_clock->UTC_date_init, master_clock->countup_time);
    }
    // ここまでにIgnitionEngineが実行されている

    if (enable_launcher) {
        // ランチクリア時刻確定のためにコピー品で短時間回す
        Rocket rocket_on_launcher = rocket;
        SequenceClock clock_on_launcher = *master_clock; // copy
        DynamicsBase::state x0_on_launcher = x0;
        FlightDataRecorder fdr_on_launcher(&rocket_on_launcher);
        p_dynamics = new Dynamics3dofOnLauncher(&rocket_on_launcher, &clock_on_launcher);
        odeint::integrate_const(stepper, std::ref(*p_dynamics), x0_on_launcher, start, start+1.0, time_step_on_launcher, std::ref(fdr_on_launcher));
        
        # ifdef DEBUG_NO
        fdr_on_launcher.dump_csv("test_estimate_launcher.csv");
        # endif
        
        for (int i=0; i < fdr_on_launcher.countup_burn_time.size(); ++i) {
            double distance = (fdr_on_launcher.position[i].LLH(2) - fdr_on_launcher.position[0].LLH(2)) / sin(fdr_on_launcher.attitude[i].euler_angle(1));
            if (distance >= length_launcher_rail) {
                end = time_step_on_launcher * i;
                break;
            }
        }

        // ランチャ滑走の本ちゃん
        p_dynamics = new Dynamics3dofOnLauncher(&rocket, master_clock);
        stepper.initialize(std::ref(*p_dynamics), x0_in_stage, start);
        odeint::integrate_const(stepper, std::ref(*p_dynamics), x0_in_stage, start, start + end, time_step_on_launcher, std::ref(fdr));
        // odeint::integrate_const(stepper, std::ref(*p_dynamics), x0_in_stage, start, start + end, time_step_on_launcher, std::ref(fdr));
        start = start + end;
        #ifdef DEBUG
        fdr.dump_csv("debug_onlauncher_log.csv");
        #endif
    }
    // ここまでに慣性飛行からの点火もしくはランチクリアまでが実行されている
    
    if (enable_cutoff) {
        // engine cutoff まで 
        SwitchDynamics(start, &p_dynamics, master_clock, wind);
        stepper.initialize(std::ref(*p_dynamics), x0_in_stage, start);
        odeint::integrate_const(stepper, std::ref(*p_dynamics), x0_in_stage, start, time_cutoff, time_step, std::ref(fdr));
        start = time_cutoff;
        rocket.CutoffEngine();
    }
    // enable_cutoff=false の場合は質量0で自動cutoffされる（Engineクラス側）

    if (enable_despin) {
        SwitchDynamics(start, &p_dynamics, master_clock, wind);
        stepper.initialize(std::ref(*p_dynamics), x0_in_stage, start);
        odeint::integrate_const(stepper, std::ref(*p_dynamics), x0_in_stage, start, time_despin, time_step, std::ref(fdr));
        start = time_despin;
        rocket.DeSpin();
    }

    if (enable_fairing_jettson) {
        SwitchDynamics(start, &p_dynamics, master_clock, wind);
        stepper.initialize(std::ref(*p_dynamics), x0_in_stage, start);
        odeint::integrate_const(stepper, std::ref(*p_dynamics), x0_in_stage, start, time_jettson_fairing, time_step, std::ref(fdr));
        start = time_jettson_fairing;
        rocket.JettsonFairing(mass_fairing);
    }

    if (enable_sepation) {
        SwitchDynamics(start, &p_dynamics, master_clock, wind);
        stepper.initialize(std::ref(*p_dynamics), x0_in_stage, start);
        odeint::integrate_const(stepper, std::ref(*p_dynamics), x0_in_stage, start, time_separation, time_step, std::ref(fdr));
        start = time_separation;
        rocket.SeparateUpperStage(mass_upper_stage);
        x0 = x0_in_stage;  // 次段のために分離情報をコピー
    }

    if (!enable_parachute_open) {
        // 弾道で落ちるまで
        SwitchDynamics(start, &p_dynamics, master_clock, wind);
        stepper.initialize(std::ref(*p_dynamics), x0_in_stage, start);
        odeint::integrate_const(stepper, std::ref(*p_dynamics), x0_in_stage, start, time_end, time_step, std::ref(fdr));
    } else {
        // パラシュート開傘
        if (enable_apogee_parachute_open) {
            // 頂点時刻確定のためにコピー品で回す
            Rocket rocket_apogee_estimate = rocket;
            SequenceClock clock_apogee_estimate = *master_clock; // copy
            DynamicsBase::state x0_apogee_estimate = x0;
            FlightDataRecorder fdr_apogee_estimate(&rocket_apogee_estimate);
            if (enable_program_attitude) {
                p_dynamics = new Dynamics6dofProgramRate(&rocket, &clock_apogee_estimate, wind);
            } else {
                p_dynamics = new Dynamics6dofAero(&rocket, &clock_apogee_estimate, wind);
            }
            odeint::integrate_const(stepper, std::ref(*p_dynamics), x0_apogee_estimate, start, time_end, time_step, std::ref(fdr_apogee_estimate));
            double max_alt = 0.0;
            for (int i=0; i < fdr_apogee_estimate.position.size(); ++i) {
                double alt = fdr_apogee_estimate.position[i].LLH(2);
                if (max_alt < alt) {
                    max_alt = alt;
                } else {
                    end = fdr_apogee_estimate.countup_time[i];
                    break;
                }
            }
        } else {
            end = time_open_parachute;
        }
        // 開傘までの慣性飛行本ちゃん
        SwitchDynamics(start, &p_dynamics, master_clock, wind);
        stepper.initialize(std::ref(*p_dynamics), x0_in_stage, start);
        odeint::integrate_const(stepper, std::ref(*p_dynamics), x0_in_stage, start, end, time_step, std::ref(fdr));
        start = end;

        // ここまでで頂点もしくは開傘時刻まで実行されている
        odeint::runge_kutta4<forrocket::DynamicsBase::state> stepper;
        rocket.OpenParachute();
        Dynamics3dofParachute dynamics_3dof_parachute(&rocket, master_clock, wind);

        if (exist_second_parachute) {
            odeint::integrate_const(stepper, dynamics_3dof_parachute, x0_in_stage, start, time_open_second_parachute, time_step_decent_parachute, std::ref(fdr));
            rocket.OpenParachute();
            odeint::integrate_const(stepper, dynamics_3dof_parachute, x0_in_stage, time_open_second_parachute, time_end, time_step_decent_parachute, std::ref(fdr));
        } else {
            odeint::integrate_const(stepper, dynamics_3dof_parachute, x0_in_stage, start, time_end, time_step_decent_parachute, std::ref(fdr));
        }
    }

    // fdr.dump_csv("flight_log_stage"+std::to_string(stage_number)+".csv");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2668, %rsp           # imm = 0x2668
movq %rcx, %r13
movq %rdx, %r15
movq %rsi, %r12
movw $0x100, 0xa59(%rsp)     # imm = 0x100
andw $0x0, 0xde0(%rsp)
movq %rdi, %r14
movaps 0xf273(%rip), %xmm0     # 0x35810
movups %xmm0, 0xde8(%rsp)
movapd 0xf273(%rip), %xmm0     # 0x35820
movupd %xmm0, 0xdf8(%rsp)
andq $0x0, 0xe08(%rsp)
andl $0x0, 0xe10(%rsp)
movb $0x1, 0xfd8(%rsp)
pushq $0x20
popq %rdi
callq 0x5330
movq %rax, %rbx
leaq 0x10(%r14), %rsi
movq %rax, %rdi
movq %rsi, 0x5c0(%rsp)
movq %r12, 0x590(%rsp)
movq %r12, %rdx
movq %r15, 0x598(%rsp)
movq %r15, %rcx
callq 0x1f2f0
movq %rbx, 0x5a0(%rsp)
leaq 0xe80(%r14), %r12
movsd 0x11f8(%r14), %xmm0
subsd 0x1150(%r14), %xmm0
divsd 0x1200(%r14), %xmm0
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
mulsd 0xf232(%rip), %xmm0     # 0x35870
cvttsd2si %xmm0, %esi
movq %r12, %rdi
callq 0x16f6e
pushq $0xe
popq %rcx
leaq 0x5c8(%rsp), %rdi
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
movsd 0x1150(%r14), %xmm0
ucomisd 0x1158(%r14), %xmm0
jae 0x2671e
leaq 0x5a0(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
movq 0x590(%rsp), %r15
movq %r15, %rdx
movq 0x598(%rsp), %rcx
callq 0x264a8
movq (%rbx), %rax
movsd 0x1150(%r14), %xmm0
movsd 0x1158(%r14), %xmm1
movsd 0x1200(%r14), %xmm2
leaq 0xa58(%rsp), %rsi
movl $0xb1, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x5c8(%rsp), %rsi
movq %rax, %rdi
movq %r12, %rdx
callq 0x27fcf
movsd 0x1158(%r14), %xmm0
movsd %xmm0, 0x5b8(%rsp)
leaq 0x18(%r15), %rsi
leaq 0x6f0(%rsp), %rbx
movq %rbx, %rdi
callq 0x12ef2
movsd 0x38(%r15), %xmm0
movq 0x5c0(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1b912
jmp 0x26765
movq 0x590(%rsp), %r15
leaq 0x18(%r15), %rsi
leaq 0x70c(%rsp), %rbx
movq %rbx, %rdi
callq 0x12ef2
movsd 0x38(%r15), %xmm0
movq 0x5c0(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x1b912
movsd 0x1150(%r14), %xmm0
movsd %xmm0, 0x5b8(%rsp)
cmpb $0x1, 0x1160(%r14)
movq %r12, 0x5b0(%rsp)
jne 0x268a6
leaq 0xfe0(%rsp), %rdi
movq %r15, %rsi
callq 0x27616
leaq 0x638(%rsp), %rdi
movq 0x590(%rsp), %rsi
callq 0x27be8
pushq $0xe
popq %rcx
leaq 0x680(%rsp), %rdi
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x788(%rsp), %rdi
leaq 0xfe0(%rsp), %rsi
callq 0x16f14
pushq $0x18
popq %rdi
callq 0x5330
movq %rax, %rbx
leaq 0xfe0(%rsp), %rsi
leaq 0x638(%rsp), %rdx
movq %rax, %rdi
callq 0x1cc74
movsd 0xb14f(%rip), %xmm1     # 0x31940
movsd 0x5b8(%rsp), %xmm0
addsd %xmm0, %xmm1
leaq 0xa58(%rsp), %rsi
movl $0xb1, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x680(%rsp), %rsi
movsd 0xf057(%rip), %xmm2     # 0x35878
leaq 0x788(%rsp), %rdx
movq %rbx, %rdi
callq 0x27fcf
pushq $0x40
popq %r12
pushq $0x8
popq %rbp
xorl %ebx, %ebx
movq 0x7b0(%rsp), %rax
subq 0x7a8(%rsp), %rax
sarq $0x3, %rax
cmpq %rbx, %rax
jbe 0x268d2
movq 0x938(%rsp), %rax
movq 0x9b0(%rsp), %rcx
movsd (%rax,%r12), %xmm0
subsd 0x40(%rax), %xmm0
movsd %xmm0, 0x588(%rsp)
movsd (%rcx,%rbp), %xmm0
callq 0x50e0
movsd 0x588(%rsp), %xmm1
divsd %xmm0, %xmm1
ucomisd 0x1168(%r14), %xmm1
jae 0x268bd
incq %rbx
addq $0x48, %r12
addq $0x40, %rbp
jmp 0x2683a
movsd 0x5b8(%rsp), %xmm0
movsd %xmm0, 0x588(%rsp)
jmp 0x2698f
cvtsi2sd %ebx, %xmm0
mulsd 0xefaf(%rip), %xmm0     # 0x35878
movsd %xmm0, 0x5a8(%rsp)
pushq $0x18
popq %rdi
callq 0x5330
movq 0x5b0(%rsp), %r12
movq %rax, %rbx
movq %rax, %rdi
movq %r15, %rsi
movq 0x590(%rsp), %rdx
callq 0x1cc74
movq %rbx, 0x5a0(%rsp)
leaq 0xe18(%rsp), %rdx
movq (%rbx), %rax
leaq 0x5c8(%rsp), %rsi
movq %rbx, %rdi
movsd 0x5b8(%rsp), %xmm0
callq *(%rax)
leaq 0xa58(%rsp), %rsi
movb $0x0, 0x580(%rsi)
movsd 0x5b8(%rsp), %xmm0
movapd %xmm0, %xmm1
addsd 0x5a8(%rsp), %xmm1
movl $0xb1, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x5c8(%rsp), %rsi
movsd 0xef17(%rip), %xmm2     # 0x35878
movq %rbx, %rdi
movsd %xmm1, 0x588(%rsp)
movq %r12, %rdx
callq 0x27fcf
leaq 0x788(%rsp), %rdi
callq 0x26156
leaq 0xfe0(%rsp), %rdi
callq 0x25374
cmpb $0x1, 0x1170(%r14)
jne 0x26a58
leaq 0x5a0(%rsp), %rbx
movq %r14, %rdi
movsd 0x588(%rsp), %xmm0
movq %rbx, %rsi
movq 0x590(%rsp), %rdx
movq 0x598(%rsp), %rcx
callq 0x264a8
movq (%rbx), %rbx
leaq 0xe18(%rsp), %rbp
movq (%rbx), %rax
leaq 0x5c8(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
movq %rbp, %rdx
movsd 0x588(%rsp), %xmm0
callq *(%rax)
movb $0x0, 0x1c0(%rbp)
movsd 0x1178(%r14), %xmm1
movsd 0x1200(%r14), %xmm2
leaq 0xa58(%rsp), %rsi
movl $0xb1, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %rbx, %rdi
movq %r12, %rsi
movq 0x5b0(%rsp), %r12
movsd 0x588(%rsp), %xmm0
movq %r12, %rdx
callq 0x27fcf
movsd 0x1178(%r14), %xmm0
movsd %xmm0, 0x588(%rsp)
movq %r15, %rdi
callq 0x1b966
cmpb $0x1, 0x11b0(%r14)
jne 0x26b23
leaq 0x5a0(%rsp), %rbx
movq %r14, %rdi
movsd 0x588(%rsp), %xmm0
movq %rbx, %rsi
movq 0x590(%rsp), %rdx
movq 0x598(%rsp), %rcx
callq 0x264a8
movq (%rbx), %rbx
leaq 0xe18(%rsp), %r12
movq (%rbx), %rax
leaq 0x5c8(%rsp), %rbp
movq %rbx, %rdi
movq %rbp, %rsi
movq %r12, %rdx
movsd 0x588(%rsp), %xmm0
callq *(%rax)
movb $0x0, 0x1c0(%r12)
movq 0x5b0(%rsp), %r12
movsd 0x11b8(%r14), %xmm1
movsd 0x1200(%r14), %xmm2
leaq 0xa58(%rsp), %rsi
movl $0xb1, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %rbx, %rdi
movq %rbp, %rsi
movsd 0x588(%rsp), %xmm0
movq %r12, %rdx
callq 0x27fcf
movsd 0x11b8(%r14), %xmm0
movsd %xmm0, 0x588(%rsp)
movq %r15, %rdi
callq 0x1b970
cmpb $0x1, 0x11c0(%r14)
jne 0x26bf7
leaq 0x5a0(%rsp), %rbx
movq %r14, %rdi
movsd 0x588(%rsp), %xmm0
movq %rbx, %rsi
movq 0x590(%rsp), %rdx
movq 0x598(%rsp), %rcx
callq 0x264a8
movq (%rbx), %rbx
leaq 0xe18(%rsp), %r12
movq (%rbx), %rax
leaq 0x5c8(%rsp), %rbp
movq %rbx, %rdi
movq %rbp, %rsi
movq %r12, %rdx
movsd 0x588(%rsp), %xmm0
callq *(%rax)
movb $0x0, 0x1c0(%r12)
movq 0x5b0(%rsp), %r12
movsd 0x11c8(%r14), %xmm1
movsd 0x1200(%r14), %xmm2
leaq 0xa58(%rsp), %rsi
movl $0xb1, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %rbx, %rdi
movq %rbp, %rsi
movsd 0x588(%rsp), %xmm0
movq %r12, %rdx
callq 0x27fcf
movsd 0x11c8(%r14), %xmm0
movsd %xmm0, 0x588(%rsp)
movsd 0x11d0(%r14), %xmm0
movq %r15, %rdi
callq 0x1b982
cmpb $0x1, 0x1198(%r14)
jne 0x26cd6
leaq 0x5a0(%rsp), %rbx
movq %r14, %rdi
movsd 0x588(%rsp), %xmm0
movq %rbx, %rsi
movq 0x590(%rsp), %rdx
movq 0x598(%rsp), %rcx
callq 0x264a8
movq (%rbx), %r12
leaq 0xe18(%rsp), %rbp
movq (%r12), %rax
leaq 0x5c8(%rsp), %rbx
movq %r12, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movsd 0x588(%rsp), %xmm0
callq *(%rax)
movb $0x0, 0x1c0(%rbp)
movsd 0x11a0(%r14), %xmm1
movsd 0x1200(%r14), %xmm2
leaq 0xa58(%rsp), %rsi
movl $0xb1, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %r12, %rdi
movq 0x5b0(%rsp), %r12
movq %rbx, %rsi
movsd 0x588(%rsp), %xmm0
movq %r12, %rdx
callq 0x27fcf
movsd 0x11a0(%r14), %xmm0
movsd %xmm0, 0x588(%rsp)
movsd 0x11a8(%r14), %xmm0
movq %r15, %rdi
callq 0x1b9b8
pushq $0xe
popq %rcx
movq %r13, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
cmpb $0x0, 0x11d8(%r14)
je 0x26d76
cmpb $0x1, 0x11d9(%r14)
jne 0x26e18
leaq 0xfe0(%rsp), %rdi
movq %r15, %rsi
callq 0x27616
leaq 0x638(%rsp), %rdi
movq 0x590(%rsp), %rsi
callq 0x27be8
pushq $0xe
popq %rcx
leaq 0x680(%rsp), %rdi
movq %r13, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x788(%rsp), %rdi
leaq 0xfe0(%rsp), %rsi
callq 0x16f14
cmpb $0x1, 0x1180(%r14)
jne 0x26e2f
pushq $0x20
popq %rdi
callq 0x5330
movq %rax, %rbp
leaq 0x638(%rsp), %rdx
movq %rax, %rdi
movq %r15, %rsi
movq 0x598(%rsp), %rcx
callq 0x20b6c
jmp 0x26e55
leaq 0x5a0(%rsp), %rbx
movq %r14, %rdi
movsd 0x588(%rsp), %xmm0
movq %rbx, %rsi
movq 0x590(%rsp), %rdx
movq 0x598(%rsp), %rcx
callq 0x264a8
movq (%rbx), %rbx
leaq 0xe18(%rsp), %r15
movq (%rbx), %rax
movq %r12, %r13
leaq 0x5c8(%rsp), %r12
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
movsd 0x588(%rsp), %xmm0
callq *(%rax)
movb $0x0, 0x1c0(%r15)
movsd 0x11f8(%r14), %xmm1
movsd 0x1200(%r14), %xmm2
leaq 0xa58(%rsp), %rsi
movl $0xb1, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %rbx, %rdi
movq %r12, %rsi
movsd 0x588(%rsp), %xmm0
movq %r13, %rdx
callq 0x27fcf
jmp 0x27309
movsd 0x11e0(%r14), %xmm0
movsd %xmm0, 0x5a8(%rsp)
jmp 0x26f13
pushq $0x20
popq %rdi
callq 0x5330
movq %rax, %rbp
leaq 0x638(%rsp), %rdx
movq %rax, %rdi
movq %r15, %rsi
movq 0x598(%rsp), %rcx
callq 0x1f2f0
movq %rbp, 0x5a0(%rsp)
movsd 0x11f8(%r14), %xmm1
movsd 0x1200(%r14), %xmm2
leaq 0xa58(%rsp), %rsi
movl $0xb1, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x680(%rsp), %rsi
leaq 0x788(%rsp), %rdx
movq %rbp, %rdi
movsd 0x588(%rsp), %xmm0
callq 0x27fcf
movq 0x938(%rsp), %rcx
movq 0x940(%rsp), %rax
subq %rcx, %rax
pushq $0x48
popq %rsi
cqto
idivq %rsi
addq $0x40, %rcx
xorpd %xmm0, %xmm0
xorl %edx, %edx
cmpq %rdx, %rax
je 0x26ef9
movsd (%rcx), %xmm1
incq %rdx
addq $0x48, %rcx
ucomisd %xmm0, %xmm1
movapd %xmm1, %xmm0
ja 0x26ec8
movq 0x790(%rsp), %rax
movsd -0x8(%rax,%rdx,8), %xmm0
movsd %xmm0, 0x5a8(%rsp)
leaq 0x788(%rsp), %rdi
callq 0x26156
leaq 0xfe0(%rsp), %rdi
callq 0x25374
leaq 0x5a0(%rsp), %rbx
movq %r14, %rdi
movsd 0x588(%rsp), %xmm0
movq %rbx, %rsi
movq 0x590(%rsp), %r13
movq %r13, %rdx
movq 0x598(%rsp), %r15
movq %r15, %rcx
callq 0x264a8
movq (%rbx), %rbx
leaq 0xe18(%rsp), %r12
movq (%rbx), %rax
leaq 0x5c8(%rsp), %rbp
movq %rbx, %rdi
movq %rbp, %rsi
movq %r12, %rdx
movsd 0x588(%rsp), %xmm0
callq *(%rax)
movb $0x0, 0x1c0(%r12)
movsd 0x1200(%r14), %xmm2
leaq 0xa58(%rsp), %rsi
movl $0xb1, %ecx
movq %rsp, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq %rbx, %rdi
movq %rbp, %rsi
movsd 0x588(%rsp), %xmm0
movsd 0x5a8(%rsp), %xmm1
movq 0x5b0(%rsp), %r12
movq %r12, %rdx
callq 0x27fcf
leaq 0xfe0(%rsp), %rbx
leaq 0x788(%rsp), %rsi
movq %rbx, %rdi
callq 0x27c1e
movq 0x5c0(%rsp), %rbp
movq %rbp, %rdi
callq 0x1b9ee
leaq 0x788(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x1ebf4
leaq 0x10c8(%rsp), %r8
cmpb $0x1, 0x11e8(%r14)
jne 0x27210
pushq $0xf
popq %rcx
movq %r12, %r15
leaq 0x23b8(%rsp), %r12
leaq 0xfe0(%rsp), %rsi
movq %r12, %rdi
rep  movsq (%rsi), %es:(%rdi)
movups 0x78(%rbx), %xmm0
movups %xmm0, 0x78(%r12)
movq 0x98(%rbx), %rax
movq %rax, 0x98(%r12)
movups 0x88(%rbx), %xmm0
movups %xmm0, 0x88(%r12)
movups 0xa0(%rbx), %xmm0
movups 0xb0(%rbx), %xmm1
movups %xmm0, 0xa0(%r12)
movups %xmm1, 0xb0(%r12)
movups 0xd0(%rbx), %xmm0
movups %xmm0, 0xd0(%r12)
movq 0xe0(%rbx), %rax
movq %rax, 0xe0(%r12)
movups 0xc0(%rbx), %xmm0
movups %xmm0, 0xc0(%r12)
movl $0xe8, %eax
leaq (%r12,%rax), %rdi
movl $0x1c8, %edx            # imm = 0x1C8
movq %r8, %rsi
callq 0x52c0
leaq 0x21867(%rip), %r13     # 0x48928
addq $0x10, %r13
leaq 0x768(%rsp), %rsi
movq %r13, (%rsi)
leaq 0x788(%rsp), %rax
movups 0x8(%rax), %xmm0
movups %xmm0, 0x8(%rsi)
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsi)
movsd 0x11f0(%r14), %xmm1
leaq 0x5c8(%rsp), %rdx
movsd 0xe77f(%rip), %xmm2     # 0x35880
movq %r12, %rdi
movsd 0x5a8(%rsp), %xmm0
movq %r15, %rcx
movq %r15, %r12
callq 0x27c8c
movq %rbp, %rdi
callq 0x1b9ee
leaq 0x2108(%rsp), %r15
pushq $0xf
popq %rcx
movq %r15, %rdi
leaq 0xfe0(%rsp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movups 0x78(%rbx), %xmm0
movups %xmm0, 0x78(%r15)
movq 0x98(%rbx), %rax
movq %rax, 0x98(%r15)
movups 0x88(%rbx), %xmm0
movups %xmm0, 0x88(%r15)
movups 0xa0(%rbx), %xmm0
movups 0xb0(%rbx), %xmm1
movups %xmm0, 0xa0(%r15)
movups %xmm1, 0xb0(%r15)
movups 0xd0(%rbx), %xmm0
movups %xmm0, 0xd0(%r15)
movq 0xe0(%rbx), %rax
movq %rax, 0xe0(%r15)
movups 0xc0(%rbx), %xmm0
movups %xmm0, 0xc0(%r15)
movl $0xe8, %edi
addq %r15, %rdi
movl $0x1c8, %edx            # imm = 0x1C8
leaq 0x10c8(%rsp), %rsi
callq 0x52c0
leaq 0x748(%rsp), %rsi
movq %r13, (%rsi)
leaq 0x788(%rsp), %rax
movups 0x8(%rax), %xmm0
movups %xmm0, 0x8(%rsi)
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsi)
movsd 0x11f0(%r14), %xmm0
movsd 0x11f8(%r14), %xmm1
movq %r15, %rdi
leaq 0x5c8(%rsp), %rdx
movsd 0xe675(%rip), %xmm2     # 0x35880
jmp 0x27301
pushq $0xf
popq %rcx
leaq 0x1e58(%rsp), %r15
leaq 0xfe0(%rsp), %rsi
movq %r15, %rdi
rep  movsq (%rsi), %es:(%rdi)
movups 0x78(%rbx), %xmm0
movups %xmm0, 0x78(%r15)
movq 0x98(%rbx), %rax
movq %rax, 0x98(%r15)
movups 0x88(%rbx), %xmm0
movups %xmm0, 0x88(%r15)
movups 0xa0(%rbx), %xmm0
movups 0xb0(%rbx), %xmm1
movups %xmm0, 0xa0(%r15)
movups %xmm1, 0xb0(%r15)
movups 0xd0(%rbx), %xmm0
movups %xmm0, 0xd0(%r15)
movq 0xe0(%rbx), %rax
movq %rax, 0xe0(%r15)
movups 0xc0(%rbx), %xmm0
movups %xmm0, 0xc0(%r15)
leaq 0x1f40(%rsp), %rdi
movl $0x1c8, %edx            # imm = 0x1C8
movq %r8, %rsi
callq 0x52c0
leaq 0x21673(%rip), %rax     # 0x48928
addq $0x10, %rax
leaq 0x728(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x788(%rsp), %rax
movups 0x8(%rax), %xmm0
movups %xmm0, 0x8(%rsi)
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsi)
movsd 0x11f8(%r14), %xmm1
leaq 0x5c8(%rsp), %rdx
movsd 0xe58b(%rip), %xmm2     # 0x35880
movq %r15, %rdi
movsd 0x5a8(%rsp), %xmm0
movq %r12, %rcx
callq 0x27c8c
addq $0x2668, %rsp           # imm = 0x2668
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2731d
movq %rax, %r14
pushq $0x20
popq %rsi
movq %rbp, %rdi
jmp 0x27339
jmp 0x27342
jmp 0x27342
jmp 0x27357
jmp 0x27330
movq %rax, %r14
pushq $0x18
popq %rsi
movq %rbx, %rdi
callq 0x5340
jmp 0x2735a
jmp 0x27342
movq %rax, %r14
jmp 0x27367
movq %rax, %r14
pushq $0x20
popq %rsi
movq %rbx, %rdi
callq 0x5340
jmp 0x27374
movq %rax, %r14
leaq 0x788(%rsp), %rdi
callq 0x26156
leaq 0xfe0(%rsp), %rdi
callq 0x25374
movq %r14, %rdi
callq 0x55b0