// File: /workspace/github_cpp_makefile_star2_O2/vsklad[P]cgen/./bal/bal/linkedlistindex.hpp
// Function: bal::SimpleLinkedListsIndexMergedFilteredOptimizingInstanceOffsetIterator<unsigned int, 2u, bal::CnfProcessor, &bal::CnfProcessor::is_clause_included(unsigned int) const>::next()
inline container_offset_t next() {
            list_index_item_t* const index_data = index_.data_;
            state_t* p_state = p_current_state_;
            
            // if data_offset_ is included, iterate and return
            // otherwise, exclude it and repeat
            while (p_state != nullptr) {
                _assert_level_4(data_offset_ != CONTAINER_END);
                if ((filter_.*IS_INCLUDED)(data_offset_)) {
                    instance_bits_ = p_state->instance_bit;
                    while (true) {
                        // 1. move p_current_state_ index instance to the next item;
                        //    p_current_state_ corresponds to the cached data_offset_
                        // 2. choose new minimal p_current_state_ instance
                        p_state->index_offset_prev = p_state->index_offset;
                        p_state->index_offset = index_data[p_state->index_offset].next_offset;
                        if (p_state->index_offset != CONTAINER_END) {
                            if (p_state->p_next != nullptr) {
                                if (p_state->p_next->index_offset > p_state->index_offset) {
                                    // the index item of the next instance is higher than
                                    // the next item of the p_state instance
                                    // data offset must be different as well respectively
                                    // terminate and return data_offset_
                                    const container_offset_t data_offset = data_offset_;
                                    data_offset_ = index_data[p_state->index_offset].container_offset;
                                    _assert_level_4(data_offset != data_offset_);
                                    return data_offset;
                                } else {
                                    // the index item of the next instance is lower than
                                    // the next item of the p_state instance (equal not possible)
                                    // update the p_state list and repeat for the new p_current_state_
                                    // if the data offset is the same; otherwise break
                                    _assert_level_4(p_state->p_next->index_offset != p_state->index_offset);
                                    state_t* p_sorted = p_current_state_ = p_state->p_next;
                                    while (p_sorted->p_next != nullptr && p_sorted->p_next->index_offset < p_state->index_offset) {
                                        p_sorted = p_sorted->p_next;
                                    };
                                    p_state->p_next = p_sorted->p_next;
                                    p_sorted->p_next = p_state;
                                    p_state = p_current_state_;
                                }
                            }
                        } else {
                            p_current_state_ = p_state = p_state->p_next;
                        };
                        if (p_state != nullptr) {
                            // next instance; if data offset is different, terminate
                            const container_offset_t data_offset = data_offset_;
                            data_offset_ = index_.data_[p_state->index_offset].container_offset;
                            if (data_offset != data_offset_) {
                                return data_offset;
                            } else {
                                instance_bits_ |= p_state->instance_bit;
                            };
                        } else {
                            return data_offset_; // iterator's end
                        };
                    }
                } else {
                    // exclude (possibly several) index-offset(s)
                    // which have the same excluded data_offset
                    // start with p_state
                    // then repeat with new data_offset_ if available
                    // can break but cannot return within the cycle
                    while (true) {
                        // 1. exclude p_state->index_offset; index can only grow
                        // 2. update the sorted state list if necessary
                        p_state->index_offset = index_data[p_state->index_offset].next_offset;
                        if (p_state->index_offset_prev == CONTAINER_END) {
                            index_.instances_.data_[p_state->instance_offset] = p_state->index_offset;
                        } else {
                            index_data[p_state->index_offset_prev].next_offset = p_state->index_offset;
                        };
                        // if CONTAINER_END, exclude p_state and update instances_last_
                        // otherwise, reposition p_state within the sorted list
                        // break if the new data_offset is different
                        if (p_state->index_offset != CONTAINER_END) {
                            // last index element is the same or greater than the first one
                            _assert_level_4(index_.instances_.data_[p_state->instance_offset] <= index_.instances_last_.data_[p_state->instance_offset]);
                            if (p_state->p_next != nullptr) {
                                if (p_state->p_next->index_offset < p_state->index_offset) {
                                    state_t* p_sorted = p_current_state_ = p_state->p_next;
                                    while (p_sorted->p_next != nullptr && p_sorted->p_next->index_offset < p_state->index_offset) {
                                        p_sorted = p_sorted->p_next;
                                    };
                                    p_state->p_next = p_sorted->p_next;
                                    p_sorted->p_next = p_state;
                                    p_state = p_current_state_;
                                }
                            }
                        } else {
                            // if the last element becomes lower than p_state->index_offset_prev
                            // this means the lst element has been updated concurrently
                            // keep the lower value; normally, the last element can only grow
                            if (p_state->index_offset_prev == CONTAINER_END ||
                                index_.instances_last_.data_[p_state->instance_offset] > p_state->index_offset_prev) {
                                index_.instances_last_.data_[p_state->instance_offset] = p_state->index_offset_prev;
                            };
                            // last index element is the same or greater than the first one
                            _assert_level_4(index_.instances_.data_[p_state->instance_offset] <= index_.instances_last_.data_[p_state->instance_offset]);
                            p_current_state_ = p_state = p_state->p_next;
                        };
                        
                        if (p_state != nullptr) {
                            // next instance; if data offset is different, break
                            // otherwise continue excluding
                            const container_offset_t data_offset = data_offset_;
                            data_offset_ = index_.data_[p_state->index_offset].container_offset;
                            if (data_offset != data_offset_) {
                                break;
                            };
                        } else {
                            break; // iterator's end
                        };
                    };
                };
            };
            return CONTAINER_END;
        }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq (%rdi), %rdx
