// File: vsklad[P]cgen/./bal/cnf/processor/cnfoptimizer.cpp
// Function: bal::CnfOptimizer::update_variables(bool)
inline variableid_t CnfOptimizer::update_variables(const bool b_reindex_variables) {
        literalid_t* var_values = variables_.data();
        variableid_t next_variable_id = VARIABLEID_MIN;
        
        // go through the variables sequentially
        for (variables_size_t i = 0; i < variables_.size(); i++) {
            if (literal_t__is_variable(var_values[i])) {
                variableid_t variable_id = literal_t__variable_id(var_values[i]);
                if (variable_id != i) {
                    // assume referencing of variables with lower ids only
                    // and therefore the reference is updated by now
                    assert(i > variable_id);
                    // all clauses with the variable must have been excluded
                    assert(!is_variable_used(i));
                    // UNASSIGNED may not be referenced
                    assert(!literal_t__is_unassigned(var_values[variable_id]));
                    // take the reference of the reference instead of making a new variable
                    var_values[i] = literal_t__substitute_literal(var_values[i], var_values[variable_id]);
                } else if (is_variable_used(variable_id) || cnf_.is_variable_named(variable_id)) {
                    if (b_reindex_variables) {
                        // generate new variable id
                        if (next_variable_id != variable_id) {
                            // only update after next_variable_id falls behind
                            var_values[i] = literal_t__substitute_variable(var_values[i], next_variable_id);
                        };
                        next_variable_id++;
                    };
                } else {
                    var_values[i] = LITERALID_UNASSIGNED;
                };
            } else {
                // unassigned cannot be created earlier than this stage
                assert(literal_t__is_constant(var_values[i]));
            };
        };
#ifdef CNF_TRACE
        if (p_tracer_ != nullptr) p_tracer_->update_variables(variables_);
#endif
        // validate the new variables size
        _assert_level_1(cnf_.variables_size() <= variables_.size());
        _assert_level_1(next_variable_id <= variables_.size());
        return next_variable_id;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movq 0xb8(%rax), %rdi
callq 0x10310
movq %rax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x30(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, -0x34(%rbp)
movq 0xb8(%rax), %rdi
callq 0x102f0
movl %eax, %ecx
movl -0x34(%rbp), %eax
cmpl %ecx, %eax
jae 0x16d1e
movq -0x18(%rbp), %rcx
movl -0x20(%rbp), %eax
movl %eax, %edx
xorl %eax, %eax
cmpl $0x1, (%rcx,%rdx,4)
movb %al, -0x35(%rbp)
jbe 0x16b62
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
cmpl $-0x2, (%rax,%rcx,4)
setbe %al
movb %al, -0x35(%rbp)
movb -0x35(%rbp), %al
testb $0x1, %al
jne 0x16b6e
jmp 0x16cde
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl (%rax,%rcx,4), %eax
shrl %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
je 0x16c59
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
jbe 0x16b96
jmp 0x16bb5
leaq 0x49b6a(%rip), %rdi     # 0x60707
leaq 0x47370(%rip), %rsi     # 0x5df14
movl $0x4a3, %edx            # imm = 0x4A3
leaq 0x49b67(%rip), %rcx     # 0x60717
callq 0xd1c0
movq -0x30(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x1f450
xorb $-0x1, %al
testb $0x1, %al
jne 0x16bc9
jmp 0x16bcb
jmp 0x16bea
leaq 0x49b82(%rip), %rdi     # 0x60754
leaq 0x4733b(%rip), %rsi     # 0x5df14
movl $0x4a5, %edx            # imm = 0x4A5
leaq 0x49b32(%rip), %rcx     # 0x60717
callq 0xd1c0
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
cmpl $-0x1, (%rax,%rcx,4)
sete %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x16c00
jmp 0x16c02
jmp 0x16c21
leaq 0x49b60(%rip), %rdi     # 0x60769
leaq 0x47304(%rip), %rsi     # 0x5df14
movl $0x4a7, %edx            # imm = 0x4A7
leaq 0x49afb(%rip), %rcx     # 0x60717
callq 0xd1c0
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
movl (%rax,%rcx,4), %edx
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl (%rax,%rcx,4), %esi
xorl $-0x1, %esi
andl $0x1, %esi
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %esi
cmovnel %ecx, %eax
xorl %eax, %edx
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
jmp 0x16cdc
movq -0x30(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x1f450
testb $0x1, %al
jne 0x16c7f
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movl -0x24(%rbp), %esi
callq 0x551f0
testb $0x1, %al
jne 0x16c7f
jmp 0x16ccc
testb $0x1, -0x9(%rbp)
je 0x16cca
movl -0x1c(%rbp), %eax
cmpl -0x24(%rbp), %eax
je 0x16cc1
movl -0x1c(%rbp), %edx
addl $0x1, %edx
shll %edx
orl $0x1, %edx
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl (%rax,%rcx,4), %esi
xorl $-0x1, %esi
andl $0x1, %esi
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %esi
cmovnel %ecx, %eax
xorl %eax, %edx
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x16cda
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
jmp 0x16cdc
jmp 0x16d0e
movq -0x18(%rbp), %rax
movl -0x20(%rbp), %ecx
cmpl $0x1, (%rax,%rcx,4)
ja 0x16ced
jmp 0x16d0c
leaq 0x49aa8(%rip), %rdi     # 0x6079c
leaq 0x47219(%rip), %rsi     # 0x5df14
movl $0x4b8, %edx            # imm = 0x4B8
leaq 0x49a10(%rip), %rcx     # 0x60717
callq 0xd1c0
jmp 0x16d0e
jmp 0x16d10
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x16b1a
leaq 0x6c66b(%rip), %rdi     # 0x83390
callq 0x16210
cmpq $0x0, %rax
je 0x16d50
leaq 0x6c659(%rip), %rdi     # 0x83390
callq 0x178d0
movq %rax, %rdi
movq -0x30(%rbp), %rax
movq 0xb8(%rax), %rsi
movq (%rdi), %rax
callq *0x38(%rax)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq (%rdi), %rax
callq *0x58(%rax)
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, -0x3c(%rbp)
movq 0xb8(%rax), %rdi
callq 0x102f0
movl %eax, %ecx
movl -0x3c(%rbp), %eax
cmpl %ecx, %eax
ja 0x16d7e
jmp 0x16d9d
leaq 0x49a3d(%rip), %rdi     # 0x607c2
leaq 0x47188(%rip), %rsi     # 0x5df14
movl $0x4bf, %edx            # imm = 0x4BF
leaq 0x4997f(%rip), %rcx     # 0x60717
callq 0xd1c0
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, -0x40(%rbp)
movq 0xb8(%rax), %rdi
callq 0x102f0
movl %eax, %ecx
movl -0x40(%rbp), %eax
cmpl %ecx, %eax
ja 0x16dbe
jmp 0x16ddd
leaq 0x49a28(%rip), %rdi     # 0x607ed
leaq 0x47148(%rip), %rsi     # 0x5df14
movl $0x4c0, %edx            # imm = 0x4C0
leaq 0x4993f(%rip), %rcx     # 0x60717
callq 0xd1c0
movl -0x1c(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)