	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function vdbeSorterMergeTreeBuild
_vdbeSorterMergeTreeBuild:              ## @vdbeSorterMergeTreeBuild
	.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	$72, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, -104(%rbp)                ## 8-byte Spill
	movq	%rdi, %r15
	movq	_SQLITE_OK@GOTPCREL(%rip), %rax
	movl	(%rax), %r14d
	xorl	%r12d, %r12d
	movq	_SQLITE_MAX_WORKER_THREADS@GOTPCREL(%rip), %r13
	xorl	%eax, %eax
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	movq	%rdi, -80(%rbp)                 ## 8-byte Spill
	jmp	LBB0_1
	.p2align	4, 0x90
LBB0_19:                                ##   in Loop: Header=BB0_1 Depth=1
	movq	-48(%rbp), %rdi
	callq	_vdbeMergeEngineFree
LBB0_20:                                ##   in Loop: Header=BB0_1 Depth=1
	movq	-80(%rbp), %r15                 ## 8-byte Reload
	movq	-88(%rbp), %r12                 ## 8-byte Reload
	movq	_SQLITE_MAX_WORKER_THREADS@GOTPCREL(%rip), %r13
LBB0_21:                                ##   in Loop: Header=BB0_1 Depth=1
	incq	%r12
	cmpl	(%rbx), %r14d
	jne	LBB0_22
LBB0_1:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_13 Depth 2
	movslq	(%r15), %rax
	cmpq	%rax, %r12
	jge	LBB0_2
## %bb.3:                               ##   in Loop: Header=BB0_1 Depth=1
	movq	8(%r15), %rbx
	cmpq	$0, (%rbx,%r12,8)
	setg	%al
	cmpq	$0, (%r13)
	setg	%cl
	orb	%al, %cl
	movzbl	%cl, %edi
	callq	_assert
	cmpq	$0, (%r13)
	movq	(%rbx,%r12,8), %rdi
	je	LBB0_6
## %bb.4:                               ##   in Loop: Header=BB0_1 Depth=1
	testq	%rdi, %rdi
	jne	LBB0_6
## %bb.5:                               ##   in Loop: Header=BB0_1 Depth=1
	movq	_SQLITE_OK@GOTPCREL(%rip), %rbx
	jmp	LBB0_21
	.p2align	4, 0x90
LBB0_6:                                 ##   in Loop: Header=BB0_1 Depth=1
	leaq	(%rbx,%r12,8), %r15
	movq	$0, -48(%rbp)
	callq	_vdbeSorterTreeDepth
	movl	%eax, -68(%rbp)                 ## 4-byte Spill
	movl	$0, -52(%rbp)
	movq	(%r15), %rsi
	movq	_SORTER_MAX_MERGE_COUNT@GOTPCREL(%rip), %rax
	movslq	(%rax), %rdi
	cmpq	%rdi, %rsi
	movq	%r12, -88(%rbp)                 ## 8-byte Spill
	jle	LBB0_7
## %bb.8:                               ##   in Loop: Header=BB0_1 Depth=1
                                        ## kill: def $edi killed $edi killed $rdi
	callq	_vdbeMergeEngineNew
	movq	%rax, -48(%rbp)
	testq	%rax, %rax
	movq	_SQLITE_OK@GOTPCREL(%rip), %rbx
	jne	LBB0_10
## %bb.9:                               ##   in Loop: Header=BB0_1 Depth=1
	movq	_SQLITE_NOMEM_BKPT@GOTPCREL(%rip), %rax
	movl	(%rax), %r14d
LBB0_10:                                ##   in Loop: Header=BB0_1 Depth=1
	movq	(%r15), %rdi
	movl	(%rbx), %eax
	testq	%rdi, %rdi
	jle	LBB0_17
## %bb.11:                              ##   in Loop: Header=BB0_1 Depth=1
	cmpl	%eax, %r14d
	jne	LBB0_17
## %bb.12:                              ##   in Loop: Header=BB0_1 Depth=1
	movq	_SORTER_MAX_MERGE_COUNT@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	xorl	%r13d, %r13d
	xorl	%r12d, %r12d
	.p2align	4, 0x90
LBB0_13:                                ##   Parent Loop BB0_1 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movq	$0, -96(%rbp)
	subl	%r12d, %edi
                                        ## kill: def $edi killed $edi killed $rdi
	callq	_MIN
	movq	%r15, %rdi
	movl	%eax, %esi
	leaq	-52(%rbp), %rdx
	leaq	-96(%rbp), %rcx
	callq	_vdbeMergeEngineLevel0
	movl	%eax, %r14d
	movl	(%rbx), %eax
	cmpl	%eax, %r14d
	jne	LBB0_15
## %bb.14:                              ##   in Loop: Header=BB0_13 Depth=2
	leal	1(%r13), %ebx
	movq	-48(%rbp), %rcx
	movq	-96(%rbp), %r8
	movq	%r15, %rdi
	movl	-68(%rbp), %esi                 ## 4-byte Reload
	movl	%r13d, %edx
	callq	_vdbeSorterAddToTree
	movl	%eax, %r14d
	movq	_SQLITE_OK@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%ebx, %r13d
	movq	_SQLITE_OK@GOTPCREL(%rip), %rbx
LBB0_15:                                ##   in Loop: Header=BB0_13 Depth=2
	movq	_SORTER_MAX_MERGE_COUNT@GOTPCREL(%rip), %rcx
	movl	(%rcx), %esi
	addl	%esi, %r12d
	movslq	%r12d, %rcx
	movq	(%r15), %rdi
	cmpq	%rcx, %rdi
	jle	LBB0_17
## %bb.16:                              ##   in Loop: Header=BB0_13 Depth=2
	cmpl	%eax, %r14d
	je	LBB0_13
	jmp	LBB0_17
	.p2align	4, 0x90
LBB0_7:                                 ##   in Loop: Header=BB0_1 Depth=1
	movq	%r15, %rdi
                                        ## kill: def $esi killed $esi killed $rsi
	leaq	-52(%rbp), %rdx
	leaq	-48(%rbp), %rcx
	callq	_vdbeMergeEngineLevel0
	movl	%eax, %r14d
	movq	_SQLITE_OK@GOTPCREL(%rip), %rbx
	movl	(%rbx), %eax
LBB0_17:                                ##   in Loop: Header=BB0_1 Depth=1
	cmpl	%eax, %r14d
	jne	LBB0_19
## %bb.18:                              ##   in Loop: Header=BB0_1 Depth=1
	xorl	%edi, %edi
	cmpq	$0, -64(%rbp)                   ## 8-byte Folded Reload
	sete	%dil
	callq	_assert
	movq	-48(%rbp), %rax
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	jmp	LBB0_20
LBB0_22:
	movq	-64(%rbp), %rdi                 ## 8-byte Reload
	callq	_vdbeMergeEngineFree
	xorl	%ecx, %ecx
	jmp	LBB0_23
LBB0_2:
	movq	-64(%rbp), %rcx                 ## 8-byte Reload
LBB0_23:
	movq	-104(%rbp), %rax                ## 8-byte Reload
	movq	%rcx, (%rax)
	movl	%r14d, %eax
	addq	$72, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_SQLITE_OK,4,2                  ## @SQLITE_OK
	.comm	_SQLITE_MAX_WORKER_THREADS,8,3  ## @SQLITE_MAX_WORKER_THREADS
	.comm	_SORTER_MAX_MERGE_COUNT,4,2     ## @SORTER_MAX_MERGE_COUNT
	.comm	_SQLITE_NOMEM_BKPT,4,2          ## @SQLITE_NOMEM_BKPT
	.no_dead_strip	_vdbeSorterMergeTreeBuild
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function vdbeSorterMergeTreeBuild
_vdbeSorterMergeTreeBuild:              ; @vdbeSorterMergeTreeBuild
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #144
	.cfi_def_cfa_offset 144
	stp	x28, x27, [sp, #48]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #64]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #80]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #96]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #112]            ; 16-byte Folded Spill
	stp	x29, x30, [sp, #128]            ; 16-byte Folded Spill
	add	x29, sp, #128
	.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
	stp	x1, xzr, [sp, #8]               ; 16-byte Folded Spill
	mov	x21, x0
	mov	x26, #0
Lloh0:
	adrp	x27, _SQLITE_OK@GOTPAGE
Lloh1:
	ldr	x27, [x27, _SQLITE_OK@GOTPAGEOFF]
	ldr	w22, [x27]
Lloh2:
	adrp	x20, _SQLITE_MAX_WORKER_THREADS@GOTPAGE
Lloh3:
	ldr	x20, [x20, _SQLITE_MAX_WORKER_THREADS@GOTPAGEOFF]
Lloh4:
	adrp	x19, _SORTER_MAX_MERGE_COUNT@GOTPAGE
Lloh5:
	ldr	x19, [x19, _SORTER_MAX_MERGE_COUNT@GOTPAGEOFF]
	b	LBB0_4
LBB0_1:                                 ;   in Loop: Header=BB0_4 Depth=1
	ldr	x0, [sp, #40]
	bl	_vdbeMergeEngineFree
LBB0_2:                                 ;   in Loop: Header=BB0_4 Depth=1
Lloh6:
	adrp	x20, _SQLITE_MAX_WORKER_THREADS@GOTPAGE
Lloh7:
	ldr	x20, [x20, _SQLITE_MAX_WORKER_THREADS@GOTPAGEOFF]
LBB0_3:                                 ;   in Loop: Header=BB0_4 Depth=1
	add	x26, x26, #1
	ldr	w8, [x27]
	cmp	w22, w8
	b.ne	LBB0_16
LBB0_4:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_11 Depth 2
	ldrsw	x8, [x21]
	cmp	x26, x8
	b.ge	LBB0_17
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	x8, [x21, #8]
	add	x23, x8, x26, lsl #3
	ldr	x8, [x23]
	cmp	x8, #0
	ldr	x8, [x20]
	ccmp	x8, #0, #0, le
	cset	w0, gt
	bl	_assert
	ldr	x8, [x20]
	ldr	x0, [x23]
	cmp	x8, #0
	ccmp	x0, #0, #0, ne
	b.eq	LBB0_3
; %bb.6:                                ;   in Loop: Header=BB0_4 Depth=1
	str	xzr, [sp, #40]
	bl	_vdbeSorterTreeDepth
	mov	x24, x0
	str	wzr, [sp, #36]
	ldr	x1, [x23]
	ldrsw	x0, [x19]
	cmp	x1, x0
	b.le	LBB0_13
; %bb.7:                                ;   in Loop: Header=BB0_4 Depth=1
                                        ; kill: def $w0 killed $w0 killed $x0
	bl	_vdbeMergeEngineNew
	str	x0, [sp, #40]
Lloh8:
	adrp	x8, _SQLITE_NOMEM_BKPT@GOTPAGE
Lloh9:
	ldr	x8, [x8, _SQLITE_NOMEM_BKPT@GOTPAGEOFF]
Lloh10:
	ldr	w8, [x8]
	cmp	x0, #0
	csel	w22, w8, w22, eq
	ldr	x9, [x23]
	ldr	w8, [x27]
	cmp	x9, #1
	ccmp	w22, w8, #0, ge
	b.ne	LBB0_14
; %bb.8:                                ;   in Loop: Header=BB0_4 Depth=1
	mov	w28, #0
	mov	w20, #0
	ldr	w1, [x19]
	b	LBB0_11
LBB0_9:                                 ;   in Loop: Header=BB0_11 Depth=2
	add	w25, w28, #1
	ldr	x3, [sp, #40]
	ldr	x4, [sp, #24]
	mov	x0, x23
	mov	x1, x24
	mov	x2, x28
	bl	_vdbeSorterAddToTree
	mov	x22, x0
	ldr	w8, [x27]
	mov	x28, x25
LBB0_10:                                ;   in Loop: Header=BB0_11 Depth=2
	ldr	w1, [x19]
	add	w20, w1, w20
	ldr	x9, [x23]
	cmp	x9, w20, sxtw
	ccmp	w22, w8, #0, gt
	b.ne	LBB0_14
LBB0_11:                                ;   Parent Loop BB0_4 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	str	xzr, [sp, #24]
	sub	w0, w9, w20
	bl	_MIN
	mov	x1, x0
	add	x2, sp, #36
	add	x3, sp, #24
	mov	x0, x23
	bl	_vdbeMergeEngineLevel0
	ldr	w8, [x27]
	cmp	w0, w8
	b.eq	LBB0_9
; %bb.12:                               ;   in Loop: Header=BB0_11 Depth=2
	mov	x22, x0
	b	LBB0_10
LBB0_13:                                ;   in Loop: Header=BB0_4 Depth=1
	add	x2, sp, #36
	add	x3, sp, #40
	mov	x0, x23
                                        ; kill: def $w1 killed $w1 killed $x1
	bl	_vdbeMergeEngineLevel0
	mov	x22, x0
	ldr	w8, [x27]
LBB0_14:                                ;   in Loop: Header=BB0_4 Depth=1
	cmp	w22, w8
	b.ne	LBB0_1
; %bb.15:                               ;   in Loop: Header=BB0_4 Depth=1
	ldr	x8, [sp, #16]                   ; 8-byte Folded Reload
	cmp	x8, #0
	cset	w0, eq
	bl	_assert
	ldr	x8, [sp, #40]
	str	x8, [sp, #16]                   ; 8-byte Folded Spill
	b	LBB0_2
LBB0_16:
	ldr	x0, [sp, #16]                   ; 8-byte Folded Reload
	bl	_vdbeMergeEngineFree
	mov	x9, #0
	b	LBB0_18
LBB0_17:
	ldr	x9, [sp, #16]                   ; 8-byte Folded Reload
LBB0_18:
	ldr	x8, [sp, #8]                    ; 8-byte Folded Reload
	str	x9, [x8]
	mov	x0, x22
	ldp	x29, x30, [sp, #128]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #112]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #96]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #80]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #64]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #48]             ; 16-byte Folded Reload
	add	sp, sp, #144
	ret
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.cfi_endproc
                                        ; -- End function
	.comm	_SQLITE_OK,4,2                  ; @SQLITE_OK
	.comm	_SQLITE_MAX_WORKER_THREADS,8,3  ; @SQLITE_MAX_WORKER_THREADS
	.comm	_SORTER_MAX_MERGE_COUNT,4,2     ; @SORTER_MAX_MERGE_COUNT
	.comm	_SQLITE_NOMEM_BKPT,4,2          ; @SQLITE_NOMEM_BKPT
	.no_dead_strip	_vdbeSorterMergeTreeBuild
.subsections_via_symbols
