// File: /workspace/github_c_makefile_star2_O2/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 %rsi, 0x8(%rsp)
andq $0x0, (%rsi)
movq %rdi, %r13
movq %rdx, 0x18(%rsp)
andq $0x0, (%rdx)
movq %r8, 0x10(%rsp)
andl $0x0, (%r8)
movl (%rdi), %ebp
movslq %ebp, %rax
xorl %ecx, %ecx
testl %eax, %eax
movl $0x0, %edx
cmovgl %eax, %edx
imulq $0x30, %rdx, %rdx
xorl %r9d, %r9d
cmpq %rcx, %rdx
je 0x16004
movq 0x8(%r13), %rdi
movq (%rdi,%rcx), %rsi
movl %esi, %r8d
andl $0xfffe, %r8d           # imm = 0xFFFE
cmpl $0x2, %r8d
jne 0x15fd6
cmpq $0x0, 0x10(%rdi,%rcx)
je 0x15ffa
cmpw $0x1, %si
jne 0x15ffe
movl %r9d, %r8d
orl $0x80, %r8d
cmpq $0x0, 0x8(%rdi,%rcx)
cmovel %r9d, %r8d
btl $0x1a, %esi
cmovael %r8d, %r9d
jmp 0x15ffe
orl $0x40, %r9d
addq $0x30, %rcx
jmp 0x15fb1
movl %r9d, 0x4(%rsp)
imulq $0x30, %rax, %rdi
callq 0x22e0
movq %rax, %rbx
xorl %r14d, %r14d
pushq $0x10
popq %r15
movabsq $-0x10000000000, %rdi   # imm = 0xFFFFFF0000000000
movabsq $0x10000000000, %r8     # imm = 0x10000000000
movabsq $0x20000000000, %r9     # imm = 0x20000000000
xorl %r12d, %r12d
movslq %ebp, %rax
cmpq %rax, %r14
jge 0x16209
movq 0x8(%r13), %rdx
movq -0x10(%rdx,%r15), %rax
movl %eax, %esi
andl $0xfffe, %esi           # imm = 0xFFFE
movslq %r12d, %rcx
cmpl $0x2, %esi
jne 0x160aa
movq %rax, %rsi
andq %rdi, %rsi
cmpq %r8, %rsi
je 0x160d7
cmpq %r9, %rsi
jne 0x1611b
movq (%rdx,%r15), %rdx
testq %rdx, %rdx
je 0x1611b
leal -0x1(%rcx), %r12d
movslq %r12d, %rsi
imulq $0x30, %rsi, %rsi
addq %rbx, %rsi
imulq $0x30, %rcx, %rbp
cmpl $0x8000000, %eax        # imm = 0x8000000
jae 0x16135
leaq (%rbx,%rbp), %rdi
addq $-0x60, %rdi
jmp 0x160f9
leaq (%rdx,%r15), %rax
addq $-0x10, %rax
leal 0x1(%rcx), %r12d
imulq $0x30, %rcx, %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 0x16125
movq (%rdx,%r15), %rdx
testq %rdx, %rdx
je 0x1611b
imulq $0x30, %rcx, %rbp
cmpl $0x8000000, %eax        # imm = 0x8000000
jae 0x1619e
leaq (%rbx,%rbp), %rdi
addq $-0x30, %rdi
xorl %esi, %esi
callq *%rdx
movabsq $0x20000000000, %r9     # imm = 0x20000000000
movabsq $0x10000000000, %r8     # imm = 0x10000000000
movabsq $-0x10000000000, %rdi   # imm = 0xFFFFFF0000000000
jmp 0x16125
sarq $0x28, %rax
subl %eax, %r12d
incl %r12d
incq %r14
movl (%r13), %ebp
addq $0x30, %r15
jmp 0x1603d
andl $0xf8000000, %eax       # imm = 0xF8000000
cmpl $0x8000000, %eax        # imm = 0x8000000
jne 0x16125
addq %rbx, %rbp
movsd -0x48(%rbp), %xmm0
movsd 0x18(%rsi), %xmm1
callq *%rdx
movabsq $0x20000000000, %r9     # imm = 0x20000000000
movabsq $0x10000000000, %r8     # imm = 0x10000000000
movabsq $-0x10000000000, %rdi   # imm = 0xFFFFFF0000000000
movsd %xmm0, -0x48(%rbp)
addsd 0x2cc5(%rip), %xmm0     # 0x18e40
cvttsd2si %xmm0, %rax
movq %rax, -0x40(%rbp)
movq -0x60(%rbp), %rax
movq $-0x3ff0001, %rcx       # imm = 0xFC00FFFF
andq %rcx, %rax
orq $0x10000, %rax          # imm = 0x10000
movq %rax, -0x60(%rbp)
jmp 0x16125
andl $0xf8000000, %eax       # imm = 0xF8000000
cmpl $0x8000000, %eax        # imm = 0x8000000
jne 0x16125
addq %rbx, %rbp
movsd -0x18(%rbp), %xmm0
callq *%rdx
movabsq $0x20000000000, %r9     # imm = 0x20000000000
movabsq $0x10000000000, %r8     # imm = 0x10000000000
movabsq $-0x10000000000, %rdi   # imm = 0xFFFFFF0000000000
movsd %xmm0, -0x18(%rbp)
addsd 0x2c5d(%rip), %xmm0     # 0x18e40
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 0x16125
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 0x4(%rsp), %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq