// File: /workspace/github_c_makefile_star2_O2/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 %r15
pushq %r14
pushq %rbx
pushq %rax
movl (%rdi), %eax
pushq $0x1
popq %r15
cmpl $0x4, %eax
je 0xd985
movq %rdi, %rbx
testl %eax, %eax
je 0xd955
movq 0x10(%rbx), %rdi
movb $0x1, %bpl
movb $0x1, %r14b
testq %rdi, %rdi
je 0xd8ed
callq 0xd8b2
testl %eax, %eax
sete %r14b
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0xd901
callq 0xd8b2
testl %eax, %eax
sete %bpl
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0xd90f
callq 0xd8b2
movq 0x28(%rbx), %rdi
testq %rdi, %rdi
je 0xd91d
callq 0xd8b2
xorl %eax, %eax
testb %r14b, %r14b
jne 0xd988
movq 0x10(%rbx), %rcx
movsd 0x30(%rcx), %xmm0
movl (%rbx), %ecx
cmpl $0x1d, %ecx
je 0xd969
cmpl $0x1f, %ecx
je 0xd95e
cmpl $0x1e, %ecx
jne 0xd993
xorpd 0x12c5a(%rip), %xmm0    # 0x205a0
jmp 0xd969
movq 0x10(%rbx), %rdi
callq 0xd8b2
movq 0x18(%rbx), %rbx
testq %rbx, %rbx
jne 0xd948
xorl %eax, %eax
jmp 0xd988
callq 0x1c67f
notl %eax
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 %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
testb %bpl, %bpl
jne 0xd988
addl $-0x21, %ecx
cmpl $0x14, %ecx
ja 0xd988
movq 0x18(%rbx), %rdx
movsd 0x30(%rdx), %xmm1
leaq 0x12d38(%rip), %rdx     # 0x206e8
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
callq 0x31b0
jmp 0xd969
movsd %xmm1, (%rsp)
callq 0x1c67f
movl %eax, %ebp
movsd (%rsp), %xmm0
callq 0x1c67f
orl %ebp, %eax
jmp 0xd965
addsd %xmm1, %xmm0
jmp 0xd969
movsd %xmm1, (%rsp)
callq 0x1c67f
movl %eax, %r14d
movsd (%rsp), %xmm0
callq 0x1c67f
movl %eax, %ecx
shrl %cl, %r14d
cvtsi2sd %r14, %xmm0
jmp 0xd969
subsd %xmm1, %xmm0
jmp 0xd969
mulsd %xmm1, %xmm0
jmp 0xd969
divsd %xmm1, %xmm0
jmp 0xd969
movsd %xmm1, (%rsp)
callq 0x1c67f
movl %eax, %ebp
movsd (%rsp), %xmm0
callq 0x1c67f
movl %eax, %ecx
sarl %cl, %ebp
jmp 0xda57
movsd %xmm1, (%rsp)
callq 0x1c67f
movl %eax, %ebp
movsd (%rsp), %xmm0
callq 0x1c67f
movl %eax, %ecx
shll %cl, %ebp
cvtsi2sd %ebp, %xmm0
jmp 0xd969
movsd %xmm1, (%rsp)
callq 0x1c67f
movl %eax, %ebp
movsd (%rsp), %xmm0
callq 0x1c67f
xorl %ebp, %eax
jmp 0xd965
movsd %xmm1, (%rsp)
callq 0x1c67f
movl %eax, %ebp
movsd (%rsp), %xmm0
callq 0x1c67f
andl %ebp, %eax
jmp 0xd965