// File: /workspace/github_cpp_makefile_star2_O3/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 0x2f223
movq %rdx, %r12
testq %rdx, %rdx
je 0x2f212
movq %rdi, %r14
testq %rdi, %rdi
je 0x2f242
movl %ecx, -0x34(%rbp)
movl 0x74(%r14), %eax
testl %eax, %eax
jne 0x2f18a
movq (%r14), %rax
movq %r14, %rdi
callq *0x30(%rax)
movq %r14, -0x48(%rbp)
movl %eax, %ecx
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
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 0x2f1dc
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 0xe9e8
movq -0x40(%rbp), %rcx
jmp 0x2f1ea
cmpq $0x1, %r14
jne 0x2f1ea
movq -0x30(%rbp), %rax
movl (%rax,%r15,4), %r13d
addq %r15, %r14
cmpq %r12, %r14
jae 0x2f203
movq -0x30(%rbp), %rax
movl %r13d, -0x4(%rax,%r14,4)
decq %r14
movq %r14, %r15
jmp 0x2f1a1
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 0x1a1fd(%rip), %rdi     # 0x49427
leaq 0x18be6(%rip), %rsi     # 0x47e17
leaq 0x1a21a(%rip), %rcx     # 0x49452
movl $0xbe, %edx
callq 0xb180
leaq 0x1b4b9(%rip), %rdi     # 0x4a702
leaq 0x18bc7(%rip), %rsi     # 0x47e17
leaq 0x1a1fb(%rip), %rcx     # 0x49452
movl $0xc3, %edx
callq 0xb180