// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdx, -0x38(%rbp)
movq %rdi, %r15
leaq -0x120(%rbp), %rbx
movq %rbx, %rdi
movq %rsi, -0x40(%rbp)
callq 0x2290
movq %r15, %rdi
movq %rbx, %rsi
callq 0x444a
movl %eax, %ebx
leaq -0x120(%rbp), %rdi
callq 0x20e0
cmpl $-0x1, %ebx
je 0x3450
leaq -0x100(%rbp), %rbx
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
callq 0x2290
movq %r15, %rdi
movq %rbx, %rsi
callq 0x444a
movl %eax, %ebx
leaq -0x100(%rbp), %rdi
callq 0x20e0
testl %ebx, %ebx
js 0x347f
movq 0x5b81(%rip), %rdi      # 0x8fc8
leaq 0x2ca8(%rip), %rsi      # 0x60f6
jmp 0x345e
movq 0x5b71(%rip), %rdi      # 0x8fc8
leaq 0x2c7c(%rip), %rsi      # 0x60da
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
xorl %eax, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq -0xe0(%rbp), %rbx
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
callq 0x2290
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4346
movl %eax, %ebx
leaq -0xe0(%rbp), %rdi
callq 0x20e0
testl %ebx, %ebx
je 0x35ad
leaq 0x2c02(%rip), %rsi      # 0x60bc
leaq -0x60(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x258e
leaq -0xc0(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2290
leaq -0xc0(%rbp), %r13
movq %r15, %rdi
movq %r13, %rsi
callq 0x444a
movl %eax, %r12d
leaq -0x160(%rbp), %r14
leaq -0x140(%rbp), %rbx
movq %r13, %rdi
callq 0x20e0
testl %r12d, %r12d
je 0x359c
leaq -0xa0(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x2290
movq %r15, %rdi
leaq -0xa0(%rbp), %r13
movq %r13, %rsi
movl %r12d, %edx
leaq -0x60(%rbp), %rcx
callq 0x487c
movq %r13, %rdi
callq 0x20e0
leaq -0x80(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x2290
movq %r14, %rdi
leaq -0x60(%rbp), %rsi
callq 0x2290
movq %r15, %rdi
leaq -0x80(%rbp), %r13
movq %r13, %rsi
movq %r14, %rdx
callq 0x45c6
movq %r14, %rdi
callq 0x20e0
movq %r13, %rdi
callq 0x20e0
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
callq 0x2290
movq %r15, %rdi
movq %rbx, %rsi
movl %r12d, %edx
callq 0x49b4
movl %eax, %r12d
movq %rbx, %r13
jmp 0x34fa
leaq -0x60(%rbp), %rdi
callq 0x20e0
pushq $0x1
popq %rax
jmp 0x346d
movq 0x5a14(%rip), %rdi      # 0x8fc8
leaq 0x2b5c(%rip), %rsi      # 0x6117
jmp 0x345e
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
jmp 0x3627
jmp 0x362e
movq %rax, %rbx
jmp 0x363a
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
jmp 0x3635
movq %rax, %rbx
leaq -0x100(%rbp), %rdi
jmp 0x3635
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
jmp 0x3635
movq %rax, %rbx
leaq -0x140(%rbp), %rdi
jmp 0x3627
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
jmp 0x3627
movq %rax, %rbx
jmp 0x3623
movq %rax, %rbx
leaq -0x160(%rbp), %rdi
callq 0x20e0
leaq -0x80(%rbp), %rdi
callq 0x20e0
jmp 0x3631
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x20e0
movq %rbx, %rdi
callq 0x2330