	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_rebuild_topmsg_tree            ## -- Begin function rebuild_topmsg_tree
	.p2align	4, 0x90
_rebuild_topmsg_tree:                   ## @rebuild_topmsg_tree
	.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	%r9, %r12
	movq	%r8, %r13
	movl	%ecx, -44(%rbp)                 ## 4-byte Spill
	movq	%rdx, %r14
	movq	%rsi, %rbx
	testq	%rdi, %rdi
	movq	%r9, -56(%rbp)                  ## 8-byte Spill
	movq	%rdx, -96(%rbp)                 ## 8-byte Spill
	je	LBB0_13
## %bb.1:
	movq	%rdi, %r15
	movq	24(%rdi), %rdi
	movl	(%r15), %ecx
	decl	%ecx
	movq	%rbx, %rsi
	movq	%r14, %rdx
	movq	%r13, %r8
	movq	%r12, %r9
	callq	_rebuild_topmsg_tree
	movq	%rax, %rbx
	movq	%rax, %rdx
	movl	(%r15), %ecx
	movq	%r15, -104(%rbp)                ## 8-byte Spill
	movl	16(%r15), %eax
	movl	%eax, -60(%rbp)
	cmpq	%r14, %rbx
	movl	%ecx, -88(%rbp)                 ## 4-byte Spill
	jae	LBB0_9
## %bb.2:
	cmpl	%ecx, 4(%rdx)
	jne	LBB0_9
## %bb.3:
	movl	8(%rdx), %eax
	movl	%eax, %r12d
	subl	(%rdx), %r12d
	movl	%r12d, %ecx
	sarl	$2, %ecx
	movl	%ecx, -84(%rbp)                 ## 4-byte Spill
	movl	%ecx, -80(%rbp)
	movq	%rdx, %r15
	movl	(%rdx), %ecx
	xorl	%r14d, %r14d
	movl	$0, %edi
	testl	%ecx, %ecx
	js	LBB0_6
## %bb.4:
	movl	$0, %edi
	cmpl	%eax, %ecx
	jg	LBB0_6
## %bb.5:
	movq	_UserHdr@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	xorl	%edi, %edi
	cmpl	(%rcx), %eax
	setle	%dil
LBB0_6:
	addq	$8, %rbx
	callq	_assert
	movslq	(%r15), %rax
	addq	-56(%rbp), %rax                 ## 8-byte Folded Reload
	movq	%rax, -72(%rbp)
	cmpl	$4, %r12d
	jb	LBB0_7
## %bb.8:
	movslq	-84(%rbp), %rcx                 ## 4-byte Folded Reload
	movl	-4(%rax,%rcx,4), %r14d
LBB0_7:
	movq	%rbx, %r15
	movq	-56(%rbp), %r12                 ## 8-byte Reload
	jmp	LBB0_10
LBB0_9:
	movq	%rdx, %r15
	movl	$0, -80(%rbp)
	movq	$0, -72(%rbp)
	xorl	%r14d, %r14d
LBB0_10:
	movl	%r14d, -64(%rbp)
	leaq	-80(%rbp), %rdi
	xorl	%esi, %esi
	callq	_listree_get_kth_last
	cmpl	$-1, %eax
	je	LBB0_12
## %bb.11:
	movl	%eax, %ebx
	xorl	%edi, %edi
	testl	%eax, %eax
	setg	%dil
	callq	_assert
	movq	(%r13), %r14
	xorl	%eax, %eax
	callq	_lrand48
	movq	%r14, %rdi
	movl	%ebx, %esi
	movl	%eax, %edx
	movl	-88(%rbp), %ecx                 ## 4-byte Reload
	callq	_tree_num_insert
	movq	%rax, (%r13)
LBB0_12:
	movq	-104(%rbp), %rax                ## 8-byte Reload
	movq	8(%rax), %rdi
	movq	%r15, %rsi
	movq	-96(%rbp), %r14                 ## 8-byte Reload
	movq	%r14, %rdx
	movl	-44(%rbp), %ecx                 ## 4-byte Reload
	movq	%r13, %r8
	movq	%r12, %r9
	callq	_rebuild_topmsg_tree
	movq	%rax, %rbx
LBB0_13:
	cmpq	%r14, %rbx
	jb	LBB0_14
LBB0_24:
	movq	%rbx, %rax
	addq	$72, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.p2align	4, 0x90
LBB0_23:                                ##   in Loop: Header=BB0_14 Depth=1
	cmpq	-96(%rbp), %rbx                 ## 8-byte Folded Reload
	jae	LBB0_24
LBB0_14:                                ## =>This Inner Loop Header: Depth=1
	movl	4(%rbx), %r15d
	cmpl	-44(%rbp), %r15d                ## 4-byte Folded Reload
	jg	LBB0_24
## %bb.15:                              ##   in Loop: Header=BB0_14 Depth=1
	movq	_NIL@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -60(%rbp)
	movl	8(%rbx), %eax
	movl	%eax, %ecx
	subl	(%rbx), %ecx
	sarl	$2, %ecx
	movl	%ecx, -80(%rbp)
	movl	(%rbx), %edx
	xorl	%r14d, %r14d
	testl	%edx, %edx
	js	LBB0_16
## %bb.17:                              ##   in Loop: Header=BB0_14 Depth=1
	movl	$0, %ecx
	cmpl	%eax, %edx
	jg	LBB0_19
## %bb.18:                              ##   in Loop: Header=BB0_14 Depth=1
	movq	_UserHdr@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	cmpl	(%rcx), %eax
	setle	%cl
	jmp	LBB0_19
	.p2align	4, 0x90
LBB0_16:                                ##   in Loop: Header=BB0_14 Depth=1
	xorl	%ecx, %ecx
LBB0_19:                                ##   in Loop: Header=BB0_14 Depth=1
	movzbl	%cl, %edi
	callq	_assert
	movslq	(%rbx), %rax
	addq	%r12, %rax
	movq	%rax, -72(%rbp)
	movslq	-80(%rbp), %rcx
	testq	%rcx, %rcx
	je	LBB0_21
## %bb.20:                              ##   in Loop: Header=BB0_14 Depth=1
	movl	-4(%rax,%rcx,4), %r14d
LBB0_21:                                ##   in Loop: Header=BB0_14 Depth=1
	addq	$8, %rbx
	movl	%r14d, -64(%rbp)
	leaq	-80(%rbp), %rdi
	xorl	%esi, %esi
	callq	_listree_get_kth_last
	cmpl	$-1, %eax
	je	LBB0_23
## %bb.22:                              ##   in Loop: Header=BB0_14 Depth=1
	movl	%eax, %r14d
	xorl	%edi, %edi
	testl	%eax, %eax
	setg	%dil
	callq	_assert
	movq	(%r13), %r12
	xorl	%eax, %eax
	callq	_lrand48
	movq	%r12, %rdi
	movq	-56(%rbp), %r12                 ## 8-byte Reload
	movl	%r14d, %esi
	movl	%eax, %edx
	movl	%r15d, %ecx
	callq	_tree_num_insert
	movq	%rax, (%r13)
	jmp	LBB0_23
	.cfi_endproc
                                        ## -- End function
	.comm	_UserHdr,8,3                    ## @UserHdr
	.comm	_NIL,4,2                        ## @NIL
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_rebuild_topmsg_tree            ; -- Begin function rebuild_topmsg_tree
	.p2align	2
_rebuild_topmsg_tree:                   ; @rebuild_topmsg_tree
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #128
	.cfi_def_cfa_offset 128
	stp	x28, x27, [sp, #32]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #48]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #64]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #80]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #96]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #112]            ; 16-byte Folded Spill
	add	x29, sp, #112
	.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, x5
	mov	x20, x4
	mov	x21, x3
	mov	x22, x2
	mov	x25, x1
	cbz	x0, LBB0_12
; %bb.1:
	mov	x23, x0
	ldr	x0, [x0, #24]
	ldr	w8, [x23]
	sub	w3, w8, #1
	mov	x1, x25
	mov	x2, x22
	mov	x4, x20
	mov	x5, x19
	bl	_rebuild_topmsg_tree
	mov	x25, x0
	ldr	w24, [x23]
	ldr	w8, [x23, #16]
	str	w8, [sp, #28]
	cmp	x0, x22
	b.hs	LBB0_8
; %bb.2:
	ldr	w8, [x25, #4]
	cmp	w8, w24
	b.ne	LBB0_8
; %bb.3:
	mov	w0, #0
	mov	x26, x25
	ldr	w8, [x26, #8]!
	ldr	w9, [x25]
	sub	w28, w8, w9
	asr	w27, w28, #2
	str	w27, [sp, #8]
	ldr	w9, [x25]
	tbnz	w9, #31, LBB0_6
; %bb.4:
	cmp	w9, w8
	b.gt	LBB0_6
; %bb.5:
Lloh0:
	adrp	x9, _UserHdr@GOTPAGE
Lloh1:
	ldr	x9, [x9, _UserHdr@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	ldr	w9, [x9]
	cmp	w8, w9
	cset	w0, le
LBB0_6:
	bl	_assert
	ldrsw	x8, [x25]
	add	x8, x19, x8
	str	x8, [sp, #16]
	cmp	w28, #4
	b.hs	LBB0_26
; %bb.7:
	mov	w8, #0
	mov	x25, x26
	b	LBB0_9
LBB0_8:
	mov	w8, #0
	str	wzr, [sp, #8]
	str	xzr, [sp, #16]
LBB0_9:
	str	w8, [sp, #24]
	add	x0, sp, #8
	mov	w1, #0
	bl	_listree_get_kth_last
	cmn	w0, #1
	b.eq	LBB0_11
; %bb.10:
	mov	x26, x0
	cmp	w0, #0
	cset	w0, gt
	bl	_assert
	ldr	x27, [x20]
	bl	_lrand48
	mov	x2, x0
	mov	x0, x27
	mov	x1, x26
	mov	x3, x24
	bl	_tree_num_insert
	str	x0, [x20]
LBB0_11:
	ldr	x0, [x23, #8]
	mov	x1, x25
	mov	x2, x22
	mov	x3, x21
	mov	x4, x20
	mov	x5, x19
	bl	_rebuild_topmsg_tree
	mov	x25, x0
LBB0_12:
	cmp	x25, x22
	b.hs	LBB0_24
; %bb.13:
Lloh3:
	adrp	x27, _NIL@GOTPAGE
Lloh4:
	ldr	x27, [x27, _NIL@GOTPAGEOFF]
Lloh5:
	adrp	x28, _UserHdr@GOTPAGE
Lloh6:
	ldr	x28, [x28, _UserHdr@GOTPAGEOFF]
	b	LBB0_15
LBB0_14:                                ;   in Loop: Header=BB0_15 Depth=1
	mov	x25, x23
	cmp	x23, x22
	b.hs	LBB0_25
LBB0_15:                                ; =>This Inner Loop Header: Depth=1
	ldr	w24, [x25, #4]
	cmp	w24, w21
	b.gt	LBB0_24
; %bb.16:                               ;   in Loop: Header=BB0_15 Depth=1
	mov	w0, #0
	ldr	w8, [x27]
	str	w8, [sp, #28]
	mov	x23, x25
	ldr	w8, [x23, #8]!
	ldr	w9, [x25]
	sub	w9, w8, w9
	asr	w9, w9, #2
	str	w9, [sp, #8]
	ldr	w9, [x25]
	tbnz	w9, #31, LBB0_19
; %bb.17:                               ;   in Loop: Header=BB0_15 Depth=1
	cmp	w9, w8
	b.gt	LBB0_19
; %bb.18:                               ;   in Loop: Header=BB0_15 Depth=1
	ldr	x9, [x28]
	ldr	w9, [x9]
	cmp	w8, w9
	cset	w0, le
LBB0_19:                                ;   in Loop: Header=BB0_15 Depth=1
	bl	_assert
	ldrsw	x8, [x25]
	add	x8, x19, x8
	str	x8, [sp, #16]
	ldr	w9, [sp, #8]
	cbz	w9, LBB0_21
; %bb.20:                               ;   in Loop: Header=BB0_15 Depth=1
	sub	w9, w9, #1
	ldr	w8, [x8, w9, sxtw #2]
	b	LBB0_22
LBB0_21:                                ;   in Loop: Header=BB0_15 Depth=1
	mov	w8, #0
LBB0_22:                                ;   in Loop: Header=BB0_15 Depth=1
	str	w8, [sp, #24]
	add	x0, sp, #8
	mov	w1, #0
	bl	_listree_get_kth_last
	cmn	w0, #1
	b.eq	LBB0_14
; %bb.23:                               ;   in Loop: Header=BB0_15 Depth=1
	mov	x25, x0
	cmp	w0, #0
	cset	w0, gt
	bl	_assert
	ldr	x26, [x20]
	bl	_lrand48
	mov	x2, x0
	mov	x0, x26
	mov	x1, x25
	mov	x3, x24
	bl	_tree_num_insert
	str	x0, [x20]
	b	LBB0_14
LBB0_24:
	mov	x23, x25
LBB0_25:
	mov	x0, x23
	ldp	x29, x30, [sp, #112]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #96]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #80]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #64]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #48]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #128
	ret
LBB0_26:
	sub	w9, w27, #1
	ldr	w8, [x8, w9, sxtw #2]
	mov	x25, x26
	b	LBB0_9
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.cfi_endproc
                                        ; -- End function
	.comm	_UserHdr,8,3                    ; @UserHdr
	.comm	_NIL,4,2                        ; @NIL
.subsections_via_symbols
