// File: /workspace/github_cpp_makefile_star2_O1/vsklad[P]cgen/./bal/variables/variablesarray.hpp
// Function: bal::VariablesArray::assign_template_from(bal::VariablesArray const&, bal::VariablesArray const&)
inline variables_size_t assign_template_from(const VariablesArray& template_, const VariablesArray& value) {
            _assert_level_1(template_.size_ == value.size_);
            variables_size_t changes_count = 0;
            for (container_size_t i = 0; i < template_.size_; i++) {
                literalid_t lhs_literal = template_.data_[i];
                literalid_t rhs_literal = value.data_[i];
                
                // an unassigned literal means there is nothing to assign or to assign to
                // equalence means there is nothing to assign as well
                while (!literal_t__is_unassigned(rhs_literal) &&
                       !literal_t__is_unassigned(lhs_literal) && lhs_literal != rhs_literal) {
                    
                    if (literal_t__is_variable(lhs_literal)) {
                        rhs_literal = literal_t__substitute_literal(lhs_literal, rhs_literal);
                        literal_t__unnegate(lhs_literal);
                        
                        const variableid_t variableid = literal_t__variable_id(lhs_literal);
                        _assert_level_1(variableid < size_);

                        // the value must not be set OR it cannot be set to two different values OR
                        // for variables, higher variable id gets assigned with the lower one
                        // i.e. swap variables if necessary
                        if (data_[variableid] != rhs_literal) {
                            if (literal_t__is_variable(rhs_literal) && rhs_literal > lhs_literal) {
                                std::swap(rhs_literal, lhs_literal);
                                continue;
                            } else if (data_[variableid] == lhs_literal || literal_t__is_unassigned(data_[variableid])) {
                                data_[variableid] = rhs_literal;
                                changes_count++;
                            } else if (literal_t__is_negation_of(data_[variableid], lhs_literal)) {
                                data_[variableid] = literal_t__negated(rhs_literal);
                                changes_count++;
                            } else if (literal_t__is_constant(data_[variableid]) || literal_t__is_variable(data_[variableid])) {
                                lhs_literal = data_[variableid];
                                continue;
                            } else {
                                return VARIABLEID_ERROR;
                            };
                        };
                    } else if (literal_t__is_constant(lhs_literal) && literal_t__is_variable(rhs_literal)) {
                        // { const = var } => { var = const }
                        std::swap(rhs_literal, lhs_literal);
                        continue;
                    } else if (lhs_literal != rhs_literal) {
                        // any remaining literals must match whatever they are
                        return VARIABLEID_ERROR;
                    };
                    break;
                };
            };
            return changes_count;
        }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl 0x8(%rsi), %eax
cmpl 0x8(%rdx), %eax
jne 0xf951
cmpl $0x0, 0x8(%rsi)
je 0xf910
movq (%rsi), %rax
movq (%rdx), %rdx
xorl %r8d, %r8d
movl $0x0, -0x2c(%rbp)
movq %rsi, -0x38(%rbp)
movl (%rax,%r8,4), %ebx
movl (%rdx,%r8,4), %r10d
movq (%rdi), %r9
movl %ebx, %r14d
cmpl $-0x1, %r10d
sete %cl
cmpl $-0x1, %ebx
sete %bl
cmpl %r10d, %r14d
sete %r11b
orb %bl, %r11b
orb %cl, %r11b
jne 0xf8fa
cmpl $0x2, %r14d
jae 0xf842
movl %r10d, %ebx
cmpl $0x1, %r10d
movl %r14d, %r10d
ja 0xf808
jmp 0xf8fa
movl %r14d, %r11d
shrl %r11d
decl %r11d
cmpl 0x8(%rdi), %r11d
jae 0xf932
movl %r14d, %r12d
andl $0x1, %r12d
xorl %r10d, %r12d
movl %r12d, %r10d
xorl $0x1, %r10d
orl $0x1, %r14d
movl %r11d, %r13d
movl (%r9,%r13,4), %ebx
xorl %r15d, %r15d
movb $0x1, %r11b
cmpl %r10d, %ebx
jne 0xf881
movl %r14d, %ebx
jmp 0xf8e8
movq %rdx, %rsi
movq %rax, %rdx
leal -0x2(%r10), %ecx
cmpl $-0x3, %ecx
setb %cl
cmpl %r14d, %r10d
seta %al
movl $0x5, %r15d
testb %cl, %al
je 0xf8ac
xorl %r11d, %r11d
movl %r10d, %ebx
movl %r14d, %r10d
jmp 0xf8de
cmpl %r14d, %ebx
sete %al
cmpl $-0x1, %ebx
sete %cl
orb %al, %cl
movl %r10d, %ecx
jne 0xf8cc
movl %ebx, %eax
xorl %r14d, %eax
movl %r12d, %ecx
cmpl $0x1, %eax
jne 0xf8db
movl %ecx, (%r9,%r13,4)
incl -0x2c(%rbp)
xorl %r15d, %r15d
movl %r14d, %ebx
jmp 0xf8de
xorl %r11d, %r11d
movq %rdx, %rax
movq %rsi, %rdx
movq -0x38(%rbp), %rsi
cmpl $0x5, %r15d
je 0xf808
testl %r15d, %r15d
jne 0xf8fa
movb $0x1, %r11b
testb %r11b, %r11b
je 0xf919
incq %r8
movl 0x8(%rsi), %ecx
cmpq %rcx, %r8
jb 0xf7fd
jmp 0xf920
movl $0x0, -0x2c(%rbp)
jmp 0xf920
movl $0x7fffffff, -0x2c(%rbp) # imm = 0x7FFFFFFF
movl -0x2c(%rbp), %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x31f87(%rip), %rdi     # 0x418c0
leaq 0x31dec(%rip), %rsi     # 0x4172c
leaq 0x31f0e(%rip), %rcx     # 0x41855
movl $0x9d, %edx
callq 0xc180
leaq 0x31ede(%rip), %rdi     # 0x41836
leaq 0x31dcd(%rip), %rsi     # 0x4172c
leaq 0x31eef(%rip), %rcx     # 0x41855
movl $0x8d, %edx
callq 0xc180