// File: vsklad[P]cgen/./bal/encoding/literaladd.hpp
// Function: bal::add_append_variable_(unsigned int, std::vector<unsigned int, std::allocator<unsigned int>>&, std::vector<unsigned int, std::allocator<unsigned int>>&, unsigned int&)
inline void add_append_variable_(const literalid_t arg,
                                     std::vector<literalid_t>& variables,
                                     std::vector<literalid_t>& carry_out_1,
                                     unsigned& constant) {
        if (literal_t__is_constant(arg)) {
            constant += literal_t__is_constant_1(arg) ? 1 : 0;
        } else {
            // check for duplicates including negation
            for (auto i = 0; i < variables.size(); i++) {
                if (literal_t__is_same_variable(arg, variables[i])) {
                    if (literal_t__is_negation_of(arg, variables[i])) {
                        // if negation, x + !x <=> 1; remove variables[i] and add 1
                        constant += 1;
                    } else {
                        add_append_carry_(arg, carry_out_1);
                    };
                    
                    // remove the variable
                    if (variables.size() > 1) {
                        variables[i] = variables[variables.size() - 1];
                    };
                    variables.resize(variables.size() - 1);
                    
                    return;
                };
            };
            variables.push_back(arg);
        };
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
cmpl $0x1, -0x4(%rbp)
ja 0x4f68a
movl -0x4(%rbp), %edx
xorl %ecx, %ecx
movl $0x1, %eax
cmpl $0x1, %edx
cmovel %eax, %ecx
movq -0x20(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
jmp 0x4f798
movl $0x0, -0x24(%rbp)
movslq -0x24(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0xf9f0
movq %rax, %rcx
movq -0x30(%rbp), %rax
cmpq %rcx, %rax
jae 0x4f78b
movl -0x4(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0xfd50
movq %rax, %rcx
movl -0x34(%rbp), %eax
xorl (%rcx), %eax
shrl %eax
cmpl $0x0, %eax
jne 0x4f77b
movl -0x4(%rbp), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0xfd50
movq %rax, %rcx
movl -0x38(%rbp), %eax
xorl (%rcx), %eax
cmpl $0x1, %eax
jne 0x4f705
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x4f711
movl -0x4(%rbp), %edi
movq -0x18(%rbp), %rsi
callq 0x4f7c0
movq -0x10(%rbp), %rdi
callq 0xf9f0
cmpq $0x1, %rax
jbe 0x4f758
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
callq 0xf9f0
movq -0x48(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0xfd50
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
movslq -0x24(%rbp), %rsi
callq 0xfd50
movl -0x3c(%rbp), %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rdi
callq 0xf9f0
movq -0x50(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0x2e270
jmp 0x4f798
jmp 0x4f77d
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x4f691
movq -0x10(%rbp), %rdi
leaq -0x4(%rbp), %rsi
callq 0xfa40
addq $0x50, %rsp
popq %rbp
retq
nop