	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function ucbus_write
_ucbus_write:                           ## @ucbus_write
	.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	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
                                        ## kill: def $ecx killed $ecx def $rcx
	cmpl	$0, (%rdi)
	js	LBB0_14
## %bb.1:
	movl	%edx, %ebx
	movq	%rdi, %r15
	leal	(%rcx,%rcx,2), %eax
	addl	$-3, %eax
	movq	_USB_BUF_SZ@GOTPCREL(%rip), %rdx
	cmpl	(%rdx), %eax
	jle	LBB0_2
## %bb.12:
	leaq	L_.str(%rip), %rsi
	movq	%r15, %rdi
	callq	_gspca_err
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%r14d, %r14d
	subl	(%rax), %r14d
	jmp	LBB0_13
LBB0_2:
	movq	%rsi, %r13
	movq	%r15, -48(%rbp)                 ## 8-byte Spill
	movq	%rcx, -64(%rbp)                 ## 8-byte Spill
	.p2align	4, 0x90
LBB0_3:                                 ## =>This Loop Header: Depth=1
                                        ##     Child Loop BB0_5 Depth 2
	cmpl	%ecx, %ebx
	movl	%ecx, %edx
	movl	%ebx, -52(%rbp)                 ## 4-byte Spill
	cmovll	%ebx, %edx
	movl	(%r13), %r14d
	movl	4(%r13), %eax
	movl	%r14d, %r8d
	shll	$8, %r8d
	movq	_SQ930_CTRL_UCBUS_IO@GOTPCREL(%rip), %rcx
	orl	(%rcx), %r8d
	shll	$8, %eax
	sarl	$8, %r14d
	orl	%eax, %r14d
	movq	8(%r15), %r12
	cmpl	$2, %edx
	movq	%rdx, -72(%rbp)                 ## 8-byte Spill
	movl	%r8d, -56(%rbp)                 ## 4-byte Spill
	jl	LBB0_8
## %bb.4:                               ##   in Loop: Header=BB0_3 Depth=1
	leal	1(%rdx), %ecx
	xorl	%eax, %eax
	.p2align	4, 0x90
LBB0_5:                                 ##   Parent Loop BB0_3 Depth=1
                                        ## =>  This Inner Loop Header: Depth=2
	movl	8(%r13), %edx
	movl	%edx, (%r12,%rax)
	movl	8(%r13), %edx
	sarl	$8, %edx
	movl	%edx, 4(%r12,%rax)
	movl	12(%r13), %ebx
	addq	$8, %r13
	movl	%ebx, 8(%r12,%rax)
	decl	%ecx
	addq	$12, %rax
	cmpl	$2, %ecx
	ja	LBB0_5
## %bb.6:                               ##   in Loop: Header=BB0_3 Depth=1
	leaq	(%r12,%rax), %r15
	testq	%rax, %rax
	je	LBB0_7
## %bb.15:                              ##   in Loop: Header=BB0_3 Depth=1
	movq	_D_USBO@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	(%r12), %r9d
	subq	$8, %rsp
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	leaq	L_.str.1(%rip), %rdx
	movl	%r8d, %ecx
	movl	%r14d, %r8d
	xorl	%eax, %eax
	pushq	%rbx
	movq	%rdi, %rbx
	callq	_gspca_dbg
	addq	$16, %rsp
	movq	%r15, %r12
	movq	%rbx, %r15
	jmp	LBB0_9
LBB0_7:                                 ##   in Loop: Header=BB0_3 Depth=1
	movq	%r15, %r12
	movq	-48(%rbp), %r15                 ## 8-byte Reload
LBB0_8:                                 ##   in Loop: Header=BB0_3 Depth=1
	movq	_D_USBO@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	leaq	L_.str.2(%rip), %rdx
	movl	%r8d, %ecx
	movl	%r14d, %r8d
	xorl	%eax, %eax
	callq	_gspca_dbg
