// File: /workspace/github_c_makefile_star2_O1/johsteffens[P]beth/lib/bcore/bcore_btree.c
// Function: bcore_btree_ip_s_push
void bcore_btree_ip_s_push( bcore_btree_ip_s* o, bcore_btree_node_ip_s* node, bcore_btree_ip_kv_s* kv, bcore_btree_node_ip_s* child0, bcore_btree_node_ip_s* child1 )
{
    if( bcore_btree_node_ip_s_is_full( node ) )
    {
        bcore_btree_node_ip_s* l_node = node;
        bcore_btree_node_ip_s* r_node = bcore_btree_ip_s_new_node( o );
        bcore_btree_ip_kv_s root_kv;

        if( kv->key < node->kv1.key )
        {
            root_kv        = l_node->kv1;
            r_node->kv1    = l_node->kv2;
            r_node->child0 = l_node->child1;
            r_node->child1 = l_node->child2;
            l_node->kv1    = *kv;
            l_node->child0 = child0;
            l_node->child1 = child1;
        }
        else if( kv->key > node->kv2.key )
        {
            root_kv        = l_node->kv2;
            r_node->kv1    = *kv;
            r_node->child0 = child0;
            r_node->child1 = child1;
        }
        else
        {
            root_kv        = *kv;
            r_node->kv1    = l_node->kv2;
            r_node->child1 = l_node->child2;
            r_node->child0 = child1;
            l_node->child1 = child0;
        }
        r_node->child2 = NULL;
        l_node->child2 = NULL;

        bcore_btree_node_ip_s_set_parent_child0( r_node );
        bcore_btree_node_ip_s_set_parent_child1( r_node );
        bcore_btree_node_ip_s_set_parent_child0( l_node );
        bcore_btree_node_ip_s_set_parent_child1( l_node );

        if( l_node->parent )
        {
            bcore_btree_ip_s_push( o, l_node->parent, &root_kv, l_node, r_node );
        }
        else
        {
            o->root = bcore_btree_ip_s_new_node( o );
            o->root->kv1    = root_kv;
            o->root->child0 = l_node;
            o->root->child1 = r_node;
            l_node->parent  = o->root;
            r_node->parent  = o->root;
        }
    }
    else
    {
        if( kv->key < node->kv1.key )
        {
            node->kv2    = node->kv1;
            node->kv1    = *kv;
            node->child2 = node->child1;
            node->child1 = child1;
            node->child0 = child0;
            bcore_btree_node_ip_s_set_parent_child0( node );
            bcore_btree_node_ip_s_set_parent_child1( node );
            bcore_btree_node_ip_s_set_parent_child2( node );
        }
        else
        {
            node->kv2    = *kv;
            node->child2 = child1;
            node->child1 = child0;
            bcore_btree_node_ip_s_set_parent_child1( node );
            bcore_btree_node_ip_s_set_parent_child2( node );
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r12
movq %rcx, %r13
movq %rdx, %rbp
movq %rsi, %rbx
cmpq $0x0, 0x38(%rsi)
je 0x12db82
movq %rdi, %r14
callq 0x12da65
movq %rax, %r15
movq (%rbp), %rcx
cmpq (%rbx), %rcx
jae 0x12dc01
movups (%rbx), %xmm0
movaps %xmm0, (%rsp)
movups 0x10(%rbx), %xmm0
movups %xmm0, (%r15)
movq 0x30(%rbx), %rax
movq %rax, 0x28(%r15)
movq 0x38(%rbx), %rax
movq %rax, 0x30(%r15)
movups (%rbp), %xmm0
movups %xmm0, (%rbx)
movq %r13, 0x28(%rbx)
movq %r12, 0x30(%rbx)
jmp 0x12dc8b
movq (%rbp), %rcx
leaq 0x10(%rbx), %rax
cmpq (%rbx), %rcx
jae 0x12dc24
movups (%rbx), %xmm0
movups %xmm0, (%rax)
movups (%rbp), %xmm0
movups %xmm0, (%rbx)
movq 0x30(%rbx), %rax
movq %rax, 0x38(%rbx)
movq %r12, 0x30(%rbx)
movq %r13, 0x28(%rbx)
testq %r13, %r13
sete %dl
leaq 0x7c773(%rip), %rcx     # 0x1aa330
cmpq %rcx, %r13
sete %sil
orb %dl, %sil
jne 0x12dbcd
movq %rbx, 0x20(%r13)
testq %r12, %r12
sete %dl
cmpq %rcx, %r12
sete %sil
orb %dl, %sil
jne 0x12dbe4
movq %rbx, 0x20(%r12)
testq %rax, %rax
sete %dl
cmpq %rcx, %rax
sete %cl
orb %dl, %cl
jne 0x12dd43
movq %rbx, 0x20(%rax)
jmp 0x12dd43
leaq 0x10(%rbx), %rax
cmpq 0x10(%rbx), %rcx
jbe 0x12dc6c
movups (%rax), %xmm0
movaps %xmm0, (%rsp)
movups (%rbp), %xmm0
movups %xmm0, (%r15)
movq %r13, 0x28(%r15)
movq %r12, 0x30(%r15)
jmp 0x12dc8b
movups (%rbp), %xmm0
movups %xmm0, (%rax)
movq %r12, 0x38(%rbx)
movq %r13, 0x30(%rbx)
testq %r13, %r13
sete %cl
leaq 0x7c6f0(%rip), %rax     # 0x1aa330
cmpq %rax, %r13
sete %dl
orb %cl, %dl
jne 0x12dc4e
movq %rbx, 0x20(%r13)
testq %r12, %r12
sete %cl
cmpq %rax, %r12
sete %al
orb %cl, %al
jne 0x12dd43
movq %rbx, 0x20(%r12)
jmp 0x12dd43
movups (%rbp), %xmm0
movaps %xmm0, (%rsp)
movups (%rax), %xmm0
movups %xmm0, (%r15)
movq 0x38(%rbx), %rax
movq %rax, 0x30(%r15)
movq %r12, 0x28(%r15)
movq %r13, 0x30(%rbx)
xorl %eax, %eax
movq %rax, 0x38(%r15)
movq %rax, 0x38(%rbx)
movq 0x28(%r15), %rcx
testq %rcx, %rcx
sete %dl
leaq 0x7c68a(%rip), %rax     # 0x1aa330
cmpq %rax, %rcx
sete %sil
orb %dl, %sil
jne 0x12dcb6
movq %r15, 0x20(%rcx)
movq 0x30(%r15), %rcx
testq %rcx, %rcx
sete %dl
cmpq %rax, %rcx
sete %sil
orb %dl, %sil
jne 0x12dcd0
movq %r15, 0x20(%rcx)
movq 0x28(%rbx), %rcx
testq %rcx, %rcx
sete %dl
cmpq %rax, %rcx
sete %sil
orb %dl, %sil
jne 0x12dcea
movq %rbx, 0x20(%rcx)
movq 0x30(%rbx), %rcx
testq %rcx, %rcx
sete %dl
cmpq %rax, %rcx
sete %al
orb %dl, %al
jne 0x12dd02
movq %rbx, 0x20(%rcx)
movq 0x20(%rbx), %rsi
testq %rsi, %rsi
je 0x12dd1e
movq %rsp, %rdx
movq %r14, %rdi
movq %rbx, %rcx
movq %r15, %r8
callq 0x12db16
jmp 0x12dd43
movq %r14, %rdi
callq 0x12da65
movq %rax, (%r14)
movaps (%rsp), %xmm0
movups %xmm0, (%rax)
movq (%r14), %rax
movq %rbx, 0x28(%rax)
movq %r15, 0x30(%rax)
movq %rax, 0x20(%rbx)
movq %rax, 0x20(%r15)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq