// File: 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
subq $0xb0, %rsp
movq %rdi, -0x80(%rbp)
movq %rdi, %rax
movq %rax, -0x78(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x18(%rbp)
movb %al, -0x69(%rbp)
je 0x464ed
cmpq $0x0, -0x20(%rbp)
setne %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x464f6
jmp 0x464f8
jmp 0x46517
leaq 0x1f9ec(%rip), %rdi     # 0x65eeb
leaq 0x1fa02(%rip), %rsi     # 0x65f08
movl $0x2e, %edx
leaq 0x1fa10(%rip), %rcx     # 0x65f22
callq 0xd1c0
movq -0x80(%rbp), %rdi
movb $0x0, -0x21(%rbp)
movq -0x10(%rbp), %rsi
callq 0x44a60
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movq %rsi, -0x98(%rbp)
callq 0x44ae0
movq %rax, %rdi
callq 0x430f0
movq -0x98(%rbp), %rsi
movl 0x20(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x44ae0
movq %rax, %rdi
callq 0x430f0
movq -0x80(%rbp), %rdi
movl 0x20(%rax), %eax
movl %eax, -0x2c(%rbp)
callq 0x42220
movq -0x98(%rbp), %rsi
movq %rax, %rdi
callq 0x42240
movq %rax, %rdi
callq 0x42cc0
movq -0x98(%rbp), %rsi
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rdi
callq 0x44ae0
movq %rax, %rdi
callq 0x42cc0
movq -0x98(%rbp), %rsi
movq %rax, -0x88(%rbp)
movq -0x20(%rbp), %rdi
callq 0x44ae0
movq %rax, %rdi
callq 0x42cc0
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
movq %rax, %rcx
leaq -0x38(%rbp), %rdi
callq 0x45d50
jmp 0x465e2
movq -0x80(%rbp), %rdi
callq 0x42220
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x42240
movq %rax, %rdi
leaq -0x38(%rbp), %rsi
callq 0x42270
leaq -0x38(%rbp), %rdi
callq 0x34860
movq -0x80(%rbp), %rdi
callq 0x42220
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x42240
movq %rax, %rdi
callq 0x430f0
movq -0x80(%rbp), %rdi
movl 0x20(%rax), %eax
movl %eax, -0x48(%rbp)
callq 0x42220
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x42240
movq %rax, %rdi
callq 0x430f0
movq 0x18(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x44ae0
movq %rax, %rdi
callq 0x42c20
movq %rax, %rsi
leaq -0x50(%rbp), %rdi
callq 0x44fe0
movq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x44ae0
movq %rax, %rdi
callq 0x42c20
movq %rax, %rsi
leaq -0x50(%rbp), %rdi
callq 0x44fe0
movl $0x1, -0x54(%rbp)
movslq -0x54(%rbp), %rax
cmpq $0x20, %rax
jae 0x468a1
movq -0x18(%rbp), %rdi
movslq -0x54(%rbp), %rsi
callq 0x44ae0
movq %rax, %rdi
callq 0x430f0
movl 0x20(%rax), %eax
movl %eax, -0x58(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x54(%rbp), %rsi
callq 0x44ae0
movq %rax, %rdi
callq 0x430f0
movl 0x20(%rax), %eax
movl %eax, -0x5c(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x54(%rbp), %rsi
callq 0x44ae0
movq %rax, %rdi
callq 0x42c20
movq %rax, %rsi
leaq -0x50(%rbp), %rdi
callq 0x44fe0
movq -0x20(%rbp), %rdi
movslq -0x54(%rbp), %rsi
callq 0x44ae0
movq %rax, %rdi
callq 0x42c20
movq %rax, %rsi
leaq -0x50(%rbp), %rdi
callq 0x44fe0
cmpl $0x1, -0x58(%rbp)
ja 0x467b2
cmpl $0x1, -0x5c(%rbp)
ja 0x467b2
cmpl $0x1, -0x48(%rbp)
ja 0x467b2
cmpl $0x1, -0x28(%rbp)
ja 0x467b2
cmpl $0x1, -0x2c(%rbp)
ja 0x467b2
movl -0x58(%rbp), %eax
xorl -0x5c(%rbp), %eax
xorl -0x28(%rbp), %eax
xorl -0x2c(%rbp), %eax
movl -0x28(%rbp), %ecx
andl -0x2c(%rbp), %ecx
xorl %ecx, %eax
movl -0x28(%rbp), %ecx
andl -0x48(%rbp), %ecx
xorl %ecx, %eax
movl -0x2c(%rbp), %ecx
andl -0x48(%rbp), %ecx
xorl %ecx, %eax
movl %eax, -0x48(%rbp)
cmpl $0x1, -0x48(%rbp)
ja 0x46774
jmp 0x467ad
leaq 0x1f84a(%rip), %rdi     # 0x65fc5
leaq 0x1f786(%rip), %rsi     # 0x65f08
movl $0x46, %edx
leaq 0x1f794(%rip), %rcx     # 0x65f22
callq 0xd1c0
movq -0x80(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
callq 0x40b20
jmp 0x468c1
jmp 0x4684b
movq -0x50(%rbp), %rdi
movl -0x58(%rbp), %edx
movl -0x5c(%rbp), %ecx
movl -0x48(%rbp), %r8d
movl -0x28(%rbp), %r9d
movl -0x2c(%rbp), %esi
movq %rsp, %rax
movl %esi, (%rax)
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x12690
movl %eax, -0x9c(%rbp)
jmp 0x467de
movl -0x9c(%rbp), %eax
movl %eax, -0x48(%rbp)
movb $0x1, %al
cmpl $0x1, -0x48(%rbp)
movb %al, -0x9d(%rbp)
jbe 0x4681c
xorl %eax, %eax
cmpl $0x1, -0x48(%rbp)
movb %al, -0x9e(%rbp)
jbe 0x46810
cmpl $-0x2, -0x48(%rbp)
setbe %al
movb %al, -0x9e(%rbp)
movb -0x9e(%rbp), %al
movb %al, -0x9d(%rbp)
movb -0x9d(%rbp), %al
testb $0x1, %al
jne 0x46828
jmp 0x4682a
jmp 0x46849
leaq 0x1f7ba(%rip), %rdi     # 0x65feb
leaq 0x1f6d0(%rip), %rsi     # 0x65f08
movl $0x49, %edx
leaq 0x1f6de(%rip), %rcx     # 0x65f22
callq 0xd1c0
jmp 0x4684b
movq -0x50(%rbp), %rsi
movl -0x48(%rbp), %edx
leaq -0x68(%rbp), %rdi
callq 0x42170
jmp 0x4685d
movq -0x80(%rbp), %rdi
callq 0x42220
movq %rax, %rdi
movslq -0x54(%rbp), %rsi
callq 0x42240
movq %rax, %rdi
leaq -0x68(%rbp), %rsi
callq 0x42270
leaq -0x68(%rbp), %rdi
callq 0x34860
movl -0x58(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x4669d
movb $0x1, -0x21(%rbp)
testb $0x1, -0x21(%rbp)
jne 0x468b4
movq -0x80(%rbp), %rdi
callq 0x40b20
movq -0x78(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0xd5a0
nopw (%rax,%rax)