// File: 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
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq $0x0, 0x38(%rax)
movl $0x0, -0x1c(%rbp)
cmpl $0x2, -0x1c(%rbp)
jae 0x1cf12
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %edx
movl (%rax,%rdx,4), %eax
movq (%rcx), %rcx
cmpl 0x38(%rcx), %eax
jae 0x1ce04
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq 0x30(%rax), %rax
movq -0x18(%rbp), %rcx
movl -0x1c(%rbp), %edx
movl (%rcx,%rdx,4), %ecx
movl (%rax,%rcx,4), %eax
movl %eax, -0x20(%rbp)
jmp 0x1ce0b
movl $0xffffffff, -0x20(%rbp) # imm = 0xFFFFFFFF
cmpl $-0x1, -0x20(%rbp)
je 0x1cf02
movq -0x38(%rbp), %rax
movq %rax, %rcx
addq $0x8, %rcx
movl -0x1c(%rbp), %edx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
movq %rcx, -0x28(%rbp)
movl -0x1c(%rbp), %ecx
movl $0x1, %edx
shll %cl, %edx
movq -0x28(%rbp), %rcx
movl %edx, (%rcx)
movq -0x18(%rbp), %rcx
movl -0x1c(%rbp), %edx
movl (%rcx,%rdx,4), %edx
movq -0x28(%rbp), %rcx
movl %edx, 0x4(%rcx)
movq -0x28(%rbp), %rcx
movl $0xffffffff, 0x8(%rcx)  # imm = 0xFFFFFFFF
movl -0x20(%rbp), %edx
movq -0x28(%rbp), %rcx
movl %edx, 0xc(%rcx)
cmpq $0x0, 0x38(%rax)
je 0x1ce7f
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movl 0xc(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jbe 0x1ce99
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rdx
movq -0x28(%rbp), %rcx
movq %rdx, 0x10(%rcx)
movq -0x28(%rbp), %rcx
movq %rcx, 0x38(%rax)
jmp 0x1cf00
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x10(%rcx)
movb %al, -0x39(%rbp)
je 0x1cecd
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movl 0xc(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0xc(%rcx), %eax
setb %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x1ced6
jmp 0x1cee4
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x1cea5
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x1cf02
jmp 0x1cf04
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1cdc7
movq -0x38(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0x1cf40
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movq 0x8(%rax), %rax
movq 0x38(%rdi), %rcx
movl 0xc(%rcx), %ecx
movl 0x4(%rax,%rcx,8), %eax
movl %eax, 0x40(%rdi)
callq 0x1e180
movl %eax, -0x4(%rbp)
jmp 0x1cf47
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq