// File: /workspace/github_cpp_makefile_star2_O1/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 %r12
pushq %rbx
subq $0x10, %rsp
movl $0x7fff, %eax           # imm = 0x7FFF
andl (%rsi), %eax
cmpl $0x2, %eax
jne 0x178c6
movq %rdx, %rbx
movl (%rdx), %eax
movl %eax, %edx
andl $0x7fff, %edx           # imm = 0x7FFF
cmpl $0x2, %edx
jne 0x178e5
movq %rsi, %r15
movq %rdi, %r14
movl 0x8(%rsi), %edx
movl 0x4(%rbx), %edi
cmpl %edi, %edx
jne 0x17904
testw %cx, %cx
je 0x17923
movq 0xb8(%r14), %rsi
movq (%rsi), %rsi
movl %edi, %r8d
shrl %r8d
decl %r8d
cmpl (%rsi,%r8,4), %edi
jne 0x17942
movl %edx, %edi
shrl %edi
decl %edi
cmpl (%rsi,%rdi,4), %edx
jne 0x17961
movl 0x4(%r15), %edx
movl %edx, %edi
shrl %edi
decl %edi
cmpl (%rsi,%rdi,4), %edx
jne 0x178b7
movw %cx, -0x22(%rbp)
cmpl $0x100000, %eax         # imm = 0x100000
jae 0x17980
shrl $0x10, %eax
movl $0xfee9, %esi           # imm = 0xFEE9
btq %rax, %rsi
jb 0x1799f
leaq 0x2f55d(%rip), %rsi     # 0x46ca0
movzbl (%rax,%rsi), %esi
notl %esi
andl $0x1, %esi
leaq 0x2f53d(%rip), %rdi     # 0x46c90
andw 0x2(%rdi,%rsi,8), %cx
movw %cx, -0x22(%rbp)
cmpw $0x8, %ax
je 0x1776a
movzwl %ax, %eax
cmpl $0x1, %eax
jne 0x17781
movl %ecx, %eax
shrl $0x2, %eax
andl $0x3333, %eax           # imm = 0x3333
andl $0xfffff333, %ecx       # imm = 0xFFFFF333
leal (%rax,%rcx,4), %eax
movw %ax, -0x22(%rbp)
cmpw $0x0, -0x22(%rbp)
je 0x177a3
movw $0x1, -0x24(%rbp)
movl %edx, -0x2c(%rbp)
movl 0x8(%rbx), %eax
movl %eax, -0x28(%rbp)
cmpl %edx, %eax
jbe 0x177ab
movw $0x2, -0x24(%rbp)
jmp 0x177bc
movb $0x1, %r12b
jmp 0x178b2
leaq -0x2c(%rbp), %rdx
leaq -0x22(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x145fd
movzwl -0x22(%rbp), %eax
testl %eax, %eax
sete %r12b
je 0x178b2
shll $0x10, %eax
movzwl -0x24(%rbp), %ecx
orl %eax, %ecx
movl %ecx, -0x30(%rbp)
movq 0x47b31(%rip), %rdi     # 0x5f310
testq %rdi, %rdi
je 0x177ea
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x47b1f(%rip), %rdi     # 0x5f310
testq %rdi, %rdi
je 0x17806
movq (%rdi), %rax
movq %r15, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
callq *0x40(%rax)
movq 0x47b03(%rip), %rdi     # 0x5f310
testq %rdi, %rdi
je 0x17818
movq (%rdi), %rax
callq *0x20(%rax)
movq 0x47af1(%rip), %rdi     # 0x5f310
testq %rdi, %rdi
je 0x17838
movq (%rdi), %rax
leaq -0x30(%rbp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0x1, %ecx
callq *0x40(%rax)
cmpw $0x2, -0x24(%rbp)
jne 0x179be
leaq -0x30(%rbp), %rdx
movq %r14, %rdi
movq %rdx, %rsi
callq 0x141ac
testl %eax, %eax
jne 0x179dd
leaq -0x30(%rbp), %rsi
movq %r14, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
callq 0x15a4c
movl %eax, %r15d
movq 0x47a96(%rip), %rdi     # 0x5f310
testq %rdi, %rdi
je 0x17885
movq (%rdi), %rax
callq *0x28(%rax)
movq 0x47a84(%rip), %rdi     # 0x5f310
testq %rdi, %rdi
je 0x17897
movq (%rdi), %rax
callq *0x28(%rax)
movl $0x4, %eax
cmpl $0x4, %r15d
je 0x178b2
movq %r14, %rdi
movq %rbx, %rsi
movq %rbx, %rdx
callq 0x141ac
jmp 0x178b2
testb %r12b, %r12b
je 0x178b9
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2d628(%rip), %rdi     # 0x44ef5
leaq 0x2c524(%rip), %rsi     # 0x43df8
leaq 0x2d948(%rip), %rcx     # 0x45223
movl $0x2f1, %edx            # imm = 0x2F1
callq 0xc180
leaq 0x2d70f(%rip), %rdi     # 0x44ffb
leaq 0x2c505(%rip), %rsi     # 0x43df8
leaq 0x2d929(%rip), %rcx     # 0x45223
movl $0x2f2, %edx            # imm = 0x2F2
callq 0xc180
leaq 0x2d715(%rip), %rdi     # 0x45020
leaq 0x2c4e6(%rip), %rsi     # 0x43df8
leaq 0x2d90a(%rip), %rcx     # 0x45223
movl $0x2f3, %edx            # imm = 0x2F3
callq 0xc180
leaq 0x2d72b(%rip), %rdi     # 0x45055
leaq 0x2c4c7(%rip), %rsi     # 0x43df8
leaq 0x2d8eb(%rip), %rcx     # 0x45223
movl $0x2f4, %edx            # imm = 0x2F4
callq 0xc180
leaq 0x2d71a(%rip), %rdi     # 0x45063
leaq 0x2c4a8(%rip), %rsi     # 0x43df8
leaq 0x2d8cc(%rip), %rcx     # 0x45223
movl $0x2ff, %edx            # imm = 0x2FF
callq 0xc180
leaq 0x2d759(%rip), %rdi     # 0x450c1
leaq 0x2c489(%rip), %rsi     # 0x43df8
leaq 0x2d8ad(%rip), %rcx     # 0x45223
movl $0x301, %edx            # imm = 0x301
callq 0xc180
leaq 0x2d7f5(%rip), %rdi     # 0x4517c
leaq 0x2d7fe(%rip), %rsi     # 0x4518c
leaq 0x2d814(%rip), %rcx     # 0x451a9
movl $0x15c, %edx            # imm = 0x15C
callq 0xc180
leaq 0x2d867(%rip), %rdi     # 0x4520d
leaq 0x2d7df(%rip), %rsi     # 0x4518c
leaq 0x2d7f5(%rip), %rcx     # 0x451a9
movl $0x15e, %edx            # imm = 0x15E
callq 0xc180
leaq 0x2d768(%rip), %rdi     # 0x4512d
leaq 0x2c42c(%rip), %rsi     # 0x43df8
leaq 0x2d850(%rip), %rcx     # 0x45223
movl $0x32b, %edx            # imm = 0x32B
callq 0xc180
leaq 0x2d763(%rip), %rdi     # 0x45147
leaq 0x2c40d(%rip), %rsi     # 0x43df8
leaq 0x2d831(%rip), %rcx     # 0x45223
movl $0x32c, %edx            # imm = 0x32C
callq 0xc180