	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_vgem_fence_attach_ioctl        ## -- Begin function vgem_fence_attach_ioctl
	.p2align	4, 0x90
_vgem_fence_attach_ioctl:               ## @vgem_fence_attach_ioctl
	.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	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	_VGEM_FENCE_WRITE@GOTPCREL(%rip), %rbx
	movl	(%rbx), %eax
	notl	%eax
	testl	%eax, (%rsi)
	jne	LBB0_1
## %bb.3:
	movq	%rsi, %r15
	cmpq	$0, 16(%rsi)
	je	LBB0_4
LBB0_1:
	movq	_EINVAL@GOTPCREL(%rip), %rax
LBB0_2:
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_22:
	movl	%ebx, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_4:
	movq	(%rdx), %r12
	movl	8(%r15), %esi
	movq	%rdx, %rdi
	callq	_drm_gem_object_lookup
	testq	%rax, %rax
	je	LBB0_5
## %bb.6:
	movq	%rax, %r14
	movl	(%r15), %esi
	movq	%r12, %rdi
	callq	_vgem_fence_create
	testq	%rax, %rax
	je	LBB0_7
## %bb.8:
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	movq	(%r14), %r13
	movl	(%rbx), %esi
	andl	(%r15), %esi
	movq	%r13, %rdi
	callq	_dma_resv_test_signaled_rcu
	testl	%eax, %eax
	movq	%r14, -56(%rbp)                 ## 8-byte Spill
	je	LBB0_9
## %bb.10:
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	_dma_resv_lock
	movl	(%rbx), %eax
	testl	%eax, (%r15)
	je	LBB0_12
## %bb.11:
	movq	%r13, %rdi
	movq	-48(%rbp), %r14                 ## 8-byte Reload
	movq	%r14, %rsi
	callq	_dma_resv_add_excl_fence
LBB0_14:
	movq	%r13, %rdi
	callq	_dma_resv_unlock
	movq	%r12, %rdi
	callq	_mutex_lock
	leaq	4(%r12), %rdi
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %r8d
	xorl	%ebx, %ebx
	movq	%r14, %rsi
	movl	$1, %edx
	xorl	%ecx, %ecx
	callq	_idr_alloc
	movq	%r14, %r13
	movl	%eax, %r14d
	movq	%r12, %rdi
	callq	_mutex_unlock
	testl	%r14d, %r14d
	jle	LBB0_15
## %bb.23:
	movl	%r14d, 4(%r15)
	jmp	LBB0_20
LBB0_5:
	movq	_ENOENT@GOTPCREL(%rip), %rax
	jmp	LBB0_2
LBB0_7:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_21
LBB0_9:
	movq	_EBUSY@GOTPCREL(%rip), %rax
	xorl	%r14d, %r14d
	subl	(%rax), %r14d
	movq	-48(%rbp), %r12                 ## 8-byte Reload
	jmp	LBB0_16
LBB0_12:
	movq	%r13, %rdi
	movl	$1, %esi
	callq	_dma_resv_reserve_shared
	testl	%eax, %eax
	je	LBB0_13
## %bb.18:
	movl	%eax, %r14d
	movq	%r13, %rdi
	callq	_dma_resv_unlock
	movq	-48(%rbp), %r12                 ## 8-byte Reload
	jmp	LBB0_19
LBB0_15:
	movq	%r13, %r12
LBB0_16:
	testl	%r14d, %r14d
	je	LBB0_17
LBB0_19:
	movq	%r12, %rdi
	callq	_dma_fence_signal
	movq	%r12, %rdi
	callq	_dma_fence_put
	movl	%r14d, %ebx
	jmp	LBB0_20
LBB0_17:
	xorl	%ebx, %ebx
LBB0_20:
	movq	-56(%rbp), %r14                 ## 8-byte Reload
LBB0_21:
	movq	%r14, %rdi
	callq	_drm_gem_object_put_unlocked
	jmp	LBB0_22
LBB0_13:
	movq	%r13, %rdi
	movq	-48(%rbp), %r14                 ## 8-byte Reload
	movq	%r14, %rsi
	callq	_dma_resv_add_shared_fence
	jmp	LBB0_14
	.cfi_endproc
                                        ## -- End function
	.comm	_VGEM_FENCE_WRITE,4,2           ## @VGEM_FENCE_WRITE
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_ENOENT,4,2                     ## @ENOENT
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_EBUSY,4,2                      ## @EBUSY
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_vgem_fence_attach_ioctl        ; -- Begin function vgem_fence_attach_ioctl
	.p2align	2
