// File: /workspace/github_cpp_makefile_star2_O1/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 0x570d
movq 0x38f3(%rip), %rbx      # 0x8fc0
leaq 0xbbe(%rip), %rsi       # 0x6292
movl $0x25, %edx
movq %rbx, %rdi
callq 0x2290
movq (%rbx), %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
jmp 0x5910
movq %rsi, %r14
movl %edi, %ebp
callq 0x5604
movq %rax, (%rsp)
movq 0x8(%r14), %rsi
leaq 0x1d0(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x2100
leaq 0x58(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0xab1(%rip), %rdx       # 0x61f2
leaq 0x48(%rsp), %rdi
movq %rdx, %rsi
callq 0x42f6
leaq 0x1d0(%rsp), %rsi
leaq 0x48(%rsp), %rdx
movq (%rsp), %rdi
callq 0x2c66
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x5778
callq 0x2240
leaq 0x1e0(%rsp), %r15
movq -0x10(%r15), %rdi
cmpq %r15, %rdi
je 0x578e
callq 0x2240
cmpl $0x3, %ebp
jne 0x5808
movq 0x10(%r14), %rsi
leaq 0x1d0(%rsp), %rbx
movq %rbx, %rdi
movl $0x8, %edx
callq 0x23c0
movq (%rbx), %rax
movq -0x18(%rax), %rax
cmpl $0x0, 0x1f0(%rsp,%rax)
je 0x5917
movq 0x3828(%rip), %rbx      # 0x8ff0
leaq 0xae9(%rip), %rsi       # 0x62b8
movl $0xf, %edx
movq %rbx, %rdi
callq 0x2290
movq 0x10(%r14), %r14
testq %r14, %r14
je 0x5aab
movq %r14, %rdi
callq 0x2120
movq 0x37f8(%rip), %rdi      # 0x8ff0
movq %r14, %rsi
movq %rax, %rdx
callq 0x2290
jmp 0x5ac2
leaq 0xae0(%rip), %r14       # 0x62ef
movq 0x37c2(%rip), %r12      # 0x8fd8
leaq 0x1d0(%rsp), %r13
movl $0xe, %edx
movq 0x3796(%rip), %rdi      # 0x8fc0
movq %r14, %rsi
callq 0x2290
movq %r15, 0x1d0(%rsp)
movq $0x0, 0x1d8(%rsp)
movb $0x0, 0x1e0(%rsp)
movq (%r12), %rax
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 0x58f4
movq %r13, %rdi
callq 0x3809
leaq 0x48(%rsp), %rdi
movq (%rsp), %rsi
movq %rax, %rdx
movl $0x3, %ecx
callq 0x2920
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq 0x370f(%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 0x58f4
callq 0x2240
movq 0x1d0(%rsp), %rdi
cmpq %r15, %rdi
je 0x5906
callq 0x2240
testb $0x5, %bpl
je 0x581e
xorl %ebx, %ebx
jmp 0x5aff
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
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rdx
movq (%rsp), %rsi
movl $0x3, %ecx
callq 0x2920
movq 0x48(%rsp), %rax
addq -0x18(%rax), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x2380
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x3628(%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 0x35f2(%rip), %rdi      # 0x8fc0
leaq 0x8f3(%rip), %rsi       # 0x62c8
movl $0x8, %edx
callq 0x2290
xorl %edi, %edi
callq 0x2220
subq %r14, %rax
movq 0x35d0(%rip), %rdi      # 0x8fc0
movq %rax, %rsi
callq 0x2250
movq %rax, %rbx
leaq 0x8cf(%rip), %rsi       # 0x62d1
movl $0x16, %edx
movq %rax, %rdi
callq 0x2290
movq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x2180
movq %rax, %r14
leaq 0x8c2(%rip), %rsi       # 0x62e8
movl $0x6, %edx
movq %rax, %rdi
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 0x323c
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5a76
callq 0x2240
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5a89
callq 0x2240
movq 0x3518(%rip), %rsi      # 0x8fa8
leaq 0x48(%rsp), %rdi
callq 0x21c0
leaq 0xc8(%rsp), %rdi
callq 0x20d0
xorl %ebx, %ebx
jmp 0x5af2
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x2380
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2260
movsbl %al, %esi
movq 0x3510(%rip), %rdi      # 0x8ff0
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 0x5b7a
jmp 0x5b1c
jmp 0x5b5f
movq %rax, %rbx
jmp 0x5b8d
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x5b3d
callq 0x2240
jmp 0x5b3d
movq %rax, %rbx
leaq 0x1e0(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0x5be5
jmp 0x5bea
movq %rax, %rbx
jmp 0x5bea
movq %rax, %rbx
jmp 0x5bab
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5b7a
callq 0x2240
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x5b8d
callq 0x2240
movq 0x3414(%rip), %rsi      # 0x8fa8
leaq 0x48(%rsp), %rdi
callq 0x21c0
leaq 0xc8(%rsp), %rdi
callq 0x20d0
leaq 0x1d0(%rsp), %rdi
callq 0x20a0
jmp 0x5bea
jmp 0x5bd5
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x5bd8
callq 0x2240
jmp 0x5bd8
movq %rax, %rbx
movq 0x1d0(%rsp), %rdi
cmpq %r15, %rdi
je 0x5bea
callq 0x2240
movq %rbx, %rdi
callq 0x2390