	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_amdgpu_display_get_crtc_scanoutpos ## -- Begin function amdgpu_display_get_crtc_scanoutpos
	.p2align	4, 0x90
_amdgpu_display_get_crtc_scanoutpos:    ## @amdgpu_display_get_crtc_scanoutpos
	.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	%r8, %rbx
	movq	%rcx, %r14
	movl	%edx, %r12d
	movl	%esi, -44(%rbp)                 ## 4-byte Spill
	movl	$0, -52(%rbp)
	movl	$0, -48(%rbp)
	movq	(%rdi), %rax
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	testq	%r9, %r9
	je	LBB0_2
## %bb.1:
	movq	%r9, %r15
	xorl	%eax, %eax
	callq	_ktime_get
	movl	%eax, (%r15)
LBB0_2:
	movq	16(%rbp), %r13
	leaq	-52(%rbp), %rdx
	leaq	-48(%rbp), %rcx
	movq	-64(%rbp), %rdi                 ## 8-byte Reload
	movl	-44(%rbp), %esi                 ## 4-byte Reload
	callq	_amdgpu_display_page_flip_get_scanoutpos
	xorl	%r15d, %r15d
	testq	%rax, %rax
	jne	LBB0_4
## %bb.3:
	movq	_DRM_SCANOUTPOS_VALID@GOTPCREL(%rip), %rax
	movl	(%rax), %r15d
LBB0_4:
	testq	%r13, %r13
	je	LBB0_6
## %bb.5:
	xorl	%eax, %eax
	callq	_ktime_get
	movl	%eax, (%r13)
LBB0_6:
	movq	24(%rbp), %r8
	movl	-48(%rbp), %eax
	movl	%eax, %ecx
	andl	$8191, %ecx                     ## imm = 0x1FFF
	movl	%ecx, (%r14)
	shrl	$16, %eax
	andl	$8191, %eax                     ## imm = 0x1FFF
	movl	%eax, (%rbx)
	movl	-52(%rbp), %ecx
	testl	%ecx, %ecx
	jle	LBB0_8
## %bb.7:
	movq	_DRM_SCANOUTPOS_ACCURATE@GOTPCREL(%rip), %rax
	orl	(%rax), %r15d
	movl	%ecx, %edx
	andl	$8191, %edx                     ## imm = 0x1FFF
	shrl	$16, %ecx
	andl	$8191, %ecx                     ## imm = 0x1FFF
	jmp	LBB0_9
LBB0_8:
	movl	(%r8), %edx
	xorl	%ecx, %ecx
LBB0_9:
	movq	_GET_DISTANCE_TO_VBLANKSTART@GOTPCREL(%rip), %rax
	testl	%r12d, (%rax)
	je	LBB0_11
## %bb.10:
	movl	(%r14), %esi
	subl	%edx, %esi
	movl	%esi, (%rbx)
LBB0_11:
	movq	_USE_REAL_VBLANKSTART@GOTPCREL(%rip), %rsi
	testl	%r12d, (%rsi)
	jne	LBB0_13
## %bb.12:
	movq	-64(%rbp), %rsi                 ## 8-byte Reload
	movq	(%rsi), %rsi
	movl	-44(%rbp), %edi                 ## 4-byte Reload
	movq	(%rsi,%rdi,8), %rsi
	subl	(%rsi), %edx
LBB0_13:
	movl	(%r14), %ebx
	movq	_DRM_SCANOUTPOS_IN_VBLANK@GOTPCREL(%rip), %rsi
	movl	(%rsi), %edi
	testl	%r12d, (%rax)
	je	LBB0_15
## %bb.14:
	movl	%ebx, %esi
	subl	%edx, %esi
	jmp	LBB0_18
LBB0_15:
	movl	%ebx, %esi
	cmpl	%edx, %ebx
	jl	LBB0_17
## %bb.16:
	xorl	%eax, %eax
	movl	%ebx, %esi
	subl	4(%r8), %esi
	cmovgel	%eax, %esi
LBB0_17:
	subl	%ecx, %esi
LBB0_18:
	xorl	%eax, %eax
	cmpl	%ecx, %ebx
	cmovll	%edi, %eax
	cmpl	%edx, %ebx
	cmovgel	%edi, %eax
	orl	%r15d, %eax
	movl	%esi, (%r14)
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_DRM_SCANOUTPOS_VALID,4,2       ## @DRM_SCANOUTPOS_VALID
	.comm	_DRM_SCANOUTPOS_ACCURATE,4,2    ## @DRM_SCANOUTPOS_ACCURATE
	.comm	_GET_DISTANCE_TO_VBLANKSTART,4,2 ## @GET_DISTANCE_TO_VBLANKSTART
	.comm	_USE_REAL_VBLANKSTART,4,2       ## @USE_REAL_VBLANKSTART
	.comm	_DRM_SCANOUTPOS_IN_VBLANK,4,2   ## @DRM_SCANOUTPOS_IN_VBLANK
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_amdgpu_display_get_crtc_scanoutpos ; -- Begin function amdgpu_display_get_crtc_scanoutpos
	.p2align	2
