	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_sem_init                       ## -- Begin function sem_init
	.p2align	4, 0x90
_sem_init:                              ## @sem_init
	.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, %r14
	testl	%esi, %esi
	je	LBB0_5
## %bb.1:
	movq	_EPERM@GOTPCREL(%rip), %rax
	jmp	LBB0_2
LBB0_5:
	movl	%edx, %ebx
	movq	_SEM_VALUE_MAX@GOTPCREL(%rip), %rax
	cmpl	%edx, (%rax)
	jae	LBB0_7
## %bb.6:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	jmp	LBB0_2
LBB0_7:
	movl	$1, %edi
	movl	$12, %esi
	callq	_calloc
	testq	%rax, %rax
	je	LBB0_8
## %bb.9:
	movq	%rax, %r12
	movl	%ebx, (%rax)
	leaq	4(%rax), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	_pthread_mutex_init
	testq	%rax, %rax
	jne	LBB0_12
## %bb.10:
	movq	%r12, %rsi
	addq	$8, %rsi
	xorl	%edi, %edi
	callq	_pte_osSemaphoreCreate
	movq	_PTE_OS_OK@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	je	LBB0_4
## %bb.11:
	movq	%r15, %rdi
	callq	_pthread_mutex_destroy
LBB0_12:
	movq	_ENOSPC@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	testl	%ebx, %ebx
	je	LBB0_4
## %bb.13:
	movq	%r12, %rdi
	callq	_free
	jmp	LBB0_14
LBB0_8:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
LBB0_2:
	movl	(%rax), %ebx
	testl	%ebx, %ebx
	je	LBB0_3
LBB0_14:
	movq	_errno@GOTPCREL(%rip), %rax
	movl	%ebx, (%rax)
	movl	$-1, %eax
	jmp	LBB0_15
LBB0_3:
	xorl	%r12d, %r12d
LBB0_4:
	movq	%r12, (%r14)
	xorl	%eax, %eax
LBB0_15:
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_EPERM,4,2                      ## @EPERM
	.comm	_SEM_VALUE_MAX,8,3              ## @SEM_VALUE_MAX
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_PTE_OS_OK,8,3                  ## @PTE_OS_OK
	.comm	_ENOSPC,4,2                     ## @ENOSPC
	.comm	_errno,4,2                      ## @errno
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_sem_init                       ; -- Begin function sem_init
	.p2align	2
_sem_init:                              ; @sem_init
	.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	x19, x0
	cbz	w1, LBB0_2
; %bb.1:
Lloh0:
	adrp	x8, _EPERM@GOTPAGE
Lloh1:
	ldr	x8, [x8, _EPERM@GOTPAGEOFF]
Lloh2:
	ldr	w21, [x8]
	cbnz	w21, LBB0_11
	b	LBB0_12
LBB0_2:
	mov	x22, x2
Lloh3:
	adrp	x8, _SEM_VALUE_MAX@GOTPAGE
Lloh4:
	ldr	x8, [x8, _SEM_VALUE_MAX@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	cmp	w8, w2
	b.hs	LBB0_4
; %bb.3:
Lloh6:
	adrp	x8, _EINVAL@GOTPAGE
Lloh7:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh8:
	ldr	w21, [x8]
	cbnz	w21, LBB0_11
	b	LBB0_12
LBB0_4:
	mov	w0, #1
	mov	w1, #12
	bl	_calloc
	cbz	x0, LBB0_10
; %bb.5:
	mov	x20, x0
	mov	x21, x0
	str	w22, [x21], #4
	mov	x0, x21
	mov	x1, #0
	bl	_pthread_mutex_init
	cbnz	x0, LBB0_8
; %bb.6:
	add	x1, x20, #8
	bl	_pte_osSemaphoreCreate
Lloh9:
	adrp	x8, _PTE_OS_OK@GOTPAGE
Lloh10:
	ldr	x8, [x8, _PTE_OS_OK@GOTPAGEOFF]
Lloh11:
	ldr	x8, [x8]
	cmp	x0, x8
	b.eq	LBB0_13
; %bb.7:
	mov	x0, x21
	bl	_pthread_mutex_destroy
LBB0_8:
Lloh12:
	adrp	x8, _ENOSPC@GOTPAGE
Lloh13:
	ldr	x8, [x8, _ENOSPC@GOTPAGEOFF]
Lloh14:
	ldr	w21, [x8]
	cbz	w21, LBB0_13
; %bb.9:
	mov	x0, x20
	bl	_free
	b	LBB0_11
LBB0_10:
Lloh15:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh16:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh17:
	ldr	w21, [x8]
	cbz	w21, LBB0_12
LBB0_11:
Lloh18:
	adrp	x8, _errno@GOTPAGE
Lloh19:
	ldr	x8, [x8, _errno@GOTPAGEOFF]
Lloh20:
	str	w21, [x8]
	mov	w0, #-1
	b	LBB0_14
LBB0_12:
	mov	x20, #0
LBB0_13:
	mov	w0, #0
	str	x20, [x19]
LBB0_14:
	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 AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotStr	Lloh18, Lloh19, Lloh20
	.cfi_endproc
                                        ; -- End function
	.comm	_EPERM,4,2                      ; @EPERM
	.comm	_SEM_VALUE_MAX,8,3              ; @SEM_VALUE_MAX
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_PTE_OS_OK,8,3                  ; @PTE_OS_OK
	.comm	_ENOSPC,4,2                     ; @ENOSPC
	.comm	_errno,4,2                      ; @errno
.subsections_via_symbols
