// File: /workspace/github_cpp_makefile_star2_O2/sus304[P]ForRocket/src/solver/trajectory_solver.cpp
// Function: forrocket::TrajectorySolver::TrajectorySolver(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
forrocket::TrajectorySolver::TrajectorySolver(std::string solver_config_json_file) {
    JsonControl jc_solver_config(solver_config_json_file);
    
    model_id = jc_solver_config.getString("Model ID");
    number_stage = jc_solver_config.getInt("Number of Stage");

    // Making Stage instance
    RocketStageFactory stage_factory;
    for (int i=1; i <= number_stage; ++i) {
        auto jc_stage = JsonControl(jc_solver_config.getString("Stage"+std::to_string(i)+" Config File List"));
        stage_vector.push_back(stage_factory.Create(i, 
                                                jc_stage.getString("Rocket Configuration File Path"),
                                                jc_stage.getString("Engine Configuration File Path"),
                                                jc_stage.getString("Sequence of Event File Path")));
    }

    for (auto& stage : stage_vector) {
        stage.fdr = FlightDataRecorder(&stage.rocket);
    }

    // Prepare Launch - Master Clock
    DateTime launch_date(jc_solver_config.getString("Launch DateTime"));
    master_clock = SequenceClock(launch_date, 0.0);

    // Prepare Launch - Position Velocity Attitude
    Rocket& rocket_first_stage = stage_vector[0].rocket;
    auto jc_launch = jc_solver_config.getSubItem("Launch Condition");

    Eigen::Vector3d pos_init_LLH;
    pos_init_LLH << jc_launch.getDouble("Latitude [deg]"), jc_launch.getDouble("Longitude [deg]"), jc_launch.getDouble("Height for WGS84 [deg]");

    rocket_first_stage.position.Initialize(master_clock.UTC_date_init, pos_init_LLH);

    Eigen::Vector3d vel_init_NED;
    vel_init_NED << jc_launch.getDouble("North Velocity [m/s]"), jc_launch.getDouble("East Velocity [m/s]"), jc_launch.getDouble("Down Velocity [m/s]");
    rocket_first_stage.velocity.Initialize(master_clock.UTC_date_init, vel_init_NED, pos_init_LLH, rocket_first_stage.position.ECI);

    Eigen::Vector3d euler;
    euler << jc_launch.getDouble("Azimuth [deg]"), jc_launch.getDouble("Elevation [deg]"), 0.0;
    euler = euler / 180.0 * 3.14159265;
    rocket_first_stage.attitude.Initialize(euler);

    rocket_first_stage.angular_velocity << 0.0, 0.0, 0.0;

    // Prepare Launch - Wind
    auto jc_wind = jc_solver_config.getSubItem("Wind Condition");
    if (jc_wind.getBool("Enable Wind")) {
        wind = EnvironmentWind(jc_wind.getString("Wind File Path"));
    } else {
        wind = EnvironmentWind(false);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1698, %rsp           # imm = 0x1698
movq %rsi, %rbx
movq %rdi, %r13
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
leaq 0x28(%rdi), %rax
movq %rax, 0x48(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rdi)
andq $0x0, 0x38(%rdi)
leaq 0x40(%rdi), %r15
movq %r15, %rdi
callq 0x13258
leaq 0x88(%r13), %r14
movq %r14, %rdi
callq 0x2ad6e
leaq 0x348(%rsp), %rdi
movq %rbx, %rsi
callq 0x5460
leaq 0x38(%rsp), %rdi
leaq 0x348(%rsp), %rsi
callq 0x660c
leaq 0x348(%rsp), %rdi
callq 0x5688
leaq 0xbee2(%rip), %rsi      # 0x35bd3
leaq 0x328(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x72de
leaq 0x480(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x328(%rsp), %rdx
callq 0x6708
leaq 0x480(%rsp), %rbx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x53c0
movq %rbx, %rdi
callq 0x5688
leaq 0x328(%rsp), %rdi
callq 0x5688
leaq 0xbe90(%rip), %rsi      # 0x35bdc
leaq 0x308(%rsp), %rdi
leaq 0x480(%rsp), %rdx
callq 0x72de
movq %r15, 0x78(%rsp)
movq %r14, 0x8(%rsp)
leaq 0x38(%rsp), %rdi
leaq 0x308(%rsp), %rsi
callq 0x6728
movq %r13, 0x10(%rsp)
movl %eax, 0x20(%r13)
leaq 0x308(%rsp), %rdi
callq 0x5688
pushq $0x1
popq %rbp
leaq 0x58(%rsp), %r15
leaq 0x480(%rsp), %r14
leaq 0xc8(%rsp), %rbx
movq 0x10(%rsp), %rax
cmpl 0x20(%rax), %ebp
jg 0x29f5f
movq %r15, %rdi
movl %ebp, %esi
callq 0x75f8
movq %r14, %rdi
leaq 0xbe19(%rip), %rsi      # 0x35be6
movq %r15, %rdx
callq 0xb4fd
leaq 0x3e8(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
leaq 0xbe02(%rip), %rdx      # 0x35bec
callq 0x74fc
leaq 0x460(%rsp), %r12
movq %r12, %rdi
leaq 0x38(%rsp), %rsi
movq %r13, %rdx
callq 0x6708
movq %rbx, %rdi
movq %r12, %rsi
callq 0x660c
movq %r12, %rdi
callq 0x5688
leaq 0x3e8(%rsp), %rdi
callq 0x5688
movq %r14, %rdi
callq 0x5688
movq %r15, %rdi
callq 0x5688
leaq 0x3c8(%rsp), %r12
movq %r12, %rdi
leaq 0xbdb5(%rip), %rsi      # 0x35bfe
movq %r15, %rdx
callq 0x72de
leaq 0x2e8(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x6708
leaq 0x3a8(%rsp), %r12
movq %r12, %rdi
leaq 0xbda7(%rip), %rsi      # 0x35c1d
leaq 0x98(%rsp), %rdx
callq 0x72de
leaq 0x2c8(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x6708
leaq 0x368(%rsp), %r12
movq %r12, %rdi
leaq 0xbd94(%rip), %rsi      # 0x35c3c
leaq 0xb0(%rsp), %rdx
callq 0x72de
leaq 0x388(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x6708
movq %r14, %rdi
leaq 0x1f(%rsp), %rsi
movl %ebp, %edx
leaq 0x2e8(%rsp), %rcx
leaq 0x2c8(%rsp), %r8
movq %r13, %r9
callq 0x25448
movq 0x48(%rsp), %rdi
movq %r14, %rsi
callq 0x2b432
movq %r14, %rdi
callq 0x26138
leaq 0x388(%rsp), %rdi
callq 0x5688
leaq 0x368(%rsp), %rdi
callq 0x5688
leaq 0x2c8(%rsp), %rdi
callq 0x5688
leaq 0x3a8(%rsp), %rdi
callq 0x5688
leaq 0x2e8(%rsp), %rdi
callq 0x5688
leaq 0x3c8(%rsp), %rdi
callq 0x5688
movq %rbx, %rdi
callq 0x68a0
incl %ebp
jmp 0x29dab
movq 0x10(%rsp), %r13
movq 0x28(%r13), %rbx
movq 0x30(%r13), %r15
leaq 0x480(%rsp), %r14
cmpq %r15, %rbx
je 0x29fa8
addq $0x10, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x16f14
leaq 0xe70(%rbx), %rdi
movq %r14, %rsi
callq 0x2ada2
movq %r14, %rdi
callq 0x26156
addq $0x1200, %rbx           # imm = 0x1200
jmp 0x29f74
leaq 0xbca9(%rip), %rsi      # 0x35c58
leaq 0x288(%rsp), %rdi
leaq 0x480(%rsp), %rdx
callq 0x72de
leaq 0x2a8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x288(%rsp), %rdx
callq 0x6708
movq 0x78(%rsp), %rbx
leaq 0xc8(%rsp), %rdi
leaq 0x2a8(%rsp), %rsi
callq 0x12d36
leaq 0x2a8(%rsp), %rdi
callq 0x5688
leaq 0x288(%rsp), %rdi
callq 0x5688
leaq 0x444(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x12ef2
leaq 0x480(%rsp), %rdi
leaq 0x444(%rsp), %rsi
xorps %xmm0, %xmm0
callq 0x132d8
leaq 0x480(%rsp), %rsi
movq %rbx, %rdi
callq 0x1baea
movq 0x48(%rsp), %rax
movq (%rax), %r13
leaq 0xbc0a(%rip), %rsi      # 0x35c68
leaq 0x268(%rsp), %rdi
leaq 0x480(%rsp), %rdx
callq 0x72de
leaq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x268(%rsp), %rdx
callq 0x6758
leaq 0x268(%rsp), %rdi
callq 0x5688
leaq 0xbbdb(%rip), %rsi      # 0x35c79
leaq 0x248(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x72de
leaq 0x28(%rsp), %rdi
leaq 0x248(%rsp), %rsi
callq 0x6738
leaq 0x98(%rsp), %rax
movq %rax, 0x480(%rsp)
andq $0x0, 0x488(%rsp)
pushq $0x1
popq %rbp
movq %rbp, 0x490(%rsp)
movq %rbp, 0x498(%rsp)
movsd %xmm0, 0x98(%rsp)
leaq 0xbb87(%rip), %rsi      # 0x35c88
leaq 0x228(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x72de
leaq 0x28(%rsp), %rdi
leaq 0x228(%rsp), %rsi
callq 0x6738
leaq 0x58(%rsp), %rsi
movsd %xmm0, (%rsi)
leaq 0x480(%rsp), %rdi
callq 0x126a8
movq %rax, %rbx
leaq 0xbb53(%rip), %rsi      # 0x35c98
leaq 0x208(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x72de
leaq 0x28(%rsp), %rdi
leaq 0x208(%rsp), %rsi
callq 0x6738
leaq 0xb0(%rsp), %r15
movsd %xmm0, (%r15)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x126a8
leaq 0x208(%rsp), %rdi
callq 0x5688
leaq 0x228(%rsp), %rdi
callq 0x5688
leaq 0x480(%rsp), %rdi
callq 0x12750
leaq 0x248(%rsp), %rdi
callq 0x5688
movq 0x10(%rsp), %rax
leaq 0x58(%rax), %r14
leaq 0x428(%rsp), %rdi
movq %r14, %rsi
callq 0x12ef2
leaq 0x2b0(%r13), %rbx
leaq 0x428(%rsp), %rsi
leaq 0x98(%rsp), %rdx
movq %rbx, %rdi
callq 0x15966
leaq 0xbabb(%rip), %rsi      # 0x35caf
leaq 0x1e8(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x72de
leaq 0x28(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
callq 0x6738
movq %r15, 0x480(%rsp)
andq $0x0, 0x488(%rsp)
movq %rbp, 0x490(%rsp)
movq %rbp, 0x498(%rsp)
movsd %xmm0, 0xb0(%rsp)
leaq 0xba7b(%rip), %rsi      # 0x35cc4
leaq 0x1c8(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x72de
leaq 0x28(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0x6738
leaq 0x58(%rsp), %rsi
movsd %xmm0, (%rsi)
leaq 0x480(%rsp), %rdi
callq 0x126a8
movq %rax, %r12
leaq 0xba4b(%rip), %rsi      # 0x35cd8
leaq 0x1a8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x72de
leaq 0x28(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x6738
leaq 0x80(%rsp), %r15
movsd %xmm0, (%r15)
movq %r12, %rdi
movq %r15, %rsi
callq 0x126a8
leaq 0x1a8(%rsp), %rdi
callq 0x5688
leaq 0x1c8(%rsp), %rdi
callq 0x5688
leaq 0x480(%rsp), %rdi
callq 0x12750
leaq 0x1e8(%rsp), %rdi
callq 0x5688
leaq 0x40c(%rsp), %rdi
movq %r14, %rsi
callq 0x12ef2
leaq 0x2f8(%r13), %rdi
leaq 0x40c(%rsp), %rsi
leaq 0xb0(%rsp), %rdx
leaq 0x98(%rsp), %rcx
movq %rbx, %r8
callq 0x161aa
leaq 0xb9b1(%rip), %rsi      # 0x35cec
leaq 0x188(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x72de
leaq 0x28(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0x6738
movq %r15, 0x480(%rsp)
andq $0x0, 0x488(%rsp)
movq %rbp, 0x490(%rsp)
movq %rbp, 0x498(%rsp)
movsd %xmm0, 0x80(%rsp)
leaq 0xb96a(%rip), %rsi      # 0x35cfa
leaq 0x168(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x72de
leaq 0x28(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x6738
leaq 0x58(%rsp), %rsi
movsd %xmm0, (%rsi)
leaq 0x480(%rsp), %rdi
callq 0x126a8
leaq 0x20(%rsp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
callq 0x126a8
leaq 0x168(%rsp), %rdi
callq 0x5688
leaq 0x480(%rsp), %rdi
callq 0x12750
leaq 0x188(%rsp), %rdi
callq 0x5688
movabsq $0x4066800000000000, %rax # imm = 0x4066800000000000
leaq 0x20(%rsp), %rdx
movq %rax, (%rdx)
leaq 0x58(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x1d618
movabsq $0x400921fb53c8d4f1, %rax # imm = 0x400921FB53C8D4F1
leaq 0x50(%rsp), %rdx
movq %rax, (%rdx)
leaq 0x480(%rsp), %rdi
leaq 0x58(%rsp), %rsi
callq 0x2af9a
leaq 0x80(%rsp), %rdi
leaq 0x480(%rsp), %rsi
callq 0x2ce83
leaq 0x3e0(%r13), %rdi
leaq 0x80(%rsp), %rsi
callq 0x1476c
leaq 0x440(%r13), %rax
leaq 0x480(%rsp), %rdi
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movq %rbp, 0x10(%rdi)
movq %rbp, 0x18(%rdi)
andq $0x0, 0x440(%r13)
leaq 0x58(%rsp), %rsi
andq $0x0, (%rsi)
callq 0x126a8
leaq 0x20(%rsp), %rsi
andq $0x0, (%rsi)
movq %rax, %rdi
movq 0x8(%rsp), %r14
callq 0x126a8
leaq 0x480(%rsp), %rdi
callq 0x12750
leaq 0xb838(%rip), %rsi      # 0x35d0a
leaq 0x148(%rsp), %rdi
leaq 0x480(%rsp), %rdx
callq 0x72de
leaq 0x58(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x148(%rsp), %rdx
callq 0x6758
leaq 0x148(%rsp), %rdi
callq 0x5688
leaq 0xb807(%rip), %rsi      # 0x35d19
leaq 0x128(%rsp), %rdi
leaq 0x480(%rsp), %rdx
callq 0x72de
leaq 0x58(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x6748
movl %eax, %ebx
leaq 0x128(%rsp), %rdi
callq 0x5688
testb %bl, %bl
je 0x2a5d1
leaq 0xb7ce(%rip), %rsi      # 0x35d25
leaq 0xe8(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x72de
leaq 0x108(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0xe8(%rsp), %rdx
callq 0x6708
leaq 0x480(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x13c1e
leaq 0x480(%rsp), %rsi
movq %r14, %rdi
callq 0x2aff4
leaq 0x480(%rsp), %rdi
callq 0x2b022
leaq 0x108(%rsp), %rdi
callq 0x5688
leaq 0xe8(%rsp), %rdi
callq 0x5688
jmp 0x2a5fd
leaq 0x480(%rsp), %rdi
xorl %esi, %esi
callq 0x13b80
leaq 0x480(%rsp), %rsi
movq %r14, %rdi
callq 0x2aff4
leaq 0x480(%rsp), %rdi
callq 0x2b022
leaq 0x58(%rsp), %rdi
callq 0x68a0
leaq 0x28(%rsp), %rdi
callq 0x68a0
leaq 0x38(%rsp), %rdi
callq 0x68a0
addq $0x1698, %rsp           # imm = 0x1698
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r12
leaq 0x480(%rsp), %rdi
callq 0x2b022
jmp 0x2a642
movq %rax, %r12
leaq 0x108(%rsp), %rdi
callq 0x5688
jmp 0x2a666
movq %rax, %r12
leaq 0x480(%rsp), %rdi
callq 0x2b022
jmp 0x2a689
movq %rax, %r12
leaq 0xe8(%rsp), %rdi
jmp 0x2a67f
jmp 0x2a686
jmp 0x2a686
movq %rax, %r12
leaq 0x128(%rsp), %rdi
callq 0x5688
jmp 0x2a689
movq %rax, %r12
leaq 0x58(%rsp), %rdi
callq 0x68a0
jmp 0x2a84e
movq %rax, %r12
leaq 0x148(%rsp), %rdi
jmp 0x2a849
jmp 0x2a80d
jmp 0x2a6af
movq %rax, %r12
leaq 0x480(%rsp), %rdi
callq 0x12750
jmp 0x2a84e
jmp 0x2a80d
jmp 0x2a80d
jmp 0x2a7ab
movq %rax, %r12
jmp 0x2a7bb
movq %rax, %r12
jmp 0x2a7c8
jmp 0x2a80d
jmp 0x2a7e6
movq %rax, %r12
jmp 0x2a7f6
movq %rax, %r12
jmp 0x2a803
jmp 0x2a80d
jmp 0x2a824
movq %rax, %r12
jmp 0x2a834
movq %rax, %r12
jmp 0x2a841
jmp 0x2a80d
movq %rax, %r12
leaq 0x268(%rsp), %rdi
jmp 0x2a8f8
jmp 0x2a96f
movq %rax, %r12
leaq 0x2a8(%rsp), %rdi
callq 0x5688
jmp 0x2a746
movq %rax, %r12
leaq 0x288(%rsp), %rdi
jmp 0x2a8f8
jmp 0x2a96f
movq %rax, %r12
leaq 0x308(%rsp), %rdi
callq 0x5688
jmp 0x2a977
jmp 0x2a784
movq %rax, %r12
leaq 0x328(%rsp), %rdi
callq 0x5688
jmp 0x2a97c
movq %rax, %r12
jmp 0x2a97c
movq %rax, %r12
leaq 0x348(%rsp), %rdi
callq 0x5688
jmp 0x2a986
movq %rax, %r12
jmp 0x2a986
jmp 0x2a80d
movq %rax, %r12
leaq 0x168(%rsp), %rdi
callq 0x5688
leaq 0x480(%rsp), %rdi
callq 0x12750
leaq 0x188(%rsp), %rdi
jmp 0x2a849
jmp 0x2a80d
movq %rax, %r12
leaq 0x1a8(%rsp), %rdi
callq 0x5688
jmp 0x2a7e9
movq %rax, %r12
leaq 0x1c8(%rsp), %rdi
callq 0x5688
leaq 0x480(%rsp), %rdi
callq 0x12750
leaq 0x1e8(%rsp), %rdi
jmp 0x2a849
movq %rax, %r12
jmp 0x2a84e
movq %rax, %r12
leaq 0x208(%rsp), %rdi
callq 0x5688
jmp 0x2a827
movq %rax, %r12
leaq 0x228(%rsp), %rdi
callq 0x5688
leaq 0x480(%rsp), %rdi
callq 0x12750
leaq 0x248(%rsp), %rdi
callq 0x5688
leaq 0x28(%rsp), %rdi
callq 0x68a0
jmp 0x2a972
movq %rax, %r12
jmp 0x2a98e
jmp 0x2a96f
movq %rax, %r12
jmp 0x2a977
movq %rax, %r12
jmp 0x2a8ba
movq %rax, %r12
jmp 0x2a8f3
movq %rax, %r12
jmp 0x2a8ad
movq %rax, %r12
jmp 0x2a8e6
movq %rax, %r12
jmp 0x2a8a0
movq %rax, %r12
jmp 0x2a8d9
movq %rax, %r12
leaq 0x480(%rsp), %rdi
callq 0x26138
leaq 0x388(%rsp), %rdi
callq 0x5688
leaq 0x368(%rsp), %rdi
callq 0x5688
leaq 0x2c8(%rsp), %rdi
callq 0x5688
jmp 0x2a92f
movq %rax, %r12
leaq 0x460(%rsp), %rdi
callq 0x5688
leaq 0x3e8(%rsp), %rdi
callq 0x5688
leaq 0x480(%rsp), %rdi
callq 0x5688
leaq 0x58(%rsp), %rdi
callq 0x5688
jmp 0x2a972
movq %rax, %r12
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %r14
jmp 0x2a960
movq %rax, %r12
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %r14
jmp 0x2a953
movq %rax, %r12
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %r14
jmp 0x2a946
movq %rax, %r12
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %r14
leaq 0x3a8(%rsp), %rdi
callq 0x5688
leaq 0x2e8(%rsp), %rdi
callq 0x5688
leaq 0x3c8(%rsp), %rdi
callq 0x5688
leaq 0xc8(%rsp), %rdi
callq 0x68a0
jmp 0x2a97c
movq %rax, %r12
movq 0x10(%rsp), %r13
movq 0x8(%rsp), %r14
leaq 0x38(%rsp), %rdi
callq 0x68a0
movq %r14, %rdi
callq 0x2b022
movq 0x48(%rsp), %rdi
callq 0x2b03c
movq %r13, %rdi
callq 0x5688
movq %r12, %rdi
callq 0x55b0