// File: /workspace/github_cpp_makefile_star2_O2/AndreyVV-100[P]GachiLang/Backend/Backend.cpp
// Function: PrintComp(Elf*, element*, Stack*)
bool PrintComp  (Elf* elf, element* el, Stack* vars)
{
    print_ass;

    if (el->type != COND)
        return 1;

    TryPrint (PrintArith, left);
    ElfAddBytes (elf, "\x66\x48\x0F\x7E\xC2", 5); // movq rdx, xmm0

    elf->xmm_counter = 0;
    TryPrint (PrintArith, right);
    ElfAddBytes (elf, "\x66\x48\x0F\x6E\xCA", 5); // movq xmm1, rdx

    switch (el->len)
    {
        case 1:
        {
            switch (el->ind[0])
            {
                case '>':
                    ElfAddBytes (elf, "\xC5\xF3\xC2\xD0\x02", 5); // vcmpsd xmm2, xmm1, xmm0, 2
                    break;

                case '<':
                    ElfAddBytes (elf, "\xC5\xF3\xC2\xD0\x0D", 5); // vcmpsd xmm2, xmm1, xmm0, 0x0D
                    break;

                default:
                    return 1;
            }
            break;
        }

        case 2:
        {
            switch (el->ind[0])
            {
                case '>':
                    ElfAddBytes (elf, "\xC5\xF3\xC2\xD0\x01", 5); // vcmpsd xmm2, xmm1, xmm0, 1
                    break;

                case '<':
                    ElfAddBytes (elf, "\xC5\xF3\xC2\xD0\x0E", 5); // vcmpsd xmm2, xmm1, xmm0, 0x0E
                    break;

                case '!':
                    ElfAddBytes (elf, "\xC5\xF3\xC2\xD0\x00", 5); // vcmpsd xmm2, xmm1, xmm0, 0
                    break;

                case '=':
                    ElfAddBytes (elf, "\xC5\xF3\xC2\xD0\x04", 5); // vcmpsd xmm2, xmm1, xmm0, 4
                    break;

                default:
                    return 1;
            }
            break;
        }

        default:
            return 1;
    }

    ElfAddBytes (elf, "\x66\x48\x0F\x7E\xD0"        // movq rax, xmm2
                      "\x48\x83\xF8\x00"            // cmp rax, 0
                      "\x0F\x85\x00\x00\x00\x00",   // jne 00 00 00 00 (will be patched)
                      15);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rdi, %rdi
je 0x2ecb
movq %rsi, %r15
testq %rsi, %rsi
je 0x2ed4
movq %rdx, %r12
testq %rdx, %rdx
je 0x2edd
movb $0x1, %bl
cmpl $0xf, (%r15)
jne 0x2e1a
movq %rdi, %r14
movq 0x8(%r15), %rsi
movq %r12, %rdx
callq 0x25bc
testb %al, %al
je 0x2dc1
leaq 0x1696(%rip), %rdi      # 0x4449
leaq 0x184f(%rip), %rsi      # 0x4609
movl $0x242, %edx            # imm = 0x242
jmp 0x2dfe
leaq 0x186b(%rip), %rsi      # 0x4633
pushq $0x5
popq %rdx
movq %r14, %rdi
callq 0x1504
movb $0x0, 0x60(%r14)
movq 0x10(%r15), %rsi
movq %r14, %rdi
movq %r12, %rdx
callq 0x25bc
testb %al, %al
je 0x2e25
leaq 0x1657(%rip), %rdi      # 0x4449
leaq 0x1810(%rip), %rsi      # 0x4609
movl $0x246, %edx            # imm = 0x246
xorl %eax, %eax
callq 0x1040
movq 0x18(%r15), %rdx
leaq 0x165e(%rip), %rdi      # 0x446e
movq %r15, %rsi
xorl %eax, %eax
callq 0x1040
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x180d(%rip), %rsi      # 0x4639
pushq $0x5
popq %rdx
movq %r14, %rdi
callq 0x1504
movq 0x20(%r15), %rax
cmpq $0x2, %rax
je 0x2e61
cmpq $0x1, %rax
jne 0x2e1a
movq 0x18(%r15), %rax
movzbl (%rax), %eax
cmpl $0x3e, %eax
je 0x2e85
cmpl $0x3c, %eax
jne 0x2e1a
leaq 0x17e6(%rip), %rsi      # 0x4645
jmp 0x2ea7
movq 0x18(%r15), %rax
movzbl (%rax), %eax
cmpl $0x21, %eax
je 0x2ea0
cmpl $0x3e, %eax
je 0x2e8e
cmpl $0x3d, %eax
je 0x2e97
cmpl $0x3c, %eax
jne 0x2e1a
leaq 0x17ce(%rip), %rsi      # 0x4651
jmp 0x2ea7
leaq 0x17b3(%rip), %rsi      # 0x463f
jmp 0x2ea7
leaq 0x17b6(%rip), %rsi      # 0x464b
jmp 0x2ea7
leaq 0x17b9(%rip), %rsi      # 0x4657
jmp 0x2ea7
leaq 0x11d9(%rip), %rsi      # 0x4080
pushq $0x5
popq %rdx
movq %r14, %rdi
callq 0x1504
leaq 0x1ab7(%rip), %rsi      # 0x4970
pushq $0xf
popq %rdx
movq %r14, %rdi
callq 0x1504
xorl %ebx, %ebx
jmp 0x2e1a
leaq 0x1414(%rip), %rdi      # 0x42e6
jmp 0x2ee4
leaq 0x154a(%rip), %rdi      # 0x4425
jmp 0x2ee4
leaq 0x15ad(%rip), %rdi      # 0x4491
leaq 0x11b5(%rip), %rsi      # 0x40a0
leaq 0x1717(%rip), %rcx      # 0x4609
movl $0x23d, %edx            # imm = 0x23D
callq 0x1080