// File: /workspace/github_cpp_makefile_star2_O2/zimpha[P]MiniSQL/indexManager.cc
// Function: BT::insertParent(std::map<long, long, std::less<long>, std::allocator<std::pair<long const, long>>>&, BTNode, element const&, BTNode)
void insertParent(map <long, long> &parent, BTNode p, const element &e, BTNode q) {
        if (p.isRoot) {
            BTNode w = newNode();
            w.n = 1;
            w.isRoot = true;
            //setRoot(name, bfm, w.offset);
            w.value[0] = e;
            w.ch[0] = p.offset;
            w.ch[1] = q.offset;
            save(w);
            return;
        }
        auto go = [&] (long off) { return blockToNode(*(bfm->BufferManagerRead(name, off))); };
        BTNode f = go(parent[p.offset]);
        if (f.n < SZ - 1) {
            int i = 0;
            while (i < f.n && p.offset != f.ch[i]) i++;
            for (int j = f.n + 1; j > i + 1; j--) {
                f.ch[j] = f.ch[j - 1];
                f.value[j - 1] = f.value[j - 2];
            }
            f.ch[i + 1] = q.offset;
            f.value[i] = q.value[0];
            save(f);
        } else { //split
            vector <element> ele(f.value, f.value + f.n);
            vector <long> off(f.offset, f.offset + f.n + 1);
            int i = 0;
            while (off[i] != p.offset) i++;
            off.insert(off.begin() + i + 1, q.offset);
            ele.insert(ele.begin() + i, e);
            int m = (SZ + 1) / 2;
            BTNode w = newNode();
            f.n = m - 1;
            w.n = ele.size() - m;
            for (i = 0; i < m - 1; i++) {
                f.value[i] = ele[i];
                f.ch[i] = off[i];
            }
            f.ch[m - 1] = off[m - 1];
            element cur = ele[m - 1];
            for (i = m; i < ele.size(); i++) {
                w.value[i] = ele[i];
                w.ch[i] = off[i];
            }
            w.ch[w.n] = off.back();
            save(w);
            save(f);
            insertParent(parent, f, cur, w);
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7ee8, %rsp           # imm = 0x7EE8
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r13
cmpb $0x1, 0x1(%rsi)
jne 0x8cf7
leaq -0x1060(%rbp), %rbx
movq %rbx, %rdi
callq 0x8b36
movl $0x1, 0x4(%rbx)
movb $0x1, 0x1(%rbx)
leaq -0xe10(%rbp), %rdi
movq %r15, %rsi
callq 0xa244
movq 0x8(%r13), %rax
leaq -0x1060(%rbp), %rsi
movq %rax, 0x10(%rsi)
movq 0x8(%r14), %rax
movq %rax, 0x18(%rsi)
leaq -0x7f10(%rbp), %rdi
callq 0x8c09
leaq -0x7f10(%rbp), %rdi
jmp 0x9061
movq %rdi, %rbx
movq %r14, -0x48(%rbp)
addq $0x8, %r13
movq %r13, %rsi
callq 0xa274
movq (%rax), %rdx
movq 0x10604(%rip), %rdi     # 0x19318
leaq 0x10605(%rip), %rsi     # 0x19320
callq 0x7a04
leaq -0x1060(%rbp), %r14
xorl %r12d, %r12d
movl $0xfd0, %edx            # imm = 0xFD0
movq %r14, %rdi
xorl %esi, %esi
callq 0x3160
movq %r14, %rdi
callq 0xa130
movslq -0x105c(%rbp), %rax
cmpq $0x45, %rax
jg 0x8d7a
testl %eax, %eax
movl $0x0, %r15d
cmovgl %eax, %r15d
cmpq %r12, %r15
je 0x8fcf
movq (%r13), %rcx
cmpq -0x1050(%rbp,%r12,8), %rcx
je 0x8fcc
incq %r12
jmp 0x8d5a
movq %r15, %r14
leaq -0xe10(%rbp), %r15
imulq $0x30, %rax, %rax
leaq (%rax,%rbp), %rdx
addq $-0xe10, %rdx           # imm = 0xF1F0
leaq -0x40(%rbp), %rdi
leaq -0x2030(%rbp), %rcx
movq %r15, %rsi
callq 0xa2c6
movq -0x1058(%rbp), %rsi
movslq -0x105c(%rbp), %rax
addq %rsi, %rax
incq %rax
leaq -0x2030(%rbp), %rdx
movq %rax, (%rdx)
leaq -0x60(%rbp), %rdi
leaq -0x90(%rbp), %rcx
callq 0xa2f8
movq -0x60(%rbp), %rsi
movq (%r13), %rax
pushq $-0x30
popq %r13
movq %rsi, %rcx
addq $0x8, %rsi
addq $0x30, %r13
cmpq %rax, (%rcx)
jne 0x8de0
movq -0x48(%rbp), %rdx
addq $0x8, %rdx
leaq -0x60(%rbp), %rdi
callq 0xa358
leaq -0x40(%rbp), %rdi
addq (%rdi), %r13
movq %r13, %rsi
movq %r14, %rdx
callq 0xa3ca
leaq -0x2030(%rbp), %rdi
callq 0x8b36
movl $0x23, -0x105c(%rbp)
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
pushq $0x30
popq %r12
cqto
idivq %r12
addl $-0x24, %eax
movl %eax, -0x202c(%rbp)
xorl %r14d, %r14d
xorl %r13d, %r13d
cmpq $0x23, %r13
je 0x8e7b
movq -0x40(%rbp), %rsi
addq %r14, %rsi
movq %r15, %rdi
callq 0xa244
movq -0x60(%rbp), %rax
movq (%rax,%r13,8), %rax
movq %rax, -0x1050(%rbp,%r13,8)
incq %r13
addq $0x30, %r15
addq $0x30, %r14
jmp 0x8e49
movq -0x60(%rbp), %rax
movq 0x118(%rax), %rax
movq %rax, -0xf38(%rbp)
movl $0x690, %esi            # imm = 0x690
addq -0x40(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x5e98
pushq $0x24
popq %r15
movl $0x6c0, %r13d           # imm = 0x6C0
leaq -0x1720(%rbp), %r14
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rax
subq %rsi, %rax
cqto
idivq %r12
cmpq %r15, %rax
jbe 0x8ef0
addq %r13, %rsi
movq %r14, %rdi
callq 0xa244
movq -0x60(%rbp), %rax
movq (%rax,%r15,8), %rax
movq %rax, -0x2020(%rbp,%r15,8)
incq %r15
addq $0x30, %r14
addq $0x30, %r13
jmp 0x8eb3
movq -0x58(%rbp), %rax
movq -0x8(%rax), %rax
leaq -0x2030(%rbp), %rsi
movslq 0x4(%rsi), %rcx
movq %rax, -0x2020(%rbp,%rcx,8)
leaq -0x5f70(%rbp), %rdi
callq 0x8c09
leaq -0x5f70(%rbp), %rdi
callq 0xa218
leaq -0x4fa0(%rbp), %rdi
leaq -0x1060(%rbp), %rsi
callq 0x8c09
leaq -0x4fa0(%rbp), %rdi
callq 0xa218
leaq -0x3fd0(%rbp), %rdi
leaq -0x1060(%rbp), %rsi
callq 0xa468
leaq -0x3000(%rbp), %rdi
leaq -0x2030(%rbp), %rsi
callq 0xa468
leaq -0x3fd0(%rbp), %rsi
leaq -0x90(%rbp), %rdx
leaq -0x3000(%rbp), %rcx
movq %rbx, %rdi
callq 0x8c7c
leaq -0x3000(%rbp), %rdi
callq 0xa218
leaq -0x3fd0(%rbp), %rdi
callq 0xa218
leaq -0x88(%rbp), %rdi
callq 0x34f8
leaq -0x2030(%rbp), %rdi
callq 0xa218
leaq -0x60(%rbp), %rdi
callq 0x7452
leaq -0x40(%rbp), %rdi
callq 0x6dc8
jmp 0x9066
movl %r12d, %r15d
incl %eax
leal 0x1(%r15), %ecx
leaq -0xe10(%rbp), %rbx
cltq
movslq %ecx, %r12
imulq $0x30, %rax, %rcx
leaq (%rcx,%r14), %rsi
addq $0x1f0, %rsi            # imm = 0x1F0
cmpq %r12, %rax
jle 0x901e
leaq -0x1(%rax), %r13
movq -0x1058(%rbp,%rax,8), %rcx
movq %rcx, -0x1050(%rbp,%rax,8)
leaq -0x30(%rsi), %r14
leaq 0x30(%rsi), %rdi
callq 0xa244
movq %r14, %rsi
movq %r13, %rax
jmp 0x8ff0
movq -0x48(%rbp), %rsi
movq 0x8(%rsi), %rax
movq %rax, -0x1050(%rbp,%r12,8)
addq $0x250, %rsi            # imm = 0x250
movl %r15d, %eax
imulq $0x30, %rax, %rax
addq %rax, %rbx
movq %rbx, %rdi
callq 0xa244
leaq -0x6f40(%rbp), %rdi
leaq -0x1060(%rbp), %rsi
callq 0x8c09
leaq -0x6f40(%rbp), %rdi
callq 0xa218
leaq -0x1060(%rbp), %rdi
callq 0xa218
addq $0x7ee8, %rsp           # imm = 0x7EE8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x3000(%rbp), %rdi
callq 0xa218
jmp 0x9098
movq %rax, %rbx
leaq -0x3fd0(%rbp), %rdi
callq 0xa218
jmp 0x90c1
jmp 0x90cf
jmp 0x90ac
jmp 0x90ac
movq %rax, %rbx
jmp 0x90de
movq %rax, %rbx
jmp 0x90e7
jmp 0x90f2
jmp 0x90f2
jmp 0x90be
jmp 0x90f2
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x34f8
jmp 0x90d2
movq %rax, %rbx
leaq -0x2030(%rbp), %rdi
callq 0xa218
leaq -0x60(%rbp), %rdi
callq 0x7452
leaq -0x40(%rbp), %rdi
callq 0x6dc8
jmp 0x90f5
movq %rax, %rbx
leaq -0x1060(%rbp), %rdi
callq 0xa218
movq %rbx, %rdi
callq 0x3450