	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function get_best_segment
_get_best_segment:                      ## @get_best_segment
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %r14
	movq	%rdi, %rbx
	callq	_DSA_AREA_LOCK
	movl	%eax, %edi
	callq	_LWLockHeldByMe
	movl	%eax, %edi
	callq	_Assert
	movq	%rbx, %rdi
	callq	_check_for_freed_segments_locked
	movq	%r14, %rdi
	callq	_contiguous_pages_to_segment_bin
	movq	_DSA_NUM_SEGMENT_BINS@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rdx
	cmpq	%rdx, %rax
	jae	LBB0_13
## %bb.1:
	movq	_DSA_SEGMENT_INDEX_NONE@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rsi
	movq	%r14, -80(%rbp)                 ## 8-byte Spill
	movq	%rbx, -48(%rbp)                 ## 8-byte Spill
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_11:                                ##   in Loop: Header=BB0_2 Depth=1
	movq	_DSA_NUM_SEGMENT_BINS@GOTPCREL(%rip), %rax
	movq	(%rax), %rdx
	movq	-56(%rbp), %rax                 ## 8-byte Reload
LBB0_12:                                ##   in Loop: Header=BB0_2 Depth=1
	incq	%rax
	cmpq	%rdx, %rax
	jae	LBB0_13
LBB0_2:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_4 Depth 2
	leal	-1(%rax), %ecx
	movl	$1, %edi
                                        ## kill: def $cl killed $cl killed $ecx
	shlq	%cl, %rdi
	movq	(%rbx), %rcx
	movq	(%rcx), %rcx
	movq	(%rcx,%rax,8), %r12
	cmpq	%rsi, %r12
	je	LBB0_12
## %bb.3:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	movq	%rdi, -88(%rbp)                 ## 8-byte Spill
	jmp	LBB0_4
	.p2align	4, 0x90
LBB0_9:                                 ##   in Loop: Header=BB0_4 Depth=2
	movq	-80(%rbp), %r14                 ## 8-byte Reload
	cmpq	%r14, %r15
	jae	LBB0_14
LBB0_10:                                ##   in Loop: Header=BB0_4 Depth=2
	movq	%rbx, %r12
	movq	_DSA_SEGMENT_INDEX_NONE@GOTPCREL(%rip), %rax
	cmpq	(%rax), %rbx
	movq	%rbx, %rsi
	movq	-48(%rbp), %rbx                 ## 8-byte Reload
	je	LBB0_11
LBB0_4:                                 ##   Parent Loop BB0_2 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movq	%rbx, %rdi
	movq	%r12, %rsi
	callq	_get_segment_by_index
	movq	%rax, %r13
	movq	(%rax), %rax
	movq	(%rax), %rbx
	movl	8(%r13), %edi
	callq	_fpm_largest
	movq	-88(%rbp), %rdi                 ## 8-byte Reload
	movq	%rax, %r15
	cmpq	%rdi, %rax
	jb	LBB0_6
## %bb.5:                               ##   in Loop: Header=BB0_4 Depth=2
	cmpq	%r14, %r15
	jb	LBB0_10
LBB0_6:                                 ##   in Loop: Header=BB0_4 Depth=2
	cmpq	%rdi, %r15
	jae	LBB0_9
## %bb.7:                               ##   in Loop: Header=BB0_4 Depth=2
	movq	%r15, %rdi
	callq	_contiguous_pages_to_segment_bin
	movq	%rax, %r14
	movq	%rbx, -72(%rbp)                 ## 8-byte Spill
	movq	-48(%rbp), %rbx                 ## 8-byte Reload
	movq	%rbx, %rdi
	movq	%r13, %rsi
	callq	_unlink_segment
	movq	_DSA_SEGMENT_INDEX_NONE@GOTPCREL(%rip), %rdi
	movq	(%rdi), %rax
	movq	(%r13), %rcx
	movq	%rax, 16(%rcx)
	movq	(%rbx), %rax
	movq	-72(%rbp), %rbx                 ## 8-byte Reload
	movq	(%rax), %rax
	movq	(%rax,%r14,8), %rdx
	movq	%rdx, (%rcx)
	movq	%r14, 8(%rcx)
	movq	%r12, (%rax,%r14,8)
	movq	(%rcx), %rsi
	cmpq	(%rdi), %rsi
	je	LBB0_9
## %bb.8:                               ##   in Loop: Header=BB0_4 Depth=2
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_get_segment_by_index
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	movq	(%rax), %rcx
	xorl	%edi, %edi
	cmpq	%r14, 8(%rcx)
	sete	%dil
	callq	_Assert
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	movq	(%rax), %rax
	movq	%r12, 16(%rax)
	jmp	LBB0_9
LBB0_13:
	xorl	%r13d, %r13d
