// File: /workspace/github_cpp_makefile_star2_O3/vsklad[P]cgen/./bal/encoding/literal.hpp
// Function: bal::Ref<bal::Literal<bal::Anf>> bal::eor<bal::Anf>(bal::Literal<bal::Anf>*, bal::Literal<bal::Anf> const* const*, unsigned long)
Ref<Literal<FORMULA_T>> eor(Literal<FORMULA_T>* const r,
                                const Literal<FORMULA_T>* const args[], const std::size_t args_size) {
        literalid_t constant = 0;
        literalid_t optimized_args[args_size];
        std::size_t optimized_args_size = 0;
        FORMULA_T* formula = nullptr;
        
        for (auto i = 0; i < args_size; i++) {
            if (literal_t__is_constant(args[i]->value)) {
                constant ^= args[i]->value;
            } else {
                // eliminate if the variables are negated or duplicated
                // build a sorted list because:
                // INCONCLUSIVE: lower indexes first - order matters
                // grouping of lower indexes reduces length of variables chain (?)
                for (auto j = 0; j <= optimized_args_size; j++) {
                    if (j == optimized_args_size) {
                        // at the end, no duplicates, append to lagrs
                        update_formula(formula, args[i]);
                        optimized_args[j] = args[i]->value;
                        optimized_args_size++;
                        break;
                    } else if (literal_t__is_same_variable(args[i]->value, optimized_args[j])) {
                        if ((literal_t__is_negation_of(args[i]->value, optimized_args[j]))) {
                            // negated means always 1
                            constant ^= 1;
                        };
                        // remove from variable_args
                        for (auto k = j; k < optimized_args_size - 1; k++) {
                            optimized_args[k] = optimized_args[k + 1];
                        };
                        optimized_args_size--;
                        break;
#if defined(XOR_ARGS_ORDER_ASCENDING) || defined(XOR_ARGS_ORDER_DESCENDING)
                    } else if (literal_t__variable_id(args[i]->value)
#if defined(XOR_ARGS_ORDER_ASCENDING)
                               <
#elif defined(XOR_ARGS_ORDER_DESCENDING)
                               >
#endif
                               literal_t__variable_id(optimized_args[j])) {
                        // insertion point found
                        for (auto k = optimized_args_size; k > j; k--) {
                            optimized_args[k] = optimized_args[k - 1];
                        };
                        update_formula(formula, args[i]);
                        optimized_args[j] = args[i]->value;
                        optimized_args_size++;
                        break;
#endif
                    };
                };
            };
        };
        
        return Literal<FORMULA_T>::from_literal(formula, eor(formula, optimized_args, optimized_args_size, constant));
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, -0x48(%rbp)
movq %rsp, %r14
leaq 0xf(,%rcx,4), %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
movq $0x0, -0x30(%rbp)
testq %rcx, %rcx
je 0x2f09c
movq %rdx, %r12
xorl %r15d, %r15d
xorl %ebx, %ebx
xorl %r9d, %r9d
movq %rcx, -0x40(%rbp)
movq (%r12,%r15,8), %rsi
movl 0x20(%rsi), %eax
cmpl $0x2, %eax
jae 0x2efd6
xorl %eax, %r9d
jmp 0x2f08a
testq %rbx, %rbx
je 0x2f005
movl %eax, %r8d
shrl %r8d
decl %r8d
xorl %r13d, %r13d
movl (%r14,%r13,4), %edx
movl %edx, %edi
xorl %eax, %edi
cmpl $0x1, %edi
jbe 0x2f028
shrl %edx
decl %edx
cmpl %edx, %r8d
jb 0x2f04e
incq %r13
cmpq %r13, %rbx
jne 0x2efe7
leaq -0x30(%rbp), %rdi
movl %r9d, %r13d
callq 0x2f0d8
movl %r13d, %r9d
movq -0x40(%rbp), %rcx
movq (%r12,%r15,8), %rax
movl 0x20(%rax), %eax
movl %eax, (%r14,%rbx,4)
incq %rbx
jmp 0x2f08a
sete %al
movzbl %al, %eax
xorl %eax, %r9d
decq %rbx
movl %r13d, %eax
cmpq %rax, %rbx
jbe 0x2f08a
movl 0x4(%r14,%r13,4), %eax
movl %eax, (%r14,%r13,4)
leaq 0x1(%r13), %rax
movq %rax, %r13
jmp 0x2f037
movl %r9d, -0x34(%rbp)
movq %rbx, %rax
cmpq %r13, %rbx
jbe 0x2f06b
movl -0x4(%r14,%rax,4), %ecx
movl %ecx, (%r14,%rax,4)
decq %rax
cmpq %r13, %rax
ja 0x2f05a
leaq -0x30(%rbp), %rdi
callq 0x2f0d8
movq (%r12,%r15,8), %rax
movl 0x20(%rax), %eax
movl %eax, (%r14,%r13,4)
incq %rbx
movq -0x40(%rbp), %rcx
movl -0x34(%rbp), %r9d
incq %r15
cmpq %rcx, %r15
jne 0x2efc2
movq -0x30(%rbp), %r15
jmp 0x2f0a4
xorl %r15d, %r15d
xorl %r9d, %r9d
xorl %ebx, %ebx
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movl %r9d, %ecx
callq 0x2f140
movq -0x48(%rbp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
movl %eax, %edx
callq 0x2d944
movq %rbx, %rax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq