// File: /workspace/github_c_makefile_star2_O2/azhai[P]mlite/mlite.c
// Function: mark
void mark(cell n) {
	cell	p, parent, *v;
	int	i;

	parent = NIL;	/* Initially, there is no parent node */
	while (1) {
		if (special_value_p(n) || Tag[n] & MARK_TAG) {
			if (parent == NIL)
				break;
			if (Tag[parent] & VECTOR_TAG) {	/* S1 --> S1|done */
				i = vector_index(parent);
				v = vector(parent);
				if (Tag[parent] & STATE_TAG &&
				    i+1 < vector_len(parent)
				) {			/* S1 --> S1 */
					p = v[i+1];
					v[i+1] = v[i];
					v[i] = n;
					n = p;
					vector_index(parent) = i+1;
				}
				else {			/* S1 --> done */
					p = parent;
					parent = v[i];
					v[i] = n;
					n = p;
				}
			}
			else if (Tag[parent] & STATE_TAG) {	/* S1 --> S2 */
				p = cdr(parent);
				cdr(parent) = car(parent);
				car(parent) = n;
				Tag[parent] &= ~STATE_TAG;
				Tag[parent] |=  MARK_TAG;
				n = p;
			}
			else {				/* S2 --> done */
				p = parent;
				parent = cdr(p);
				cdr(p) = n;
				n = p;
			}
		}
		else {
			if (Tag[n] & VECTOR_TAG) {	/* S0 --> S1|S2 */
				Tag[n] |= MARK_TAG;
				/* Tag[n] &= ~STATE_TAG; */
				vector_link(n) = n;
				if (car(n) == T_VECTOR && vector_len(n) != 0) {
					Tag[n] |= STATE_TAG;
					vector_index(n) = 0;
					v = vector(n);
					p = v[0];
					v[0] = parent;
					parent = n;
					n = p;
				}
			}
			else if (Tag[n] & ATOM_TAG) {	/* S0 --> S2 */
				if (instream_p(n) || outstream_p(n))
					Stream_flags[stream_id(n)] |= USED_TAG;
				p = cdr(n);
				cdr(n) = parent;
				/*Tag[n] &= ~STATE_TAG;*/
				parent = n;
				n = p;
				Tag[parent] |= MARK_TAG;
			}
			else {				/* S0 --> S1 */
				p = car(n);
				car(n) = parent;
				Tag[n] |= MARK_TAG;
				parent = n;
				n = p;
				Tag[parent] |= STATE_TAG;
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movabsq $-0x1, %rsi
movabsq $0x100000000, %rax      # imm = 0x100000000
leaq 0x18a3e(%rip), %rcx     # 0x1c600
movq %rsi, %rdx
testq %rdi, %rdi
js 0x3c13
movq 0x18a0f(%rip), %rsi     # 0x1c5e0
movzbl (%rsi,%rdi), %r8d
testb $0x2, %r8b
jne 0x3c13
testb $0x10, %r8b
jne 0x3cf9
testb $0x1, %r8b
jne 0x3d7e
movq 0x18579(%rip), %r8      # 0x1c170
movq (%r8,%rdi,8), %r9
movq %rdx, (%r8,%rdi,8)
orb $0x2, (%rsi,%rdi)
movq 0x189d6(%rip), %rdx     # 0x1c5e0
orb $0x4, (%rdx,%rdi)
jmp 0x3dc2
cmpq $-0x1, %rdx
je 0x3dcd
movq 0x189bc(%rip), %rsi     # 0x1c5e0
movzbl (%rsi,%rdx), %r11d
testb $0x10, %r11b
jne 0x3c53
movq 0x1898a(%rip), %r9      # 0x1c5c0
movq (%r9,%rdx,8), %r8
testb $0x4, %r11b
jne 0x3ccc
movq %rdi, (%r9,%rdx,8)
movq %r8, %rsi
movq %rdx, %rdi
jmp 0x3bc2
movq 0x1898e(%rip), %rsi     # 0x1c5e8
movq 0x1895f(%rip), %r10     # 0x1c5c0
movq (%r10,%rdx,8), %r8
leaq (%rsi,%r8,8), %r8
movq -0x10(%r8), %r9
shlq $0x20, %r9
testb $0x4, %r11b
je 0x3cb8
leaq (%r9,%rax), %r11
sarq $0x20, %r11
movq -0x8(%r8), %rbx
addq $0x7, %rbx
shrq $0x3, %rbx
cmpq %rbx, %r11
jae 0x3cb8
movq (%r8,%r11,8), %rbx
sarq $0x1d, %r9
movq (%r8,%r9), %r14
movq %r14, (%r8,%r11,8)
movq %rdi, (%r8,%r9)
movq (%r10,%rdx,8), %rdi
movq %r11, -0x10(%rsi,%rdi,8)
movq %rdx, %rsi
movq %rbx, %rdi
jmp 0x3bc2
sarq $0x1d, %r9
movq (%r8,%r9), %rsi
movq %rdi, (%r8,%r9)
movq %rdx, %rdi
jmp 0x3bc2
movq 0x1849d(%rip), %r10     # 0x1c170
movq (%r10,%rdx,8), %r11
movq %r11, (%r9,%rdx,8)
movq %rdi, (%r10,%rdx,8)
andb $-0x5, (%rsi,%rdx)
movq 0x188f6(%rip), %rsi     # 0x1c5e0
orb $0x2, (%rsi,%rdx)
movq %rdx, %rsi
movq %r8, %rdi
jmp 0x3bc2
orb $0x2, %r8b
movb %r8b, (%rsi,%rdi)
movq 0x188e0(%rip), %r8      # 0x1c5e8
movq 0x188b1(%rip), %r9      # 0x1c5c0
movq (%r9,%rdi,8), %rsi
movq %rdi, -0x18(%r8,%rsi,8)
movq 0x18451(%rip), %rsi     # 0x1c170
cmpq $-0x24, (%rsi,%rdi,8)
movq %rdx, %rsi
jne 0x3bc2
movq (%r9,%rdi,8), %rsi
movq -0x8(%r8,%rsi,8), %r8
addq $0x7, %r8
movq %rdx, %rsi
cmpq $0x8, %r8
jb 0x3bc2
movq 0x18892(%rip), %rsi     # 0x1c5e0
orb $0x4, (%rsi,%rdi)
movq 0x1888f(%rip), %r8      # 0x1c5e8
movq 0x18860(%rip), %rsi     # 0x1c5c0
movq (%rsi,%rdi,8), %r9
andq $0x0, -0x10(%r8,%r9,8)
movq (%rsi,%rdi,8), %r9
movq %rdi, %rsi
movq (%r8,%r9,8), %rdi
movq %rdx, (%r8,%r9,8)
jmp 0x3bc2
testb $0x20, %r8b
je 0x3daf
movq 0x183e5(%rip), %r8      # 0x1c170
movq (%r8,%rdi,8), %r9
cmpq $-0x17, %r9
je 0x3d9b
cmpq $-0x19, %r9
jne 0x3daf
movq 0x1881e(%rip), %r9      # 0x1c5c0
movq (%r9,%rdi,8), %r9
movq (%r8,%r9,8), %r8
orb $0x40, (%r8,%rcx)
movq 0x1880a(%rip), %r8      # 0x1c5c0
movq (%r8,%rdi,8), %r9
movq %rdx, (%r8,%rdi,8)
orb $0x2, (%rsi,%rdi)
movq %rdi, %rsi
movq %r9, %rdi
jmp 0x3bc2
popq %rbx
popq %r14
popq %rbp
retq