// File: /workspace/github_cpp_makefile_star2_O3/vsklad[P]cgen/./bal/cnf/processor/cnfoptimizer.cpp
// Function: bal::processor_result_t bal::CnfOptimizer::resolve_ca_c2<false, (unsigned short)2, (unsigned short)1, (unsigned short)0>(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 0x16398
movq %rdx, %rbx
movl (%rdx), %edx
movl %edx, %eax
andl $0x7fff, %eax           # imm = 0x7FFF
cmpl $0x2, %eax
jne 0x163b7
movq %rsi, %r15
movl 0x8(%rsi), %eax
cmpl 0x4(%rbx), %eax
jne 0x163d6
testw %cx, %cx
je 0x163f5
movq %rdi, %r14
movq 0xb8(%rdi), %rsi
movq (%rsi), %rsi
movl %eax, %edi
shrl %edi
decl %edi
cmpl (%rsi,%rdi,4), %eax
jne 0x16414
movl 0x4(%r15), %eax
movl %eax, %edi
shrl %edi
decl %edi
xorl %r12d, %r12d
cmpl (%rsi,%rdi,4), %eax
jne 0x16386
cmpl $0x100000, %edx         # imm = 0x100000
jae 0x16433
shrl $0x10, %edx
movl $0xfee9, %esi           # imm = 0xFEE9
btq %rdx, %rsi
jb 0x16452
leaq 0x2ea97(%rip), %rsi     # 0x44cb0
movzbl (%rdx,%rsi), %esi
notl %esi
andl $0x1, %esi
leaq 0x2ea77(%rip), %rdi     # 0x44ca0
andw 0x2(%rdi,%rsi,8), %cx
movw %cx, -0x2c(%rbp)
cmpw $0x8, %dx
je 0x16240
movzwl %dx, %edx
cmpl $0x1, %edx
jne 0x16258
movl %ecx, %edx
shrl $0x2, %edx
andl $0x3333, %edx           # imm = 0x3333
andl $0xfffff333, %ecx       # imm = 0xFFFFF333
leal (%rdx,%rcx,4), %ecx
movw %cx, -0x2c(%rbp)
testw %cx, %cx
je 0x16386
movw $0x1, -0x2a(%rbp)
movl %eax, -0x34(%rbp)
movl 0x8(%rbx), %edx
movl %edx, -0x30(%rbp)
cmpl %eax, %edx
jbe 0x1627c
movw $0x2, -0x2a(%rbp)
jmp 0x1629e
leaq -0x34(%rbp), %rdx
leaq -0x2c(%rbp), %r13
leaq -0x2a(%rbp), %rsi
movq %r13, %rdi
callq 0x131ce
movzwl (%r13), %ecx
testw %cx, %cx
je 0x16386
shll $0x10, %ecx
movzwl -0x2a(%rbp), %eax
orl %ecx, %eax
movl %eax, -0x38(%rbp)
movq 0x4605f(%rip), %rdi     # 0x5c310
testq %rdi, %rdi
je 0x1630a
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x4604d(%rip), %rdi     # 0x5c310
testq %rdi, %rdi
je 0x1630a
movq (%rdi), %rax
movq %r15, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
callq *0x40(%rax)
movq 0x46031(%rip), %rdi     # 0x5c310
testq %rdi, %rdi
je 0x1630a
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x4601f(%rip), %rdi     # 0x5c310
testq %rdi, %rdi
je 0x1630a
movq (%rdi), %rax
leaq -0x38(%rbp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x1, %ecx
callq *0x40(%rax)
cmpw $0x2, -0x2a(%rbp)
jne 0x16471
leaq -0x38(%rbp), %rdx
movq %r14, %rdi
movq %rdx, %rsi
callq 0x12d5e
testl %eax, %eax
jne 0x16490
leaq -0x38(%rbp), %rsi
movq %r14, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x1460c
movl %eax, %r15d
movq 0x45fc4(%rip), %rdi     # 0x5c310
testq %rdi, %rdi
je 0x16369
movq (%rdi), %rax
callq *0x28(%rax)
movq 0x45fb2(%rip), %rdi     # 0x5c310
testq %rdi, %rdi
je 0x16369
movq (%rdi), %rax
callq *0x28(%rax)
movl $0x4, %r12d
cmpl $0x4, %r15d
je 0x16386
movq %r14, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x12d5e
movl %eax, %r12d
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2cb66(%rip), %rdi     # 0x42f05
leaq 0x2ba62(%rip), %rsi     # 0x41e08
leaq 0x2ce86(%rip), %rcx     # 0x43233
movl $0x2f1, %edx            # imm = 0x2F1
callq 0xb180
leaq 0x2cc4d(%rip), %rdi     # 0x4300b
leaq 0x2ba43(%rip), %rsi     # 0x41e08
leaq 0x2ce67(%rip), %rcx     # 0x43233
movl $0x2f2, %edx            # imm = 0x2F2
callq 0xb180
leaq 0x2cc53(%rip), %rdi     # 0x43030
leaq 0x2ba24(%rip), %rsi     # 0x41e08
leaq 0x2ce48(%rip), %rcx     # 0x43233
movl $0x2f3, %edx            # imm = 0x2F3
callq 0xb180
leaq 0x2cc69(%rip), %rdi     # 0x43065
leaq 0x2ba05(%rip), %rsi     # 0x41e08
leaq 0x2ce29(%rip), %rcx     # 0x43233
movl $0x2f4, %edx            # imm = 0x2F4
callq 0xb180
leaq 0x2cc58(%rip), %rdi     # 0x43073
leaq 0x2b9e6(%rip), %rsi     # 0x41e08
leaq 0x2ce0a(%rip), %rcx     # 0x43233
movl $0x2ff, %edx            # imm = 0x2FF
callq 0xb180
leaq 0x2cd52(%rip), %rdi     # 0x4318c
leaq 0x2cd5b(%rip), %rsi     # 0x4319c
leaq 0x2cd71(%rip), %rcx     # 0x431b9
movl $0x15c, %edx            # imm = 0x15C
callq 0xb180
leaq 0x2cdc4(%rip), %rdi     # 0x4321d
leaq 0x2cd3c(%rip), %rsi     # 0x4319c
leaq 0x2cd52(%rip), %rcx     # 0x431b9
movl $0x15e, %edx            # imm = 0x15E
callq 0xb180
leaq 0x2ccc5(%rip), %rdi     # 0x4313d
leaq 0x2b989(%rip), %rsi     # 0x41e08
leaq 0x2cdad(%rip), %rcx     # 0x43233
movl $0x32b, %edx            # imm = 0x32B
callq 0xb180
leaq 0x2ccc0(%rip), %rdi     # 0x43157
leaq 0x2b96a(%rip), %rsi     # 0x41e08
leaq 0x2cd8e(%rip), %rcx     # 0x43233
movl $0x32c, %edx            # imm = 0x32C
callq 0xb180
nop