	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function ata_eh_speed_down
_ata_eh_speed_down:                     ## @ata_eh_speed_down
	.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
	movl	%edx, %r12d
	movl	%esi, %ebx
	movq	%rdi, %r14
	callq	_ata_dev_phys_link
	movq	%rax, %r13
	movl	$0, -44(%rbp)
	leaq	-44(%rbp), %rdx
	movl	%ebx, %edi
	movl	%r12d, %esi
	callq	_ata_eh_categorize_error
	xorl	%r15d, %r15d
	testq	%rax, %rax
	je	LBB0_18
## %bb.1:
	leaq	24(%r14), %rdi
	movq	%rdi, -56(%rbp)                 ## 8-byte Spill
	movl	%ebx, %esi
	movl	%r12d, %edx
	callq	_ata_ering_record
	movq	%r14, %rdi
	callq	_ata_eh_speed_down_verdict
	movl	%eax, %r12d
	movq	_ATA_EH_SPDN_NCQ_OFF@GOTPCREL(%rip), %rax
	testl	%r12d, (%rax)
	je	LBB0_4
## %bb.2:
	movl	(%r14), %eax
	movq	_ATA_DFLAG_PIO@GOTPCREL(%rip), %rcx
	movq	_ATA_DFLAG_NCQ@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
	movl	(%rcx), %esi
	orl	%edx, %esi
	movq	_ATA_DFLAG_NCQ_OFF@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	orl	%ecx, %esi
	andl	%eax, %esi
	cmpl	%edx, %esi
	jne	LBB0_4
## %bb.3:
	orl	%eax, %ecx
	movl	%ecx, (%r14)
	movq	_KERN_WARNING@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	L_.str(%rip), %rdx
	movq	%r14, %rdi
	callq	_ata_dev_printk
	xorl	%r15d, %r15d
	jmp	LBB0_16
LBB0_4:
	movq	_ATA_EH_SPDN_SPEED_DOWN@GOTPCREL(%rip), %rax
	testl	%r12d, (%rax)
	je	LBB0_8
## %bb.5:
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	_sata_down_spd_limit
	testq	%rax, %rax
	je	LBB0_15
## %bb.6:
	movslq	4(%r14), %rax
	cmpq	$1, %rax
	jg	LBB0_8
## %bb.7:
	movq	8(%r14), %rcx
	movq	_ATA_SHIFT_PIO@GOTPCREL(%rip), %rdx
	cmpq	(%rdx), %rcx
	leaq	_ata_eh_speed_down.pio_dnxfer_sel(%rip), %rcx
	leaq	_ata_eh_speed_down.dma_dnxfer_sel(%rip), %rdx
	cmoveq	%rcx, %rdx
	movl	(%rdx,%rax,4), %esi
	incl	%eax
	movl	%eax, 4(%r14)
	movq	%r14, %rdi
	callq	_ata_down_xfermask_limit
	testq	%rax, %rax
	je	LBB0_15
LBB0_8:
	movq	_ATA_EH_SPDN_FALLBACK_TO_PIO@GOTPCREL(%rip), %rax
	testl	%r12d, (%rax)
	je	LBB0_18
## %bb.9:
	cmpl	$2, 4(%r14)
	jl	LBB0_18
## %bb.10:
	movq	(%r13), %rax
	movq	(%rax), %rax
	movq	_ATA_CBL_SATA@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_12
## %bb.11:
	movq	16(%r14), %rax
	movq	_ATA_DEV_ATAPI@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_18
LBB0_12:
	movq	8(%r14), %rax
	movq	_ATA_SHIFT_PIO@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	je	LBB0_18
## %bb.13:
	movq	_ATA_DNXFER_FORCE_PIO@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	callq	_ata_down_xfermask_limit
	testq	%rax, %rax
	jne	LBB0_18
## %bb.14:
	movl	$0, 4(%r14)
LBB0_15:
	movq	_ATA_EH_RESET@GOTPCREL(%rip), %rax
	movl	(%rax), %r15d
