// File: /workspace/github_cpp_makefile_star2_O3/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, %r12
cmpb $0x1, 0x1(%rsi)
jne 0xab91
leaq -0x1060(%rbp), %rbx
movq %rbx, %rdi
callq 0xa8be
movl $0x1, 0x4(%rbx)
movb $0x1, 0x1(%rbx)
movq (%r15), %rax
movq %rax, 0x250(%rbx)
leaq -0xe08(%rbp), %rdi
leaq 0x8(%r15), %rsi
callq 0x3150
movl 0x28(%r15), %eax
leaq -0x1060(%rbp), %rsi
movl %eax, 0x278(%rsi)
movq 0x8(%r12), %rax
movq %rax, 0x10(%rsi)
movq 0x8(%r14), %rax
movq %rax, 0x18(%rsi)
leaq -0x7f10(%rbp), %rdi
callq 0xa9ed
movq $-0xd80, %rbx           # imm = 0xF280
leaq -0x6f58(%rbp), %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0xab55
callq 0x3270
addq $-0x30, %r14
addq $0x30, %rbx
jne 0xab47
leaq -0xa8(%rbp), %rbx
xorl %r14d, %r14d
movq -0xb8(%rbp,%r14), %rdi
leaq (%rbx,%r14), %rax
cmpq %rdi, %rax
je 0xab7f
callq 0x3270
addq $-0x30, %r14
cmpq $-0xd80, %r14           # imm = 0xF280
jne 0xab69
jmp 0xb0f3
movq %rdi, %rbx
addq $0x8, %r12
movq %r12, %rsi
callq 0xca6e
movq (%rax), %rdx
movq 0x1077e(%rip), %rdi     # 0x1b328
leaq 0x1077f(%rip), %rsi     # 0x1b330
callq 0x94d8
leaq -0x1060(%rbp), %r13
movq %r13, %rdi
callq 0xa76d
movslq -0x105c(%rbp), %rax
cmpq $0x45, %rax
jg 0xabfb
testl %eax, %eax
jle 0xb031
movq (%r12), %rcx
xorl %ebx, %ebx
cmpq -0x1050(%rbp,%rbx,8), %rcx
je 0xb105
incq %rbx
cmpq %rbx, %rax
jne 0xabe0
jmp 0xb033
leaq -0xe10(%rbp), %rsi
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
leaq (%rax,%rbp), %rdx
addq $-0xe10, %rdx           # imm = 0xF1F0
leaq -0x40(%rbp), %rdi
leaq -0x2030(%rbp), %rcx
callq 0xcad6
movq -0x1058(%rbp), %rsi
movslq -0x105c(%rbp), %rax
addq %rsi, %rax
incq %rax
leaq -0x2030(%rbp), %rdx
movq %rax, (%rdx)
leaq -0x58(%rbp), %rdi
leaq -0x90(%rbp), %rcx
callq 0xcb10
movq -0x58(%rbp), %rsi
movq (%r12), %rax
movq $-0x30, %r12
movq %rsi, %rcx
addq $0x8, %rsi
addq $0x30, %r12
cmpq %rax, (%rcx)
jne 0xac62
addq $0x8, %r14
leaq -0x58(%rbp), %rdi
movq %r14, %rdx
callq 0xcb98
leaq -0x40(%rbp), %rdi
addq (%rdi), %r12
movq %r12, %rsi
movq %r15, %rdx
callq 0xcc1a
leaq -0x2030(%rbp), %rdi
callq 0xa8be
movl $0x23, -0x105c(%rbp)
movq -0x38(%rbp), %rax
subq -0x40(%rbp), %rax
shrq $0x4, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
addl $-0x24, %eax
movl %eax, -0x202c(%rbp)
movl $0x2, %r14d
xorl %r15d, %r15d
movq -0x40(%rbp), %r12
leaq (%r12,%r15), %rsi
addq $0x8, %rsi
movq -0x8(%rsi), %rax
leaq (%r15,%rbp), %rdi
addq $-0xe08, %rdi           # imm = 0xF1F8
movq %rax, -0x8(%rdi)
callq 0x3150
movl 0x28(%r12,%r15), %eax
movl %eax, -0xde8(%rbp,%r15)
movq -0x58(%rbp), %rax
movq -0x10(%rax,%r14,8), %rcx
movq %rcx, -0x1060(%rbp,%r14,8)
incq %r14
addq $0x30, %r15
cmpq $0x690, %r15            # imm = 0x690
jne 0xacce
movq 0x118(%rax), %rax
movq %rax, -0xf38(%rbp)
movq -0x40(%rbp), %r14
movq 0x690(%r14), %rax
leaq -0x88(%rbp), %rdi
movq %rax, -0x8(%rdi)
leaq -0x78(%rbp), %rax
movq %rax, -0x10(%rax)
movq 0x698(%r14), %rsi
movq 0x6a0(%r14), %rdx
addq %rsi, %rdx
callq 0x88b4
movl 0x6b8(%r14), %eax
movl %eax, -0x68(%rbp)
movq -0x40(%rbp), %r12
movq -0x38(%rbp), %rax
subq %r12, %rax
sarq $0x4, %rax
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
imulq %r15, %rax
cmpq $0x25, %rax
jb 0xadfa
movl $0x24, %r13d
xorl %r14d, %r14d
leaq (%r12,%r14), %rsi
addq $0x6c8, %rsi            # imm = 0x6C8
movq -0x8(%rsi), %rax
leaq (%r14,%rbp), %rdi
addq $-0x1718, %rdi          # imm = 0xE8E8
movq %rax, -0x8(%rdi)
callq 0x3150
movl 0x6e8(%r12,%r14), %eax
movl %eax, -0x16f8(%rbp,%r14)
movq -0x58(%rbp), %rax
movq (%rax,%r13,8), %rax
movq %rax, -0x2020(%rbp,%r13,8)
incq %r13
movq -0x40(%rbp), %r12
movq -0x38(%rbp), %rax
subq %r12, %rax
sarq $0x4, %rax
imulq %r15, %rax
addq $0x30, %r14
cmpq %r13, %rax
ja 0xad98
movq -0x50(%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 0xa9ed
movq $-0xd80, %r14           # imm = 0xF280
leaq -0x4fb8(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0xae3d
callq 0x3270
addq $-0x30, %r15
addq $0x30, %r14
jne 0xae2f
leaq -0x4fa0(%rbp), %rdi
leaq -0x1060(%rbp), %rsi
callq 0xa9ed
movq $-0xd80, %r14           # imm = 0xF280
leaq -0x3fe8(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0xae76
callq 0x3270
addq $-0x30, %r15
addq $0x30, %r14
jne 0xae68
leaq -0x3fd0(%rbp), %rdi
leaq -0x1060(%rbp), %rsi
movl $0x250, %edx            # imm = 0x250
callq 0x3210
xorl %r15d, %r15d
movq -0xe10(%rbp,%r15), %rax
movq -0xe08(%rbp,%r15), %rsi
leaq (%r15,%rbp), %rdi
addq $-0x3d78, %rdi          # imm = 0xC288
movq %rax, -0x8(%rdi)
leaq (%r15,%rbp), %rax
addq $-0x3d68, %rax          # imm = 0xC298
movq %rax, -0x10(%rax)
movq -0xe00(%rbp,%r15), %rdx
addq %rsi, %rdx
callq 0x88b4
movl -0xde8(%rbp,%r15), %eax
movl %eax, -0x3d58(%rbp,%r15)
addq $0x30, %r15
cmpq $0xd80, %r15            # imm = 0xD80
jne 0xae9b
leaq -0x3000(%rbp), %rdi
leaq -0x2030(%rbp), %rsi
movl $0x250, %edx            # imm = 0x250
callq 0x3210
xorl %r15d, %r15d
movq -0x1de0(%rbp,%r15), %rax
movq -0x1dd8(%rbp,%r15), %rsi
leaq (%r15,%rbp), %rdi
addq $-0x2da8, %rdi          # imm = 0xD258
movq %rax, -0x8(%rdi)
leaq (%r15,%rbp), %rax
addq $-0x2d98, %rax          # imm = 0xD268
movq %rax, -0x10(%rax)
movq -0x1dd0(%rbp,%r15), %rdx
addq %rsi, %rdx
callq 0x88b4
movl -0x1db8(%rbp,%r15), %eax
movl %eax, -0x2d88(%rbp,%r15)
addq $0x30, %r15
cmpq $0xd80, %r15            # imm = 0xD80
jne 0xaf10
leaq -0x3fd0(%rbp), %rsi
leaq -0x90(%rbp), %rdx
leaq -0x3000(%rbp), %rcx
movq %rbx, %rdi
callq 0xaab0
movq $-0xd80, %rbx           # imm = 0xF280
leaq -0x2048(%rbp), %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0xafa3
callq 0x3270
addq $-0x30, %r14
addq $0x30, %rbx
jne 0xaf95
movq $-0xd80, %rbx           # imm = 0xF280
leaq -0x3018(%rbp), %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0xafc9
callq 0x3270
addq $-0x30, %r14
addq $0x30, %rbx
jne 0xafbb
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0xafe8
callq 0x3270
leaq -0x1078(%rbp), %rbx
xorl %r14d, %r14d
movq -0x1088(%rbp,%r14), %rdi
leaq (%rbx,%r14), %rax
cmpq %rdi, %rax
je 0xb008
callq 0x3270
addq $-0x30, %r14
cmpq $-0xd80, %r14           # imm = 0xF280
jne 0xaff2
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0xb023
callq 0x3270
leaq -0x40(%rbp), %rdi
callq 0x89f0
jmp 0xb0c6
xorl %eax, %eax
leal 0x1(%rax), %r15d
movq 0x8(%r14), %rcx
movl %r15d, %edx
movq %rcx, -0x1050(%rbp,%rdx,8)
movl %eax, %eax
leaq (%rax,%rax,2), %rbx
shlq $0x4, %rbx
leaq (%rbx,%rbp), %rdi
addq $-0x1060, %rdi          # imm = 0xEFA0
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 $-0xe10, %rax           # imm = 0xF1F0
movl 0x278(%r14), %ecx
movl %ecx, 0x28(%rax)
leaq -0x6f40(%rbp), %rdi
leaq -0x1060(%rbp), %rsi
callq 0xa9ed
movq $-0xd80, %rbx           # imm = 0xF280
leaq -0x5f88(%rbp), %r14
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0xb0bc
callq 0x3270
addq $-0x30, %r14
addq $0x30, %rbx
jne 0xb0ae
leaq -0xa8(%rbp), %rbx
xorl %r14d, %r14d
movq -0xb8(%rbp,%r14), %rdi
leaq (%rbx,%r14), %rax
cmpq %rdi, %rax
je 0xb0e6
callq 0x3270
addq $-0x30, %r14
cmpq $-0xd80, %r14           # imm = 0xF280
jne 0xb0d0
addq $0x7ee8, %rsp           # imm = 0x7EE8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1(%rbx), %r15
cmpl %ebx, %eax
jle 0xb175
movq %r14, -0x60(%rbp)
leaq 0x1(%rax), %r12
movq %r13, %rcx
leaq -0x1048(,%rax,8), %r13
addq %rbp, %r13
leaq (%rax,%rax,2), %rax
shlq $0x4, %rax
leaq (%rax,%rcx), %r14
addq $0x220, %r14            # imm = 0x220
movq -0x8(%r13), %rax
movq %rax, (%r13)
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, %r13
addq $-0x30, %r14
cmpq %r15, %r12
jg 0xb136
movl %ebx, %eax
movq -0x60(%rbp), %r14
jmp 0xb037
movl %ebx, %eax
jmp 0xb037
movq %rax, %rbx
leaq -0x3000(%rbp), %rdi
callq 0x356e
jmp 0xb1fe
jmp 0xb26b
jmp 0xb196
jmp 0xb196
movq %rax, %rbx
jmp 0xb294
movq %rax, %rbx
jmp 0xb2a2
jmp 0xb1c0
jmp 0xb1c8
jmp 0xb1c0
movq %rax, %rbx
leaq -0x1060(%rbp), %rdi
callq 0x35a3
jmp 0xb2d8
movq %rax, %rbx
jmp 0xb2ab
movq %rax, %rbx
jmp 0xb254
movq %rax, %rbx
testq %r15, %r15
je 0xb1fe
leaq (%r15,%rbp), %r14
addq $-0x2dc8, %r14          # imm = 0xD238
negq %r15
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0xb1f4
callq 0x3270
addq $-0x30, %r14
addq $0x30, %r15
jne 0xb1e6
movq $-0xd80, %r14           # imm = 0xF280
leaq -0x3018(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0xb21a
callq 0x3270
addq $-0x30, %r15
addq $0x30, %r14
jne 0xb20c
jmp 0xb254
movq %rax, %rbx
testq %r15, %r15
je 0xb254
leaq (%r15,%rbp), %r14
addq $-0x3d98, %r14          # imm = 0xC268
negq %r15
movq -0x10(%r14), %rdi
cmpq %rdi, %r14
je 0xb24a
callq 0x3270
addq $-0x30, %r14
addq $0x30, %r15
jne 0xb23c
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0xb26e
callq 0x3270
jmp 0xb26e
movq %rax, %rbx
movq $-0xd80, %r14           # imm = 0xF280
leaq -0x1078(%rbp), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0xb28a
callq 0x3270
addq $-0x30, %r15
addq $0x30, %r14
jne 0xb27c
movq -0x58(%rbp), %rdi
testq %rdi, %rdi
je 0xb2a2
callq 0x3270
leaq -0x40(%rbp), %rdi
callq 0x89f0
leaq -0xa8(%rbp), %r14
xorl %r15d, %r15d
movq -0xb8(%rbp,%r15), %rdi
leaq (%r14,%r15), %rax
cmpq %rdi, %rax
je 0xb2cb
callq 0x3270
addq $-0x30, %r15
cmpq $-0xd80, %r15           # imm = 0xF280
jne 0xb2b5
movq %rbx, %rdi
callq 0x3480