// File: /workspace/github_cpp_makefile_star2_O3/jkom-cloud[P]mmseg/src/main.cpp
// Function: main
int main(int argc, const char *argv[]) {
  if (argc < 2) {
    std::cout<<"Usage: mmseg <dictionary> [input.txt]"<<std::endl;
    return 0;
  }

  MMSeg * pmmseg = MMSeg::getInstance();

  pmmseg->load(argv[1]);

  if (argc == 3) {
    std::ifstream ifs(argv[2]);
    if (! ifs.good()) {
      std::cerr << "Failed to open " << argv[2] << std::endl;
      return -1;
    }
    std::stringstream ss;
    ss << ifs.rdbuf();
    ifs.close();

    time_t now = time(0);
    auto s = ss.str();
    auto so = pmmseg->segment(s);

    ss.clear();
    std::cout << so << std::endl;

    std::cout << "Done in " << time(0)  - now << " seconds,  words from " << s.size() << " chars" << std::endl;
    pmmseg->unload();

    return 0;
  }

  while (true) {
    std::cout << "Input String: ";
    std::string line;
    if (! std::getline(std::cin, line)) break;
    std::string ss = pmmseg->segment(trim(line));
    std::cout <<ss << std::endl; 
  }

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3d8, %rsp            # imm = 0x3D8
cmpl $0x1, %edi
jg 0x5675
movq 0x398b(%rip), %rbx      # 0x8fc0
leaq 0xc1e(%rip), %rsi       # 0x625a
movl $0x25, %edx
movq %rbx, %rdi
callq 0x2290
movq (%rbx), %rax
movl $0xa, %esi
movq -0x18(%rax), %rdi
addq %rbx, %rdi
callq 0x2260
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2190
jmp 0x5878
movq %rsi, %r14
movl %edi, %ebp
callq 0x556e
movq 0x8(%r14), %rsi
movq %rax, (%rsp)
leaq 0x1d0(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x2100
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xb11(%rip), %rdx       # 0x61ba
leaq 0x48(%rsp), %rdi
movq %rdx, %rsi
callq 0x42c0
movq (%rsp), %rdi
leaq 0x1d0(%rsp), %rsi
leaq 0x48(%rsp), %rdx
callq 0x2c4c
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x56e0
callq 0x2240
leaq 0x1e0(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x56f6
callq 0x2240
cmpl $0x3, %ebp
jne 0x5770
movq 0x10(%r14), %rsi
leaq 0x1d0(%rsp), %rbx
movl $0x8, %edx
movq %rbx, %rdi
callq 0x23c0
movq (%rbx), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x1f0(%rsp,%rax)
je 0x587f
movq 0x38c0(%rip), %rbx      # 0x8ff0
leaq 0xb49(%rip), %rsi       # 0x6280
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2290
movq 0x10(%r14), %r14
testq %r14, %r14
je 0x5a13
movq %r14, %rdi
callq 0x2120
movq 0x3890(%rip), %rdi      # 0x8ff0
movq %r14, %rsi
movq %rax, %rdx
callq 0x2290
jmp 0x5a2a
movq 0x3861(%rip), %r12      # 0x8fd8
leaq 0xb39(%rip), %r14       # 0x62b7
leaq 0x1d0(%rsp), %r13
movq 0x3833(%rip), %rdi      # 0x8fc0
movl $0xe, %edx
movq %r14, %rsi
callq 0x2290
movq (%r12), %rax
movq %r15, 0x1d0(%rsp)
movq $0x0, 0x1d8(%rsp)
movb $0x0, 0x1e0(%rsp)
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2260
movsbl %al, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x23d0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x20(%rax,%rcx), %ebp
testb $0x5, %bpl
jne 0x585c
movq %r13, %rdi
callq 0x37fb
movq (%rsp), %rsi
leaq 0x48(%rsp), %rdi
movl $0x3, %ecx
movq %rax, %rdx
callq 0x2916
movq 0x50(%rsp), %rdx
movq 0x48(%rsp), %rsi
movq 0x37a7(%rip), %rdi      # 0x8fc0
callq 0x2290
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2260
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2190
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x585c
callq 0x2240
movq 0x1d0(%rsp), %rdi
cmpq %r15, %rdi
je 0x586e
callq 0x2240
testb $0x5, %bpl
je 0x5786
xorl %ebx, %ebx
jmp 0x5a67
leaq 0x48(%rsp), %r15
movq %r15, %rdi
callq 0x21a0
leaq 0x58(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
callq 0x2080
leaq 0x1d0(%rsp), %rdi
callq 0x2070
xorl %edi, %edi
callq 0x2220
movq %rax, %r14
leaq 0x60(%rsp), %rsi
leaq 0x8(%rsp), %rdi
callq 0x2340
movq (%rsp), %rsi
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rdx
movl $0x3, %ecx
callq 0x2916
movq 0x48(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x2380
movq 0x30(%rsp), %rdx
movq 0x28(%rsp), %rsi
movq 0x36c0(%rip), %rdi      # 0x8fc0
callq 0x2290
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2260
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2190
movq 0x368a(%rip), %rdi      # 0x8fc0
leaq 0x953(%rip), %rsi       # 0x6290
movl $0x8, %edx
callq 0x2290
xorl %edi, %edi
callq 0x2220
subq %r14, %rax
movq 0x3668(%rip), %rdi      # 0x8fc0
movq %rax, %rsi
callq 0x2250
leaq 0x932(%rip), %rsi       # 0x6299
movl $0x16, %edx
movq %rax, %rdi
movq %rax, %rbx
callq 0x2290
movq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x2180
leaq 0x925(%rip), %rsi       # 0x62b0
movl $0x6, %edx
movq %rax, %rdi
movq %rax, %r14
callq 0x2290
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2260
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2190
movq (%rsp), %rdi
callq 0x3222
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x59de
callq 0x2240
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x59f1
callq 0x2240
movq 0x35b0(%rip), %rsi      # 0x8fa8
leaq 0x48(%rsp), %rdi
callq 0x21c0
leaq 0xc8(%rsp), %rdi
callq 0x20d0
xorl %ebx, %ebx
jmp 0x5a5a
movq (%rbx), %rax
movq -0x18(%rax), %rax
movl 0x20(%rbx,%rax), %esi
leaq (%rbx,%rax), %rdi
orl $0x1, %esi
callq 0x2380
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movl $0xa, %esi
movq %rbx, %rdi
callq 0x2260
movq 0x35ab(%rip), %rdi      # 0x8ff0
movsbl %al, %esi
callq 0x2040
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movq %rax, %rdi
callq 0x2190
leaq 0x1d0(%rsp), %rdi
callq 0x20a0
movl %ebx, %eax
addq $0x3d8, %rsp            # imm = 0x3D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x5ae2
jmp 0x5a84
jmp 0x5ac7
movq %rax, %rbx
jmp 0x5af5
movq 0x48(%rsp), %rdi
movq %rax, %rbx
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x5aa5
callq 0x2240
jmp 0x5aa5
movq %rax, %rbx
leaq 0x1e0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x5b4d
jmp 0x5b52
movq %rax, %rbx
jmp 0x5b52
movq %rax, %rbx
jmp 0x5b13
leaq 0x38(%rsp), %rcx
movq %rax, %rbx
movq -0x10(%rcx), %rdi
cmpq %rcx, %rdi
je 0x5ae2
callq 0x2240
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5af5
callq 0x2240
movq 0x34ac(%rip), %rsi      # 0x8fa8
leaq 0x48(%rsp), %rdi
callq 0x21c0
leaq 0xc8(%rsp), %rdi
callq 0x20d0
leaq 0x1d0(%rsp), %rdi
callq 0x20a0
jmp 0x5b52
jmp 0x5b3d
movq 0x48(%rsp), %rdi
movq %rax, %rbx
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x5b40
callq 0x2240
jmp 0x5b40
movq %rax, %rbx
movq 0x1d0(%rsp), %rdi
cmpq %r15, %rdi
je 0x5b52
callq 0x2240
movq %rbx, %rdi
callq 0x2390