// File: /workspace/github_cpp_makefile_star2_O2/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 0x2b10
movslq %ebp, %rax
leaq (%rbx,%rax,8), %rdx
leaq 0x8(%rsp), %rdi
leaq 0x90(%rsp), %rcx
movq %rbx, %rsi
callq 0x27cc
cmpl $0x1, %ebp
jne 0x24f8
leaq 0x40(%rsp), %rdi
callq 0x30b2
jmp 0x2677
movq 0x8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x1afc(%rip), %rsi      # 0x4004
callq 0x27fe
testb %al, %al
jne 0x26b3
movq 0x8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x1c21(%rip), %rsi      # 0x4146
callq 0x27fe
testb %al, %al
je 0x253d
leaq 0x40(%rsp), %rdi
callq 0x31ee
jmp 0x2677
movq 0x8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x1bfc(%rip), %rsi      # 0x4149
callq 0x27fe
testb %al, %al
je 0x257c
leaq 0x40(%rsp), %rdi
callq 0x3132
movq 0x4a69(%rip), %rdi      # 0x6fd0
movq %rax, %rsi
callq 0x2130
movq %rax, %rdi
callq 0x20e0
jmp 0x2677
movq 0x8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x1bc0(%rip), %rsi      # 0x414c
callq 0x27fe
testb %al, %al
je 0x25a4
leaq 0x40(%rsp), %rdi
callq 0x3138
jmp 0x2677
movq 0x8(%rbx), %rdi
callq 0x22c0
testl %eax, %eax
je 0x25c2
leaq 0x40(%rsp), %rdi
movl %eax, %esi
callq 0x2f52
jmp 0x2677
movq 0x8(%rsp), %rdi
addq $0x20, %rdi
leaq 0x1b7d(%rip), %rsi      # 0x414f
xorl %edx, %edx
callq 0x2110
cmpq $-0x1, %rax
je 0x269b
leaq 0x90(%rsp), %rdi
callq 0x2260
movq 0x8(%rsp), %rbx
addq $0x20, %rbx
leaq 0x90(%rsp), %r14
leaq 0x1b52(%rip), %r15      # 0x415a
movq 0x10(%rsp), %rsi
addq $-0x20, %rsi
cmpq %rsi, %rbx
jae 0x2632
movq %r14, %rdi
movq %rbx, %rsi
callq 0x21a0
addq $0x20, %rbx
movq %rax, %rdi
movq %r15, %rsi
callq 0x21b0
jmp 0x2608
leaq 0x90(%rsp), %rdi
callq 0x21a0
leaq 0x98(%rsp), %rsi
leaq 0x20(%rsp), %rdi
callq 0x22e0
leaq 0x40(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x2d6a
leaq 0x20(%rsp), %rdi
callq 0x20d0
leaq 0x90(%rsp), %rdi
callq 0x2060
leaq 0x8(%rsp), %rdi
callq 0x280c
leaq 0x40(%rsp), %rdi
callq 0x282e
xorl %eax, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x492e(%rip), %rdi      # 0x6fd0
leaq 0x1ab3(%rip), %rsi      # 0x415c
callq 0x21b0
jmp 0x256f
movq 0x4916(%rip), %rdi      # 0x6fd0
leaq 0x1946(%rip), %rsi      # 0x4007
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
movq 0x48fb(%rip), %rdi      # 0x6fd0
leaq 0x1954(%rip), %rsi      # 0x4030
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
movq 0x48e0(%rip), %rdi      # 0x6fd0
leaq 0x1968(%rip), %rsi      # 0x405f
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
movq 0x48c5(%rip), %rdi      # 0x6fd0
leaq 0x1973(%rip), %rsi      # 0x4085
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
movq 0x48aa(%rip), %rdi      # 0x6fd0
leaq 0x198b(%rip), %rsi      # 0x40b8
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
movq 0x488f(%rip), %rdi      # 0x6fd0
leaq 0x199e(%rip), %rsi      # 0x40e6
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
movq 0x4874(%rip), %rdi      # 0x6fd0
leaq 0x19b7(%rip), %rsi      # 0x411a
callq 0x21b0
movq %rax, %rdi
callq 0x20e0
movq 0x4859(%rip), %rdi      # 0x6fd0
callq 0x20e0
xorl %edi, %edi
callq 0x2220
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x20d0
jmp 0x2799
jmp 0x27ad
jmp 0x2796
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x2060
jmp 0x27b0
movq %rax, %rbx
jmp 0x27ba
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x280c
leaq 0x40(%rsp), %rdi
callq 0x282e
movq %rbx, %rdi
callq 0x2310