// File: Konano[P]UselessDatabase/Table.cpp
// Function: Table::insertRecord(Any*)
int Table::insertRecord(Any* data) {
    int x = this->constraintRow(data, record_num, true);
    if (x) return x;
    int index;
    BufType buf = bpm->getPage(main_file, record_num / record_onepg, index);
    exist_set(buf, record_num % record_onepg);
    buf += (record_onepg - 1) / 8 + 1;
    buf += record_size * (record_num % record_onepg);
    for (uint i = 0; i < col_num; i++) {
        insert(data[i], col_ty[i].ty, col_ty[i].size(), buf);
    }
    for (uint i = 0; i < index_num; i++) {
        Anys a;
        for (uint j = 0; j < this->index[i].key_num; j++) {
            a.push_back(data[this->index[i].key[j]]);
        }
        this->index[i].insertRecord(&a, record_num);
    }
    bpm->markDirty(index);
    record_num++;
    /*
    printf("check index_num:%d record_num:%d\n",index_num,record_num);
    for(uint i = 0;i < record_num;i ++){
        Anys temp = queryRecord(i);
        if (temp[0].isNull()) printf("null ");
        else printf("%d ", *temp[0].anyCast<int>());
        if (temp[1].isNull()) printf("null ");
        else printf("%d ", *temp[1].anyCast<int>());
        printf("\n");
    }*/
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x70(%rbp)
movq -0x18(%rbp), %rsi
movl 0x9fa0(%rdi), %edx
movl $0x1, %ecx
callq 0x49ca0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x49a03
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x49c80
movq -0x70(%rbp), %rcx
movq 0x48(%rcx), %rdi
movl 0x9fa4(%rcx), %esi
movl 0x9fa0(%rcx), %eax
xorl %edx, %edx
divl 0x9fac(%rcx)
movl %eax, %edx
leaq -0x20(%rbp), %rcx
callq 0x71d0
movq -0x70(%rbp), %rsi
movq %rax, -0x28(%rbp)
movl 0x9fa0(%rsi), %eax
xorl %edx, %edx
divl 0x9fac(%rsi)
movl %edx, %ecx
andl $0x7, %ecx
movl $0x1, %edi
shll %cl, %edi
movq -0x28(%rbp), %rax
movq %rax, -0x78(%rbp)
movl 0x9fa0(%rsi), %eax
xorl %edx, %edx
divl 0x9fac(%rsi)
movq -0x78(%rbp), %rax
shrl $0x3, %edx
movl %edx, %ecx
movzbl (%rax,%rcx), %edx
orl %edi, %edx
movb %dl, (%rax,%rcx)
movl 0x9fac(%rsi), %ecx
subl $0x1, %ecx
shrl $0x3, %ecx
addl $0x1, %ecx
movq -0x28(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movl 0x9fa8(%rsi), %ecx
movl 0x9fa0(%rsi), %eax
xorl %edx, %edx
divl 0x9fac(%rsi)
imull %edx, %ecx
movq -0x28(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x70(%rbp), %rcx
movl -0x2c(%rbp), %eax
cmpl 0x54(%rcx), %eax
jae 0x49b2e
movq -0x70(%rbp), %rdi
movq -0x18(%rbp), %rax
movl -0x2c(%rbp), %ecx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
movq %rdi, %rax
addq $0x58, %rax
movl -0x2c(%rbp), %ecx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movl 0x24(%rax), %eax
movl %eax, -0x7c(%rbp)
addq $0x58, %rdi
movl -0x2c(%rbp), %eax
imulq $0x38, %rax, %rax
addq %rax, %rdi
callq 0x3d3d0
movq -0x70(%rbp), %rdi
movq -0x88(%rbp), %rsi
movl -0x7c(%rbp), %edx
movl %eax, %ecx
leaq -0x28(%rbp), %r8
callq 0x496a0
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x49abb
movl $0x0, -0x30(%rbp)
movq -0x70(%rbp), %rcx
movl -0x30(%rbp), %eax
cmpl 0x798(%rcx), %eax
jae 0x49c56
leaq -0x48(%rbp), %rdi
callq 0xc310
movl $0x0, -0x4c(%rbp)
movq -0x70(%rbp), %rcx
movl -0x4c(%rbp), %eax
addq $0x7a0, %rcx            # imm = 0x7A0
movl -0x30(%rbp), %edx
imulq $0x98, %rdx, %rdx
addq %rdx, %rcx
cmpl 0x28(%rcx), %eax
jae 0x49c0d
movq -0x70(%rbp), %rax
movq -0x18(%rbp), %rcx
movq %rcx, -0x90(%rbp)
movl -0x30(%rbp), %ecx
imulq $0x98, %rcx, %rcx
leaq 0x7d0(%rax,%rcx), %rdi
movl -0x4c(%rbp), %eax
movl %eax, %esi
callq 0x3cf40
movq %rax, %rcx
movq -0x90(%rbp), %rax
movl (%rcx), %ecx
leaq (%rax,%rcx,8), %rsi
leaq -0x58(%rbp), %rdi
callq 0xca00
jmp 0x49bc2
leaq -0x48(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0xc330
jmp 0x49bd1
leaq -0x58(%rbp), %rdi
callq 0xc3c0
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x49b58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x49c4b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xc3c0
jmp 0x49c4b
movq -0x70(%rbp), %rax
movl -0x30(%rbp), %ecx
imulq $0x98, %rcx, %rcx
leaq 0x7a0(%rax,%rcx), %rdi
movl 0x9fa0(%rax), %edx
leaq -0x48(%rbp), %rsi
callq 0x390e0
jmp 0x49c34
leaq -0x48(%rbp), %rdi
callq 0xc430
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x49b35
leaq -0x48(%rbp), %rdi
callq 0xc430
jmp 0x49c8c
movq -0x70(%rbp), %rax
movq 0x48(%rax), %rdi
movl -0x20(%rbp), %esi
callq 0x7300
movq -0x70(%rbp), %rax
movl 0x9fa0(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x9fa0(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
movq -0x60(%rbp), %rdi
callq 0x6890
nopw %cs:(%rax,%rax)