// File: /workspace/github_cpp_makefile_star2_O2/sus304[P]ForRocket/src/ForRocket.cpp
// Function: main
int main(int argc, char* argv[]) {
    // arg parse
    //////////////////////////////////////////////
    bool enable_msg = true;
    bool enable_minimum_damp = false;

    std::vector<int> json_index;
    for (int i=1; i < argc; ++i) {
        std::string str = argv[i];
        if (str.rfind(".json") != std::string::npos) {
            json_index.push_back(i);
            continue;
        }
        if (str.find("--") != std::string::npos) {
            if (str == "--help") {
                std::cout << "ForRocket v" << program_ver << " (release: " << release_date << ")"  << std::endl;
                forrocket::DisplayHelp();
                return 0;
            }
            if (str == "--version") {
                std::cout << "ForRocket version:" << program_ver << " (release: " << release_date << ")" << std::endl;
                return 0;
            }
            if (str == "--quite") {
                enable_msg = false;
            }
        }
        if (str.find("-") != std::string::npos) {
            if (str.find('h') != std::string::npos) {
                std::cout << "ForRocket v" << program_ver << " (release: " << release_date << ")"  << std::endl;
                forrocket::DisplayHelp();
                return 0;
            }
            if (str.find('v') != std::string::npos) {
                std::cout << "ForRocket version:" << program_ver << " (release: " << release_date << ")"  << std::endl;
                return 0;
            }
            if (str.find('q') != std::string::npos) {
                enable_msg = false;
            }
            if (str.find('m') != std::string::npos) {
                enable_minimum_damp = true;
            }
        }
    }
    
    if (json_index.size() == 0) {
        std::cerr << "Error! missing argument json file.";
        return 1;
    }
    if (json_index.size() != 1) {
        std::cerr << "Error! too many argument json file.";
        return 1;
    }

    if (enable_msg) std::cout << "ForRocket v" << program_ver << " Contact." << std::endl;
    
    // Timer Start
    auto start = std::chrono::system_clock::now();

    // Solver Run
    //////////////////////////////////////////////
    if (enable_msg) std::cout << "Solver Start." << std::endl;
    forrocket::TrajectorySolver solver(argv[json_index[0]]);
    solver.Solve();
    if (enable_msg) std::cout << "Solver Terminate." << std::endl;
    if (enable_msg) std::cout << "Export Result ..." << std::endl;
    solver.DumpResult(enable_minimum_damp);
    if (enable_msg) std::cout << "Export Compleate." << std::endl;

    // Timer Stop
    auto end = std::chrono::system_clock::now();
    auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
    if (enable_msg) {
        if (msec > 10000) {
            std::cout << "Running Time: " << msec / 1000 << " sec" << std::endl;
        } else {
            std::cout << "Running Time: " << msec << " msec" << std::endl;
        }
    }

    if (enable_msg) std::cout << "Good Day." << std::endl;
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %rsi, %rbx
movl %edi, %ebp
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movb $0x1, %r12b
pushq $0x1
popq %rax
movq $0x0, 0x8(%rsp)
leaq 0x50(%rsp), %r15
leaq 0x109b(%rip), %r13      # 0x2e038
pushq $-0x1
popq %r14
movl %eax, (%rsp)
cmpl %ebp, %eax
jge 0x2d0cc
cltq
movq (%rbx,%rax,8), %rsi
movq %r15, %rdi
leaq 0x7(%rsp), %rdx
callq 0x72de
movq %r15, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x5570
cmpq $-0x1, %rax
je 0x2cfe5
leaq 0x10(%rsp), %rdi
movq %rsp, %rsi
callq 0x2d418
jmp 0x2d0ba
movq %r15, %rdi
leaq 0x8d71(%rip), %rsi      # 0x35d60
xorl %edx, %edx
callq 0x5660
cmpq $-0x1, %rax
je 0x2d03e
movq %r15, %rdi
leaq 0x8d5d(%rip), %rsi      # 0x35d63
callq 0xfe34
testb %al, %al
jne 0x2d0f9
movq %r15, %rdi
leaq 0x8d65(%rip), %rsi      # 0x35d82
callq 0xfe34
testb %al, %al
jne 0x2d157
movq %r15, %rdi
leaq 0x8d6b(%rip), %rsi      # 0x35d9f
callq 0xfe34
xorb $0x1, %al
andb %al, %r12b
movq %r15, %rdi
leaq 0x8d19(%rip), %rsi      # 0x35d61
xorl %edx, %edx
callq 0x5660
cmpq $-0x1, %rax
je 0x2d0ba
movq %r15, %rdi
pushq $0x68
popq %rsi
xorl %edx, %edx
callq 0x5410
cmpq $-0x1, %rax
jne 0x2d0f9
movq %r15, %rdi
pushq $0x76
popq %rsi
xorl %edx, %edx
callq 0x5410
cmpq $-0x1, %rax
jne 0x2d157
movq %r15, %rdi
pushq $0x71
popq %rsi
xorl %edx, %edx
callq 0x5410
cmpq $-0x1, %rax
sete %al
andb %al, %r12b
movq %r15, %rdi
pushq $0x6d
popq %rsi
xorl %edx, %edx
callq 0x5410
cmpq $-0x1, %rax
setne %al
movq 0x8(%rsp), %rcx
orb %al, %cl
movq %rcx, 0x8(%rsp)
movq %r15, %rdi
callq 0x5688
movl (%rsp), %eax
incl %eax
jmp 0x2cfa1
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
sarq $0x2, %rax
cmpq $0x1, %rax
je 0x2d1bd
testq %rax, %rax
jne 0x2d221
leaq 0x8cb3(%rip), %rsi      # 0x35da7
jmp 0x2d228
movq 0x1bec0(%rip), %rdi     # 0x48fc0
leaq 0x8c63(%rip), %rsi      # 0x35d6a
callq 0x5320
leaq 0x1c715(%rip), %rsi     # 0x49828
movq %rax, %rdi
callq 0x5300
leaq 0x8c54(%rip), %rsi      # 0x35d76
movq %rax, %rdi
callq 0x5320
leaq 0x1c717(%rip), %rsi     # 0x49848
movq %rax, %rdi
callq 0x5300
leaq 0x88bc(%rip), %rsi      # 0x359fc
movq %rax, %rdi
callq 0x5320
movq %rax, %rdi
callq 0x51a0
callq 0x5a90
jmp 0x2d1ae
movq 0x1be62(%rip), %rdi     # 0x48fc0
leaq 0x8c27(%rip), %rsi      # 0x35d8c
callq 0x5320
leaq 0x1c6b7(%rip), %rsi     # 0x49828
movq %rax, %rdi
callq 0x5300
leaq 0x8bf6(%rip), %rsi      # 0x35d76
movq %rax, %rdi
callq 0x5320
leaq 0x1c6b9(%rip), %rsi     # 0x49848
movq %rax, %rdi
callq 0x5300
leaq 0x885e(%rip), %rsi      # 0x359fc
movq %rax, %rdi
callq 0x5320
movq %rax, %rdi
callq 0x51a0
leaq 0x50(%rsp), %rdi
callq 0x5688
jmp 0x2d3b1
testb $0x1, %r12b
je 0x2d23c
movq 0x1bdf6(%rip), %rdi     # 0x48fc0
leaq 0x8b99(%rip), %rsi      # 0x35d6a
callq 0x5320
leaq 0x1c64b(%rip), %rsi     # 0x49828
movq %rax, %rdi
callq 0x5300
leaq 0x8c02(%rip), %rsi      # 0x35dee
movq %rax, %rdi
callq 0x5320
movq %rax, %rdi
callq 0x51a0
callq 0x5060
movq %rax, %r14
movq 0x1bdb5(%rip), %rdi     # 0x48fc0
leaq 0x8be6(%rip), %rsi      # 0x35df8
callq 0x5320
movq %rax, %rdi
callq 0x51a0
jmp 0x2d244
leaq 0x8ba2(%rip), %rsi      # 0x35dca
movq 0x1bdc1(%rip), %rdi     # 0x48ff0
callq 0x5320
pushq $0x1
popq %rbx
jmp 0x2d3b3
callq 0x5060
movq %rax, %r14
movq 0x10(%rsp), %rax
movslq (%rax), %rax
movq (%rbx,%rax,8), %rsi
leaq 0x30(%rsp), %rdi
movq %rsp, %rdx
callq 0x72de
leaq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x29c64
leaq 0x30(%rsp), %rdi
callq 0x5688
leaq 0x50(%rsp), %rdi
callq 0x2a9a8
testb $0x1, %r12b
je 0x2d2bc
movq 0x1bd33(%rip), %rdi     # 0x48fc0
leaq 0x8b72(%rip), %rsi      # 0x35e06
callq 0x5320
movq %rax, %rdi
callq 0x51a0
movq 0x1bd18(%rip), %rdi     # 0x48fc0
leaq 0x8b69(%rip), %rsi      # 0x35e18
callq 0x5320
movq %rax, %rdi
callq 0x51a0
movzbl 0x8(%rsp), %esi
andl $0x1, %esi
leaq 0x50(%rsp), %rdi
callq 0x2abc4
testb $0x1, %r12b
je 0x2d2ef
movq 0x1bce5(%rip), %rdi     # 0x48fc0
leaq 0x8b48(%rip), %rsi      # 0x35e2a
callq 0x5320
movq %rax, %rdi
callq 0x51a0
callq 0x5060
movq %rax, %rcx
subq %r14, %rcx
movl $0xf4240, %esi          # imm = 0xF4240
movq %rcx, %rax
cqto
idivq %rsi
testb $0x1, %r12b
je 0x2d3a7
movq %rax, %rbx
movabsq $0x2541b2640, %rax      # imm = 0x2541B2640
cmpq %rax, %rcx
jl 0x2d357
movq 0x1bc96(%rip), %rdi     # 0x48fc0
leaq 0x8b0b(%rip), %rsi      # 0x35e3c
callq 0x5320
movq %rax, %rdi
movl $0x3e8, %ecx            # imm = 0x3E8
movq %rbx, %rax
xorl %edx, %edx
divq %rcx
movq %rax, %rsi
callq 0x5310
leaq 0x8af6(%rip), %rsi      # 0x35e4b
jmp 0x2d37c
movq 0x1bc62(%rip), %rdi     # 0x48fc0
leaq 0x8ad7(%rip), %rsi      # 0x35e3c
callq 0x5320
movq %rax, %rdi
movq %rbx, %rsi
callq 0x5310
leaq 0x8ad4(%rip), %rsi      # 0x35e50
movq %rax, %rdi
callq 0x5320
movq %rax, %rdi
callq 0x51a0
movq 0x1bc2d(%rip), %rdi     # 0x48fc0
leaq 0x8abc(%rip), %rsi      # 0x35e56
callq 0x5320
movq %rax, %rdi
callq 0x51a0
leaq 0x50(%rsp), %rdi
callq 0x2d436
xorl %ebx, %ebx
leaq 0x10(%rsp), %rdi
callq 0x2d458
movl %ebx, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2d3f4
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
jmp 0x2d401
jmp 0x2d3f4
jmp 0x2d3e3
jmp 0x2d3f4
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2d436
jmp 0x2d406
jmp 0x2d3f9
movq %rax, %rbx
jmp 0x2d406
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x5688
leaq 0x10(%rsp), %rdi
callq 0x2d458
movq %rbx, %rdi
callq 0x55b0