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

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

    TryPrint (PrintArith, left);
    TryPrint (PrintArith, right);

    // arithm_op xmm(№-1), xmm№
    // arithm_op = {addsd, subsd, mulsd, divsd} 

    if (elf->xmm_counter < 8)
        ElfAddBytes (elf, "\xF2\x0F", 2); // arithm_op xmm[0..6], xmm[1..7]
    else if (elf->xmm_counter == 8)
        ElfAddBytes (elf, "\xF2\x41\x0F", 3); // arithm_op xmm7, xmm8
    else
        ElfAddBytes (elf, "\xF2\x45\x0F", 3); // arithm_op xmm[8..14], xmm[9..15]

    switch (el->ind[0])
    {
        case '+':
            ElfAddBytes (elf, "\x58", 1); // arithm_op = addsd
            break;
        case '-':
            ElfAddBytes (elf, "\x5C", 1); // arithm_op = subsd
            break;
        case '*':
            ElfAddBytes (elf, "\x59", 1); // arithm_op = mulsd
            break;
        case '/':
            ElfAddBytes (elf, "\x5E", 1); // arithm_op = divsd
            break;
        // case '^': // ToDo: Deleted operator
            // fprintf (asm_text, "pow\n");
            // return 0;
        default:
            return 1;
    }

    char num_registers = ((elf->xmm_counter - 2) % 8) * 8 + (elf->xmm_counter - 1) % 8 + 0xC0;
    elf->xmm_counter -= 1;
    ElfAddBytes (elf, &num_registers, 1);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
testq %rdi, %rdi
je 0x2bb4
movq %rsi, %r15
testq %rsi, %rsi
je 0x2bbd
movq %rdx, %r12
testq %rdx, %rdx
je 0x2bc6
movb $0x1, %r14b
cmpl $0x6, (%r15)
jne 0x2ae0
movq %rdi, %rbx
movq 0x8(%r15), %rsi
movq %r12, %rdx
callq 0x27c6
testb %al, %al
je 0x2a9e
leaq 0x29e1(%rip), %rdi      # 0x5471
leaq 0x2c94(%rip), %rsi      # 0x572b
movl $0x2d8, %edx            # imm = 0x2D8
jmp 0x2ac4
movq 0x10(%r15), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0x27c6
testb %al, %al
je 0x2af0
leaq 0x29b9(%rip), %rdi      # 0x5471
leaq 0x2c6c(%rip), %rsi      # 0x572b
movl $0x2d9, %edx            # imm = 0x2D9
xorl %eax, %eax
callq 0x1040
movq 0x18(%r15), %rdx
leaq 0x29c0(%rip), %rdi      # 0x5496
movq %r15, %rsi
xorl %eax, %eax
callq 0x1040
movl %r14d, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movb 0x60(%rbx), %al
cmpb $0x7, %al
jg 0x2b05
leaq 0x2c5c(%rip), %rsi      # 0x575a
movl $0x2, %edx
jmp 0x2b1e
cmpb $0x8, %al
jne 0x2b12
leaq 0x2c4d(%rip), %rsi      # 0x575d
jmp 0x2b19
leaq 0x2c48(%rip), %rsi      # 0x5761
movl $0x3, %edx
movq %rbx, %rdi
callq 0x15a4
movq 0x18(%r15), %rax
movb (%rax), %al
addb $-0x2a, %al
cmpb $0x5, %al
ja 0x2ae0
movzbl %al, %eax
movl $0x2b, %ecx
btl %eax, %ecx
jae 0x2ae0
leaq 0x256a(%rip), %rcx      # 0x50b0
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
movl $0x1, %edx
movq %rbx, %rdi
callq 0x15a4
movsbl 0x60(%rbx), %eax
leal -0x2(%rax), %ecx
leal 0x5(%rax), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
andl $0x18, %edx
negl %edx
leal (%rax,%rdx), %ecx
addl $-0x2, %ecx
leal -0x1(%rax), %edx
movl %eax, %esi
addl $0x6, %esi
testl %edx, %edx
cmovnsl %edx, %esi
andl $0xf8, %esi
negl %esi
leal (%rax,%rsi), %edx
decl %edx
leal (%rdx,%rcx,8), %ecx
addb $-0x40, %cl
leaq -0x21(%rbp), %rsi
movb %cl, (%rsi)
decl %eax
movb %al, 0x60(%rbx)
movl $0x1, %edx
movq %rbx, %rdi
callq 0x15a4
xorl %r14d, %r14d
jmp 0x2ae0
leaq 0x2753(%rip), %rdi      # 0x530e
jmp 0x2bcd
leaq 0x2889(%rip), %rdi      # 0x544d
jmp 0x2bcd
leaq 0x28ec(%rip), %rdi      # 0x54b9
leaq 0x24f4(%rip), %rsi      # 0x50c8
leaq 0x2b50(%rip), %rcx      # 0x572b
movl $0x2d3, %edx            # imm = 0x2D3
callq 0x1090