// File: /workspace/github_c_makefile_star2_O2/bobrippling[P]tim/window.c
// Function: window_evict
void window_evict(window *const evictee)
{
	if(evictee->neighbours.above){
		/* we are just a child in the chain */
		assert(!evictee->neighbours.left);
		assert(!evictee->neighbours.right);

		window *above = evictee->neighbours.above;

		assert(above->neighbours.below == evictee);
		above->neighbours.below = evictee->neighbours.below;

		if(evictee->neighbours.below)
			evictee->neighbours.below->neighbours.above = above;

		evictee->neighbours.above = evictee->neighbours.below = NULL;
		return;
	}

	/* we are a top-most chain.
	 * remove ourselves from the left-right hierarchy
	 * if we have a child below, it takes our place.
	 */
	window *const child = evictee->neighbours.below;

	if(evictee->neighbours.left){
		window *left = evictee->neighbours.left;

		assert(left->neighbours.right == evictee);

		window *target = child ? child : evictee->neighbours.right;
		left->neighbours.right = target;
		if(target)
			target->neighbours.left = left;
	}

	if(evictee->neighbours.right){
		window *right = evictee->neighbours.right;

		window *target = child ? child : evictee->neighbours.left;
		right->neighbours.left = target;
		if(target)
			target->neighbours.right = right;
	}

	evictee->neighbours.left = evictee->neighbours.right = NULL;
	evictee->neighbours.above = evictee->neighbours.below = NULL;
	if(child){
		assert(child->neighbours.above == evictee);
		child->neighbours.above = NULL;
	}
}

// Assembly:
pushq %rax
movq 0x60(%rdi), %rax
testq %rax, %rax
je 0xcc3b
cmpq $0x0, 0x48(%rdi)
jne 0xccb9
cmpq $0x0, 0x50(%rdi)
jne 0xccd2
cmpq %rdi, 0x58(%rax)
jne 0xcceb
movq 0x58(%rdi), %rcx
addq $0x58, %rdi
movq %rcx, 0x58(%rax)
testq %rcx, %rcx
je 0xcc33
movq %rax, 0x60(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
jmp 0xccb7
movq 0x48(%rdi), %rcx
movq 0x58(%rdi), %rax
testq %rcx, %rcx
je 0xcc71
cmpq %rdi, 0x50(%rcx)
jne 0xcd04
testq %rax, %rax
je 0xcc60
movq %rax, 0x50(%rcx)
movq %rax, %rdx
jmp 0xcc6d
movq 0x50(%rdi), %rdx
movq %rdx, 0x50(%rcx)
testq %rdx, %rdx
je 0xcc99
movq %rcx, 0x48(%rdx)
movq 0x50(%rdi), %rcx
testq %rcx, %rcx
je 0xcc99
testq %rax, %rax
je 0xcc88
movq %rax, 0x48(%rcx)
movq %rax, %rdx
jmp 0xcc95
movq 0x48(%rdi), %rdx
movq %rdx, 0x48(%rcx)
testq %rdx, %rdx
je 0xcc99
movq %rcx, 0x50(%rdx)
leaq 0x58(%rdi), %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x48(%rdi)
movups %xmm0, (%rcx)
testq %rax, %rax
je 0xccb7
cmpq %rdi, 0x60(%rax)
jne 0xcd21
andq $0x0, 0x60(%rax)
popq %rax
retq
leaq 0x1ce9(%rip), %rdi      # 0xe9a9
leaq 0x1cfc(%rip), %rsi      # 0xe9c3
leaq 0x1cfe(%rip), %rcx      # 0xe9cc
pushq $0x64
jmp 0xcd1b
leaq 0x1d14(%rip), %rdi      # 0xe9ed
leaq 0x1ce3(%rip), %rsi      # 0xe9c3
leaq 0x1ce5(%rip), %rcx      # 0xe9cc
pushq $0x65
jmp 0xcd1b
leaq 0x1d16(%rip), %rdi      # 0xea08
leaq 0x1cca(%rip), %rsi      # 0xe9c3
leaq 0x1ccc(%rip), %rcx      # 0xe9cc
pushq $0x69
jmp 0xcd1b
leaq 0x1d20(%rip), %rdi      # 0xea2b
leaq 0x1cb1(%rip), %rsi      # 0xe9c3
leaq 0x1cb3(%rip), %rcx      # 0xe9cc
pushq $0x7c
popq %rdx
callq 0x4210
leaq 0x1d25(%rip), %rdi      # 0xea4d
leaq 0x1c94(%rip), %rsi      # 0xe9c3
leaq 0x1c96(%rip), %rcx      # 0xe9cc
movl $0x90, %edx
callq 0x4210