// File: /workspace/github_cpp_makefile_star2_O1/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<false, true, true>(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, %edx
movl 0x8(%rax,%rdx,4), %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
cmpq %r8, %rcx
je 0x18371
cmpl $-0x1, 0x8(%rax,%rcx,4)
jne 0x18390
leaq (%rax,%rdx,4), %r8
movl 0x4(%r8), %edx
movl (%rax,%rcx,4), %r9d
movl %r9d, 0x8(%rax,%rcx,4)
movl (%r8), %r9d
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
cmpq %r10, %r9
je 0x182f4
cmpl %esi, 0x4(%rax,%r9,4)
jne 0x1832d
leaq (%rax,%r9,4), %rdi
addq $0x4, %rdi
jmp 0x1833e
movl $0x7fff, %r10d          # imm = 0x7FFF
andl 0xc(%r8), %r10d
decl %r10d
movl 0x10(%r8,%r10,4), %r10d
shrl %r10d
decl %r10d
cmpl 0x38(%rdi), %r10d
jae 0x183af
movq 0x30(%rdi), %rdi
movl %r10d, %r10d
cmpl %esi, (%rdi,%r10,4)
jne 0x183ce
leaq (%rdi,%r10,4), %rdi
jmp 0x1833e
leaq (%rax,%r9,4), %rdi
cmpl %esi, 0x8(%rdi)
jne 0x183ed
addq $0x8, %rdi
movl %ecx, (%rdi)
movl %r9d, (%rax,%rcx,4)
movl %ecx, (%r8)
movq $-0x1, 0x4(%r8)
cmpl $-0x1, %edx
je 0x1836f
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %ecx, %edi
movq %rcx, %r8
movl 0x4(%rax,%rcx,4), %ecx
cmpq %rsi, %rcx
jne 0x18359
movl %edx, 0x4(%rax,%r8,4)
movl %edi, (%rax,%rdx,4)
popq %rbp
retq
leaq 0x2d6c8(%rip), %rdi     # 0x45a40
leaq 0x2b3be(%rip), %rsi     # 0x4373d
leaq 0x2da1d(%rip), %rcx     # 0x45da3
movl $0xd2, %edx
callq 0xc180
leaq 0x2db73(%rip), %rdi     # 0x45f0a
leaq 0x2b39f(%rip), %rsi     # 0x4373d
leaq 0x2d9fe(%rip), %rcx     # 0x45da3
movl $0xe5, %edx
callq 0xc180
leaq 0x2b97b(%rip), %rdi     # 0x43d31
leaq 0x2b380(%rip), %rsi     # 0x4373d
leaq 0x2b82d(%rip), %rcx     # 0x43bf1
movl $0xab, %edx
callq 0xc180
leaq 0x2b985(%rip), %rdi     # 0x43d5a
leaq 0x2b361(%rip), %rsi     # 0x4373d
leaq 0x2b80e(%rip), %rcx     # 0x43bf1
movl $0xac, %edx
callq 0xc180
leaq 0x2b7df(%rip), %rdi     # 0x43bd3
leaq 0x2b342(%rip), %rsi     # 0x4373d
leaq 0x2b7ef(%rip), %rcx     # 0x43bf1
movl $0xa6, %edx
callq 0xc180