// File: /workspace/github_c_makefile_star2_O2/ArtifexSoftware[P]mujs/./jsgc.c
// Function: js_gc
void js_gc(js_State *J, int report)
{
	js_Function *fun, *nextfun, **prevnextfun;
	js_Object *obj, *nextobj, **prevnextobj;
	js_String *str, *nextstr, **prevnextstr;
	js_Environment *env, *nextenv, **prevnextenv;
	unsigned int nenv = 0, nfun = 0, nobj = 0, nstr = 0, nprop = 0;
	unsigned int genv = 0, gfun = 0, gobj = 0, gstr = 0, gprop = 0;
	int mark;
	int i;

	mark = J->gcmark = J->gcmark == 1 ? 2 : 1;

	/* Add initial roots. */

	jsG_markobject(J, mark, J->Object_prototype);
	jsG_markobject(J, mark, J->Array_prototype);
	jsG_markobject(J, mark, J->Function_prototype);
	jsG_markobject(J, mark, J->Boolean_prototype);
	jsG_markobject(J, mark, J->Number_prototype);
	jsG_markobject(J, mark, J->String_prototype);
	jsG_markobject(J, mark, J->RegExp_prototype);
	jsG_markobject(J, mark, J->Date_prototype);

	jsG_markobject(J, mark, J->Error_prototype);
	jsG_markobject(J, mark, J->EvalError_prototype);
	jsG_markobject(J, mark, J->RangeError_prototype);
	jsG_markobject(J, mark, J->ReferenceError_prototype);
	jsG_markobject(J, mark, J->SyntaxError_prototype);
	jsG_markobject(J, mark, J->TypeError_prototype);
	jsG_markobject(J, mark, J->URIError_prototype);

	jsG_markobject(J, mark, J->R);
	jsG_markobject(J, mark, J->G);

	jsG_markstack(J, mark);

	jsG_markenvironment(J, mark, J->E);
	jsG_markenvironment(J, mark, J->GE);
	for (i = 0; i < J->envtop; ++i)
		jsG_markenvironment(J, mark, J->envstack[i]);

	/* Scan objects until none remain. */

	while ((obj = J->gcroot) != NULL) {
		J->gcroot = obj->gcroot;
		obj->gcroot = NULL;
		jsG_scanobject(J, mark, obj);
	}

	/* Free everything not marked. */

	prevnextenv = &J->gcenv;
	for (env = J->gcenv; env; env = nextenv) {
		nextenv = env->gcnext;
		if (env->gcmark != mark) {
			*prevnextenv = nextenv;
			jsG_freeenvironment(J, env);
			++genv;
		} else {
			prevnextenv = &env->gcnext;
		}
		++nenv;
	}

	prevnextfun = &J->gcfun;
	for (fun = J->gcfun; fun; fun = nextfun) {
		nextfun = fun->gcnext;
		if (fun->gcmark != mark) {
			*prevnextfun = nextfun;
			jsG_freefunction(J, fun);
			++gfun;
		} else {
			prevnextfun = &fun->gcnext;
		}
		++nfun;
	}

	prevnextobj = &J->gcobj;
	for (obj = J->gcobj; obj; obj = nextobj) {
		nprop += obj->count;
		nextobj = obj->gcnext;
		if (obj->gcmark != mark) {
			gprop += obj->count;
			*prevnextobj = nextobj;
			jsG_freeobject(J, obj);
			++gobj;
		} else {
			prevnextobj = &obj->gcnext;
		}
		++nobj;
	}

	prevnextstr = &J->gcstr;
	for (str = J->gcstr; str; str = nextstr) {
		nextstr = str->gcnext;
		if (str->gcmark != mark) {
			*prevnextstr = nextstr;
			js_free(J, str);
			++gstr;
		} else {
			prevnextstr = &str->gcnext;
		}
		++nstr;
	}

	unsigned int ntot = nenv + nfun + nobj + nstr + nprop;
	unsigned int gtot = genv + gfun + gobj + gstr + gprop;
	unsigned int remaining = ntot - gtot;

	J->gccounter = remaining;
	J->gcthresh = remaining * JS_GCFACTOR;

	if (report) {
		char buf[256];
		snprintf(buf, sizeof buf, "garbage collected (%d%%): %d/%d envs, %d/%d funs, %d/%d objs, %d/%d props, %d/%d strs",
			100*gtot/ntot, genv, nenv, gfun, nfun, gobj, nobj, gprop, nprop, gstr, nstr);
		js_report(J, buf);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movl %esi, 0x38(%rsp)
xorl %esi, %esi
cmpl $0x1, 0x150(%rdi)
sete %sil
incl %esi
movl %esi, 0x150(%rdi)
movq 0x90(%rdi), %rax
movl %esi, 0x60(%rax)
movq 0x180(%rdi), %rcx
movq %rcx, 0x58(%rax)
movq 0x98(%rdi), %rcx
movl %esi, 0x60(%rcx)
movq %rax, 0x58(%rcx)
movq 0xa0(%rdi), %rax
movl %esi, 0x60(%rax)
movq %rcx, 0x58(%rax)
movq 0xa8(%rdi), %rcx
movl %esi, 0x60(%rcx)
movq %rax, 0x58(%rcx)
movq 0xb0(%rdi), %rax
movl %esi, 0x60(%rax)
movq %rcx, 0x58(%rax)
movq 0xb8(%rdi), %rcx
movl %esi, 0x60(%rcx)
movq %rax, 0x58(%rcx)
movq 0xc0(%rdi), %rax
movl %esi, 0x60(%rax)
movq %rcx, 0x58(%rax)
movq 0xc8(%rdi), %rcx
movl %esi, 0x60(%rcx)
movq %rax, 0x58(%rcx)
movq 0xd0(%rdi), %rax
movl %esi, 0x60(%rax)
movq %rcx, 0x58(%rax)
movq 0xd8(%rdi), %rcx
movl %esi, 0x60(%rcx)
movq %rax, 0x58(%rcx)
movq 0xe0(%rdi), %rax
movl %esi, 0x60(%rax)
movq %rcx, 0x58(%rax)
movq 0xe8(%rdi), %rcx
movl %esi, 0x60(%rcx)
movq %rax, 0x58(%rcx)
movq 0xf0(%rdi), %rax
movl %esi, 0x60(%rax)
movq %rcx, 0x58(%rax)
movq 0xf8(%rdi), %rcx
movl %esi, 0x60(%rcx)
movq %rax, 0x58(%rcx)
movq 0x100(%rdi), %rax
movl %esi, 0x60(%rax)
movq %rcx, 0x58(%rax)
movq 0x120(%rdi), %rcx
movl %esi, 0x60(%rcx)
movq %rax, 0x58(%rcx)
movq 0x128(%rdi), %rdx
movl %esi, %ebx
movl %esi, 0x60(%rdx)
movq %rcx, 0x58(%rdx)
movq %rdx, 0x180(%rdi)
movq 0x148(%rdi), %rax
movq %rdi, (%rsp)
movl 0x140(%rdi), %ecx
subl $0x1, %ecx
jb 0xa302
movb 0xf(%rax), %sil
cmpb $0x6, %sil
jne 0xa2d4
movq (%rax), %rsi
movsbl 0x8(%rsi), %edi
cmpl %edi, %ebx
je 0xa2e2
movb %bl, 0x8(%rsi)
movb 0xf(%rax), %sil
cmpb $0x7, %sil
jne 0xa2e2
movq (%rax), %rsi
cmpl %ebx, 0x60(%rsi)
jne 0xa2ee
movq %rdx, %rsi
addq $0x10, %rax
movq %rsi, %rdx
jmp 0xa2b3
movl %ebx, 0x60(%rsi)
movq %rdx, 0x58(%rsi)
movq (%rsp), %rdx
movq %rsi, 0x180(%rdx)
jmp 0xa2e5
movq (%rsp), %r14
movq 0x130(%r14), %rdx
movq %r14, %rdi
movl %ebx, %esi
callq 0xa73d
movq 0x138(%r14), %rdx
movq %r14, %rdi
movl %ebx, %esi
callq 0xa73d
xorl %r15d, %r15d
movq (%rsp), %rax
movslq 0x188(%rax), %rax
cmpq %rax, %r15
jge 0xa480
movq (%rsp), %rdi
movq 0x190(%rdi,%r15,8), %rdx
movl %ebx, %esi
callq 0xa73d
incq %r15
jmp 0xa32b
movq 0x58(%r15), %rax
movq (%rsp), %rcx
movq %rax, 0x180(%rcx)
andq $0x0, 0x58(%r15)
movq 0x8(%r15), %rdx
cmpl $0x0, 0x10(%rdx)
je 0xa380
movq (%rsp), %rdi
movl %ebx, %esi
callq 0x18e2c
movq 0x18(%r15), %rax
testq %rax, %rax
je 0xa3a7
cmpl %ebx, 0x60(%rax)
je 0xa3a7
movl %ebx, 0x60(%rax)
movq (%rsp), %rdx
movq 0x180(%rdx), %rcx
movq %rcx, 0x58(%rax)
movq %rax, 0x180(%rdx)
movl (%r15), %eax
cmpl $0xe, %eax
je 0xa45e
cmpl $0x1, %eax
jne 0xa426
cmpl $0x0, 0x24(%r15)
je 0xa480
xorl %ecx, %ecx
xorl %edx, %edx
movslq 0x28(%r15), %rsi
cmpq %rsi, %rdx
jge 0xa426
movq 0x30(%r15), %rsi
movb 0xf(%rsi,%rcx), %dil
cmpb $0x6, %dil
jne 0xa3f5
movq (%rsi,%rcx), %rdi
movsbl 0x8(%rdi), %r8d
cmpl %r8d, %ebx
je 0xa41d
movb %bl, 0x8(%rdi)
movb 0xf(%rsi,%rcx), %dil
cmpb $0x7, %dil
jne 0xa41d
movq (%rsi,%rcx), %rsi
cmpl %ebx, 0x60(%rsi)
je 0xa41d
movl %ebx, 0x60(%rsi)
movq (%rsp), %r8
movq 0x180(%r8), %rdi
movq %rdi, 0x58(%rsi)
movq %rsi, 0x180(%r8)
incq %rdx
addq $0x10, %rcx
jmp 0xa3c7
andl $-0x2, %eax
cmpl $0x2, %eax
jne 0xa480
movq 0x28(%r15), %rdx
testq %rdx, %rdx
je 0xa447
cmpl %ebx, 0x18(%rdx)
je 0xa447
movq (%rsp), %rdi
movl %ebx, %esi
callq 0xa73d
movq 0x20(%r15), %rsi
testq %rsi, %rsi
je 0xa480
cmpl %ebx, 0x68(%rsi)
je 0xa480
movl %ebx, %edi
callq 0x18ee8
jmp 0xa480
movq 0x20(%r15), %rax
cmpl %ebx, 0x60(%rax)
je 0xa480
movl %ebx, 0x60(%rax)
movq (%rsp), %rdx
movq 0x180(%rdx), %rcx
movq %rcx, 0x58(%rax)
movq %rax, 0x180(%rdx)
movq (%rsp), %rax
movq 0x180(%rax), %r15
testq %r15, %r15
jne 0xa357
movq (%rsp), %rax
leaq 0x160(%rax), %r15
movq 0x160(%rax), %rsi
xorl %r13d, %r13d
xorl %ebp, %ebp
testq %rsi, %rsi
je 0xa4db
movq 0x10(%rsi), %r12
cmpl %ebx, 0x18(%rsi)
jne 0xa4c2
addq $0x10, %rsi
movq %rsi, %r15
jmp 0xa4d3
movq %r12, (%r15)
movq (%rsp), %rax
movq (%rax), %rdi
xorl %edx, %edx
callq *0x10(%rax)
incl %ebp
incl %r13d
movq %r12, %rsi
jmp 0xa4ab
movq (%rsp), %rax
leaq 0x168(%rax), %r15
movq 0x168(%rax), %rsi
movq $0x0, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
testq %rsi, %rsi
je 0xa53f
movq 0x60(%rsi), %r12
cmpl %ebx, 0x68(%rsi)
jne 0xa516
addq $0x60, %rsi
movq %rsi, %r15
jmp 0xa52e
movq %r12, (%r15)
movq (%rsp), %rdi
callq 0xa76c
movq 0x28(%rsp), %rax
incl %eax
movq %rax, 0x28(%rsp)
movq 0x20(%rsp), %rax
incl %eax
movq %rax, 0x20(%rsp)
movq %r12, %rsi
jmp 0xa4ff
movq %rbp, 0x50(%rsp)
movq (%rsp), %rax
leaq 0x170(%rax), %r14
movq 0x170(%rax), %rsi
movq %r13, 0x48(%rsp)
movq 0x20(%rsp), %rax
leal (%rax,%r13), %edi
xorl %r11d, %r11d
xorl %r12d, %r12d
movq $0x0, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
testq %rsi, %rsi
je 0xa5d7
movl 0x10(%rsi), %ebp
movq 0x50(%rsi), %r13
cmpl %ebx, 0x60(%rsi)
jne 0xa596
addq $0x50, %rsi
movq %rsi, %r14
jmp 0xa5ca
movq 0x10(%rsp), %rax
addl %ebp, %eax
movq %rax, 0x10(%rsp)
movq %r13, (%r14)
movq %rdi, 0x30(%rsp)
movq (%rsp), %rdi
movq %r11, %r15
callq 0xa7b2
movq 0x30(%rsp), %rdi
movq %r15, %r11
movq 0x18(%rsp), %rax
incl %eax
movq %rax, 0x18(%rsp)
addl %ebp, %r12d
incl %r11d
incl %edi
movq %r13, %rsi
jmp 0xa57c
movq (%rsp), %rax
leaq 0x178(%rax), %rcx
movq 0x178(%rax), %rsi
leal (%rdi,%r12), %eax
movq %rax, 0x40(%rsp)
leal (%rax,%rax,4), %r9d
movl %r12d, %r13d
subl 0x10(%rsp), %r13d
subl 0x18(%rsp), %r13d
xorl %ebp, %ebp
movq $0x0, 0x8(%rsp)
movq %rdi, 0x30(%rsp)
testq %rsi, %rsi
je 0xa680
movq (%rsi), %r15
movsbl 0x8(%rsi), %eax
cmpl %eax, %ebx
jne 0xa628
movq %rsi, %rcx
jmp 0xa672
movq %r15, (%rcx)
movq (%rsp), %rax
movq (%rax), %rdi
xorl %edx, %edx
movq %rbp, 0x58(%rsp)
movq %r11, %rbp
movq (%rsp), %rax
movl %r13d, 0x3c(%rsp)
movl %r9d, %r14d
movq %rcx, %r13
callq *0x10(%rax)
movq %r13, %rcx
movl %r14d, %r9d
movl 0x3c(%rsp), %r13d
movq 0x30(%rsp), %rdi
movq %rbp, %r11
movq 0x58(%rsp), %rbp
movq 0x8(%rsp), %rax
incl %eax
movq %rax, 0x8(%rsp)
incl %ebp
addl $0x5, %r9d
incl %r13d
movq %r15, %rsi
jmp 0xa613
movq 0x50(%rsp), %r8
movq 0x28(%rsp), %r10
leal (%r10,%r8), %ecx
movq 0x18(%rsp), %r14
movq 0x10(%rsp), %rsi
leal (%r14,%rsi), %eax
addl %ecx, %eax
movq 0x8(%rsp), %rbx
addl %ebx, %eax
subl %ebx, %r13d
subl %ecx, %r13d
addl %edi, %r13d
movq (%rsp), %rdi
movl %r13d, 0x154(%rdi)
imull $-0x5, %eax, %ecx
addl %r9d, %ecx
movl %ecx, 0x158(%rdi)
cmpl $0x0, 0x38(%rsp)
je 0xa72b
movq 0x40(%rsp), %rcx
addl %ebp, %ecx
imull $0x64, %eax, %eax
xorl %edx, %edx
divl %ecx
leaq 0x1db3b(%rip), %rdx     # 0x2821c
leaq 0x60(%rsp), %rdi
movq %rsi, %r15
movl $0x100, %esi            # imm = 0x100
movl %eax, %ecx
movq 0x48(%rsp), %r9
xorl %eax, %eax
pushq %rbp
pushq 0x10(%rsp)
pushq %r12
pushq %r15
pushq %r11
pushq %r14
pushq 0x50(%rsp)
pushq %r10
callq 0x3080
addq $0x40, %rsp
movq (%rsp), %rax
movq 0x18(%rax), %rax
testq %rax, %rax
je 0xa72b
leaq 0x60(%rsp), %rsi
movq (%rsp), %rdi
callq *%rax
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq