// File: /workspace/github_c_makefile_star2_O1/ccxvii[P]mujs/./jsparse.c
// Function: jsP_foldconst
static int jsP_foldconst(js_Ast *node)
{
	double x, y;
	int a, b;

	if (node->type == AST_LIST) {
		while (node) {
			jsP_foldconst(node->a);
			node = node->b;
		}
		return 0;
	}

	if (node->type == EXP_NUMBER)
		return 1;

	a = node->a ? jsP_foldconst(node->a) : 0;
	b = node->b ? jsP_foldconst(node->b) : 0;
	if (node->c) jsP_foldconst(node->c);
	if (node->d) jsP_foldconst(node->d);

	if (a) {
		x = node->a->number;
		switch (node->type) {
		default: break;
		case EXP_NEG: return jsP_setnumnode(node, -x);
		case EXP_POS: return jsP_setnumnode(node, x);
		case EXP_BITNOT: return jsP_setnumnode(node, ~toint32(x));
		}

		if (b) {
			y = node->b->number;
			switch (node->type) {
			default: break;
			case EXP_MUL: return jsP_setnumnode(node, x * y);
			case EXP_DIV: return jsP_setnumnode(node, x / y);
			case EXP_MOD: return jsP_setnumnode(node, fmod(x, y));
			case EXP_ADD: return jsP_setnumnode(node, x + y);
			case EXP_SUB: return jsP_setnumnode(node, x - y);
			case EXP_SHL: return jsP_setnumnode(node, toint32(x) << (touint32(y) & 0x1F));
			case EXP_SHR: return jsP_setnumnode(node, toint32(x) >> (touint32(y) & 0x1F));
			case EXP_USHR: return jsP_setnumnode(node, touint32(x) >> (touint32(y) & 0x1F));
			case EXP_BITAND: return jsP_setnumnode(node, toint32(x) & toint32(y));
			case EXP_BITXOR: return jsP_setnumnode(node, toint32(x) ^ toint32(y));
			case EXP_BITOR: return jsP_setnumnode(node, toint32(x) | toint32(y));
			}
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl (%rdi), %ecx
movl $0x1, %eax
cmpl $0x4, %ecx
je 0x12330
movq %rdi, %rbx
testl %ecx, %ecx
jne 0x1228c
movq 0x10(%rbx), %rdi
callq 0x12254
movq 0x18(%rbx), %rbx
testq %rbx, %rbx
jne 0x12273
xorl %eax, %eax
jmp 0x12330
movq 0x10(%rbx), %rdi
movb $0x1, %bpl
movb $0x1, %r14b
testq %rdi, %rdi
je 0x122a6
callq 0x12254
testl %eax, %eax
sete %r14b
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x122ba
callq 0x12254
testl %eax, %eax
sete %bpl
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x122c8
callq 0x12254
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x122d6
callq 0x12254
xorl %eax, %eax
testb %r14b, %r14b
jne 0x12330
movq 0x10(%rbx), %rcx
movsd 0x30(%rcx), %xmm0
movl (%rbx), %ecx
cmpl $0x1d, %ecx
je 0x1230f
cmpl $0x1f, %ecx
je 0x12301
cmpl $0x1e, %ecx
jne 0x12339
xorpd 0x19101(%rip), %xmm0    # 0x2b400
jmp 0x1230f
callq 0x26762
notl %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
leaq 0x10(%rbx), %rax
movl $0x4, (%rbx)
movsd %xmm0, 0x30(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x10(%rax)
movupd %xmm0, (%rax)
movl $0x1, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
testb %bpl, %bpl
jne 0x12330
addl $-0x21, %ecx
cmpl $0x14, %ecx
ja 0x12330
movq 0x18(%rbx), %rdx
movsd 0x30(%rdx), %xmm1
leaq 0x193a2(%rip), %rdx     # 0x2b6f8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
callq 0x31b0
jmp 0x1230f
movsd %xmm1, 0x8(%rsp)
callq 0x26762
movl %eax, %ebp
movsd 0x8(%rsp), %xmm0
callq 0x26762
orl %ebp, %eax
jmp 0x12308
addsd %xmm1, %xmm0
jmp 0x1230f
movsd %xmm1, 0x8(%rsp)
callq 0x26762
movl %eax, %r14d
movsd 0x8(%rsp), %xmm0
callq 0x26762
movl %eax, %ecx
shrl %cl, %r14d
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
jmp 0x1230f
subsd %xmm1, %xmm0
jmp 0x1230f
mulsd %xmm1, %xmm0
jmp 0x1230f
divsd %xmm1, %xmm0
jmp 0x1230f
movsd %xmm1, 0x8(%rsp)
callq 0x26762
movl %eax, %ebp
movsd 0x8(%rsp), %xmm0
callq 0x26762
movl %eax, %ecx
sarl %cl, %ebp
jmp 0x12408
movsd %xmm1, 0x8(%rsp)
callq 0x26762
movl %eax, %ebp
movsd 0x8(%rsp), %xmm0
callq 0x26762
movl %eax, %ecx
shll %cl, %ebp
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
jmp 0x1230f
movsd %xmm1, 0x8(%rsp)
callq 0x26762
movl %eax, %ebp
movsd 0x8(%rsp), %xmm0
callq 0x26762
xorl %ebp, %eax
jmp 0x12308
movsd %xmm1, 0x8(%rsp)
callq 0x26762
movl %eax, %ebp
movsd 0x8(%rsp), %xmm0
callq 0x26762
andl %ebp, %eax
jmp 0x12308