// File: /workspace/github_cpp_makefile_star2_O3/vsklad[P]cgen/./bal/anf/anf.cpp
// Function: bal::Anf::append_equation_term(unsigned int const*, unsigned long)
void Anf::append_equation_term(const literalid_t* const symbols, const std::size_t symbols_size) {
        is_incomplete_last_equation_();
        const size_t equation_terms_size = terms_size_(equations_.size() - 1);
        
        // while 1, the term is valid even if becomes 1
        literalid_t constant = literal_t__constant(1);
        
        // validate the term itself
        // build sorted array of unique variable numbers
        // the rest is optimized out
        literalid_t validated_symbols[symbols_size];
        std::size_t validated_symbols_size = 0;
        std::size_t first_negation_index = symbols_size;
        
        for (auto i = 0; i < symbols_size && literal_t__is_constant_1(constant); i++) {
            if (literal_t__is_constant_0(symbols[i])) {
                constant = literal_t__constant(0);
                validated_symbols_size = 0;
                break;
            } else if (literal_t__is_constant_1(symbols[i])) {
                continue;
            } else {
                // adjust number of variables if necessary
                if (VariableGenerator::next() <= literal_t__variable_id(symbols[i])) {
                    VariableGenerator::reset(literal_t__variable_id(symbols[i]) + 1);
                };
                
                unsigned int j = 0;
                while (j < validated_symbols_size) {
                    if (literal_t__is_negation_of(symbols[i], validated_symbols[j])) {
                        // x & ~x == 0
                        constant = literal_t__constant(0);
                        validated_symbols_size = 0;
                        break;
                    } else if (symbols[i] == validated_symbols[j]) {
                        // x & x == x
                        break;
                    } else if (symbols[i] > validated_symbols[j]) {
                        // found the sorted insertion point
                        break;
                    };
                    j++;
                };
                if (j == validated_symbols_size || symbols[i] > validated_symbols[j]) {
                    if (j < validated_symbols_size) {
                        j++;
                        for (auto k = j; k < validated_symbols_size; k++) {
                            validated_symbols[k + 1] = validated_symbols[k];
                        };
                    };
                    validated_symbols[j] = symbols[i];
                    validated_symbols_size++;
                    
                    if (literal_t__is_negation(validated_symbols[j]) && first_negation_index > j) {
                        first_negation_index = j;
                    };
                };
            };
        };
        
        if (literal_t__is_constant_1(constant)) {
            if (validated_symbols_size > 0) {
                // handle negations
                // the first negation should be processed recursively replacing the negated variable with 1
                // then the second time unnegated
                if (first_negation_index < validated_symbols_size) {
                    literalid_t first_negated_literal = validated_symbols[first_negation_index];
                    validated_symbols[first_negation_index] = literal_t__constant(1);
                    append_equation_term(validated_symbols, validated_symbols_size); // recursive call
                    validated_symbols[first_negation_index] = literal_t__unnegated(first_negated_literal);
                    append_equation_term(validated_symbols, validated_symbols_size); // recursive call
                } else {
                    // now there is a sorted list of unique unnegated literals
                    // go through existing terms and check if there is a matching one
                    size_t term_index = terms_.size();
                    if (equation_terms_size > 1) {
                        const auto first_term_index = equations_[equations_.size() - 1] + 1; // skip the constant
                        for (auto i = first_term_index; i < first_term_index + equation_terms_size - 1; i++) {
                            const auto term_symbols_size = symbols_size_(i);
                            if (term_symbols_size == validated_symbols_size) {
                                term_index = i;
                                const auto first_symbol_index = terms_[i];
                                for (auto j = 0; j < validated_symbols_size; j++) {
                                    if (symbols_[first_symbol_index + j] != validated_symbols[j]) {
                                        term_index = terms_.size();
                                        break;
                                    };
                                };
                                if (term_index < terms_.size()) {
                                    break;
                                };
                            };
                        };
                    };
                    
                    if (term_index < terms_.size()) {
                        // term == terms_[term_index], i.e. <term> + <term>, remove the term_[term_index]
                        last_equation_remove_term_(term_index);
                    } else {
                        // append the new term
                        assert(symbols_.size() < UINT32_MAX);
                        terms_.push_back((uint32_t)symbols_.size());
                        for (auto i = 0; i < validated_symbols_size; i++) {
                            symbols_.push_back(validated_symbols[i]);
                        };
                    };
                };
            } else {
                // the term is the constant 1
                // find the first term of size 1 and attach to it
                auto term_index = equations_[equations_.size() - 1];
                const auto term_index_end = term_index + equation_terms_size;
                while (term_index < term_index_end && symbols_size_(term_index) > 1) {
                    term_index++;
                };
                _assert_level_1(term_index < term_index_end);
                literal_t__negate(symbols_[terms_[term_index]]);
            };
        };
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
movq %rsi, %r13
movq %rdi, %r14
callq 0xe4f6
movq %r14, %rdi
movq 0xb0(%r14), %rcx
movq 0x98(%r14), %rax
movq 0xa8(%r14), %r8
subq 0x90(%r14), %rax
sarq $0x2, %rax
movl -0x4(%rcx), %edx
subq %r8, %rcx
subq %rdx, %rax
movq %rsp, %r14
leaq 0xf(,%rbx,4), %rdx
andq $-0x10, %rdx
subq %rdx, %r14
movq %r14, %rsp
testq %rbx, %rbx
je 0xd12e
movq %r8, -0x40(%rbp)
movq %rcx, -0x48(%rbp)
movq %rdi, -0x30(%rbp)
movl 0x8(%rdi), %edi
xorl %esi, %esi
xorl %r15d, %r15d
movq %rbx, %r12
movl (%r13,%rsi,4), %r8d
cmpl $0x1, %r8d
je 0xd0c4
testl %r8d, %r8d
je 0xd1b1
movl %r8d, %r9d
shrl %r9d
leal -0x1(%r9), %edx
cmpl %edx, %edi
ja 0xd023
cmpl $-0x4, %r8d
jae 0xd40d
movq -0x30(%rbp), %rcx
movl %r9d, 0x8(%rcx)
movl %r9d, %edi
testq %r15, %r15
je 0xd05f
movl (%r13,%rsi,4), %r11d
xorl %r8d, %r8d
xorl %r10d, %r10d
xorl %r9d, %r9d
movl (%r14,%r10,4), %ecx
movl %ecx, %edx
xorl %r11d, %edx
cmpl $0x1, %edx
je 0xd06d
cmpl %ecx, %r11d
jae 0xd057
incl %r9d
movq %r9, %r10
cmpq %r9, %r15
ja 0xd036
movq %r9, %r10
movl $0x1, %r8d
jmp 0xd070
movl $0x1, %r8d
xorl %r9d, %r9d
xorl %r15d, %r15d
jmp 0xd0a7
xorl %r15d, %r15d
cmpq %r10, %r15
je 0xd080
movl (%r13,%rsi,4), %ecx
cmpl (%r14,%r10,4), %ecx
jbe 0xd0c4
cmpq %r10, %r15
jbe 0xd0a7
leal 0x1(%r9), %r10d
cmpq %r10, %r15
jbe 0xd0aa
movl (%r14,%r10,4), %r11d
addl $0x2, %r9d
movl %r9d, %ecx
movl %r11d, (%r14,%rcx,4)
incl %r9d
cmpq %rcx, %r15
ja 0xd096
jmp 0xd0aa
movl %r9d, %r10d
movl (%r13,%rsi,4), %ecx
movl %ecx, (%r14,%r10,4)
incq %r15
cmpq %r10, %r12
cmovbq %r12, %r10
testb $0x1, %cl
cmoveq %r10, %r12
incq %rsi
cmpq %rbx, %rsi
jae 0xd0d6
cmpl $0x1, %r8d
je 0xcfe8
cmpl $0x1, %r8d
jne 0xd1b1
testq %r15, %r15
movq -0x30(%rbp), %rdi
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %r8
je 0xd12e
cmpq %r15, %r12
jae 0xd1c0
movl (%r14,%r12,4), %ebx
movl $0x1, (%r14,%r12,4)
movq %r14, %rsi
movq %r15, %rdx
movq %rdi, %r13
callq 0xcf68
orl $0x1, %ebx
movl %ebx, (%r14,%r12,4)
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0xcf68
jmp 0xd1b1
movl -0x4(%r8,%rcx), %ecx
addq %rcx, %rax
cmpq %rcx, %rax
jbe 0xd18d
movq 0x98(%rdi), %rdx
movq 0x90(%rdi), %rsi
subq %rsi, %rdx
sarq $0x2, %rdx
decq %rdx
movq 0x78(%rdi), %r11
movq 0x80(%rdi), %r8
subq %r11, %r8
sarq $0x2, %r8
leal 0x1(%rcx), %r9d
movq %r8, %r10
cmpq %rcx, %rdx
je 0xd176
movl 0x4(%rsi,%rcx,4), %r10d
movl (%rsi,%rcx,4), %ecx
subq %rcx, %r10
cmpq $0x1, %r10
jbe 0xd1ac
movl %r9d, %ecx
incl %r9d
cmpq %rcx, %rax
ja 0xd169
leaq 0x31f2c(%rip), %rdi     # 0x3f0c0
leaq 0x31e84(%rip), %rsi     # 0x3f01f
leaq 0x31ecd(%rip), %rcx     # 0x3f06f
movl $0xae, %edx
callq 0xb180
xorb $0x1, (%r11,%rcx,4)
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x98(%rdi), %rsi
cmpq $0x2, %rax
jb 0xd2bd
movl -0x4(%r8,%rcx), %ecx
incl %ecx
addq %rcx, %rax
decq %rax
cmpq %rcx, %rax
jbe 0xd2bd
movq 0x90(%rdi), %r13
movq %rsi, %rdx
subq %r13, %rdx
sarq $0x2, %rdx
leaq -0x1(%rdx), %r8
movq 0x78(%rdi), %r9
movq 0x80(%rdi), %r10
subq %r9, %r10
sarq $0x2, %r10
movq %rdx, %rbx
movq %r10, %r12
cmpq %rcx, %r8
je 0xd21e
movl 0x4(%r13,%rcx,4), %r12d
movl (%r13,%rcx,4), %r11d
subq %r11, %r12
cmpq %r15, %r12
jne 0xd250
xorl %ebx, %ebx
leal (%r11,%rbx), %r12d
movl (%r9,%r12,4), %r12d
cmpl (%r14,%rbx,4), %r12d
jne 0xd24d
incq %rbx
cmpq %rbx, %r15
jne 0xd22d
movq %rcx, %rbx
cmpq %rcx, %rdx
jbe 0xd250
jmp 0xd257
movq %rdx, %rbx
incl %ecx
cmpq %rcx, %rax
ja 0xd211
cmpq %rdx, %rbx
movq -0x30(%rbp), %rdi
jae 0xd2bd
callq 0xe4f6
movq -0x30(%rbp), %rdi
movq 0xb0(%rdi), %rax
movl -0x4(%rax), %eax
cmpq %rax, %rbx
jb 0xd44b
movq 0x90(%rdi), %rax
movq 0x98(%rdi), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %rbx, %rcx
jbe 0xd44b
decq %rcx
cmpq %rbx, %rcx
jne 0xd34c
movq 0x78(%rdi), %rcx
movq 0x80(%rdi), %r12
subq %rcx, %r12
sarq $0x2, %r12
jmp 0xd355
movq 0x80(%rdi), %rax
subq 0x78(%rdi), %rax
sarq $0x2, %rax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
jae 0xd42c
movl %eax, -0x34(%rbp)
cmpq 0xa0(%rdi), %rsi
je 0xd2f5
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x98(%rdi)
jmp 0xd309
addq $0x90, %rdi
leaq -0x34(%rbp), %rdx
callq 0xe7da
movq -0x30(%rbp), %rdi
leaq 0x78(%rdi), %r12
movq -0x30(%rbp), %rcx
movq 0x80(%rcx), %rsi
cmpq 0x88(%rcx), %rsi
je 0xd333
movl (%r14), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x80(%rcx)
jmp 0xd33e
movq %r12, %rdi
movq %r14, %rdx
callq 0xe912
addq $0x4, %r14
decq %r15
jne 0xd30d
jmp 0xd1b1
movl 0x4(%rax,%rbx,4), %r12d
movq 0x78(%rdi), %rcx
movl (%rax,%rbx,4), %r13d
cmpq %r13, %r12
je 0xd3a5
leaq (%rcx,%r13,4), %r14
leaq (%rcx,%r12,4), %r15
movq 0x80(%rdi), %rdx
subq %r15, %rdx
je 0xd38d
movq %r14, %rdi
movq %r15, %rsi
callq 0xb450
movq -0x30(%rbp), %rdi
movq 0x80(%rdi), %rax
movq %rax, %rcx
jmp 0xd393
movq %r15, %rax
movq %r15, %rcx
subq %r15, %rax
addq %rax, %r14
cmpq %r14, %rcx
je 0xd3a5
movq %r14, 0x80(%rdi)
movq 0x90(%rdi), %rax
movq 0x98(%rdi), %rdx
leaq (%rax,%rbx,4), %rsi
addq $0x4, %rsi
cmpq %rdx, %rsi
je 0xd3de
leaq (%rax,%rbx,4), %rdi
subq %rsi, %rdx
callq 0xb450
movq -0x30(%rbp), %rdi
movq 0x90(%rdi), %rax
movq 0x98(%rdi), %rdx
addq $-0x4, %rdx
movq %rdx, 0x98(%rdi)
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rbx, %rdx
jbe 0xd1b1
subl %r12d, %r13d
addl %r13d, (%rax,%rbx,4)
incq %rbx
cmpq %rbx, %rdx
jne 0xd3fc
jmp 0xd1b1
leaq 0x321f7(%rip), %rdi     # 0x3f60b
leaq 0x3220d(%rip), %rsi     # 0x3f628
leaq 0x3221e(%rip), %rcx     # 0x3f640
movl $0x9b, %edx
callq 0xb180
leaq 0x31c1f(%rip), %rdi     # 0x3f052
leaq 0x31be5(%rip), %rsi     # 0x3f01f
leaq 0x31c2e(%rip), %rcx     # 0x3f06f
movl $0x9f, %edx
callq 0xb180
leaq 0x32225(%rip), %rdi     # 0x3f677
leaq 0x31bc6(%rip), %rsi     # 0x3f01f
leaq 0x32265(%rip), %rcx     # 0x3f6c5
movl $0x26, %edx
callq 0xb180