LBB0_9:                                 ##   in Loop: Header=BB0_3 Depth=1
	movq	%r15, %rbx
	movl	16(%r15), %r15d
	movl	%r15d, %edi
	xorl	%esi, %esi
	callq	_usb_sndctrlpipe
	movq	_USB_TYPE_VENDOR@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movq	_USB_DIR_OUT@GOTPCREL(%rip), %rdx
	orl	(%rdx), %ecx
	movq	_USB_RECIP_DEVICE@GOTPCREL(%rip), %rdx
	orl	(%rdx), %ecx
	movq	8(%rbx), %rbx
	subq	%rbx, %r12
	shrq	$2, %r12
	subq	$8, %rsp
	movl	%r15d, %edi
	movl	%eax, %esi
	movl	$12, %edx
	movl	-56(%rbp), %r8d                 ## 4-byte Reload
	movl	%r14d, %r9d
	pushq	$500                            ## imm = 0x1F4
	pushq	%r12
	pushq	%rbx
	callq	_usb_control_msg
	addq	$32, %rsp
	testl	%eax, %eax
	js	LBB0_10
## %bb.11:                              ##   in Loop: Header=BB0_3 Depth=1
	movl	-52(%rbp), %ebx                 ## 4-byte Reload
	subl	-72(%rbp), %ebx                 ## 4-byte Folded Reload
	movl	$30, %edi
	callq	_msleep
	addq	$8, %r13
	testl	%ebx, %ebx
	movq	-48(%rbp), %r15                 ## 8-byte Reload
	movq	-64(%rbp), %rcx                 ## 8-byte Reload
	jg	LBB0_3
	jmp	LBB0_14
LBB0_10:
	movl	%eax, %r14d
	leaq	L_.str.3(%rip), %rdi
	movl	%eax, %esi
	callq	_pr_err
	movq	-48(%rbp), %r15                 ## 8-byte Reload
LBB0_13:
	movl	%r14d, (%r15)
LBB0_14:
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_USB_BUF_SZ,4,2                 ## @USB_BUF_SZ
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Bug: usb_buf overflow\n"

	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_SQ930_CTRL_UCBUS_IO,4,2        ## @SQ930_CTRL_UCBUS_IO
	.comm	_D_USBO,4,2                     ## @D_USBO
L_.str.1:                               ## @.str.1
	.asciz	"ucbus v: %04x i: %04x %02x...%02x\n"

L_.str.2:                               ## @.str.2
	.asciz	"ucbus v: %04x i: %04x\n"

	.comm	_USB_DIR_OUT,4,2                ## @USB_DIR_OUT
	.comm	_USB_TYPE_VENDOR,4,2            ## @USB_TYPE_VENDOR
	.comm	_USB_RECIP_DEVICE,4,2           ## @USB_RECIP_DEVICE
L_.str.3:                               ## @.str.3
	.asciz	"ucbus_write failed %d\n"

	.no_dead_strip	_ucbus_write
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function ucbus_write
_ucbus_write:                           ; @ucbus_write
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	ldr	w8, [x0]
	tbnz	w8, #31, LBB0_22
; %bb.1:
	mov	x20, x3
	mov	x19, x0
	add	w8, w3, w3, lsl #1
	sub	w8, w8, #3
Lloh0:
	adrp	x9, _USB_BUF_SZ@GOTPAGE
Lloh1:
	ldr	x9, [x9, _USB_BUF_SZ@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x9]
	cmp	w8, w9
	b.le	LBB0_3
; %bb.2:
Lloh3:
	adrp	x1, l_.str@PAGE
Lloh4:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x19
	bl	_gspca_err
Lloh5:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh6:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh7:
	ldr	w8, [x8]
	neg	w25, w8
	b	LBB0_21
LBB0_3:
	mov	x21, x2
	mov	x24, x1
	mov	w23, #500
LBB0_4:                                 ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB0_11 Depth 2
                                        ;     Child Loop BB0_14 Depth 2
	cmp	w21, w20
	csel	w28, w21, w20, lt
