// File: /workspace/github_cpp_makefile_star2_O1/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 %rdi, 0x20(%rsp)
movq %rsi, 0x18(%rsp)
movq %rsi, %rdi
movl %ecx, %esi
callq 0x19bd2
movq %rax, %r12
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
cmpl $0x0, 0x1c(%rax)
jle 0x1a2a9
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl $0x8, %r15d
xorl %ebx, %ebx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq 0x50(%r12), %rdi
addq %r15, %rdi
movq %r14, %rsi
callq 0x9abe
testb %al, %al
je 0x1a280
cmpl $-0x1, %ebp
cmovel %ebx, %ebp
movl %ebx, %r13d
jmp 0x1a294
movq 0x50(%r12), %rdi
addq %r15, %rdi
movq %r14, %rsi
callq 0x9be2
testb %al, %al
jne 0x1a2a5
incq %rbx
movslq 0x1c(%r12), %rax
addq $0x20, %r15
cmpq %rax, %rbx
jl 0x1a261
movl %ebx, %eax
jmp 0x1a2b6
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
movl 0x1c(%r12), %ecx
movq 0x18(%rsp), %rdx
cmpl 0x90(%rdx), %ecx
jg 0x1a3e3
cmpl $-0x1, %ebp
je 0x1a3db
cmpl %r13d, %ebp
jg 0x1a31b
movslq %ebp, %r15
shlq $0x5, %r15
movl %r13d, %ebx
subl %ebp, %ebx
incl %ebx
movq 0x50(%r12), %rdx
addq %r15, %rdx
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x1a30b
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x1a313
movq %rsp, %rdi
callq 0x1db1c
addq $0x20, %r15
decl %ebx
jne 0x1a2e8
cmpb $0x0, 0x68(%r12)
jne 0x1a3e3
leal 0x1(%r13), %eax
cmpl %eax, %ebp
jg 0x1a3e3
movslq %ebp, %r15
movslq %r13d, %rax
movq %rax, 0x28(%rsp)
movq %r12, %rbp
movq 0x20(%r12), %rax
movl (%rax,%r15,4), %ecx
leaq 0x30(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq %r14, %r12
movq %r14, %rdx
callq 0x1a210
movq 0x30(%rsp), %rbx
movq 0x38(%rsp), %r13
subq %rbx, %r13
je 0x1a3ac
sarq $0x2, %r13
movl $0x1, %r14d
xorl %eax, %eax
leaq (%rbx,%rax,4), %rdx
movq 0x8(%rsp), %rsi
cmpq 0x10(%rsp), %rsi
je 0x1a399
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
jmp 0x1a3a1
movq %rsp, %rdi
callq 0x1db1c
movl %r14d, %eax
incl %r14d
cmpq %rax, %r13
ja 0x1a37a
testq %rbx, %rbx
je 0x1a3c1
movq 0x40(%rsp), %rsi
subq %rbx, %rsi
movq %rbx, %rdi
callq 0x53a0
leaq 0x1(%r15), %rax
cmpq 0x28(%rsp), %r15
movq %rax, %r15
movq %r12, %r14
movq %rbp, %r12
jle 0x1a33e
jmp 0x1a3e3
cmpb $0x0, 0x68(%r12)
je 0x1a439
movq (%rsp), %rax
movq 0x20(%rsp), %rbx
movq %rax, (%rbx)
movq 0x8(%rsp), %rax
movq %rax, 0x8(%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1a427
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
movq %rbx, %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 0x20(%rsp), %rbx
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
movq %r14, %rdx
callq 0x1a210
jmp 0x1a411
jmp 0x1a45e
jmp 0x1a45e
jmp 0x1a45e
movq %rax, %r14
jmp 0x1a47b
movq %rax, %r14
testq %rbx, %rbx
je 0x1a47b
movq 0x40(%rsp), %rsi
subq %rbx, %rsi
movq %rbx, %rdi
callq 0x53a0
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x1a491
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x53a0
movq %r14, %rdi
callq 0x56e0
nop