// File: /workspace/github_cpp_makefile_star2_O3/vsklad[P]cgen/./bal/cnf/processor/cnfoptimizer.cpp
// Function: bal::CnfVariableNormalizer::execute(bool)
bool CnfVariableNormalizer::execute(const bool b_reindex_variables) {
        cnf_.named_variables_assign_negations(variables_);
        
        // index is needed for checking if a variable is used
        build_clauses_index();
        const variableid_t new_variables_size = update_variables(b_reindex_variables);
        if (b_reindex_variables && new_variables_size != cnf_.variables_size()) {
            set_variables_size(new_variables_size);
        };
            
        // nothe that rebuild_clauses() invalidates clauses_index_ and processed_offset_
        // since these are not used below, its fine
        rebuild_clauses<CnfOptimizer, &CnfOptimizer::_update_clause_variables>(this, false);
        cnf_.named_variables_update(variables_);
        
        // it is possible that some negated references remain
        // since the same variable may appear straight and complemented
        // across named variables
        // for those, need to introduce new variables
        
        for (auto vit = named_variables_.begin(); vit != named_variables_.end(); vit++) {
            literalid_t* const template_ = vit->second.data();
            for (auto j = 0; j < vit->second.size(); j++) {
                if (literal_t__is_variable(template_[j]) && literal_t__is_negation(template_[j])) {
                    literalid_t value = cnf_.new_variable_literal();
                    clauses_.append_clause_l(value, literal_t__negated(template_[j]));
                    clauses_.append_clause_l(literal_t__negated(value), template_[j]);
                    template_[j] = value;
                };
            };
        };
        
        return true;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %r15d
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
movq 0xb8(%rbx), %rsi
callq 0x3b44a
movq %rbx, %rdi
callq 0x11e04
movq %rbx, %rdi
movl %r15d, %esi
callq 0x11eca
movq %rbx, -0x30(%rbp)
movq 0x8(%rbx), %rdi
testl %r15d, %r15d
je 0x11235
movl %eax, %r14d
movq (%rdi), %rax
callq *0x58(%rax)
cmpl %eax, %r14d
jne 0x11215
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
jmp 0x11235
cmpl $0x7ffffffe, %r14d      # imm = 0x7FFFFFFE
jae 0x113c7
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movl %r14d, 0x8(%rdi)
movl %r14d, 0xb0(%rdi)
cmpl $-0x1, 0xc8(%rdi)
jne 0x113a8
leaq 0x78(%rdi), %rax
movl 0x88(%rdi), %r12d
movq 0x78(%rdi), %r8
xorl %r13d, %r13d
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq *(%r8)
testl %r12d, %r12d
je 0x112b9
movl $0x7fff, %ebx           # imm = 0x7FFF
movq -0x30(%rbp), %rdi
movq 0x18(%rdi), %rax
movq (%rax), %rax
movl %r13d, %ecx
leaq (%rax,%rcx,4), %r15
addq $0xc, %r15
movl (%r15), %r14d
andl %ebx, %r14d
movq %r15, %rsi
callq 0x1746a
testb %al, %al
je 0x112ad
movl $0xffffffff, -0x3c(%rbp) # imm = 0xFFFFFFFF
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
movq %r15, %rsi
leaq -0x40(%rbp), %rdx
callq 0x10062
addl %r14d, %r13d
addl $0x4, %r13d
cmpl %r12d, %r13d
jb 0x1126a
movq -0x30(%rbp), %rbx
movq 0x8(%rbx), %rdi
movq 0xb8(%rbx), %rsi
callq 0x3b32e
movq 0x28(%rbx), %r15
movq 0x18(%r15), %rdi
leaq 0x8(%r15), %rax
cmpq %rax, %rdi
je 0x11397
movq -0x30(%rbp), %rbx
movl 0x48(%rdi), %eax
testl %eax, %eax
je 0x11382
movq 0x40(%rdi), %r13
xorl %r15d, %r15d
movq %rdi, -0x48(%rbp)
movl (%r13,%r15,4), %ecx
leal -0x2(%rcx), %edx
cmpl $-0x3, %edx
setae %dl
orb %dl, %cl
testb $0x1, %cl
jne 0x11370
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movl %eax, %r12d
movq 0x10(%rbx), %rdi
movl (%r13,%r15,4), %eax
xorl $0x1, %eax
movl %r12d, -0x40(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x40(%rbp), %r14
movq %r14, %rsi
movl $0x2, %edx
callq 0xfc72
movq 0x10(%rbx), %rdi
movl %r12d, %eax
xorl $0x1, %eax
movl (%r13,%r15,4), %ecx
movl %eax, -0x40(%rbp)
movl %ecx, -0x3c(%rbp)
movq %r14, %rsi
movl $0x2, %edx
callq 0xfc72
movq -0x48(%rbp), %rdi
movl %r12d, (%r13,%r15,4)
movl 0x48(%rdi), %eax
incq %r15
movl %eax, %ecx
cmpq %rcx, %r15
jb 0x112fc
movq -0x30(%rbp), %rax
movq 0x28(%rax), %r15
callq 0xb1b0
movq %rax, %rdi
leaq 0x8(%r15), %rax
cmpq %rax, %rdi
jne 0x112e6
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x30ed5(%rip), %rdi     # 0x42284
leaq 0x30ee8(%rip), %rsi     # 0x4229e
leaq 0x336f7(%rip), %rcx     # 0x44ab4
movl $0x52, %edx
callq 0xb180
leaq 0x2e23d(%rip), %rdi     # 0x3f60b
leaq 0x2e253(%rip), %rsi     # 0x3f628
leaq 0x2e264(%rip), %rcx     # 0x3f640
movl $0x9b, %edx
callq 0xb180