LBB0_16:
	movq	_ATA_EH_SPDN_KEEP_ERRORS@GOTPCREL(%rip), %rax
	testl	%r12d, (%rax)
	jne	LBB0_18
## %bb.17:
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_ata_ering_clear
LBB0_18:
	movl	%r15d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_ATA_EH_SPDN_NCQ_OFF,4,2        ## @ATA_EH_SPDN_NCQ_OFF
	.comm	_ATA_DFLAG_PIO,4,2              ## @ATA_DFLAG_PIO
	.comm	_ATA_DFLAG_NCQ,4,2              ## @ATA_DFLAG_NCQ
	.comm	_ATA_DFLAG_NCQ_OFF,4,2          ## @ATA_DFLAG_NCQ_OFF
	.comm	_KERN_WARNING,4,2               ## @KERN_WARNING
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"NCQ disabled due to excessive errors\n"

	.comm	_ATA_EH_SPDN_SPEED_DOWN,4,2     ## @ATA_EH_SPDN_SPEED_DOWN
	.comm	_ATA_EH_RESET,4,2               ## @ATA_EH_RESET
	.section	__TEXT,__const
	.p2align	2                               ## @ata_eh_speed_down.dma_dnxfer_sel
_ata_eh_speed_down.dma_dnxfer_sel:
	.long	130                             ## 0x82
	.long	131                             ## 0x83

	.p2align	2                               ## @ata_eh_speed_down.pio_dnxfer_sel
