// File: /workspace/github_c_makefile_star2_O0/vtereshkov[P]umka-lang/src/umka_expr.c
// Function: doExplicitTypeConv
void doExplicitTypeConv(Compiler *comp, const Type *dest, const Type **src, Const *constant)
{
    doImplicitTypeConv(comp, dest, src, constant);

    // Type to same type (up to the type identifier)
    if (typeSameExceptMaybeIdent(dest, *src))
    {
        *src = dest;
    }

    // Ordinal to ordinal or real to real
    else if ((typeOrdinal(*src) && typeOrdinal(dest)) || (typeReal(*src) && typeReal(dest)))
    {
        doOrdinalToOrdinalOrRealToRealConv(comp, dest, src, constant);
    }

    // Pointer to pointer
    else if (dest->kind == TYPE_PTR && (*src)->kind == TYPE_PTR && typeExplicitlyConvertibleBaseTypes(&comp->types, dest->base, (*src)->base))
    {
        *src = dest;
    }

    // Interface to concrete (type assertion)
    else if ((*src)->kind == TYPE_INTERFACE && dest->kind != TYPE_INTERFACE)
    {
        if (dest->kind == TYPE_PTR)
        {
            // Interface to pointer
            doInterfaceToPtrConv(comp, dest, src, constant);
        }
        else
        {
            // Interface to value
            doInterfaceToValueConv(comp, dest, src, constant);
        }
    }

    // Dynamic array to string
    else if ((*src)->kind == TYPE_DYNARRAY && (*src)->base->kind == TYPE_UINT8 && dest->kind == TYPE_STR)
    {
        doDynArrayToStrConv(comp, dest, src, constant, false);
    }

    // String to dynamic array
    else if ((*src)->kind == TYPE_STR && dest->kind == TYPE_DYNARRAY && dest->base->kind == TYPE_UINT8)
    {
        doStrToDynArrayConv(comp, dest, src, constant);
    }

    // Dynamic array to dynamic array of another base type (covariant arrays)
    else if ((*src)->kind == TYPE_DYNARRAY && dest->kind == TYPE_DYNARRAY)
    {
        doDynArrayToDynArrayConv(comp, dest, src, constant);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0xd190
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rsi
callq 0x22760
testb $0x1, %al
jne 0xd773
jmp 0xd783
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0xd928
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0xcf60
testb $0x1, %al
jne 0xd795
jmp 0xd7a2
movq -0x10(%rbp), %rdi
callq 0xcf60
testb $0x1, %al
jne 0xd7c3
movq -0x18(%rbp), %rax
movq (%rax), %rdi
callq 0xcf80
testb $0x1, %al
jne 0xd7b4
jmp 0xd7dd
movq -0x10(%rbp), %rdi
callq 0xcf80
testb $0x1, %al
jne 0xd7c3
jmp 0xd7dd
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0xd930
jmp 0xd926
movq -0x10(%rbp), %rax
cmpl $0x10, (%rax)
jne 0xd82b
movq -0x18(%rbp), %rax
movq (%rax), %rax
cmpl $0x10, (%rax)
jne 0xd82b
movq -0x8(%rbp), %rdi
addq $0x4e18, %rdi           # imm = 0x4E18
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rdx
callq 0xd9e0
testb $0x1, %al
jne 0xd81b
jmp 0xd82b
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
jmp 0xd924
movq -0x18(%rbp), %rax
movq (%rax), %rax
cmpl $0x17, (%rax)
jne 0xd87a
movq -0x10(%rbp), %rax
cmpl $0x17, (%rax)
je 0xd87a
movq -0x10(%rbp), %rax
cmpl $0x10, (%rax)
jne 0xd860
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0xda60
jmp 0xd875
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0xdad0
jmp 0xd922
movq -0x18(%rbp), %rax
movq (%rax), %rax
cmpl $0x13, (%rax)
jne 0xd8b9
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
cmpl $0x8, (%rax)
jne 0xd8b9
movq -0x10(%rbp), %rax
cmpl $0x14, (%rax)
jne 0xd8b9
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
xorl %r8d, %r8d
callq 0xdb70
jmp 0xd920
movq -0x18(%rbp), %rax
movq (%rax), %rax
cmpl $0x14, (%rax)
jne 0xd8f2
movq -0x10(%rbp), %rax
cmpl $0x13, (%rax)
jne 0xd8f2
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x8, (%rax)
jne 0xd8f2
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0xdc20
jmp 0xd91e
movq -0x18(%rbp), %rax
movq (%rax), %rax
cmpl $0x13, (%rax)
jne 0xd91c
movq -0x10(%rbp), %rax
cmpl $0x13, (%rax)
jne 0xd91c
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
callq 0xdd10
jmp 0xd91e
jmp 0xd920
jmp 0xd922
jmp 0xd924
jmp 0xd926
jmp 0xd928
addq $0x20, %rsp
popq %rbp
retq
nop