	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_sem_wait                       ## -- Begin function sem_wait
	.p2align	4, 0x90
_sem_wait:                              ## @sem_wait
	.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	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r15
	movq	(%rdi), %r14
	xorl	%eax, %eax
	callq	_pthread_testcancel
	testq	%r14, %r14
	je	LBB0_1
## %bb.2:
	leaq	8(%r14), %r12
	movq	%r12, %rdi
	callq	_pthread_mutex_lock
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_9
## %bb.3:
	cmpq	$0, (%r15)
	je	LBB0_8
## %bb.4:
	movl	(%r14), %ebx
	leal	-1(%rbx), %eax
	movl	%eax, (%r14)
	movq	%r12, %rdi
	callq	_pthread_mutex_unlock
	xorl	%eax, %eax
	testl	%ebx, %ebx
	jg	LBB0_10
## %bb.5:
	movq	_pte_sem_wait_cleanup@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	%r14, %rsi
	callq	_pthread_cleanup_push
	movl	4(%r14), %edi
	xorl	%esi, %esi
	callq	_pte_cancellable_wait
	movl	%eax, %ebx
	movl	%eax, %edi
	callq	_pthread_cleanup_pop
	testl	%ebx, %ebx
	jne	LBB0_9
	jmp	LBB0_7
LBB0_1:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	testl	%ebx, %ebx
	jne	LBB0_9
LBB0_7:
	xorl	%eax, %eax
	jmp	LBB0_10
LBB0_8:
	movq	%r12, %rdi
	callq	_pthread_mutex_unlock
	movq	_EINVAL@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
LBB0_9:
	movq	_errno@GOTPCREL(%rip), %rax
	movl	%ebx, (%rax)
	movl	$-1, %eax
LBB0_10:
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_EINVAL,8,3                     ## @EINVAL
	.comm	_errno,4,2                      ## @errno
	.comm	_pte_sem_wait_cleanup,4,2       ## @pte_sem_wait_cleanup
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_sem_wait                       ; -- Begin function sem_wait
	.p2align	2
_sem_wait:                              ; @sem_wait
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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
	mov	x22, x0
	ldr	x19, [x0]
	bl	_pthread_testcancel
	cbz	x19, LBB0_5
; %bb.1:
	add	x21, x19, #8
	mov	x0, x21
	bl	_pthread_mutex_lock
	mov	x20, x0
	cbnz	w0, LBB0_8
; %bb.2:
	ldr	x8, [x22]
	cbz	x8, LBB0_7
; %bb.3:
	ldr	w20, [x19]
	sub	w8, w20, #1
	str	w8, [x19]
	mov	x0, x21
	bl	_pthread_mutex_unlock
	cmp	w20, #0
	b.gt	LBB0_6
; %bb.4:
Lloh0:
	adrp	x8, _pte_sem_wait_cleanup@GOTPAGE
Lloh1:
	ldr	x8, [x8, _pte_sem_wait_cleanup@GOTPAGEOFF]
Lloh2:
	ldr	w0, [x8]
	mov	x1, x19
	bl	_pthread_cleanup_push
	ldr	w0, [x19, #4]
	mov	x1, #0
	bl	_pte_cancellable_wait
	mov	x20, x0
	bl	_pthread_cleanup_pop
	cbnz	w20, LBB0_8
	b	LBB0_6
LBB0_5:
Lloh3:
	adrp	x8, _EINVAL@GOTPAGE
Lloh4:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh5:
	ldr	w20, [x8]
	cbnz	w20, LBB0_8
LBB0_6:
	mov	w0, #0
	b	LBB0_9
LBB0_7:
	mov	x0, x21
	bl	_pthread_mutex_unlock
Lloh6:
	adrp	x8, _EINVAL@GOTPAGE
Lloh7:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh8:
	ldr	w20, [x8]
LBB0_8:
Lloh9:
	adrp	x8, _errno@GOTPAGE
Lloh10:
	ldr	x8, [x8, _errno@GOTPAGEOFF]
Lloh11:
	str	w20, [x8]
	mov	w0, #-1
LBB0_9:
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotStr	Lloh9, Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.comm	_EINVAL,8,3                     ; @EINVAL
	.comm	_errno,4,2                      ; @errno
	.comm	_pte_sem_wait_cleanup,4,2       ; @pte_sem_wait_cleanup
.subsections_via_symbols
