// File: /workspace/github_cpp_makefile_star2_O3/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 0x16e09
cmpl $-0x1, 0x8(%rax,%rcx,4)
jne 0x16e28
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 0x16d8c
cmpl %esi, 0x4(%rax,%r9,4)
jne 0x16dc5
leaq (%rax,%r9,4), %rdi
addq $0x4, %rdi
jmp 0x16dd6
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 0x16e47
movq 0x30(%rdi), %rdi
movl %r10d, %r10d
cmpl %esi, (%rdi,%r10,4)
jne 0x16e66
leaq (%rdi,%r10,4), %rdi
jmp 0x16dd6
leaq (%rax,%r9,4), %rdi
cmpl %esi, 0x8(%rdi)
jne 0x16e85
addq $0x8, %rdi
movl %ecx, (%rdi)
movl %r9d, (%rax,%rcx,4)
movl %ecx, (%r8)
movq $-0x1, 0x4(%r8)
cmpl $-0x1, %edx
je 0x16e07
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %ecx, %edi
movq %rcx, %r8
movl 0x4(%rax,%rcx,4), %ecx
cmpq %rsi, %rcx
jne 0x16df1
movl %edx, 0x4(%rax,%r8,4)
movl %edi, (%rax,%rdx,4)
popq %rbp
retq
leaq 0x2cc40(%rip), %rdi     # 0x43a50
leaq 0x2a916(%rip), %rsi     # 0x4172d
leaq 0x2cf95(%rip), %rcx     # 0x43db3
movl $0xd2, %edx
callq 0xb180
leaq 0x2d0eb(%rip), %rdi     # 0x43f1a
leaq 0x2a8f7(%rip), %rsi     # 0x4172d
leaq 0x2cf76(%rip), %rcx     # 0x43db3
movl $0xe5, %edx
callq 0xb180
leaq 0x2aed3(%rip), %rdi     # 0x41d21
leaq 0x2a8d8(%rip), %rsi     # 0x4172d
leaq 0x2ad85(%rip), %rcx     # 0x41be1
movl $0xab, %edx
callq 0xb180
leaq 0x2aedd(%rip), %rdi     # 0x41d4a
leaq 0x2a8b9(%rip), %rsi     # 0x4172d
leaq 0x2ad66(%rip), %rcx     # 0x41be1
movl $0xac, %edx
callq 0xb180
leaq 0x2ad37(%rip), %rdi     # 0x41bc3
leaq 0x2a89a(%rip), %rsi     # 0x4172d
leaq 0x2ad47(%rip), %rcx     # 0x41be1
movl $0xa6, %edx
callq 0xb180