// File: /workspace/github_cpp_makefile_star2_O1/wandernauta[P]ttasks/t.cpp
// Function: main
int main(int argc, char* argv[]) {
  TodoList tl;
  std::vector<std::string> args(argv, argv+argc);

  if (argc == 1) {
    // Called as 't'. Dump the todo list.
    tl.dump();
  } else {
    if (args[1] == "-h") {
      // Called as 't -h': Dump some help info.
      std::cout << "usage: t               # Dump all items." << std::endl;
      std::cout << "       t 3             # Erase the third item." << std::endl;
      std::cout << "       t Walk the dog  # Add an item." << std::endl;
      std::cout << "       t -e            # Open todo.txt in $EDITOR." << std::endl;
      std::cout << "       t -h            # Show this help text." << std::endl;
      std::cout << "       t -c            # Count the amount of items." << std::endl;
      std::cout << "       t -r            # Reorder the items." << std::endl;
      std::cout << std::endl;
      exit(0);
    } else if (args[1] == "-e") {
      // Called as 't -e'. Open todo.txt in $EDITOR.
      tl.edit();
    } else if (args[1] == "-c") {
      // Called as 't -c'. Count the amount of items in the list.
      std::cout << tl.count() << std::endl;
    } else if (args[1] == "-r") {
      // Called as 't -r'. Reorder the items.
      tl.reorder();
    } else if (atoi(argv[1]) != 0) {
      // Called as 't 3' or similar. Erase the task.
      tl.erase(atoi(argv[1]));
    } else if (args[1].find_first_not_of("1234567890. ") == std::string::npos) {
      std::cout << "Say what?" << std::endl;
    } else {
      // Called as 't Walk the dog' or similar.
      // Collect the argument:

      std::ostringstream oss;
      for (std::vector<std::string>::iterator it = args.begin()+1; it < args.end()-1; ++it) {
        oss << *it << " ";
      }
      oss << args.back();
      tl.add(oss.str());
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x40(%rsp), %rdi
callq 0x2c54
movslq %ebp, %rax
leaq (%rbx,%rax,8), %rdx
leaq 0x8(%rsp), %rdi
leaq 0x90(%rsp), %rcx
movq %rbx, %rsi
callq 0x28ec
cmpl $0x1, %ebp
jne 0x2528
leaq 0x40(%rsp), %rdi
callq 0x34ec
jmp 0x272a
movq 0x8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x1acc(%rip), %rsi      # 0x4004
callq 0x2080
testl %eax, %eax
je 0x276f
movq 0x8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x1bf1(%rip), %rsi      # 0x4146
callq 0x2080
testl %eax, %eax
je 0x25ae
movq 0x8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x1bdb(%rip), %rsi      # 0x4149
callq 0x2080
testl %eax, %eax
je 0x25bd
movq 0x8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x1bc5(%rip), %rsi      # 0x414c
callq 0x2080
testl %eax, %eax
je 0x2605
movq 0x8(%rbx), %rdi
callq 0x22d0
testl %eax, %eax
je 0x2614
leaq 0x40(%rsp), %rdi
movl %eax, %esi
callq 0x32b8
jmp 0x272a
leaq 0x40(%rsp), %rdi
callq 0x368a
jmp 0x272a
leaq 0x40(%rsp), %rdi
callq 0x35c8
movq 0x4a02(%rip), %rdi      # 0x6fd0
movq %rax, %rsi
callq 0x2130
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2140
jmp 0x272a
leaq 0x40(%rsp), %rdi
callq 0x35ce
jmp 0x272a
movq 0x8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x1b2b(%rip), %rsi      # 0x414f
movl $0xc, %ecx
xorl %edx, %edx
callq 0x2310
cmpq $-0x1, %rax
je 0x2706
leaq 0x90(%rsp), %rdi
callq 0x2280
movq 0x8(%rsp), %r15
addq $0x20, %r15
leaq 0x90(%rsp), %rbx
leaq 0x1afb(%rip), %r14      # 0x415a
movq 0x10(%rsp), %rax
leaq -0x20(%rax), %rcx
cmpq %rcx, %r15
jae 0x2692
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x2230
addq $0x20, %r15
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2230
jmp 0x265f
movq -0x20(%rax), %rsi
movq -0x18(%rax), %rdx
leaq 0x90(%rsp), %rdi
callq 0x2230
leaq 0x98(%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0x22f0
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x2fba
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x26e3
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21f0
movq 0x48de(%rip), %rsi      # 0x6fc8
leaq 0x90(%rsp), %rdi
callq 0x2100
leaq 0x100(%rsp), %rdi
callq 0x20a0
jmp 0x272a
movq 0x48c3(%rip), %rdi      # 0x6fd0
leaq 0x1a48(%rip), %rsi      # 0x415c
movl $0x9, %edx
callq 0x2230
movq 0x48ab(%rip), %rdi      # 0x6fd0
callq 0x20e0
leaq 0x8(%rsp), %rdi
callq 0x292e
leaq 0x80(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x2755
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x21f0
leaq 0x40(%rsp), %rdi
callq 0x29b0
xorl %eax, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x485a(%rip), %rdi      # 0x6fd0
leaq 0x188a(%rip), %rsi      # 0x4007
movl $0x28, %edx
callq 0x2230
movq 0x4842(%rip), %rdi      # 0x6fd0
callq 0x20e0
movq 0x4836(%rip), %rdi      # 0x6fd0
leaq 0x188f(%rip), %rsi      # 0x4030
movl $0x2e, %edx
callq 0x2230
movq 0x481e(%rip), %rdi      # 0x6fd0
callq 0x20e0
movq 0x4812(%rip), %rdi      # 0x6fd0
leaq 0x189a(%rip), %rsi      # 0x405f
movl $0x25, %edx
callq 0x2230
movq 0x47fa(%rip), %rdi      # 0x6fd0
callq 0x20e0
movq 0x47ee(%rip), %rdi      # 0x6fd0
leaq 0x189c(%rip), %rsi      # 0x4085
movl $0x32, %edx
callq 0x2230
movq 0x47d6(%rip), %rdi      # 0x6fd0
callq 0x20e0
movq 0x47ca(%rip), %rdi      # 0x6fd0
leaq 0x18ab(%rip), %rsi      # 0x40b8
movl $0x2d, %edx
callq 0x2230
movq 0x47b2(%rip), %rdi      # 0x6fd0
callq 0x20e0
movq 0x47a6(%rip), %rdi      # 0x6fd0
leaq 0x18b5(%rip), %rsi      # 0x40e6
movl $0x33, %edx
callq 0x2230
movq 0x478e(%rip), %rdi      # 0x6fd0
callq 0x20e0
movq 0x4782(%rip), %rdi      # 0x6fd0
leaq 0x18c5(%rip), %rsi      # 0x411a
movl $0x2b, %edx
callq 0x2230
movq 0x476a(%rip), %rdi      # 0x6fd0
callq 0x20e0
movq 0x475e(%rip), %rdi      # 0x6fd0
callq 0x20e0
xorl %edi, %edi
callq 0x2250
movq %rax, %rbx
leaq 0x30(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x28aa
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x21f0
jmp 0x28aa
jmp 0x28cd
jmp 0x28a7
movq %rax, %rbx
jmp 0x28da
movq %rax, %rbx
movq 0x4717(%rip), %rsi      # 0x6fc8
leaq 0x90(%rsp), %rdi
callq 0x2100
leaq 0x100(%rsp), %rdi
callq 0x20a0
jmp 0x28d0
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x292e
leaq 0x40(%rsp), %rdi
callq 0x298a
movq %rbx, %rdi
callq 0x2330