// 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>::first(unsigned int const*)
inline container_offset_t first(const container_offset_t instance_offset[INSTANCES_SIZE]) {
            p_current_state_ = nullptr;
            
            for (unsigned i = 0; i < INSTANCES_SIZE; i++) {
                container_offset_t index_offset;
                if (instance_offset[i] < this->index_.instances_.size_) {
                    index_offset = index_.instances_.data_[instance_offset[i]];
                } else {
                    index_offset = CONTAINER_END;
                };
                
                // build list ordered by index_offset; without empty instance lists
                if (index_offset != CONTAINER_END) {
                    state_t* p_state = state_ + i;
                    p_state->instance_bit = 0x1 << i;
                    p_state->instance_offset = instance_offset[i];
                    p_state->index_offset_prev = CONTAINER_END;
                    p_state->index_offset = index_offset;
                
                    if (p_current_state_ == nullptr || p_current_state_->index_offset > p_state->index_offset) {
                        p_state->p_next = p_current_state_;
                        p_current_state_ = p_state;
                    } else {
                        state_t* p_sorted = p_current_state_; // index_offset lower than p_state
                        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;
                    };
                };
            };
            
            if (p_current_state_ != nullptr) {
                data_offset_ = index_.data_[p_current_state_->index_offset].container_offset;
                return next();
            } else {
                return CONTAINER_END;
            };
        }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
andq $0x0, 0x38(%rdi)
leaq 0x38(%rdi), %rdx
movq (%rdi), %rax
movl 0x38(%rax), %r8d
leaq 0x8(%rdi), %r9
xorl %ecx, %ecx
movl $0x1, %r11d
xorl %r10d, %r10d
cmpq $0x2, %rcx
je 0x13dd0
movl (%rsi,%rcx,4), %ebx
cmpl %r8d, %ebx
jae 0x13dcb
movq 0x30(%rax), %r14
movl (%r14,%rbx,4), %r14d
cmpl $-0x1, %r14d
je 0x13dcb
movl %r11d, %ebx
shll %cl, %ebx
imulq $0x18, %rcx, %r15
movl %ebx, (%r9,%r15)
movl (%rsi,%rcx,4), %ebx
movl %ebx, 0x4(%r9,%r15)
orl $-0x1, 0x8(%r9,%r15)
leaq (%r9,%r15), %rbx
movl %r14d, 0xc(%r9,%r15)
testq %r10, %r10
je 0x13d9f
cmpl %r14d, 0xc(%r10)
jbe 0x13daa
movq %r10, %r15
movq %rdx, %r12
movq %rbx, %r10
jmp 0x13dc3
movq %r10, %r15
movq %r15, %r12
movq 0x10(%r15), %r15
testq %r15, %r15
je 0x13dbf
cmpl %r14d, 0xc(%r15)
jb 0x13dad
addq $0x10, %r12
movq %r15, 0x10(%rbx)
movq %rbx, (%r12)
incq %rcx
jmp 0x13d54
testq %r10, %r10
je 0x13df1
movq 0x8(%rax), %rax
movl 0xc(%r10), %ecx
movl 0x4(%rax,%rcx,8), %eax
movl %eax, 0x40(%rdi)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x1494a
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop