// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rsi, %r14
movq %rdi, %r15
leaq -0x108(%rbp), %rbx
movq %rbx, %rdi
callq 0x2290
movq %r15, -0x30(%rbp)
movq %r15, %rdi
movq %rbx, %rsi
callq 0x444a
movl %eax, %ebx
leaq -0x108(%rbp), %rdi
callq 0x20e0
cmpl $-0x1, %ebx
je 0x2e49
leaq -0x1a8(%rbp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x2290
movq -0x30(%rbp), %rdi
movq %r13, %rsi
callq 0x444a
movl %eax, %r15d
movq %r14, %rbx
leaq -0x188(%rbp), %r12
movq %r13, %rdi
callq 0x20e0
leaq -0x40(%rbp), %r14
testl %r15d, %r15d
je 0x2e6b
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2290
movq -0x30(%rbp), %rdi
movq %r12, %rsi
movl %r15d, %edx
callq 0x49b4
movl %eax, %r13d
movq %r12, %rdi
callq 0x20e0
testl %r13d, %r13d
je 0x2e80
leaq -0x168(%rbp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x2290
movq -0x30(%rbp), %rdi
movq %r13, %rsi
movl %r15d, %edx
callq 0x49b4
movl %eax, %r15d
jmp 0x2de8
movq 0x6178(%rip), %rdi      # 0x8fc8
leaq 0x32d6(%rip), %rsi      # 0x612d
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
xorl %eax, %eax
jmp 0x303c
movq %r14, -0x50(%rbp)
andq $0x0, -0x48(%rbp)
movb $0x0, -0x40(%rbp)
movq %rbx, %r14
jmp 0x2f30
movq %r14, -0x50(%rbp)
andq $0x0, -0x48(%rbp)
movb $0x0, -0x40(%rbp)
leaq -0xe8(%rbp), %rdi
movq %rbx, %r14
movq %rbx, %rsi
callq 0x2290
leaq -0xe8(%rbp), %rsi
leaq -0x50(%rbp), %rcx
movq -0x30(%rbp), %rdi
movl %r15d, %edx
callq 0x487c
leaq -0xe8(%rbp), %rdi
callq 0x20e0
leaq -0xc8(%rbp), %rdi
movq %r14, %rsi
callq 0x2290
leaq -0xc8(%rbp), %rsi
movq -0x30(%rbp), %rdi
movl %r15d, %edx
callq 0x478c
leaq -0xc8(%rbp), %rdi
callq 0x20e0
leaq -0x50(%rbp), %rbx
pushq $0x23
popq %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2270
leaq -0x88(%rbp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x2200
leaq -0x50(%rbp), %rdi
leaq -0x88(%rbp), %rbx
movq %rbx, %rsi
callq 0x2240
movq %rbx, %rdi
callq 0x20e0
leaq -0x78(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x6081(%rip), %rdi      # 0x8fc8
leaq 0x31f3(%rip), %rsi      # 0x6141
callq 0x21d0
movq %rax, %rdi
callq 0x20f0
movq 0x607e(%rip), %rdi      # 0x8fe0
leaq -0x88(%rbp), %rsi
callq 0x2060
leaq -0x50(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x2380
leaq -0xa8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x2290
movq -0x30(%rbp), %rdi
callq 0x51b4
leaq -0x68(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
movl %eax, %edx
callq 0x4216
leaq -0xa8(%rbp), %rdi
callq 0x20e0
xorl %ebx, %ebx
leaq -0x148(%rbp), %r15
leaq -0x128(%rbp), %r12
xorl %r13d, %r13d
movq -0x60(%rbp), %rax
subq -0x68(%rbp), %rax
sarq $0x5, %rax
cmpq %r13, %rax
jbe 0x301b
movq %r15, %rdi
movq %r14, %rsi
callq 0x2290
movq -0x68(%rbp), %rsi
addq %rbx, %rsi
movq %r12, %rdi
callq 0x2290
movq -0x30(%rbp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x45c6
movq %r12, %rdi
callq 0x20e0
movq %r15, %rdi
callq 0x20e0
incq %r13
addq $0x20, %rbx
jmp 0x2fc8
leaq -0x68(%rbp), %rdi
callq 0x25fc
leaq -0x88(%rbp), %rdi
callq 0x20e0
leaq -0x50(%rbp), %rdi
callq 0x20e0
pushq $0x1
popq %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x306e
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
jmp 0x30f3
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
jmp 0x30f3
movq %rax, %rbx
jmp 0x30f8
jmp 0x30a1
movq %rax, %rbx
leaq -0x1a8(%rbp), %rdi
jmp 0x30fc
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
jmp 0x30fc
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x20e0
jmp 0x30ec
movq %rax, %rbx
jmp 0x30ec
movq %rax, %rbx
leaq -0x168(%rbp), %rdi
jmp 0x30fc
movq %rax, %rbx
leaq -0x188(%rbp), %rdi
jmp 0x30fc
movq %rax, %rbx
leaq -0x128(%rbp), %rdi
callq 0x20e0
jmp 0x30d2
movq %rax, %rbx
leaq -0x148(%rbp), %rdi
callq 0x20e0
jmp 0x30e3
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x25fc
leaq -0x88(%rbp), %rdi
callq 0x20e0
leaq -0x50(%rbp), %rdi
callq 0x20e0
movq %rbx, %rdi
callq 0x2330
nop