	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function v3d_measure_clock
_v3d_measure_clock:                     ## @v3d_measure_clock
	.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	%rbx
	pushq	%rax
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r14
	movq	(%rdi), %rax
	movq	(%rax), %rax
	movq	(%rax), %rdi
	callq	_to_v3d_dev
	movq	%rax, %r15
	movl	4(%rax), %edi
	callq	_pm_runtime_get_sync
	testl	%eax, %eax
	js	LBB0_1
## %bb.2:
	cmpl	$40, (%r15)
	jl	LBB0_4
## %bb.3:
	movq	_V3D_V4_PCTR_0_SRC_0_3@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	movq	_V3D_PCTR_CYCLE_COUNT@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_V3D_PCTR_S0@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_V3D_SET_FIELD
	xorl	%edi, %edi
	movl	%ebx, %esi
	movl	%eax, %edx
	callq	_V3D_CORE_WRITE
	movq	_V3D_V4_PCTR_0_CLR@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	xorl	%edi, %edi
	movl	$1, %edx
	callq	_V3D_CORE_WRITE
	movq	_V3D_V4_PCTR_0_EN@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	xorl	%edi, %edi
	movl	$1, %edx
	jmp	LBB0_5
LBB0_1:
	movl	%eax, %ebx
	jmp	LBB0_6
LBB0_4:
	movq	_V3D_V3_PCTR_0_PCTRS0@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_V3D_PCTR_CYCLE_COUNT@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	xorl	%edi, %edi
	callq	_V3D_CORE_WRITE
	movq	_V3D_V3_PCTR_0_CLR@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	xorl	%edi, %edi
	movl	$1, %edx
	callq	_V3D_CORE_WRITE
	movq	_V3D_V3_PCTR_0_EN@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_V3D_V3_PCTR_0_EN_ENABLE@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	orl	$1, %edx
	xorl	%edi, %edi
LBB0_5:
	callq	_V3D_CORE_WRITE
	movl	$1000, %edi                     ## imm = 0x3E8
	callq	_msleep
	movq	_V3D_PCTR_0_PCTR0@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	xorl	%ebx, %ebx
	xorl	%edi, %edi
	callq	_V3D_CORE_READ
	movslq	%eax, %rdx
	imulq	$1125899907, %rdx, %rcx         ## imm = 0x431BDE83
	movq	%rcx, %rax
	shrq	$63, %rax
	sarq	$50, %rcx
	addl	%eax, %ecx
	imulq	$351843721, %rdx, %rax          ## imm = 0x14F8B589
	movq	%rax, %rsi
	shrq	$63, %rsi
	sarq	$45, %rax
	addl	%esi, %eax
	movswl	%ax, %esi
	imull	$26215, %esi, %esi              ## imm = 0x6667
	movl	%esi, %edi
	shrl	$31, %edi
	sarl	$18, %esi
	addl	%edi, %esi
	addl	%esi, %esi
	leal	(%rsi,%rsi,4), %esi
	subl	%esi, %eax
	movswl	%ax, %r8d
	leaq	L_.str(%rip), %rsi
	movq	%r14, %rdi
                                        ## kill: def $edx killed $edx killed $rdx
                                        ## kill: def $ecx killed $ecx killed $rcx
	callq	_seq_printf
	movl	4(%r15), %edi
	callq	_pm_runtime_mark_last_busy
	movl	4(%r15), %edi
	callq	_pm_runtime_put_autosuspend
