	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function exit_thread
_exit_thread:                           ## @exit_thread
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -24
	xorl	%eax, %eax
	callq	__get_curthread
	movq	%rax, %rbx
	movq	32(%rax), %rdi
	callq	_free
	movq	$0, 32(%rbx)
	cmpq	$0, 24(%rbx)
	je	LBB0_2
## %bb.1:
	xorl	%eax, %eax
	callq	__thread_cleanupspecific
LBB0_2:
	xorl	%eax, %eax
	callq	__thr_isthreaded
	testl	%eax, %eax
	je	LBB0_10
## %bb.3:
	movq	__thread_active_threads@GOTPCREL(%rip), %rdi
	movl	$-1, %esi
	callq	_atomic_fetchadd_int
	cmpl	$1, %eax
	je	LBB0_10
## %bb.4:
	xorl	%eax, %eax
	callq	__malloc_thread_cleanup
	movq	%rbx, %rdi
	callq	_THR_LOCK
	movq	_PS_DEAD@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 20(%rbx)
	movq	_THR_FLAGS_NEED_SUSPEND@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%rbx)
	je	LBB0_6
## %bb.5:
	incl	16(%rbx)
	leaq	16(%rbx), %rdi
	movq	_INT_MAX@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	xorl	%edx, %edx
	callq	__thr_umtx_wake
LBB0_6:
	cmpl	$0, 12(%rbx)
	jne	LBB0_9
## %bb.7:
	movq	_TD_DEATH@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	callq	_SHOULD_REPORT_EVENT
	testq	%rax, %rax
	je	LBB0_9
## %bb.8:
	movq	%rbx, %rdi
	callq	__thr_report_death
LBB0_9:
	decl	8(%rbx)
	movq	%rbx, %rdi
	movq	%rbx, %rsi
	callq	__thr_try_gc
	addq	$4, %rbx
	movq	%rbx, %rdi
	callq	_thr_exit
	leaq	L_.str(%rip), %rdi
	xorl	%eax, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%rbp
	jmp	_PANIC                          ## TAILCALL
LBB0_10:
	xorl	%edi, %edi
	callq	_exit
	.cfi_endproc
                                        ## -- End function
	.comm	__thread_active_threads,4,2     ## @_thread_active_threads
	.comm	_PS_DEAD,4,2                    ## @PS_DEAD
	.comm	_THR_FLAGS_NEED_SUSPEND,4,2     ## @THR_FLAGS_NEED_SUSPEND
	.comm	_INT_MAX,4,2                    ## @INT_MAX
	.comm	_TD_DEATH,4,2                   ## @TD_DEATH
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"thr_exit() returned"

	.no_dead_strip	_exit_thread
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function exit_thread
_exit_thread:                           ; @exit_thread
	.cfi_startproc
; %bb.0:
	stp	x20, x19, [sp, #-32]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 32
	stp	x29, x30, [sp, #16]             ; 16-byte Folded Spill
	add	x29, sp, #16
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	bl	__get_curthread
	mov	x19, x0
	ldr	x0, [x0, #32]
	bl	_free
	str	xzr, [x19, #32]
	ldr	x8, [x19, #24]
	cbz	x8, LBB0_2
; %bb.1:
	bl	__thread_cleanupspecific
LBB0_2:
	bl	__thr_isthreaded
	cbz	w0, LBB0_10
; %bb.3:
Lloh0:
	adrp	x0, __thread_active_threads@GOTPAGE
Lloh1:
	ldr	x0, [x0, __thread_active_threads@GOTPAGEOFF]
	mov	w1, #-1
	bl	_atomic_fetchadd_int
	cmp	w0, #1
	b.eq	LBB0_11
; %bb.4:
	bl	__malloc_thread_cleanup
	mov	x0, x19
	bl	_THR_LOCK
Lloh2:
	adrp	x8, _PS_DEAD@GOTPAGE
Lloh3:
	ldr	x8, [x8, _PS_DEAD@GOTPAGEOFF]
Lloh4:
	ldr	w8, [x8]
	str	w8, [x19, #20]
	ldr	w8, [x19]
Lloh5:
	adrp	x9, _THR_FLAGS_NEED_SUSPEND@GOTPAGE
Lloh6:
	ldr	x9, [x9, _THR_FLAGS_NEED_SUSPEND@GOTPAGEOFF]
Lloh7:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_6
; %bb.5:
	mov	x0, x19
	ldr	w8, [x0, #16]!
	add	w8, w8, #1
	str	w8, [x0]
Lloh8:
	adrp	x8, _INT_MAX@GOTPAGE
Lloh9:
	ldr	x8, [x8, _INT_MAX@GOTPAGEOFF]
Lloh10:
	ldr	w1, [x8]
	mov	w2, #0
	bl	__thr_umtx_wake
LBB0_6:
	ldr	w8, [x19, #12]
	cbnz	w8, LBB0_9
; %bb.7:
Lloh11:
	adrp	x8, _TD_DEATH@GOTPAGE
Lloh12:
	ldr	x8, [x8, _TD_DEATH@GOTPAGEOFF]
Lloh13:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_SHOULD_REPORT_EVENT
	cbz	x0, LBB0_9
; %bb.8:
	mov	x0, x19
	bl	__thr_report_death
LBB0_9:
	ldr	w8, [x19, #8]
	sub	w8, w8, #1
	str	w8, [x19, #8]
	mov	x0, x19
	mov	x1, x19
	bl	__thr_try_gc
	add	x0, x19, #4
	bl	_thr_exit
Lloh14:
	adrp	x0, l_.str@PAGE
Lloh15:
	add	x0, x0, l_.str@PAGEOFF
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp], #32             ; 16-byte Folded Reload
	b	_PANIC
LBB0_10:
	bl	_exit
LBB0_11:
	mov	w0, #0
	bl	_exit
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpAdd	Lloh14, Lloh15
	.cfi_endproc
                                        ; -- End function
	.comm	__thread_active_threads,4,2     ; @_thread_active_threads
	.comm	_PS_DEAD,4,2                    ; @PS_DEAD
	.comm	_THR_FLAGS_NEED_SUSPEND,4,2     ; @THR_FLAGS_NEED_SUSPEND
	.comm	_INT_MAX,4,2                    ; @INT_MAX
	.comm	_TD_DEATH,4,2                   ; @TD_DEATH
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"thr_exit() returned"

	.no_dead_strip	_exit_thread
.subsections_via_symbols
