// File: /workspace/github_cpp_makefile_star2_O2/zimpha[P]MiniSQL/RecordManager.cc
// Function: RecordManager::RecordManagerRecordDelete(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, long, Filter const&, Table&)
void RecordManager::RecordManagerRecordDelete(std::string dbName, long offset, const Filter & filter, Table & nt)
{
    bufferIter pBlock;
    std::vector<element> queryTuple;
    int tupleSize = nt.entrySize + 1;

    pBlock = bm.BufferManagerRead(dbName, offset);
    Block & block = *pBlock;
    int endPoint = getInt(block, BLOCKSIZE - 4);
    int tuple;
    int startPos;
    for (tuple = 0; tuple <= endPoint - tupleSize; tuple += tupleSize) {
        if (block.data[tuple] == 'N')
            continue;
        startPos = tuple + 1;
        queryTuple.clear();
        for (auto attr : nt.attributes) {
            switch (attr.type) {
                case 0:
                    queryTuple.push_back(element(getInt(block, startPos)));
                    startPos += sizeof(int);
                    break;
                case 1:
                    queryTuple.push_back(element(getFloat(block, startPos)));
                    startPos += sizeof(float);
                    break;
                case 2:
                    queryTuple.push_back(element(getString(block, startPos)));
                    startPos += attr.length;//Include +1
                    break;
                default:
                    break;
            }
        }
        if (true == filter.test(queryTuple)) {
            block.data[tuple] = 'N';
            std::string tableName = dbName.substr(0, dbName.find('.'));
            for (int i = 0; i < nt.attributes.size(); i++) {
                for (auto index : nt.attributes[i].indices) {
                    im.erase(tableName + "." + nt.attributes[i].name, queryTuple[i]);

                }
            }
        }
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rcx, -0x70(%rbp)
andq $0x0, -0x50(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movq %r8, -0x40(%rbp)
movl (%r8), %ebx
movq %rdi, -0x90(%rbp)
movq (%rdi), %rdi
movq %rsi, -0x68(%rbp)
callq 0x7a04
incl %ebx
addq $0x10, %rax
movq %rax, -0x38(%rbp)
movq %rax, %rsi
movl $0xffc, %edx            # imm = 0xFFC
callq 0xea9c
subl %ebx, %eax
movslq %ebx, %rcx
movq %rcx, -0x78(%rbp)
cltq
movq %rax, -0x80(%rbp)
xorl %r13d, %r13d
cmpq -0x80(%rbp), %r13
jg 0xf2ed
movq -0x38(%rbp), %rax
cmpb $0x4e, (%rax,%r13)
je 0xf2e4
leaq -0x60(%rbp), %rdi
callq 0xf6ac
movq -0x40(%rbp), %rax
movq 0x28(%rax), %rsi
movq 0x30(%rax), %rbx
leal 0x1(%r13), %eax
movl %eax, -0x30(%rbp)
cmpq %rbx, %rsi
je 0xf180
leaq -0x168(%rbp), %rdi
movq %rsi, %r15
callq 0xc260
movl -0x148(%rbp), %eax
testl %eax, %eax
je 0xf12f
cmpl $0x1, %eax
je 0xf106
cmpl $0x2, %eax
jne 0xf168
leaq -0x108(%rbp), %r12
movq %r12, %rdi
movq -0x38(%rbp), %rdx
movl -0x30(%rbp), %ecx
callq 0xead0
leaq -0xc8(%rbp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0xfb80
leaq -0x60(%rbp), %rdi
movq %r14, %rsi
callq 0xe8a2
leaq -0xc0(%rbp), %rdi
callq 0x34f8
leaq -0x108(%rbp), %rdi
callq 0x34f8
movl -0x30(%rbp), %eax
addl -0x144(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0xf168
movq -0x38(%rbp), %rsi
movl -0x30(%rbp), %edx
callq 0xeab4
leaq -0xc8(%rbp), %r14
movq %r14, %rdi
callq 0xfb34
leaq -0x60(%rbp), %rdi
movq %r14, %rsi
callq 0xe8a2
jmp 0xf158
movq -0x38(%rbp), %rsi
movl -0x30(%rbp), %edx
callq 0xea9c
leaq -0xc8(%rbp), %r14
movq %r14, %rdi
movl %eax, %esi
callq 0xfb16
leaq -0x60(%rbp), %rdi
movq %r14, %rsi
callq 0xe8a2
leaq -0xc0(%rbp), %rdi
callq 0x34f8
addl $0x4, -0x30(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x684c
movq %r15, %rsi
addq $0x60, %rsi
jmp 0xf078
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xc5f4
testb %al, %al
je 0xf2e4
movq -0x38(%rbp), %rax
movb $0x4e, (%rax,%r13)
movq -0x68(%rbp), %rbx
movq %rbx, %rdi
pushq $0x2e
popq %rsi
xorl %edx, %edx
callq 0x3350
leaq -0x168(%rbp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x32b0
xorl %edi, %edi
leaq -0xc8(%rbp), %r12
movq %r13, -0x88(%rbp)
movq -0x40(%rbp), %rax
movq 0x28(%rax), %rcx
movq 0x30(%rax), %rax
subq %rcx, %rax
cqto
pushq $0x60
popq %rsi
idivq %rsi
cmpq %rdi, %rax
jbe 0xf2d8
movq %rdi, -0x30(%rbp)
imulq $0x60, %rdi, %rax
movq %rax, -0x98(%rbp)
leaq (%rcx,%rax), %r14
addq $0x38, %r14
movq 0x10(%r14), %rbx
cmpq %r14, %rbx
je 0xf2c5
leaq 0x20(%rbx), %rsi
movq %r12, %rdi
callq 0x3380
movq -0x90(%rbp), %rax
movq 0x8(%rax), %r12
leaq -0xe8(%rbp), %r15
movq %r15, %rdi
leaq -0x168(%rbp), %rsi
leaq 0x2060(%rip), %rdx      # 0x112a6
callq 0x5d7d
movq -0x40(%rbp), %rax
movq 0x28(%rax), %rdx
addq -0x98(%rbp), %rdx
leaq -0x188(%rbp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x5dd8
imulq $0x30, -0x30(%rbp), %rcx
addq -0x60(%rbp), %rcx
leaq -0x1c8(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x9bfe
movq %r15, %rdi
callq 0x5e02
movq %r13, %rdi
callq 0x34f8
leaq -0xe8(%rbp), %rdi
callq 0x34f8
leaq -0xc8(%rbp), %r12
movq %r12, %rdi
callq 0x34f8
movq %rbx, %rdi
callq 0x32f0
movq %rax, %rbx
jmp 0xf20e
movq -0x30(%rbp), %rdi
incq %rdi
movq -0x88(%rbp), %r13
jmp 0xf1d3
leaq -0x168(%rbp), %rdi
callq 0x34f8
addq -0x78(%rbp), %r13
jmp 0xf043
leaq -0x60(%rbp), %rdi
callq 0x6dc8
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf353
jmp 0xf353
jmp 0xf353
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0x34f8
jmp 0xf322
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
jmp 0xf33b
jmp 0xf342
jmp 0xf331
jmp 0xf342
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
callq 0x34f8
jmp 0xf345
movq %rax, %rbx
leaq -0x168(%rbp), %rdi
callq 0x684c
jmp 0xf39a
movq %rax, %rbx
jmp 0xf39a
movq %rax, %rbx
jmp 0xf38e
movq %rax, %rbx
jmp 0xf382
movq %rax, %rbx
jmp 0xf376
movq %rax, %rbx
leaq -0x188(%rbp), %rdi
callq 0x34f8
leaq -0xe8(%rbp), %rdi
callq 0x34f8
leaq -0xc8(%rbp), %rdi
callq 0x34f8
leaq -0x168(%rbp), %rdi
callq 0x34f8
leaq -0x60(%rbp), %rdi
callq 0x6dc8
movq %rbx, %rdi
callq 0x3450
nop