	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mt76x0u_upload_firmware
_mt76x0u_upload_firmware:               ## @mt76x0u_upload_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	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %r13
	movq	%rdi, %r15
	leaq	8(%rsi), %r12
	movq	_MT_MCU_IVB_SIZE@GOTPCREL(%rip), %r14
	movl	(%r14), %esi
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r12, %rdi
	callq	_kmemdup
	testq	%rax, %rax
	je	LBB0_1
## %bb.2:
	movq	%rax, %rbx
	movl	(%r13), %edi
	callq	_le32_to_cpu
	movq	%r12, -48(%rbp)                 ## 8-byte Spill
	movq	%rbx, %r12
	movl	%eax, %ebx
	movl	(%r14), %ecx
	subl	%ecx, %ebx
	movl	(%r15), %edi
	leaq	L_.str(%rip), %rsi
	movl	%ebx, %edx
	xorl	%eax, %eax
	callq	_dev_dbg
	movslq	(%r14), %r8
	movq	%r12, %r14
	movq	-48(%rbp), %r12                 ## 8-byte Reload
	leaq	(%r12,%r8,4), %rsi
	movq	_MCU_FW_URB_MAX_PAYLOAD@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	%r15, %rdi
	movl	%ebx, %edx
                                        ## kill: def $r8d killed $r8d killed $r8
	callq	_mt76x02u_mcu_fw_send_data
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_8
## %bb.3:
	movl	4(%r13), %edi
	callq	_le32_to_cpu
	movl	%eax, %ebx
	movl	(%r15), %edi
	leaq	L_.str.1(%rip), %rsi
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	_dev_dbg
	movl	(%r13), %edi
	callq	_le32_to_cpu
	cltq
	leaq	(%r12,%rax,4), %rsi
	movq	_MCU_FW_URB_MAX_PAYLOAD@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	_MT_MCU_DLM_OFFSET@GOTPCREL(%rip), %rax
	movl	(%rax), %r8d
	movq	%r15, %rdi
	movl	%ebx, %edx
	callq	_mt76x02u_mcu_fw_send_data
	movl	%eax, %ebx
	testl	%eax, %eax
	je	LBB0_4
LBB0_8:
	movq	%r14, %rdi
	callq	_kfree
	jmp	LBB0_9
LBB0_1:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_9:
	movl	%ebx, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_4:
	movq	_MT_VEND_DEV_MODE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_USB_DIR_OUT@GOTPCREL(%rip), %rax
	movq	_USB_TYPE_VENDOR@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	orl	(%rax), %edx
	movq	_MT_MCU_IVB_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, (%rsp)
	movq	%r15, %rdi
	movl	$18, %ecx
	xorl	%r8d, %r8d
	movq	%r14, %r9
	callq	_mt76u_vendor_request
	movl	%eax, %ebx
	testl	%eax, %eax
	js	LBB0_8
## %bb.5:
	movq	_MT_MCU_COM_REG0@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	movl	$1, %edx
	movl	$1, %ecx
	movl	$1000, %r8d                     ## imm = 0x3E8
	callq	_mt76_poll_msec
	movl	(%r15), %edi
	testl	%eax, %eax
	je	LBB0_6
## %bb.7:
	leaq	L_.str.3(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_dbg
	jmp	LBB0_8
LBB0_6:
	leaq	L_.str.2(%rip), %rsi
	callq	_dev_err
	movq	_ETIMEDOUT@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_8
	.cfi_endproc
                                        ## -- End function
	.comm	_MT_MCU_IVB_SIZE,4,2            ## @MT_MCU_IVB_SIZE
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"loading FW - ILM %u + IVB %u\n"

	.comm	_MCU_FW_URB_MAX_PAYLOAD,4,2     ## @MCU_FW_URB_MAX_PAYLOAD
L_.str.1:                               ## @.str.1
	.asciz	"loading FW - DLM %u\n"

	.comm	_MT_MCU_DLM_OFFSET,4,2          ## @MT_MCU_DLM_OFFSET
	.comm	_MT_VEND_DEV_MODE,4,2           ## @MT_VEND_DEV_MODE
	.comm	_USB_DIR_OUT,4,2                ## @USB_DIR_OUT
	.comm	_USB_TYPE_VENDOR,4,2            ## @USB_TYPE_VENDOR
	.comm	_MT_MCU_COM_REG0,4,2            ## @MT_MCU_COM_REG0
L_.str.2:                               ## @.str.2
	.asciz	"Firmware failed to start\n"

	.comm	_ETIMEDOUT,4,2                  ## @ETIMEDOUT
L_.str.3:                               ## @.str.3
	.asciz	"Firmware running!\n"

	.no_dead_strip	_mt76x0u_upload_firmware
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mt76x0u_upload_firmware
_mt76x0u_upload_firmware:               ; @mt76x0u_upload_firmware
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #96
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	mov	x22, x1
	mov	x20, x0
	add	x21, x1, #8
Lloh0:
	adrp	x24, _MT_MCU_IVB_SIZE@GOTPAGE
Lloh1:
	ldr	x24, [x24, _MT_MCU_IVB_SIZE@GOTPAGEOFF]
	ldr	w1, [x24]
Lloh2:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh3:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh4:
	ldr	w2, [x8]
	mov	x0, x21
	bl	_kmemdup
	cbz	x0, LBB0_4
; %bb.1:
	mov	x19, x0
	ldr	w0, [x22]
	bl	_le32_to_cpu
	ldr	w8, [x24]
	sub	w23, w0, w8
	ldr	w0, [x20]
	stp	x23, x8, [sp]
Lloh5:
	adrp	x1, l_.str@PAGE
Lloh6:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_dbg
	ldrsw	x4, [x24]
	add	x1, x21, x4, lsl #2
Lloh7:
	adrp	x25, _MCU_FW_URB_MAX_PAYLOAD@GOTPAGE
Lloh8:
	ldr	x25, [x25, _MCU_FW_URB_MAX_PAYLOAD@GOTPAGEOFF]
	ldr	w3, [x25]
	mov	x0, x20
	mov	x2, x23
                                        ; kill: def $w4 killed $w4 killed $x4
	bl	_mt76x02u_mcu_fw_send_data
	mov	x23, x0
	cbnz	w0, LBB0_3
; %bb.2:
	ldr	w0, [x22, #4]
	bl	_le32_to_cpu
	mov	x23, x0
	ldr	w0, [x20]
	str	x23, [sp]
Lloh9:
	adrp	x1, l_.str.1@PAGE
Lloh10:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_dev_dbg
	ldr	w0, [x22]
	bl	_le32_to_cpu
	add	x1, x21, w0, sxtw #2
	ldr	w3, [x25]
Lloh11:
	adrp	x8, _MT_MCU_DLM_OFFSET@GOTPAGE
Lloh12:
	ldr	x8, [x8, _MT_MCU_DLM_OFFSET@GOTPAGEOFF]
Lloh13:
	ldr	w4, [x8]
	mov	x0, x20
	mov	x2, x23
	bl	_mt76x02u_mcu_fw_send_data
	mov	x23, x0
	cbz	w0, LBB0_6
LBB0_3:
	mov	x0, x19
	bl	_kfree
	b	LBB0_5
LBB0_4:
Lloh14:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh15:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh16:
	ldr	w8, [x8]
	neg	w23, w8
LBB0_5:
	mov	x0, x23
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #96
	ret
LBB0_6:
Lloh17:
	adrp	x8, _MT_VEND_DEV_MODE@GOTPAGE
Lloh18:
	ldr	x8, [x8, _MT_VEND_DEV_MODE@GOTPAGEOFF]
Lloh19:
	ldr	w1, [x8]
Lloh20:
	adrp	x8, _USB_DIR_OUT@GOTPAGE
Lloh21:
	ldr	x8, [x8, _USB_DIR_OUT@GOTPAGEOFF]
Lloh22:
	ldr	w8, [x8]
Lloh23:
	adrp	x9, _USB_TYPE_VENDOR@GOTPAGE
Lloh24:
	ldr	x9, [x9, _USB_TYPE_VENDOR@GOTPAGEOFF]
Lloh25:
	ldr	w9, [x9]
	orr	w2, w9, w8
	ldr	w6, [x24]
	mov	x0, x20
	mov	w3, #18
	mov	w4, #0
	mov	x5, x19
	bl	_mt76u_vendor_request
	mov	x23, x0
	tbnz	w0, #31, LBB0_3
; %bb.7:
Lloh26:
	adrp	x8, _MT_MCU_COM_REG0@GOTPAGE
Lloh27:
	ldr	x8, [x8, _MT_MCU_COM_REG0@GOTPAGEOFF]
Lloh28:
	ldr	w1, [x8]
	mov	x0, x20
	mov	w2, #1
	mov	w3, #1
	mov	w4, #1000
	bl	_mt76_poll_msec
	mov	x8, x0
	ldr	w0, [x20]
	cbz	w8, LBB0_9
; %bb.8:
Lloh29:
	adrp	x1, l_.str.3@PAGE
Lloh30:
	add	x1, x1, l_.str.3@PAGEOFF
	bl	_dev_dbg
	b	LBB0_3
LBB0_9:
Lloh31:
	adrp	x1, l_.str.2@PAGE
Lloh32:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_dev_err
Lloh33:
	adrp	x8, _ETIMEDOUT@GOTPAGE
Lloh34:
	ldr	x8, [x8, _ETIMEDOUT@GOTPAGEOFF]
Lloh35:
	ldr	w8, [x8]
	neg	w23, w8
	b	LBB0_3
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpAdd	Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh26, Lloh27, Lloh28
	.loh AdrpAdd	Lloh29, Lloh30
	.loh AdrpLdrGotLdr	Lloh33, Lloh34, Lloh35
	.loh AdrpAdd	Lloh31, Lloh32
	.cfi_endproc
                                        ; -- End function
	.comm	_MT_MCU_IVB_SIZE,4,2            ; @MT_MCU_IVB_SIZE
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"loading FW - ILM %u + IVB %u\n"

	.comm	_MCU_FW_URB_MAX_PAYLOAD,4,2     ; @MCU_FW_URB_MAX_PAYLOAD
l_.str.1:                               ; @.str.1
	.asciz	"loading FW - DLM %u\n"

	.comm	_MT_MCU_DLM_OFFSET,4,2          ; @MT_MCU_DLM_OFFSET
	.comm	_MT_VEND_DEV_MODE,4,2           ; @MT_VEND_DEV_MODE
	.comm	_USB_DIR_OUT,4,2                ; @USB_DIR_OUT
	.comm	_USB_TYPE_VENDOR,4,2            ; @USB_TYPE_VENDOR
	.comm	_MT_MCU_COM_REG0,4,2            ; @MT_MCU_COM_REG0
l_.str.2:                               ; @.str.2
	.asciz	"Firmware failed to start\n"

	.comm	_ETIMEDOUT,4,2                  ; @ETIMEDOUT
l_.str.3:                               ; @.str.3
	.asciz	"Firmware running!\n"

	.no_dead_strip	_mt76x0u_upload_firmware
.subsections_via_symbols
