// File: /workspace/github_c_makefile_star2_O0/vtereshkov[P]umka-lang/src/umka_expr.c
// Function: doApplyOperator
void doApplyOperator(Compiler *comp, const Type **type, const Type **rightType, Const *constant, Const *rightConstant, TokenKind op, bool apply, bool convertLhs)
{
    // First, the right-hand side type is converted to the left-hand side type
    doImplicitTypeConvEx(comp, *type, rightType, rightConstant, false, true);

    // Second, the left-hand side type is converted to the right-hand side type for symmetric operators
    if (convertLhs)
        doImplicitTypeConvEx(comp, *rightType, type, constant, true, false);

    typeAssertCompatible(&comp->types, *type, *rightType);
    typeAssertValidOperator(&comp->types, *type, op);

    if (apply)
    {
        if ((*type)->kind == TYPE_STR && (op == TOK_PLUS || op == TOK_PLUSEQ))
            doApplyStrCat(comp, constant, rightConstant, op);
        else
        {
            if (constant)
                constBinary(&comp->consts, constant, rightConstant, op, (*type)->kind);
            else
                genBinary(&comp->gen, op, (*type)->kind, typeSize(&comp->types, *type));
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rcx, -0x48(%rbp)
movq %rdx, %rax
movq -0x48(%rbp), %rdx
movq %rax, -0x40(%rbp)
movq %rsi, %rax
movq -0x40(%rbp), %rsi
movq %rax, -0x38(%rbp)
movq %rdi, %r10
movq -0x38(%rbp), %rdi
movb 0x18(%rbp), %al
movb 0x10(%rbp), %cl
movq %r10, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
andb $0x1, %cl
movb %cl, -0x2d(%rbp)
andb $0x1, %al
movb %al, -0x2e(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rdx
movq -0x28(%rbp), %rcx
xorl %r8d, %r8d
movl $0x1, %r9d
callq 0xd1d0
testb $0x1, -0x2e(%rbp)
je 0xe26a
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
movq -0x10(%rbp), %rdx
movq -0x20(%rbp), %rcx
movl $0x1, %r8d
xorl %r9d, %r9d
callq 0xd1d0
movq -0x8(%rbp), %rdi
addq $0x4e18, %rdi           # imm = 0x4E18
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
callq 0x22870
movq -0x8(%rbp), %rdi
addq $0x4e18, %rdi           # imm = 0x4E18
movq -0x10(%rbp), %rax
movq (%rax), %rsi
movl -0x2c(%rbp), %edx
callq 0x22db0
testb $0x1, -0x2d(%rbp)
je 0xe354
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpl $0x14, (%rax)
jne 0xe2da
cmpl $0x16, -0x2c(%rbp)
je 0xe2c4
cmpl $0x20, -0x2c(%rbp)
jne 0xe2da
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl -0x2c(%rbp), %ecx
callq 0xe360
jmp 0xe352
cmpq $0x0, -0x20(%rbp)
je 0xe308
movq -0x8(%rbp), %rdi
addq $0x4e68, %rdi           # imm = 0x4E68
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %r8d
callq 0x8c30
jmp 0xe350
movq -0x8(%rbp), %rax
addq $0x4e70, %rax           # imm = 0x4E70
movq %rax, -0x58(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
movq -0x8(%rbp), %rdi
addq $0x4e18, %rdi           # imm = 0x4E18
movq -0x10(%rbp), %rax
movq (%rax), %rsi
callq 0x21fe0
movq -0x58(%rbp), %rdi
movl -0x50(%rbp), %esi
movl -0x4c(%rbp), %edx
movl %eax, %ecx
callq 0x17790
jmp 0xe352
jmp 0xe354
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)