// File: phillip-h[P]todo/src/args.cpp
// Function: renameList()
void renameList()
{
    TodoList *list = Core::list(name());
    if (!list->exists()){
        cout << ANSI_RED << "Todo List '" << list->name;
        cout << "' does not exist!\n" << ANSI_RESET;
        return;
    }
    
    string newName;
    cout << "Enter new list name, or an empty line to cancel > ";
    getline(cin, newName);
    if (newName.empty()){
        cout << "Canceling rename.\n";
        return;
    }
    
    if (remove(list->getPath().c_str()) != 0){
        cout << ANSI_RED << "Failed to remove list!\n" << ANSI_RESET;
        return;
    }
    
    string oldName = list->name;
    list->name = newName;
    if (list->exists()){
        cout << ANSI_RED << "List already exists!\n" << ANSI_RESET;
        list->name = oldName;
    } else{
       cout << "List renamed.\n"; 
    }
    
    list->save();    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
leaq -0x28(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x82a0
movq -0xb0(%rbp), %rdi
callq 0x9820
movq %rax, -0xa8(%rbp)
jmp 0x7910
leaq -0x28(%rbp), %rdi
callq 0x4738
movq -0xa8(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0xdd20
testb $0x1, %al
jne 0x79a4
movq 0x10690(%rip), %rdi     # 0x17fc8
leaq 0x10ba9(%rip), %rsi     # 0x184e8
callq 0x4300
movq %rax, %rdi
leaq 0xa998(%rip), %rsi      # 0x122e6
callq 0x4340
movq %rax, %rdi
movq -0x8(%rbp), %rsi
addq $0x8, %rsi
callq 0x4300
movq 0x1065e(%rip), %rdi     # 0x17fc8
leaq 0xa795(%rip), %rsi      # 0x12106
callq 0x4340
movq %rax, %rdi
leaq 0x10b48(%rip), %rsi     # 0x184c8
callq 0x4300
jmp 0x7bab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x4738
jmp 0x7bbd
leaq -0x58(%rbp), %rdi
callq 0x4500
movq 0x10614(%rip), %rdi     # 0x17fc8
leaq 0xa985(%rip), %rsi      # 0x12340
callq 0x4340
jmp 0x79c2
movq 0x10617(%rip), %rdi     # 0x17fe0
leaq -0x58(%rbp), %rsi
callq 0x40e0
jmp 0x79d4
leaq -0x58(%rbp), %rdi
callq 0x4630
testb $0x1, %al
jne 0x79e3
jmp 0x7a15
movq 0x105de(%rip), %rdi     # 0x17fc8
leaq 0xa982(%rip), %rsi      # 0x12373
callq 0x4340
jmp 0x79f8
movl $0x1, -0x5c(%rbp)
jmp 0x7ba2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
jmp 0x7bb4
movq -0x8(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0xd7b0
jmp 0x7a24
leaq -0x80(%rbp), %rdi
callq 0x41b0
movq %rax, %rdi
callq 0x46b0
movl %eax, -0xb4(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x4738
movl -0xb4(%rbp), %eax
cmpl $0x0, %eax
je 0x7aa8
movq 0x10572(%rip), %rdi     # 0x17fc8
leaq 0x10a8b(%rip), %rsi     # 0x184e8
callq 0x4300
movq %rax, -0xc0(%rbp)
jmp 0x7a6b
movq -0xc0(%rbp), %rdi
leaq 0xa8a0(%rip), %rsi      # 0x12319
callq 0x4340
movq %rax, -0xc8(%rbp)
jmp 0x7a87
movq -0xc8(%rbp), %rdi
leaq 0x10a33(%rip), %rsi     # 0x184c8
callq 0x4300
jmp 0x7a9c
movl $0x1, -0x5c(%rbp)
jmp 0x7ba2
movq -0x8(%rbp), %rsi
addq $0x8, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x41c0
jmp 0x7abe
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
leaq -0x58(%rbp), %rsi
callq 0x4060
jmp 0x7ad1
movq -0x8(%rbp), %rdi
callq 0xdd20
movb %al, -0xc9(%rbp)
jmp 0x7ae2
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x7aee
jmp 0x7b6d
movq 0x104d3(%rip), %rdi     # 0x17fc8
leaq 0x109ec(%rip), %rsi     # 0x184e8
callq 0x4300
movq %rax, -0xd8(%rbp)
jmp 0x7b0a
movq -0xd8(%rbp), %rdi
leaq 0xa86e(%rip), %rsi      # 0x12386
callq 0x4340
movq %rax, -0xe0(%rbp)
jmp 0x7b26
movq -0xe0(%rbp), %rdi
leaq 0x10994(%rip), %rsi     # 0x184c8
callq 0x4300
jmp 0x7b3b
movq -0x8(%rbp), %rdi
addq $0x8, %rdi
leaq -0xa0(%rbp), %rsi
callq 0x4060
jmp 0x7b51
jmp 0x7b84
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x4738
jmp 0x7bb4
movq 0x10454(%rip), %rdi     # 0x17fc8
leaq 0xa821(%rip), %rsi      # 0x1239c
callq 0x4340
jmp 0x7b82
jmp 0x7b84
movq -0x8(%rbp), %rdi
callq 0xd480
jmp 0x7b8f
leaq -0xa0(%rbp), %rdi
callq 0x4738
movl $0x0, -0x5c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4738
addq $0xe0, %rsp
popq %rbp
retq
leaq -0x58(%rbp), %rdi
callq 0x4738
movq -0x30(%rbp), %rdi
callq 0x4680
nopw %cs:(%rax,%rax)