// File: /workspace/github_cpp_makefile_star2_O3/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, -0xa0(%rbp)
xorl %eax, %eax
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movq %rdi, -0x48(%rbp)
movups %xmm0, (%rdi)
movq %rax, -0x30(%rbp)
movaps %xmm0, -0x40(%rbp)
movq %r9, -0xa8(%rbp)
movl (%r9), %ebx
movq (%rsi), %rdi
movq %rdx, %rsi
movq %rcx, %rdx
callq 0x94d8
movq %rax, %r15
incl %ebx
movl 0x100c(%rax), %eax
subl %ebx, %eax
js 0x12b93
addq $0x10, %r15
leaq -0x120(%rbp), %r14
movslq %ebx, %rbx
movl %eax, %r12d
xorl %r13d, %r13d
movq %r15, -0x58(%rbp)
movq %rbx, -0x98(%rbp)
movq %r12, -0x90(%rbp)
cmpb $0x4e, (%r15,%r13)
je 0x12b87
movq -0x40(%rbp), %rbx
movq -0x38(%rbp), %r15
cmpq %rbx, %r15
je 0x129b0
movq %rbx, %r12
movq 0x8(%r12), %rdi
leaq 0x18(%r12), %rax
cmpq %rdi, %rax
je 0x129a3
callq 0x3270
addq $0x30, %r12
cmpq %r15, %r12
jne 0x1298f
movq %rbx, -0x38(%rbp)
movq %r13, -0x50(%rbp)
movq -0xa8(%rbp), %rax
movq 0x28(%rax), %rbx
movq 0x30(%rax), %rax
movq %rax, -0xb0(%rbp)
cmpq %rax, %rbx
movq -0x58(%rbp), %r15
je 0x12b54
movq -0x50(%rbp), %rax
leal 0x1(%rax), %r13d
movq %r14, -0x130(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x130(%rbp), %rdi
callq 0x88b4
movb 0x28(%rbx), %al
movb %al, 0x18(%r14)
movq 0x20(%rbx), %rax
movq %rax, 0x10(%r14)
addq $0x30, %rbx
leaq -0x100(%rbp), %rdi
movq %rbx, %rsi
callq 0xeaa6
movl -0x110(%rbp), %eax
testl %eax, %eax
je 0x12aee
cmpl $0x1, %eax
je 0x12ac8
cmpl $0x2, %eax
jne 0x12b26
movq %r15, %rax
movslq %r13d, %r15
addq %rax, %r15
movq %r15, %rdi
callq 0x3110
leaq -0xc0(%rbp), %rcx
movq %rcx, -0xd0(%rbp)
leaq (%rax,%r15), %rdx
leaq -0xd0(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x8952
leaq -0x88(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x1332c
leaq -0x40(%rbp), %rdi
movq %r15, %rsi
callq 0x11a94
movq -0x58(%rbp), %r15
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x12aa7
callq 0x3270
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
cmpq %rax, %rdi
je 0x12abf
callq 0x3270
addl -0x10c(%rbp), %r13d
jmp 0x12b26
movslq %r13d, %rax
movss (%r15,%rax), %xmm0
leaq -0x88(%rbp), %r12
movq %r12, %rdi
callq 0x132dc
leaq -0x40(%rbp), %rdi
movq %r12, %rsi
callq 0x11a94
jmp 0x12b10
movslq %r13d, %rax
movl (%r15,%rax), %esi
leaq -0x88(%rbp), %r12
movq %r12, %rdi
callq 0x132b8
leaq -0x40(%rbp), %rdi
movq %r12, %rsi
callq 0x11a94
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x12b22
callq 0x3270
addl $0x4, %r13d
leaq -0x100(%rbp), %rdi
callq 0x84ba
movq -0x130(%rbp), %rdi
cmpq %r14, %rdi
je 0x12b43
callq 0x3270
addq $0x30, %rbx
cmpq -0xb0(%rbp), %rbx
jne 0x129df
movq -0xa0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0xeea6
movq -0x98(%rbp), %rbx
movq -0x90(%rbp), %r12
movq -0x50(%rbp), %r13
testb %al, %al
je 0x12b87
movq -0x48(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x7b52
addq %rbx, %r13
cmpq %r12, %r13
jle 0x12974
leaq -0x40(%rbp), %rdi
callq 0x89f0
movq -0x48(%rbp), %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x12c24
jmp 0x12c24
movq %rax, %rbx
jmp 0x12bd0
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x12bd0
callq 0x3270
movq -0xd0(%rbp), %rdi
leaq -0xc0(%rbp), %rax
jmp 0x12bf6
jmp 0x12be6
jmp 0x12beb
jmp 0x12be6
movq %rax, %rbx
jmp 0x12c00
movq %rax, %rbx
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x12c00
callq 0x3270
leaq -0x130(%rbp), %rdi
callq 0xe72c
jmp 0x12c27
movq %rax, %rbx
movq -0x130(%rbp), %rdi
cmpq %r14, %rdi
je 0x12c27
callq 0x3270
jmp 0x12c27
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x89f0
movq -0x48(%rbp), %rdi
callq 0x7a6a
movq %rbx, %rdi
callq 0x3480
nop