	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mutex_unlock_common
_mutex_unlock_common:                   ## @mutex_unlock_common
	.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	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdx, %r12
	movl	%esi, %ebx
	movq	%rdi, %r14
	movq	_THR_MUTEX_DESTROYED@GOTPCREL(%rip), %r15
	xorl	%edi, %edi
	cmpq	%r14, (%r15)
	setae	%dil
	callq	___predict_false
	testq	%rax, %rax
	je	LBB0_3
## %bb.1:
	cmpq	%r14, (%r15)
	jne	LBB0_4
## %bb.2:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	jmp	LBB0_5
LBB0_3:
	movq	%r12, -72(%rbp)                 ## 8-byte Spill
	xorl	%r15d, %r15d
	xorl	%eax, %eax
	callq	__get_curthread
	movq	%rax, %r12
	movq	%rax, %rdi
	callq	_TID
	movq	%rax, %r13
	movq	%r14, %rdi
	callq	_PMUTEX_OWNER_ID
	xorl	%edi, %edi
	cmpq	%r13, %rax
	setne	%dil
	callq	___predict_false
	testq	%rax, %rax
	je	LBB0_7
LBB0_4:
	movq	_EPERM@GOTPCREL(%rip), %rax
LBB0_5:
	movl	(%rax), %r13d
LBB0_6:
	movl	%r13d, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_7:
	movq	%r12, -48(%rbp)                 ## 8-byte Spill
	movl	(%r14), %r12d
	movq	_PMUTEX_FLAG_PRIVATE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -64(%rbp)                 ## 4-byte Spill
	movl	%r12d, %edi
	callq	_PMUTEX_TYPE
	movq	_PTHREAD_MUTEX_RECURSIVE@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_9
## %bb.8:
	xorl	%r15d, %r15d
	cmpq	$0, 8(%r14)
	setg	%r15b
LBB0_9:
	movl	%r15d, %edi
	callq	___predict_false
	testq	%rax, %rax
	je	LBB0_11
## %bb.10:
	decq	8(%r14)
	xorl	%r13d, %r13d
LBB0_19:
	movq	-48(%rbp), %r15                 ## 8-byte Reload
	testl	%ebx, %ebx
	je	LBB0_21
	jmp	LBB0_6
LBB0_11:
	movl	%r12d, -60(%rbp)                ## 4-byte Spill
	movl	(%r14), %ecx
	movq	_PMUTEX_FLAG_DEFERRED@GOTPCREL(%rip), %rax
	movl	(%rax), %r15d
	testl	%ecx, %r15d
	je	LBB0_13
## %bb.12:
	movl	%r15d, %eax
	notl	%eax
	andl	%ecx, %eax
	movl	%eax, (%r14)
LBB0_13:
	movq	-48(%rbp), %r12                 ## 8-byte Reload
	movq	%r12, %rdi
	movq	%r14, %rsi
	movl	%ecx, -52(%rbp)                 ## 4-byte Spill
	callq	__mutex_enter_robust
	movl	%eax, -56(%rbp)                 ## 4-byte Spill
	movq	%r12, %rdi
	movq	%r14, %rsi
	callq	_dequeue_mutex
	leaq	16(%r14), %rdi
	movq	%r13, %rsi
	movq	-72(%rbp), %r12                 ## 8-byte Reload
	movq	%r12, %rdx
	callq	__thr_umutex_unlock2
	movl	%eax, %r13d
	testl	%r15d, -52(%rbp)                ## 4-byte Folded Reload
	je	LBB0_17
## %bb.14:
	testq	%r12, %r12
	je	LBB0_16
## %bb.15:
	movl	$1, (%r12)
	jmp	LBB0_17
LBB0_16:
	movq	-48(%rbp), %r15                 ## 8-byte Reload
	movl	8(%r15), %edi
	movq	(%r15), %rsi
	callq	__thr_wake_all
	movq	$0, (%r15)
LBB0_17:
	cmpl	$0, -56(%rbp)                   ## 4-byte Folded Reload
	movl	-60(%rbp), %r12d                ## 4-byte Reload
	je	LBB0_19
## %bb.18:
	movq	-48(%rbp), %r15                 ## 8-byte Reload
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	__mutex_leave_robust
	testl	%ebx, %ebx
	jne	LBB0_6
LBB0_21:
	andl	%r12d, -64(%rbp)                ## 4-byte Folded Spill
	je	LBB0_6
## %bb.22:
	movq	%r15, %rdi
	callq	_THR_CRITICAL_LEAVE
	jmp	LBB0_6
	.cfi_endproc
                                        ## -- End function
	.comm	_THR_MUTEX_DESTROYED,8,3        ## @THR_MUTEX_DESTROYED
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_EPERM,4,2                      ## @EPERM
	.comm	_PMUTEX_FLAG_PRIVATE,4,2        ## @PMUTEX_FLAG_PRIVATE
	.comm	_PTHREAD_MUTEX_RECURSIVE,8,3    ## @PTHREAD_MUTEX_RECURSIVE
	.comm	_PMUTEX_FLAG_DEFERRED,4,2       ## @PMUTEX_FLAG_DEFERRED
	.no_dead_strip	_mutex_unlock_common
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mutex_unlock_common
_mutex_unlock_common:                   ; @mutex_unlock_common
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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	x22, x2
	mov	x19, x1
	mov	x21, x0