_amdgpu_display_get_crtc_scanoutpos:    ; @amdgpu_display_get_crtc_scanoutpos
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #96
	.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
	mov	x20, x7
	mov	x25, x6
	mov	x23, x4
	mov	x19, x3
	mov	x21, x2
	mov	x22, x1
	str	xzr, [sp, #8]
	ldr	x24, [x0]
	cbz	x5, LBB0_2
; %bb.1:
	mov	x26, x5
	bl	_ktime_get
	str	w0, [x26]
LBB0_2:
	add	x2, sp, #12
	add	x3, sp, #8
	mov	x0, x24
	mov	x1, x22
	bl	_amdgpu_display_page_flip_get_scanoutpos
Lloh0:
	adrp	x8, _DRM_SCANOUTPOS_VALID@GOTPAGE
Lloh1:
	ldr	x8, [x8, _DRM_SCANOUTPOS_VALID@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	cmp	x0, #0
	csel	w26, w8, wzr, eq
	cbz	x25, LBB0_4
; %bb.3:
	bl	_ktime_get
	str	w0, [x25]
LBB0_4:
	ldr	w8, [sp, #8]
	and	w9, w8, #0x1fff
	str	w9, [x19]
	ubfx	w8, w8, #16, #13
	str	w8, [x23]
	ldr	w9, [sp, #12]
	cmp	w9, #1
	b.lt	LBB0_6
; %bb.5:
Lloh3:
	adrp	x8, _DRM_SCANOUTPOS_ACCURATE@GOTPAGE
Lloh4:
	ldr	x8, [x8, _DRM_SCANOUTPOS_ACCURATE@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	orr	w26, w8, w26
	and	w8, w9, #0x1fff
	ubfx	w9, w9, #16, #13
	b	LBB0_7
LBB0_6:
	mov	w9, #0
	ldr	w8, [x20]
LBB0_7:
Lloh6:
	adrp	x12, _GET_DISTANCE_TO_VBLANKSTART@GOTPAGE
Lloh7:
	ldr	x12, [x12, _GET_DISTANCE_TO_VBLANKSTART@GOTPAGEOFF]
	ldr	w10, [x12]
	tst	w10, w21
	b.eq	LBB0_9
; %bb.8:
	ldr	w10, [x19]
	sub	w10, w10, w8
	str	w10, [x23]
LBB0_9:
Lloh8:
	adrp	x10, _USE_REAL_VBLANKSTART@GOTPAGE
Lloh9:
	ldr	x10, [x10, _USE_REAL_VBLANKSTART@GOTPAGEOFF]
Lloh10:
	ldr	w10, [x10]
	tst	w10, w21
	b.ne	LBB0_11
; %bb.10:
	ldr	x10, [x24]
	ldr	x10, [x10, w22, uxtw #3]
	ldr	w10, [x10]
	sub	w8, w8, w10
LBB0_11:
	ldr	w10, [x19]
Lloh11:
	adrp	x11, _DRM_SCANOUTPOS_IN_VBLANK@GOTPAGE
Lloh12:
	ldr	x11, [x11, _DRM_SCANOUTPOS_IN_VBLANK@GOTPAGEOFF]
Lloh13:
	ldr	w11, [x11]
	ldr	w12, [x12]
	tst	w12, w21
	b.eq	LBB0_13
; %bb.12:
	sub	w12, w10, w8
	b	LBB0_16
LBB0_13:
	mov	x12, x10
	cmp	w10, w8
	b.lt	LBB0_15
; %bb.14:
	ldr	w12, [x20, #4]
	subs	w12, w10, w12
	csel	w12, w12, wzr, lt
LBB0_15:
	sub	w12, w12, w9
LBB0_16:
	cmp	w10, w9
	ccmp	w10, w8, #0, ge
	csel	w8, wzr, w11, lt
	orr	w0, w8, w26
	str	w12, [x19]
	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
	add	sp, sp, #96
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.cfi_endproc
                                        ; -- End function
	.comm	_DRM_SCANOUTPOS_VALID,4,2       ; @DRM_SCANOUTPOS_VALID
	.comm	_DRM_SCANOUTPOS_ACCURATE,4,2    ; @DRM_SCANOUTPOS_ACCURATE
	.comm	_GET_DISTANCE_TO_VBLANKSTART,4,2 ; @GET_DISTANCE_TO_VBLANKSTART
	.comm	_USE_REAL_VBLANKSTART,4,2       ; @USE_REAL_VBLANKSTART
	.comm	_DRM_SCANOUTPOS_IN_VBLANK,4,2   ; @DRM_SCANOUTPOS_IN_VBLANK
.subsections_via_symbols
