// File: Konano[P]UselessDatabase/Table.cpp
// Function: Table::constraintRowKey(Any*, Key*)
int Table::constraintRowKey(Any* data, Key* key) {
    if (key->ty() == 1) {
        for (auto i: key->v) if (data[i].isNull()) return -1;
        Anys val;
        for (auto i: key->v) val.push_back(data[i]);
        vector<int> ans;
        if(this->index[p_key_index].fileID == -1){
            this->index[p_key_index].open();
            ans = this->index[p_key_index].queryRecord(&val);
            this->index[p_key_index].close();
        }
        else ans = this->index[p_key_index].queryRecord(&val);
        if (ans.size() != 0) return -2;
    } else {
        Anys val;
        for (auto i: key->v) val.push_back(data[i]);
        vector <int> ans;
        //if(key->v.size() == 2)printf("%d %d\n",*val[0].anyCast<int>(),*val[1].anyCast<int>());
        Table* p_table = dynamic_cast<ForeignKey*>(key)->p->table;
        if(p_table->index[p_table->p_key_index].fileID == -1){
            p_table->index[p_table->p_key_index].open();
            ans = p_table->index[p_table->p_key_index].queryRecord(&val);
            p_table->index[p_table->p_key_index].close();
        }
        else {ans = p_table->index[p_table->p_key_index].queryRecord(&val);}
        if (ans.size() == 0){
            return -3;
        }
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x178(%rbp)
movq -0x20(%rbp), %rdi
movq (%rdi), %rax
callq *(%rax)
cmpl $0x1, %eax
jne 0x4ecfc
movq -0x20(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
callq 0x3d210
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x3d240
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3d270
testb $0x1, %al
jne 0x4ea4d
jmp 0x4ea8d
leaq -0x30(%rbp), %rdi
callq 0x3d2b0
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rdi
movl -0x3c(%rbp), %eax
shlq $0x3, %rax
addq %rax, %rdi
callq 0xc920
testb $0x1, %al
jne 0x4ea74
jmp 0x4ea80
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4f008
jmp 0x4ea82
leaq -0x30(%rbp), %rdi
callq 0x3d3b0
jmp 0x4ea3a
leaq -0x58(%rbp), %rdi
callq 0xc310
movq -0x20(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0x3d210
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
callq 0x3d240
movq %rax, -0x70(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x3d270
testb $0x1, %al
jne 0x4eacf
jmp 0x4eb4d
leaq -0x68(%rbp), %rdi
callq 0x3d2b0
movl (%rax), %eax
movl %eax, -0x74(%rbp)
movq -0x18(%rbp), %rax
movl -0x74(%rbp), %ecx
leaq (%rax,%rcx,8), %rsi
leaq -0x80(%rbp), %rdi
callq 0xca00
jmp 0x4eaf3
leaq -0x58(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0xc330
jmp 0x4eb02
leaq -0x80(%rbp), %rdi
callq 0xc3c0
leaq -0x68(%rbp), %rdi
callq 0x3d3b0
jmp 0x4eabc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x4ecee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0xc3c0
jmp 0x4ecee
leaq -0xa8(%rbp), %rdi
callq 0xd880
movq -0x178(%rbp), %rcx
movq %rcx, %rax
addq $0x7a0, %rax            # imm = 0x7A0
movslq 0x778(%rcx), %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
cmpl $-0x1, 0x74(%rax)
jne 0x4ec46
movq -0x178(%rbp), %rax
movslq 0x778(%rax), %rcx
imulq $0x98, %rcx, %rcx
leaq 0x7a0(%rax,%rcx), %rdi
callq 0x36ad0
jmp 0x4eba8
movq -0x178(%rbp), %rax
movslq 0x778(%rax), %rcx
imulq $0x98, %rcx, %rcx
leaq 0x7a0(%rax,%rcx), %rsi
leaq -0xc0(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x37aa0
jmp 0x4ebd7
leaq -0xa8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
movq %rsi, -0x180(%rbp)
callq 0x52d90
movq -0x180(%rbp), %rdi
callq 0xde10
movq -0x178(%rbp), %rax
movslq 0x778(%rax), %rcx
imulq $0x98, %rcx, %rcx
leaq 0x7a0(%rax,%rcx), %rdi
callq 0x36b30
jmp 0x4ec21
jmp 0x4ec94
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0xde10
jmp 0x4ecee
movq -0x178(%rbp), %rax
movslq 0x778(%rax), %rcx
imulq $0x98, %rcx, %rcx
leaq 0x7a0(%rax,%rcx), %rsi
leaq -0xd8(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x37aa0
jmp 0x4ec75
leaq -0xa8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x52d90
leaq -0xd8(%rbp), %rdi
callq 0xde10
leaq -0xa8(%rbp), %rdi
callq 0x3d860
cmpq $0x0, %rax
je 0x4ecb9
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
movl $0x1, -0xdc(%rbp)
jmp 0x4ecc3
movl $0x0, -0xdc(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0xde10
leaq -0x58(%rbp), %rdi
callq 0xc430
movl -0xdc(%rbp), %eax
testl %eax, %eax
je 0x4ece9
jmp 0x4ece4
jmp 0x4f008
jmp 0x4f001
leaq -0x58(%rbp), %rdi
callq 0xc430
jmp 0x4f014
leaq -0xf8(%rbp), %rdi
callq 0xc310
movq -0x20(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rdi
callq 0x3d210
movq %rax, -0x108(%rbp)
movq -0x100(%rbp), %rdi
callq 0x3d240
movq %rax, -0x110(%rbp)
leaq -0x108(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0x3d270
testb $0x1, %al
jne 0x4ed59
jmp 0x4edf2
leaq -0x108(%rbp), %rdi
callq 0x3d2b0
movl (%rax), %eax
movl %eax, -0x114(%rbp)
movq -0x18(%rbp), %rax
movl -0x114(%rbp), %ecx
leaq (%rax,%rcx,8), %rsi
leaq -0x120(%rbp), %rdi
callq 0xca00
jmp 0x4ed89
leaq -0xf8(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xc330
jmp 0x4ed9e
leaq -0x120(%rbp), %rdi
callq 0xc3c0
leaq -0x108(%rbp), %rdi
callq 0x3d3b0
jmp 0x4ed3d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x4eff3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x120(%rbp), %rdi
callq 0xc3c0
jmp 0x4eff3
leaq -0x138(%rbp), %rdi
callq 0xd880
movq -0x20(%rbp), %rax
movq %rax, -0x188(%rbp)
cmpq $0x0, %rax
je 0x4ee36
movq -0x188(%rbp), %rdi
leaq 0x61e13(%rip), %rsi     # 0xb0c30
leaq 0x61e1c(%rip), %rdx     # 0xb0c40
xorl %eax, %eax
movl %eax, %ecx
callq 0x6590
movq %rax, -0x190(%rbp)
jmp 0x4ee41
xorl %eax, %eax
movq %rax, -0x190(%rbp)
jmp 0x4ee41
movq -0x190(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x48(%rax), %rax
movq %rax, -0x140(%rbp)
movq -0x140(%rbp), %rax
addq $0x7a0, %rax            # imm = 0x7A0
movq -0x140(%rbp), %rcx
movslq 0x778(%rcx), %rcx
imulq $0x98, %rcx, %rcx
addq %rcx, %rax
cmpl $-0x1, 0x74(%rax)
jne 0x4ef4b
movq -0x140(%rbp), %rax
movslq 0x778(%rax), %rcx
imulq $0x98, %rcx, %rcx
leaq 0x7a0(%rax,%rcx), %rdi
callq 0x36ad0
jmp 0x4eeaa
movq -0x140(%rbp), %rax
movslq 0x778(%rax), %rcx
imulq $0x98, %rcx, %rcx
leaq 0x7a0(%rax,%rcx), %rsi
leaq -0x158(%rbp), %rdi
leaq -0xf8(%rbp), %rdx
callq 0x37aa0
jmp 0x4eedc
leaq -0x138(%rbp), %rdi
leaq -0x158(%rbp), %rsi
movq %rsi, -0x198(%rbp)
callq 0x52d90
movq -0x198(%rbp), %rdi
callq 0xde10
movq -0x140(%rbp), %rax
movslq 0x778(%rax), %rcx
imulq $0x98, %rcx, %rcx
leaq 0x7a0(%rax,%rcx), %rdi
callq 0x36b30
jmp 0x4ef26
jmp 0x4ef9c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x138(%rbp), %rdi
callq 0xde10
jmp 0x4eff3
movq -0x140(%rbp), %rax
movslq 0x778(%rax), %rcx
imulq $0x98, %rcx, %rcx
leaq 0x7a0(%rax,%rcx), %rsi
leaq -0x170(%rbp), %rdi
leaq -0xf8(%rbp), %rdx
callq 0x37aa0
jmp 0x4ef7d
leaq -0x138(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x52d90
leaq -0x170(%rbp), %rdi
callq 0xde10
leaq -0x138(%rbp), %rdi
callq 0x3d860
cmpq $0x0, %rax
jne 0x4efc1
movl $0xfffffffd, -0x4(%rbp) # imm = 0xFFFFFFFD
movl $0x1, -0xdc(%rbp)
jmp 0x4efcb
movl $0x0, -0xdc(%rbp)
leaq -0x138(%rbp), %rdi
callq 0xde10
leaq -0xf8(%rbp), %rdi
callq 0xc430
movl -0xdc(%rbp), %eax
testl %eax, %eax
je 0x4eff1
jmp 0x4efef
jmp 0x4f008
jmp 0x4f001
leaq -0xf8(%rbp), %rdi
callq 0xc430
jmp 0x4f014
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq -0x88(%rbp), %rdi
callq 0x6890