// File: 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
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
cmpl $0x1, -0x24(%rbp)
ja 0x450af
jmp 0x450ce
leaq 0x20904(%rip), %rdi     # 0x659ba
leaq 0x1f106(%rip), %rsi     # 0x641c3
movl $0xbe, %edx
leaq 0x2091c(%rip), %rcx     # 0x659e5
callq 0xd1c0
cmpq $0x0, -0x20(%rbp)
jne 0x450e0
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4521a
movl $0xffffffff, -0x28(%rbp) # imm = 0xFFFFFFFF
cmpq $0x0, -0x10(%rbp)
je 0x450f0
jmp 0x4510f
leaq 0x21d05(%rip), %rdi     # 0x66dfc
leaq 0x1f0c5(%rip), %rsi     # 0x641c3
movl $0xc3, %edx
leaq 0x208db(%rip), %rcx     # 0x659e5
callq 0xd1c0
movq -0x10(%rbp), %rdi
callq 0x40ac0
movl %eax, %eax
movq %rax, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq -0x20(%rbp), %rcx
subq -0x38(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x45145
movq -0x20(%rbp), %rax
subq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x4514d
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x1, -0x40(%rbp)
jbe 0x451b2
cmpq $0x0, -0x10(%rbp)
je 0x45165
jmp 0x45184
leaq 0x21c90(%rip), %rdi     # 0x66dfc
leaq 0x1f050(%rip), %rsi     # 0x641c3
movl $0xcd, %edx
leaq 0x20866(%rip), %rcx     # 0x659e5
callq 0xd1c0
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movl -0x28(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x38(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdx
movq -0x40(%rbp), %rcx
callq 0x120e0
jmp 0x451c9
cmpq $0x1, -0x40(%rbp)
jne 0x451c7
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x28(%rbp)
jmp 0x451c9
movq -0x40(%rbp), %rax
addq -0x38(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x451fb
movq -0x38(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
movl -0x28(%rbp), %edx
movq -0x18(%rbp), %rax
movq -0x38(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x451fd
jmp 0x45202
jmp 0x45126
movl -0x28(%rbp), %eax
movl -0x24(%rbp), %esi
xorl %ecx, %ecx
movl $0x1, %edx
cmpl $0x1, %esi
cmovel %edx, %ecx
xorl %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)