// File: /workspace/github_cpp_makefile_star2_O1/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 $0x7ef8, %rsp           # imm = 0x7EF8
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
cmpb $0x1, 0x1(%rsi)
jne 0xaa45
leaq -0x1068(%rbp), %rbx
movq %rbx, %rdi
callq 0xa772
movl $0x1, 0x4(%rbx)
movb $0x1, 0x1(%rbx)
movq (%r15), %rax
movq %rax, 0x250(%rbx)
leaq -0xe10(%rbp), %rdi
leaq 0x8(%r15), %rsi
callq 0x3150
movl 0x28(%r15), %eax
leaq -0x1068(%rbp), %rsi
movl %eax, 0x278(%rsi)
movq 0x8(%r12), %rax
movq %rax, 0x10(%rsi)
movq 0x8(%r14), %rax
movq %rax, 0x18(%rsi)
leaq -0x7f18(%rbp), %rdi
callq 0xa8a1
movq $-0xd80, %rbx           # imm = 0xF280
leaq -0x6f60(%rbp), %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0xaa09
callq 0x3270
addq $-0x30, %r14
addq $0x30, %rbx
jne 0xa9fb
leaq -0xb0(%rbp), %rbx
xorl %r14d, %r14d
movq -0xc0(%rbp,%r14), %rdi
leaq (%rbx,%r14), %rax
cmpq %rdi, %rax
je 0xaa33
callq 0x3270
addq $-0x30, %r14
cmpq $-0xd80, %r14           # imm = 0xF280
jne 0xaa1d
jmp 0xb016
movq %rdi, %rbx
addq $0x8, %r12
movq %r12, %rsi
callq 0xc928
movq (%rax), %rdx
movq 0x108ca(%rip), %rdi     # 0x1b328
leaq 0x108cb(%rip), %rsi     # 0x1b330
callq 0x9384
leaq -0x1068(%rbp), %r13
movq %r13, %rdi
callq 0xa621
movl -0x1064(%rbp), %eax
cmpl $0x45, %eax
jg 0xaab3
testl %eax, %eax
movq %r14, -0x68(%rbp)
jle 0xaeed
movq (%r12), %rcx
xorl %ebx, %ebx
cmpq -0x1058(%rbp,%rbx,8), %rcx
je 0xaeef
incq %rbx
cmpq %rbx, %rax
jne 0xaa96
movl %eax, %ebx
jmp 0xaeef
leaq -0xe18(%rbp), %rsi
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
leaq (%rax,%rbp), %rdx
addq $-0xe18, %rdx           # imm = 0xF1E8
leaq -0x48(%rbp), %rdi
leaq -0x2038(%rbp), %rcx
callq 0xc992
movq -0x1060(%rbp), %rsi
movslq -0x1064(%rbp), %rax
addq %rsi, %rax
incq %rax
leaq -0x2038(%rbp), %rdx
movq %rax, (%rdx)
leaq -0x60(%rbp), %rdi
leaq -0x98(%rbp), %rcx
callq 0xc9cc
movq -0x60(%rbp), %rsi
movq (%r12), %rax
movq $-0x30, %r12
movq %rsi, %rcx
addq $0x8, %rsi
addq $0x30, %r12
cmpq %rax, (%rcx)
jne 0xab1a
addq $0x8, %r14
leaq -0x60(%rbp), %rdi
movq %r14, %rdx
callq 0xca54
leaq -0x48(%rbp), %rdi
addq (%rdi), %r12
movq %r12, %rsi
movq %r15, %rdx
callq 0xcad6
leaq -0x2038(%rbp), %rdi
callq 0xa772
movl $0x23, -0x1064(%rbp)
movq -0x40(%rbp), %rax
subq -0x48(%rbp), %rax
shrq $0x4, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
addl $-0x24, %eax
movl %eax, -0x2034(%rbp)
movl $0x2, %r14d
xorl %r15d, %r15d
movq -0x48(%rbp), %r12
leaq (%r12,%r15), %rsi
addq $0x8, %rsi
movq -0x8(%rsi), %rax
leaq (%r15,%rbp), %rdi
addq $-0xe10, %rdi           # imm = 0xF1F0
movq %rax, -0x8(%rdi)
callq 0x3150
movl 0x28(%r12,%r15), %eax
movl %eax, -0xdf0(%rbp,%r15)
movq -0x60(%rbp), %rax
movq -0x10(%rax,%r14,8), %rax
movq %rax, -0x1068(%rbp,%r14,8)
incq %r14
addq $0x30, %r15
cmpq $0x690, %r15            # imm = 0x690
jne 0xab86
movq -0x60(%rbp), %rax
movq 0x118(%rax), %rax
movq %rax, -0xf40(%rbp)
movq -0x48(%rbp), %r14
movq 0x690(%r14), %rax
leaq -0x90(%rbp), %rdi
movq %rax, -0x8(%rdi)
leaq -0x80(%rbp), %rax
movq %rax, -0x10(%rax)
movq 0x698(%r14), %rsi
movq 0x6a0(%r14), %rdx
addq %rsi, %rdx
callq 0x8766
movl 0x6b8(%r14), %eax
movl %eax, -0x70(%rbp)
movq -0x48(%rbp), %r12
movq -0x40(%rbp), %rax
subq %r12, %rax
sarq $0x4, %rax
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r15, %rax
cmpq $0x25, %rax
jb 0xacb6
movl $0x24, %r13d
xorl %r14d, %r14d
leaq (%r12,%r14), %rsi
addq $0x6c8, %rsi            # imm = 0x6C8
movq -0x8(%rsi), %rax
leaq (%r14,%rbp), %rdi
addq $-0x1720, %rdi          # imm = 0xE8E0
movq %rax, -0x8(%rdi)
callq 0x3150
movl 0x6e8(%r12,%r14), %eax
movl %eax, -0x1700(%rbp,%r14)
movq -0x60(%rbp), %rax
movq (%rax,%r13,8), %rax
movq %rax, -0x2028(%rbp,%r13,8)
incq %r13
movq -0x48(%rbp), %r12
movq -0x40(%rbp), %rax
subq %r12, %rax
sarq $0x4, %rax
imulq %r15, %rax
addq $0x30, %r14
cmpq %r13, %rax
ja 0xac54
movq -0x58(%rbp), %rax
movq -0x8(%rax), %rax
leaq -0x2038(%rbp), %rsi
movslq 0x4(%rsi), %rcx
movq %rax, -0x2028(%rbp,%rcx,8)
leaq -0x5f78(%rbp), %rdi
callq 0xa8a1
movq $-0xd80, %r14           # imm = 0xF280
leaq -0x4fc0(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0xacf9
callq 0x3270
addq $-0x30, %r15
addq $0x30, %r14
jne 0xaceb
leaq -0x4fa8(%rbp), %rdi
leaq -0x1068(%rbp), %rsi
callq 0xa8a1
movq $-0xd80, %r14           # imm = 0xF280
leaq -0x3ff0(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0xad32
callq 0x3270
addq $-0x30, %r15
addq $0x30, %r14
jne 0xad24
leaq -0x3fd8(%rbp), %rdi
leaq -0x1068(%rbp), %rsi
movl $0x250, %edx            # imm = 0x250
callq 0x3210
xorl %r15d, %r15d
movq -0xe18(%rbp,%r15), %rax
movq -0xe10(%rbp,%r15), %rsi
leaq (%r15,%rbp), %rdi
addq $-0x3d80, %rdi          # imm = 0xC280
movq %rax, -0x8(%rdi)
leaq (%r15,%rbp), %rax
addq $-0x3d70, %rax          # imm = 0xC290
movq %rax, -0x10(%rax)
movq -0xe08(%rbp,%r15), %rdx
addq %rsi, %rdx
callq 0x8766
movl -0xdf0(%rbp,%r15), %eax
movl %eax, -0x3d60(%rbp,%r15)
addq $0x30, %r15
cmpq $0xd80, %r15            # imm = 0xD80
jne 0xad57
leaq -0x3008(%rbp), %rdi
leaq -0x2038(%rbp), %rsi
movl $0x250, %edx            # imm = 0x250
callq 0x3210
xorl %r15d, %r15d
movq -0x1de8(%rbp,%r15), %rax
movq -0x1de0(%rbp,%r15), %rsi
leaq (%r15,%rbp), %rdi
addq $-0x2db0, %rdi          # imm = 0xD250
movq %rax, -0x8(%rdi)
leaq (%r15,%rbp), %rax
addq $-0x2da0, %rax          # imm = 0xD260
movq %rax, -0x10(%rax)
movq -0x1dd8(%rbp,%r15), %rdx
addq %rsi, %rdx
callq 0x8766
movl -0x1dc0(%rbp,%r15), %eax
movl %eax, -0x2d90(%rbp,%r15)
addq $0x30, %r15
cmpq $0xd80, %r15            # imm = 0xD80
jne 0xadcc
leaq -0x3fd8(%rbp), %rsi
leaq -0x98(%rbp), %rdx
leaq -0x3008(%rbp), %rcx
movq %rbx, %rdi
callq 0xa964
movq $-0xd80, %rbx           # imm = 0xF280
leaq -0x2050(%rbp), %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0xae5f
callq 0x3270
addq $-0x30, %r14
addq $0x30, %rbx
jne 0xae51
movq $-0xd80, %rbx           # imm = 0xF280
leaq -0x3020(%rbp), %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0xae85
callq 0x3270
addq $-0x30, %r14
addq $0x30, %rbx
jne 0xae77
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0xaea4
callq 0x3270
leaq -0x1080(%rbp), %rbx
xorl %r14d, %r14d
movq -0x1090(%rbp,%r14), %rdi
leaq (%rbx,%r14), %rax
cmpq %rdi, %rax
je 0xaec4
callq 0x3270
addq $-0x30, %r14
cmpq $-0xd80, %r14           # imm = 0xF280
jne 0xaeae
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0xaedf
callq 0x3270
leaq -0x48(%rbp), %rdi
callq 0x889a
jmp 0xafe9
xorl %ebx, %ebx
leal 0x1(%rbx), %ecx
movl %ecx, -0x2c(%rbp)
cmpl %ebx, %eax
jle 0xaf56
incl %eax
movslq %eax, %r12
movq %r13, %rcx
movslq -0x2c(%rbp), %r13
leaq -0x1058(,%r12,8), %r15
addq %rbp, %r15
leaq (%r12,%r12,2), %rax
shlq $0x4, %rax
leaq (%rax,%rcx), %r14
addq $0x1f0, %r14            # imm = 0x1F0
movq -0x8(%r15), %rax
movq %rax, (%r15)
movq (%r14), %rax
movq %rax, 0x30(%r14)
leaq 0x38(%r14), %rdi
leaq 0x8(%r14), %rsi
callq 0x3150
decq %r12
movl 0x28(%r14), %eax
movl %eax, 0x58(%r14)
addq $-0x8, %r15
addq $-0x30, %r14
cmpq %r13, %r12
jg 0xaf23
movq -0x68(%rbp), %r14
movq 0x8(%r14), %rax
movl -0x2c(%rbp), %ecx
movq %rax, -0x1058(%rbp,%rcx,8)
movl %ebx, %eax
leaq (%rax,%rax,2), %rbx
shlq $0x4, %rbx
leaq (%rbx,%rbp), %rdi
addq $-0x1068, %rdi          # imm = 0xEF98
movq 0x250(%r14), %rax
movq %rax, 0x250(%rdi)
movl $0x258, %esi            # imm = 0x258
addq %rsi, %rdi
addq %r14, %rsi
callq 0x3150
leaq (%rbx,%rbp), %rax
addq $-0xe18, %rax           # imm = 0xF1E8
movl 0x278(%r14), %ecx
movl %ecx, 0x28(%rax)
leaq -0x6f48(%rbp), %rdi
leaq -0x1068(%rbp), %rsi
callq 0xa8a1
movq $-0xd80, %rbx           # imm = 0xF280
leaq -0x5f90(%rbp), %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0xafdf
callq 0x3270
addq $-0x30, %r14
addq $0x30, %rbx
jne 0xafd1
leaq -0xb0(%rbp), %rbx
xorl %r14d, %r14d
movq -0xc0(%rbp,%r14), %rdi
leaq (%rbx,%r14), %rax
cmpq %rdi, %rax
je 0xb009
callq 0x3270
addq $-0x30, %r14
cmpq $-0xd80, %r14           # imm = 0xF280
jne 0xaff3
addq $0x7ef8, %rsp           # imm = 0x7EF8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x3008(%rbp), %rdi
callq 0x356e
jmp 0xb0aa
jmp 0xb117
jmp 0xb042
jmp 0xb042
movq %rax, %rbx
jmp 0xb140
movq %rax, %rbx
jmp 0xb14e
jmp 0xb074
jmp 0xb06c
jmp 0xb074
movq %rax, %rbx
leaq -0x1068(%rbp), %rdi
callq 0x35a3
jmp 0xb184
movq %rax, %rbx
jmp 0xb100
movq %rax, %rbx
jmp 0xb157
movq %rax, %rbx
testq %r15, %r15
je 0xb0aa
leaq (%r15,%rbp), %r14
addq $-0x2dd0, %r14          # imm = 0xD230
negq %r15
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0xb0a0
callq 0x3270
addq $-0x30, %r14
addq $0x30, %r15
jne 0xb092
movq $-0xd80, %r14           # imm = 0xF280
leaq -0x3020(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0xb0c6
callq 0x3270
addq $-0x30, %r15
addq $0x30, %r14
jne 0xb0b8
jmp 0xb100
movq %rax, %rbx
testq %r15, %r15
je 0xb100
leaq (%r15,%rbp), %r14
addq $-0x3da0, %r14          # imm = 0xC260
negq %r15
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0xb0f6
callq 0x3270
addq $-0x30, %r14
addq $0x30, %r15
jne 0xb0e8
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0xb11a
callq 0x3270
jmp 0xb11a
movq %rax, %rbx
movq $-0xd80, %r14           # imm = 0xF280
leaq -0x1080(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0xb136
callq 0x3270
addq $-0x30, %r15
addq $0x30, %r14
jne 0xb128
movq -0x60(%rbp), %rdi
testq %rdi, %rdi
je 0xb14e
callq 0x3270
leaq -0x48(%rbp), %rdi
callq 0x889a
leaq -0xb0(%rbp), %r14
xorl %r15d, %r15d
movq -0xc0(%rbp,%r15), %rdi
leaq (%r14,%r15), %rax
cmpq %rdi, %rax
je 0xb177
callq 0x3270
addq $-0x30, %r15
cmpq $-0xd80, %r15           # imm = 0xF280
jne 0xb161
movq %rbx, %rdi
callq 0x3480