// File: /workspace/github_c_makefile_star2_O0/gplessis[P]dotdeb-redis/deps/jemalloc/include/jemalloc/internal/arena.h
// Function: je_arena_run_regind
JEMALLOC_INLINE unsigned
arena_run_regind(arena_run_t *run, arena_bin_info_t *bin_info, const void *ptr)
{
	unsigned shift, diff, regind;
	size_t interval;
	arena_chunk_map_misc_t *miscelm = arena_run_to_miscelm(run);
	void *rpages = arena_miscelm_to_rpages(miscelm);

	/*
	 * Freeing a pointer lower than region zero can cause assertion
	 * failure.
	 */
	assert((uintptr_t)ptr >= (uintptr_t)rpages +
	    (uintptr_t)bin_info->reg0_offset);

	/*
	 * Avoid doing division with a variable divisor if possible.  Using
	 * actual division here can reduce allocator throughput by over 20%!
	 */
	diff = (unsigned)((uintptr_t)ptr - (uintptr_t)rpages -
	    bin_info->reg0_offset);

	/* Rescale (factor powers of 2 out of the numerator and denominator). */
	interval = bin_info->reg_interval;
	shift = jemalloc_ffs(interval) - 1;
	diff >>= shift;
	interval >>= shift;

	if (interval == 1) {
		/* The divisor was a power of 2. */
		regind = diff;
	} else {
		/*
		 * To divide by a number D that is not a power of two we
		 * multiply by (2^21 / D) and then right shift by 21 positions.
		 *
		 *   X / D
		 *
		 * becomes
		 *
		 *   (X * interval_invs[D - 3]) >> SIZE_INV_SHIFT
		 *
		 * We can omit the first three elements, because we never
		 * divide by 0, and 1 and 2 are both powers of two, which are
		 * handled above.
		 */
#define	SIZE_INV_SHIFT	((sizeof(unsigned) << 3) - LG_RUN_MAXREGS)
#define	SIZE_INV(s)	(((1U << SIZE_INV_SHIFT) / (s)) + 1)
		static const unsigned interval_invs[] = {
		    SIZE_INV(3),
		    SIZE_INV(4), SIZE_INV(5), SIZE_INV(6), SIZE_INV(7),
		    SIZE_INV(8), SIZE_INV(9), SIZE_INV(10), SIZE_INV(11),
		    SIZE_INV(12), SIZE_INV(13), SIZE_INV(14), SIZE_INV(15),
		    SIZE_INV(16), SIZE_INV(17), SIZE_INV(18), SIZE_INV(19),
		    SIZE_INV(20), SIZE_INV(21), SIZE_INV(22), SIZE_INV(23),
		    SIZE_INV(24), SIZE_INV(25), SIZE_INV(26), SIZE_INV(27),
		    SIZE_INV(28), SIZE_INV(29), SIZE_INV(30), SIZE_INV(31)
		};

		if (likely(interval <= ((sizeof(interval_invs) /
		    sizeof(unsigned)) + 2))) {
			regind = (diff * interval_invs[interval - 3]) >>
			    SIZE_INV_SHIFT;
		} else
			regind = diff / interval;
#undef SIZE_INV
#undef SIZE_INV_SHIFT
	}
	assert(diff == regind * interval);
	assert(regind < bin_info->nregs);

	return (regind);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rax
movq %rdi, -0x50(%rbp)
movq %rsi, -0x58(%rbp)
movq %rdx, -0x60(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
subq $0x10, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
leaq 0x54790(%rip), %rcx     # 0xa2730
movq (%rcx), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
leaq 0x5476f(%rip), %rcx     # 0xa2730
movq (%rcx), %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
addq 0x54602(%rip), %rcx     # 0xa25e0
subq %rcx, %rax
movl $0x60, %ecx
xorl %edx, %edx
divq %rcx
addq 0x545e6(%rip), %rax     # 0xa25d8
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
shlq $0xc, %rcx
addq %rcx, %rax
movq %rax, -0x88(%rbp)
jmp 0x4e016
movq -0x60(%rbp), %rax
movq -0x88(%rbp), %rcx
subq %rcx, %rax
movq -0x58(%rbp), %rcx
movl 0x58(%rcx), %ecx
subq %rcx, %rax
movl %eax, -0x68(%rbp)
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %edx
tzcntl %edx, %eax
addl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovel %ecx, %eax
subl $0x1, %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %ecx
movl -0x68(%rbp), %eax
shrl %cl, %eax
movl %eax, -0x68(%rbp)
movl -0x64(%rbp), %ecx
movq -0x78(%rbp), %rax
movl %ecx, %ecx
shrq %cl, %rax
movq %rax, -0x78(%rbp)
cmpq $0x1, -0x78(%rbp)
jne 0x4e086
movl -0x68(%rbp), %eax
movl %eax, -0x6c(%rbp)
jmp 0x4e0cd
cmpq $0x1f, -0x78(%rbp)
setbe %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
cltq
cmpq $0x0, %rax
je 0x4e0bd
movl -0x68(%rbp), %eax
movq -0x78(%rbp), %rdx
subq $0x3, %rdx
leaq 0x40fff(%rip), %rcx     # 0x8f0b0
imull (%rcx,%rdx,4), %eax
shrl $0x17, %eax
movl %eax, -0x6c(%rbp)
jmp 0x4e0cb
movl -0x68(%rbp), %eax
xorl %ecx, %ecx
movl %ecx, %edx
divq -0x78(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x4e0cd
jmp 0x4e0cf
jmp 0x4e0d1
jmp 0x4e0d3
jmp 0x4e0d5
movl -0x6c(%rbp), %eax
addq $0x8, %rsp
popq %rbp
retq
nop