// File: /workspace/github_c_makefile_star2_O3/blakemcbride[P]LISP9/ls9.c
// Function: mark
void mark(cell n) {
	cell	x, parent, *v;
	int	i;

	parent = NIL;
	while (1) {
		if (specialp(n) || (tag(n) & MARK_TAG)) {
			if (NIL == parent)
				break;
			if (tag(parent) & VECTOR_TAG) { /* S1 --> S1|done */
				i = vecndx(parent);
				v = vector(parent);
				if (tag(parent) & TRAV_TAG &&
				    i+1 < veclen(parent)
				) {			/* S1 --> S1 */
					x = v[i+1];
					v[i+1] = v[i];
					v[i] = n;
					n = x;
					vecndx(parent) = i+1;
				}
				else {			/* S1 --> done */
					x = parent;
					parent = v[i];
					v[i] = n;
					n = x;
					veclink(n) = n;
				}
			}
			else if (tag(parent) & TRAV_TAG) { /* S1 --> S2 */
				x = cdr(parent);
				cdr(parent) = car(parent);
				car(parent) = n;
				tag(parent) &= ~TRAV_TAG;
				n = x;
			}
			else {				/* S2 --> done */
				x = parent;
				parent = cdr(x);
				cdr(x) = n;
				n = x;
			}
		}
		else if (tag(n) & VECTOR_TAG) {		/* S0 --> S1 */
			tag(n) |= MARK_TAG;
			if (T_VECTOR == car(n) && veclen(n) != 0) {
				tag(n) |= TRAV_TAG;
				vecndx(n) = 0;
				v = vector(n);
				x = v[0];
				v[0] = parent;
				parent = n;
				n = x;
			}
			else {
				veclink(n) = n;
			}
		}
		else if (tag(n) & ATOM_TAG) {		/* S0 --> S2 */
			if (cdr(n) != NIL) {
				if (T_BYTECODE == car(n)) {
					marklit(cdr(n));
				}
				else if (T_INPORT == car(n) ||
					 T_OUTPORT == car(n)
				)
					Port_flags[portno(n)] |= USED_TAG;
			}
			x = cdr(n);
			cdr(n) = parent;
			parent = n;
			n = x;
			tag(parent) |= MARK_TAG;
		}
		else {					/* S0 --> S1 */
			x = car(n);
			car(n) = parent;
			tag(n) |= MARK_TAG;
			parent = n;
			n = x;
			tag(parent) |= TRAV_TAG;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leaq 0x16935(%rip), %r14     # 0x19600
movl %ecx, %ebp
testl %ebx, %ebx
js 0x2d1b
movq 0x16678(%rip), %rax     # 0x19350
movl %ebx, %r15d
movzbl (%rax,%r15), %ecx
testb $0x2, %cl
jne 0x2d1b
testb $0x8, %cl
jne 0x2de4
testb $0x1, %cl
jne 0x2e25
movq 0x16642(%rip), %rdx     # 0x19340
movl %ebx, %ecx
movl (%rdx,%r15,4), %ebx
movl %ebp, (%rdx,%r15,4)
orb $0x2, (%rax,%r15)
movq 0x1663c(%rip), %rax     # 0x19350
orb $0x4, (%rax,%r15)
jmp 0x2ccb
cmpl $-0x1, %ebp
je 0x2eb9
movq 0x16625(%rip), %rcx     # 0x19350
movslq %ebp, %rax
movzbl (%rcx,%rax), %r9d
testb $0x8, %r9b
jne 0x2d55
movq 0x16608(%rip), %rsi     # 0x19348
movl (%rsi,%rax,4), %edx
testb $0x4, %r9b
jne 0x2dc5
movl %ebx, (%rsi,%rax,4)
movl %edx, %ecx
movl %ebp, %ebx
jmp 0x2ccb
movq 0x165fc(%rip), %rdx     # 0x19358
movq 0x165e5(%rip), %rsi     # 0x19348
movslq (%rsi,%rax,4), %rcx
leaq (%rdx,%rcx,4), %rdi
movslq -0x8(%rdi), %r8
testb $0x4, %r9b
je 0x2dae
leaq 0x1(%r8), %rcx
movslq -0x4(%rdi), %r9
addq $0x3, %r9
shrq $0x2, %r9
cmpq %rcx, %r9
jbe 0x2dae
movl (%rdi,%r8,4), %r9d
movl 0x4(%rdi,%r8,4), %r10d
movl %r9d, 0x4(%rdi,%r8,4)
movl %ebx, (%rdi,%r8,4)
movslq (%rsi,%rax,4), %rax
movl %ecx, -0x8(%rdx,%rax,4)
movl %ebp, %ecx
movl %r10d, %ebx
jmp 0x2ccb
movl (%rdi,%r8,4), %ecx
movl %ebx, (%rdi,%r8,4)
movslq (%rsi,%rax,4), %rax
movl %ebp, -0x8(%rdx,%rax,4)
movl %ebp, %ebx
jmp 0x2ccb
movq 0x16574(%rip), %rdi     # 0x19340
movl (%rdi,%rax,4), %r8d
movl %r8d, (%rsi,%rax,4)
movl %ebx, (%rdi,%rax,4)
andb $-0x5, (%rcx,%rax)
movl %ebp, %ecx
movl %edx, %ebx
jmp 0x2ccb
orb $0x2, %cl
movb %cl, (%rax,%r15)
movq 0x1654e(%rip), %rax     # 0x19340
cmpl $-0x13, (%rax,%r15,4)
movq 0x1655a(%rip), %rax     # 0x19358
movq 0x16543(%rip), %rcx     # 0x19348
movslq (%rcx,%r15,4), %rcx
jne 0x2e1a
movslq -0x4(%rax,%rcx,4), %rdx
addq $0x3, %rdx
cmpq $0x4, %rdx
jae 0x2e56
movl %ebx, -0x8(%rax,%rcx,4)
movl %ebp, %ecx
jmp 0x2ccb
movq 0x1651c(%rip), %rdx     # 0x19348
movslq (%rdx,%r15,4), %rdi
cmpq $-0x1, %rdi
je 0x2ea5
movq 0x16503(%rip), %rcx     # 0x19340
movl (%rcx,%r15,4), %esi
leal 0x10(%rsi), %r8d
cmpl $0x2, %r8d
jae 0x2e8d
movslq (%rcx,%rdi,4), %rcx
orb $0x20, (%rcx,%r14)
jmp 0x2ea5
movq 0x164f3(%rip), %rax     # 0x19350
orb $0x4, (%rax,%r15)
movq 0x164ef(%rip), %rax     # 0x19358
movq 0x164d8(%rip), %rcx     # 0x19348
movslq (%rcx,%r15,4), %rdx
movl $0x0, -0x8(%rax,%rdx,4)
movslq (%rcx,%r15,4), %rdx
movl %ebx, %ecx
movl (%rax,%rdx,4), %ebx
movl %ebp, (%rax,%rdx,4)
jmp 0x2ccb
cmpl $-0xa, %esi
jne 0x2ea5
callq 0x2c24
movq 0x164aa(%rip), %rdx     # 0x19348
movq 0x164ab(%rip), %rax     # 0x19350
movl %ebx, %ecx
movl (%rdx,%r15,4), %ebx
movl %ebp, (%rdx,%r15,4)
orb $0x2, (%rax,%r15)
jmp 0x2ccb
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq