// File: RC2K7[P]SDisk-FileSystem/shell.cpp
// Function: Shell::copy(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int Shell::copy(string src, string dest)
{
    if (this->getFirstBlock(src) == -1) {
        cout << "Could Not Find Source File!" << endl;
        return 0;
    } else if (this->getFirstBlock(dest) >= 0) {
        cout << "Destination File Already Exists!" << endl;
        return 0;
    }

    if (this->newFile(dest) == 0) {
        cout << "Could Not Create File" << endl;
        return 0;
    }

    string buffer = "";
    for (int curBlock = this->getFirstBlock(src); curBlock != 0; curBlock = this->nextBlock(src, curBlock)) {
        this->readBlock(src, curBlock, buffer);
        this->addBlock(dest, buffer);
    }

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rsi, -0x180(%rbp)
movq %rdx, -0x178(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x170(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x3100
movq -0x170(%rbp), %rdi
movq -0x168(%rbp), %rsi
callq 0x7a10
movl %eax, -0x15c(%rbp)
jmp 0x554b
leaq -0x40(%rbp), %rdi
callq 0x3170
movl -0x15c(%rbp), %eax
cmpl $-0x1, %eax
jne 0x55a7
movq 0x8a62(%rip), %rdi      # 0xdfc8
leaq 0x4b6d(%rip), %rsi      # 0xa0da
callq 0x3280
movq %rax, %rdi
movq 0x8a3c(%rip), %rsi      # 0xdfb8
callq 0x32c0
movl $0x0, -0x4(%rbp)
jmp 0x5925
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x3170
jmp 0x5931
movq -0x178(%rbp), %rsi
leaq -0x70(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x3100
movq -0x170(%rbp), %rdi
movq -0x190(%rbp), %rsi
callq 0x7a10
movl %eax, -0x184(%rbp)
jmp 0x55d9
leaq -0x70(%rbp), %rdi
callq 0x3170
movl -0x184(%rbp), %eax
cmpl $0x0, %eax
jl 0x5635
movq 0x89d4(%rip), %rdi      # 0xdfc8
leaq 0x4afb(%rip), %rsi      # 0xa0f6
callq 0x3280
movq %rax, %rdi
movq 0x89ae(%rip), %rsi      # 0xdfb8
callq 0x32c0
movl $0x0, -0x4(%rbp)
jmp 0x5925
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x3170
jmp 0x5931
jmp 0x5637
movq -0x178(%rbp), %rsi
leaq -0x90(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x3100
movq -0x170(%rbp), %rdi
movq -0x1a0(%rbp), %rsi
callq 0x7880
movl %eax, -0x194(%rbp)
jmp 0x566c
leaq -0x90(%rbp), %rdi
callq 0x3170
movl -0x194(%rbp), %eax
cmpl $0x0, %eax
jne 0x56ce
movq 0x893e(%rip), %rdi      # 0xdfc8
leaq 0x4a86(%rip), %rsi      # 0xa117
callq 0x3280
movq %rax, %rdi
movq 0x8918(%rip), %rsi      # 0xdfb8
callq 0x32c0
movl $0x0, -0x4(%rbp)
jmp 0x5925
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x3170
jmp 0x5931
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x1a8(%rbp)
callq 0x3480
movq -0x1a8(%rbp), %rdx
leaq 0x49cd(%rip), %rsi      # 0xa0bc
leaq -0xb0(%rbp), %rdi
callq 0x3750
jmp 0x56fd
leaq -0xb1(%rbp), %rdi
callq 0x32e0
movq -0x180(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
callq 0x3100
jmp 0x571e
movq -0x170(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x7a10
movl %eax, -0x1ac(%rbp)
jmp 0x5739
leaq -0xd8(%rbp), %rdi
callq 0x3170
movl -0x1ac(%rbp), %eax
movl %eax, -0xb8(%rbp)
cmpl $0x0, -0xb8(%rbp)
je 0x5902
movq -0x180(%rbp), %rsi
leaq -0xf8(%rbp), %rdi
callq 0x3100
jmp 0x5773
movq -0x170(%rbp), %rdi
movl -0xb8(%rbp), %edx
leaq -0xf8(%rbp), %rsi
leaq -0xb0(%rbp), %rcx
callq 0x8310
jmp 0x5795
leaq -0xf8(%rbp), %rdi
callq 0x3170
movq -0x178(%rbp), %rsi
leaq -0x118(%rbp), %rdi
callq 0x3100
jmp 0x57b6
leaq -0x138(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3100
jmp 0x57cb
movq -0x170(%rbp), %rdi
leaq -0x118(%rbp), %rsi
leaq -0x138(%rbp), %rdx
callq 0x7c60
jmp 0x57e7
leaq -0x138(%rbp), %rdi
callq 0x3170
leaq -0x118(%rbp), %rdi
callq 0x3170
movq -0x180(%rbp), %rsi
leaq -0x158(%rbp), %rdi
callq 0x3100
jmp 0x5814
movq -0x170(%rbp), %rdi
movl -0xb8(%rbp), %edx
leaq -0x158(%rbp), %rsi
callq 0x8540
movl %eax, -0x1b0(%rbp)
jmp 0x5835
movl -0x1b0(%rbp), %eax
movl %eax, -0xb8(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x3170
jmp 0x5751
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xb1(%rbp), %rdi
callq 0x32e0
jmp 0x5931
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x5917
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xd8(%rbp), %rdi
callq 0x3170
jmp 0x5917
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x3170
jmp 0x5917
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x58da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x3170
leaq -0x118(%rbp), %rdi
callq 0x3170
jmp 0x5917
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x3170
jmp 0x5917
movl $0x1, -0x4(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3170
jmp 0x5925
leaq -0xb0(%rbp), %rdi
callq 0x3170
jmp 0x5931
movl -0x4(%rbp), %eax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
movq -0x48(%rbp), %rdi
callq 0x3470
nopw (%rax,%rax)