// File: /workspace/github_cpp_makefile_star2_O1/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 0xe1031(%rip), %al      # 0xf6550
testb %al, %al
je 0x15d79
movq 0x10(%rbx), %rax
cmpq %rax, 0x30(%rbx)
je 0x15719
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 0x17038
movq 0x8(%r14), %r14
testq %r14, %r14
je 0x1557d
movq 0x8(%rsp), %r15
xorl %r13d, %r13d
movsbl (%r15,%r13), %edi
callq 0x12530
movb %al, (%r15,%r13)
incq %r13
cmpq %r13, %r14
jne 0x15567
movq %rbx, %rdi
callq 0x17806
leaq 0x258(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x248(%rsp), %rdi
callq 0x17038
leaq 0x238(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa5d84(%rip), %rsi     # 0xbb342
leaq 0xa5d83(%rip), %rdx     # 0xbb348
leaq 0x228(%rsp), %rdi
callq 0x1725c
leaq 0x248(%rsp), %rdi
leaq 0x228(%rsp), %rsi
callq 0x1616d
movl %eax, %ebp
movq 0x228(%rsp), %rdi
cmpq %r15, %rdi
je 0x15606
movq 0x238(%rsp), %rsi
incq %rsi
callq 0x17920
movq 0x248(%rsp), %rdi
cmpq %r14, %rdi
je 0x15623
movq 0x258(%rsp), %rsi
incq %rsi
callq 0x17920
testb %bpl, %bpl
je 0x15649
movb $0x0, 0xe0f1a(%rip)     # 0xf6549
movq 0x30(%rbx), %rax
cmpq 0x10(%rbx), %rax
jne 0x156f8
xorl %edi, %edi
callq 0x15249
jmp 0x156f8
leaq 0x218(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x208(%rsp), %rdi
callq 0x17038
leaq 0x1f8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa5cc7(%rip), %rsi     # 0xbb349
leaq 0xa5cc4(%rip), %rdx     # 0xbb34d
leaq 0x1e8(%rsp), %rdi
callq 0x1725c
leaq 0x208(%rsp), %rdi
leaq 0x1e8(%rsp), %rsi
callq 0x1616d
movl %eax, %ebp
movq 0x1e8(%rsp), %rdi
cmpq %r15, %rdi
je 0x156ca
movq 0x1f8(%rsp), %rsi
incq %rsi
callq 0x17920
movq 0x208(%rsp), %rdi
cmpq %r14, %rdi
je 0x156e7
movq 0x218(%rsp), %rsi
incq %rsi
callq 0x17920
testb %bpl, %bpl
je 0x1572b
movzbl 0xe0e56(%rip), %edi     # 0xf6549
callq 0x16247
movq %rbx, %rdi
xorl %esi, %esi
callq 0x15505
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x15719
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x17920
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 0x17038
leaq 0x1b8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa5bea(%rip), %rsi     # 0xbb34e
leaq 0xa5be6(%rip), %rdx     # 0xbb351
leaq 0x1a8(%rsp), %rdi
callq 0x1725c
leaq 0x1c8(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
callq 0x1616d
movl %eax, %ebp
movq 0x1a8(%rsp), %rdi
cmpq %r15, %rdi
je 0x157ac
movq 0x1b8(%rsp), %rsi
incq %rsi
callq 0x17920
movq 0x1c8(%rsp), %rdi
cmpq %r14, %rdi
je 0x157c9
movq 0x1d8(%rsp), %rsi
incq %rsi
callq 0x17920
testb %bpl, %bpl
je 0x1582a
movq 0x30(%rbx), %rax
cmpq 0x10(%rbx), %rax
je 0x159b4
leaq 0x268(%rsp), %rdi
movq %rbx, %rsi
callq 0x164c1
movzbl 0xe0d56(%rip), %esi     # 0xf6549
leaq 0x268(%rsp), %rdi
callq 0x16557
leaq 0x278(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x156f8
movq 0x278(%rsp), %rsi
incq %rsi
callq 0x17920
jmp 0x156f8
leaq 0x198(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x188(%rsp), %rdi
callq 0x17038
leaq 0x178(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa5b06(%rip), %rsi     # 0xbb369
leaq 0xa5b07(%rip), %rdx     # 0xbb371
leaq 0x168(%rsp), %rdi
callq 0x1725c
leaq 0x188(%rsp), %rdi
leaq 0x168(%rsp), %rsi
callq 0x1616d
movl %eax, %ebp
movq 0x168(%rsp), %rdi
cmpq %r15, %rdi
je 0x158ab
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x17920
movq 0x188(%rsp), %rdi
cmpq %r14, %rdi
je 0x158c8
movq 0x198(%rsp), %rsi
incq %rsi
callq 0x17920
testb %bpl, %bpl
je 0x15900
movq 0x10(%rbx), %rax
cmpq %rax, 0x30(%rbx)
je 0x15ad1
movq (%rax), %rdi
callq 0x12420
movl %eax, %ebp
movq %rbx, %rdi
callq 0x17806
movzbl 0xe0c55(%rip), %esi     # 0xf6549
movl %ebp, %edi
callq 0x167a0
jmp 0x156f8
leaq 0x158(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x148(%rsp), %rdi
callq 0x17038
leaq 0x138(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa5a4e(%rip), %rsi     # 0xbb387
leaq 0xa5a4c(%rip), %rdx     # 0xbb38c
leaq 0x128(%rsp), %rdi
callq 0x1725c
leaq 0x148(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x1616d
movl %eax, %ebp
movq 0x128(%rsp), %rdi
cmpq %r15, %rdi
je 0x15981
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x17920
movq 0x148(%rsp), %rdi
cmpq %r14, %rdi
je 0x1599e
movq 0x158(%rsp), %rsi
incq %rsi
callq 0x17920
testb %bpl, %bpl
je 0x159ff
movzbl 0xe0b9f(%rip), %edi     # 0xf6549
callq 0x16a53
jmp 0x156f8
leaq 0xe1aa5(%rip), %r14     # 0xf7460
leaq 0xa5990(%rip), %rsi     # 0xbb352
movl $0x16, %edx
movq %r14, %rdi
callq 0x80a30
movq (%r14), %rax
addq -0x18(%rax), %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x61b80
movsbl %al, %esi
leaq 0xe1a73(%rip), %rdi     # 0xf7460
callq 0x80530
movq %rax, %rdi
callq 0x7fb00
jmp 0x156f8
leaq 0x118(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x108(%rsp), %rdi
callq 0x17038
leaq 0xf8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa5955(%rip), %rsi     # 0xbb38d
leaq 0xa5954(%rip), %rdx     # 0xbb393
leaq 0xe8(%rsp), %rdi
callq 0x1725c
leaq 0x108(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x1616d
movl %eax, %ebp
movq 0xe8(%rsp), %rdi
cmpq %r15, %rdi
je 0x15a80
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x17920
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0x15a9d
movq 0x118(%rsp), %rsi
incq %rsi
callq 0x17920
testb %bpl, %bpl
je 0x15b01
movq 0x10(%rbx), %rax
cmpq %rax, 0x30(%rbx)
je 0x15ad1
movq (%rax), %rdi
callq 0x12420
movl %eax, %ebp
movq %rbx, %rdi
callq 0x17806
movzbl 0xe0a84(%rip), %esi     # 0xf6549
movl %ebp, %edi
callq 0x168f0
jmp 0x156f8
movl $0x14, %r14d
leaq 0xa5894(%rip), %r15     # 0xbb372
leaq 0xe197b(%rip), %rdi     # 0xf7460
movq %r15, %rsi
movq %r14, %rdx
callq 0x80a30
leaq 0xe1969(%rip), %rdi     # 0xf7460
callq 0x80840
jmp 0x156f8
leaq 0xd8(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0xc8(%rsp), %rdi
callq 0x17038
leaq 0xb8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa585a(%rip), %rsi     # 0xbb394
leaq 0xa5858(%rip), %rdx     # 0xbb399
leaq 0xa8(%rsp), %rdi
callq 0x1725c
leaq 0xc8(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x1616d
movl %eax, %ebp
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x15b82
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x17920
movq 0xc8(%rsp), %rdi
cmpq %r14, %rdi
je 0x15b9f
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x17920
testb %bpl, %bpl
je 0x15bb5
movzbl 0xe099e(%rip), %edi     # 0xf6549
callq 0x16bc3
jmp 0x156f8
leaq 0x98(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x88(%rsp), %rdi
callq 0x17038
leaq 0x78(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa57af(%rip), %rsi     # 0xbb39a
leaq 0xa57af(%rip), %rdx     # 0xbb3a1
leaq 0x68(%rsp), %rdi
callq 0x1725c
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x1616d
movl %eax, %ebp
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x15c27
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x17920
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x15c44
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x17920
testb %bpl, %bpl
je 0x15c9e
leaq 0xe1810(%rip), %rdi     # 0xf7460
leaq 0xa574b(%rip), %rsi     # 0xbb3a2
movl $0x11, %edx
callq 0x80a30
leaq 0xe17f8(%rip), %rdi     # 0xf7460
leaq 0xa5745(%rip), %rsi     # 0xbb3b4
movl $0x5, %edx
callq 0x80a30
leaq 0xe17e0(%rip), %rdi     # 0xf7460
callq 0x80840
jmp 0x15c8f
movq %rbx, %rdi
callq 0x17806
movq 0x30(%rbx), %rax
cmpq 0x10(%rbx), %rax
jne 0x15c87
jmp 0x156f8
leaq 0x58(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
leaq 0x48(%rsp), %rdi
callq 0x17038
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0xa56ec(%rip), %rsi     # 0xbb3ba
leaq 0xa56e9(%rip), %rdx     # 0xbb3be
leaq 0x28(%rsp), %rdi
callq 0x1725c
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rsi
callq 0x1616d
movl %eax, %ebp
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x15d07
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x17920
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x15d1e
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x17920
movq 0x10(%rbx), %rax
movq 0x30(%rbx), %rcx
testb %bpl, %bpl
je 0x15d4c
cmpq %rax, %rcx
je 0x15d42
movq %rbx, %rdi
callq 0x17806
movq 0x30(%rbx), %rax
cmpq 0x10(%rbx), %rax
jne 0x15d30
callq 0x16018
jmp 0x156f8
movl $0x36, %r14d
leaq 0xa5666(%rip), %r15     # 0xbb3bf
cmpq %rax, %rcx
je 0x15ade
movq %rbx, %rdi
callq 0x17806
movq 0x30(%rbx), %rax
cmpq 0x10(%rbx), %rax
jne 0x15d62
jmp 0x15ade
movzbl %sil, %edi
callq 0x12720
jmp 0x15527
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x15da6
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x17920
jmp 0x15da6
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x15ff9
movq 0x58(%rsp), %rsi
jmp 0x15fec
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0x15ddd
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x17920
jmp 0x15ddd
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x15ff9
movq 0x98(%rsp), %rsi
jmp 0x15fec
jmp 0x15ff6
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r15, %rdi
je 0x15e25
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x17920
jmp 0x15e25
movq %rax, %rbx
movq 0xc8(%rsp), %rdi
cmpq %r14, %rdi
je 0x15ff9
movq 0xd8(%rsp), %rsi
jmp 0x15fec
movq %rax, %rbx
movq 0xe8(%rsp), %rdi
cmpq %r15, %rdi
je 0x15e68
movq 0xf8(%rsp), %rsi
incq %rsi
callq 0x17920
jmp 0x15e68
movq %rax, %rbx
movq 0x108(%rsp), %rdi
cmpq %r14, %rdi
je 0x15ff9
movq 0x118(%rsp), %rsi
jmp 0x15fec
jmp 0x15ff6
movq %rax, %rbx
movq 0x128(%rsp), %rdi
cmpq %r15, %rdi
je 0x15eb0
movq 0x138(%rsp), %rsi
incq %rsi
callq 0x17920
jmp 0x15eb0
movq %rax, %rbx
movq 0x148(%rsp), %rdi
cmpq %r14, %rdi
je 0x15ff9
movq 0x158(%rsp), %rsi
jmp 0x15fec
movq %rax, %rbx
leaq 0x278(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x15ff9
movq 0x278(%rsp), %rsi
jmp 0x15fec
movq %rax, %rbx
movq 0x168(%rsp), %rdi
cmpq %r15, %rdi
je 0x15f18
movq 0x178(%rsp), %rsi
incq %rsi
callq 0x17920
jmp 0x15f18
movq %rax, %rbx
movq 0x188(%rsp), %rdi
cmpq %r14, %rdi
je 0x15ff9
movq 0x198(%rsp), %rsi
jmp 0x15fec
movq %rax, %rbx
movq 0x1a8(%rsp), %rdi
cmpq %r15, %rdi
je 0x15f5b
movq 0x1b8(%rsp), %rsi
incq %rsi
callq 0x17920
jmp 0x15f5b
movq %rax, %rbx
movq 0x1c8(%rsp), %rdi
cmpq %r14, %rdi
je 0x15ff9
movq 0x1d8(%rsp), %rsi
jmp 0x15fec
movq %rax, %rbx
movq 0x1e8(%rsp), %rdi
cmpq %r15, %rdi
je 0x15f9b
movq 0x1f8(%rsp), %rsi
incq %rsi
callq 0x17920
jmp 0x15f9b
movq %rax, %rbx
movq 0x208(%rsp), %rdi
cmpq %r14, %rdi
je 0x15ff9
movq 0x218(%rsp), %rsi
jmp 0x15fec
movq %rax, %rbx
movq 0x228(%rsp), %rdi
cmpq %r15, %rdi
je 0x15fd7
movq 0x238(%rsp), %rsi
incq %rsi
callq 0x17920
jmp 0x15fd7
movq %rax, %rbx
movq 0x248(%rsp), %rdi
cmpq %r14, %rdi
je 0x15ff9
movq 0x258(%rsp), %rsi
incq %rsi
callq 0x17920
jmp 0x15ff9
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x16010
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x17920
movq %rbx, %rdi
callq 0xb8350