	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function af9035_download_firmware
_af9035_download_firmware:              ## @af9035_download_firmware
	.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	$120, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %r15
	movq	%rdi, %r13
	movq	(%rdi), %r14
	callq	_d_to_priv
	movq	%rax, %r12
	pxor	%xmm0, %xmm0
	movdqa	%xmm0, -128(%rbp)
	movdqa	%xmm0, -144(%rbp)
	movdqa	%xmm0, -160(%rbp)
	movq	_CMD_FW_QUERYINFO@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -96(%rbp)
	movq	$0, -88(%rbp)
	movl	$1, -80(%rbp)
	leaq	-44(%rbp), %rax
	movq	%rax, -72(%rbp)
	movl	$4, -64(%rbp)
	leaq	-112(%rbp), %rax
	movl	%eax, -60(%rbp)
	movl	$0, -56(%rbp)
	leaq	L_.str(%rip), %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	callq	_dev_dbg
	cmpq	$0, 16(%r12)
	je	LBB0_15
## %bb.1:
	movq	%r13, %rdi
	movl	$55472, %esi                    ## imm = 0xD8B0
	movl	$1, %edx
	movl	$1, %ecx
	callq	_af9035_wr_reg_mask
	testl	%eax, %eax
	js	LBB0_27
## %bb.2:
	movq	%r13, %rdi
	movl	$55473, %esi                    ## imm = 0xD8B1
	movl	$1, %edx
	movl	$1, %ecx
	callq	_af9035_wr_reg_mask
	testl	%eax, %eax
	js	LBB0_27
## %bb.3:
	movq	%r13, %rdi
	movl	$55471, %esi                    ## imm = 0xD8AF
	xorl	%edx, %edx
	movl	$1, %ecx
	callq	_af9035_wr_reg_mask
	testl	%eax, %eax
	js	LBB0_27
## %bb.4:
	movl	$10000, %edi                    ## imm = 0x2710
	movl	$50000, %esi                    ## imm = 0xC350
	callq	_usleep_range
	movq	%r13, %rdi
	movl	$55471, %esi                    ## imm = 0xD8AF
	movl	$1, %edx
	movl	$1, %ecx
	callq	_af9035_wr_reg_mask
	testl	%eax, %eax
	js	LBB0_27
## %bb.5:
	movq	(%r12), %rax
	movq	_EEPROM_2ND_DEMOD_ADDR@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movl	(%rax,%rcx,4), %eax
	testl	%eax, %eax
	movl	$58, %edx
	cmovnel	%eax, %edx
	movl	8(%r12), %eax
	cmpl	$37638, %eax                    ## imm = 0x9306
	je	LBB0_7
## %bb.6:
	cmpl	$37173, %eax                    ## imm = 0x9135
	jne	LBB0_13
LBB0_7:
	movq	%r13, %rdi
	movl	$19451, %esi                    ## imm = 0x4BFB
	callq	_af9035_wr_reg
	testl	%eax, %eax
	jns	LBB0_15
	jmp	LBB0_27
LBB0_13:
	movq	%r13, %rdi
	movl	$16767, %esi                    ## imm = 0x417F
	callq	_af9035_wr_reg
	testl	%eax, %eax
	js	LBB0_27
## %bb.14:
	movq	%r13, %rdi
	movl	$55322, %esi                    ## imm = 0xD81A
	movl	$1, %edx
	movl	$1, %ecx
	callq	_af9035_wr_reg_mask
	testl	%eax, %eax
	js	LBB0_27
LBB0_15:
	movq	(%r15), %rax
	cmpl	$1, (%rax)
	jne	LBB0_17
## %bb.16:
	movq	%r13, %rdi
	movq	%r15, %rsi
	callq	_af9035_download_firmware_old
	jmp	LBB0_18
LBB0_17:
	movq	%r13, %rdi
	movq	%r15, %rsi
	callq	_af9035_download_firmware_new
LBB0_18:
	movl	%eax, %ebx
	testl	%eax, %eax
	js	LBB0_28
## %bb.19:
	movq	_CMD_FW_BOOT@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, -128(%rbp)
	leaq	-160(%rbp), %rsi
	movq	%r13, %rdi
	callq	_af9035_ctrl_msg
	testl	%eax, %eax
	js	LBB0_27
## %bb.20:
	movl	$1, -44(%rbp)
	leaq	-96(%rbp), %rsi
	movq	%r13, %rdi
	callq	_af9035_ctrl_msg
	testl	%eax, %eax
	js	LBB0_27
## %bb.21:
	movdqa	-112(%rbp), %xmm0
	ptest	%xmm0, %xmm0
	je	LBB0_25
## %bb.22:
	movd	%xmm0, %edx
	pextrd	$1, %xmm0, %ecx
	pextrd	$2, %xmm0, %r8d
	pextrd	$3, %xmm0, %r9d
	leaq	L_.str.2(%rip), %rsi
	movq	%r14, %rdi
	callq	_dev_info
	xorl	%ebx, %ebx
	jmp	LBB0_29
LBB0_27:
	movl	%eax, %ebx
LBB0_28:
	leaq	L_.str.3(%rip), %rsi
	movq	%r14, %rdi
	movl	%ebx, %edx
	xorl	%eax, %eax
	callq	_dev_dbg
LBB0_29:
	movl	%ebx, %eax
	addq	$120, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_25:
	leaq	L_.str.1(%rip), %rsi
	movq	%r14, %rdi
	callq	_dev_err
	movq	_ENODEV@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_28
	.cfi_endproc
                                        ## -- End function
	.comm	_CMD_FW_QUERYINFO,4,2           ## @CMD_FW_QUERYINFO
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"\n"

	.comm	_EEPROM_2ND_DEMOD_ADDR,8,3      ## @EEPROM_2ND_DEMOD_ADDR
	.comm	_CMD_FW_BOOT,4,2                ## @CMD_FW_BOOT
L_.str.1:                               ## @.str.1
	.asciz	"firmware did not run\n"

	.comm	_ENODEV,4,2                     ## @ENODEV
L_.str.2:                               ## @.str.2
	.asciz	"firmware version=%d.%d.%d.%d"

L_.str.3:                               ## @.str.3
	.asciz	"failed=%d\n"

	.no_dead_strip	_af9035_download_firmware
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function af9035_download_firmware
_af9035_download_firmware:              ; @af9035_download_firmware
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #208
	.cfi_def_cfa_offset 208
	stp	x24, x23, [sp, #144]            ; 16-byte Folded Spill
	stp	x22, x21, [sp, #160]            ; 16-byte Folded Spill
	stp	x20, x19, [sp, #176]            ; 16-byte Folded Spill
	stp	x29, x30, [sp, #192]            ; 16-byte Folded Spill
	add	x29, sp, #192
	.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	x21, x1
	mov	x20, x0
Lloh0:
	adrp	x8, ___stack_chk_guard@GOTPAGE
Lloh1:
	ldr	x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	stur	x8, [x29, #-56]
	ldr	x19, [x0]
	bl	_d_to_priv
	mov	x22, x0
	movi.2d	v0, #0000000000000000
	stp	q0, q0, [sp, #80]
	str	q0, [sp, #64]
Lloh3:
	adrp	x8, _CMD_FW_QUERYINFO@GOTPAGE
Lloh4:
	ldr	x8, [x8, _CMD_FW_QUERYINFO@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	str	w8, [sp, #16]
	str	xzr, [sp, #24]
	mov	w8, #1
	str	w8, [sp, #32]
	sub	x8, x29, #76
	str	x8, [sp, #40]
	mov	w8, #4
	sub	x9, x29, #72
	stp	w8, w9, [sp, #48]
	str	wzr, [sp, #56]
Lloh6:
	adrp	x1, l_.str@PAGE
Lloh7:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x19
	bl	_dev_dbg
	ldr	x8, [x22, #16]
	cbz	x8, LBB0_10
; %bb.1:
	mov	x0, x20
	mov	w1, #55472
	mov	w2, #1
	mov	w3, #1
	bl	_af9035_wr_reg_mask
	tbnz	w0, #31, LBB0_20
; %bb.2:
	mov	x0, x20
	mov	w1, #55473
	mov	w2, #1
	mov	w3, #1
	bl	_af9035_wr_reg_mask
	tbnz	w0, #31, LBB0_20
; %bb.3:
	mov	x0, x20
	mov	w1, #55471
	mov	w2, #0
	mov	w3, #1
	bl	_af9035_wr_reg_mask
	tbnz	w0, #31, LBB0_20
; %bb.4:
	mov	w0, #10000
	mov	w1, #50000
	bl	_usleep_range
	mov	x0, x20
	mov	w1, #55471
	mov	w2, #1
	mov	w3, #1
	bl	_af9035_wr_reg_mask
	tbnz	w0, #31, LBB0_20
; %bb.5:
	ldr	x8, [x22]
Lloh8:
	adrp	x9, _EEPROM_2ND_DEMOD_ADDR@GOTPAGE
Lloh9:
	ldr	x9, [x9, _EEPROM_2ND_DEMOD_ADDR@GOTPAGEOFF]
Lloh10:
	ldr	x9, [x9]
	ldr	w8, [x8, x9, lsl #2]
	mov	w9, #58
	cmp	w8, #0
	csel	w2, w9, w8, eq
	ldr	w8, [x22, #8]
	mov	w9, #37638
	cmp	w8, w9
	b.eq	LBB0_7
; %bb.6:
	mov	w9, #37173
	cmp	w8, w9
	b.ne	LBB0_8
LBB0_7:
	mov	x0, x20
	mov	w1, #19451
	bl	_af9035_wr_reg
	tbz	w0, #31, LBB0_10
	b	LBB0_20
LBB0_8:
	mov	x0, x20
	mov	w1, #16767
	bl	_af9035_wr_reg
	tbnz	w0, #31, LBB0_20
; %bb.9:
	mov	x0, x20
	mov	w1, #55322
	mov	w2, #1
	mov	w3, #1
	bl	_af9035_wr_reg_mask
	tbnz	w0, #31, LBB0_20
LBB0_10:
	ldr	x8, [x21]
	ldr	w8, [x8]
	mov	x0, x20
	mov	x1, x21
	cmp	w8, #1
	b.ne	LBB0_12
; %bb.11:
	bl	_af9035_download_firmware_old
	mov	x23, x0
	tbz	w0, #31, LBB0_13
	b	LBB0_21
LBB0_12:
	bl	_af9035_download_firmware_new
	mov	x23, x0
	tbnz	w0, #31, LBB0_21
LBB0_13:
Lloh11:
	adrp	x8, _CMD_FW_BOOT@GOTPAGE
Lloh12:
	ldr	x8, [x8, _CMD_FW_BOOT@GOTPAGEOFF]
Lloh13:
	ldr	w8, [x8]
	str	w8, [sp, #96]
	add	x1, sp, #64
	mov	x0, x20
	bl	_af9035_ctrl_msg
	tbnz	w0, #31, LBB0_20
; %bb.14:
	mov	w8, #1
	stur	w8, [x29, #-76]
	add	x1, sp, #16
	mov	x0, x20
	bl	_af9035_ctrl_msg
	tbnz	w0, #31, LBB0_20
; %bb.15:
	ldp	w2, w3, [x29, #-72]
	ldp	w4, w5, [x29, #-64]
	cbnz	w2, LBB0_24
; %bb.16:
	cbnz	w3, LBB0_24
; %bb.17:
	cbnz	w4, LBB0_24
; %bb.18:
	cbnz	w5, LBB0_24
; %bb.19:
Lloh14:
	adrp	x1, l_.str.1@PAGE
Lloh15:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x19
	bl	_dev_err
Lloh16:
	adrp	x8, _ENODEV@GOTPAGE
Lloh17:
	ldr	x8, [x8, _ENODEV@GOTPAGEOFF]
Lloh18:
	ldr	w8, [x8]
	neg	w23, w8
	b	LBB0_21
LBB0_20:
	mov	x23, x0
LBB0_21:
	str	x23, [sp]
Lloh19:
	adrp	x1, l_.str.3@PAGE
Lloh20:
	add	x1, x1, l_.str.3@PAGEOFF
	mov	x0, x19
	bl	_dev_dbg
LBB0_22:
	ldur	x8, [x29, #-56]
Lloh21:
	adrp	x9, ___stack_chk_guard@GOTPAGE
Lloh22:
	ldr	x9, [x9, ___stack_chk_guard@GOTPAGEOFF]
Lloh23:
	ldr	x9, [x9]
	cmp	x9, x8
	b.ne	LBB0_25
; %bb.23:
	mov	x0, x23
	ldp	x29, x30, [sp, #192]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #176]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #160]            ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #144]            ; 16-byte Folded Reload
	add	sp, sp, #208
	ret
LBB0_24:
Lloh24:
	adrp	x1, l_.str.2@PAGE
Lloh25:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	x0, x19
	bl	_dev_info
	mov	w23, #0
	b	LBB0_22
LBB0_25:
	bl	___stack_chk_fail
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpAdd	Lloh24, Lloh25
	.cfi_endproc
                                        ; -- End function
	.comm	_CMD_FW_QUERYINFO,4,2           ; @CMD_FW_QUERYINFO
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"\n"

	.comm	_EEPROM_2ND_DEMOD_ADDR,8,3      ; @EEPROM_2ND_DEMOD_ADDR
	.comm	_CMD_FW_BOOT,4,2                ; @CMD_FW_BOOT
l_.str.1:                               ; @.str.1
	.asciz	"firmware did not run\n"

	.comm	_ENODEV,4,2                     ; @ENODEV
l_.str.2:                               ; @.str.2
	.asciz	"firmware version=%d.%d.%d.%d"

l_.str.3:                               ; @.str.3
	.asciz	"failed=%d\n"

	.no_dead_strip	_af9035_download_firmware
.subsections_via_symbols
