// File: /workspace/github_cpp_makefile_star2_O2/zimpha[P]MiniSQL/RecordManager.cc
// Function: RecordManager::RecordManagerRecordSelect(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, long, Filter const&, Table&)
std::vector<std::vector<element> > RecordManager::RecordManagerRecordSelect(std::string dbName, long offset, const Filter & filter, Table & nt)
{
    bufferIter pBlock;
    std::vector<std::vector<element> > queryResut;
    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))
            queryResut.push_back(queryTuple);
    }
    return queryResut;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %r8, -0x60(%rbp)
andq $0x0, 0x10(%rdi)
xorps %xmm0, %xmm0
andq $0x0, -0x40(%rbp)
movq %rdi, -0x38(%rbp)
movups %xmm0, (%rdi)
movaps %xmm0, -0x50(%rbp)
movq %r9, -0x68(%rbp)
movl (%r9), %r14d
movq (%rsi), %rdi
movq %rdx, %rsi
movq %rcx, %rdx
callq 0x7a04
incl %r14d
addq $0x10, %rax
movq %rax, -0x30(%rbp)
movq %rax, %rsi
movl $0xffc, %edx            # imm = 0xFFC
callq 0xea9c
subl %r14d, %eax
movslq %r14d, %rcx
movq %rcx, -0x70(%rbp)
cltq
movq %rax, -0x78(%rbp)
xorl %eax, %eax
cmpq -0x78(%rbp), %rax
jg 0xf57f
movq %rax, -0x58(%rbp)
movq -0x30(%rbp), %rcx
cmpb $0x4e, (%rcx,%rax)
je 0xf572
leaq -0x50(%rbp), %rdi
callq 0xf6ac
movq -0x68(%rbp), %rax
movq 0x28(%rax), %r15
movq 0x30(%rax), %r12
movq -0x58(%rbp), %rax
leal 0x1(%rax), %r14d
cmpq %r12, %r15
je 0xf554
leaq -0x128(%rbp), %rdi
movq %r15, %rsi
callq 0xc260
movl -0x108(%rbp), %eax
testl %eax, %eax
je 0xf506
cmpl $0x1, %eax
je 0xf4dd
cmpl $0x2, %eax
jne 0xf53f
leaq -0xc8(%rbp), %r13
movq %r13, %rdi
movq -0x30(%rbp), %rdx
movl %r14d, %ecx
callq 0xead0
leaq -0xa8(%rbp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0xfb80
leaq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0xe8a2
leaq -0xa0(%rbp), %rdi
callq 0x34f8
leaq -0xc8(%rbp), %rdi
callq 0x34f8
addl -0x104(%rbp), %r14d
jmp 0xf53f
movq -0x30(%rbp), %rsi
movl %r14d, %edx
callq 0xeab4
leaq -0xa8(%rbp), %rbx
movq %rbx, %rdi
callq 0xfb34
leaq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0xe8a2
jmp 0xf52f
movq -0x30(%rbp), %rsi
movl %r14d, %edx
callq 0xea9c
leaq -0xa8(%rbp), %rbx
movq %rbx, %rdi
movl %eax, %esi
callq 0xfb16
leaq -0x50(%rbp), %rdi
movq %rbx, %rsi
callq 0xe8a2
leaq -0xa0(%rbp), %rdi
callq 0x34f8
addl $0x4, %r14d
leaq -0x128(%rbp), %rdi
callq 0x684c
addq $0x60, %r15
jmp 0xf454
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xc5f4
testb %al, %al
je 0xf572
movq -0x38(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x5f5a
movq -0x58(%rbp), %rax
addq -0x70(%rbp), %rax
jmp 0xf41b
leaq -0x50(%rbp), %rdi
callq 0x6dc8
movq -0x38(%rbp), %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf5e7
jmp 0xf5e7
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x34f8
jmp 0xf5b6
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
jmp 0xf5cf
jmp 0xf5d6
jmp 0xf5c5
jmp 0xf5d6
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x34f8
jmp 0xf5d9
movq %rax, %rbx
leaq -0x128(%rbp), %rdi
callq 0x684c
jmp 0xf5ea
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x6dc8
movq -0x38(%rbp), %rdi
callq 0x5ec4
movq %rbx, %rdi
callq 0x3450