// File: /workspace/github_cpp_makefile_star2_O3/UTSASRG[P]Guarder/./bibopheap.hh
// Function: BibopHeap::BibopObjCache::getRandomObject(bool)
uintptr_t getRandomObject(bool doReplacement = false) {
					unsigned index;
					//unsigned numTries = 1;
					void * object;

					// Obtain a random number between [0, opts.bibop_cache_size)
					index = getRandomNumber() & BIBOP_CACHE_SIZE_MASK;
					object = _objects[index];

					PRDBG("trying object %p at index %d...", object, index);
					// Find the next sequential cache region with objects available for use
					if(!object) {
							int i;
							unsigned cacheRegionNumber = index >> CACHE_REGION_SIZE_SHIFT_BITS;
							unsigned tryRegionNumber;

							PRDBG(" ... didn't work, current region = %d, searching regions...", cacheRegionNumber);
							for(i = cacheRegionNumber; i < cacheRegionNumber + NUM_CACHE_REGIONS; i++) {
									tryRegionNumber = i & NUM_CACHE_REGIONS_MASK;
									//numTries++;
									if(_regionCounters[tryRegionNumber] == UNINITIALIZED_CACHE_REGION) {
											initialPopulate();
											break;
									} else if(_regionCounters[tryRegionNumber] > 0) {
											PRDBG(" ... using region = %d, has %d objects", tryRegionNumber, _regionCounters[tryRegionNumber]);
											break;
									} else {
											PRDBG(" ... region %d has no objects, moving on...", tryRegionNumber);
									}
							}

							// Attempt to use a "random" object from this region
							// (add +1 to index in order to avoid rehecking the same object if the
							// same cache region is chosen by the for-loop above).
							index = (tryRegionNumber << CACHE_REGION_SIZE_SHIFT_BITS) + ((index + 1) & CACHE_REGION_SIZE_MASK);
							object = _objects[index];
							PRDBG("	...trying first object (%p) in region %d, has index %d...", object, tryRegionNumber, index);

							// Now walk through the region's objects to find an available one
							// (that is, if the first object is unavailable)...
							//numTries++;
							while(!object) {
									PRDBG("cache conflict on index %u (object = %p, num used=%d); trying next item...",
													index, object, _numUsedObjects);

									// Try the next adjacent index, wrapping around if necessary...
									index++;
									if((index & CACHE_REGION_SIZE_MASK) == 0) {
											index = tryRegionNumber << CACHE_REGION_SIZE_SHIFT_BITS;
									}

									object = _objects[index];
									//numTries++;
							}
					}
					unsigned currentRegion = index >> CACHE_REGION_SIZE_SHIFT_BITS;
					//PRINT("numTries %u numAvailObjs %u curRegion %d regionObjects %d",
					//				numTries, (BibopHeap::_cacheSize - _numUsedObjects), currentRegion, _regionCounters[currentRegion]);

					// If desired, we will replace the randomly selected object with a
					// fresh object from the free cache, if one is available to use.
					if(doReplacement && (_freeCache->getNumObjects() > 0)) {
							PRDBG("freecache has free objects, doing replacement of cache index %u", index);
							_objects[index] = _freeCache->getNext();
					} else {
							// mark the object as NULL in _objects array to indicate
							// it is no longer available
							PRDBG("writing NULL to used cache index: cache @ %p, entry @ %p equals %p; index=%u",
											_objects, &_objects[index], _objects[index], index);
							_objects[index] = NULL;
							_numUsedObjects++;
							
							PRDBG("_regionCounters[%d]-- (index = %d)", currentRegion, index);
							_regionCounters[currentRegion]--;
							assert(_regionCounters[currentRegion] >= 0);
					}

					PRDBG("getRandomObject() returning %p", object);
					return (uintptr_t)object;
			}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, 0x10(%rsp)
