// File: /workspace/github_c_makefile_star2_O1/lh3[P]bgt/kexpr.c
// Function: ke_eval
int ke_eval(const kexpr_t *ke, int64_t *_i, double *_r, const char **_p, int *ret_type)
{
	ke1_t *stack, *p, *q;
	int i, top = 0, err = 0;
	*_i = 0, *_r = 0., *ret_type = 0;
	for (i = 0; i < ke->n; ++i) {
		ke1_t *e = &ke->e[i];
		if ((e->ttype == KET_OP || e->ttype == KET_FUNC) && e->f.builtin == 0) err |= KEE_UNFUNC;
		else if (e->ttype == KET_VAL && e->name && e->assigned == 0) err |= KEE_UNVAR;
	}
	stack = (ke1_t*)malloc(ke->n * sizeof(ke1_t));
	for (i = 0; i < ke->n; ++i) {
		ke1_t *e = &ke->e[i];
		if (e->ttype == KET_OP || e->ttype == KET_FUNC) {
			if (e->n_args == 2 && e->f.builtin) {
				q = &stack[--top], p = &stack[top-1];
				if (e->user_func) {
					if (e->user_func == KEF_REAL)
						p->r = e->f.real_func2(p->r, q->r), p->i = (int64_t)(p->r + .5), p->vtype = KEV_REAL;
				} else e->f.builtin(p, q);
			} else if (e->n_args == 1 && e->f.builtin) {
				p = &stack[top-1];
				if (e->user_func) {
					if (e->user_func == KEF_REAL)
						p->r = e->f.real_func1(p->r), p->i = (int64_t)(p->r + .5), p->vtype = KEV_REAL;
				} else e->f.builtin(&stack[top-1], 0);
			} else top -= e->n_args - 1;
		} else stack[top++] = *e;
	}
	*ret_type = stack->vtype;
	*_i = stack->i, *_r = stack->r, *_p = stack->s;
	free(stack);
	return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, 0x20(%rsp)
movq %rdi, %r9
xorl %r13d, %r13d
movq %rsi, 0x8(%rsp)
movq %r13, (%rsi)
movq %rdx, 0x18(%rsp)
movq %r13, (%rdx)
movq %r8, 0x10(%rsp)
movl $0x0, (%r8)
movslq (%rdi), %rax
testq %rax, %rax
jle 0x1cbab
movq 0x8(%r9), %rcx
movq %rax, %rdx
shlq $0x4, %rdx
leaq (%rdx,%rdx,2), %rdx
xorl %esi, %esi
xorl %r13d, %r13d
movq (%rcx,%rsi), %rdi
movl %edi, %r8d
andl $0xfffe, %r8d           # imm = 0xFFFE
cmpl $0x2, %r8d
jne 0x1cb7a
cmpq $0x0, 0x10(%rcx,%rsi)
je 0x1cb9e
cmpw $0x1, %di
jne 0x1cba2
movl %r13d, %r8d
orl $0x80, %r8d
cmpq $0x0, 0x8(%rcx,%rsi)
cmovel %r13d, %r8d
btl $0x1a, %edi
cmovael %r8d, %r13d
jmp 0x1cba2
orl $0x40, %r13d
addq $0x30, %rsi
cmpq %rsi, %rdx
jne 0x1cb5e
shlq $0x4, %rax
leaq (%rax,%rax,2), %rdi
movq %r9, (%rsp)
callq 0x22e0
movq (%rsp), %rdi
movq %rax, %rbx
cmpl $0x0, (%rdi)
jle 0x1ce1c
xorl %r14d, %r14d
movl $0x10, %r15d
movabsq $-0x10000000000, %r8    # imm = 0xFFFFFF0000000000
movabsq $0x10000000000, %r9     # imm = 0x10000000000
movabsq $0x20000000000, %r10    # imm = 0x20000000000
xorl %r12d, %r12d
movq 0x8(%rdi), %rdx
movq -0x10(%rdx,%r15), %rax
movl %eax, %ecx
andl $0xfffe, %ecx           # imm = 0xFFFE
cmpl $0x2, %ecx
jne 0x1cc8b
movq %rax, %rsi
andq %r8, %rsi
cmpq %r9, %rsi
je 0x1ccc3
cmpq %r10, %rsi
jne 0x1cd0e
movq (%rdx,%r15), %rcx
testq %rcx, %rcx
je 0x1ccbe
leal -0x1(%r12), %ebp
movslq %ebp, %rdx
leaq (%rdx,%rdx,2), %rsi
shlq $0x4, %rsi
addq %rbx, %rsi
movslq %r12d, %rdx
leaq (%rdx,%rdx,2), %r12
shlq $0x4, %r12
cmpl $0x8000000, %eax        # imm = 0x8000000
jae 0x1cda1
leaq (%rbx,%r12), %rdi
addq $-0x60, %rdi
callq *%rcx
movabsq $0x20000000000, %r10    # imm = 0x20000000000
movabsq $0x10000000000, %r9     # imm = 0x10000000000
movabsq $-0x10000000000, %r8    # imm = 0xFFFFFF0000000000
movq (%rsp), %rdi
jmp 0x1cd1b
leaq (%rdx,%r15), %rax
addq $-0x10, %rax
movslq %r12d, %rcx
incl %r12d
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movupd (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups 0x20(%rax), %xmm2
movups %xmm2, 0x20(%rbx,%rcx)
movups %xmm1, 0x10(%rbx,%rcx)
movupd %xmm0, (%rbx,%rcx)
jmp 0x1cd18
cmpq %r9, %rsi
jne 0x1cd0e
movq (%rdx,%r15), %rcx
testq %rcx, %rcx
je 0x1cd0e
movslq %r12d, %rdx
leaq (%rdx,%rdx,2), %rbp
shlq $0x4, %rbp
cmpl $0x8000000, %eax        # imm = 0x8000000
jae 0x1cd36
leaq (%rbx,%rbp), %rdi
addq $-0x30, %rdi
xorl %esi, %esi
callq *%rcx
movabsq $0x20000000000, %r10    # imm = 0x20000000000
movabsq $0x10000000000, %r9     # imm = 0x10000000000
movabsq $-0x10000000000, %r8    # imm = 0xFFFFFF0000000000
movq (%rsp), %rdi
jmp 0x1cd18
sarq $0x28, %rax
subl %eax, %r12d
incl %r12d
movl %r12d, %ebp
incq %r14
movslq (%rdi), %rax
addq $0x30, %r15
movl %ebp, %r12d
cmpq %rax, %r14
jl 0x1cbf6
jmp 0x1ce1c
andl $0xf8000000, %eax       # imm = 0xF8000000
cmpl $0x8000000, %eax        # imm = 0x8000000
jne 0x1cd18
addq %rbx, %rbp
movsd -0x18(%rbp), %xmm0
callq *%rcx
movabsq $0x20000000000, %r10    # imm = 0x20000000000
movabsq $0x10000000000, %r9     # imm = 0x10000000000
movabsq $-0x10000000000, %r8    # imm = 0xFFFFFF0000000000
movq (%rsp), %rdi
movsd %xmm0, -0x18(%rbp)
addsd 0x20ed(%rip), %xmm0     # 0x1ee68
cvttsd2si %xmm0, %rax
movq %rax, -0x10(%rbp)
movq -0x30(%rbp), %rax
movq $-0x3ff0001, %rcx       # imm = 0xFC00FFFF
andq %rcx, %rax
orq $0x10000, %rax          # imm = 0x10000
movq %rax, -0x30(%rbp)
jmp 0x1cd18
andl $0xf8000000, %eax       # imm = 0xF8000000
cmpl $0x8000000, %eax        # imm = 0x8000000
jne 0x1cd1b
addq %rbx, %r12
movsd -0x48(%r12), %xmm0
movsd 0x18(%rsi), %xmm1
callq *%rcx
movabsq $0x20000000000, %r10    # imm = 0x20000000000
movabsq $0x10000000000, %r9     # imm = 0x10000000000
movabsq $-0x10000000000, %r8    # imm = 0xFFFFFF0000000000
movq (%rsp), %rdi
movsd %xmm0, -0x48(%r12)
addsd 0x2075(%rip), %xmm0     # 0x1ee68
cvttsd2si %xmm0, %rax
movq %rax, -0x40(%r12)
movq -0x60(%r12), %rax
movq $-0x3ff0001, %rcx       # imm = 0xFC00FFFF
andq %rcx, %rax
orq $0x10000, %rax          # imm = 0x10000
movq %rax, -0x60(%r12)
jmp 0x1cd1b
movzwl 0x2(%rbx), %eax
andl $0x3ff, %eax            # imm = 0x3FF
movq 0x10(%rsp), %rcx
movl %eax, (%rcx)
movq 0x20(%rbx), %rax
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
movsd 0x18(%rbx), %xmm0
movq 0x18(%rsp), %rax
movsd %xmm0, (%rax)
movq 0x28(%rbx), %rax
movq 0x20(%rsp), %rcx
movq %rax, (%rcx)
movq %rbx, %rdi
callq 0x2050
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq