// File: /workspace/github_c_makefile_star2_O0/nilyang[P]redis-tdd-annotation/deps/jemalloc/src/arena.c
// Function: bin_info_run_size_calc
static size_t
bin_info_run_size_calc(arena_bin_info_t *bin_info, size_t min_run_size)
{
	size_t pad_size;
	size_t try_run_size, good_run_size;
	uint32_t try_nregs, good_nregs;
	uint32_t try_hdr_size, good_hdr_size;
	uint32_t try_bitmap_offset, good_bitmap_offset;
	uint32_t try_ctx0_offset, good_ctx0_offset;
	uint32_t try_redzone0_offset, good_redzone0_offset;

	assert(min_run_size >= PAGE);
	assert(min_run_size <= arena_maxclass);

	/*
	 * Determine redzone size based on minimum alignment and minimum
	 * redzone size.  Add padding to the end of the run if it is needed to
	 * align the regions.  The padding allows each redzone to be half the
	 * minimum alignment; without the padding, each redzone would have to
	 * be twice as large in order to maintain alignment.
	 */
	if (config_fill && opt_redzone) {
		size_t align_min = ZU(1) << (ffs(bin_info->reg_size) - 1);
		if (align_min <= REDZONE_MINSIZE) {
			bin_info->redzone_size = REDZONE_MINSIZE;
			pad_size = 0;
		} else {
			bin_info->redzone_size = align_min >> 1;
			pad_size = bin_info->redzone_size;
		}
	} else {
		bin_info->redzone_size = 0;
		pad_size = 0;
	}
	bin_info->reg_interval = bin_info->reg_size +
	    (bin_info->redzone_size << 1);

	/*
	 * Calculate known-valid settings before entering the run_size
	 * expansion loop, so that the first part of the loop always copies
	 * valid settings.
	 *
	 * The do..while loop iteratively reduces the number of regions until
	 * the run header and the regions no longer overlap.  A closed formula
	 * would be quite messy, since there is an interdependency between the
	 * header's mask length and the number of regions.
	 */
	try_run_size = min_run_size;
	try_nregs = ((try_run_size - sizeof(arena_run_t)) /
	    bin_info->reg_interval)
	    + 1; /* Counter-act try_nregs-- in loop. */
	if (try_nregs > RUN_MAXREGS) {
		try_nregs = RUN_MAXREGS
		    + 1; /* Counter-act try_nregs-- in loop. */
	}
	do {
		try_nregs--;
		try_hdr_size = sizeof(arena_run_t);
		/* Pad to a long boundary. */
		try_hdr_size = LONG_CEILING(try_hdr_size);
		try_bitmap_offset = try_hdr_size;
		/* Add space for bitmap. */
		try_hdr_size += bitmap_size(try_nregs);
		if (config_prof && opt_prof && prof_promote == false) {
			/* Pad to a quantum boundary. */
			try_hdr_size = QUANTUM_CEILING(try_hdr_size);
			try_ctx0_offset = try_hdr_size;
			/* Add space for one (prof_ctx_t *) per region. */
			try_hdr_size += try_nregs * sizeof(prof_ctx_t *);
		} else
			try_ctx0_offset = 0;
		try_redzone0_offset = try_run_size - (try_nregs *
		    bin_info->reg_interval) - pad_size;
	} while (try_hdr_size > try_redzone0_offset);

	/* run_size expansion loop. */
	do {
		/*
		 * Copy valid settings before trying more aggressive settings.
		 */
		good_run_size = try_run_size;
		good_nregs = try_nregs;
		good_hdr_size = try_hdr_size;
		good_bitmap_offset = try_bitmap_offset;
		good_ctx0_offset = try_ctx0_offset;
		good_redzone0_offset = try_redzone0_offset;

		/* Try more aggressive settings. */
		try_run_size += PAGE;
		try_nregs = ((try_run_size - sizeof(arena_run_t) - pad_size) /
		    bin_info->reg_interval)
		    + 1; /* Counter-act try_nregs-- in loop. */
		if (try_nregs > RUN_MAXREGS) {
			try_nregs = RUN_MAXREGS
			    + 1; /* Counter-act try_nregs-- in loop. */
		}
		do {
			try_nregs--;
			try_hdr_size = sizeof(arena_run_t);
			/* Pad to a long boundary. */
			try_hdr_size = LONG_CEILING(try_hdr_size);
			try_bitmap_offset = try_hdr_size;
			/* Add space for bitmap. */
			try_hdr_size += bitmap_size(try_nregs);
			if (config_prof && opt_prof && prof_promote == false) {
				/* Pad to a quantum boundary. */
				try_hdr_size = QUANTUM_CEILING(try_hdr_size);
				try_ctx0_offset = try_hdr_size;
				/*
				 * Add space for one (prof_ctx_t *) per region.
				 */
				try_hdr_size += try_nregs *
				    sizeof(prof_ctx_t *);
			}
			try_redzone0_offset = try_run_size - (try_nregs *
			    bin_info->reg_interval) - pad_size;
		} while (try_hdr_size > try_redzone0_offset);
	} while (try_run_size <= arena_maxclass
	    && try_run_size <= arena_maxclass
	    && RUN_MAX_OVRHD * (bin_info->reg_interval << 3) >
	    RUN_MAX_OVRHD_RELAX
	    && (try_redzone0_offset << RUN_BFP) > RUN_MAX_OVRHD * try_run_size
	    && try_nregs < RUN_MAXREGS);

	assert(good_hdr_size <= good_redzone0_offset);

	/* Copy final settings. */
	bin_info->run_size = good_run_size;
	bin_info->nregs = good_nregs;
	bin_info->bitmap_offset = good_bitmap_offset;
	bin_info->ctx0_offset = good_ctx0_offset;
	bin_info->reg0_offset = good_redzone0_offset + bin_info->redzone_size;

	assert(bin_info->reg0_offset - bin_info->redzone_size + (bin_info->nregs
	    * bin_info->reg_interval) + pad_size == bin_info->run_size);

	return (good_run_size);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
jmp 0xbf9d2
jmp 0xbf9d4
jmp 0xbf9d6
leaq 0x68adb(%rip), %rax     # 0x1284b8
testb $0x1, (%rax)
je 0xbfa3d
movq -0x8(%rbp), %rax
movq (%rax), %rax
movl %eax, %edi
callq 0x1f740
subl $0x1, %eax
movl %eax, %eax
movl %eax, %ecx
movl $0x1, %eax
shlq %cl, %rax
movq %rax, -0x58(%rbp)
cmpq $0x10, -0x58(%rbp)
ja 0xbfa20
movq -0x8(%rbp), %rax
movq $0x10, 0x8(%rax)
movq $0x0, -0x18(%rbp)
jmp 0xbfa3b
movq -0x58(%rbp), %rcx
shrq %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0xbfa51
movq -0x8(%rbp), %rax
movq $0x0, 0x8(%rax)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
shlq %rax
addq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
subq $0x10, %rax
movq -0x8(%rbp), %rcx
xorl %edx, %edx
divq 0x10(%rcx)
addq $0x1, %rax
movl %eax, -0x2c(%rbp)
cmpl $0x800, -0x2c(%rbp)     # imm = 0x800
jbe 0xbfa9f
movl $0x801, -0x2c(%rbp)     # imm = 0x801
jmp 0xbfaa1
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
movl $0x10, -0x34(%rbp)
movl -0x34(%rbp), %eax
addq $0x7, %rax
andq $-0x8, %rax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, %edi
callq 0xc0100
movq %rax, %rcx
movl -0x34(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x34(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x20(%rbp), %rax
movl -0x2c(%rbp), %ecx
movq -0x8(%rbp), %rdx
imulq 0x10(%rdx), %rcx
subq %rcx, %rax
subq -0x18(%rbp), %rax
movl %eax, -0x4c(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x4c(%rbp), %eax
ja 0xbfaa1
jmp 0xbfb06
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x50(%rbp)
movq -0x20(%rbp), %rax
addq $0x1000, %rax           # imm = 0x1000
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
subq $0x10, %rax
subq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
xorl %edx, %edx
divq 0x10(%rcx)
addq $0x1, %rax
movl %eax, -0x2c(%rbp)
cmpl $0x800, -0x2c(%rbp)     # imm = 0x800
jbe 0xbfb67
movl $0x801, -0x2c(%rbp)     # imm = 0x801
jmp 0xbfb69
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
movl $0x10, -0x34(%rbp)
movl -0x34(%rbp), %eax
addq $0x7, %rax
andq $-0x8, %rax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, %edi
callq 0xc0100
movq %rax, %rcx
movl -0x34(%rbp), %eax
addq %rcx, %rax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movl -0x2c(%rbp), %ecx
movq -0x8(%rbp), %rdx
imulq 0x10(%rdx), %rcx
subq %rcx, %rax
subq -0x18(%rbp), %rax
movl %eax, -0x4c(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x4c(%rbp), %eax
ja 0xbfb69
jmp 0xbfbc7
movq -0x20(%rbp), %rcx
xorl %eax, %eax
leaq 0x696ac(%rip), %rdx     # 0x129280
cmpq (%rdx), %rcx
movb %al, -0x59(%rbp)
ja 0xbfc35
movq -0x20(%rbp), %rcx
xorl %eax, %eax
leaq 0x69697(%rip), %rdx     # 0x129280
cmpq (%rdx), %rcx
movb %al, -0x59(%rbp)
ja 0xbfc35
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
shlq $0x3, %rax
imulq $0x3d, %rax, %rcx
xorl %eax, %eax
cmpq $0x1800, %rcx           # imm = 0x1800
movb %al, -0x59(%rbp)
jbe 0xbfc35
movl -0x4c(%rbp), %eax
shll $0xc, %eax
movl %eax, %eax
movl %eax, %ecx
imulq $0x3d, -0x20(%rbp), %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x59(%rbp)
jbe 0xbfc35
cmpl $0x800, -0x2c(%rbp)     # imm = 0x800
setb %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0xbfb06
jmp 0xbfc42
jmp 0xbfc44
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x30(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x20(%rax)
movl -0x40(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x24(%rax)
movl -0x48(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x60(%rax)
movl -0x50(%rbp), %eax
movq -0x8(%rbp), %rcx
addq 0x8(%rcx), %rax
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x64(%rax)
jmp 0xbfc84
movq -0x28(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nop