// File: /workspace/github_cpp_makefile_star2_O3/Konano[P]UselessDatabase/Table.cpp
// Function: Table::findWheres(std::vector<WhereStmt, std::allocator<WhereStmt>>&)
vector<uint> Table::findWheres(vector<WhereStmt> &where) { // preliminary search
    int mx = -1;
    WhereStmt w;
    // uint w_index;
    for (auto it: where) if (it.rvalue_ty == 1) {
        for (uint i = 0; i < index_num; i++) if (index[i].key.size() == it.cols.size()) {
            bool tmp = true;
            for (uint j = 0; j < it.cols.size(); j++) tmp &= (index[i].key[j] == it.cols[j].second);
            if (tmp) {
                Anys data;
                for (auto _it: it.rvalue) data.push_back(_it);
                int nums = index[i].queryRecordsNum(it.op, data);
                if (nums > mx) {
                    mx = nums;
                    w = it;
                    // w_index = i;
                }
            }
        }
    }

    // FIXME
    // if (mx == -1) {
        return existentRecords();
    // } else {
    //     Anys data;
    //     for (auto it: w.rvalue) data.push_back(it);
    //     return index[w_index].queryRecords(w.op, data);           
    // }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rsi, 0x8(%rsp)
movq %rdi, 0x18(%rsp)
xorps %xmm0, %xmm0
leaq 0xd8(%rsp), %rax
movaps %xmm0, -0x28(%rax)
movq $0x0, -0x18(%rax)
movw $0x0, -0xc(%rax)
movl $0x0, -0x8(%rax)
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movq (%rdx), %rbx
movq 0x8(%rdx), %rax
movq %rax, 0x98(%rsp)
cmpq %rax, %rbx
je 0x26546
movq 0x8(%rsp), %rax
leaq 0x7a0(%rax), %r14
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movq %r14, 0xa8(%rsp)
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0xa682
movl 0x20(%rbx), %eax
leaq 0x38(%rsp), %rcx
movl %eax, 0x8(%rcx)
movq 0x18(%rbx), %rax
movq %rax, (%rcx)
leaq 0x28(%rbx), %rsi
leaq 0x48(%rsp), %rdi
callq 0xa26a
leaq 0x40(%rbx), %rsi
leaq 0x60(%rsp), %rdi
callq 0xa682
movq %rbx, 0xa0(%rsp)
movl 0x58(%rbx), %eax
movl %eax, 0x78(%rsp)
cmpl $0x1, 0x40(%rsp)
sete %cl
movq 0x8(%rsp), %rax
movl 0x798(%rax), %eax
testl %eax, %eax
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x264f4
xorl %r12d, %r12d
imulq $0x98, %r12, %rbx
movq 0x30(%r14,%rbx), %rcx
movq 0x38(%r14,%rbx), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdi
movq %rdi, %r8
subq %rsi, %r8
sarq $0x3, %r8
cmpq %r8, %rdx
jne 0x264e6
cmpq %rsi, %rdi
je 0x263ba
movb $0x1, %dil
xorl %r8d, %r8d
movl (%rcx,%r8,4), %r9d
cmpl 0x4(%rsi,%r8,8), %r9d
sete %r9b
andb %r9b, %dil
incq %r8
movl %r8d, %r9d
cmpq %r9, %rdx
ja 0x26396
testb %dil, %dil
je 0x264e6
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movq $0x0, 0x90(%rsp)
movq 0x48(%rsp), %r15
movq 0x50(%rsp), %rbp
cmpq %rbp, %r15
je 0x26449
movq (%r15), %rdi
movb $0x1, %r14b
testq %rdi, %rdi
je 0x26408
movq (%rdi), %rax
callq *0x10(%rax)
movq %rax, %r13
testq %rax, %rax
je 0x26408
movq (%r13), %rax
movq %r13, %rdi
callq *0x10(%rax)
xorl %r14d, %r14d
jmp 0x2640d
xorl %r13d, %r13d
xorl %eax, %eax
movq %rax, 0x10(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x9f9a
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x26434
movq (%rdi), %rax
callq *0x8(%rax)
testb %r14b, %r14b
jne 0x26443
movq (%r13), %rax
movq %r13, %rdi
callq *0x8(%rax)
addq $0x8, %r15
jmp 0x263db
movq 0xa8(%rsp), %r14
addq %r14, %rbx
movl 0x38(%rsp), %esi
movq %rbx, %rdi
leaq 0x80(%rsp), %rdx
callq 0x1c580
movl %eax, %ebx
cmpl 0x4(%rsp), %eax
jle 0x264ce
leaq 0xb0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x28944
leaq 0x38(%rsp), %rcx
movl 0x8(%rcx), %eax
leaq 0xc8(%rsp), %rdx
movl %eax, 0x8(%rdx)
movq (%rcx), %rax
movq %rax, (%rdx)
leaq 0xd8(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x1c7e2
leaq 0xf0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x28944
movl 0x78(%rsp), %eax
movl %eax, 0x108(%rsp)
movl %ebx, 0x4(%rsp)
leaq 0x80(%rsp), %rdi
callq 0xa37e
movq 0x8(%rsp), %rax
movl 0x798(%rax), %eax
incq %r12
movl %eax, %ecx
cmpq %rcx, %r12
jb 0x26356
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x2650b
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
leaq 0x48(%rsp), %rdi
callq 0xa37e
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
movq 0xa0(%rsp), %rbx
je 0x26534
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
addq $0x60, %rbx
cmpq 0x98(%rsp), %rbx
jne 0x262e6
movq 0x18(%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x26188
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x26572
movq 0x100(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
leaq 0xd8(%rsp), %rdi
callq 0xa37e
movq 0xb0(%rsp), %rdi
testq %rdi, %rdi
je 0x2659c
movq 0xc0(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
movq 0x18(%rsp), %rax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x265b5
movq %rax, %rbx
jmp 0x2662a
movq %rax, %rbx
jmp 0x265cc
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0xa37e
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x2662a
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
jmp 0x2662a
jmp 0x265ec
movq %rax, %rbx
jmp 0x26609
movq %rax, %rbx
jmp 0x26613
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x26604
movq (%rdi), %rax
callq *0x8(%rax)
testb %r14b, %r14b
jne 0x26613
movq (%r13), %rax
movq %r13, %rdi
callq *0x8(%rax)
leaq 0x80(%rsp), %rdi
callq 0xa37e
leaq 0x20(%rsp), %rdi
callq 0x9b74
leaq 0xb0(%rsp), %rdi
callq 0x9b74
movq %rbx, %rdi
callq 0x56e0
nop