	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function winbond_set_piomode
_winbond_set_piomode:                   ## @winbond_set_piomode
	.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	%rsi, %r14
	movq	8(%rdi), %rax
	movq	(%rax), %r15
	movl	(%r15), %edi
	movl	$129, %esi
	callq	_winbond_readcfg
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	testb	$64, %al
	movl	16(%r14), %esi
	movl	$30303, %eax                    ## imm = 0x765F
	movl	$20000, %ecx                    ## imm = 0x4E20
	cmovel	%eax, %ecx
	leaq	-56(%rbp), %rdx
	movq	%r14, %rdi
	movl	$1000, %r8d                     ## imm = 0x3E8
	callq	_ata_timing_compute
	movl	-48(%rbp), %edi
	movl	$3, %esi
	movl	$17, %edx
	callq	_clamp_val
	movl	%eax, %ebx
	movl	-52(%rbp), %edi
	movl	$1, %esi
	movl	$15, %edx
	callq	_clamp_val
	movl	%eax, %r12d
	incl	%r12d
	andl	$15, %r12d
	shll	$4, %ebx
	addl	$240, %ebx
	movzbl	%bl, %r13d
	leal	(%r12,%r13), %esi
	movl	(%r15), %edi
	movl	-44(%rbp), %edx                 ## 4-byte Reload
	callq	_winbond_writecfg
	movq	8(%r14), %rax
	movq	_ATA_DEV_ATA@GOTPCREL(%rip), %rcx
	xorl	%ebx, %ebx
	cmpq	(%rcx), %rax
	setne	%bl
	shll	$3, %ebx
	movq	%r14, %rdi
	callq	_ata_pio_need_iordy
	xorl	%ecx, %ecx
	testl	%eax, %eax
	sete	%cl
	leal	(%rbx,%rcx,2), %ebx
	movl	-56(%rbp), %edi
	xorl	%esi, %esi
	movl	$3, %edx
	callq	_clamp_val
                                        ## kill: def $eax killed $eax def $rax
	shll	$6, %eax
	leal	(%rax,%rbx), %edx
	addl	$53, %edx
	movl	(%r15), %edi
	leal	(%r12,%r13), %esi
	incl	%esi
	callq	_winbond_writecfg
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_ATA_DEV_ATA,8,3                ## @ATA_DEV_ATA
	.no_dead_strip	_winbond_set_piomode
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function winbond_set_piomode
_winbond_set_piomode:                   ; @winbond_set_piomode
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #64
	.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
	mov	x19, x1
	ldr	x8, [x0, #8]
	ldr	x22, [x8]
	ldr	w0, [x22]
	mov	w1, #129
	bl	_winbond_readcfg
	mov	x20, x0
	ldr	w1, [x19, #16]
	tst	w0, #0x40
	mov	w8, #20000
	mov	w9, #30303
	csel	w3, w9, w8, eq
	mov	x2, sp
	mov	x0, x19
	mov	w4, #1000
	bl	_ata_timing_compute
	ldr	w0, [sp, #8]
	mov	w1, #3
	mov	w2, #17
	bl	_clamp_val
	mov	x21, x0
	ldr	w0, [sp, #4]
	mov	w1, #1
	mov	w2, #15
	bl	_clamp_val
	add	w8, w0, #1
	lsl	w9, w21, #4
	add	w9, w9, #240
	and	w21, w9, #0xf0
	bfxil	w21, w8, #0, #4
	ldr	w0, [x22]
	mov	x1, x21
	mov	x2, x20
	bl	_winbond_writecfg
Lloh0:
	adrp	x8, _ATA_DEV_ATA@GOTPAGE
Lloh1:
	ldr	x8, [x8, _ATA_DEV_ATA@GOTPAGEOFF]
	ldr	x9, [x19, #8]
Lloh2:
	ldr	x8, [x8]
	cmp	x9, x8
	mov	w8, #61
	mov	w9, #53
	csel	w20, w9, w8, eq
	mov	x0, x19
	bl	_ata_pio_need_iordy
	orr	w8, w20, #0x2
	cmp	w0, #0
	csel	w19, w8, w20, eq
	ldr	w0, [sp]
	mov	w1, #0
	mov	w2, #3
	bl	_clamp_val
	bfi	w19, w0, #6, #26
	ldr	w0, [x22]
	add	w1, w21, #1
	mov	x2, x19
	bl	_winbond_writecfg
	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
	add	sp, sp, #64
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.cfi_endproc
                                        ; -- End function
	.comm	_ATA_DEV_ATA,8,3                ; @ATA_DEV_ATA
	.no_dead_strip	_winbond_set_piomode
.subsections_via_symbols
