// File: /workspace/github_c_makefile_star2_O3/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 %r14
pushq %rbx
movslq 0xb92f(%rip), %rsi      # 0x191c0
testq %rsi, %rsi
js 0xdb72
movq 0xbaaf(%rip), %rax      # 0x19350
testb $0x1, (%rax,%rsi)
je 0xdb72
movq 0xba8e(%rip), %rax      # 0x19340
cmpl $-0xd, (%rax,%rsi,4)
jne 0xdb72
testl %edi, %edi
je 0xd9b8
movq 0xba7d(%rip), %rcx      # 0x19348
movslq (%rcx,%rsi,4), %rdx
movslq (%rcx,%rdx,4), %rdx
movl (%rax,%rdx,4), %edx
movl %edx, 0xb8f4(%rip)      # 0x191d0
movslq (%rcx,%rsi,4), %rdx
movslq (%rcx,%rdx,4), %rdx
movslq (%rcx,%rdx,4), %rdx
movl (%rax,%rdx,4), %edx
movl %edx, 0xb8cb(%rip)      # 0x191bc
movq 0xba60(%rip), %rdx      # 0x19358
movslq 0xb85d(%rip), %r11      # 0x1915c
movslq (%rcx,%r11,4), %r10
leaq (%rdx,%r10,4), %r14
movslq 0xb852(%rip), %rdi      # 0x19160
movslq (%r14,%rdi,4), %rsi
movslq (%rcx,%rsi,4), %rsi
movl (%rax,%rsi,4), %esi
movl %edi, %r9d
subl %esi, %r9d
movslq %r9d, %rbx
movslq -0x10(%r14,%rbx,4), %r8
movslq (%rcx,%r8,4), %r8
movl (%rax,%r8,4), %r8d
movl %ebx, %ebp
subl %r8d, %ebp
addl $-0x4, %ebp
cmpl %esi, %r8d
jne 0xdac5
testl %esi, %esi
js 0xd98c
movslq %ebp, %r8
movq %rsi, %rdi
incq %rdi
leaq (%rdx,%r8,4), %r8
leaq (%rdx,%rbx,4), %r9
movslq 0xb800(%rip), %r10      # 0x1915c
movslq (%rcx,%r10,4), %r10
movl (%r9,%r10,4), %r11d
movl %r11d, (%r8,%r10,4)
addq $0x4, %r8
addq $0x4, %r9
decq %rdi
jne 0xd955
movslq 0xb7e0(%rip), %rdi      # 0x1915c
movslq (%rcx,%rdi,4), %r10
movl 0xb7da(%rip), %edi      # 0x19160
movl %edi, %r9d
subl %esi, %r9d
leaq (%rdx,%r10,4), %rdx
notl %esi
addl %edi, %esi
movslq %esi, %rsi
movslq (%rdx,%rsi,4), %rdx
movslq (%rcx,%rdx,4), %rdx
movl (%rax,%rdx,4), %edx
movl %edx, 0xb820(%rip)      # 0x191c8
addl $-0x2, %r9d
movl %r9d, 0xb7ad(%rip)      # 0x19160
jmp 0xdb57
movl 0xb812(%rip), %ebx      # 0x191d0
movl %ebx, 0xb7b0(%rip)      # 0x19174
movl $0x1, %edi
callq 0xd6c2
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, 0xb79b(%rip)      # 0x19174
movslq 0xb780(%rip), %rax      # 0x19160
leaq 0x1(%rax), %rcx
movl %ecx, 0xb776(%rip)      # 0x19160
movq 0xb957(%rip), %rcx      # 0x19348
movslq 0xb764(%rip), %rdx      # 0x1915c
movslq (%rcx,%rdx,4), %rcx
shlq $0x2, %rcx
addq 0xb951(%rip), %rcx      # 0x19358
movl %ebx, 0x4(%rcx,%rax,4)
movl 0xbf47(%rip), %edi      # 0x19958
incl %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x1, %edx
callq 0x30e7
movl $0xfffffff2, %edi       # imm = 0xFFFFFFF2
movl %eax, %esi
movl $0x1, %edx
callq 0x30e7
movl 0xb783(%rip), %esi      # 0x191bc
movl %eax, %edi
xorl %edx, %edx
callq 0x30e7
movl %eax, %ebx
movl %eax, 0xb72a(%rip)      # 0x19174
movl $0x1, %edi
callq 0xd6c2
movl %ebp, 0xb71a(%rip)      # 0x19174
movslq 0xb6ff(%rip), %rax      # 0x19160
leaq 0x1(%rax), %rcx
movl %ecx, 0xb6f5(%rip)      # 0x19160
movq 0xb8d6(%rip), %rcx      # 0x19348
movslq 0xb6e3(%rip), %rdx      # 0x1915c
movslq (%rcx,%rdx,4), %rdx
shlq $0x2, %rdx
addq 0xb8d0(%rip), %rdx      # 0x19358
movl %ebx, 0x4(%rdx,%rax,4)
movq 0xb8ad(%rip), %rax      # 0x19340
movslq 0xb726(%rip), %rdx      # 0x191c0
movslq (%rcx,%rdx,4), %rsi
movslq (%rcx,%rsi,4), %rsi
movl (%rax,%rsi,4), %esi
movl %esi, 0xb725(%rip)      # 0x191d0
movslq (%rcx,%rdx,4), %rdx
movslq (%rcx,%rdx,4), %rdx
movslq (%rcx,%rdx,4), %rdx
movl (%rax,%rdx,4), %edx
movl %edx, 0xb6fc(%rip)      # 0x191bc
jmp 0xdb57
movl -0xc(%r14,%rbx,4), %r10d
movl -0x8(%r14,%rbx,4), %r9d
movslq -0x4(%r14,%rbx,4), %r14
movslq (%rcx,%r14,4), %r14
movl (%rax,%r14,4), %r14d
movl %r14d, 0xb6e5(%rip)     # 0x191c8
testl %esi, %esi
js 0xdb21
movslq %ebp, %rdi
incq %rsi
leaq (%rdx,%rdi,4), %rdi
leaq (%rdx,%rbx,4), %r11
movslq 0xb660(%rip), %rbx      # 0x1915c
movslq (%rcx,%rbx,4), %rbx
movl (%r11,%rbx,4), %ebp
movl %ebp, (%rdi,%rbx,4)
addq $0x4, %rdi
addq $0x4, %r11
decq %rsi
jne 0xdaf5
movl 0xb646(%rip), %edi      # 0x19160
movslq 0xb63b(%rip), %r11      # 0x1915c
subl %r8d, %edi
addl $-0x2, %edi
movl %edi, 0xb633(%rip)      # 0x19160
movslq (%rcx,%r11,4), %rsi
leaq (%rdx,%rsi,4), %rsi
movslq %edi, %rdi
movl %r10d, -0x4(%rsi,%rdi,4)
movslq 0xb618(%rip), %rsi      # 0x1915c
movslq (%rcx,%rsi,4), %rsi
leaq (%rdx,%rsi,4), %rdx
movslq 0xb60d(%rip), %rsi      # 0x19160
movl %r9d, (%rdx,%rsi,4)
movslq 0xb662(%rip), %rdx      # 0x191c0
movslq (%rcx,%rdx,4), %rdx
movslq (%rax,%rdx,4), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %eax
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x6115(%rip), %rdi      # 0x13c8e
callq 0x2643