// File: 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
movq %rsp, %rbp
subq $0x400, %rsp            # imm = 0x400
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x1, -0x11(%rbp)
movb $0x0, -0x12(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x8fc00
movl $0x1, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x8f70e
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x298(%rbp)
leaq -0x59(%rbp), %rdi
movq %rdi, -0x290(%rbp)
callq 0x6770
movq -0x298(%rbp), %rsi
movq -0x290(%rbp), %rdx
leaq -0x58(%rbp), %rdi
callq 0xd1d0
jmp 0x8f249
leaq -0x59(%rbp), %rdi
callq 0x6490
leaq 0x1ddf(%rip), %rsi      # 0x91038
leaq -0x58(%rbp), %rdi
movq $-0x1, %rdx
callq 0x6710
movq %rax, -0x2a0(%rbp)
jmp 0x8f272
movq -0x2a0(%rbp), %rax
cmpq $-0x1, %rax
je 0x8f2ce
leaq -0x30(%rbp), %rdi
leaq -0x34(%rbp), %rsi
callq 0x8fc20
jmp 0x8f28e
movl $0x4, -0x70(%rbp)
jmp 0x8f6d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x59(%rbp), %rdi
callq 0x6490
jmp 0x8fbe4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x6898
jmp 0x8fbe4
leaq -0x58(%rbp), %rdi
leaq 0x17b84(%rip), %rsi     # 0xa6e5d
xorl %eax, %eax
movl %eax, %edx
callq 0x6860
cmpq $-0x1, %rax
je 0x8f4d3
leaq 0x17b6d(%rip), %rsi     # 0xa6e60
leaq -0x58(%rbp), %rdi
callq 0x28140
movb %al, -0x2a1(%rbp)
jmp 0x8f304
movb -0x2a1(%rbp), %al
testb $0x1, %al
jne 0x8f313
jmp 0x8f3ce
movq 0x54ca6(%rip), %rdi     # 0xe3fc0
leaq 0x17b46(%rip), %rsi     # 0xa6e67
callq 0x6420
movq %rax, -0x2b0(%rbp)
jmp 0x8f32f
movq -0x2b0(%rbp), %rdi
leaq 0x55733(%rip), %rsi     # 0xe4a70
callq 0x6400
movq %rax, -0x2b8(%rbp)
jmp 0x8f34b
movq -0x2b8(%rbp), %rdi
leaq 0x17b1a(%rip), %rsi     # 0xa6e73
callq 0x6420
movq %rax, -0x2c0(%rbp)
jmp 0x8f367
movq -0x2c0(%rbp), %rdi
leaq 0x5571b(%rip), %rsi     # 0xe4a90
callq 0x6400
movq %rax, -0x2c8(%rbp)
jmp 0x8f383
movq -0x2c8(%rbp), %rdi
leaq 0x16f5f(%rip), %rsi     # 0xa62f0
callq 0x6420
movq %rax, -0x2d0(%rbp)
jmp 0x8f39f
movq -0x2d0(%rbp), %rdi
movq 0x54bcb(%rip), %rsi     # 0xe3f78
callq 0x6470
jmp 0x8f3b4
callq 0x70f0
jmp 0x8f3bb
movl $0x0, -0x4(%rbp)
movl $0x1, -0x70(%rbp)
jmp 0x8f6d6
leaq 0x17aaa(%rip), %rsi     # 0xa6e7f
leaq -0x58(%rbp), %rdi
callq 0x28140
movb %al, -0x2d1(%rbp)
jmp 0x8f3e6
movb -0x2d1(%rbp), %al
testb $0x1, %al
jne 0x8f3f5
jmp 0x8f4a9
movq 0x54bc4(%rip), %rdi     # 0xe3fc0
leaq 0x17a86(%rip), %rsi     # 0xa6e89
callq 0x6420
movq %rax, -0x2e0(%rbp)
jmp 0x8f411
movq -0x2e0(%rbp), %rdi
leaq 0x55651(%rip), %rsi     # 0xe4a70
callq 0x6400
movq %rax, -0x2e8(%rbp)
jmp 0x8f42d
movq -0x2e8(%rbp), %rdi
leaq 0x17a38(%rip), %rsi     # 0xa6e73
callq 0x6420
movq %rax, -0x2f0(%rbp)
jmp 0x8f449
movq -0x2f0(%rbp), %rdi
leaq 0x55639(%rip), %rsi     # 0xe4a90
callq 0x6400
movq %rax, -0x2f8(%rbp)
jmp 0x8f465
movq -0x2f8(%rbp), %rdi
leaq 0x16e7d(%rip), %rsi     # 0xa62f0
callq 0x6420
movq %rax, -0x300(%rbp)
jmp 0x8f481
movq -0x300(%rbp), %rdi
movq 0x54ae9(%rip), %rsi     # 0xe3f78
callq 0x6470
jmp 0x8f496
movl $0x0, -0x4(%rbp)
movl $0x1, -0x70(%rbp)
jmp 0x8f6d6
leaq 0x179ec(%rip), %rsi     # 0xa6e9c
leaq -0x58(%rbp), %rdi
callq 0x28140
movb %al, -0x301(%rbp)
jmp 0x8f4c1
movb -0x301(%rbp), %al
testb $0x1, %al
jne 0x8f4cd
jmp 0x8f4d1
movb $0x0, -0x11(%rbp)
jmp 0x8f4d3
leaq -0x58(%rbp), %rdi
leaq 0x17980(%rip), %rsi     # 0xa6e5e
xorl %eax, %eax
movl %eax, %edx
callq 0x6860
cmpq $-0x1, %rax
je 0x8f6cf
leaq -0x58(%rbp), %rdi
movl $0x68, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x6580
cmpq $-0x1, %rax
je 0x8f5c8
movq 0x54aac(%rip), %rdi     # 0xe3fc0
leaq 0x1794c(%rip), %rsi     # 0xa6e67
callq 0x6420
movq %rax, -0x310(%rbp)
jmp 0x8f529
movq -0x310(%rbp), %rdi
leaq 0x55539(%rip), %rsi     # 0xe4a70
callq 0x6400
movq %rax, -0x318(%rbp)
jmp 0x8f545
movq -0x318(%rbp), %rdi
leaq 0x17920(%rip), %rsi     # 0xa6e73
callq 0x6420
movq %rax, -0x320(%rbp)
jmp 0x8f561
movq -0x320(%rbp), %rdi
leaq 0x55521(%rip), %rsi     # 0xe4a90
callq 0x6400
movq %rax, -0x328(%rbp)
jmp 0x8f57d
movq -0x328(%rbp), %rdi
leaq 0x16d65(%rip), %rsi     # 0xa62f0
callq 0x6420
movq %rax, -0x330(%rbp)
jmp 0x8f599
movq -0x330(%rbp), %rdi
movq 0x549d1(%rip), %rsi     # 0xe3f78
callq 0x6470
jmp 0x8f5ae
callq 0x70f0
jmp 0x8f5b5
movl $0x0, -0x4(%rbp)
movl $0x1, -0x70(%rbp)
jmp 0x8f6d6
leaq -0x58(%rbp), %rdi
movl $0x76, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x6580
cmpq $-0x1, %rax
je 0x8f695
movq 0x549d5(%rip), %rdi     # 0xe3fc0
leaq 0x17897(%rip), %rsi     # 0xa6e89
callq 0x6420
movq %rax, -0x338(%rbp)
jmp 0x8f600
movq -0x338(%rbp), %rdi
leaq 0x55462(%rip), %rsi     # 0xe4a70
callq 0x6400
movq %rax, -0x340(%rbp)
jmp 0x8f61c
movq -0x340(%rbp), %rdi
leaq 0x17849(%rip), %rsi     # 0xa6e73
callq 0x6420
movq %rax, -0x348(%rbp)
jmp 0x8f638
movq -0x348(%rbp), %rdi
leaq 0x5544a(%rip), %rsi     # 0xe4a90
callq 0x6400
movq %rax, -0x350(%rbp)
jmp 0x8f654
movq -0x350(%rbp), %rdi
leaq 0x16c8e(%rip), %rsi     # 0xa62f0
callq 0x6420
movq %rax, -0x358(%rbp)
jmp 0x8f670
movq -0x358(%rbp), %rdi
movq 0x548fa(%rip), %rsi     # 0xe3f78
callq 0x6470
jmp 0x8f685
movl $0x0, -0x4(%rbp)
movl $0x1, -0x70(%rbp)
jmp 0x8f6d6
leaq -0x58(%rbp), %rdi
movl $0x71, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x6580
cmpq $-0x1, %rax
je 0x8f6b1
movb $0x0, -0x11(%rbp)
leaq -0x58(%rbp), %rdi
movl $0x6d, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x6580
cmpq $-0x1, %rax
je 0x8f6cd
movb $0x1, -0x12(%rbp)
jmp 0x8f6cf
movl $0x0, -0x70(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x6898
movl -0x70(%rbp), %eax
movl %eax, -0x35c(%rbp)
testl %eax, %eax
je 0x8f6fe
jmp 0x8f6ee
movl -0x35c(%rbp), %eax
subl $0x4, %eax
je 0x8f700
jmp 0x8fbcf
jmp 0x8f700
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x8f201
leaq -0x30(%rbp), %rdi
callq 0x8fc90
cmpq $0x0, %rax
jne 0x8f756
movq 0x548cc(%rip), %rdi     # 0xe3ff0
leaq 0x17779(%rip), %rsi     # 0xa6ea4
callq 0x6420
jmp 0x8f732
movl $0x1, -0x4(%rbp)
movl $0x1, -0x70(%rbp)
jmp 0x8fbcf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x8fbe4
leaq -0x30(%rbp), %rdi
callq 0x8fc90
cmpq $0x1, %rax
je 0x8f78d
movq 0x54884(%rip), %rdi     # 0xe3ff0
leaq 0x17754(%rip), %rsi     # 0xa6ec7
callq 0x6420
jmp 0x8f77a
movl $0x1, -0x4(%rbp)
movl $0x1, -0x70(%rbp)
jmp 0x8fbcf
testb $0x1, -0x11(%rbp)
je 0x8f7fe
movq 0x54826(%rip), %rdi     # 0xe3fc0
leaq 0x176c6(%rip), %rsi     # 0xa6e67
callq 0x6420
movq %rax, -0x368(%rbp)
jmp 0x8f7af
movq -0x368(%rbp), %rdi
leaq 0x552b3(%rip), %rsi     # 0xe4a70
callq 0x6400
movq %rax, -0x370(%rbp)
jmp 0x8f7cb
movq -0x370(%rbp), %rdi
leaq 0x17712(%rip), %rsi     # 0xa6eeb
callq 0x6420
movq %rax, -0x378(%rbp)
jmp 0x8f7e7
movq -0x378(%rbp), %rdi
movq 0x54783(%rip), %rsi     # 0xe3f78
callq 0x6470
jmp 0x8f7fc
jmp 0x8f7fe
callq 0x6090
movq %rax, -0x78(%rbp)
testb $0x1, -0x11(%rbp)
je 0x8f840
movq 0x547ac(%rip), %rdi     # 0xe3fc0
leaq 0x176da(%rip), %rsi     # 0xa6ef5
callq 0x6420
movq %rax, -0x380(%rbp)
jmp 0x8f829
movq -0x380(%rbp), %rdi
movq 0x54741(%rip), %rsi     # 0xe3f78
callq 0x6470
jmp 0x8f83e
jmp 0x8f840
movq -0x10(%rbp), %rax
movq %rax, -0x398(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x8fcb0
movq %rax, %rcx
movq -0x398(%rbp), %rax
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x390(%rbp)
leaq -0x261(%rbp), %rdi
movq %rdi, -0x388(%rbp)
callq 0x6770
movq -0x390(%rbp), %rsi
movq -0x388(%rbp), %rdx
leaq -0x260(%rbp), %rdi
callq 0xd1d0
jmp 0x8f89f
leaq -0x240(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x856b0
jmp 0x8f8b4
leaq -0x260(%rbp), %rdi
callq 0x6898
leaq -0x261(%rbp), %rdi
callq 0x6490
leaq -0x240(%rbp), %rdi
callq 0x86b60
jmp 0x8f8da
testb $0x1, -0x11(%rbp)
je 0x8f96b
movq 0x546d5(%rip), %rdi     # 0xe3fc0
leaq 0x17611(%rip), %rsi     # 0xa6f03
callq 0x6420
movq %rax, -0x3a0(%rbp)
jmp 0x8f900
movq -0x3a0(%rbp), %rdi
movq 0x5466a(%rip), %rsi     # 0xe3f78
callq 0x6470
jmp 0x8f915
jmp 0x8f96b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x8f93d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x260(%rbp), %rdi
callq 0x6898
leaq -0x261(%rbp), %rdi
callq 0x6490
jmp 0x8fbe4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x8fd70
jmp 0x8fbe4
testb $0x1, -0x11(%rbp)
je 0x8f9a4
movq 0x54648(%rip), %rdi     # 0xe3fc0
leaq 0x17596(%rip), %rsi     # 0xa6f15
callq 0x6420
movq %rax, -0x3a8(%rbp)
jmp 0x8f98d
movq -0x3a8(%rbp), %rdi
movq 0x545dd(%rip), %rsi     # 0xe3f78
callq 0x6470
jmp 0x8f9a2
jmp 0x8f9a4
movzbl -0x12(%rbp), %esi
andl $0x1, %esi
leaq -0x240(%rbp), %rdi
callq 0x87200
jmp 0x8f9b9
testb $0x1, -0x11(%rbp)
je 0x8f9f2
movq 0x545fa(%rip), %rdi     # 0xe3fc0
leaq 0x1755a(%rip), %rsi     # 0xa6f27
callq 0x6420
movq %rax, -0x3b0(%rbp)
jmp 0x8f9db
movq -0x3b0(%rbp), %rdi
movq 0x5458f(%rip), %rsi     # 0xe3f78
callq 0x6470
jmp 0x8f9f0
jmp 0x8f9f2
callq 0x6090
movq %rax, -0x270(%rbp)
leaq -0x270(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x8fd00
movq %rax, -0x3b8(%rbp)
jmp 0x8fa17
movq -0x3b8(%rbp), %rax
movq %rax, -0x288(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x8fcd0
movq %rax, -0x3c0(%rbp)
jmp 0x8fa3a
movq -0x3c0(%rbp), %rax
movq %rax, -0x280(%rbp)
leaq -0x280(%rbp), %rdi
callq 0x8fd50
movq %rax, -0x3c8(%rbp)
jmp 0x8fa5d
movq -0x3c8(%rbp), %rax
movq %rax, -0x278(%rbp)
testb $0x1, -0x11(%rbp)
je 0x8fb7c
cmpq $0x2710, -0x278(%rbp) # imm = 0x2710
jle 0x8fb0f
movq 0x54533(%rip), %rdi     # 0xe3fc0
leaq 0x174a5(%rip), %rsi     # 0xa6f39
callq 0x6420
movq %rax, -0x3d0(%rbp)
jmp 0x8faa2
movq -0x3d0(%rbp), %rdi
movq -0x278(%rbp), %rax
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
imulq %rcx
movq %rdx, %rsi
movq %rsi, %rdx
shrq $0x3f, %rdx
sarq $0x7, %rsi
addq %rdx, %rsi
callq 0x67c0
movq %rax, -0x3d8(%rbp)
jmp 0x8fadc
movq -0x3d8(%rbp), %rdi
leaq 0x1745e(%rip), %rsi     # 0xa6f48
callq 0x6420
movq %rax, -0x3e0(%rbp)
jmp 0x8faf8
movq -0x3e0(%rbp), %rdi
movq 0x54472(%rip), %rsi     # 0xe3f78
callq 0x6470
jmp 0x8fb0d
jmp 0x8fb7a
movq 0x544aa(%rip), %rdi     # 0xe3fc0
leaq 0x1741c(%rip), %rsi     # 0xa6f39
callq 0x6420
movq %rax, -0x3e8(%rbp)
jmp 0x8fb2b
movq -0x3e8(%rbp), %rdi
movq -0x278(%rbp), %rsi
callq 0x67c0
movq %rax, -0x3f0(%rbp)
jmp 0x8fb47
movq -0x3f0(%rbp), %rdi
leaq 0x173f8(%rip), %rsi     # 0xa6f4d
callq 0x6420
movq %rax, -0x3f8(%rbp)
jmp 0x8fb63
movq -0x3f8(%rbp), %rdi
movq 0x54407(%rip), %rsi     # 0xe3f78
callq 0x6470
jmp 0x8fb78
jmp 0x8fb7a
jmp 0x8fb7c
testb $0x1, -0x11(%rbp)
je 0x8fbb5
movq 0x54437(%rip), %rdi     # 0xe3fc0
leaq 0x173c3(%rip), %rsi     # 0xa6f53
callq 0x6420
movq %rax, -0x400(%rbp)
jmp 0x8fb9e
movq -0x400(%rbp), %rdi
movq 0x543cc(%rip), %rsi     # 0xe3f78
callq 0x6470
jmp 0x8fbb3
jmp 0x8fbb5
movl $0x0, -0x4(%rbp)
movl $0x1, -0x70(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x8fd70
leaq -0x30(%rbp), %rdi
callq 0x8fdb0
movl -0x4(%rbp), %eax
addq $0x400, %rsp            # imm = 0x400
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x8fdb0
movq -0x68(%rbp), %rdi
callq 0x6760
nopw %cs:(%rax,%rax)