// File: /workspace/github_cpp_makefile_star2_O3/64Mega[P]todo-cli/src/todo.cpp
// Function: process_todos(std::queue<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::deque<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>>*, bool)
void process_todos(std::queue<std::string>* command_list, bool local_mode) {
    static bool local = local_mode;

    // Recursion guard
    if(command_list->empty()) { 
        return; 
    }
    
    std::string command = command_list->front();
    std::transform(command.begin(), command.end(), command.begin(), ::tolower);    
    command_list->pop();

    // Pretty straightforward state-changes where necessary. Some of the functions "eat" the remainder
    // of the command inputs (if any) to make sure there aren't multiple triggerings of, for instance,
    // the usage() function.
    if(match_one_or_more(command, "global")) {
        local = false;        
        if(command_list->empty()) {
            read_todos(local);
        }
    } else
    if(match_one_or_more(command, "init")) {
        todo_init(local);
    } else 
    if(match_one_or_more(command, "add")) {
        if(command_list->empty()) {
            ccout << "No todo body provided." << std::endl;
        } else {
            write_todo(concat_remainder(command_list), local);
        }
    } else
    if(match_one_or_more(command, "complete")) {
        if(command_list->empty()) {
            ccout << "No todo ID provided." << std::endl;
        } else {
            unsigned int idx = atoi(command_list->front().c_str());
            command_list->pop();
            complete_todo(idx, local);
        }
    } else
    if(match_one_or_more(command, "sweep")) {
        sweep_todos(local);
    } else
    if(match_one_or_more(command, "delete")) {
        if(command_list->empty()) {
            ccout << "No todo ID provided." << std::endl;          
        } else {
            unsigned int idx = atoi(command_list->front().c_str());
            command_list->pop();
            delete_todo(idx, local);
        }
    } else 
    if(match_one_or_more(command, "purge")) {
        purge_todos(local);
    } else
    if(match_one_or_more(command, "version")) {
        ccout << "todo-cli version " << VERSION << std::endl;       
        while(!command_list->empty()) { command_list->pop(); }
    } else
    if(match_one_or_more(command, "help")) {
        while(!command_list->empty()) { command_list->pop(); }
        usage();
    } else {
        while(!command_list->empty()) { command_list->pop(); }
        // usage();
        ccout << "Invalid command. Run 'todo help' for usage information" << std::endl;
    }
    
    process_todos(command_list);    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rdi, %rbx
movb 0xe1041(%rip), %al      # 0xf6550
testb %al, %al
je 0x15d69
movq 0x10(%rbx), %rax
cmpq %rax, 0x30(%rbx)
je 0x15709
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x1706c
movq 0x8(%r14), %r14
testq %r14, %r14
je 0x1556d
movq 0x8(%rsp), %r15
xorl %r13d, %r13d
movsbl (%r15,%r13), %edi
callq 0x12530
movb %al, (%r15,%r13)
incq %r13
cmpq %r13, %r14
jne 0x15557
movq %rbx, %rdi
callq 0x17854
leaq 0x258(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x248(%rsp), %rdi
callq 0x1706c
leaq 0x238(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa5d94(%rip), %rsi     # 0xbb342
leaq 0xa5d93(%rip), %rdx     # 0xbb348
leaq 0x228(%rsp), %rdi
callq 0x17296
leaq 0x248(%rsp), %rdi
leaq 0x228(%rsp), %rsi
callq 0x1615d
movl %eax, %ebp
movq 0x228(%rsp), %rdi
cmpq %r15, %rdi
je 0x155f6
movq 0x238(%rsp), %rsi
incq %rsi
callq 0x17970
movq 0x248(%rsp), %rdi
cmpq %r14, %rdi
je 0x15613
movq 0x258(%rsp), %rsi
incq %rsi
callq 0x17970
testb %bpl, %bpl
je 0x15639
movb $0x0, 0xe0f2a(%rip)     # 0xf6549
movq 0x30(%rbx), %rax
cmpq 0x10(%rbx), %rax
jne 0x156e8
xorl %edi, %edi
callq 0x15249
jmp 0x156e8
leaq 0x218(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x208(%rsp), %rdi
callq 0x1706c
leaq 0x1f8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa5cd7(%rip), %rsi     # 0xbb349
leaq 0xa5cd4(%rip), %rdx     # 0xbb34d
leaq 0x1e8(%rsp), %rdi
callq 0x17296
leaq 0x208(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
callq 0x1615d
movl %eax, %ebp
movq 0x1e8(%rsp), %rdi
cmpq %r15, %rdi
je 0x156ba
movq 0x1f8(%rsp), %rsi
incq %rsi
callq 0x17970
movq 0x208(%rsp), %rdi
cmpq %r14, %rdi
je 0x156d7
movq 0x218(%rsp), %rsi
incq %rsi
callq 0x17970
testb %bpl, %bpl
je 0x1571b
movzbl 0xe0e66(%rip), %edi     # 0xf6549
callq 0x16237
movq %rbx, %rdi
xorl %esi, %esi
callq 0x154f5
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x15709
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x17970
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1d8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x1c8(%rsp), %rdi
callq 0x1706c
leaq 0x1b8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa5bfa(%rip), %rsi     # 0xbb34e
leaq 0xa5bf6(%rip), %rdx     # 0xbb351
leaq 0x1a8(%rsp), %rdi
callq 0x17296
leaq 0x1c8(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x1615d
movl %eax, %ebp
movq 0x1a8(%rsp), %rdi
cmpq %r15, %rdi
je 0x1579c
movq 0x1b8(%rsp), %rsi
incq %rsi
callq 0x17970
movq 0x1c8(%rsp), %rdi
cmpq %r14, %rdi
je 0x157b9
movq 0x1d8(%rsp), %rsi
incq %rsi
callq 0x17970
testb %bpl, %bpl
je 0x1581a
movq 0x30(%rbx), %rax
cmpq 0x10(%rbx), %rax
je 0x159a4
leaq 0x268(%rsp), %rdi
movq %rbx, %rsi
callq 0x164cd
movzbl 0xe0d66(%rip), %esi     # 0xf6549
leaq 0x268(%rsp), %rdi
callq 0x16569
leaq 0x278(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x156e8
movq 0x278(%rsp), %rsi
incq %rsi
callq 0x17970
jmp 0x156e8
leaq 0x198(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x188(%rsp), %rdi
callq 0x1706c
leaq 0x178(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa5b16(%rip), %rsi     # 0xbb369
leaq 0xa5b17(%rip), %rdx     # 0xbb371
leaq 0x168(%rsp), %rdi
callq 0x17296
leaq 0x188(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x1615d
movl %eax, %ebp
movq 0x168(%rsp), %rdi
cmpq %r15, %rdi
je 0x1589b
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x17970
movq 0x188(%rsp), %rdi
cmpq %r14, %rdi
je 0x158b8
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x17970
testb %bpl, %bpl
je 0x158f0
movq 0x10(%rbx), %rax
cmpq %rax, 0x30(%rbx)
je 0x15ac1
movq (%rax), %rdi
callq 0x12420
movl %eax, %ebp
movq %rbx, %rdi
callq 0x17854
movzbl 0xe0c65(%rip), %esi     # 0xf6549
movl %ebp, %edi
callq 0x167b8
jmp 0x156e8
leaq 0x158(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x148(%rsp), %rdi
callq 0x1706c
leaq 0x138(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa5a5e(%rip), %rsi     # 0xbb387
leaq 0xa5a5c(%rip), %rdx     # 0xbb38c
leaq 0x128(%rsp), %rdi
callq 0x17296
leaq 0x148(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x1615d
movl %eax, %ebp
movq 0x128(%rsp), %rdi
cmpq %r15, %rdi
je 0x15971
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x17970
movq 0x148(%rsp), %rdi
cmpq %r14, %rdi
je 0x1598e
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x17970
testb %bpl, %bpl
je 0x159ef
movzbl 0xe0baf(%rip), %edi     # 0xf6549
callq 0x16a6b
jmp 0x156e8
leaq 0xe1ab5(%rip), %r14     # 0xf7460
leaq 0xa59a0(%rip), %rsi     # 0xbb352
movl $0x16, %edx
movq %r14, %rdi
callq 0x80a80
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x61bd0
movsbl %al, %esi
leaq 0xe1a83(%rip), %rdi     # 0xf7460
callq 0x80580
movq %rax, %rdi
callq 0x7fb50
jmp 0x156e8
leaq 0x118(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x108(%rsp), %rdi
callq 0x1706c
leaq 0xf8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa5965(%rip), %rsi     # 0xbb38d
leaq 0xa5964(%rip), %rdx     # 0xbb393
leaq 0xe8(%rsp), %rdi
callq 0x17296
leaq 0x108(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x1615d
movl %eax, %ebp
movq 0xe8(%rsp), %rdi
cmpq %r15, %rdi
je 0x15a70
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x17970
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0x15a8d
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x17970
testb %bpl, %bpl
je 0x15af1
movq 0x10(%rbx), %rax
cmpq %rax, 0x30(%rbx)
je 0x15ac1
movq (%rax), %rdi
callq 0x12420
movl %eax, %ebp
movq %rbx, %rdi
callq 0x17854
movzbl 0xe0a94(%rip), %esi     # 0xf6549
movl %ebp, %edi
callq 0x16908
jmp 0x156e8
movl $0x14, %r14d
leaq 0xa58a4(%rip), %r15     # 0xbb372
leaq 0xe198b(%rip), %rdi     # 0xf7460
movq %r15, %rsi
movq %r14, %rdx
callq 0x80a80
leaq 0xe1979(%rip), %rdi     # 0xf7460
callq 0x80890
jmp 0x156e8
leaq 0xd8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0xc8(%rsp), %rdi
callq 0x1706c
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa586a(%rip), %rsi     # 0xbb394
leaq 0xa5868(%rip), %rdx     # 0xbb399
leaq 0xa8(%rsp), %rdi
callq 0x17296
leaq 0xc8(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x1615d
movl %eax, %ebp
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x15b72
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x17970
movq 0xc8(%rsp), %rdi
cmpq %r14, %rdi
je 0x15b8f
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x17970
testb %bpl, %bpl
je 0x15ba5
movzbl 0xe09ae(%rip), %edi     # 0xf6549
callq 0x16be2
jmp 0x156e8
leaq 0x98(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0x1706c
leaq 0x78(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa57bf(%rip), %rsi     # 0xbb39a
leaq 0xa57bf(%rip), %rdx     # 0xbb3a1
leaq 0x68(%rsp), %rdi
callq 0x17296
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x1615d
movl %eax, %ebp
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x15c17
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x17970
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x15c34
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x17970
testb %bpl, %bpl
je 0x15c8e
leaq 0xe1820(%rip), %rdi     # 0xf7460
leaq 0xa575b(%rip), %rsi     # 0xbb3a2
movl $0x11, %edx
callq 0x80a80
leaq 0xe1808(%rip), %rdi     # 0xf7460
leaq 0xa5755(%rip), %rsi     # 0xbb3b4
movl $0x5, %edx
callq 0x80a80
leaq 0xe17f0(%rip), %rdi     # 0xf7460
callq 0x80890
jmp 0x15c7f
movq %rbx, %rdi
callq 0x17854
movq 0x30(%rbx), %rax
cmpq 0x10(%rbx), %rax
jne 0x15c77
jmp 0x156e8
leaq 0x58(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %rdi
callq 0x1706c
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa56fc(%rip), %rsi     # 0xbb3ba
leaq 0xa56f9(%rip), %rdx     # 0xbb3be
leaq 0x28(%rsp), %rdi
callq 0x17296
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x1615d
movl %eax, %ebp
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x15cf7
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x17970
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x15d0e
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x17970
movq 0x10(%rbx), %rax
movq 0x30(%rbx), %rcx
testb %bpl, %bpl
je 0x15d3c
cmpq %rax, %rcx
je 0x15d32
movq %rbx, %rdi
callq 0x17854
movq 0x30(%rbx), %rax
cmpq 0x10(%rbx), %rax
jne 0x15d20
callq 0x16008
jmp 0x156e8
movl $0x36, %r14d
leaq 0xa5676(%rip), %r15     # 0xbb3bf
cmpq %rax, %rcx
je 0x15ace
movq %rbx, %rdi
callq 0x17854
movq 0x30(%rbx), %rax
cmpq 0x10(%rbx), %rax
jne 0x15d52
jmp 0x15ace
movzbl %sil, %edi
callq 0x12720
jmp 0x15517
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x15d96
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x17970
jmp 0x15d96
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x15fe9
movq 0x58(%rsp), %rsi
jmp 0x15fdc
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x15dcd
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x17970
jmp 0x15dcd
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x15fe9
movq 0x98(%rsp), %rsi
jmp 0x15fdc
jmp 0x15fe6
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x15e15
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x17970
jmp 0x15e15
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
cmpq %r14, %rdi
je 0x15fe9
movq 0xd8(%rsp), %rsi
jmp 0x15fdc
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
cmpq %r15, %rdi
je 0x15e58
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x17970
jmp 0x15e58
movq %rax, %rbx
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0x15fe9
movq 0x118(%rsp), %rsi
jmp 0x15fdc
jmp 0x15fe6
movq %rax, %rbx
movq 0x128(%rsp), %rdi
cmpq %r15, %rdi
je 0x15ea0
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x17970
jmp 0x15ea0
movq %rax, %rbx
movq 0x148(%rsp), %rdi
cmpq %r14, %rdi
je 0x15fe9
movq 0x158(%rsp), %rsi
jmp 0x15fdc
movq %rax, %rbx
leaq 0x278(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15fe9
movq 0x278(%rsp), %rsi
jmp 0x15fdc
movq %rax, %rbx
movq 0x168(%rsp), %rdi
cmpq %r15, %rdi
je 0x15f08
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x17970
jmp 0x15f08
movq %rax, %rbx
movq 0x188(%rsp), %rdi
cmpq %r14, %rdi
je 0x15fe9
movq 0x198(%rsp), %rsi
jmp 0x15fdc
movq %rax, %rbx
movq 0x1a8(%rsp), %rdi
cmpq %r15, %rdi
je 0x15f4b
movq 0x1b8(%rsp), %rsi
incq %rsi
callq 0x17970
jmp 0x15f4b
movq %rax, %rbx
movq 0x1c8(%rsp), %rdi
cmpq %r14, %rdi
je 0x15fe9
movq 0x1d8(%rsp), %rsi
jmp 0x15fdc
movq %rax, %rbx
movq 0x1e8(%rsp), %rdi
cmpq %r15, %rdi
je 0x15f8b
movq 0x1f8(%rsp), %rsi
incq %rsi
callq 0x17970
jmp 0x15f8b
movq %rax, %rbx
movq 0x208(%rsp), %rdi
cmpq %r14, %rdi
je 0x15fe9
movq 0x218(%rsp), %rsi
jmp 0x15fdc
movq %rax, %rbx
movq 0x228(%rsp), %rdi
cmpq %r15, %rdi
je 0x15fc7
movq 0x238(%rsp), %rsi
incq %rsi
callq 0x17970
jmp 0x15fc7
movq %rax, %rbx
movq 0x248(%rsp), %rdi
cmpq %r14, %rdi
je 0x15fe9
movq 0x258(%rsp), %rsi
incq %rsi
callq 0x17970
jmp 0x15fe9
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x16000
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x17970
movq %rbx, %rdi
callq 0xb83a0