	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function panfrost_ioctl_madvise
_panfrost_ioctl_madvise:                ## @panfrost_ioctl_madvise
	.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	%rsi, %rbx
	movq	(%rdi), %r14
	movl	16(%rsi), %esi
	movq	%rdx, %rdi
	callq	_drm_gem_object_lookup
	testq	%rax, %rax
	je	LBB0_1
## %bb.2:
	movq	%rax, %r15
	movq	(%rbx), %rsi
	movq	%rax, %rdi
	callq	_drm_gem_shmem_madvise
	movq	%rax, 8(%rbx)
	testq	%rax, %rax
	je	LBB0_8
## %bb.3:
	movq	%r15, %rdi
	callq	_to_panfrost_bo
	movq	%rax, %r12
	movq	%r14, %rdi
	callq	_mutex_lock
	movq	(%rbx), %rax
	movq	_PANFROST_MADV_DONTNEED@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_5
## %bb.4:
	leaq	4(%r14), %rsi
	movq	%r12, %rdi
	callq	_list_add_tail
	jmp	LBB0_7
LBB0_1:
	movl	16(%rbx), %esi
	leaq	L_.str(%rip), %rdi
	callq	_DRM_DEBUG
	movq	_ENOENT@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
	jmp	LBB0_9
LBB0_5:
	movq	_PANFROST_MADV_WILLNEED@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_7
## %bb.6:
	movq	%r12, %rdi
	callq	_list_del_init
LBB0_7:
	movq	%r14, %rdi
	callq	_mutex_unlock
LBB0_8:
	movq	%r15, %rdi
	callq	_drm_gem_object_put_unlocked
	xorl	%eax, %eax
LBB0_9:
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Failed to look up GEM BO %d\n"

	.comm	_ENOENT,4,2                     ## @ENOENT
	.comm	_PANFROST_MADV_DONTNEED,8,3     ## @PANFROST_MADV_DONTNEED
	.comm	_PANFROST_MADV_WILLNEED,8,3     ## @PANFROST_MADV_WILLNEED
	.no_dead_strip	_panfrost_ioctl_madvise
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function panfrost_ioctl_madvise
_panfrost_ioctl_madvise:                ; @panfrost_ioctl_madvise
	.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	x21, x1
	ldr	x19, [x0]
	ldr	w1, [x1, #16]
	mov	x0, x2
	bl	_drm_gem_object_lookup
	cbz	x0, LBB0_4
; %bb.1:
	mov	x20, x0
	ldr	x1, [x21]
	bl	_drm_gem_shmem_madvise
	str	x0, [x21, #8]
	cbz	x0, LBB0_8
; %bb.2:
	mov	x0, x20
	bl	_to_panfrost_bo
	mov	x22, x0
	mov	x0, x19
	bl	_mutex_lock
	ldr	x8, [x21]
Lloh0:
	adrp	x9, _PANFROST_MADV_DONTNEED@GOTPAGE
Lloh1:
	ldr	x9, [x9, _PANFROST_MADV_DONTNEED@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_5
; %bb.3:
	add	x1, x19, #4
	mov	x0, x22
	bl	_list_add_tail
	b	LBB0_7
LBB0_4:
	ldr	w1, [x21, #16]
Lloh3:
	adrp	x0, l_.str@PAGE
Lloh4:
	add	x0, x0, l_.str@PAGEOFF
	bl	_DRM_DEBUG
Lloh5:
	adrp	x8, _ENOENT@GOTPAGE
Lloh6:
	ldr	x8, [x8, _ENOENT@GOTPAGEOFF]
Lloh7:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_9
LBB0_5:
Lloh8:
	adrp	x9, _PANFROST_MADV_WILLNEED@GOTPAGE
Lloh9:
	ldr	x9, [x9, _PANFROST_MADV_WILLNEED@GOTPAGEOFF]
Lloh10:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_7
; %bb.6:
	mov	x0, x22
	bl	_list_del_init
LBB0_7:
	mov	x0, x19
	bl	_mutex_unlock
LBB0_8:
	mov	x0, x20
	bl	_drm_gem_object_put_unlocked
	mov	w0, #0
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	Lloh5, Lloh6, Lloh7
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Failed to look up GEM BO %d\n"

	.comm	_ENOENT,4,2                     ; @ENOENT
	.comm	_PANFROST_MADV_DONTNEED,8,3     ; @PANFROST_MADV_DONTNEED
	.comm	_PANFROST_MADV_WILLNEED,8,3     ; @PANFROST_MADV_WILLNEED
	.no_dead_strip	_panfrost_ioctl_madvise
.subsections_via_symbols
