// File: /workspace/github_cpp_makefile_star2_O2/vsklad[P]cgen/./bal/bal/binarytreeindex.hpp
// Function: void bal::AvlTreesIndex<unsigned int, true, &int bal::compare_clauses<false>(unsigned int const*, unsigned int const*), &unsigned int bal::clause_index_variable_id<false>(unsigned int const*)>::_merge_or_swap_child<true, true, false>(unsigned int)
inline void _merge_or_swap_child(const container_offset_t offset) {
            container_offset_t* const p_item = _bti_item(this->data_, offset);
            container_offset_t child_offset = b_with_left ? _bti_item_left_offset(p_item) : _bti_item_right_offset(p_item);
            _assert_level_1(child_offset != CONTAINER_END);
            container_offset_t* p_child = _bti_item(this->data_, child_offset);
            const container_offset_t other_child_offset = (b_with_left ? _bti_item_right_offset(p_item) : _bti_item_left_offset(p_item));
            
            if (b_merge) {
                _bti_item_left_offset(p_item) = _bti_item_left_offset(p_child);
                if (_bti_item_left_offset(p_item) != CONTAINER_END) {
                    _assert_level_2(_bti_parent_offset(this->data_, _bti_item_left_offset(p_item)) == child_offset);
                    _bti_parent_offset(this->data_, _bti_item_left_offset(p_item)) = offset;
                };
                _bti_item_right_offset(p_item) = _bti_item_right_offset(p_child);
                if (_bti_item_right_offset(p_item) != CONTAINER_END) {
                    _assert_level_2(_bti_parent_offset(this->data_, _bti_item_right_offset(p_item)) == child_offset);
                    _bti_parent_offset(this->data_, _bti_item_right_offset(p_item)) = offset;
                };
                p_child = p_item;
                child_offset = offset;
            } else { // swap
                _assert_level_1((b_become_left || _bti_item_right_offset(p_child) == CONTAINER_END) &&
                                (!b_become_left || _bti_item_left_offset(p_child) == CONTAINER_END));
                (b_become_left ? _bti_item_left_offset(p_child) : _bti_item_right_offset(p_child)) = _bti_item_parent_offset(p_child);
                _update_parent(offset, child_offset);
                _bti_item_parent_offset(p_item) = child_offset;
                _bti_item_left_offset(p_item) = CONTAINER_END;
                _bti_item_right_offset(p_item) = CONTAINER_END;
            };
            
            if (other_child_offset != CONTAINER_END) {
                // the other child becomes the rightmost or leftmost furtherst leaf respectively
                while ((b_with_left ? _bti_item_right_offset(p_child) : _bti_item_left_offset(p_child)) != CONTAINER_END) {
                    child_offset = (b_with_left ? _bti_item_right_offset(p_child) : _bti_item_left_offset(p_child));
                    p_child = this->data_ + child_offset;
                };
                
                (b_with_left ? _bti_item_right_offset(p_child) : _bti_item_left_offset(p_child)) = other_child_offset;
                _bti_parent_offset(this->data_, other_child_offset) = child_offset;
            };
        }

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x8(%rdi), %rax
movl %esi, %ecx
movl 0x8(%rax,%rcx,4), %edi
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
cmpq %r9, %rdi
je 0x14ca5
movl 0x4(%rax,%rcx,4), %edx
movl 0x8(%rax,%rdi,4), %r8d
movl %r8d, 0x8(%rax,%rcx,4)
cmpq %r9, %r8
je 0x14c66
cmpl %edi, (%rax,%r8,4)
jne 0x14cc4
movl %esi, (%rax,%r8,4)
movl 0x4(%rax,%rdi,4), %r8d
movl %r8d, 0x4(%rax,%rcx,4)
cmpq %r9, %r8
je 0x14c7f
cmpl %edi, (%rax,%r8,4)
jne 0x14ce3
movl %esi, (%rax,%r8,4)
cmpl $-0x1, %edx
je 0x14ca3
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl %esi, %r8d
movq %rcx, %r9
movl 0x4(%rax,%rcx,4), %ecx
movl %ecx, %esi
cmpq %rdi, %rcx
jne 0x14c89
movl %edx, 0x4(%rax,%r9,4)
movl %r8d, (%rax,%rdx,4)
popq %rbp
retq
leaq 0x20da4(%rip), %rdi     # 0x35a50
leaq 0x1ea7a(%rip), %rsi     # 0x3372d
leaq 0x20db4(%rip), %rcx     # 0x35a6e
movl $0xd2, %edx
callq 0xc180
leaq 0x20f0a(%rip), %rdi     # 0x35bd5
leaq 0x1ea5b(%rip), %rsi     # 0x3372d
leaq 0x20d95(%rip), %rcx     # 0x35a6e
movl $0xd9, %edx
callq 0xc180
leaq 0x20f26(%rip), %rdi     # 0x35c10
leaq 0x1ea3c(%rip), %rsi     # 0x3372d
leaq 0x20d76(%rip), %rcx     # 0x35a6e
movl $0xde, %edx
callq 0xc180