_vgem_fence_attach_ioctl:               ; @vgem_fence_attach_ioctl
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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
	ldr	w8, [x1]
Lloh0:
	adrp	x23, _VGEM_FENCE_WRITE@GOTPAGE
Lloh1:
	ldr	x23, [x23, _VGEM_FENCE_WRITE@GOTPAGEOFF]
	ldr	w9, [x23]
	bics	wzr, w8, w9
	b.ne	LBB0_2
; %bb.1:
	mov	x20, x1
	ldr	x8, [x1, #16]
	cbz	x8, LBB0_5
LBB0_2:
Lloh2:
	adrp	x8, _EINVAL@GOTPAGE
Lloh3:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
LBB0_3:
	ldr	w8, [x8]
	neg	w23, w8
LBB0_4:
	mov	x0, x23
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
LBB0_5:
	ldr	x22, [x2]
	ldr	w1, [x20, #8]
	mov	x0, x2
	bl	_drm_gem_object_lookup
	cbz	x0, LBB0_12
; %bb.6:
	mov	x19, x0
	ldr	w1, [x20]
	mov	x0, x22
	bl	_vgem_fence_create
	cbz	x0, LBB0_13
; %bb.7:
	mov	x21, x0
	ldr	x24, [x19]
	ldr	w8, [x20]
	ldr	w9, [x23]
	and	w1, w9, w8
	mov	x0, x24
	bl	_dma_resv_test_signaled_rcu
	cbz	w0, LBB0_14
; %bb.8:
	mov	x0, x24
	mov	x1, #0
	bl	_dma_resv_lock
	ldr	w8, [x20]
	ldr	w9, [x23]
	mov	x0, x24
	tst	w9, w8
	b.eq	LBB0_16
; %bb.9:
	mov	x1, x21
	bl	_dma_resv_add_excl_fence
LBB0_10:
	mov	x0, x24
	bl	_dma_resv_unlock
	mov	x0, x22
	bl	_mutex_lock
	add	x0, x22, #4
Lloh4:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh5:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh6:
	ldr	w4, [x8]
	mov	x1, x21
	mov	w2, #1
	mov	w3, #0
	bl	_idr_alloc
	mov	x23, x0
	mov	x0, x22
	bl	_mutex_unlock
	cmp	w23, #1
	b.lt	LBB0_15
; %bb.11:
	str	w23, [x20, #4]
	mov	w23, #0
	b	LBB0_19
LBB0_12:
Lloh7:
	adrp	x8, _ENOENT@GOTPAGE
Lloh8:
	ldr	x8, [x8, _ENOENT@GOTPAGEOFF]
	b	LBB0_3
LBB0_13:
Lloh9:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh10:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	neg	w23, w8
	b	LBB0_19
LBB0_14:
Lloh12:
	adrp	x8, _EBUSY@GOTPAGE
Lloh13:
	ldr	x8, [x8, _EBUSY@GOTPAGEOFF]
Lloh14:
	ldr	w8, [x8]
	neg	w23, w8
LBB0_15:
	cbnz	w23, LBB0_18
	b	LBB0_19
LBB0_16:
	mov	w1, #1
	bl	_dma_resv_reserve_shared
	cbz	w0, LBB0_20
; %bb.17:
	mov	x23, x0
	mov	x0, x24
	bl	_dma_resv_unlock
LBB0_18:
	mov	x0, x21
	bl	_dma_fence_signal
	mov	x0, x21
	bl	_dma_fence_put
LBB0_19:
	mov	x0, x19
	bl	_drm_gem_object_put_unlocked
	b	LBB0_4
LBB0_20:
	mov	x0, x24
	mov	x1, x21
	bl	_dma_resv_add_shared_fence
	b	LBB0_10
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.cfi_endproc
                                        ; -- End function
	.comm	_VGEM_FENCE_WRITE,4,2           ; @VGEM_FENCE_WRITE
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_ENOENT,4,2                     ; @ENOENT
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_EBUSY,4,2                      ; @EBUSY
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
.subsections_via_symbols
