	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function kaweth_download_firmware
_kaweth_download_firmware:              ## @kaweth_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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rcx, %r12
	movq	%rdx, %r15
	movq	%rdi, %r13
	movq	8(%rdi), %rdx
	leaq	-48(%rbp), %rdi
	callq	_request_firmware
	testl	%eax, %eax
	je	LBB0_2
## %bb.1:
	movl	%eax, %ebx
	movq	24(%r13), %rdi
	leaq	L_.str(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_5
LBB0_2:
	movq	-48(%rbp), %rax
	movl	(%rax), %r14d
	movq	_KAWETH_FIRMWARE_BUF_SIZE@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %r14d
	jle	LBB0_4
## %bb.3:
	movq	24(%r13), %rdi
	leaq	L_.str.1(%rip), %rsi
	xorl	%ebx, %ebx
	movl	%r14d, %edx
	xorl	%eax, %eax
	callq	_dev_err
	movq	-48(%rbp), %rdi
	callq	_release_firmware
	movq	_ENOSPC@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	jmp	LBB0_5
LBB0_4:
	movq	(%r13), %rdi
	movl	4(%rax), %esi
	movl	%r14d, %edx
	callq	_memcpy
	movq	-48(%rbp), %rdi
	callq	_release_firmware
	movzbl	%r14b, %ecx
	addl	$-7, %ecx
	movq	(%r13), %rax
	movl	%ecx, 8(%rax)
	movl	%r14d, %edx
	sarl	$8, %edx
	movl	%edx, 12(%rax)
	movl	%r12d, 16(%rax)
	movl	%r15d, 20(%rax)
	movl	16(%r13), %edi
	leaq	L_.str.2(%rip), %rsi
	xorl	%eax, %eax
	callq	_netdev_dbg
	movl	16(%r13), %edi
	movq	(%r13), %rdx
	leaq	L_.str.3(%rip), %rsi
	movq	%r13, %rcx
	xorl	%eax, %eax
	callq	_netdev_dbg
	movl	16(%r13), %edi
	leaq	L_.str.4(%rip), %rsi
	movl	%r14d, %edx
	xorl	%eax, %eax
	callq	_netdev_dbg
	movq	8(%r13), %rdi
	xorl	%esi, %esi
	callq	_usb_sndctrlpipe
	movq	_KAWETH_COMMAND_SCAN@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	movq	_USB_TYPE_VENDOR@GOTPCREL(%rip), %rsi
	movq	_USB_DIR_OUT@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	orl	(%rsi), %ecx
	movq	_USB_RECIP_DEVICE@GOTPCREL(%rip), %rsi
	orl	(%rsi), %ecx
	movq	_KAWETH_CONTROL_TIMEOUT@GOTPCREL(%rip), %rsi
	movl	(%rsi), %ebx
	subq	$8, %rsp
	movq	%r13, %rdi
	movl	%eax, %esi
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	pushq	%rbx
	pushq	%r14
	pushq	(%r13)
	callq	_kaweth_control
	addq	$32, %rsp
	movl	%eax, %ebx
LBB0_5:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Firmware request failed\n"

	.comm	_KAWETH_FIRMWARE_BUF_SIZE,4,2   ## @KAWETH_FIRMWARE_BUF_SIZE
L_.str.1:                               ## @.str.1
	.asciz	"Firmware too big: %zu\n"

	.comm	_ENOSPC,4,2                     ## @ENOSPC
L_.str.2:                               ## @.str.2
	.asciz	"High: %i, Low:%i\n"

L_.str.3:                               ## @.str.3
	.asciz	"Downloading firmware at %p to kaweth device at %p\n"

L_.str.4:                               ## @.str.4
	.asciz	"Firmware length: %d\n"

	.comm	_KAWETH_COMMAND_SCAN,4,2        ## @KAWETH_COMMAND_SCAN
	.comm	_USB_TYPE_VENDOR,4,2            ## @USB_TYPE_VENDOR
	.comm	_USB_DIR_OUT,4,2                ## @USB_DIR_OUT
	.comm	_USB_RECIP_DEVICE,4,2           ## @USB_RECIP_DEVICE
	.comm	_KAWETH_CONTROL_TIMEOUT,4,2     ## @KAWETH_CONTROL_TIMEOUT
	.no_dead_strip	_kaweth_download_firmware
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function kaweth_download_firmware
_kaweth_download_firmware:              ; @kaweth_download_firmware
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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	x22, x3
	mov	x21, x2
	mov	x19, x0
	ldr	x2, [x0, #8]
	add	x0, sp, #24
	bl	_request_firmware
	cbz	w0, LBB0_2
; %bb.1:
	mov	x20, x0
	ldr	x0, [x19, #24]
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
	b	LBB0_5
LBB0_2:
	ldr	x8, [sp, #24]
	ldr	w20, [x8]
Lloh2:
	adrp	x9, _KAWETH_FIRMWARE_BUF_SIZE@GOTPAGE
Lloh3:
	ldr	x9, [x9, _KAWETH_FIRMWARE_BUF_SIZE@GOTPAGEOFF]
Lloh4:
	ldr	w9, [x9]
	cmp	w20, w9
	b.le	LBB0_4
; %bb.3:
	ldr	x0, [x19, #24]
	str	x20, [sp]
Lloh5:
	adrp	x1, l_.str.1@PAGE
Lloh6:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_dev_err
	ldr	x0, [sp, #24]
	bl	_release_firmware
Lloh7:
	adrp	x8, _ENOSPC@GOTPAGE
Lloh8:
	ldr	x8, [x8, _ENOSPC@GOTPAGEOFF]
Lloh9:
	ldr	w8, [x8]
	neg	w20, w8
	b	LBB0_5
LBB0_4:
	ldr	x0, [x19]
	ldr	w1, [x8, #4]
	mov	x2, x20
	bl	_memcpy
	ldr	x0, [sp, #24]
	bl	_release_firmware
	and	w8, w20, #0xff
	sub	w8, w8, #7
	ldr	x9, [x19]
	asr	w10, w20, #8
	stp	w8, w10, [x9, #8]
	stp	w22, w21, [x9, #16]
	ldr	w0, [x19, #16]
	stp	x10, x8, [sp]
Lloh10:
	adrp	x1, l_.str.2@PAGE
Lloh11:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_netdev_dbg
	ldr	w0, [x19, #16]
	ldr	x8, [x19]
	stp	x8, x19, [sp]
Lloh12:
	adrp	x1, l_.str.3@PAGE
Lloh13:
	add	x1, x1, l_.str.3@PAGEOFF
	bl	_netdev_dbg
	ldr	w0, [x19, #16]
	mov	x8, x20
	str	x8, [sp]
Lloh14:
	adrp	x1, l_.str.4@PAGE
Lloh15:
	add	x1, x1, l_.str.4@PAGEOFF
	bl	_netdev_dbg
	ldr	x0, [x19, #8]
	mov	w1, #0
	bl	_usb_sndctrlpipe
	mov	x1, x0
Lloh16:
	adrp	x8, _KAWETH_COMMAND_SCAN@GOTPAGE
Lloh17:
	ldr	x8, [x8, _KAWETH_COMMAND_SCAN@GOTPAGEOFF]
Lloh18:
	ldr	w2, [x8]
Lloh19:
	adrp	x8, _USB_TYPE_VENDOR@GOTPAGE
Lloh20:
	ldr	x8, [x8, _USB_TYPE_VENDOR@GOTPAGEOFF]
Lloh21:
	ldr	w8, [x8]
Lloh22:
	adrp	x9, _USB_DIR_OUT@GOTPAGE
Lloh23:
	ldr	x9, [x9, _USB_DIR_OUT@GOTPAGEOFF]
Lloh24:
	ldr	w9, [x9]
	orr	w8, w9, w8
Lloh25:
	adrp	x9, _USB_RECIP_DEVICE@GOTPAGE
Lloh26:
	ldr	x9, [x9, _USB_RECIP_DEVICE@GOTPAGEOFF]
Lloh27:
	ldr	w9, [x9]
	orr	w3, w8, w9
	ldr	x6, [x19]
Lloh28:
	adrp	x8, _KAWETH_CONTROL_TIMEOUT@GOTPAGE
Lloh29:
	ldr	x8, [x8, _KAWETH_CONTROL_TIMEOUT@GOTPAGEOFF]
Lloh30:
	ldr	w8, [x8]
	str	w8, [sp]
	mov	x0, x19
	mov	w4, #0
	mov	w5, #0
	mov	x7, x20
	bl	_kaweth_control
	mov	x20, x0
LBB0_5:
	mov	x0, x20
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #80
	ret
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.loh AdrpLdrGotLdr	Lloh25, Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpAdd	Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Firmware request failed\n"

	.comm	_KAWETH_FIRMWARE_BUF_SIZE,4,2   ; @KAWETH_FIRMWARE_BUF_SIZE
l_.str.1:                               ; @.str.1
	.asciz	"Firmware too big: %zu\n"

	.comm	_ENOSPC,4,2                     ; @ENOSPC
l_.str.2:                               ; @.str.2
	.asciz	"High: %i, Low:%i\n"

l_.str.3:                               ; @.str.3
	.asciz	"Downloading firmware at %p to kaweth device at %p\n"

l_.str.4:                               ; @.str.4
	.asciz	"Firmware length: %d\n"

	.comm	_KAWETH_COMMAND_SCAN,4,2        ; @KAWETH_COMMAND_SCAN
	.comm	_USB_TYPE_VENDOR,4,2            ; @USB_TYPE_VENDOR
	.comm	_USB_DIR_OUT,4,2                ; @USB_DIR_OUT
	.comm	_USB_RECIP_DEVICE,4,2           ; @USB_RECIP_DEVICE
	.comm	_KAWETH_CONTROL_TIMEOUT,4,2     ; @KAWETH_CONTROL_TIMEOUT
	.no_dead_strip	_kaweth_download_firmware
.subsections_via_symbols
