// File: RC2K7[P]SDisk-FileSystem/shell.cpp
// Function: Shell::append(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int Shell::append(string fileName)
{
    if (getFirstBlock(fileName) == -1) {
        cout << "Could Not Find File" << endl;
        return 0;
    }

    int lastBlock;
    for (lastBlock = this->getFirstBlock(fileName); lastBlock != 0 && this->nextBlock(fileName, lastBlock) != 0; lastBlock = nextBlock(fileName, lastBlock)) ;

    string totalBuffer;
    if (lastBlock != 0) {
        this->readBlock(fileName, lastBlock, totalBuffer);
        this->delBlock(fileName, lastBlock);
        totalBuffer = totalBuffer.substr(0, totalBuffer.find_first_of('#'));
    }

    string buffer;
    cout << "Enter Data:" << endl;
    getline(cin, buffer);
    totalBuffer += buffer;

    vector<string> blocks = block(totalBuffer, this->getBlockSize());

    for (int i = 0; i < blocks.size(); i++)
        this->addBlock(fileName, blocks[i]);

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movq %rsi, -0x1f0(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1e8(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x3100
movq -0x1e8(%rbp), %rdi
movq -0x1e0(%rbp), %rsi
callq 0x7a10
movl %eax, -0x1d4(%rbp)
jmp 0x4aa0
leaq -0x38(%rbp), %rdi
callq 0x3170
movl -0x1d4(%rbp), %eax
cmpl $-0x1, %eax
jne 0x4afc
movq 0x950d(%rip), %rdi      # 0xdfc8
leaq 0x566b(%rip), %rsi      # 0xa12d
callq 0x3280
movq %rax, %rdi
movq 0x94e7(%rip), %rsi      # 0xdfb8
callq 0x32c0
movl $0x0, -0x4(%rbp)
jmp 0x4ff9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x3170
jmp 0x5005
movq -0x1f0(%rbp), %rsi
leaq -0x68(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x3100
movq -0x1e8(%rbp), %rdi
movq -0x200(%rbp), %rsi
callq 0x7a10
movl %eax, -0x1f4(%rbp)
jmp 0x4b2e
movl -0x1f4(%rbp), %eax
movl %eax, -0x48(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x3170
movl -0x48(%rbp), %ecx
movb $0x0, -0x89(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x201(%rbp)
je 0x4ba8
movq -0x1f0(%rbp), %rsi
leaq -0x88(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0x3100
movq -0x1e8(%rbp), %rdi
movq -0x210(%rbp), %rsi
movb $0x1, -0x89(%rbp)
movl -0x48(%rbp), %edx
callq 0x8540
movl %eax, -0x208(%rbp)
jmp 0x4b96
movl -0x208(%rbp), %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x201(%rbp)
movb -0x201(%rbp), %al
movb %al, -0x211(%rbp)
testb $0x1, -0x89(%rbp)
jne 0x4bbf
jmp 0x4bcb
leaq -0x88(%rbp), %rdi
callq 0x3170
movb -0x211(%rbp), %al
testb $0x1, %al
jne 0x4bda
jmp 0x4c8d
jmp 0x4bdc
movq -0x1f0(%rbp), %rsi
leaq -0xb0(%rbp), %rdi
movq %rdi, -0x220(%rbp)
callq 0x3100
movq -0x1e8(%rbp), %rdi
movq -0x220(%rbp), %rsi
movl -0x48(%rbp), %edx
callq 0x8540
movl %eax, -0x218(%rbp)
jmp 0x4c14
movl -0x218(%rbp), %eax
movl %eax, -0x48(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3170
jmp 0x4b40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x3170
jmp 0x5005
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
testb $0x1, -0x89(%rbp)
jne 0x4c5f
jmp 0x4c6b
leaq -0x88(%rbp), %rdi
callq 0x3170
jmp 0x5005
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x3170
jmp 0x5005
leaq -0xd0(%rbp), %rdi
callq 0x33e0
cmpl $0x0, -0x48(%rbp)
je 0x4dca
movq -0x1f0(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x3100
jmp 0x4cb8
movq -0x1e8(%rbp), %rdi
movl -0x48(%rbp), %edx
leaq -0xf0(%rbp), %rsi
leaq -0xd0(%rbp), %rcx
callq 0x8310
jmp 0x4cd7
leaq -0xf0(%rbp), %rdi
callq 0x3170
movq -0x1f0(%rbp), %rsi
leaq -0x110(%rbp), %rdi
callq 0x3100
jmp 0x4cf8
movq -0x1e8(%rbp), %rdi
movl -0x48(%rbp), %edx
leaq -0x110(%rbp), %rsi
callq 0x80a0
jmp 0x4d10
leaq -0x110(%rbp), %rdi
callq 0x3170
xorl %eax, %eax
movl %eax, %edx
movq %rdx, -0x228(%rbp)
leaq -0xd0(%rbp), %rdi
movq %rdi, -0x230(%rbp)
movl $0x23, %esi
callq 0x3190
movq -0x230(%rbp), %rsi
movq -0x228(%rbp), %rdx
movq %rax, %rcx
leaq -0x130(%rbp), %rdi
callq 0x32b0
jmp 0x4d5e
leaq -0xd0(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x3360
leaq -0x130(%rbp), %rdi
callq 0x3170
jmp 0x4dca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x4feb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x3170
jmp 0x4feb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x3170
jmp 0x4feb
leaq -0x150(%rbp), %rdi
callq 0x33e0
movq 0x91eb(%rip), %rdi      # 0xdfc8
leaq 0x535d(%rip), %rsi      # 0xa141
callq 0x3280
movq %rax, -0x238(%rbp)
jmp 0x4df2
movq -0x238(%rbp), %rdi
movq 0x91b8(%rip), %rsi      # 0xdfb8
callq 0x32c0
jmp 0x4e07
movq 0x91d2(%rip), %rdi      # 0xdfe0
leaq -0x150(%rbp), %rsi
callq 0x3090
jmp 0x4e1c
leaq -0xd0(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x33a0
jmp 0x4e31
leaq -0x188(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x3100
jmp 0x4e46
movq -0x1e8(%rbp), %rdi
callq 0x9bf0
movl %eax, -0x23c(%rbp)
jmp 0x4e5a
movl -0x23c(%rbp), %edx
leaq -0x168(%rbp), %rdi
leaq -0x188(%rbp), %rsi
callq 0x76a0
jmp 0x4e75
leaq -0x188(%rbp), %rdi
callq 0x3170
movl $0x0, -0x18c(%rbp)
movslq -0x18c(%rbp), %rax
movq %rax, -0x248(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x5a60
movq %rax, %rcx
movq -0x248(%rbp), %rax
cmpq %rcx, %rax
jae 0x4fa6
movq -0x1f0(%rbp), %rsi
leaq -0x1b0(%rbp), %rdi
callq 0x3100
jmp 0x4ecd
movslq -0x18c(%rbp), %rsi
leaq -0x168(%rbp), %rdi
callq 0x5a80
movq %rax, %rsi
leaq -0x1d0(%rbp), %rdi
callq 0x3100
jmp 0x4ef1
movq -0x1e8(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
leaq -0x1d0(%rbp), %rdx
callq 0x7c60
jmp 0x4f0d
leaq -0x1d0(%rbp), %rdi
callq 0x3170
leaq -0x1b0(%rbp), %rdi
callq 0x3170
movl -0x18c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18c(%rbp)
jmp 0x4e8b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x4fdf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x3170
jmp 0x4fdf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x4fd3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x4f98
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x3170
leaq -0x1b0(%rbp), %rdi
callq 0x3170
jmp 0x4fd3
movl $0x1, -0x4(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x38d0
leaq -0x150(%rbp), %rdi
callq 0x3170
leaq -0xd0(%rbp), %rdi
callq 0x3170
jmp 0x4ff9
leaq -0x168(%rbp), %rdi
callq 0x38d0
leaq -0x150(%rbp), %rdi
callq 0x3170
leaq -0xd0(%rbp), %rdi
callq 0x3170
jmp 0x5005
movl -0x4(%rbp), %eax
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x3470
nop