// File: /workspace/github_c_makefile_star2_O3/ArtifexSoftware[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 0x11f9b
movq %rdi, %rbx
testl %ecx, %ecx
jne 0x11ef7
movq 0x10(%rbx), %rdi
callq 0x11ebf
movq 0x18(%rbx), %rbx
testq %rbx, %rbx
jne 0x11ede
xorl %eax, %eax
jmp 0x11f9b
movq 0x10(%rbx), %rdi
movb $0x1, %bpl
movb $0x1, %r14b
testq %rdi, %rdi
je 0x11f11
callq 0x11ebf
testl %eax, %eax
sete %r14b
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x11f25
callq 0x11ebf
testl %eax, %eax
sete %bpl
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x11f33
callq 0x11ebf
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0x11f41
callq 0x11ebf
xorl %eax, %eax
testb %r14b, %r14b
jne 0x11f9b
movq 0x10(%rbx), %rcx
movsd 0x30(%rcx), %xmm0
movl (%rbx), %ecx
cmpl $0x1d, %ecx
je 0x11f7a
cmpl $0x1f, %ecx
je 0x11f6c
cmpl $0x1e, %ecx
jne 0x11fa4
xorpd 0x19496(%rip), %xmm0    # 0x2b400
jmp 0x11f7a
callq 0x26412
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 0x11f9b
addl $-0x21, %ecx
cmpl $0x14, %ecx
ja 0x11f9b
movq 0x18(%rbx), %rdx
movsd 0x30(%rdx), %xmm1
leaq 0x19737(%rip), %rdx     # 0x2b6f8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
callq 0x31b0
jmp 0x11f7a
movsd %xmm1, 0x8(%rsp)
callq 0x26412
movl %eax, %ebp
movsd 0x8(%rsp), %xmm0
callq 0x26412
orl %ebp, %eax
jmp 0x11f73
addsd %xmm1, %xmm0
jmp 0x11f7a
movsd %xmm1, 0x8(%rsp)
callq 0x26412
movl %eax, %r14d
movsd 0x8(%rsp), %xmm0
callq 0x26412
movl %eax, %ecx
shrl %cl, %r14d
xorps %xmm0, %xmm0
cvtsi2sd %r14, %xmm0
jmp 0x11f7a
subsd %xmm1, %xmm0
jmp 0x11f7a
mulsd %xmm1, %xmm0
jmp 0x11f7a
divsd %xmm1, %xmm0
jmp 0x11f7a
movsd %xmm1, 0x8(%rsp)
callq 0x26412
movl %eax, %ebp
movsd 0x8(%rsp), %xmm0
callq 0x26412
movl %eax, %ecx
sarl %cl, %ebp
jmp 0x12073
movsd %xmm1, 0x8(%rsp)
callq 0x26412
movl %eax, %ebp
movsd 0x8(%rsp), %xmm0
callq 0x26412
movl %eax, %ecx
shll %cl, %ebp
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
jmp 0x11f7a
movsd %xmm1, 0x8(%rsp)
callq 0x26412
movl %eax, %ebp
movsd 0x8(%rsp), %xmm0
callq 0x26412
xorl %ebp, %eax
jmp 0x11f73
movsd %xmm1, 0x8(%rsp)
callq 0x26412
movl %eax, %ebp
movsd 0x8(%rsp), %xmm0
callq 0x26412
andl %ebp, %eax
jmp 0x11f73