// File: /workspace/github_cpp_makefile_star2_O1/vsklad[P]cgen/./bal/encoding/literal.hpp
// Function: bal::Ref<bal::Literal<bal::Anf>> bal::maj<bal::Anf>(bal::Literal<bal::Anf>*, bal::Literal<bal::Anf>*, bal::Literal<bal::Anf>*, bal::Literal<bal::Anf>*)
Ref<Literal<FORMULA_T>> maj(Literal<FORMULA_T>* const r,
                                Literal<FORMULA_T>* const x, Literal<FORMULA_T>* const y, Literal<FORMULA_T>* const z) {
        if (literal_t__is_constant_0(x->value)) {
            return con2(r, y, z);
        } else if (literal_t__is_constant_0(y->value)) {
            return con2(r, x, z);
        } else if (literal_t__is_constant_0(z->value)) {
            return con2(r, x, y);
        } else if (literal_t__is_constant_1(x->value)) {
            return dis2(r, y, z);
        } else if (literal_t__is_constant_1(y->value)) {
            return dis2(r, x, z);
        } else if (literal_t__is_constant_1(z->value)) {
            return dis2(r, x, y);
        } else if (x->value == y->value || x->value == z->value) {
            return x;
        } else if (y->value == z->value) {
            return y;
        } else {
            _assert_level_1(x->formula != nullptr && x->formula == y->formula && x->formula == z->formula);
            const literalid_t r_value = x->formula->new_variable_literal();
            maj(x->formula, r_value, x->value, y->value, z->value);
            return new Literal<FORMULA_T>(x->formula, r_value);
        };
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %r12
movq %rcx, %r15
movq %rdi, %rbx
movl 0x20(%rdx), %ecx
testl %ecx, %ecx
je 0x31550
movq %rdx, %r14
movl 0x20(%r15), %eax
testl %eax, %eax
je 0x31558
movl 0x20(%r12), %edx
testl %edx, %edx
je 0x31568
cmpl $0x1, %ecx
jne 0x31573
movq %rbx, %rdi
movq %r15, %rdx
jmp 0x3157e
movq %rbx, %rdi
movq %r15, %rdx
jmp 0x3155e
movq %rbx, %rdi
movq %r14, %rdx
movq %r12, %rcx
callq 0x311cc
jmp 0x31586
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
jmp 0x31561
cmpl $0x1, %eax
jne 0x31598
movq %rbx, %rdi
movq %r14, %rdx
movq %r12, %rcx
callq 0x312d8
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x1, %edx
jne 0x315a8
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
jmp 0x31581
cmpl %eax, %ecx
setne %sil
cmpl %edx, %ecx
setne %cl
testb %cl, %sil
jne 0x315ce
movq %r14, (%rbx)
testq %r14, %r14
je 0x31586
movq (%r14), %rax
movq -0x20(%rax), %rax
incl 0x8(%r14,%rax)
jmp 0x31586
cmpl %edx, %eax
jne 0x315dc
movq %r15, (%rbx)
testq %r15, %r15
jne 0x31632
jmp 0x31586
movq 0x18(%r14), %rdi
testq %rdi, %rdi
je 0x31643
cmpq 0x18(%r15), %rdi
jne 0x31643
cmpq 0x18(%r12), %rdi
jne 0x31643
movq (%rdi), %rax
callq *0x8(%rax)
movl %eax, %r13d
movq 0x18(%r14), %rdi
movl 0x20(%r14), %edx
movl 0x20(%r15), %ecx
movl 0x20(%r12), %r8d
movl %eax, %esi
callq 0xff65
movl $0x40, %edi
callq 0xc2c0
movq %rax, %r15
movq 0x18(%r14), %rsi
movq %rax, %rdi
movl %r13d, %edx
callq 0x301b2
movq %r15, (%rbx)
movq (%r15), %rax
movq -0x20(%rax), %rax
incl 0x8(%r15,%rax)
jmp 0x31586
leaq 0x19ef4(%rip), %rdi     # 0x4b53e
leaq 0x187b6(%rip), %rsi     # 0x49e07
leaq 0x1a191(%rip), %rcx     # 0x4b7e9
movl $0x13a, %edx            # imm = 0x13A
callq 0xc180