Lloh0:
	adrp	x20, _THR_MUTEX_DESTROYED@GOTPAGE
Lloh1:
	ldr	x20, [x20, _THR_MUTEX_DESTROYED@GOTPAGEOFF]
	ldr	x8, [x20]
	cmp	x8, x0
	cset	w0, hs
	bl	___predict_false
	cbz	x0, LBB0_3
; %bb.1:
	ldr	x8, [x20]
	cmp	x8, x21
	b.ne	LBB0_4
; %bb.2:
Lloh2:
	adrp	x8, _EINVAL@GOTPAGE
Lloh3:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
	b	LBB0_5
LBB0_3:
	bl	__get_curthread
	mov	x20, x0
	bl	_TID
	mov	x24, x0
	mov	x0, x21
	bl	_PMUTEX_OWNER_ID
	cmp	x0, x24
	cset	w0, ne
	bl	___predict_false
	cbz	x0, LBB0_7
LBB0_4:
Lloh4:
	adrp	x8, _EPERM@GOTPAGE
Lloh5:
	ldr	x8, [x8, _EPERM@GOTPAGEOFF]
LBB0_5:
	ldr	w24, [x8]
LBB0_6:
	mov	x0, x24
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
LBB0_7:
	ldr	w23, [x21]
Lloh6:
	adrp	x8, _PMUTEX_FLAG_PRIVATE@GOTPAGE
Lloh7:
	ldr	x8, [x8, _PMUTEX_FLAG_PRIVATE@GOTPAGEOFF]
Lloh8:
	ldr	w26, [x8]
	mov	x0, x23
	bl	_PMUTEX_TYPE
Lloh9:
	adrp	x8, _PTHREAD_MUTEX_RECURSIVE@GOTPAGE
Lloh10:
	ldr	x8, [x8, _PTHREAD_MUTEX_RECURSIVE@GOTPAGEOFF]
Lloh11:
	ldr	x8, [x8]
	cmp	x0, x8
	b.ne	LBB0_10
; %bb.8:
	ldr	x8, [x21, #8]
	cmp	x8, #0
	cset	w0, gt
	bl	___predict_false
	cbz	x0, LBB0_11
LBB0_9:
	mov	w24, #0
	ldr	x8, [x21, #8]
	sub	x8, x8, #1
	str	x8, [x21, #8]
	b	LBB0_19
LBB0_10:
	mov	w0, #0
	bl	___predict_false
	cbnz	x0, LBB0_9
LBB0_11:
	ldr	w8, [x21]
Lloh12:
	adrp	x9, _PMUTEX_FLAG_DEFERRED@GOTPAGE
Lloh13:
	ldr	x9, [x9, _PMUTEX_FLAG_DEFERRED@GOTPAGEOFF]
Lloh14:
	ldr	w9, [x9]
	ands	w27, w9, w8
	b.eq	LBB0_13
; %bb.12:
	bic	w8, w8, w9
	str	w8, [x21]
LBB0_13:
	mov	x0, x20
	mov	x1, x21
	bl	__mutex_enter_robust
	mov	x25, x0
	mov	x0, x20
	mov	x1, x21
	bl	_dequeue_mutex
	add	x0, x21, #16
	mov	x1, x24
	mov	x2, x22
	bl	__thr_umutex_unlock2
	mov	x24, x0
	cbz	w27, LBB0_17
; %bb.14:
	cbz	x22, LBB0_16
; %bb.15:
	mov	w8, #1
	str	w8, [x22]
	b	LBB0_17
LBB0_16:
	ldr	w0, [x20, #8]
	ldr	x1, [x20]
	bl	__thr_wake_all
	str	xzr, [x20]
LBB0_17:
	cbz	w25, LBB0_19
; %bb.18:
	mov	x0, x20
	mov	x1, x21
	bl	__mutex_leave_robust
LBB0_19:
	cbnz	w19, LBB0_6
; %bb.20:
	and	w8, w26, w23
	cbz	w8, LBB0_6
; %bb.21:
	mov	x0, x20
	bl	_THR_CRITICAL_LEAVE
	b	LBB0_6
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.cfi_endproc
                                        ; -- End function
	.comm	_THR_MUTEX_DESTROYED,8,3        ; @THR_MUTEX_DESTROYED
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_EPERM,4,2                      ; @EPERM
	.comm	_PMUTEX_FLAG_PRIVATE,4,2        ; @PMUTEX_FLAG_PRIVATE
	.comm	_PTHREAD_MUTEX_RECURSIVE,8,3    ; @PTHREAD_MUTEX_RECURSIVE
	.comm	_PMUTEX_FLAG_DEFERRED,4,2       ; @PMUTEX_FLAG_DEFERRED
	.no_dead_strip	_mutex_unlock_common
.subsections_via_symbols
