// File: 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
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdx, -0x1c8(%rbp)
movq %rdi, -0x1d8(%rbp)
movq %rdi, %rax
movq %rax, -0x1e0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1d0(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x23de0
movq -0x1d8(%rbp), %rdi
movb $0x0, -0x39(%rbp)
callq 0x7fb0
leaq -0x58(%rbp), %rdi
callq 0x21a10
movq -0x1d0(%rbp), %rax
movq -0x1c8(%rbp), %rsi
movq -0x30(%rbp), %rcx
movl (%rcx), %ecx
incl %ecx
movl %ecx, -0x5c(%rbp)
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
callq 0xefc0
movq %rax, -0x1c0(%rbp)
jmp 0x238e6
movq -0x1c0(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xfa80
movq -0x1d0(%rbp), %rdi
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rsi
movl $0xffc, %edx            # imm = 0xFFC
callq 0x227d0
movl %eax, -0x84(%rbp)
movl $0x0, -0x88(%rbp)
movl -0x88(%rbp), %eax
movl -0x84(%rbp), %ecx
subl -0x5c(%rbp), %ecx
cmpl %ecx, %eax
jg 0x23c4c
movq -0x80(%rbp), %rax
movslq -0x88(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x4e, %eax
jne 0x2396c
jmp 0x23c38
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x23c61
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x23e00
movq -0x30(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
callq 0x1d230
movq %rax, -0xa0(%rbp)
movq -0x98(%rbp), %rdi
callq 0x1caa0
movq %rax, -0xa8(%rbp)
leaq -0xa0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x23e20
testb $0x1, %al
jne 0x239d5
jmp 0x23bf9
leaq -0xa0(%rbp), %rdi
callq 0x23e60
movq %rax, %rsi
leaq -0x108(%rbp), %rdi
callq 0x1cb00
jmp 0x239f2
movl -0xe8(%rbp), %eax
movl %eax, -0x1e4(%rbp)
testl %eax, %eax
je 0x23a29
jmp 0x23a04
movl -0x1e4(%rbp), %eax
subl $0x1, %eax
je 0x23ab1
jmp 0x23a15
movl -0x1e4(%rbp), %eax
subl $0x2, %eax
je 0x23b26
jmp 0x23bcc
movq -0x1d0(%rbp), %rdi
movq -0x80(%rbp), %rsi
movl -0x8c(%rbp), %edx
callq 0x227d0
movl %eax, %esi
leaq -0x138(%rbp), %rdi
callq 0x24620
jmp 0x23a4f
leaq -0x58(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x21a30
jmp 0x23a61
leaq -0x138(%rbp), %rdi
callq 0x7af0
movslq -0x8c(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x8c(%rbp)
jmp 0x23bce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x23beb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x7af0
jmp 0x23beb
movq -0x1d0(%rbp), %rdi
movq -0x80(%rbp), %rsi
movl -0x8c(%rbp), %edx
callq 0x228a0
leaq -0x168(%rbp), %rdi
callq 0x24660
jmp 0x23ad5
leaq -0x58(%rbp), %rdi
leaq -0x168(%rbp), %rsi
callq 0x21a30
jmp 0x23ae7
leaq -0x168(%rbp), %rdi
callq 0x7af0
movslq -0x8c(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x8c(%rbp)
jmp 0x23bce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x168(%rbp), %rdi
callq 0x7af0
jmp 0x23beb
movq -0x1d0(%rbp), %rsi
movq -0x80(%rbp), %rdx
movl -0x8c(%rbp), %ecx
leaq -0x1b8(%rbp), %rdi
callq 0x22970
jmp 0x23b45
leaq -0x198(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x246f0
jmp 0x23b5a
leaq -0x58(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0x21a30
jmp 0x23b6c
leaq -0x198(%rbp), %rdi
callq 0x7af0
leaq -0x1b8(%rbp), %rdi
callq 0x35b8
movl -0xe4(%rbp), %eax
addl -0x8c(%rbp), %eax
movl %eax, -0x8c(%rbp)
jmp 0x23bce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x23bbe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x198(%rbp), %rdi
callq 0x7af0
leaq -0x1b8(%rbp), %rdi
callq 0x35b8
jmp 0x23beb
jmp 0x23bce
leaq -0x108(%rbp), %rdi
callq 0x9fd0
leaq -0xa0(%rbp), %rdi
callq 0x23e80
jmp 0x239b9
leaq -0x108(%rbp), %rdi
callq 0x9fd0
jmp 0x23c61
movq -0x28(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x1d8f0
movb %al, -0x1e5(%rbp)
jmp 0x23c0e
movb -0x1e5(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
movl $0x1, %eax
cmpl %ecx, %eax
jne 0x23c36
movq -0x1d8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x8080
jmp 0x23c34
jmp 0x23c36
jmp 0x23c38
movl -0x5c(%rbp), %eax
addl -0x88(%rbp), %eax
movl %eax, -0x88(%rbp)
jmp 0x2392b
movb $0x1, -0x39(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xb6d0
testb $0x1, -0x39(%rbp)
jne 0x23c84
jmp 0x23c78
leaq -0x58(%rbp), %rdi
callq 0xb6d0
movq -0x1d8(%rbp), %rdi
callq 0x7b30
jmp 0x23c94
movq -0x1d8(%rbp), %rdi
callq 0x7b30
movq -0x1e0(%rbp), %rax
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x34f0
nopl (%rax)