movq %rdi, %rbx
callq 0x40a0
movq 0x58fb(%rip), %rbp      # 0xcf20
movl 0x8(%rbp), %r14d
decl %r14d
andl %eax, %r14d
movq 0x58(%rbx), %rax
movq (%rax,%r14,8), %r15
callq 0x41e0
movq %rax, %r12
callq 0x4250
movq %rax, %r13
leaq 0x29a5(%rip), %rdx      # 0x9ff3
leaq 0x1f35(%rip), %r8       # 0x958a
movl $0x1000, %esi           # imm = 0x1000
movq %r12, %rdi
movq %rax, %rcx
movl $0x25c, %r9d            # imm = 0x25C
xorl %eax, %eax
pushq %r14
pushq %r15
callq 0x4490
addq $0x10, %rsp
callq 0x41e0
movq %rax, %r12
callq 0x41e0
movq %rax, %rdi
callq 0x4120
movl $0x2, %edi
movq %r12, %rsi
movq %rax, %rdx
callq 0x40f0
movl 0x8(%rbp), %eax
testq %r15, %r15
movq %r13, 0x8(%rsp)
jne 0x7938
shrl $0x3, %eax
bsrl %eax, %ecx
movl %r14d, %ebp
shrl %cl, %ebp
callq 0x41e0
subq $0x8, %rsp
leaq 0x296d(%rip), %rdx      # 0xa033
leaq 0x1ebd(%rip), %r8       # 0x958a
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
movq %r13, %rcx
movl $0x263, %r9d            # imm = 0x263
xorl %eax, %eax
pushq %rbp
callq 0x4490
addq $0x10, %rsp
callq 0x41e0
movq %rax, %r15
callq 0x41e0
movq %rax, %rdi
callq 0x4120
movl $0x2, %edi
movq %r15, %rsi
movq %rax, %rdx
callq 0x40f0
cmpl $-0x9, %ebp
ja 0x7801
xorl %r15d, %r15d
leal (%r15,%rbp), %r12d
andl $0x7, %r12d
movl 0x34(%rbx,%r12,4), %eax
testl %eax, %eax
jne 0x7793
callq 0x41e0
subq $0x8, %rsp
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
leaq 0x2992(%rip), %rdx      # 0xa0d6
movq 0x10(%rsp), %rcx
leaq 0x1e3a(%rip), %r8       # 0x958a
movl $0x26e, %r9d            # imm = 0x26E
xorl %eax, %eax
pushq %r12
callq 0x4490
addq $0x10, %rsp
callq 0x41e0
movq %rax, %r13
callq 0x41e0
movq %rax, %rdi
callq 0x4120
movl $0x2, %edi
movq %r13, %rsi
movq %rax, %rdx
callq 0x40f0
incl %r15d
cmpl $0x8, %r15d
jne 0x771b
jmp 0x7801
cmpl $-0x1, %eax
jne 0x77a2
movq %rbx, %rdi
callq 0x4450
jmp 0x7801
callq 0x41e0
movl 0x34(%rbx,%r12,4), %r10d
leaq 0x28dc(%rip), %rdx      # 0xa08f
leaq 0x1dd0(%rip), %r8       # 0x958a
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
movq 0x8(%rsp), %rcx
movl $0x26b, %r9d            # imm = 0x26B
xorl %eax, %eax
pushq %r10
pushq %r12
callq 0x4490
addq $0x10, %rsp
callq 0x41e0
movq %rax, %r15
callq 0x41e0
movq %rax, %rdi
callq 0x4120
movl $0x2, %edi
movq %r15, %rsi
movq %rax, %rdx
callq 0x40f0
movq 0x5718(%rip), %rbp      # 0xcf20
movl 0x8(%rbp), %eax
shrl $0x3, %eax
bsrl %eax, %ecx
movl %r12d, %edx
shll %cl, %edx
incl %r14d
decl %eax
andl %r14d, %eax
movl %eax, %r14d
addl %edx, %r14d
movq 0x58(%rbx), %rax
movq (%rax,%r14,8), %r15
callq 0x41e0
subq $0x8, %rsp
leaq 0x28e6(%rip), %rdx      # 0xa122
leaq 0x1d47(%rip), %r8       # 0x958a
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
movq 0x10(%rsp), %rcx
movl $0x277, %r9d            # imm = 0x277
xorl %eax, %eax
pushq %r14
pushq %r12
pushq %r15
callq 0x4490
addq $0x20, %rsp
callq 0x41e0
movq %rax, %r13
callq 0x41e0
movq %rax, %rdi
callq 0x4120
movl $0x2, %edi
movq %r13, %rsi
movq %rax, %rdx
callq 0x40f0
testq %r15, %r15
je 0x7899
movl 0x8(%rbp), %eax
jmp 0x7938
movl %r14d, %ebp
movq 0x8(%rsp), %r13
callq 0x41e0
movl 0x2c(%rbx), %r10d
subq $0x8, %rsp
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
leaq 0x28c0(%rip), %rdx      # 0xa17d
movq %r13, %rcx
leaq 0x1cc3(%rip), %r8       # 0x958a
movl $0x27e, %r9d            # imm = 0x27E
xorl %eax, %eax
pushq %r10
pushq $0x0
pushq %rbp
callq 0x4490
addq $0x20, %rsp
callq 0x41e0
movq %rax, %r15
callq 0x41e0
movq %rax, %rdi
callq 0x4120
movl $0x2, %edi
movq %r15, %rsi
movq %rax, %rdx
callq 0x40f0
incl %ebp
movq 0x5615(%rip), %rax      # 0xcf20
movl 0x8(%rax), %eax
movl %eax, %edx
shrl $0x3, %edx
bsrl %edx, %ecx
movl %r12d, %r14d
shll %cl, %r14d
decl %edx
testl %ebp, %edx
cmovnel %ebp, %r14d
movq 0x58(%rbx), %rcx
movq (%rcx,%r14,8), %r15
movl %r14d, %ebp
testq %r15, %r15
je 0x78a1
shrl $0x3, %eax
bsrl %eax, %ecx
movl %r14d, %ebp
shrl %cl, %ebp
cmpb $0x0, 0x10(%rsp)
je 0x79d1
movq 0x8(%rbx), %rax
cmpq $0x0, 0x38(%rax)
je 0x79d1
callq 0x41e0
subq $0x8, %rsp
leaq 0x287f(%rip), %rdx      # 0xa1e8
leaq 0x1c1a(%rip), %r8       # 0x958a
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
movq 0x10(%rsp), %r13
movq %r13, %rcx
movl $0x291, %r9d            # imm = 0x291
xorl %eax, %eax
pushq %r14
callq 0x4490
addq $0x10, %rsp
callq 0x41e0
movq %rax, %r12
callq 0x41e0
movq %rax, %rdi
callq 0x4120
movl $0x2, %edi
movq %r12, %rsi
movq %rax, %rdx
callq 0x40f0
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
callq *(%rax)
movq 0x58(%rbx), %rcx
movl %r14d, %edx
movq %rax, (%rcx,%rdx,8)
jmp 0x7ab7
callq 0x41e0
movq 0x58(%rbx), %r10
movl %r14d, %ecx
movq %rcx, 0x10(%rsp)
leaq (%r10,%rcx,8), %r11
leaq 0x285b(%rip), %rdx      # 0xa248
leaq 0x1b96(%rip), %r8       # 0x958a
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
movq 0x8(%rsp), %r12
movq %r12, %rcx
movl $0x297, %r9d            # imm = 0x297
xorl %eax, %eax
pushq %r14
pushq (%r11)
pushq %r11
pushq %r10
callq 0x4490
addq $0x20, %rsp
callq 0x41e0
movq %rax, %r13
callq 0x41e0
movq %rax, %rdi
callq 0x4120
movl $0x2, %edi
movq %r13, %rsi
movq %r12, %r13
movq %rax, %rdx
callq 0x40f0
movq 0x58(%rbx), %rax
movq 0x10(%rsp), %rcx
movq $0x0, (%rax,%rcx,8)
incl 0x2c(%rbx)
callq 0x41e0
leaq 0x284f(%rip), %rdx      # 0xa2b5
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
movq %r12, %rcx
leaq 0x1b12(%rip), %r8       # 0x958a
movl $0x29b, %r9d            # imm = 0x29B
xorl %eax, %eax
pushq %r14
pushq %rbp
callq 0x4490
addq $0x10, %rsp
callq 0x41e0
movq %rax, %r12
callq 0x41e0
movq %rax, %rdi
callq 0x4120
movl $0x2, %edi
movq %r12, %rsi
movq %rax, %rdx
callq 0x40f0
movl %ebp, %eax
decl 0x34(%rbx,%rax,4)
callq 0x41e0
subq $0x8, %rsp
leaq 0x2831(%rip), %rdx      # 0xa2f8
leaq 0x1abc(%rip), %r8       # 0x958a
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
movq %r13, %rcx
movl $0x2a0, %r9d            # imm = 0x2A0
xorl %eax, %eax
pushq %r15
callq 0x4490
addq $0x10, %rsp
callq 0x41e0
movq %rax, %rbx
callq 0x41e0
movq %rax, %rdi
callq 0x4120
movl $0x2, %edi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x40f0
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop