// File: /workspace/github_c_makefile_star2_O3/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, %r15
movq %rdx, %r12
xorl %r13d, %r13d
movq %rsi, 0x18(%rsp)
movq %r13, (%rsi)
movq %r13, (%rdx)
movq %r8, 0x20(%rsp)
movl $0x0, (%r8)
movslq (%rdi), %r14
testq %r14, %r14
jle 0x1d04d
movq %rdi, (%rsp)
movq 0x8(%rdi), %rax
movq %r14, %rcx
shlq $0x4, %rcx
leaq (%rcx,%rcx,2), %rdi
xorl %ecx, %ecx
xorl %r13d, %r13d
movq (%rax,%rcx), %rdx
movl %edx, %esi
andl $0xfffe, %esi           # imm = 0xFFFE
cmpl $0x2, %esi
jne 0x1cd8c
cmpq $0x0, 0x10(%rax,%rcx)
je 0x1cdaf
cmpw $0x1, %dx
jne 0x1cdb3
movl %r13d, %esi
orl $0x80, %esi
cmpq $0x0, 0x8(%rax,%rcx)
cmovel %r13d, %esi
btl $0x1a, %edx
cmovael %esi, %r13d
jmp 0x1cdb3
orl $0x40, %r13d
addq $0x30, %rcx
cmpq %rcx, %rdi
jne 0x1cd73
callq 0x22e0
movq %rax, %rbx
testl %r14d, %r14d
jle 0x1d061
movq %r12, 0x8(%rsp)
movq %r15, 0x10(%rsp)
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 (%rsp), %rdi
movq 0x8(%rdi), %rcx
movq -0x10(%rcx,%r15), %rax
movl %eax, %edx
andl $0xfffe, %edx           # imm = 0xFFFE
cmpl $0x2, %edx
jne 0x1ce9a
movq %rax, %rdx
andq %r8, %rdx
cmpq %r9, %rdx
je 0x1cecd
cmpq %r10, %rdx
jne 0x1cf1c
movq (%rcx,%r15), %rcx
testq %rcx, %rcx
je 0x1cf1c
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 0x1cf44
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 0x1cf29
leaq (%rcx,%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 0x1cf26
movq (%rcx,%r15), %rcx
testq %rcx, %rcx
je 0x1cf1c
movslq %r12d, %rdx
leaq (%rdx,%rdx,2), %rbp
shlq $0x4, %rbp
cmpl $0x8000000, %eax        # imm = 0x8000000
jae 0x1cfbb
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 0x1cf26
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 0x1ce05
jmp 0x1d02a
andl $0xf8000000, %eax       # imm = 0xF8000000
cmpl $0x8000000, %eax        # imm = 0x8000000
jne 0x1cf29
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 0x1eae(%rip), %xmm0     # 0x1ee40
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 0x1cf29
andl $0xf8000000, %eax       # imm = 0xF8000000
cmpl $0x8000000, %eax        # imm = 0x8000000
jne 0x1cf26
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 0x1e3c(%rip), %xmm0     # 0x1ee40
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 0x1cf26
movzwl 0x2(%rbx), %ecx
movq 0x20(%rbx), %rdx
movsd 0x18(%rbx), %xmm0
movq 0x28(%rbx), %rax
andl $0x3ff, %ecx            # imm = 0x3FF
movq 0x10(%rsp), %r15
movq 0x8(%rsp), %r12
jmp 0x1d063
shlq $0x4, %r14
leaq (%r14,%r14,2), %rdi
callq 0x22e0
movq %rax, %rbx
xorl %ecx, %ecx
jmp 0x1d063
xorl %ecx, %ecx
movq 0x20(%rsp), %rsi
movl %ecx, (%rsi)
movq 0x18(%rsp), %rcx
movq %rdx, (%rcx)
movsd %xmm0, (%r12)
movq %rax, (%r15)
movq %rbx, %rdi
callq 0x2050
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq