	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function upload_firmware
_upload_firmware:                       ## @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	%r12
	pushq	%rbx
	subq	$160, %rsp
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r12
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, -40(%rbp)
	callq	_zd_usb_to_usbdev
	movq	%rax, %r14
	movq	$0, -184(%rbp)
	movq	$0, -192(%rbp)
	movq	%rax, %rdi
	callq	_get_bcdDevice
	movl	%eax, %r15d
	leaq	L_.str(%rip), %rcx
	leaq	-176(%rbp), %rsi
	movq	%r12, %rdi
	movl	$128, %edx
	callq	_get_fw_name
	leaq	-184(%rbp), %rdi
	movl	%eax, %esi
	movq	%r14, %rdx
	callq	_request_fw_file
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_10
## %bb.1:
	movq	-184(%rbp), %rax
	movl	4(%rax), %edi
	movq	_E2P_DATA_OFFSET@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_get_word
	cmpl	%r15d, %eax
	jne	LBB0_2
## %bb.5:
	leaq	L_.str.3(%rip), %rsi
	movq	%r14, %rdi
	movl	%r15d, %edx
	callq	_dev_dbg_f
	jmp	LBB0_6
LBB0_2:
	leaq	L_.str.1(%rip), %rsi
	movq	%r14, %rdi
	movl	%eax, %edx
	movl	%r15d, %ecx
	callq	_dev_info
	cmpl	$17171, %r15d                   ## imm = 0x4313
	jg	LBB0_4
## %bb.3:
	leaq	L_.str.2(%rip), %rsi
	movq	%r14, %rdi
	callq	_dev_warn
LBB0_4:
	movq	-184(%rbp), %rsi
	movq	%r12, %rdi
	callq	_handle_version_mismatch
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_10
LBB0_6:
	leaq	L_.str.4(%rip), %rcx
	leaq	-176(%rbp), %rsi
	movq	%r12, %rdi
	movl	$128, %edx
	callq	_get_fw_name
	leaq	-192(%rbp), %rdi
	movl	%eax, %esi
	movq	%r14, %rdx
	callq	_request_fw_file
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_10
## %bb.7:
	movq	-192(%rbp), %rax
	movl	(%rax), %edx
	movl	4(%rax), %esi
	movq	_FW_START@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	_REBOOT@GOTPCREL(%rip), %rax
	movl	(%rax), %r8d
	movq	%r14, %rdi
	callq	_upload_code
	testl	%eax, %eax
	je	LBB0_8
## %bb.9:
	movl	%eax, %ebx
	leaq	L_.str.5(%rip), %rsi
	movq	%r14, %rdi
	movl	%eax, %edx
	callq	_dev_err
	jmp	LBB0_10
LBB0_8:
	xorl	%ebx, %ebx
LBB0_10:
	movq	-184(%rbp), %rdi
	callq	_release_firmware
	movq	-192(%rbp), %rdi
	callq	_release_firmware
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpq	-40(%rbp), %rax
	jne	LBB0_12
## %bb.11:
	movl	%ebx, %eax
	addq	$160, %rsp
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_12:
	callq	___stack_chk_fail
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"ub"

	.comm	_E2P_DATA_OFFSET,4,2            ## @E2P_DATA_OFFSET
L_.str.1:                               ## @.str.1
	.asciz	"firmware version %#06x and device bootcode version %#06x differ\n"

L_.str.2:                               ## @.str.2
	.asciz	"device has old bootcode, please report success or failure\n"

L_.str.3:                               ## @.str.3
	.asciz	"firmware device id %#06x is equal to the actual device id\n"

L_.str.4:                               ## @.str.4
	.asciz	"uphr"

	.comm	_FW_START,4,2                   ## @FW_START
	.comm	_REBOOT,4,2                     ## @REBOOT
L_.str.5:                               ## @.str.5
	.asciz	"Could not upload firmware code uph. Error number %d\n"

	.no_dead_strip	_upload_firmware
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function upload_firmware
_upload_firmware:                       ; @upload_firmware
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #208
	.cfi_def_cfa_offset 208
	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
	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, #-40]
	bl	_zd_usb_to_usbdev
	mov	x19, x0
	stp	xzr, xzr, [sp, #8]
	bl	_get_bcdDevice
	mov	x21, x0
Lloh3:
	adrp	x3, l_.str@PAGE
Lloh4:
	add	x3, x3, l_.str@PAGEOFF
	add	x1, sp, #24
	mov	x0, x20
	mov	w2, #128
	bl	_get_fw_name
	mov	x1, x0
	add	x0, sp, #16
	mov	x2, x19
	bl	_request_fw_file
	mov	x22, x0
	cbnz	w0, LBB0_9
; %bb.1:
	ldr	x8, [sp, #16]
	ldr	w0, [x8, #4]
Lloh5:
	adrp	x8, _E2P_DATA_OFFSET@GOTPAGE
Lloh6:
	ldr	x8, [x8, _E2P_DATA_OFFSET@GOTPAGEOFF]
Lloh7:
	ldr	w1, [x8]
	bl	_get_word
	cmp	w0, w21
	b.ne	LBB0_3
; %bb.2:
Lloh8:
	adrp	x1, l_.str.3@PAGE
Lloh9:
	add	x1, x1, l_.str.3@PAGEOFF
	mov	x0, x19
	mov	x2, x21
	bl	_dev_dbg_f
	b	LBB0_6
LBB0_3:
	mov	x2, x0
Lloh10:
	adrp	x1, l_.str.1@PAGE
Lloh11:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x19
	mov	x3, x21
	bl	_dev_info
	mov	w8, #17171
	cmp	w21, w8
	b.gt	LBB0_5
; %bb.4:
Lloh12:
	adrp	x1, l_.str.2@PAGE
Lloh13:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	x0, x19
	bl	_dev_warn
LBB0_5:
	ldr	x1, [sp, #16]
	mov	x0, x20
	bl	_handle_version_mismatch
	mov	x22, x0
	cbnz	w0, LBB0_9
LBB0_6:
Lloh14:
	adrp	x3, l_.str.4@PAGE
Lloh15:
	add	x3, x3, l_.str.4@PAGEOFF
	add	x1, sp, #24
	mov	x0, x20
	mov	w2, #128
	bl	_get_fw_name
	mov	x1, x0
	add	x0, sp, #8
	mov	x2, x19
	bl	_request_fw_file
	mov	x22, x0
	cbnz	w0, LBB0_9
; %bb.7:
	ldr	x8, [sp, #8]
	ldp	w2, w1, [x8]
Lloh16:
	adrp	x8, _FW_START@GOTPAGE
Lloh17:
	ldr	x8, [x8, _FW_START@GOTPAGEOFF]
Lloh18:
	ldr	w3, [x8]
Lloh19:
	adrp	x8, _REBOOT@GOTPAGE
Lloh20:
	ldr	x8, [x8, _REBOOT@GOTPAGEOFF]
Lloh21:
	ldr	w4, [x8]
	mov	x0, x19
	bl	_upload_code
	mov	x22, x0
	cbz	w0, LBB0_9
; %bb.8:
Lloh22:
	adrp	x1, l_.str.5@PAGE
Lloh23:
	add	x1, x1, l_.str.5@PAGEOFF
	mov	x0, x19
	mov	x2, x22
	bl	_dev_err
LBB0_9:
	ldr	x0, [sp, #16]
	bl	_release_firmware
	ldr	x0, [sp, #8]
	bl	_release_firmware
	ldur	x8, [x29, #-40]
Lloh24:
	adrp	x9, ___stack_chk_guard@GOTPAGE
Lloh25:
	ldr	x9, [x9, ___stack_chk_guard@GOTPAGEOFF]
Lloh26:
	ldr	x9, [x9]
	cmp	x9, x8
	b.ne	LBB0_11
; %bb.10:
	mov	x0, x22
	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
	add	sp, sp, #208
	ret
LBB0_11:
	bl	___stack_chk_fail
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpAdd	Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"ub"

	.comm	_E2P_DATA_OFFSET,4,2            ; @E2P_DATA_OFFSET
l_.str.1:                               ; @.str.1
	.asciz	"firmware version %#06x and device bootcode version %#06x differ\n"

l_.str.2:                               ; @.str.2
	.asciz	"device has old bootcode, please report success or failure\n"

l_.str.3:                               ; @.str.3
	.asciz	"firmware device id %#06x is equal to the actual device id\n"

l_.str.4:                               ; @.str.4
	.asciz	"uphr"

	.comm	_FW_START,4,2                   ; @FW_START
	.comm	_REBOOT,4,2                     ; @REBOOT
l_.str.5:                               ; @.str.5
	.asciz	"Could not upload firmware code uph. Error number %d\n"

	.no_dead_strip	_upload_firmware
.subsections_via_symbols