LBB0_6:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_V3D_V4_PCTR_0_SRC_0_3,4,2      ## @V3D_V4_PCTR_0_SRC_0_3
	.comm	_V3D_PCTR_CYCLE_COUNT,4,2       ## @V3D_PCTR_CYCLE_COUNT
	.comm	_V3D_PCTR_S0,4,2                ## @V3D_PCTR_S0
	.comm	_V3D_V4_PCTR_0_CLR,4,2          ## @V3D_V4_PCTR_0_CLR
	.comm	_V3D_V4_PCTR_0_EN,4,2           ## @V3D_V4_PCTR_0_EN
	.comm	_V3D_V3_PCTR_0_PCTRS0,4,2       ## @V3D_V3_PCTR_0_PCTRS0
	.comm	_V3D_V3_PCTR_0_CLR,4,2          ## @V3D_V3_PCTR_0_CLR
	.comm	_V3D_V3_PCTR_0_EN,4,2           ## @V3D_V3_PCTR_0_EN
	.comm	_V3D_V3_PCTR_0_EN_ENABLE,4,2    ## @V3D_V3_PCTR_0_EN_ENABLE
	.comm	_V3D_PCTR_0_PCTR0,4,2           ## @V3D_PCTR_0_PCTR0
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"cycles: %d (%d.%d Mhz)\n"

	.no_dead_strip	_v3d_measure_clock
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function v3d_measure_clock
_v3d_measure_clock:                     ; @v3d_measure_clock
	.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	x20, x0
	ldr	x8, [x0]
	ldr	x8, [x8]
	ldr	x0, [x8]
	bl	_to_v3d_dev
	mov	x19, x0
	ldr	w0, [x0, #4]
	bl	_pm_runtime_get_sync
	tbnz	w0, #31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loh21:
	adrp	x8, _V3D_V3_PCTR_0_CLR@GOTPAGE
Lloh22:
	ldr	x8, [x8, _V3D_V3_PCTR_0_CLR@GOTPAGEOFF]
Lloh23:
	ldr	w1, [x8]
	mov	w0, #0
	mov	w2, #1
	bl	_V3D_CORE_WRITE
Lloh24:
	adrp	x8, _V3D_V3_PCTR_0_EN@GOTPAGE
Lloh25:
	ldr	x8, [x8, _V3D_V3_PCTR_0_EN@GOTPAGEOFF]
Lloh26:
	ldr	w1, [x8]
Lloh27:
	adrp	x8, _V3D_V3_PCTR_0_EN_ENABLE@GOTPAGE
Lloh28:
	ldr	x8, [x8, _V3D_V3_PCTR_0_EN_ENABLE@GOTPAGEOFF]
Lloh29:
	ldr	w8, [x8]
	orr	w2, w8, #0x1
	mov	w0, #0
LBB0_4:
	bl	_V3D_CORE_WRITE
	mov	w0, #1000
	bl	_msleep
Lloh30:
	adrp	x8, _V3D_PCTR_0_PCTR0@GOTPAGE
Lloh31:
	ldr	x8, [x8, _V3D_PCTR_0_PCTR0@GOTPAGEOFF]
Lloh32:
	ldr	w1, [x8]
	mov	w0, #0
	bl	_V3D_CORE_READ
	mov	x2, x0
	mov	w8, #56963
	movk	w8, #17179, lsl #16
	smull	x8, w0, w8
	lsr	x9, x8, #63
	asr	x8, x8, #50
	add	w3, w8, w9
	mov	w8, #46473
	movk	w8, #5368, lsl #16
	smull	x8, w0, w8
	lsr	x9, x8, #63
	asr	x8, x8, #45
	add	w8, w8, w9
	sxth	w9, w8
	mov	w10, #26215
	mul	w9, w9, w10
	asr	w10, w9, #18
	add	w9, w10, w9, lsr #31
	mov	w10, #10
	msub	w8, w9, w10, w8
	sxth	w4, w8
Lloh33:
	adrp	x1, l_.str@PAGE
Lloh34:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x20
	bl	_seq_printf
	ldr	w0, [x19, #4]
	bl	_pm_runtime_mark_last_busy
	ldr	w0, [x19, #4]
	bl	_pm_runtime_put_autosuspend
	mov	w0, #0
LBB0_5:
	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	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh27, Lloh28, Lloh29
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpAdd	Lloh33, Lloh34
	.loh AdrpLdrGotLdr	Lloh30, Lloh31, Lloh32
	.cfi_endproc
                                        ; -- End function
	.comm	_V3D_V4_PCTR_0_SRC_0_3,4,2      ; @V3D_V4_PCTR_0_SRC_0_3
	.comm	_V3D_PCTR_CYCLE_COUNT,4,2       ; @V3D_PCTR_CYCLE_COUNT
	.comm	_V3D_PCTR_S0,4,2                ; @V3D_PCTR_S0
	.comm	_V3D_V4_PCTR_0_CLR,4,2          ; @V3D_V4_PCTR_0_CLR
	.comm	_V3D_V4_PCTR_0_EN,4,2           ; @V3D_V4_PCTR_0_EN
	.comm	_V3D_V3_PCTR_0_PCTRS0,4,2       ; @V3D_V3_PCTR_0_PCTRS0
	.comm	_V3D_V3_PCTR_0_CLR,4,2          ; @V3D_V3_PCTR_0_CLR
	.comm	_V3D_V3_PCTR_0_EN,4,2           ; @V3D_V3_PCTR_0_EN
	.comm	_V3D_V3_PCTR_0_EN_ENABLE,4,2    ; @V3D_V3_PCTR_0_EN_ENABLE
	.comm	_V3D_PCTR_0_PCTR0,4,2           ; @V3D_PCTR_0_PCTR0
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"cycles: %d (%d.%d Mhz)\n"

	.no_dead_strip	_v3d_measure_clock
.subsections_via_symbols