_ata_eh_speed_down.pio_dnxfer_sel:
	.long	128                             ## 0x80
	.long	129                             ## 0x81

	.comm	_ATA_SHIFT_PIO,8,3              ## @ATA_SHIFT_PIO
	.comm	_ATA_EH_SPDN_FALLBACK_TO_PIO,4,2 ## @ATA_EH_SPDN_FALLBACK_TO_PIO
	.comm	_ATA_CBL_SATA,8,3               ## @ATA_CBL_SATA
	.comm	_ATA_DEV_ATAPI,8,3              ## @ATA_DEV_ATAPI
	.comm	_ATA_DNXFER_FORCE_PIO,4,2       ## @ATA_DNXFER_FORCE_PIO
	.comm	_ATA_EH_SPDN_KEEP_ERRORS,4,2    ## @ATA_EH_SPDN_KEEP_ERRORS
	.no_dead_strip	_ata_eh_speed_down
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function ata_eh_speed_down
_ata_eh_speed_down:                     ; @ata_eh_speed_down
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	mov	x20, x2
	mov	x23, x1
	mov	x21, x0
	bl	_ata_dev_phys_link
	mov	x22, x0
	str	wzr, [sp, #12]
	add	x2, sp, #12
	mov	x0, x23
	mov	x1, x20
	bl	_ata_eh_categorize_error
	cbz	x0, LBB0_14
; %bb.1:
	add	x19, x21, #24
	mov	x0, x19
	mov	x1, x23
	mov	x2, x20
	bl	_ata_ering_record
	mov	x0, x21
	bl	_ata_eh_speed_down_verdict
	mov	x20, x0
Lloh0:
	adrp	x8, _ATA_EH_SPDN_NCQ_OFF@GOTPAGE
Lloh1:
	ldr	x8, [x8, _ATA_EH_SPDN_NCQ_OFF@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	tst	w8, w0
	b.eq	LBB0_4
; %bb.2:
Lloh3:
	adrp	x9, _ATA_DFLAG_PIO@GOTPAGE
Lloh4:
	ldr	x9, [x9, _ATA_DFLAG_PIO@GOTPAGEOFF]
	ldr	w8, [x21]
Lloh5:
	ldr	w9, [x9]
Lloh6:
	adrp	x10, _ATA_DFLAG_NCQ@GOTPAGE
Lloh7:
	ldr	x10, [x10, _ATA_DFLAG_NCQ@GOTPAGEOFF]
Lloh8:
	ldr	w10, [x10]
	orr	w11, w10, w9
Lloh9:
	adrp	x9, _ATA_DFLAG_NCQ_OFF@GOTPAGE
Lloh10:
	ldr	x9, [x9, _ATA_DFLAG_NCQ_OFF@GOTPAGEOFF]
Lloh11:
	ldr	w9, [x9]
	orr	w11, w11, w9
	and	w11, w11, w8
	cmp	w11, w10
	b.ne	LBB0_4
; %bb.3:
	orr	w8, w9, w8
	str	w8, [x21]
Lloh12:
	adrp	x8, _KERN_WARNING@GOTPAGE
Lloh13:
	ldr	x8, [x8, _KERN_WARNING@GOTPAGEOFF]
Lloh14:
	ldr	w1, [x8]
Lloh15:
	adrp	x2, l_.str@PAGE
Lloh16:
	add	x2, x2, l_.str@PAGEOFF
	mov	x0, x21
	bl	_ata_dev_printk
	mov	w21, #0
	b	LBB0_17
LBB0_4:
Lloh17:
	adrp	x8, _ATA_EH_SPDN_SPEED_DOWN@GOTPAGE
Lloh18:
	ldr	x8, [x8, _ATA_EH_SPDN_SPEED_DOWN@GOTPAGEOFF]
Lloh19:
	ldr	w8, [x8]
	tst	w8, w20
	b.eq	LBB0_8
; %bb.5:
	mov	x0, x22
	mov	w1, #0
	bl	_sata_down_spd_limit
	cbz	x0, LBB0_16
; %bb.6:
	ldrsw	x8, [x21, #4]
	cmp	w8, #1
	b.gt	LBB0_8
; %bb.7:
Lloh20:
	adrp	x9, _ATA_SHIFT_PIO@GOTPAGE
Lloh21:
	ldr	x9, [x9, _ATA_SHIFT_PIO@GOTPAGEOFF]
	ldr	x10, [x21, #8]
Lloh22:
	ldr	x9, [x9]
Lloh23:
	adrp	x11, _ata_eh_speed_down.dma_dnxfer_sel@PAGE
Lloh24:
	add	x11, x11, _ata_eh_speed_down.dma_dnxfer_sel@PAGEOFF
Lloh25:
	adrp	x12, _ata_eh_speed_down.pio_dnxfer_sel@PAGE
Lloh26:
	add	x12, x12, _ata_eh_speed_down.pio_dnxfer_sel@PAGEOFF
	cmp	x10, x9
	csel	x9, x12, x11, eq
	ldr	w1, [x9, x8, lsl #2]
	add	w8, w8, #1
	str	w8, [x21, #4]
	mov	x0, x21
	bl	_ata_down_xfermask_limit
	cbz	x0, LBB0_16
LBB0_8:
Lloh27:
	adrp	x8, _ATA_EH_SPDN_FALLBACK_TO_PIO@GOTPAGE
Lloh28:
	ldr	x8, [x8, _ATA_EH_SPDN_FALLBACK_TO_PIO@GOTPAGEOFF]
Lloh29:
	ldr	w8, [x8]
	tst	w8, w20
	b.eq	LBB0_14
; %bb.9:
	ldr	w8, [x21, #4]
	cmp	w8, #2
	b.lt	LBB0_14
; %bb.10:
	ldr	x8, [x22]
	ldr	x8, [x8]
Lloh30:
	adrp	x9, _ATA_CBL_SATA@GOTPAGE
Lloh31:
	ldr	x9, [x9, _ATA_CBL_SATA@GOTPAGEOFF]
Lloh32:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_12
; %bb.11:
	ldr	x8, [x21, #16]
Lloh33:
	adrp	x9, _ATA_DEV_ATAPI@GOTPAGE
Lloh34:
	ldr	x9, [x9, _ATA_DEV_ATAPI@GOTPAGEOFF]
Lloh35:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_14
LBB0_12:
	ldr	x8, [x21, #8]
Lloh36:
	adrp	x9, _ATA_SHIFT_PIO@GOTPAGE
Lloh37:
	ldr	x9, [x9, _ATA_SHIFT_PIO@GOTPAGEOFF]
Lloh38:
	ldr	x9, [x9]
	cmp	x8, x9
	b.eq	LBB0_14
; %bb.13:
Lloh39:
	adrp	x8, _ATA_DNXFER_FORCE_PIO@GOTPAGE
Lloh40:
	ldr	x8, [x8, _ATA_DNXFER_FORCE_PIO@GOTPAGEOFF]
Lloh41:
	ldr	w1, [x8]
	mov	x0, x21
	bl	_ata_down_xfermask_limit
	cbz	x0, LBB0_15
LBB0_14:
	mov	w21, #0
	b	LBB0_19
LBB0_15:
	str	wzr, [x21, #4]
LBB0_16:
Lloh42:
	adrp	x8, _ATA_EH_RESET@GOTPAGE
Lloh43:
	ldr	x8, [x8, _ATA_EH_RESET@GOTPAGEOFF]
Lloh44:
	ldr	w21, [x8]
LBB0_17:
Lloh45:
	adrp	x8, _ATA_EH_SPDN_KEEP_ERRORS@GOTPAGE
Lloh46:
	ldr	x8, [x8, _ATA_EH_SPDN_KEEP_ERRORS@GOTPAGEOFF]
Lloh47:
	ldr	w8, [x8]
	tst	w8, w20
	b.ne	LBB0_19
; %bb.18:
	mov	x0, x19
	bl	_ata_ering_clear
LBB0_19:
	mov	x0, x21
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #80
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpAdd	Lloh23, Lloh24
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh27, Lloh28, Lloh29
	.loh AdrpLdrGotLdr	Lloh30, Lloh31, Lloh32
	.loh AdrpLdrGotLdr	Lloh33, Lloh34, Lloh35
	.loh AdrpLdrGotLdr	Lloh36, Lloh37, Lloh38
	.loh AdrpLdrGotLdr	Lloh39, Lloh40, Lloh41
	.loh AdrpLdrGotLdr	Lloh42, Lloh43, Lloh44
	.loh AdrpLdrGotLdr	Lloh45, Lloh46, Lloh47
	.cfi_endproc
                                        ; -- End function
	.comm	_ATA_EH_SPDN_NCQ_OFF,4,2        ; @ATA_EH_SPDN_NCQ_OFF
	.comm	_ATA_DFLAG_PIO,4,2              ; @ATA_DFLAG_PIO
	.comm	_ATA_DFLAG_NCQ,4,2              ; @ATA_DFLAG_NCQ
	.comm	_ATA_DFLAG_NCQ_OFF,4,2          ; @ATA_DFLAG_NCQ_OFF
	.comm	_KERN_WARNING,4,2               ; @KERN_WARNING
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"NCQ disabled due to excessive errors\n"

	.comm	_ATA_EH_SPDN_SPEED_DOWN,4,2     ; @ATA_EH_SPDN_SPEED_DOWN
	.comm	_ATA_EH_RESET,4,2               ; @ATA_EH_RESET
	.section	__TEXT,__const
	.p2align	2                               ; @ata_eh_speed_down.dma_dnxfer_sel
_ata_eh_speed_down.dma_dnxfer_sel:
	.long	130                             ; 0x82
	.long	131                             ; 0x83

	.p2align	2                               ; @ata_eh_speed_down.pio_dnxfer_sel
_ata_eh_speed_down.pio_dnxfer_sel:
	.long	128                             ; 0x80
	.long	129                             ; 0x81

	.comm	_ATA_SHIFT_PIO,8,3              ; @ATA_SHIFT_PIO
	.comm	_ATA_EH_SPDN_FALLBACK_TO_PIO,4,2 ; @ATA_EH_SPDN_FALLBACK_TO_PIO
	.comm	_ATA_CBL_SATA,8,3               ; @ATA_CBL_SATA
	.comm	_ATA_DEV_ATAPI,8,3              ; @ATA_DEV_ATAPI
	.comm	_ATA_DNXFER_FORCE_PIO,4,2       ; @ATA_DNXFER_FORCE_PIO
	.comm	_ATA_EH_SPDN_KEEP_ERRORS,4,2    ; @ATA_EH_SPDN_KEEP_ERRORS
	.no_dead_strip	_ata_eh_speed_down
.subsections_via_symbols
