	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function via_cable_detect
_via_cable_detect:                      ## @via_cable_detect
	.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	8(%rdi), %rax
	movq	8(%rax), %r15
	movl	(%rax), %edi
	callq	_to_pci_dev
	movq	%rax, %rbx
	movq	%rax, %rdi
	callq	_via_cable_override
	testq	%rax, %rax
	je	LBB0_2
## %bb.1:
	movq	_ATA_CBL_PATA40_SHORT@GOTPCREL(%rip), %rbx
	jmp	LBB0_12
LBB0_2:
	movl	(%r15), %eax
	movq	_VIA_SATA_PATA@GOTPCREL(%rip), %rcx
	testl	%eax, (%rcx)
	je	LBB0_5
## %bb.3:
	cmpl	$0, (%r14)
	je	LBB0_4
LBB0_5:
	movq	_VIA_UDMA@GOTPCREL(%rip), %rcx
	andl	(%rcx), %eax
	movq	_VIA_UDMA_66@GOTPCREL(%rip), %rcx
	movq	_ATA_CBL_PATA40@GOTPCREL(%rip), %r15
	cmpl	(%rcx), %eax
	jge	LBB0_6
LBB0_11:
	movq	%r15, %rbx
	jmp	LBB0_12
LBB0_6:
	movq	_VIA_UDMA_100@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jge	LBB0_8
## %bb.7:
	movq	_ATA_CBL_PATA_UNK@GOTPCREL(%rip), %rbx
	jmp	LBB0_12
LBB0_4:
	movq	_ATA_CBL_SATA@GOTPCREL(%rip), %rbx
	jmp	LBB0_12
LBB0_8:
	leaq	-28(%rbp), %rdx
	movq	%rbx, %rdi
	movl	$80, %esi
	callq	_pci_read_config_dword
	movl	-28(%rbp), %eax
	movb	(%r14), %cl
	shlb	$4, %cl
	shll	%cl, %eax
	movq	_ATA_CBL_PATA80@GOTPCREL(%rip), %rbx
	testl	$269484032, %eax                ## imm = 0x10100000
	je	LBB0_9
LBB0_12:
	movl	(%rbx), %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_9:
	movq	%r14, %rdi
	callq	_ata_acpi_init_gtm
	testq	%rax, %rax
	je	LBB0_11
## %bb.10:
	movq	%r14, %rdi
	callq	_ata_acpi_init_gtm
	movq	%r14, %rdi
	movq	%rax, %rsi
	callq	_ata_acpi_cbl_80wire
	testq	%rax, %rax
	jne	LBB0_12
	jmp	LBB0_11
	.cfi_endproc
                                        ## -- End function
	.comm	_ATA_CBL_PATA40_SHORT,4,2       ## @ATA_CBL_PATA40_SHORT
	.comm	_VIA_SATA_PATA,4,2              ## @VIA_SATA_PATA
	.comm	_ATA_CBL_SATA,4,2               ## @ATA_CBL_SATA
	.comm	_VIA_UDMA,4,2                   ## @VIA_UDMA
	.comm	_VIA_UDMA_66,4,2                ## @VIA_UDMA_66
	.comm	_ATA_CBL_PATA40,4,2             ## @ATA_CBL_PATA40
	.comm	_VIA_UDMA_100,4,2               ## @VIA_UDMA_100
	.comm	_ATA_CBL_PATA_UNK,4,2           ## @ATA_CBL_PATA_UNK
	.comm	_ATA_CBL_PATA80,4,2             ## @ATA_CBL_PATA80
	.no_dead_strip	_via_cable_detect
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function via_cable_detect
_via_cable_detect:                      ; @via_cable_detect
	.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, x0
	ldr	x8, [x0, #8]
	ldr	x21, [x8, #8]
	ldr	w0, [x8]
	bl	_to_pci_dev
	mov	x20, x0
	bl	_via_cable_override
	cbz	x0, LBB0_2
; %bb.1:
Lloh0:
	adrp	x8, _ATA_CBL_PATA40_SHORT@GOTPAGE
Lloh1:
	ldr	x8, [x8, _ATA_CBL_PATA40_SHORT@GOTPAGEOFF]
	b	LBB0_11
LBB0_2:
	ldr	w8, [x21]
Lloh2:
	adrp	x9, _VIA_SATA_PATA@GOTPAGE
Lloh3:
	ldr	x9, [x9, _VIA_SATA_PATA@GOTPAGEOFF]
Lloh4:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_4
; %bb.3:
	ldr	w9, [x19]
	cbz	w9, LBB0_8
LBB0_4:
Lloh5:
	adrp	x9, _VIA_UDMA@GOTPAGE
Lloh6:
	ldr	x9, [x9, _VIA_UDMA@GOTPAGEOFF]
Lloh7:
	ldr	w9, [x9]
	and	w8, w9, w8
Lloh8:
	adrp	x9, _VIA_UDMA_66@GOTPAGE
Lloh9:
	ldr	x9, [x9, _VIA_UDMA_66@GOTPAGEOFF]
Lloh10:
	ldr	w9, [x9]
	cmp	w8, w9
	b.ge	LBB0_6
LBB0_5:
Lloh11:
	adrp	x8, _ATA_CBL_PATA40@GOTPAGE
Lloh12:
	ldr	x8, [x8, _ATA_CBL_PATA40@GOTPAGEOFF]
	b	LBB0_11
LBB0_6:
Lloh13:
	adrp	x9, _VIA_UDMA_100@GOTPAGE
Lloh14:
	ldr	x9, [x9, _VIA_UDMA_100@GOTPAGEOFF]
Lloh15:
	ldr	w9, [x9]
	cmp	w8, w9
	b.ge	LBB0_9
; %bb.7:
Lloh16:
	adrp	x8, _ATA_CBL_PATA_UNK@GOTPAGE
Lloh17:
	ldr	x8, [x8, _ATA_CBL_PATA_UNK@GOTPAGEOFF]
	b	LBB0_11
LBB0_8:
Lloh18:
	adrp	x8, _ATA_CBL_SATA@GOTPAGE
Lloh19:
	ldr	x8, [x8, _ATA_CBL_SATA@GOTPAGEOFF]
	b	LBB0_11
LBB0_9:
	add	x2, sp, #12
	mov	x0, x20
	mov	w1, #80
	bl	_pci_read_config_dword
	ldr	w8, [sp, #12]
	ldr	w9, [x19]
	lsl	w9, w9, #4
	lsl	w8, w8, w9
	mov	w9, #269484032
	tst	w8, w9
	b.eq	LBB0_12
LBB0_10:
Lloh20:
	adrp	x8, _ATA_CBL_PATA80@GOTPAGE
Lloh21:
	ldr	x8, [x8, _ATA_CBL_PATA80@GOTPAGEOFF]
LBB0_11:
	ldr	w0, [x8]
	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
LBB0_12:
	mov	x0, x19
	bl	_ata_acpi_init_gtm
	cbz	x0, LBB0_5
; %bb.13:
	mov	x0, x19
	bl	_ata_acpi_init_gtm
	mov	x1, x0
	mov	x0, x19
	bl	_ata_acpi_cbl_80wire
	cbnz	x0, LBB0_10
	b	LBB0_5
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh16, Lloh17
	.loh AdrpLdrGot	Lloh18, Lloh19
	.loh AdrpLdrGot	Lloh20, Lloh21
	.cfi_endproc
                                        ; -- End function
	.comm	_ATA_CBL_PATA40_SHORT,4,2       ; @ATA_CBL_PATA40_SHORT
	.comm	_VIA_SATA_PATA,4,2              ; @VIA_SATA_PATA
	.comm	_ATA_CBL_SATA,4,2               ; @ATA_CBL_SATA
	.comm	_VIA_UDMA,4,2                   ; @VIA_UDMA
	.comm	_VIA_UDMA_66,4,2                ; @VIA_UDMA_66
	.comm	_ATA_CBL_PATA40,4,2             ; @ATA_CBL_PATA40
	.comm	_VIA_UDMA_100,4,2               ; @VIA_UDMA_100
	.comm	_ATA_CBL_PATA_UNK,4,2           ; @ATA_CBL_PATA_UNK
	.comm	_ATA_CBL_PATA80,4,2             ; @ATA_CBL_PATA80
	.no_dead_strip	_via_cable_detect
.subsections_via_symbols
