// File: /workspace/github_cpp_makefile_star2_O2/vsklad[P]cgen/./bal/cnf/processor/cnfoptimizer.cpp
// Function: bal::processor_result_t bal::CnfOptimizer::resolve_ca_c2<false, (unsigned short)2, (unsigned short)0, (unsigned short)1>(unsigned int*, unsigned int*, unsigned short)
inline processor_result_t CnfOptimizer::resolve_ca_c2(uint32_t* const p_ca, uint32_t* const p_c2, const clause_flags_t ca_flags) {
        static_assert(ca_size >= 2 && ca_size <= 4, "ca_size out of bounds; p_ca must be an aggregated clause");
        static_assert(ca_index >= 0 && ca_index < ca_size, "ca_index out of bounds; p_ca must be an aggregated clause");
        static_assert(c2_index >= 0 && c2_index <= 1, "c2_index out of bounds; p_c2 must be a binary clause");
        _assert_level_0(_clause_size(p_ca) == ca_size);
        _assert_level_0(_clause_size(p_c2) == 2);
        _assert_level_0(_clause_literal(p_ca, ca_index) == _clause_literal(p_c2, c2_index));
        _assert_level_0(ca_flags != 0);
        
        // check that the clauses are unchanged
        const literalid_t* const variables = variables_.data();
        if (b_ca_master) {
            _assert_level_3(_clause_is_literal_unchanged(p_c2, c2_index, variables));
            _assert_level_3(ca_size < 1 || ca_index == 0 || _clause_is_literal_unchanged(p_ca, 0, variables));
            _assert_level_3(ca_size < 2 || ca_index == 1 || _clause_is_literal_unchanged(p_ca, 1, variables));
            _assert_level_3(ca_size < 3 || ca_index == 2 || _clause_is_literal_unchanged(p_ca, 2, variables));
            _assert_level_3(ca_size < 4 || ca_index == 3 || _clause_is_literal_unchanged(p_ca, 3, variables));
        } else {
            _assert_level_3(_clause_is_literal_unchanged(p_c2, 0, variables));
            _assert_level_3(_clause_is_literal_unchanged(p_c2, 0, variables));
            _assert_level_3(_clause_is_literal_unchanged(p_ca, ca_index, variables));
        };
        
        const bool is_clause_unchanged = b_ca_master ? (
            _clause_literal(p_c2, 1 - c2_index) == variables[literal_t__variable_id(_clause_literal(p_c2, 1 - c2_index))]
                                                  ) : (
            (ca_size < 1 || ca_index == 0 || _clause_literal(p_ca, 0) == variables[literal_t__variable_id(_clause_literal(p_ca, 0))]) &&
            (ca_size < 2 || ca_index == 1 || _clause_literal(p_ca, 1) == variables[literal_t__variable_id(_clause_literal(p_ca, 1))]) &&
            (ca_size < 3 || ca_index == 2 || _clause_literal(p_ca, 2) == variables[literal_t__variable_id(_clause_literal(p_ca, 2))]) &&
            (ca_size < 4 || ca_index == 3 || _clause_literal(p_ca, 3) == variables[literal_t__variable_id(_clause_literal(p_ca, 3))])
                                                  );
        
        if (is_clause_unchanged) {
            // determine the resolvent flags
            clause_flags_t resolvent_flags = ca_flags;
            resolve_ca_c2_flags(resolvent_flags, ca_index, c2_index, _clause_flags(p_c2));
            
            if (resolvent_flags != 0) {
                // construct the resolvent
                uint32_t resolvent[_clause_size_memory_size(ca_size)];
                clause_size_t resolvent_size = 1;
                _clause_literal(resolvent, 0) = (ca_index == 0) ? _clause_literal(p_c2, 1 - c2_index) : _clause_literal(p_ca, 0);
                for (auto i = 1; i < ca_size; i++) {
                    const literalid_t literal = (ca_index == i) ? _clause_literal(p_c2, 1 - c2_index) : _clause_literal(p_ca, i);
                    _clause_literal(resolvent, resolvent_size) = literal;
                    if (literal <= _clause_literal(resolvent, resolvent_size - 1)) {
                        ca_insert_last_literal_sorted(resolvent_flags, resolvent_size, _clause_literals(resolvent));
                    } else {
                        resolvent_size++;
                    };
                };
                
                if (resolvent_flags != 0) {
                    _clause_header_set(resolvent, resolvent_flags, resolvent_size);
                    
                    TRACE_LEVEL_NEXT;
                    TRACE_CLAUSE(b_ca_master ? p_c2 : p_ca, CONTAINER_END);
                    TRACE_LEVEL_NEXT;
                    TRACE_CLAUSE_RESOLVENT(resolvent);
                    
                    // with c2 resolution, resolvent_size < ca_size is only possible if both c2 literals are in ca
                    // which means resolution should be handled within the aggregation concept
                    _assert_level_2(resolvent_size == ca_size);
                    _assert_level_3(normalize_ca(resolvent, resolvent) == erUndetermined);
                    
                    processor_result_t result = evaluate_clause_a(resolvent);
                    
                    TRACE_LEVEL_PREV;
                    TRACE_LEVEL_PREV;
                    
                    if (result != erConflict) {
                        result = normalize_ca(b_ca_master ? p_ca : p_c2, b_ca_master ? p_ca : p_c2);
                    };
                    
                    return result;
                };
            };
        };
        return erUndetermined;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl $0x7fff, %eax           # imm = 0x7FFF
andl (%rsi), %eax
cmpl $0x2, %eax
jne 0x1456e
movq %rdx, %rbx
movl (%rdx), %eax
movl %eax, %edx
andl $0x7fff, %edx           # imm = 0x7FFF
cmpl $0x2, %edx
jne 0x1458d
movq %rsi, %r15
movl 0x4(%rsi), %edx
cmpl 0x8(%rbx), %edx
jne 0x145ac
testw %cx, %cx
je 0x145cb
movq %rdi, %r14
movq 0xb8(%rdi), %rsi
movq (%rsi), %rsi
movl 0x4(%rbx), %edi
movl %edi, %r8d
shrl %r8d
decl %r8d
cmpl (%rsi,%r8,4), %edi
jne 0x145ea
movl %edx, %edi
shrl %edi
decl %edi
cmpl (%rsi,%rdi,4), %edx
jne 0x14609
movl 0x8(%r15), %edx
movl %edx, %edi
shrl %edi
decl %edi
xorl %r12d, %r12d
cmpl (%rsi,%rdi,4), %edx
jne 0x1455c
leaq -0x2c(%rbp), %r13
movw %cx, (%r13)
shrl $0x10, %eax
xorl %r12d, %r12d
pushq $0x1
popq %rdx
movq %r13, %rdi
xorl %esi, %esi
movl %eax, %ecx
callq 0x14ae5
movzwl (%r13), %eax
testw %ax, %ax
je 0x1455c
movw $0x1, -0x2a(%rbp)
movl 0x4(%rbx), %ecx
movl %ecx, -0x34(%rbp)
movl 0x8(%r15), %edx
movl %edx, -0x30(%rbp)
cmpl %ecx, %edx
jbe 0x14458
movw $0x2, -0x2a(%rbp)
jmp 0x1447a
leaq -0x34(%rbp), %rdx
leaq -0x2c(%rbp), %r12
leaq -0x2a(%rbp), %rsi
movq %r12, %rdi
callq 0x11a03
movzwl (%r12), %eax
testw %ax, %ax
je 0x14559
shll $0x10, %eax
movzwl -0x2a(%rbp), %ecx
orl %eax, %ecx
movl %ecx, -0x38(%rbp)
movq 0x3ce73(%rip), %rdi     # 0x51300
testq %rdi, %rdi
je 0x144e0
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x3ce61(%rip), %rdi     # 0x51300
testq %rdi, %rdi
je 0x144e0
movq (%rdi), %rax
pushq $-0x1
popq %rdx
movq %r15, %rsi
xorl %ecx, %ecx
callq *0x40(%rax)
movq 0x3ce47(%rip), %rdi     # 0x51300
testq %rdi, %rdi
je 0x144e0
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x3ce35(%rip), %rdi     # 0x51300
testq %rdi, %rdi
je 0x144e0
movq (%rdi), %rax
leaq -0x38(%rbp), %rsi
pushq $-0x1
popq %rdx
pushq $0x1
popq %rcx
callq *0x40(%rax)
cmpw $0x2, -0x2a(%rbp)
jne 0x14628
leaq -0x38(%rbp), %rdx
movq %r14, %rdi
movq %rdx, %rsi
callq 0x11624
testl %eax, %eax
jne 0x14647
leaq -0x38(%rbp), %rsi
pushq $-0x1
popq %rcx
movq %r14, %rdi
movl %ecx, %edx
callq 0x12be6
movl %eax, %r15d
movq 0x3cde3(%rip), %rdi     # 0x51300
testq %rdi, %rdi
je 0x1453a
movq (%rdi), %rax
callq *0x28(%rax)
movq 0x3cdd1(%rip), %rdi     # 0x51300
testq %rdi, %rdi
je 0x1453a
movq (%rdi), %rax
callq *0x28(%rax)
cmpl $0x4, %r15d
jne 0x14546
pushq $0x4
popq %r12
jmp 0x1455c
movq %r14, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x11624
movl %eax, %r12d
jmp 0x1455c
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20990(%rip), %rdi     # 0x34f05
leaq 0x1f88c(%rip), %rsi     # 0x33e08
leaq 0x20d8b(%rip), %rcx     # 0x3530e
movl $0x2f1, %edx            # imm = 0x2F1
callq 0xc180
leaq 0x20a77(%rip), %rdi     # 0x3500b
leaq 0x1f86d(%rip), %rsi     # 0x33e08
leaq 0x20d6c(%rip), %rcx     # 0x3530e
movl $0x2f2, %edx            # imm = 0x2F2
callq 0xc180
leaq 0x20a7d(%rip), %rdi     # 0x35030
leaq 0x1f84e(%rip), %rsi     # 0x33e08
leaq 0x20d4d(%rip), %rcx     # 0x3530e
movl $0x2f3, %edx            # imm = 0x2F3
callq 0xc180
leaq 0x20a93(%rip), %rdi     # 0x35065
leaq 0x1f82f(%rip), %rsi     # 0x33e08
leaq 0x20d2e(%rip), %rcx     # 0x3530e
movl $0x2f4, %edx            # imm = 0x2F4
callq 0xc180
leaq 0x20a82(%rip), %rdi     # 0x35073
leaq 0x1f810(%rip), %rsi     # 0x33e08
leaq 0x20d0f(%rip), %rcx     # 0x3530e
movl $0x2ff, %edx            # imm = 0x2FF
callq 0xc180
leaq 0x20ac1(%rip), %rdi     # 0x350d1
leaq 0x1f7f1(%rip), %rsi     # 0x33e08
leaq 0x20cf0(%rip), %rcx     # 0x3530e
movl $0x301, %edx            # imm = 0x301
callq 0xc180
leaq 0x20b0e(%rip), %rdi     # 0x3513d
leaq 0x1f7d2(%rip), %rsi     # 0x33e08
leaq 0x20cd1(%rip), %rcx     # 0x3530e
movl $0x32b, %edx            # imm = 0x32B
callq 0xc180
leaq 0x20b09(%rip), %rdi     # 0x35157
leaq 0x1f7b3(%rip), %rsi     # 0x33e08
leaq 0x20cb2(%rip), %rcx     # 0x3530e
movl $0x32c, %edx            # imm = 0x32C
callq 0xc180