// File: /workspace/github_c_makefile_star2_O2/blakemcbride[P]LISP9/ls9.c
// Function: apply
int apply(int tail) {
	int	n, m, pn, pm, i;
	cell	k, e;

	if (!closurep(Acc))
		error("application of non-function", Acc);
	if (tail) {
		Ep = closure_env(Acc);
		Prog = closure_prog(Acc);
		m = fixval(stackref(Sp));
		n = fixval(stackref(Sp-m-4));
		pm = Sp-m;
		pn = Sp-m-n-4;
		if (n == m) {
			for (i=0; i<=m; i++)
				stackset(pn+i, stackref(pm+i));
			Fp = fixval(stackref(Sp-m-1));
			Sp -= n+2;
		}
		else {
			e = stackref(Sp-m-3);
			k = stackref(Sp-m-2);
			Fp = fixval(stackref(Sp-m-1));
			for (i=0; i<=m; i++)
				stackset(pn+i, stackref(pm+i));
			Sp -= n+2;
			stackset(Sp-1, e);
			stackset(Sp,   k);
		}
	}
	else {
		push(Ep);
		push(cons(mkfix(Ip+1), Prog));
		Ep = closure_env(Acc);
		Prog = closure_prog(Acc);
	}
	return fixval(closure_ip(Acc));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movslq 0xb8c5(%rip), %rsi      # 0x171c0
testq %rsi, %rsi
js 0xbb66
movq 0xba45(%rip), %rax      # 0x17350
testb $0x1, (%rax,%rsi)
je 0xbb66
movq 0xba24(%rip), %rax      # 0x17340
cmpl $-0xd, (%rax,%rsi,4)
jne 0xbb66
testl %edi, %edi
je 0xb9ee
movq 0xba13(%rip), %rcx      # 0x17348
movslq (%rcx,%rsi,4), %rdx
movslq (%rcx,%rdx,4), %rdx
movl (%rax,%rdx,4), %edx
movl %edx, 0xb88a(%rip)      # 0x171d0
movslq (%rcx,%rsi,4), %rdx
movslq (%rcx,%rdx,4), %rdx
movslq (%rcx,%rdx,4), %rdx
movl (%rax,%rdx,4), %edx
movl %edx, 0xb861(%rip)      # 0x171bc
movq 0xb9f6(%rip), %rdx      # 0x17358
movslq 0xb7f3(%rip), %rsi      # 0x1715c
movslq (%rcx,%rsi,4), %rsi
leaq (%rdx,%rsi,4), %r11
movslq 0xb7e8(%rip), %rdi      # 0x17160
movslq (%r11,%rdi,4), %rsi
movslq (%rcx,%rsi,4), %rsi
movslq (%rax,%rsi,4), %rsi
movq %rdi, %r14
subq %rsi, %r14
movslq -0x10(%r11,%r14,4), %r8
movslq (%rcx,%r8,4), %r8
movl (%rax,%r8,4), %r9d
movl %r14d, %ebx
subl %r9d, %ebx
addl $-0x4, %ebx
cmpl %esi, %r9d
jne 0xba70
movslq %ebx, %r8
leaq (%rdx,%r8,4), %r8
shlq $0x2, %rdi
leaq (,%rsi,4), %r9
subq %r9, %rdi
addq %rdx, %rdi
xorl %r9d, %r9d
movslq 0xb790(%rip), %r10      # 0x1715c
movslq (%rcx,%r10,4), %r10
cmpq %rsi, %r9
jg 0xbace
leaq (%rdi,%r10,4), %r11
movl (%r11,%r9,4), %r11d
leaq (%r8,%r10,4), %r10
movl %r11d, (%r10,%r9,4)
incq %r9
jmp 0xb9c5
movl 0xb7dc(%rip), %edi      # 0x171d0
callq 0xb7d0
movl 0xbf59(%rip), %edi      # 0x17958
incl %edi
pushq $-0x1
popq %rsi
pushq $0x1
popq %rbx
movl %ebx, %edx
callq 0x2f8c
pushq $-0xe
popq %rdi
movl %eax, %esi
movl %ebx, %edx
callq 0x2f8c
movl 0xb79c(%rip), %esi      # 0x171bc
movl %eax, %edi
xorl %edx, %edx
callq 0x2f8c
movl %eax, %edi
callq 0xb7d0
movq 0xb909(%rip), %rax      # 0x17340
movq 0xb90a(%rip), %rcx      # 0x17348
movslq 0xb77b(%rip), %rdx      # 0x171c0
movslq (%rcx,%rdx,4), %rsi
movslq (%rcx,%rsi,4), %rsi
movl (%rax,%rsi,4), %esi
movl %esi, 0xb77a(%rip)      # 0x171d0
movslq (%rcx,%rdx,4), %rdx
movslq (%rcx,%rdx,4), %rdx
movslq (%rcx,%rdx,4), %rdx
movl (%rax,%rdx,4), %edx
movl %edx, 0xb751(%rip)      # 0x171bc
jmp 0xbb45
movl -0xc(%r11,%r14,4), %r10d
movl -0x8(%r11,%r14,4), %r8d
movslq -0x4(%r11,%r14,4), %r11
movslq (%rcx,%r11,4), %r11
movl (%rax,%r11,4), %r11d
movl %r11d, 0xb73a(%rip)     # 0x171c8
movslq %ebx, %r11
leaq (%rdx,%r11,4), %r11
shlq $0x2, %rdi
leaq (,%rsi,4), %rbx
subq %rbx, %rdi
addq %rdx, %rdi
xorl %ebx, %ebx
cmpq %rsi, %rbx
jg 0xbb02
movslq 0xb6a7(%rip), %r14      # 0x1715c
movslq (%rcx,%r14,4), %r14
leaq (%rdi,%r14,4), %r15
movl (%r15,%rbx,4), %ebp
leaq (%r11,%r14,4), %r14
movl %ebp, (%r14,%rbx,4)
incq %rbx
jmp 0xbaa9
leaq (%rdx,%r10,4), %rdx
movl 0xb688(%rip), %edi      # 0x17160
movl %esi, %r8d
notl %r8d
addl %edi, %r8d
movslq %r8d, %r8
movslq (%rdx,%r8,4), %rdx
movslq (%rcx,%rdx,4), %rdx
movl (%rax,%rdx,4), %edx
movl %edx, 0xb6d3(%rip)      # 0x171c8
subl %esi, %edi
addl $-0x2, %edi
movl %edi, 0xb660(%rip)      # 0x17160
jmp 0xbb45
movl 0xb658(%rip), %esi      # 0x17160
subl %r9d, %esi
addl $-0x2, %esi
movl %esi, 0xb64c(%rip)      # 0x17160
movslq 0xb641(%rip), %rdi      # 0x1715c
movslq (%rcx,%rdi,4), %rdi
leaq (%rdx,%rdi,4), %rdi
movslq %esi, %rsi
movl %r10d, -0x4(%rdi,%rsi,4)
movslq 0xb62a(%rip), %rsi      # 0x1715c
movslq (%rcx,%rsi,4), %rsi
leaq (%rdx,%rsi,4), %rdx
movslq 0xb61f(%rip), %rsi      # 0x17160
movl %r8d, (%rdx,%rsi,4)
movslq 0xb674(%rip), %rdx      # 0x171c0
movslq (%rcx,%rdx,4), %rdx
movslq (%rax,%rdx,4), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x50e1(%rip), %rdi      # 0x10c4e
callq 0x258a