movq 0x38(%rdi), %r9
movq 0x8(%rdx), %rcx
movq 0x48(%rdi), %r8
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %r10d      # imm = 0xFFFFFFFF
testq %r9, %r9
je 0x14a4c
movl 0x40(%rdi), %eax
movq 0x18(%r8), %r11
movq (%r11), %r11
testb $-0x80, 0xd(%r11,%rax,4)
je 0x14a53
movl 0xc(%r9), %r11d
movq %r9, %rax
movl %r11d, %r9d
movl (%rcx,%r9,8), %r11d
movl %r11d, 0xc(%rax)
movl 0x8(%rax), %r9d
cmpq %r10, %r9
je 0x149ab
movl %r11d, (%rcx,%r9,8)
jmp 0x149ba
movq 0x30(%rdx), %r9
movl 0x4(%rax), %ebx
movl %r11d, (%r9,%rbx,4)
movl 0xc(%rax), %r11d
cmpl $-0x1, %r11d
je 0x149f7
movq 0x10(%rax), %r9
testq %r9, %r9
je 0x149f2
cmpl %r11d, 0xc(%r9)
jae 0x149f2
movq %r9, 0x38(%rdi)
movq %r9, %r14
movq %r14, %rbx
movq 0x10(%r14), %r14
testq %r14, %r14
je 0x149e8
cmpl %r11d, 0xc(%r14)
jb 0x149d6
movq %r14, 0x10(%rax)
movq %rax, 0x10(%rbx)
jmp 0x14a1b
movq %rax, %r9
jmp 0x14a24
movl 0x4(%rax), %r9d
movl 0x8(%rax), %r11d
movq 0x60(%rdx), %rbx
cmpl $-0x1, %r11d
je 0x14a0f
cmpl %r11d, (%rbx,%r9,4)
jbe 0x14a13
movl %r11d, (%rbx,%r9,4)
movq 0x10(%rax), %r9
movq %r9, 0x38(%rdi)
testq %r9, %r9
je 0x14a44
movl 0xc(%r9), %r11d
movl 0x40(%rdi), %ebx
movl %r11d, %eax
movl 0x4(%rcx,%rax,8), %r14d
movl %r14d, 0x40(%rdi)
movq %r9, %rax
cmpl %r14d, %ebx
je 0x14991
jmp 0x1496b
xorl %r9d, %r9d
jmp 0x1496b
movl %esi, %eax
jmp 0x14ad3
movl (%r9), %edx
movl 0xc(%r9), %r8d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %r8d, 0x8(%r9)
movl %r8d, %r8d
movl (%rcx,%r8,8), %r8d
movl %r8d, 0xc(%r9)
movq 0x10(%r9), %r10
cmpq %rsi, %r8
je 0x14aa5
testq %r10, %r10
je 0x14ab4
cmpl %r8d, 0xc(%r10)
ja 0x14ad8
movq %r10, 0x38(%rdi)
movq %r10, %rbx
movq %rbx, %r11
movq 0x10(%rbx), %rbx
testq %rbx, %rbx
je 0x14a9b
cmpl %r8d, 0xc(%rbx)
jb 0x14a89
movq %rbx, 0x10(%r9)
movq %r9, 0x10(%r11)
jmp 0x14aa9
movq %r10, 0x38(%rdi)
testq %r10, %r10
je 0x14ad0
movl 0xc(%r10), %r8d
jmp 0x14ab7
movq %r9, %r10
movl %r8d, %r9d
movl 0x4(%rcx,%r9,8), %r9d
movl %r9d, 0x40(%rdi)
cmpl %r9d, %eax
jne 0x14ad0
orl (%r10), %edx
movq %r10, %r9
jmp 0x14a5f
movl %edx, 0x44(%rdi)
popq %rbx
popq %r14
popq %rbp
retq
movl %edx, 0x44(%rdi)
movl 0x4(%rcx,%r8,8), %ecx
movl %ecx, 0x40(%rdi)
jmp 0x14ad3