// File: /workspace/github_cpp_makefile_star2_O3/Konano[P]UselessDatabase/Index.cpp
// Function: Index::queryRecord(Anys*, int)
std::vector<int> Index::queryRecord(Anys* info, int now_index) {
    
    BtreeNode* now = Index::convert_buf_to_BtreeNode(now_index);

    //if((*info)[0].anyCast<int>()!=nullptr)printf("val %d\n",*(*info)[0].anyCast<int>());
    //else printf("\n");

    std::vector<int> v;

    //printf("%d\n",now->record_cnt);

    int l = -1, r = -1, i;
    for (i = 0; i < now->record_cnt; i++) {
        if (now->record[i].key == *info) {
            if (l == -1) l = i;
            r = i;
        }
        else if (now->record[i].key > *info) {
            break;
        }
    }

    if (now->record_cnt > btree_max_per_node) return v;
    
    if (l == -1 && now -> is_leaf) 
        return v;
    else if (l == -1) {
        //Index::convert_BtreeNode_to_buf(now);
        //printf("%d %d %d\n",index, now->child[i],now->record_cnt);
        return Index::queryRecord(info, now->child[i]);
    }

    for (int i = l; i <= r; i++) v.push_back(now -> record[i].record_id);

    if (now -> is_leaf) {
        return v;
    }
    else {
        for (int i = l; i <= r + 1; i++) {
            //Index::convert_BtreeNode_to_buf(now);
            std::vector<int> cv = Index::queryRecord(info, now->child[i]);
            for (uint j = 0; j < cv.size(); j++) v.push_back(cv[j]);
        }
        return v;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq %rsi, %rdi
movl %ecx, %esi
callq 0x19412
movq %rax, %r12
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movl 0x1c(%rax), %eax
testl %eax, %eax
movq %rbx, 0x20(%rsp)
jle 0x19ae1
movq %r15, 0x18(%rsp)
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl $0x8, %r15d
xorl %ebp, %ebp
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movq 0x50(%r12), %rdi
addq %r15, %rdi
movq %r14, %rsi
callq 0x9996
testb %al, %al
je 0x19aba
cmpl $-0x1, %r13d
cmovel %ebp, %r13d
movl %ebp, %ebx
jmp 0x19ace
movq 0x50(%r12), %rdi
addq %r15, %rdi
movq %r14, %rsi
callq 0x9aa6
testb %al, %al
jne 0x19af4
incq %rbp
movslq 0x1c(%r12), %rax
addq $0x20, %r15
cmpq %rax, %rbp
jl 0x19a9a
jmp 0x19af9
cmpl 0x90(%rbx), %eax
jg 0x19c2f
xorl %eax, %eax
jmp 0x19c22
movl 0x1c(%r12), %eax
movq 0x20(%rsp), %rcx
cmpl 0x90(%rcx), %eax
movq 0x18(%rsp), %r15
jg 0x19c2f
cmpl $-0x1, %r13d
je 0x19c20
cmpl %ebx, %r13d
jg 0x19b5f
movslq %r13d, %r15
shlq $0x5, %r15
movl %ebx, %ebp
subl %r13d, %ebp
incl %ebp
movq 0x50(%r12), %rdx
addq %r15, %rdx
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x19b4f
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x19b57
movq %rsp, %rdi
callq 0x1d42c
addq $0x20, %r15
decl %ebp
jne 0x19b2c
cmpb $0x0, 0x68(%r12)
jne 0x19c15
leal 0x1(%rbx), %eax
cmpl %eax, %r13d
jg 0x19c15
movslq %r13d, %r15
movslq %ebx, %rax
movq %rax, 0x28(%rsp)
movq 0x20(%r12), %rax
movl (%rax,%r15,4), %ecx
leaq 0x30(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq %r14, %rdx
callq 0x19a42
movq 0x30(%rsp), %r13
movq 0x38(%rsp), %rbx
subq %r13, %rbx
je 0x19bee
sarq $0x2, %rbx
movl $0x1, %ebp
xorl %eax, %eax
leaq (,%rax,4), %rdx
addq %r13, %rdx
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x19bdd
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x19be5
movq %rsp, %rdi
callq 0x1d42c
movl %ebp, %eax
incl %ebp
cmpq %rax, %rbx
ja 0x19bb7
testq %r13, %r13
je 0x19c03
movq 0x40(%rsp), %rsi
subq %r13, %rsi
movq %r13, %rdi
callq 0x53a0
leaq 0x1(%r15), %rax
cmpq 0x28(%rsp), %r15
movq %rax, %r15
jle 0x19b82
movaps (%rsp), %xmm0
movq 0x18(%rsp), %r15
jmp 0x19c33
movl %ebp, %eax
cmpb $0x1, 0x68(%r12)
movq 0x20(%rsp), %rsi
jne 0x19c52
movaps (%rsp), %xmm0
movups %xmm0, (%r15)
movq 0x10(%rsp), %rax
movq %rax, 0x10(%r15)
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%r12), %rcx
movl (%rcx,%rax,4), %ecx
movq %r15, %rdi
movq %r14, %rdx
callq 0x19a42
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x19c40
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
jmp 0x19c40
jmp 0x19c9d
jmp 0x19c9d
jmp 0x19c9d
movq %rax, %rbx
testq %r13, %r13
je 0x19ca0
movq 0x40(%rsp), %rsi
subq %r13, %rsi
movq %r13, %rdi
callq 0x53a0
jmp 0x19ca0
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x19cb6
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
movq %rbx, %rdi
callq 0x56e0