// File: /workspace/github_cpp_makefile_star2_O2/vsklad[P]cgen/./bal/cnf/processor/cnfoptimizer.cpp
// Function: bal::processor_result_t bal::CnfOptimizer::normalize_ca<false>(unsigned int const*, unsigned int*) const
inline processor_result_t CnfOptimizer::normalize_ca(const uint32_t* const p_src, uint32_t* const p_dst) const {
        processor_result_t result = erUndetermined;
        const clause_size_t clause_size = _clause_size(p_src);
        const literalid_t* const literals = _clause_literals(p_src);
        uint16_t flags = _clause_flags(p_src);
        const literalid_t* const variable_values = variables_.data();
        
        literalid_t* new_literals = _clause_literals(p_dst);
        clause_size_t new_clause_size = 0;
        
        _assert_level_0(_clause_size_is_aggregated(clause_size));
        
        for (auto i = 0; i < clause_size && flags != 0; i++) {
            const literalid_t original_value = literals[i]; // because p_src may == p_dst
            _assert_level_0(literal_t__is_variable(original_value) && !literal_t__is_negation(original_value));
            literalid_t new_value = literal_t::resolve(variable_values, original_value);
            
            if (literal_t__is_variable(new_value)) {
                if (literal_t__is_negation(new_value)) {
                    __TRACE_ASSIGN_LITERAL;
                    ca_flags_negate(flags, new_clause_size);
                    literal_t__unnegate(new_value);
                    result = erChangedV;
                } else if (new_value != original_value) {
                    __TRACE_ASSIGN_LITERAL;
                    result = erChangedV;
                };
                new_literals[new_clause_size] = new_value;
                ca_insert_last_literal_sorted(flags, new_clause_size, new_literals);
            } else { // is_constant
                __TRACE_ASSIGN_LITERAL;
                new_literals[new_clause_size] = new_value;
                __reduce_clause_flags(flags, new_clause_size, new_value);
                if (result == erUndetermined) {
                    result = erChangedC;
                };
            };
        };
        // save new clause size and flags
        _clause_header_set(p_dst, flags, new_clause_size);
        return (flags != 0) ? result : erSatisfied;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, -0x50(%rbp)
movl (%rsi), %eax
movl %eax, %esi
andl $0x7fff, %esi           # imm = 0x7FFF
shrl $0x10, %eax
movw %ax, -0x2c(%rbp)
movq 0xb8(%rdi), %rcx
movq (%rcx), %rcx
movq %rcx, -0x48(%rbp)
andw $0x0, -0x2a(%rbp)
movq %rsi, -0x58(%rbp)
cmpl $0x4, %esi
ja 0x117c6
movq %rdx, -0x40(%rbp)
leaq 0x4(%rdx), %rcx
movq %rcx, -0x38(%rbp)
xorl %r15d, %r15d
leaq -0x2c(%rbp), %r12
xorl %ebx, %ebx
cmpq -0x58(%rbp), %r15
jae 0x1177c
testw %ax, %ax
je 0x1177c
movq -0x50(%rbp), %rax
movl 0x4(%rax,%r15,4), %r13d
leal -0x2(%r13), %eax
cmpl $-0x4, %eax
ja 0x117a7
movl %r13d, %eax
andl $0x1, %eax
je 0x117a7
movq -0x48(%rbp), %rdi
movl %r13d, %esi
callq 0xeae2
movl %eax, %r14d
leal -0x2(%r14), %eax
cmpl $-0x4, %eax
ja 0x116fc
testb $0x1, %r14b
jne 0x11733
movq 0x3fc27(%rip), %rdi     # 0x51300
testq %rdi, %rdi
je 0x116ea
movq (%rdi), %rax
movl %r13d, %esi
movl %r14d, %edx
callq *0x48(%rax)
movzwl -0x2a(%rbp), %esi
movq %r12, %rdi
callq 0x119c1
orl $0x1, %r14d
jmp 0x11755
movq 0x3fbfd(%rip), %rdi     # 0x51300
testq %rdi, %rdi
je 0x11714
movq (%rdi), %rax
movl %r13d, %esi
movl %r14d, %edx
callq *0x48(%rax)
movzwl -0x2a(%rbp), %esi
movq -0x38(%rbp), %rax
movl %r14d, (%rax,%rsi,4)
movq %r12, %rdi
movl %r14d, %edx
callq 0x11da0
cmpl $0x1, %ebx
adcl $0x0, %ebx
jmp 0x11770
cmpl %r13d, %r14d
jne 0x1173d
movl %r13d, %r14d
jmp 0x11758
movq 0x3fbbc(%rip), %rdi     # 0x51300
testq %rdi, %rdi
je 0x11755
movq (%rdi), %rax
movl %r13d, %esi
movl %r14d, %edx
callq *0x48(%rax)
pushq $0x2
popq %rbx
movzwl -0x2a(%rbp), %eax
movq -0x38(%rbp), %rdx
movl %r14d, (%rdx,%rax,4)
movq %r12, %rdi
leaq -0x2a(%rbp), %rsi
callq 0x11a03
incq %r15
movzwl -0x2c(%rbp), %eax
jmp 0x1167f
movl %eax, %ecx
shll $0x10, %ecx
movzwl -0x2a(%rbp), %edx
orl %ecx, %edx
movq -0x40(%rbp), %rcx
movl %edx, (%rcx)
testw %ax, %ax
pushq $0x3
popq %rax
cmovel %eax, %ebx
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x22cce(%rip), %rdi     # 0x3447c
leaq 0x22653(%rip), %rsi     # 0x33e08
leaq 0x22c47(%rip), %rcx     # 0x34403
movl $0x105, %edx            # imm = 0x105
callq 0xc180
leaq 0x22d32(%rip), %rdi     # 0x344ff
leaq 0x22634(%rip), %rsi     # 0x33e08
leaq 0x22c28(%rip), %rcx     # 0x34403
movl $0x101, %edx            # imm = 0x101
callq 0xc180
nop