// File: /workspace/github_cpp_makefile_star2_O1/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, %r14
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movq $0x0, -0x50(%rbp)
movq %r8, -0x40(%rbp)
movl (%r8), %ebx
movq %rdi, -0x108(%rbp)
movq (%rdi), %rdi
movq %rsi, -0xe8(%rbp)
callq 0x9384
incl %ebx
movl 0x100c(%rax), %ecx
subl %ebx, %ecx
js 0x1265e
addq $0x10, %rax
movslq %ebx, %rdx
movq %rdx, -0x100(%rbp)
movl %ecx, %ecx
movq %rcx, -0xf8(%rbp)
xorl %ecx, %ecx
leaq -0xa0(%rbp), %r13
movq %r14, -0xf0(%rbp)
movq %rax, -0x38(%rbp)
cmpb $0x4e, (%rax,%rcx)
je 0x1264a
movq %rcx, -0x68(%rbp)
movq -0x60(%rbp), %rbx
movq -0x58(%rbp), %r14
cmpq %rbx, %r14
je 0x1225d
movq %rbx, %r15
movq 0x8(%r15), %rdi
leaq 0x18(%r15), %rax
cmpq %rdi, %rax
je 0x12250
callq 0x3270
addq $0x30, %r15
cmpq %r14, %r15
jne 0x1223e
movq %rbx, -0x58(%rbp)
movq -0x40(%rbp), %rax
movq 0x28(%rax), %r15
movq 0x30(%rax), %rax
movq %rax, -0x70(%rbp)
cmpq %rax, %r15
leaq -0x178(%rbp), %rbx
leaq -0x118(%rbp), %r14
je 0x123f7
movq -0x68(%rbp), %rax
incl %eax
movl %eax, -0x30(%rbp)
movq %rbx, -0x188(%rbp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0x188(%rbp), %rdi
callq 0x8766
movb 0x28(%r15), %al
movb %al, 0x18(%rbx)
movq 0x20(%r15), %rax
movq %rax, 0x10(%rbx)
addq $0x30, %r15
leaq -0x158(%rbp), %rdi
movq %r15, %rsi
callq 0xe992
movl -0x168(%rbp), %eax
testl %eax, %eax
je 0x12391
cmpl $0x1, %eax
je 0x1236e
cmpl $0x2, %eax
jne 0x123cc
movslq -0x30(%rbp), %r13
addq -0x38(%rbp), %r13
movq %r13, %rdi
callq 0x3110
movq %r14, -0x128(%rbp)
leaq (%rax,%r13), %rdx
leaq -0x128(%rbp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x8800
leaq -0xa0(%rbp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x131fa
leaq -0x60(%rbp), %rdi
movq %r13, %rsi
callq 0x1193a
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x1234f
callq 0x3270
movq -0x128(%rbp), %rdi
cmpq %r14, %rdi
je 0x12360
callq 0x3270
movl -0x30(%rbp), %eax
addl -0x164(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x123cc
movslq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movss (%rcx,%rax), %xmm0
movq %r13, %rdi
callq 0x131aa
leaq -0x60(%rbp), %rdi
movq %r13, %rsi
callq 0x1193a
jmp 0x123b0
movslq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movl (%rcx,%rax), %esi
movq %r13, %rdi
callq 0x13186
leaq -0x60(%rbp), %rdi
movq %r13, %rsi
callq 0x1193a
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x123c8
callq 0x3270
addl $0x4, -0x30(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x8372
movq -0x188(%rbp), %rdi
cmpq %rbx, %rdi
je 0x123e9
callq 0x3270
addq $0x30, %r15
cmpq -0x70(%rbp), %r15
jne 0x1228d
movq -0xf0(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0xed9a
testb %al, %al
movq -0x38(%rbp), %rax
movq -0x68(%rbp), %rcx
je 0x1264a
movb $0x4e, (%rax,%rcx)
movq -0xe8(%rbp), %rbx
movq %rbx, %rdi
movl $0x2e, %esi
xorl %edx, %edx
callq 0x3370
leaq -0x188(%rbp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rax, %rcx
callq 0x32c0
movq -0x40(%rbp), %rcx
movq 0x28(%rcx), %rax
cmpq %rax, 0x30(%rcx)
je 0x1262a
xorl %esi, %esi
movq %rsi, -0x70(%rbp)
leaq (%rsi,%rsi,2), %rbx
movq %rbx, -0x30(%rbp)
shlq $0x5, %rbx
leaq (%rax,%rbx), %r14
addq $0x38, %r14
movq 0x10(%r14), %r15
cmpq %r14, %r15
je 0x125f9
leaq -0x90(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq 0x20(%r15), %rsi
movq 0x28(%r15), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x8766
movq -0x108(%rbp), %rax
movq 0x8(%rax), %r13
leaq -0xd0(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x188(%rbp), %rsi
movq -0x180(%rbp), %rdx
addq %rsi, %rdx
leaq -0xe0(%rbp), %r12
movq %r12, %rdi
callq 0x8766
movq %r12, %rdi
leaq 0x1dee(%rip), %rsi      # 0x142d0
callq 0x34f0
movq -0x40(%rbp), %rax
movq 0x28(%rax), %rax
movq (%rax,%rbx), %rsi
movq 0x8(%rax,%rbx), %rdx
movq %r12, %rdi
callq 0x30c0
leaq -0xb0(%rbp), %rsi
movq %rsi, -0xc0(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x12530
movq %rdx, -0xc0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xb0(%rbp)
jmp 0x12536
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0xb8(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x30(%rbp), %rcx
shlq $0x4, %rcx
addq -0x60(%rbp), %rcx
leaq -0x1c8(%rbp), %rdi
movq %r13, %rsi
leaq -0xc0(%rbp), %rdx
callq 0xc1e2
leaq -0x1a0(%rbp), %rdi
callq 0x7926
movq -0x1c0(%rbp), %rdi
leaq -0x1b0(%rbp), %rax
cmpq %rax, %rdi
je 0x12596
callq 0x3270
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
leaq -0xa0(%rbp), %r13
je 0x125b5
callq 0x3270
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x125cd
callq 0x3270
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x125e5
callq 0x3270
movq %r15, %rdi
callq 0x3320
movq %rax, %r15
cmpq %r14, %rax
jne 0x1247e
movq -0x70(%rbp), %rsi
incq %rsi
movq -0x40(%rbp), %rcx
movq 0x28(%rcx), %rax
movq 0x30(%rcx), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rcx
cmpq %rsi, %rcx
ja 0x12459
movq -0x188(%rbp), %rdi
leaq -0x178(%rbp), %rax
cmpq %rax, %rdi
je 0x12642
callq 0x3270
movq -0x38(%rbp), %rax
movq -0x68(%rbp), %rcx
addq -0x100(%rbp), %rcx
cmpq -0xf8(%rbp), %rcx
jle 0x12220
leaq -0x60(%rbp), %rdi
callq 0x889a
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x126eb
jmp 0x126eb
jmp 0x126eb
movq %rax, %rbx
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x1269a
callq 0x3270
leaq -0x118(%rbp), %r14
jmp 0x126a6
movq %rax, %rbx
movq -0x128(%rbp), %rdi
cmpq %r14, %rdi
jne 0x126d0
jmp 0x126da
jmp 0x126d7
jmp 0x126ba
jmp 0x126d7
movq %rax, %rbx
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x126da
callq 0x3270
jmp 0x126da
movq %rax, %rbx
leaq -0x188(%rbp), %rdi
callq 0xe618
jmp 0x1277b
movq %rax, %rbx
jmp 0x1277b
movq %rbx, %rcx
movq %rax, %rbx
movq -0x188(%rbp), %rdi
cmpq %rcx, %rdi
jne 0x12776
jmp 0x1277b
movq %rax, %rbx
jmp 0x1274b
jmp 0x1270e
movq %rax, %rbx
jmp 0x12733
movq %rax, %rbx
jmp 0x12763
movq %rax, %rbx
movq -0xc0(%rbp), %rdi
leaq -0xb0(%rbp), %rax
cmpq %rax, %rdi
je 0x12733
callq 0x3270
movq -0xe0(%rbp), %rdi
leaq -0xd0(%rbp), %rax
cmpq %rax, %rdi
je 0x1274b
callq 0x3270
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x12763
callq 0x3270
movq -0x188(%rbp), %rdi
leaq -0x178(%rbp), %rax
cmpq %rax, %rdi
je 0x1277b
callq 0x3270
leaq -0x60(%rbp), %rdi
callq 0x889a
movq %rbx, %rdi
callq 0x3480