// File: zimpha[P]MiniSQL/indexManager.cc
// Function: BT::insert(element const&, long)
void insert(const element &e, long offset) {
        auto go = [&] (long off) { return blockToNode(*(bfm->BufferManagerRead(name, off))); };
        BTNode c;//s
        map <long, long> parent;
        while (!c.isLeaf) {
            int i = 0;
            while (i < c.n && c.value[i] <= e) i++;
            parent[c.ch[i]] = c.offset;
            c = go(c.ch[i]);
        }
        if (c.n < SZ - 1) {
            //BT::insert_in_leaf(c, e, offset);
        } else { // split
            BTNode p = BT::newNode();
            vector < pair <element, long> > v;
            for (int i = 0; i < c.n; i++) v.push_back(make_pair(c.value[i], c.ch[i]));
            auto it = v.begin();
            while (it != v.end() && e < it->first) it++;
            v.insert(it, make_pair(e, offset));
            int m = (SZ + 1) / 2;
            p.ch[SZ] = c.ch[SZ];
            c.ch[SZ] = p.offset;
            c.n = m;
            p.n = v.size() - m;
            for (size_t i = 0; i < v.size(); i++) {
                (i < m ? c.value[i] : p.value[i - m]) = v[i].first;
                (i < m ? c.ch[i]    : p.ch[i - m]   ) = v[i].second;
            }
            BT::insertParent(parent, c, p.value[0], p);
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50a0, %rsp           # imm = 0x50A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0xfe8(%rbp), %rdi
callq 0x14c00
leaq -0x1018(%rbp), %rdi
callq 0x15800
movb -0xfe8(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x12cfc
jmp 0x12e0e
movl $0x0, -0x101c(%rbp)
movl -0x101c(%rbp), %ecx
xorl %eax, %eax
cmpl -0xfe4(%rbp), %ecx
movb %al, -0x5039(%rbp)
jge 0x12d52
movslq -0x101c(%rbp), %rax
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
leaq -0xd98(%rbp,%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0x24ae0
movb %al, -0x503a(%rbp)
jmp 0x12d44
movb -0x503a(%rbp), %al
movb %al, -0x5039(%rbp)
jmp 0x12d52
movb -0x5039(%rbp), %al
testb $0x1, %al
jne 0x12d5e
jmp 0x12d86
movl -0x101c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x101c(%rbp)
jmp 0x12d06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1028(%rbp)
movl %eax, -0x102c(%rbp)
jmp 0x132e0
movq -0xfe0(%rbp), %rax
movq %rax, -0x5050(%rbp)
movslq -0x101c(%rbp), %rax
leaq -0xfd8(%rbp,%rax,8), %rsi
leaq -0x1018(%rbp), %rdi
callq 0x14f80
movq %rax, -0x5048(%rbp)
jmp 0x12db8
movq -0x5048(%rbp), %rax
movq -0x5050(%rbp), %rcx
movq %rcx, (%rax)
movslq -0x101c(%rbp), %rax
movq -0xfd8(%rbp,%rax,8), %rdx
leaq -0x2000(%rbp), %rdi
leaq -0x11(%rbp), %rsi
callq 0x13310
jmp 0x12dea
leaq -0xfe8(%rbp), %rdi
leaq -0x2000(%rbp), %rsi
callq 0x15820
leaq -0x2000(%rbp), %rdi
callq 0x14ee0
jmp 0x12ceb
cmpl $0x46, -0xfe4(%rbp)
jge 0x12e1c
jmp 0x132bf
leaq -0x2fd0(%rbp), %rdi
callq 0x121f0
jmp 0x12e2a
leaq -0x2fe8(%rbp), %rdi
callq 0x14a50
movl $0x0, -0x2fec(%rbp)
movl -0x2fec(%rbp), %eax
cmpl -0xfe4(%rbp), %eax
jge 0x12eeb
movslq -0x2fec(%rbp), %rax
leaq (%rax,%rax,2), %rcx
shlq $0x4, %rcx
leaq -0xd98(%rbp,%rcx), %rsi
leaq -0xfd8(%rbp,%rax,8), %rdx
leaq -0x3028(%rbp), %rdi
callq 0x14b00
jmp 0x12e7f
leaq -0x2fe8(%rbp), %rdi
leaq -0x3028(%rbp), %rsi
callq 0x14ad0
jmp 0x12e94
leaq -0x3028(%rbp), %rdi
callq 0x14b60
movl -0x2fec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2fec(%rbp)
jmp 0x12e40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1028(%rbp)
movl %eax, -0x102c(%rbp)
jmp 0x132a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1028(%rbp)
movl %eax, -0x102c(%rbp)
leaq -0x3028(%rbp), %rdi
callq 0x14b60
jmp 0x132a5
leaq -0x2fe8(%rbp), %rdi
callq 0x158a0
movq %rax, -0x3030(%rbp)
leaq -0x2fe8(%rbp), %rdi
callq 0x15910
movq %rax, -0x3038(%rbp)
leaq -0x3030(%rbp), %rdi
leaq -0x3038(%rbp), %rsi
callq 0x158d0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x5051(%rbp)
jne 0x12f35
jmp 0x12f71
movq -0x8(%rbp), %rax
movq %rax, -0x5060(%rbp)
leaq -0x3030(%rbp), %rdi
callq 0x15940
movq -0x5060(%rbp), %rdi
movq %rax, %rsi
callq 0x24850
movb %al, -0x5052(%rbp)
jmp 0x12f63
movb -0x5052(%rbp), %al
movb %al, -0x5051(%rbp)
jmp 0x12f71
movb -0x5051(%rbp), %al
testb $0x1, %al
jne 0x12f7d
jmp 0x12f97
leaq -0x3030(%rbp), %rdi
xorl %esi, %esi
callq 0x15960
movq %rax, -0x3040(%rbp)
jmp 0x12efe
leaq -0x3048(%rbp), %rdi
leaq -0x3030(%rbp), %rsi
callq 0x159e0
movq -0x8(%rbp), %rsi
leaq -0x3080(%rbp), %rdi
leaq -0x10(%rbp), %rdx
callq 0x15a20
jmp 0x12fc0
movq -0x3048(%rbp), %rsi
leaq -0x2fe8(%rbp), %rdi
leaq -0x3080(%rbp), %rdx
callq 0x159a0
movq %rax, -0x5068(%rbp)
jmp 0x12fe3
movq -0x5068(%rbp), %rax
movq %rax, -0x3088(%rbp)
leaq -0x3080(%rbp), %rdi
callq 0x14b60
movl $0x24, -0x308c(%rbp)
movq -0xda0(%rbp), %rax
movq %rax, -0x2d88(%rbp)
movq -0x2fc8(%rbp), %rax
movq %rax, -0xda0(%rbp)
movl -0x308c(%rbp), %eax
movl %eax, -0xfe4(%rbp)
leaq -0x2fe8(%rbp), %rdi
callq 0x15a60
movslq -0x308c(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x2fcc(%rbp)
movq $0x0, -0x3098(%rbp)
movq -0x3098(%rbp), %rax
movq %rax, -0x5070(%rbp)
leaq -0x2fe8(%rbp), %rdi
callq 0x15a60
movq %rax, %rcx
movq -0x5070(%rbp), %rax
cmpq %rcx, %rax
jae 0x131da
movq -0x3098(%rbp), %rsi
leaq -0x2fe8(%rbp), %rdi
callq 0x15a90
movq %rax, -0x5078(%rbp)
movq -0x3098(%rbp), %rax
movslq -0x308c(%rbp), %rcx
cmpq %rcx, %rax
jae 0x130d1
leaq -0xfe8(%rbp), %rax
addq $0x250, %rax            # imm = 0x250
imulq $0x30, -0x3098(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x5080(%rbp)
jmp 0x130fd
leaq -0x2fd0(%rbp), %rax
addq $0x250, %rax            # imm = 0x250
movq -0x3098(%rbp), %rcx
movslq -0x308c(%rbp), %rdx
subq %rdx, %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x5080(%rbp)
movq -0x5078(%rbp), %rsi
movq -0x5080(%rbp), %rdi
callq 0x14f30
jmp 0x13112
movq -0x3098(%rbp), %rsi
leaq -0x2fe8(%rbp), %rdi
callq 0x15a90
movq 0x30(%rax), %rax
movq %rax, -0x5088(%rbp)
movq -0x3098(%rbp), %rax
movslq -0x308c(%rbp), %rcx
cmpq %rcx, %rax
jae 0x13165
leaq -0xfe8(%rbp), %rax
addq $0x10, %rax
movq -0x3098(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x5090(%rbp)
jmp 0x1318f
leaq -0x2fd0(%rbp), %rax
addq $0x10, %rax
movq -0x3098(%rbp), %rcx
movslq -0x308c(%rbp), %rdx
subq %rdx, %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x5090(%rbp)
movq -0x5088(%rbp), %rcx
movq -0x5090(%rbp), %rax
movq %rcx, (%rax)
movq -0x3098(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x3098(%rbp)
jmp 0x13056
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1028(%rbp)
movl %eax, -0x102c(%rbp)
leaq -0x3080(%rbp), %rdi
callq 0x14b60
jmp 0x132a5
leaq -0x4068(%rbp), %rdi
leaq -0xfe8(%rbp), %rsi
callq 0x15720
jmp 0x131ef
leaq -0x2d80(%rbp), %rax
movq %rax, -0x5098(%rbp)
leaq -0x5038(%rbp), %rdi
leaq -0x2fd0(%rbp), %rsi
callq 0x15720
jmp 0x13212
movq -0x5098(%rbp), %rdx
leaq -0x1018(%rbp), %rdi
leaq -0x4068(%rbp), %rsi
leaq -0x5038(%rbp), %rcx
callq 0x123d0
jmp 0x13235
leaq -0x5038(%rbp), %rdi
callq 0x14ee0
leaq -0x4068(%rbp), %rdi
callq 0x14ee0
leaq -0x2fe8(%rbp), %rdi
callq 0x14ba0
leaq -0x2fd0(%rbp), %rdi
callq 0x14ee0
jmp 0x132bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1028(%rbp)
movl %eax, -0x102c(%rbp)
jmp 0x13299
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1028(%rbp)
movl %eax, -0x102c(%rbp)
leaq -0x5038(%rbp), %rdi
callq 0x14ee0
leaq -0x4068(%rbp), %rdi
callq 0x14ee0
leaq -0x2fe8(%rbp), %rdi
callq 0x14ba0
leaq -0x2fd0(%rbp), %rdi
callq 0x14ee0
jmp 0x132e0
leaq -0x1018(%rbp), %rdi
callq 0x15ab0
leaq -0xfe8(%rbp), %rdi
callq 0x14ee0
addq $0x50a0, %rsp           # imm = 0x50A0
popq %rbp
retq
leaq -0x1018(%rbp), %rdi
callq 0x15ab0
leaq -0xfe8(%rbp), %rdi
callq 0x14ee0
movq -0x1028(%rbp), %rdi
callq 0x34f0
nopw %cs:(%rax,%rax)