// File: 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
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq (%rax), %rcx
movq 0x8(%rcx), %rcx
movq %rcx, -0x18(%rbp)
movq 0x38(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x1e51f
movq -0x50(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x58(%rbp)
xorl %eax, %eax
testb $0x1, %al
jne 0x1e1c6
jmp 0x1e1e2
movq -0x58(%rbp), %rax
movq (%rax), %rax
leaq -0x1b94(%rip), %rcx     # 0x1c640
subq $0x1, %rcx
movq (%rax,%rcx), %rax
movq %rax, -0x60(%rbp)
jmp 0x1e1ef
leaq -0x1ba9(%rip), %rax     # 0x1c640
movq %rax, -0x60(%rbp)
jmp 0x1e1ef
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rcx
movq -0x60(%rbp), %rax
movl 0x40(%rcx), %esi
callq *%rax
testb $0x1, %al
jne 0x1e209
jmp 0x1e383
movq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, 0x44(%rax)
movq -0x20(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movl 0xc(%rcx), %ecx
movl (%rax,%rcx,8), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x20(%rbp), %rax
cmpl $-0x1, 0xc(%rax)
je 0x1e310
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1e30e
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jbe 0x1e291
movq -0x50(%rbp), %rax
movl 0x40(%rax), %ecx
movl %ecx, -0x24(%rbp)
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rdx
movl 0xc(%rdx), %edx
movl 0x4(%rcx,%rdx,8), %ecx
movl %ecx, 0x40(%rax)
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1e526
movq -0x50(%rbp), %rcx
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x38(%rcx)
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x10(%rcx)
movb %al, -0x61(%rbp)
je 0x1e2cd
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0xc(%rcx), %eax
setb %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x1e2d6
jmp 0x1e2e4
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x1e2a5
movq -0x50(%rbp), %rax
movq -0x30(%rbp), %rcx
movq 0x10(%rcx), %rdx
movq -0x20(%rbp), %rcx
movq %rdx, 0x10(%rcx)
movq -0x20(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq %rdx, 0x10(%rcx)
movq 0x38(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x1e30e
jmp 0x1e324
movq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq %rcx, -0x20(%rbp)
movq %rcx, 0x38(%rax)
cmpq $0x0, -0x20(%rbp)
je 0x1e36f
movq -0x50(%rbp), %rcx
movl 0x40(%rcx), %eax
movl %eax, -0x34(%rbp)
movq (%rcx), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rdx
movl 0xc(%rdx), %edx
movl 0x4(%rax,%rdx,8), %eax
movl %eax, 0x40(%rcx)
movl -0x34(%rbp), %eax
cmpl 0x40(%rcx), %eax
je 0x1e35d
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x1e526
movq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
movl (%rcx), %ecx
orl 0x44(%rax), %ecx
movl %ecx, 0x44(%rax)
jmp 0x1e37e
movq -0x50(%rbp), %rax
movl 0x40(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x1e526
jmp 0x1e216
jmp 0x1e385
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movl 0xc(%rcx), %ecx
movl (%rax,%rcx,8), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x20(%rbp), %rax
cmpl $-0x1, 0x8(%rax)
jne 0x1e3c2
movq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
movl 0xc(%rcx), %edx
movq (%rax), %rax
movq 0x30(%rax), %rax
movq -0x20(%rbp), %rcx
movl 0x4(%rcx), %ecx
movl %edx, (%rax,%rcx,4)
jmp 0x1e3d7
movq -0x20(%rbp), %rax
movl 0xc(%rax), %edx
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movl 0x8(%rcx), %ecx
movl %edx, (%rax,%rcx,8)
movq -0x20(%rbp), %rax
cmpl $-0x1, 0xc(%rax)
je 0x1e487
movq -0x20(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1e485
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jae 0x1e483
movq -0x50(%rbp), %rcx
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x38(%rcx)
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x10(%rcx)
movb %al, -0x62(%rbp)
je 0x1e444
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0xc(%rcx), %eax
setb %al
movb %al, -0x62(%rbp)
movb -0x62(%rbp), %al
testb $0x1, %al
jne 0x1e44d
jmp 0x1e45b
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x1e41c
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
movq 0x10(%rcx), %rdx
movq -0x20(%rbp), %rcx
movq %rdx, 0x10(%rcx)
movq -0x20(%rbp), %rdx
movq -0x40(%rbp), %rcx
movq %rdx, 0x10(%rcx)
movq 0x38(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x1e485
jmp 0x1e4df
movq -0x20(%rbp), %rax
cmpl $-0x1, 0x8(%rax)
je 0x1e4af
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq 0x60(%rax), %rax
movq -0x20(%rbp), %rcx
movl 0x4(%rcx), %ecx
movl (%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jbe 0x1e4cb
movq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
movl 0x8(%rcx), %edx
movq (%rax), %rax
movq 0x60(%rax), %rax
movq -0x20(%rbp), %rcx
movl 0x4(%rcx), %ecx
movl %edx, (%rax,%rcx,4)
movq -0x50(%rbp), %rax
movq -0x20(%rbp), %rcx
movq 0x10(%rcx), %rcx
movq %rcx, -0x20(%rbp)
movq %rcx, 0x38(%rax)
cmpq $0x0, -0x20(%rbp)
je 0x1e511
movq -0x50(%rbp), %rcx
movl 0x40(%rcx), %eax
movl %eax, -0x44(%rbp)
movq (%rcx), %rax
movq 0x8(%rax), %rax
movq -0x20(%rbp), %rdx
movl 0xc(%rdx), %edx
movl 0x4(%rax,%rdx,8), %eax
movl %eax, 0x40(%rcx)
movl -0x44(%rbp), %eax
cmpl 0x40(%rcx), %eax
je 0x1e50f
jmp 0x1e518
jmp 0x1e513
jmp 0x1e518
jmp 0x1e385
jmp 0x1e51a
jmp 0x1e1a7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nop