// File: /workspace/github_cpp_makefile_star2_O2/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 0x297d
movq %rsi, %r15
testq %rsi, %rsi
je 0x2986
movq %rdx, %r12
testq %rdx, %rdx
je 0x298f
movb $0x1, %r14b
cmpl $0x6, (%r15)
jne 0x28c4
movq %rdi, %rbx
movq 0x8(%r15), %rsi
movq %r12, %rdx
callq 0x25bc
testb %al, %al
je 0x2882
leaq 0x1bd5(%rip), %rdi      # 0x4449
leaq 0x1e88(%rip), %rsi      # 0x4703
movl $0x2d8, %edx            # imm = 0x2D8
jmp 0x28a8
movq 0x10(%r15), %rsi
movq %rbx, %rdi
movq %r12, %rdx
callq 0x25bc
testb %al, %al
je 0x28d4
leaq 0x1bad(%rip), %rdi      # 0x4449
leaq 0x1e60(%rip), %rsi      # 0x4703
movl $0x2d9, %edx            # imm = 0x2D9
xorl %eax, %eax
callq 0x1040
movq 0x18(%r15), %rdx
leaq 0x1bb4(%rip), %rdi      # 0x446e
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 0x28e6
leaq 0x1e50(%rip), %rsi      # 0x4732
pushq $0x2
jmp 0x28fc
cmpb $0x8, %al
jne 0x28f3
leaq 0x1e44(%rip), %rsi      # 0x4735
jmp 0x28fa
leaq 0x1e3f(%rip), %rsi      # 0x4739
pushq $0x3
popq %rdx
movq %rbx, %rdi
callq 0x1504
movq 0x18(%r15), %rax
movb (%rax), %al
addb $-0x2a, %al
cmpb $0x5, %al
ja 0x28c4
movzbl %al, %eax
pushq $0x2b
popq %rcx
btl %eax, %ecx
jae 0x28c4
leaq 0x1765(%rip), %rcx      # 0x4088
movslq (%rcx,%rax,4), %rsi
addq %rcx, %rsi
pushq $0x1
popq %r14
movq %rbx, %rdi
movq %r14, %rdx
callq 0x1504
movsbl 0x60(%rbx), %edi
leal -0x2(%rdi), %eax
movw $0x8, %si
cwtd
idivw %si
movl %edx, %ecx
leal -0x1(%rdi), %r8d
movl %edi, %eax
decl %eax
cwtd
shlb $0x3, %cl
idivw %si
addb %cl, %dl
addb $-0x40, %dl
leaq -0x21(%rbp), %rsi
movb %dl, (%rsi)
movb %r8b, 0x60(%rbx)
movq %rbx, %rdi
movq %r14, %rdx
callq 0x1504
xorl %r14d, %r14d
jmp 0x28c4
leaq 0x1962(%rip), %rdi      # 0x42e6
jmp 0x2996
leaq 0x1a98(%rip), %rdi      # 0x4425
jmp 0x2996
leaq 0x1afb(%rip), %rdi      # 0x4491
leaq 0x1703(%rip), %rsi      # 0x40a0
leaq 0x1d5f(%rip), %rcx      # 0x4703
movl $0x2d3, %edx            # imm = 0x2D3
callq 0x1080