// File: /workspace/github_cpp_makefile_star2_O2/sus304[P]ForRocket/src/factory/engine_factory.cpp
// Function: forrocket::EngineFactory::Create(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
forrocket::Engine forrocket::EngineFactory::Create(std::string engine_config_json_file) {
    JsonControl jc(engine_config_json_file);

    double diameter_exit = jc.getDouble("Nozzle Exit Diameter [mm]") / 1e3;
    double area_exit = 0.25 * std::pow(diameter_exit, 2) * pi;

    bool enable_mis_alignment = jc.getBool("Enable Engine Miss Alignment");
    if (jc.getBool("Enable Thrust File")) {
        JsonControl jc_file = jc.getSubItem("Thrust File");
        auto thrust_log = LoadCsvLog(jc_file.getString("Thrust at vacuum File Path"));
        if (enable_mis_alignment) {
            double mis_alignment_y = jc.getSubItem("Engine Miss-Alignment").getDouble("y-Axis Angle [deg]") / 180.0 * 3.14159265;
            double mis_alignment_z = jc.getSubItem("Engine Miss-Alignment").getDouble("z-Axis Angle [deg]") / 180.0 * 3.14159265;
            return Engine(thrust_log[0], thrust_log[1], thrust_log[2], area_exit, mis_alignment_y, mis_alignment_z);
        } else {
            return Engine(thrust_log[0], thrust_log[1], thrust_log[2], area_exit);
        }
    } else {
        JsonControl jc_const = jc.getSubItem("Constant Thrust");
        double thrust = jc_const.getDouble("Thrust at vacuum [N]");
        double mdot_p = jc_const.getDouble("Propellant Mass Flow Rate [kg/s]");
        double burn_duration = jc_const.getDouble("Burn Duration [sec]");
        if (enable_mis_alignment) {
            double mis_alignment_y = jc.getSubItem("Engine Miss-Alignment").getDouble("y-Axis Angle [deg]") / 180.0 * 3.14159265;
            double mis_alignment_z = jc.getSubItem("Engine Miss-Alignment").getDouble("z-Axis Angle [deg]") / 180.0 * 3.14159265;
            return Engine(burn_duration, thrust, mdot_p, area_exit, mis_alignment_y, mis_alignment_z);
        } else {
            return Engine(burn_duration, thrust, mdot_p, area_exit);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x370, %rsp            # imm = 0x370
movq %rdi, %rbx
leaq 0x2c0(%rsp), %r14
movq %r14, %rdi
movq %rdx, %rsi
callq 0x5460
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x660c
leaq 0x2c0(%rsp), %rdi
callq 0x5688
leaq 0x1359a(%rip), %rsi     # 0x351a0
leaq 0x2a0(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x72de
leaq 0x38(%rsp), %rdi
leaq 0x2a0(%rsp), %rsi
callq 0x6738
movsd %xmm0, 0x18(%rsp)
leaq 0x2a0(%rsp), %rdi
callq 0x5688
leaq 0x13576(%rip), %rsi     # 0x351ba
leaq 0x280(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x72de
leaq 0x38(%rsp), %rdi
leaq 0x280(%rsp), %rsi
callq 0x6748
movl %eax, %ebp
leaq 0x280(%rsp), %rdi
callq 0x5688
leaq 0x13559(%rip), %rsi     # 0x351d7
leaq 0x260(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x72de
leaq 0x38(%rsp), %rdi
leaq 0x260(%rsp), %rsi
callq 0x6748
movl %eax, %r14d
movsd 0x18(%rsp), %xmm0
divsd 0x1056d(%rip), %xmm0    # 0x32220
mulsd %xmm0, %xmm0
mulsd 0x105e1(%rip), %xmm0    # 0x322a0
mulsd 0xc341(%rip), %xmm0     # 0x2e008
movsd %xmm0, 0x18(%rsp)
leaq 0x260(%rsp), %rdi
callq 0x5688
testb %r14b, %r14b
je 0x21f24
leaq 0x134f4(%rip), %rsi     # 0x351de
leaq 0x240(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x72de
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x240(%rsp), %rdx
callq 0x6758
leaq 0x240(%rsp), %rdi
callq 0x5688
leaq 0x134c3(%rip), %rsi     # 0x351ea
leaq 0x200(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x72de
leaq 0x220(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0x200(%rsp), %rdx
callq 0x6708
leaq 0x20(%rsp), %rdi
leaq 0x220(%rsp), %rsi
pushq $0x1
popq %rdx
callq 0x5b24
leaq 0x220(%rsp), %rdi
callq 0x5688
leaq 0x200(%rsp), %rdi
callq 0x5688
testb %bpl, %bpl
je 0x2218b
leaq 0x13473(%rip), %rsi     # 0x35205
leaq 0x1e0(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x72de
leaq 0x48(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x1e0(%rsp), %rdx
callq 0x6758
leaq 0x13459(%rip), %rsi     # 0x3521b
leaq 0x1c0(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x72de
leaq 0x48(%rsp), %rdi
leaq 0x1c0(%rsp), %rsi
callq 0x6738
movsd %xmm0, 0x60(%rsp)
leaq 0x1c0(%rsp), %rdi
callq 0x5688
leaq 0x48(%rsp), %rdi
callq 0x68a0
leaq 0x1e0(%rsp), %rdi
callq 0x5688
leaq 0x133ee(%rip), %rsi     # 0x35205
leaq 0x1a0(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x72de
leaq 0x48(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x1a0(%rsp), %rdx
callq 0x6758
leaq 0x133e7(%rip), %rsi     # 0x3522e
leaq 0x180(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x72de
leaq 0x48(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0x6738
movsd %xmm0, 0x58(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x5688
leaq 0x48(%rsp), %rdi
callq 0x68a0
leaq 0x1a0(%rsp), %rdi
callq 0x5688
movq 0x20(%rsp), %rsi
leaq 0x358(%rsp), %r14
movq %r14, %rdi
callq 0x614a
movq 0x20(%rsp), %rsi
addq $0x18, %rsi
leaq 0x340(%rsp), %r15
movq %r15, %rdi
callq 0x614a
movq 0x20(%rsp), %rsi
addq $0x30, %rsi
leaq 0x328(%rsp), %r12
movq %r12, %rdi
callq 0x614a
movsd 0x60(%rsp), %xmm1
divsd 0xc126(%rip), %xmm1     # 0x2e010
mulsd 0xc116(%rip), %xmm1     # 0x2e008
movsd 0x58(%rsp), %xmm2
divsd 0xc110(%rip), %xmm2     # 0x2e010
mulsd 0xc100(%rip), %xmm2     # 0x2e008
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
movsd 0x18(%rsp), %xmm0
callq 0x16bb6
jmp 0x221e9
leaq 0x13316(%rip), %rsi     # 0x35241
leaq 0x160(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x72de
leaq 0x20(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x160(%rsp), %rdx
callq 0x6758
leaq 0x160(%rsp), %rdi
callq 0x5688
leaq 0x132e9(%rip), %rsi     # 0x35251
leaq 0x140(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x72de
leaq 0x20(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x6738
movsd %xmm0, 0x60(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x5688
leaq 0x132c0(%rip), %rsi     # 0x35266
leaq 0x120(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x72de
leaq 0x20(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x6738
movsd %xmm0, 0x58(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x5688
leaq 0x132a3(%rip), %rsi     # 0x35287
leaq 0x100(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x72de
leaq 0x20(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x6738
movsd %xmm0, 0x70(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x5688
testb %bpl, %bpl
je 0x22212
leaq 0x131da(%rip), %rsi     # 0x35205
leaq 0xe0(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x72de
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
callq 0x6758
leaq 0x131c0(%rip), %rsi     # 0x3521b
leaq 0xc0(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x72de
leaq 0x8(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x6738
movsd %xmm0, 0x68(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x5688
leaq 0x8(%rsp), %rdi
callq 0x68a0
leaq 0xe0(%rsp), %rdi
callq 0x5688
leaq 0x13155(%rip), %rsi     # 0x35205
leaq 0xa0(%rsp), %rdi
leaq 0x48(%rsp), %rdx
callq 0x72de
leaq 0x8(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
callq 0x6758
leaq 0x1314e(%rip), %rsi     # 0x3522e
leaq 0x80(%rsp), %rdi
leaq 0x6(%rsp), %rdx
callq 0x72de
leaq 0x8(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x6738
movsd 0x68(%rsp), %xmm1
divsd 0xbefe(%rip), %xmm1     # 0x2e010
mulsd 0xbeee(%rip), %xmm1     # 0x2e008
movsd %xmm1, 0x68(%rsp)
divsd 0xbee8(%rip), %xmm0     # 0x2e010
mulsd 0xbed8(%rip), %xmm0     # 0x2e008
movsd %xmm0, 0x78(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x5688
leaq 0x8(%rsp), %rdi
callq 0x68a0
leaq 0xa0(%rsp), %rdi
callq 0x5688
movq %rbx, %rdi
movsd 0x70(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x58(%rsp), %xmm2
movsd 0x18(%rsp), %xmm3
movsd 0x68(%rsp), %xmm4
movsd 0x78(%rsp), %xmm5
callq 0x167d2
jmp 0x22232
movq 0x20(%rsp), %rsi
leaq 0x310(%rsp), %r14
movq %r14, %rdi
callq 0x614a
movq 0x20(%rsp), %rsi
addq $0x18, %rsi
leaq 0x2f8(%rsp), %r15
movq %r15, %rdi
callq 0x614a
movq 0x20(%rsp), %rsi
addq $0x30, %rsi
leaq 0x2e0(%rsp), %r12
movq %r12, %rdi
callq 0x614a
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r12, %rcx
movsd 0x18(%rsp), %xmm0
callq 0x16922
movq %r12, %rdi
callq 0x6002
movq %r15, %rdi
callq 0x6002
movq %r14, %rdi
callq 0x6002
leaq 0x20(%rsp), %rdi
callq 0x5e36
leaq 0x8(%rsp), %rdi
jmp 0x22237
movq %rbx, %rdi
movsd 0x70(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
movsd 0x58(%rsp), %xmm2
movsd 0x18(%rsp), %xmm3
callq 0x166a6
leaq 0x20(%rsp), %rdi
callq 0x68a0
leaq 0x38(%rsp), %rdi
callq 0x68a0
movq %rbx, %rax
addq $0x370, %rsp            # imm = 0x370
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x22406
movq %rax, %rbx
leaq 0x328(%rsp), %rdi
callq 0x6002
jmp 0x22285
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x5688
jmp 0x22297
movq %rax, %rbx
leaq 0x340(%rsp), %rdi
callq 0x6002
jmp 0x222a6
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x68a0
jmp 0x222b6
movq %rax, %rbx
leaq 0x358(%rsp), %rdi
jmp 0x22388
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
jmp 0x223ed
jmp 0x223a3
jmp 0x22406
movq %rax, %rbx
leaq 0x180(%rsp), %rdi
callq 0x5688
jmp 0x222f4
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x5688
jmp 0x22303
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x68a0
jmp 0x22312
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x68a0
jmp 0x2231f
movq %rax, %rbx
leaq 0x1a0(%rsp), %rdi
jmp 0x2239a
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
jmp 0x223ed
jmp 0x223a3
jmp 0x22406
movq %rax, %rbx
leaq 0x2e0(%rsp), %rdi
callq 0x6002
jmp 0x2235f
jmp 0x22406
movq %rax, %rbx
leaq 0x1c0(%rsp), %rdi
callq 0x5688
jmp 0x22371
movq %rax, %rbx
leaq 0x2f8(%rsp), %rdi
callq 0x6002
jmp 0x22380
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x68a0
jmp 0x22392
movq %rax, %rbx
leaq 0x310(%rsp), %rdi
callq 0x6002
jmp 0x223a6
movq %rax, %rbx
leaq 0x1e0(%rsp), %rdi
callq 0x5688
jmp 0x223a6
jmp 0x223a3
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x5e36
jmp 0x22413
movq %rax, %rbx
leaq 0x100(%rsp), %rdi
jmp 0x223ed
jmp 0x22406
movq %rax, %rbx
leaq 0x120(%rsp), %rdi
jmp 0x223ed
jmp 0x22406
movq %rax, %rbx
leaq 0x220(%rsp), %rdi
callq 0x5688
jmp 0x223f7
movq %rax, %rbx
leaq 0x140(%rsp), %rdi
callq 0x5688
jmp 0x22409
movq %rax, %rbx
leaq 0x200(%rsp), %rdi
callq 0x5688
jmp 0x22413
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
jmp 0x22418
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x68a0
jmp 0x22470
movq %rax, %rbx
leaq 0x160(%rsp), %rdi
jmp 0x22466
movq %rax, %rbx
leaq 0x240(%rsp), %rdi
jmp 0x22466
jmp 0x2246d
jmp 0x2246d
movq %rax, %rbx
leaq 0x260(%rsp), %rdi
jmp 0x22466
jmp 0x2246d
movq %rax, %rbx
leaq 0x280(%rsp), %rdi
jmp 0x22466
jmp 0x2246d
movq %rax, %rbx
leaq 0x2a0(%rsp), %rdi
callq 0x5688
jmp 0x22470
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x68a0
movq %rbx, %rdi
callq 0x55b0
movq %rax, %rbx
leaq 0x2c0(%rsp), %rdi
callq 0x5688
jmp 0x2247a