// File: /workspace/github_cpp_makefile_star2_O2/vsklad[P]cgen/./bal/anf/anfencoding.hpp
// Function: bal::Ref<bal::GF2NElement<32ul, bal::Literal<bal::Anf>>> bal::add2<32ul>(bal::GF2NElement<32ul, bal::Literal<bal::Anf>>*, bal::GF2NElement<32ul, bal::Literal<bal::Anf>> const*, bal::GF2NElement<32ul, bal::Literal<bal::Anf>> const*)
Ref<GF2NElement<N, Literal<Anf>>> add2(GF2NElement<N, Literal<Anf>>* r,
                                           const GF2NElement<N, Literal<Anf>>* x,
                                           const GF2NElement<N, Literal<Anf>>* y) {
        static_assert(N > 0, "trivial");
        _assert_level_0(x != nullptr && y != nullptr);
        Ref<GF2NElement<N, Literal<Anf>>> result = new_instance_if_unassigned(r);
        
        // because it is possible that result == one of the operands
        literalid_t x_p = (*x)[0]->value;      // previous x
        literalid_t y_p = (*y)[0]->value;      // previous y
        (*result)[0] = eor2((*result)[0].data(), (*x)[0].data(), (*y)[0].data());
        literalid_t r_p = (*result)[0]->value; // previous r
        
        Anf* formula = (*result)[0]->formula;
        update_formula(formula, (*x)[0]);
        update_formula(formula, (*y)[0]);
        
        for (auto i = 1; i < N; i++) {
            const literalid_t x_i = (*x)[i]->value;
            const literalid_t y_i = (*y)[i]->value;
            update_formula(formula, (*x)[i]);
            update_formula(formula, (*y)[i]);
            
            // formula instance is undefined when all operands are constant
            // but the result can be easily calculated and no extra variables required
            if (literal_t__is_constant(x_i) && literal_t__is_constant(y_i) &&
                literal_t__is_constant(r_p) && literal_t__is_constant(x_p) && literal_t__is_constant(y_p)) {
                r_p = x_i ^ y_i ^ x_p ^ y_p ^ (x_p & y_p) ^ (x_p & r_p) ^ (y_p & r_p);
                _assert_level_2(literal_t__is_constant(r_p));
            } else {
                r_p = __add2(formula, LITERALID_UNASSIGNED, x_i, y_i, r_p, x_p, y_p);
                _assert_level_2(literal_t__is_constant(r_p) || literal_t__is_variable(r_p));
            };
            
            (*result)[i] = Literal<Anf>::from_literal(formula, r_p);
            
            x_p = x_i;
            y_p = y_i;
        };
        
        return result;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
testq %rdx, %rdx
je 0x2687f
movq %rcx, %r14
testq %rcx, %rcx
je 0x2687f
movq %rdx, %r15
movq %rdi, %rbx
callq 0x258e4
movq 0x30(%r15), %rdx
movl 0x20(%rdx), %eax
movl %eax, -0x2c(%rbp)
movq 0x30(%r14), %rcx
movl 0x20(%rcx), %eax
movl %eax, -0x3c(%rbp)
movq (%rbx), %rax
movq 0x30(%rax), %rsi
leaq -0x38(%rbp), %rdi
movq %rbx, -0x48(%rbp)
callq 0x262d7
movq (%rbx), %rax
leaq -0x38(%rbp), %r12
movq (%r12), %rcx
movq %rcx, 0x30(%rax)
andq $0x0, (%r12)
movq %r12, %rdi
callq 0x1f456
movq (%rbx), %rax
movq 0x30(%rax), %rax
movl 0x20(%rax), %r13d
movq 0x18(%rax), %rax
movq %rax, (%r12)
movq 0x30(%r15), %rsi
leaq -0x38(%rbp), %rbx
movq %rbx, %rdi
callq 0x25b82
movq %r14, -0x60(%rbp)
movq 0x30(%r14), %rsi
movq %rbx, %rdi
callq 0x25b82
xorl %r12d, %r12d
movl -0x2c(%rbp), %ecx
movq %r15, -0x58(%rbp)
cmpq $0x1f, %r12
je 0x2684f
movq 0x38(%r15,%r12,8), %rsi
movl 0x20(%rsi), %eax
movl %eax, -0x2c(%rbp)
movq -0x60(%rbp), %r14
movq 0x38(%r14,%r12,8), %rax
movl 0x20(%rax), %r15d
leaq -0x38(%rbp), %rdi
movl %ecx, %ebx
callq 0x25b82
movq 0x38(%r14,%r12,8), %rsi
movl %r15d, %r14d
leaq -0x38(%rbp), %rdi
callq 0x25b82
movl -0x2c(%rbp), %r15d
cmpl $0x1, %r15d
movl -0x3c(%rbp), %ecx
ja 0x267e9
cmpl $0x1, %r14d
ja 0x267e9
cmpl $0x1, %r13d
ja 0x267e9
cmpl $0x1, %ebx
ja 0x267e9
cmpl $0x1, %ecx
ja 0x267e9
movl %r13d, %eax
xorl %ecx, %eax
andl %ebx, %eax
notl %r13d
andl %ecx, %r13d
xorl %eax, %r13d
xorl %ebx, %r13d
xorl %r15d, %r13d
xorl %r14d, %r13d
leaq -0x50(%rbp), %rbx
jmp 0x26810
movq -0x38(%rbp), %rdi
movl %ecx, (%rsp)
pushq $-0x1
popq %rsi
movl %r15d, %edx
movl %r14d, %ecx
movl %r13d, %r8d
movl %ebx, %r9d
callq 0xe6ac
leaq -0x50(%rbp), %rbx
movl %eax, %r13d
cmpl $-0x1, %eax
je 0x26862
movq -0x38(%rbp), %rsi
movq %rbx, %rdi
movl %r13d, %edx
callq 0x248c8
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq -0x50(%rbp), %rcx
movq %rcx, 0x38(%rax,%r12,8)
andq $0x0, -0x50(%rbp)
movq %rbx, %rdi
callq 0x1f456
incq %r12
movl %r14d, -0x3c(%rbp)
movl %r15d, %ecx
movq -0x58(%rbp), %r15
jmp 0x26769
movq -0x48(%rbp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x15303(%rip), %rdi     # 0x3bb6c
leaq 0x1523f(%rip), %rsi     # 0x3baaf
leaq 0x15252(%rip), %rcx     # 0x3bac9
pushq $0x49
popq %rdx
callq 0xc180
leaq 0x1520c(%rip), %rdi     # 0x3ba92
leaq 0x15222(%rip), %rsi     # 0x3baaf
leaq 0x15235(%rip), %rcx     # 0x3bac9
pushq $0x2e
jmp 0x26879
jmp 0x2689c
jmp 0x2689c
movq %rax, %rbx
movq -0x48(%rbp), %rdi
callq 0x23cce
movq %rbx, %rdi
callq 0xc4c0