// File: /workspace/github_cpp_makefile_star2_O2/vsklad[P]cgen/./bal/encoding/literal.hpp
// Function: unsigned int bal::eor<bal::Anf>(bal::Anf*, unsigned int*, unsigned long, unsigned int)
literalid_t eor(FORMULA_T* const formula, literalid_t args[], const std::size_t args_size, const literalid_t constant) {
        _assert_level_0(literal_t__is_constant(constant));
        if (args_size == 0) {
            return constant;
        } else {
            literalid_t result = LITERALID_UNASSIGNED;
            _assert_level_0(formula != nullptr);
            
            // split a single xor into smaller ones if requested
            const std::size_t batch_size = formula->get_xor_max_args();
            std::size_t vargs_start_idx = 0;
            
            while (true) {
                const std::size_t vargs_size = batch_size > args_size - vargs_start_idx ? args_size - vargs_start_idx : batch_size;
                
                if (vargs_size > 1) {
                    _assert_level_0(formula != nullptr);
                    result = formula->new_variable_literal();
                    eor(formula, result, args + vargs_start_idx, vargs_size);
                } else if (vargs_size == 1) {
                    result = args[vargs_start_idx];
                };
                
                vargs_start_idx += vargs_size;
                if (vargs_start_idx < args_size) {
                    vargs_start_idx--;
                    args[vargs_start_idx] = result;
                } else {
                    break;
                };
            };
            
            // invert the result if the sum of the constants is 1, i.e. xor(x, 1) <-> not(x)
            return literal_t__negated_onlyif(result, literal_t__is_constant_1(constant));;
        };
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, -0x30(%rbp)
cmpl $0x2, %ecx
jae 0x25cc3
movq %rdx, %r12
testq %rdx, %rdx
je 0x25cb2
movq %rdi, %r14
testq %rdi, %rdi
je 0x25ce2
movl %ecx, -0x34(%rbp)
movl 0x74(%r14), %eax
testl %eax, %eax
jne 0x25c2c
movq (%r14), %rax
movq %r14, %rdi
callq *0x30(%rax)
movq %r14, -0x48(%rbp)
movl %eax, %ecx
pushq $-0x1
popq %r13
xorl %r15d, %r15d
movq %rcx, -0x40(%rbp)
movq -0x48(%rbp), %rbx
movq %r12, %r14
subq %r15, %r14
cmpq %rcx, %r14
cmovaeq %rcx, %r14
cmpq $0x2, %r14
jb 0x25c7c
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movl %eax, %r13d
movq -0x30(%rbp), %rax
leaq (%rax,%r15,4), %rdx
movq %rbx, %rdi
movl %r13d, %esi
movq %r14, %rcx
callq 0xe30c
movq -0x40(%rbp), %rcx
jmp 0x25c8a
cmpq $0x1, %r14
jne 0x25c8a
movq -0x30(%rbp), %rax
movl (%rax,%r15,4), %r13d
addq %r15, %r14
cmpq %r12, %r14
jae 0x25ca3
movq -0x30(%rbp), %rax
movl %r13d, -0x4(%rax,%r14,4)
decq %r14
movq %r14, %r15
jmp 0x25c41
xorl %eax, %eax
cmpl $0x1, -0x34(%rbp)
sete %al
xorl %eax, %r13d
movl %r13d, %ecx
movl %ecx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1590b(%rip), %rdi     # 0x3b5d5
leaq 0x142aa(%rip), %rsi     # 0x39f7b
leaq 0x15928(%rip), %rcx     # 0x3b600
movl $0xbe, %edx
callq 0xc180
leaq 0x16c20(%rip), %rdi     # 0x3c909
leaq 0x1428b(%rip), %rsi     # 0x39f7b
leaq 0x15909(%rip), %rcx     # 0x3b600
movl $0xc3, %edx
callq 0xc180