// File: /workspace/github_cpp_makefile_star2_O3/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, -0x50(%rbp)
movl (%rsi), %eax
movl %eax, %r9d
andl $0x7fff, %r9d           # imm = 0x7FFF
movl %eax, %r8d
shrl $0x10, %r8d
movw %r8w, -0x2c(%rbp)
movq 0xb8(%rdi), %rcx
movq (%rcx), %r14
movw $0x0, -0x2a(%rbp)
cmpl $0x4, %r9d
ja 0x12f8e
testl %r9d, %r9d
sete %cl
cmpl $0x10000, %eax          # imm = 0x10000
setb %sil
xorl %eax, %eax
orb %cl, %sil
jne 0x12f48
movq %rdx, -0x40(%rbp)
leaq 0x4(%rdx), %rax
movq %rax, -0x38(%rbp)
xorl %r12d, %r12d
movl $0x0, -0x30(%rbp)
movq %r9, -0x48(%rbp)
movq -0x50(%rbp), %rax
movl 0x4(%rax,%r12,4), %esi
leal -0x2(%rsi), %eax
cmpl $-0x4, %eax
ja 0x12f6f
movl %esi, %eax
movl %esi, %r13d
andl $0x1, %eax
je 0x12f6f
leal -0x2(%r13), %eax
cmpl $-0x4, %eax
ja 0x12e4d
movl %r13d, %eax
shrl %eax
movl -0x4(%r14,%rax,4), %r15d
movl %r13d, %eax
andl $0x1, %eax
xorl %r15d, %eax
movl %eax, %ebx
xorl $0x1, %ebx
cmpl $-0x1, %r15d
movl %ebx, %ecx
cmovel %r15d, %ecx
cmpl %r13d, %ecx
movl %ecx, %r13d
jne 0x12dfc
leal -0x2(%rbx), %ecx
cmpl $-0x4, %ecx
ja 0x12e4a
testb $0x1, %al
jne 0x12e8b
cmpl %esi, %ebx
jne 0x12ef0
movl %esi, %ebx
jmp 0x12f0b
movl %ebx, %r13d
movq 0x494bc(%rip), %rdi     # 0x5c310
testq %rdi, %rdi
je 0x12e62
movq (%rdi), %rax
movl %r13d, %edx
callq *0x48(%rax)
movzwl -0x2a(%rbp), %esi
movq -0x38(%rbp), %rax
movl %r13d, (%rax,%rsi,4)
leaq -0x2c(%rbp), %rdi
movl %r13d, %edx
callq 0x13592
movl -0x30(%rbp), %eax
cmpl $0x1, %eax
adcl $0x0, %eax
movl %eax, -0x30(%rbp)
jmp 0x12f23
movq 0x4947e(%rip), %rdi     # 0x5c310
testq %rdi, %rdi
je 0x12ea4
movq (%rdi), %rax
movl %ebx, %edx
callq *0x48(%rax)
movzwl -0x2c(%rbp), %r8d
movzwl -0x2a(%rbp), %eax
movl $0x1, %edx
movl %eax, %ecx
shll %cl, %edx
addl %eax, %eax
movl %r8d, %ecx
leaq 0x31dcf(%rip), %rsi     # 0x44c8c
andw (%rax,%rsi), %cx
movzwl %cx, %esi
movl %edx, %ecx
shrl %cl, %esi
leaq 0x31db5(%rip), %rcx     # 0x44c84
movzwl (%rax,%rcx), %eax
andl %r8d, %eax
movl %edx, %ecx
shll %cl, %eax
orl %esi, %eax
movw %ax, -0x2c(%rbp)
orl $0x1, %r15d
movl $0x2, -0x30(%rbp)
movl %r15d, %ebx
jmp 0x12f0b
movq 0x49419(%rip), %rdi     # 0x5c310
movl $0x2, -0x30(%rbp)
testq %rdi, %rdi
je 0x12f0b
movq (%rdi), %rax
movl %ebx, %edx
callq *0x48(%rax)
movzwl -0x2a(%rbp), %eax
movq -0x38(%rbp), %rdx
movl %ebx, (%rdx,%rax,4)
leaq -0x2c(%rbp), %rdi
leaq -0x2a(%rbp), %rsi
callq 0x131ce
incq %r12
movzwl -0x2c(%rbp), %r8d
cmpq -0x48(%rbp), %r12
jae 0x12f3b
testw %r8w, %r8w
jne 0x12dd9
movzwl -0x2a(%rbp), %eax
movq -0x40(%rbp), %rdx
movl -0x30(%rbp), %esi
jmp 0x12f4a
xorl %esi, %esi
movl %r8d, %ecx
shll $0x10, %ecx
orl %eax, %ecx
movl %ecx, (%rdx)
testw %r8w, %r8w
movl $0x3, %eax
cmovnel %esi, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2f506(%rip), %rdi     # 0x4247c
leaq 0x2ee8b(%rip), %rsi     # 0x41e08
leaq 0x2f47f(%rip), %rcx     # 0x42403
movl $0x105, %edx            # imm = 0x105
callq 0xb180
leaq 0x2f56a(%rip), %rdi     # 0x424ff
leaq 0x2ee6c(%rip), %rsi     # 0x41e08
leaq 0x2f460(%rip), %rcx     # 0x42403
movl $0x101, %edx            # imm = 0x101
callq 0xb180
nop