// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
movq %rsi, -0x48(%rbp)
movl (%rsi), %eax
movl %eax, %r8d
andl $0x7fff, %r8d           # imm = 0x7FFF
shrl $0x10, %eax
movw %ax, -0x2a(%rbp)
movq 0xb8(%rdi), %rax
movq (%rax), %r12
movw $0x0, -0x2c(%rbp)
cmpl $0x4, %r8d
ja 0x143a8
testl %r8d, %r8d
setne %cl
movzwl -0x2a(%rbp), %eax
testw %ax, %ax
setne %sil
andb %cl, %sil
cmpb $0x1, %sil
movq %rdx, -0x38(%rbp)
jne 0x1435a
leaq 0x4(%rdx), %r15
xorl %r14d, %r14d
xorl %r13d, %r13d
movq %r8, -0x40(%rbp)
movq -0x48(%rbp), %rax
movl 0x4(%rax,%r14,4), %esi
leal -0x2(%rsi), %eax
cmpl $-0x4, %eax
ja 0x14389
movl %esi, %ecx
movl %esi, %eax
andl $0x1, %ecx
je 0x14389
leal -0x2(%rax), %ecx
cmpl $-0x4, %ecx
ja 0x1426a
movl %eax, %ecx
shrl %ecx
decl %ecx
movl (%r12,%rcx,4), %ecx
movl %eax, %ebx
andl $0x1, %ebx
xorl %ecx, %ebx
xorl $0x1, %ebx
cmpl $-0x1, %ecx
cmovel %ecx, %ebx
cmpl %eax, %ebx
movl %ebx, %eax
jne 0x14240
jmp 0x1426c
movl %eax, %ebx
leal -0x2(%rbx), %eax
cmpl $-0x4, %eax
ja 0x142db
testb $0x1, %bl
jne 0x1430c
movq 0x4b08c(%rip), %rdi     # 0x5f310
testq %rdi, %rdi
je 0x14291
movq (%rdi), %rax
movl %ebx, %edx
callq *0x48(%rax)
movzwl -0x2c(%rbp), %eax
movl $0x1, %edx
movl %eax, %ecx
shll %cl, %edx
movzwl -0x2a(%rbp), %esi
addl %eax, %eax
leaq 0x329d1(%rip), %rcx     # 0x46c7c
movzwl (%rax,%rcx), %ecx
andw %si, %cx
movzwl %cx, %edi
movl %edx, %ecx
shrl %cl, %edi
leaq 0x329b4(%rip), %rcx     # 0x46c74
movzwl (%rax,%rcx), %eax
andl %esi, %eax
movl %edx, %ecx
shll %cl, %eax
orl %edi, %eax
movw %ax, -0x2a(%rbp)
orl $0x1, %ebx
movl $0x2, %r13d
jmp 0x1432a
movq 0x4b02e(%rip), %rdi     # 0x5f310
testq %rdi, %rdi
je 0x142ef
movq (%rdi), %rax
movl %ebx, %edx
callq *0x48(%rax)
movzwl -0x2c(%rbp), %esi
movl %ebx, (%r15,%rsi,4)
leaq -0x2a(%rbp), %rdi
movl %ebx, %edx
callq 0x149b4
cmpl $0x1, %r13d
adcl $0x0, %r13d
jmp 0x14342
cmpl %esi, %ebx
je 0x1432a
movq 0x4aff9(%rip), %rdi     # 0x5f310
movl $0x2, %r13d
testq %rdi, %rdi
je 0x1432a
movq (%rdi), %rax
movl %ebx, %edx
callq *0x48(%rax)
movzwl -0x2c(%rbp), %eax
movl %ebx, (%r15,%rax,4)
leaq -0x2a(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
movq %r15, %rdx
callq 0x145fd
incq %r14
movzwl -0x2a(%rbp), %eax
cmpq -0x40(%rbp), %r14
jae 0x1435d
testw %ax, %ax
jne 0x1421e
jmp 0x1435d
xorl %r13d, %r13d
movl %eax, %ecx
shll $0x10, %ecx
movzwl -0x2c(%rbp), %edx
orl %ecx, %edx
movq -0x38(%rbp), %rcx
movl %edx, (%rcx)
testw %ax, %ax
movl $0x3, %eax
cmovnel %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x300dc(%rip), %rdi     # 0x4446c
leaq 0x2fa61(%rip), %rsi     # 0x43df8
leaq 0x30055(%rip), %rcx     # 0x443f3
movl $0x105, %edx            # imm = 0x105
callq 0xc180
leaq 0x30140(%rip), %rdi     # 0x444ef
leaq 0x2fa42(%rip), %rsi     # 0x43df8
leaq 0x30036(%rip), %rcx     # 0x443f3
movl $0x101, %edx            # imm = 0x101
callq 0xc180
nop