// File: UTSASRG[P]Guarder/./bibopheap.hh
// Function: BibopHeap::BibopObjCache::getNext()
void * getNext() {
					if(_heapTop >= _bagEnd) {
							FATAL("heap out of memory (bag size = %lu)", _bibopBagSize);
					}

					uintptr_t foundNextObject = 0;
					do {
							// Repopulate the over provisioning buffer, if necessary...
							if(_nextUp >= BibopHeap::_overProvObjBufSize) {
									int i;
									for(i = 0; i < BibopHeap::_overProvObjBufSize; i++) {
											#ifdef RANDOM_GUARD
											if((_heapTop & PageMask) == 0) {
													tryRandomGuardPage(&_heapTop);
											}
											#endif

											// Use the top-of-bag pointer to satisfy this request
											_nextObjs[i] = _heapTop;
											// Bump the top-of-bag pointer to point to next object
											_heapTop += _classSize;
									}
									// Now kill a portion of these objects in accordance with
									// the over-provisioning ratio
									for(i = 0; i < NUM_DEAD_OBJS; i++) {
											unsigned randIndex = getRandomNumber() % BibopHeap::_overProvObjBufSize;

											// Perform a forward sequential search if the
											// object we selected for sacrifice is already dead
											while(_nextObjs[randIndex] == 0) {
													randIndex = (randIndex + 1) % BibopHeap::_overProvObjBufSize;
											}
											_nextObjs[randIndex] = 0;		// Mark selected index as a dead object
									}
									_nextUp = 0;
							}

							// Try the next object in the over-provisioning buffer...
							foundNextObject = _nextObjs[_nextUp++];
					} while(foundNextObject == 0);
					//PRDBG("\theap top returning object @ 0x%lx", foundNextObject);
		
					return (void *)foundNextObject;
			}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rcx
movq %rcx, -0x20(%rbp)
movq 0x20(%rcx), %rax
cmpq 0x18(%rcx), %rax
jb 0x8492
callq 0x52d0
movq %rax, -0x30(%rbp)
callq 0x5400
movq -0x30(%rbp), %rdi
movq %rax, %rcx
movq 0x8b6e(%rip), %rax      # 0x10fa8
movq (%rax), %rax
movl $0x1000, %esi           # imm = 0x1000
leaq 0x40ca(%rip), %rdx      # 0xc513
leaq 0x4112(%rip), %r8       # 0xc562
movl $0x1ce, %r9d            # imm = 0x1CE
movq %rax, (%rsp)
movb $0x0, %al
callq 0x57e0
callq 0x52d0
movq %rax, -0x28(%rbp)
callq 0x52d0
movq %rax, %rdi
callq 0x51e0
movq -0x28(%rbp), %rsi
movq %rax, %rdx
movl $0x2, %edi
callq 0x5160
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x55b0
movq $0x0, -0x10(%rbp)
movq -0x20(%rbp), %rax
movl 0x28(%rax), %eax
movq 0x8af0(%rip), %rcx      # 0x10f98
cmpl (%rcx), %eax
jb 0x859c
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq 0x8ad7(%rip), %rcx      # 0x10f98
cmpl (%rcx), %eax
jae 0x84f0
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rsi
movq 0x60(%rax), %rcx
movslq -0x14(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movq 0x10(%rax), %rcx
addq 0x20(%rax), %rcx
movq %rcx, 0x20(%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x84b7
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x34(%rbp)
movq 0x8a14(%rip), %rax      # 0x10f18
movl 0x8(%rax), %eax
shrl %eax
movq 0x8a08(%rip), %rcx      # 0x10f18
movl 0xc(%rcx), %ecx
movq 0x89fe(%rip), %rdx      # 0x10f18
subl 0x10(%rdx), %ecx
imull %ecx, %eax
movq 0x89f1(%rip), %rcx      # 0x10f18
xorl %edx, %edx
divl 0xc(%rcx)
movl %eax, %ecx
movl -0x34(%rbp), %eax
cmpl %ecx, %eax
jae 0x8591
callq 0x5520
movq 0x8a57(%rip), %rcx      # 0x10f98
xorl %edx, %edx
divl (%rcx)
movl %edx, -0x18(%rbp)
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x18(%rbp), %ecx
cmpq $0x0, (%rax,%rcx,8)
jne 0x8570
movl -0x18(%rbp), %eax
addl $0x1, %eax
movq 0x8a31(%rip), %rcx      # 0x10f98
xorl %edx, %edx
divl (%rcx)
movl %edx, -0x18(%rbp)
jmp 0x8548
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x18(%rbp), %ecx
movq $0x0, (%rax,%rcx,8)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x84f7
movq -0x20(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x20(%rbp), %rdx
movq 0x60(%rdx), %rax
movl 0x28(%rdx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x28(%rdx)
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x849a
movq -0x10(%rbp), %rax
addq $0x40, %rsp
popq %rbp
retq
nop