// File: /workspace/github_cpp_makefile_star2_O2/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, 0x14(%rsp)
movq %rdi, %rbx
callq 0x40b0
movq 0x6a45(%rip), %rbp      # 0xdf20
movl 0x8(%rbp), %r14d
decl %r14d
andl %eax, %r14d
movq 0x58(%rbx), %rax
movq (%rax,%r14,8), %r15
callq 0x4200
movq %rax, %r12
callq 0x4280
movq %rax, %r13
leaq 0x2adf(%rip), %rdx      # 0x9fe3
leaq 0x206f(%rip), %r8       # 0x957a
movl $0x1000, %esi           # imm = 0x1000
movq %r12, %rdi
movq %rax, %rcx
movl $0x25c, %r9d            # imm = 0x25C
xorl %eax, %eax
pushq %r14
pushq %r15
callq 0x4560
popq %rcx
popq %rdx
callq 0x4200
movq %rax, %r12
callq 0x4200
movq %rax, %rdi
callq 0x4130
pushq $0x2
popq %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x4100
movl 0x8(%rbp), %eax
testq %r15, %r15
movq %r13, 0x8(%rsp)
jne 0x77d9
shrl $0x3, %eax
bsrl %eax, %ecx
movl %r14d, %ebp
shrl %cl, %ebp
callq 0x4200
subq $0x8, %rsp
leaq 0x2aab(%rip), %rdx      # 0xa023
leaq 0x1ffb(%rip), %r8       # 0x957a
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
movq %r13, %rcx
movl $0x263, %r9d            # imm = 0x263
xorl %eax, %eax
pushq %rbp
callq 0x4560
popq %rcx
popq %rdx
callq 0x4200
movq %rax, %r12
callq 0x4200
movq %rax, %rdi
callq 0x4130
pushq $0x2
popq %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x4100
leal 0x8(%rbp), %r15d
cmpl %r15d, %ebp
jae 0x76a1
movl %ebp, %r12d
andl $0x7, %r12d
movl 0x34(%rbx,%r12,4), %eax
testl %eax, %eax
jne 0x7639
callq 0x4200
subq $0x8, %rsp
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
leaq 0x2ad4(%rip), %rdx      # 0xa0c6
movq %r13, %rcx
leaq 0x1f7e(%rip), %r8       # 0x957a
movl $0x26e, %r9d            # imm = 0x26E
xorl %eax, %eax
pushq %r12
callq 0x4560
popq %rcx
popq %rdx
callq 0x4200
movq %rax, %r13
callq 0x4200
movq %rax, %rdi
callq 0x4130
pushq $0x2
popq %rdi
movq %r13, %rsi
movq 0x8(%rsp), %r13
movq %rax, %rdx
callq 0x4100
incl %ebp
jmp 0x75c1
cmpl $-0x1, %eax
jne 0x7648
movq %rbx, %rdi
callq 0x4510
jmp 0x76a1
callq 0x4200
movl 0x34(%rbx,%r12,4), %r10d
leaq 0x2a26(%rip), %rdx      # 0xa07f
leaq 0x1f1a(%rip), %r8       # 0x957a
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
movq %r13, %rcx
movl $0x26b, %r9d            # imm = 0x26B
xorl %eax, %eax
pushq %r10
pushq %r12
callq 0x4560
popq %rcx
popq %rdx
callq 0x4200
movq %rax, %r15
callq 0x4200
movq %rax, %rdi
callq 0x4130
pushq $0x2
popq %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x4100
movq 0x6878(%rip), %rax      # 0xdf20
movl 0x8(%rax), %edx
shrl $0x3, %edx
bsrl %edx, %ecx
movl %r12d, %eax
shll %cl, %eax
incl %r14d
decl %edx
andl %r14d, %edx
addl %eax, %edx
movq 0x58(%rbx), %rax
movq (%rax,%rdx,8), %r15
movq %rdx, %r14
callq 0x4200
subq $0x8, %rsp
leaq 0x2a37(%rip), %rdx      # 0xa112
leaq 0x1e98(%rip), %r8       # 0x957a
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
movq %r13, %rcx
movl $0x277, %r9d            # imm = 0x277
xorl %eax, %eax
pushq %r14
pushq %r12
pushq %r15
callq 0x4560
addq $0x20, %rsp
callq 0x4200
movq %rax, %rbp
callq 0x4200
movq %rax, %rdi
callq 0x4130
pushq $0x2
popq %r13
movl %r13d, %edi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x4100
leaq 0x2a3b(%rip), %rbp      # 0xa16d
testq %r15, %r15
jne 0x77ca
callq 0x4200
movl 0x2c(%rbx), %r10d
subq $0x8, %rsp
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
movq %rbp, %rdx
movq 0x10(%rsp), %rcx
leaq 0x1e1b(%rip), %r8       # 0x957a
movl $0x27e, %r9d            # imm = 0x27E
xorl %eax, %eax
pushq %r10
pushq $0x0
pushq %r14
callq 0x4560
addq $0x20, %rsp
callq 0x4200
movq %rax, %r15
callq 0x4200
movq %rax, %rdi
callq 0x4130
movl %r13d, %edi
movq %r15, %rsi
movq %rax, %rdx
callq 0x4100
incl %r14d
movq 0x677d(%rip), %rax      # 0xdf20
movl 0x8(%rax), %eax
shrl $0x3, %eax
bsrl %eax, %ecx
movl %r12d, %edx
shll %cl, %edx
decl %eax
testl %r14d, %eax
cmovnel %r14d, %edx
movq 0x58(%rbx), %rax
movq (%rax,%rdx,8), %r15
movl %edx, %r14d
jmp 0x7732
movq 0x674f(%rip), %rax      # 0xdf20
movl 0x8(%rax), %eax
movq 0x8(%rsp), %r13
shrl $0x3, %eax
bsrl %eax, %ecx
movl %r14d, %ebp
shrl %cl, %ebp
cmpb $0x0, 0x14(%rsp)
je 0x7865
movq 0x8(%rbx), %rax
cmpq $0x0, 0x38(%rax)
je 0x7865
callq 0x4200
subq $0x8, %rsp
leaq 0x29d2(%rip), %rdx      # 0xa1d8
leaq 0x1d6d(%rip), %r8       # 0x957a
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
movq %r13, %rcx
movl $0x291, %r9d            # imm = 0x291
xorl %eax, %eax
pushq %r14
callq 0x4560
popq %rcx
popq %rdx
callq 0x4200
movq %rax, %r12
callq 0x4200
movq %rax, %rdi
callq 0x4130
pushq $0x2
popq %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x4100
movq 0x8(%rbx), %rdi
movq (%rdi), %rax
callq *(%rax)
movq 0x58(%rbx), %rcx
movl %r14d, %edx
movq %rax, (%rcx,%rdx,8)
jmp 0x7935
callq 0x4200
movq 0x58(%rbx), %r10
movl %r14d, %r12d
leaq (%r10,%r12,8), %r11
leaq 0x29bc(%rip), %rdx      # 0xa238
leaq 0x1cf7(%rip), %r8       # 0x957a
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
movq %r13, %rcx
movl $0x297, %r9d            # imm = 0x297
xorl %eax, %eax
pushq %r14
pushq (%r11)
pushq %r11
pushq %r10
callq 0x4560
addq $0x20, %rsp
callq 0x4200
movq %rax, %r13
callq 0x4200
movq %rax, %rdi
callq 0x4130
pushq $0x2
popq %rdi
movq %r13, %rsi
movq 0x8(%rsp), %r13
movq %rax, %rdx
callq 0x4100
movq 0x58(%rbx), %rax
andq $0x0, (%rax,%r12,8)
incl 0x2c(%rbx)
callq 0x4200
leaq 0x29bd(%rip), %rdx      # 0xa2a5
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
movq %r13, %rcx
leaq 0x1c80(%rip), %r8       # 0x957a
movl $0x29b, %r9d            # imm = 0x29B
xorl %eax, %eax
pushq %r14
pushq %rbp
callq 0x4560
popq %rcx
popq %rdx
callq 0x4200
movq %rax, %r12
callq 0x4200
movq %rax, %rdi
callq 0x4130
pushq $0x2
popq %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x4100
movl %ebp, %eax
decl 0x34(%rbx,%rax,4)
callq 0x4200
subq $0x8, %rsp
leaq 0x29a3(%rip), %rdx      # 0xa2e8
leaq 0x1c2e(%rip), %r8       # 0x957a
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rdi
movq %r13, %rcx
movl $0x2a0, %r9d            # imm = 0x2A0
xorl %eax, %eax
pushq %r15
callq 0x4560
popq %rcx
popq %rdx
callq 0x4200
movq %rax, %rbx
callq 0x4200
movq %rax, %rdi
callq 0x4130
pushq $0x2
popq %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x4100
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop