	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function rt2800usb_write_firmware
_rt2800usb_write_firmware:              ## @rt2800usb_write_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	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %r14
	movq	%rdi, %r15
	movq	_RT2860@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_rt2x00_rt
	testq	%rax, %rax
	jne	LBB0_1
## %bb.2:
	movq	_RT2872@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	callq	_rt2x00_rt
	testq	%rax, %rax
	je	LBB0_4
LBB0_1:
	xorl	%r12d, %r12d
LBB0_5:
	movq	%r15, %rdi
	callq	_rt2800usb_autorun_detect
	testl	%eax, %eax
	js	LBB0_8
## %bb.6:
	je	LBB0_9
## %bb.7:
	leaq	L_.str(%rip), %rsi
	movq	%r15, %rdi
	callq	_rt2x00_info
	movq	_REQUIRE_FIRMWARE@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	%r15, %rsi
	callq	___clear_bit
	jmp	LBB0_10
LBB0_8:
	movl	%eax, %ebx
	jmp	LBB0_13
LBB0_9:
	movq	_FIRMWARE_IMAGE_BASE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	(%r14,%r12,4), %rdx
	movq	%r15, %rdi
	movl	$4096, %ecx                     ## imm = 0x1000
	callq	_rt2x00usb_register_multiwrite
LBB0_10:
	movq	_H2M_MAILBOX_CID@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	movl	$-1, %edx
	callq	_rt2x00usb_register_write
	movq	_H2M_MAILBOX_STATUS@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	movl	$-1, %edx
	callq	_rt2x00usb_register_write
	movq	_USB_DEVICE_MODE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_USB_MODE_FIRMWARE@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	_REGISTER_TIMEOUT_FIRMWARE@GOTPCREL(%rip), %rax
	movl	(%rax), %r8d
	xorl	%ebx, %ebx
	movq	%r15, %rdi
	xorl	%edx, %edx
	callq	_rt2x00usb_vendor_request_sw
	testl	%eax, %eax
	js	LBB0_12
## %bb.11:
	movl	$10, %edi
	callq	_msleep
	movq	_H2M_MAILBOX_CSR@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	xorl	%edx, %edx
	callq	_rt2x00usb_register_write
	jmp	LBB0_13
LBB0_12:
	movl	%eax, %r14d
	leaq	L_.str.1(%rip), %rsi
	movq	%r15, %rdi
	callq	_rt2x00_err
	movl	%r14d, %ebx
LBB0_13:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_4:
	movq	_RT3070@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	callq	_rt2x00_rt
	xorl	%r12d, %r12d
	testq	%rax, %rax
	sete	%r12b
	shlq	$12, %r12
	jmp	LBB0_5
	.cfi_endproc
                                        ## -- End function
	.comm	_RT2860,4,2                     ## @RT2860
	.comm	_RT2872,4,2                     ## @RT2872
	.comm	_RT3070,4,2                     ## @RT3070
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Firmware loading not required - NIC in AutoRun mode\n"

	.comm	_REQUIRE_FIRMWARE,4,2           ## @REQUIRE_FIRMWARE
	.comm	_FIRMWARE_IMAGE_BASE,4,2        ## @FIRMWARE_IMAGE_BASE
	.comm	_H2M_MAILBOX_CID,4,2            ## @H2M_MAILBOX_CID
	.comm	_H2M_MAILBOX_STATUS,4,2         ## @H2M_MAILBOX_STATUS
	.comm	_USB_DEVICE_MODE,4,2            ## @USB_DEVICE_MODE
	.comm	_USB_MODE_FIRMWARE,4,2          ## @USB_MODE_FIRMWARE
	.comm	_REGISTER_TIMEOUT_FIRMWARE,4,2  ## @REGISTER_TIMEOUT_FIRMWARE
L_.str.1:                               ## @.str.1
	.asciz	"Failed to write Firmware to device\n"

	.comm	_H2M_MAILBOX_CSR,4,2            ## @H2M_MAILBOX_CSR
	.no_dead_strip	_rt2800usb_write_firmware
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function rt2800usb_write_firmware
_rt2800usb_write_firmware:              ; @rt2800usb_write_firmware
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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	x20, x1
	mov	x19, x0
Lloh0:
	adrp	x8, _RT2860@GOTPAGE
Lloh1:
	ldr	x8, [x8, _RT2860@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	bl	_rt2x00_rt
	cbnz	x0, LBB0_2
; %bb.1:
Lloh3:
	adrp	x8, _RT2872@GOTPAGE
Lloh4:
	ldr	x8, [x8, _RT2872@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_rt2x00_rt
	cbz	x0, LBB0_11
LBB0_2:
	mov	x22, #0
LBB0_3:
	mov	x0, x19
	bl	_rt2800usb_autorun_detect
	mov	x21, x0
	tbnz	w0, #31, LBB0_10
; %bb.4:
	cbz	w21, LBB0_6
; %bb.5:
Lloh6:
	adrp	x1, l_.str@PAGE
Lloh7:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x19
	bl	_rt2x00_info
Lloh8:
	adrp	x8, _REQUIRE_FIRMWARE@GOTPAGE
Lloh9:
	ldr	x8, [x8, _REQUIRE_FIRMWARE@GOTPAGEOFF]
Lloh10:
	ldr	w0, [x8]
	mov	x1, x19
	bl	___clear_bit
	b	LBB0_7
LBB0_6:
Lloh11:
	adrp	x8, _FIRMWARE_IMAGE_BASE@GOTPAGE
Lloh12:
	ldr	x8, [x8, _FIRMWARE_IMAGE_BASE@GOTPAGEOFF]
Lloh13:
	ldr	w1, [x8]
	add	x2, x20, x22, lsl #2
	mov	x0, x19
	mov	w3, #4096
	bl	_rt2x00usb_register_multiwrite
LBB0_7:
Lloh14:
	adrp	x8, _H2M_MAILBOX_CID@GOTPAGE
Lloh15:
	ldr	x8, [x8, _H2M_MAILBOX_CID@GOTPAGEOFF]
Lloh16:
	ldr	w1, [x8]
	mov	x0, x19
	mov	w2, #-1
	bl	_rt2x00usb_register_write
Lloh17:
	adrp	x8, _H2M_MAILBOX_STATUS@GOTPAGE
Lloh18:
	ldr	x8, [x8, _H2M_MAILBOX_STATUS@GOTPAGEOFF]
Lloh19:
	ldr	w1, [x8]
	mov	x0, x19
	mov	w2, #-1
	bl	_rt2x00usb_register_write
Lloh20:
	adrp	x8, _USB_DEVICE_MODE@GOTPAGE
Lloh21:
	ldr	x8, [x8, _USB_DEVICE_MODE@GOTPAGEOFF]
Lloh22:
	ldr	w1, [x8]
Lloh23:
	adrp	x8, _USB_MODE_FIRMWARE@GOTPAGE
Lloh24:
	ldr	x8, [x8, _USB_MODE_FIRMWARE@GOTPAGEOFF]
Lloh25:
	ldr	w3, [x8]
Lloh26:
	adrp	x8, _REGISTER_TIMEOUT_FIRMWARE@GOTPAGE
Lloh27:
	ldr	x8, [x8, _REGISTER_TIMEOUT_FIRMWARE@GOTPAGEOFF]
Lloh28:
	ldr	w4, [x8]
	mov	x0, x19
	mov	w2, #0
	bl	_rt2x00usb_vendor_request_sw
	tbnz	w0, #31, LBB0_9
; %bb.8:
	mov	w0, #10
	bl	_msleep
Lloh29:
	adrp	x8, _H2M_MAILBOX_CSR@GOTPAGE
Lloh30:
	ldr	x8, [x8, _H2M_MAILBOX_CSR@GOTPAGEOFF]
Lloh31:
	ldr	w1, [x8]
	mov	x0, x19
	mov	w2, #0
	bl	_rt2x00usb_register_write
	mov	w21, #0
	b	LBB0_10
LBB0_9:
	mov	x21, x0
Lloh32:
	adrp	x1, l_.str.1@PAGE
Lloh33:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x19
	bl	_rt2x00_err
LBB0_10:
	mov	x0, x21
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
LBB0_11:
Lloh34:
	adrp	x8, _RT3070@GOTPAGE
Lloh35:
	ldr	x8, [x8, _RT3070@GOTPAGEOFF]
Lloh36:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_rt2x00_rt
	cmp	x0, #0
	cset	w8, eq
	lsl	x22, x8, #12
	b	LBB0_3
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh26, Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpAdd	Lloh32, Lloh33
	.loh AdrpLdrGotLdr	Lloh34, Lloh35, Lloh36
	.cfi_endproc
                                        ; -- End function
	.comm	_RT2860,4,2                     ; @RT2860
	.comm	_RT2872,4,2                     ; @RT2872
	.comm	_RT3070,4,2                     ; @RT3070
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Firmware loading not required - NIC in AutoRun mode\n"

	.comm	_REQUIRE_FIRMWARE,4,2           ; @REQUIRE_FIRMWARE
	.comm	_FIRMWARE_IMAGE_BASE,4,2        ; @FIRMWARE_IMAGE_BASE
	.comm	_H2M_MAILBOX_CID,4,2            ; @H2M_MAILBOX_CID
	.comm	_H2M_MAILBOX_STATUS,4,2         ; @H2M_MAILBOX_STATUS
	.comm	_USB_DEVICE_MODE,4,2            ; @USB_DEVICE_MODE
	.comm	_USB_MODE_FIRMWARE,4,2          ; @USB_MODE_FIRMWARE
	.comm	_REGISTER_TIMEOUT_FIRMWARE,4,2  ; @REGISTER_TIMEOUT_FIRMWARE
l_.str.1:                               ; @.str.1
	.asciz	"Failed to write Firmware to device\n"

	.comm	_H2M_MAILBOX_CSR,4,2            ; @H2M_MAILBOX_CSR
	.no_dead_strip	_rt2800usb_write_firmware
.subsections_via_symbols
