// File: /workspace/github_cpp_makefile_star2_O3/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 0x2b85
movq %rsi, %r15
testq %rsi, %rsi
je 0x2b8e
movq %rdx, %r12
testq %rdx, %rdx
je 0x2b97
movb $0x1, %r14b
cmpl $0x6, (%r15)
jne 0x2aad
movq %rdi, %rbx
movq 0x8(%r15), %rsi
movq %r12, %rdx
callq 0x278d
testb %al, %al
je 0x2a6b
leaq 0x29ec(%rip), %rdi      # 0x5449
leaq 0x2c9f(%rip), %rsi      # 0x5703
movl $0x2d8, %edx            # imm = 0x2D8
jmp 0x2a91
movq 0x10(%r15), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0x278d
testb %al, %al
je 0x2abd
leaq 0x29c4(%rip), %rdi      # 0x5449
leaq 0x2c77(%rip), %rsi      # 0x5703
movl $0x2d9, %edx            # imm = 0x2D9
xorl %eax, %eax
callq 0x1040
movq 0x18(%r15), %rdx
leaq 0x29cb(%rip), %rdi      # 0x546e
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 0x2ad2
leaq 0x2c67(%rip), %rsi      # 0x5732
movl $0x2, %edx
jmp 0x2aeb
cmpb $0x8, %al
jne 0x2adf
leaq 0x2c58(%rip), %rsi      # 0x5735
jmp 0x2ae6
leaq 0x2c53(%rip), %rsi      # 0x5739
movl $0x3, %edx
movq %rbx, %rdi
callq 0x156a
movq 0x18(%r15), %rax
movb (%rax), %al
addb $-0x2a, %al
cmpb $0x5, %al
ja 0x2aad
movzbl %al, %eax
movl $0x2b, %ecx
btl %eax, %ecx
jae 0x2aad
leaq 0x2575(%rip), %rcx      # 0x5088
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
movl $0x1, %edx
movq %rbx, %rdi
callq 0x156a
movsbl 0x60(%rbx), %eax
leal -0x2(%rax), %ecx
leal 0x5(%rax), %edx
testw %cx, %cx
cmovnsl %ecx, %edx
andl $0x18, %edx
negl %edx
leal (%rax,%rdx), %ecx
addl $-0x2, %ecx
shlb $0x3, %cl
leal -0x1(%rax), %edx
movl %eax, %esi
addl $0x6, %esi
testw %dx, %dx
cmovnsl %edx, %esi
andl $0xf8, %esi
negl %esi
leal (%rax,%rsi), %edx
decl %edx
addb %cl, %dl
addb $-0x40, %dl
leaq -0x21(%rbp), %rsi
movb %dl, (%rsi)
decl %eax
movb %al, 0x60(%rbx)
movl $0x1, %edx
movq %rbx, %rdi
callq 0x156a
xorl %r14d, %r14d
jmp 0x2aad
leaq 0x275a(%rip), %rdi      # 0x52e6
jmp 0x2b9e
leaq 0x2890(%rip), %rdi      # 0x5425
jmp 0x2b9e
leaq 0x28f3(%rip), %rdi      # 0x5491
leaq 0x24fb(%rip), %rsi      # 0x50a0
leaq 0x2b57(%rip), %rcx      # 0x5703
movl $0x2d3, %edx            # imm = 0x2D3
callq 0x1090