// File: /workspace/github_c_makefile_star2_O0/vtereshkov[P]umka-lang/src/umka_const.c
// Function: constCallBuiltin
void constCallBuiltin(const Consts *consts, Const *arg, const Const *arg2, TypeKind argTypeKind, BuiltinFunc builtinVal)
{
    switch (builtinVal)
    {
        case BUILTIN_REAL:
        case BUILTIN_REAL_LHS:
        {
            if (argTypeKind == TYPE_UINT)
                arg->realVal = arg->uintVal;
            else
                arg->realVal = arg->intVal;
            break;
        }
        case BUILTIN_ROUND:     arg->intVal  = (int64_t)round(arg->realVal); break;
        case BUILTIN_TRUNC:     arg->intVal  = (int64_t)trunc(arg->realVal); break;
        case BUILTIN_CEIL:      arg->intVal  = (int64_t)ceil (arg->realVal); break;
        case BUILTIN_FLOOR:     arg->intVal  = (int64_t)floor(arg->realVal); break;
        case BUILTIN_ABS:
        {
            if (arg->intVal == LLONG_MIN)
                consts->error->handler(consts->error->context, "abs() domain error");
            arg->intVal = llabs(arg->intVal);
            break;
        }
        case BUILTIN_FABS:      arg->realVal = fabs(arg->realVal); break;
        case BUILTIN_SQRT:
        {
            if (arg->realVal < 0)
                consts->error->handler(consts->error->context, "sqrt() domain error");
            arg->realVal = sqrt(arg->realVal);
            break;
        }
        case BUILTIN_SIN:       arg->realVal = sin (arg->realVal); break;
        case BUILTIN_COS:       arg->realVal = cos (arg->realVal); break;
        case BUILTIN_ATAN:      arg->realVal = atan(arg->realVal); break;
        case BUILTIN_ATAN2:
        {
            if (arg->realVal == 0 || arg2->realVal == 0)
                consts->error->handler(consts->error->context, "atan2() domain error");
            arg->realVal = atan2(arg->realVal, arg2->realVal);
            break;
        }
        case BUILTIN_EXP:       arg->realVal = exp (arg->realVal); break;
        case BUILTIN_LOG:
        {
            if (arg->realVal <= 0)
                consts->error->handler(consts->error->context, "log() domain error");
            arg->realVal = log(arg->realVal);
            break;
        }
        case BUILTIN_LEN:       arg->intVal  = strlen((char *)arg->ptrVal); break;

        default: consts->error->handler(consts->error->context, "Illegal function");
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movl -0x20(%rbp), %eax
addl $-0x6, %eax
movl %eax, %ecx
movq %rcx, -0x28(%rbp)
subl $0x1c, %eax
ja 0x967e
movq -0x28(%rbp), %rax
leaq 0x1cead9(%rip), %rcx    # 0x1d7ea4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0xb, -0x1c(%rbp)
jne 0x940e
movq -0x10(%rbp), %rax
movq (%rax), %xmm0
movaps 0x1ceba7(%rip), %xmm1   # 0x1d7f90
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x1cebab(%rip), %xmm1   # 0x1d7fa0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x941f
movq -0x10(%rbp), %rax
cvtsi2sdq (%rax), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x969e
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
callq 0x3070
cvttsd2si %xmm0, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x969e
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
callq 0x30b0
cvttsd2si %xmm0, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x969e
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
callq 0x33b0
cvttsd2si %xmm0, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x969e
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
callq 0x3360
cvttsd2si %xmm0, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x969e
movq -0x10(%rbp), %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
cmpq %rcx, (%rax)
jne 0x94cf
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rdi
leaq 0x1ceb71(%rip), %rsi    # 0x1d803c
movb $0x0, %al
callq *%rcx
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq %rcx, %rax
negq %rax
cmovnsq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x969e
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
movaps 0x1cea85(%rip), %xmm1   # 0x1d7f80
pand %xmm1, %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x969e
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x9539
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rdi
leaq 0x1ceb1a(%rip), %rsi    # 0x1d804f
movb $0x0, %al
callq *%rcx
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
callq 0x33a0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x969e
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
callq 0x3350
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x969e
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
callq 0x31f0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x969e
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
callq 0x30f0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x969e
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x95b6
jp 0x95b6
jmp 0x95c9
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x95e9
jp 0x95e9
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rdi
leaq 0x1cea7e(%rip), %rsi    # 0x1d8063
movb $0x0, %al
callq *%rcx
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
movq -0x18(%rbp), %rax
movsd (%rax), %xmm1
callq 0x32e0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x969e
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
callq 0x33c0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x969e
movq -0x10(%rbp), %rax
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jb 0x964f
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rdi
leaq 0x1cea2d(%rip), %rsi    # 0x1d8078
movb $0x0, %al
callq *%rcx
movq -0x10(%rbp), %rax
movsd (%rax), %xmm0
callq 0x31d0
movq -0x10(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x969e
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x3120
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
jmp 0x969e
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq 0x20(%rax), %rdi
leaq 0x1ce9f1(%rip), %rsi    # 0x1d808b
movb $0x0, %al
callq *%rcx
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)