Lloh8:
	adrp	x8, _SQ930_CTRL_UCBUS_IO@GOTPAGE
Lloh9:
	ldr	x8, [x8, _SQ930_CTRL_UCBUS_IO@GOTPAGEOFF]
Lloh10:
	ldr	w8, [x8]
	ldp	w9, w10, [x24]
	orr	w25, w8, w9, lsl #8
	lsl	w8, w10, #8
	orr	w26, w8, w9, asr #8
	ldr	x8, [x19, #8]
	subs	w9, w28, #2
	b.lt	LBB0_9
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	csel	w9, wzr, w9, lo
	cmp	w9, #8
	b.lo	LBB0_8
; %bb.6:                                ;   in Loop: Header=BB0_4 Depth=1
	subs	w10, w28, #2
	csel	w10, wzr, w10, lo
	add	x11, x24, w10, uxtw #3
	add	x11, x11, #16
	cmp	x8, x11
	b.hs	LBB0_10
; %bb.7:                                ;   in Loop: Header=BB0_4 Depth=1
	mov	w11, #12
	umaddl	x10, w10, w11, x8
	add	x10, x10, #12
	add	x11, x24, #8
	cmp	x11, x10
	b.hs	LBB0_10
LBB0_8:                                 ;   in Loop: Header=BB0_4 Depth=1
	mov	x10, x28
	mov	x9, x8
	b	LBB0_13
LBB0_9:                                 ;   in Loop: Header=BB0_4 Depth=1
	mov	x22, x8
	b	LBB0_17
LBB0_10:                                ;   in Loop: Header=BB0_4 Depth=1
	add	w13, w9, #1
	ands	x9, x13, #0x7
	mov	w10, #8
	csel	x14, x10, x9, eq
	sub	x9, x13, x14
	sub	w10, w28, w9
	add	x11, x24, x9, lsl #3
	mov	w12, #12
	madd	x9, x9, x12, x8
	add	x12, x24, #40
	sub	x13, x14, x13
	mov	x14, x8
LBB0_11:                                ;   Parent Loop BB0_4 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	sub	x15, x12, #32
	ld2.4s	{ v0, v1 }, [x15]
	sshr.4s	v3, v0, #8
	mov.16b	v2, v0
	ld2.4s	{ v5, v6 }, [x12]
	mov.16b	v4, v1
	sshr.4s	v17, v5, #8
	mov.16b	v16, v5
	mov.16b	v18, v6
	add	x15, x14, #96
	st3.4s	{ v2, v3, v4 }, [x14], #48
	st3.4s	{ v16, v17, v18 }, [x14]
	add	x12, x12, #64
	mov	x14, x15
	adds	x13, x13, #8
	b.ne	LBB0_11
; %bb.12:                               ;   in Loop: Header=BB0_4 Depth=1
	mov	x24, x11
LBB0_13:                                ;   in Loop: Header=BB0_4 Depth=1
	add	w10, w10, #1
LBB0_14:                                ;   Parent Loop BB0_4 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	ldr	w11, [x24, #8]!
	str	w11, [x9]
	ldr	w11, [x24]
	asr	w11, w11, #8
	str	w11, [x9, #4]
	ldr	w11, [x24, #4]
	add	x22, x9, #12
	str	w11, [x9, #8]
	sub	w10, w10, #1
	mov	x9, x22
	cmp	w10, #2
	b.hi	LBB0_14
; %bb.15:                               ;   in Loop: Header=BB0_4 Depth=1
	cmp	x22, x8
	b.eq	LBB0_17
; %bb.16:                               ;   in Loop: Header=BB0_4 Depth=1
Lloh11:
	adrp	x9, _D_USBO@GOTPAGE
Lloh12:
	ldr	x9, [x9, _D_USBO@GOTPAGEOFF]
Lloh13:
	ldr	w1, [x9]
	ldr	w8, [x8]
	stp	x8, x11, [sp]
	mov	x0, x19
Lloh14:
	adrp	x2, l_.str.1@PAGE
Lloh15:
	add	x2, x2, l_.str.1@PAGEOFF
	b	LBB0_18
LBB0_17:                                ;   in Loop: Header=BB0_4 Depth=1
Lloh16:
	adrp	x8, _D_USBO@GOTPAGE
Lloh17:
	ldr	x8, [x8, _D_USBO@GOTPAGEOFF]
Lloh18:
	ldr	w1, [x8]
	mov	x0, x19
Lloh19:
	adrp	x2, l_.str.2@PAGE
Lloh20:
	add	x2, x2, l_.str.2@PAGEOFF
LBB0_18:                                ;   in Loop: Header=BB0_4 Depth=1
	mov	x3, x25
	mov	x4, x26
	bl	_gspca_dbg
	ldr	w27, [x19, #16]
	mov	x0, x27
	mov	w1, #0
	bl	_usb_sndctrlpipe
	mov	x1, x0
Lloh21:
	adrp	x8, _USB_DIR_OUT@GOTPAGE
Lloh22:
	ldr	x8, [x8, _USB_DIR_OUT@GOTPAGEOFF]
Lloh23:
	ldr	w8, [x8]
Lloh24:
	adrp	x9, _USB_TYPE_VENDOR@GOTPAGE
Lloh25:
	ldr	x9, [x9, _USB_TYPE_VENDOR@GOTPAGEOFF]
Lloh26:
	ldr	w9, [x9]
	orr	w8, w9, w8
Lloh27:
	adrp	x9, _USB_RECIP_DEVICE@GOTPAGE
Lloh28:
	ldr	x9, [x9, _USB_RECIP_DEVICE@GOTPAGEOFF]
Lloh29:
	ldr	w9, [x9]
	orr	w3, w8, w9
	ldr	x6, [x19, #8]
	sub	x8, x22, x6
	lsr	x7, x8, #2
	str	w23, [sp]
	mov	x0, x27
	mov	w2, #12
	mov	x4, x25
	mov	x5, x26
                                        ; kill: def $w7 killed $w7 killed $x7
	bl	_usb_control_msg
	tbnz	w0, #31, LBB0_20
; %bb.19:                               ;   in Loop: Header=BB0_4 Depth=1
	sub	w21, w21, w28
	mov	w0, #30
	bl	_msleep
	add	x24, x24, #8
	cmp	w21, #1
	b.ge	LBB0_4
	b	LBB0_22
LBB0_20:
	mov	x25, x0
Lloh30:
	adrp	x0, l_.str.3@PAGE
Lloh31:
	add	x0, x0, l_.str.3@PAGEOFF
	mov	x1, x25
	bl	_pr_err
LBB0_21:
	str	w25, [x19]
LBB0_22:
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh27, Lloh28, Lloh29
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpAdd	Lloh30, Lloh31
	.cfi_endproc
                                        ; -- End function
	.comm	_USB_BUF_SZ,4,2                 ; @USB_BUF_SZ
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Bug: usb_buf overflow\n"

	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_SQ930_CTRL_UCBUS_IO,4,2        ; @SQ930_CTRL_UCBUS_IO
	.comm	_D_USBO,4,2                     ; @D_USBO
l_.str.1:                               ; @.str.1
	.asciz	"ucbus v: %04x i: %04x %02x...%02x\n"

l_.str.2:                               ; @.str.2
	.asciz	"ucbus v: %04x i: %04x\n"

	.comm	_USB_DIR_OUT,4,2                ; @USB_DIR_OUT
	.comm	_USB_TYPE_VENDOR,4,2            ; @USB_TYPE_VENDOR
	.comm	_USB_RECIP_DEVICE,4,2           ; @USB_RECIP_DEVICE
l_.str.3:                               ; @.str.3
	.asciz	"ucbus_write failed %d\n"

	.no_dead_strip	_ucbus_write
.subsections_via_symbols
