// File: vsklad[P]cgen/./bal/cnf/cnf/cnfclauses.hpp
// Function: bal::resolve_ca_c2_flags(unsigned short&, unsigned short, unsigned short, unsigned short)
inline void resolve_ca_c2_flags(uint16_t& flags, const clause_size_t index, const clause_size_t c2_index, const uint16_t c2_flags) {
        
        // filters out clauses with specified literal negated (or not)
        // first dimention is whether negated or not, 0 means negated 1 direct
        // second dimention is the literal index, 0..3
        constexpr uint16_t clause_flags_negation_mask[2][4] = {
            {0x5555, 0x3333, 0x0F0F, 0x00FF}, // negated
            {0xAAAA, 0xCCCC, 0xF0F0, 0xFF00}  // direct
        };
        
        _assert_level_0(c2_flags <= 0xF);
        const uint8_t c2_combination = _c2_combination_index(c2_flags);
        _assert_level_1(c2_combination != 0xF);
        
        // if implicant is complemented, only get uncompemented clauses and vise versa
        if (c2_index == 0) {
            // (... lo ...) (lo, lx)
            flags &= clause_flags_negation_mask[!(c2_combination & 0b01)][index];
        } else {
            // (... lo ...) (lx, l0)
            flags &= clause_flags_negation_mask[!(c2_combination & 0b10)][index];
        };
        
        // if the resolvent literal is complemented, uncomplement the flags
        if (c2_combination == 0b00 || c2_combination == 0b11) {
            ca_flags_negate(flags, index);
        };
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movw %cx, %ax
movw %dx, %cx
movw %si, %dx
movq %rdi, -0x8(%rbp)
movw %dx, -0xa(%rbp)
movw %cx, -0xc(%rbp)
movw %ax, -0xe(%rbp)
movq 0x42858(%rip), %rax     # 0x60db0
movq %rax, -0x20(%rbp)
movq 0x42855(%rip), %rax     # 0x60db8
movq %rax, -0x18(%rbp)
movzwl -0xe(%rbp), %eax
cmpl $0xf, %eax
jg 0x1e572
jmp 0x1e591
leaq 0x40d1f(%rip), %rdi     # 0x5f298
leaq 0x40d28(%rip), %rsi     # 0x5f2a8
movl $0x15c, %edx            # imm = 0x15C
leaq 0x40d39(%rip), %rcx     # 0x5f2c5
callq 0xd1c0
movzwl -0xe(%rbp), %eax
movl %eax, %ecx
leaq 0x427f2(%rip), %rax     # 0x60d90
movb (%rax,%rcx), %al
movb %al, -0x21(%rbp)
movzbl -0x21(%rbp), %eax
cmpl $0xf, %eax
je 0x1e5af
jmp 0x1e5ce
leaq 0x40d73(%rip), %rdi     # 0x5f329
leaq 0x40ceb(%rip), %rsi     # 0x5f2a8
movl $0x15e, %edx            # imm = 0x15E
leaq 0x40cfc(%rip), %rcx     # 0x5f2c5
callq 0xd1c0
movzwl -0xc(%rbp), %eax
cmpl $0x0, %eax
jne 0x1e60e
movzbl -0x21(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, %ecx
leaq -0x20(%rbp), %rax
shlq $0x3, %rcx
addq %rcx, %rax
movzwl -0xa(%rbp), %ecx
movzwl (%rax,%rcx,2), %edx
movq -0x8(%rbp), %rax
movzwl (%rax), %ecx
andl %edx, %ecx
movw %cx, (%rax)
jmp 0x1e643
movzbl -0x21(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, %ecx
leaq -0x20(%rbp), %rax
shlq $0x3, %rcx
addq %rcx, %rax
movzwl -0xa(%rbp), %ecx
movzwl (%rax,%rcx,2), %edx
movq -0x8(%rbp), %rax
movzwl (%rax), %ecx
andl %edx, %ecx
movw %cx, (%rax)
movzbl -0x21(%rbp), %eax
cmpl $0x0, %eax
je 0x1e655
movzbl -0x21(%rbp), %eax
cmpl $0x3, %eax
jne 0x1e662
movq -0x8(%rbp), %rdi
movzwl -0xa(%rbp), %esi
callq 0x187e0
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)