LBB0_14:
	movq	%r13, %rax
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_DSA_NUM_SEGMENT_BINS,8,3       ## @DSA_NUM_SEGMENT_BINS
	.comm	_DSA_SEGMENT_INDEX_NONE,8,3     ## @DSA_SEGMENT_INDEX_NONE
	.no_dead_strip	_get_best_segment
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function get_best_segment
_get_best_segment:                      ; @get_best_segment
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x19, x1
	mov	x20, x0
	bl	_DSA_AREA_LOCK
	bl	_LWLockHeldByMe
	bl	_Assert
	mov	x0, x20
	bl	_check_for_freed_segments_locked
	mov	x0, x19
	bl	_contiguous_pages_to_segment_bin
Lloh0:
	adrp	x8, _DSA_NUM_SEGMENT_BINS@GOTPAGE
Lloh1:
	ldr	x8, [x8, _DSA_NUM_SEGMENT_BINS@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	cmp	x0, x8
	b.hs	LBB0_12
; %bb.1:
Lloh3:
	adrp	x28, _DSA_SEGMENT_INDEX_NONE@GOTPAGE
Lloh4:
	ldr	x28, [x28, _DSA_SEGMENT_INDEX_NONE@GOTPAGEOFF]
	ldr	x27, [x28]
	b	LBB0_4
LBB0_2:                                 ;   in Loop: Header=BB0_4 Depth=1
Lloh5:
	adrp	x8, _DSA_NUM_SEGMENT_BINS@GOTPAGE
Lloh6:
	ldr	x8, [x8, _DSA_NUM_SEGMENT_BINS@GOTPAGEOFF]
Lloh7:
	ldr	x8, [x8]
	ldr	x0, [sp, #8]                    ; 8-byte Folded Reload
LBB0_3:                                 ;   in Loop: Header=BB0_4 Depth=1
	add	x0, x0, #1
	cmp	x0, x8
	b.hs	LBB0_12
LBB0_4:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_8 Depth 2
	ldr	x9, [x20]
	ldr	x9, [x9]
	ldr	x22, [x9, x0, lsl #3]
	cmp	x22, x27
	b.eq	LBB0_3
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	str	x0, [sp, #8]                    ; 8-byte Folded Spill
	sub	x8, x0, #1
	mov	w9, #1
	lsl	x21, x9, x8
	b	LBB0_8
LBB0_6:                                 ;   in Loop: Header=BB0_8 Depth=2
	cmp	x24, x19
	b.hs	LBB0_13
LBB0_7:                                 ;   in Loop: Header=BB0_8 Depth=2
	ldr	x8, [x28]
	mov	x22, x27
	cmp	x27, x8
	b.eq	LBB0_2
LBB0_8:                                 ;   Parent Loop BB0_4 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	mov	x0, x20
	mov	x1, x22
	bl	_get_segment_by_index
	mov	x23, x0
	ldr	x8, [x0]
	ldr	x27, [x8]
	ldr	w0, [x0, #8]
	bl	_fpm_largest
	cmp	x0, x21
	ccmp	x0, x19, #2, hs
	b.lo	LBB0_7
; %bb.9:                                ;   in Loop: Header=BB0_8 Depth=2
	mov	x24, x0
	cmp	x0, x21
	b.hs	LBB0_6
; %bb.10:                               ;   in Loop: Header=BB0_8 Depth=2
	mov	x0, x24
	bl	_contiguous_pages_to_segment_bin
	mov	x25, x0
	mov	x0, x20
	mov	x1, x23
	bl	_unlink_segment
	ldr	x8, [x28]
	ldr	x9, [x23]
	str	x8, [x9, #16]
	ldr	x8, [x20]
	ldr	x8, [x8]
	lsl	x10, x25, #3
	ldr	x11, [x8, x10]
	stp	x11, x25, [x9]
	str	x22, [x8, x10]
	ldr	x1, [x9]
	ldr	x8, [x28]
	cmp	x1, x8
	b.eq	LBB0_6
; %bb.11:                               ;   in Loop: Header=BB0_8 Depth=2
	mov	x0, x20
	bl	_get_segment_by_index
	mov	x26, x0
	ldr	x8, [x0]
	ldr	x8, [x8, #8]
	cmp	x8, x25
	cset	w0, eq
	bl	_Assert
	ldr	x8, [x26]
	str	x22, [x8, #16]
	b	LBB0_6
LBB0_12:
	mov	x23, #0
LBB0_13:
	mov	x0, x23
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.cfi_endproc
                                        ; -- End function
	.comm	_DSA_NUM_SEGMENT_BINS,8,3       ; @DSA_NUM_SEGMENT_BINS
	.comm	_DSA_SEGMENT_INDEX_NONE,8,3     ; @DSA_SEGMENT_INDEX_NONE
	.no_dead_strip	_get_best_segment
.subsections_via_symbols
