	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function stm32_dma_desc_residue
_stm32_dma_desc_residue:                ## @stm32_dma_desc_residue
	.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	%rdx, %r15
	movq	%rsi, %r13
	movq	%rdi, %r14
	movq	(%rdi), %rax
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	movq	24(%rdi), %rax
	movq	16(%rax), %r12
	callq	_stm32_dma_get_remaining_bytes
	movq	%rax, %rbx
	movq	%r14, %rdi
	callq	_stm32_dma_is_current_sg
	testl	%eax, %eax
	je	LBB0_2
## %bb.1:
	movq	24(%r14), %rax
	cmpl	$0, 8(%rax)
	jne	LBB0_4
	jmp	LBB0_5
LBB0_2:
	incq	%r15
	movq	24(%r14), %rax
	xorl	%ecx, %ecx
	cmpq	(%rax), %r15
	cmoveq	%rcx, %r15
	movq	-48(%rbp), %rcx                 ## 8-byte Reload
	movq	(%r12,%rcx,8), %rbx
	cmpl	$0, 8(%rax)
	je	LBB0_5
LBB0_4:
	testq	%r15, %r15
	je	LBB0_17
LBB0_5:
	movslq	(%r13), %rax
	cmpl	%r15d, %eax
	jle	LBB0_17
## %bb.6:
	movq	8(%r13), %rcx
	movslq	%r15d, %rdx
	movq	%rax, %r9
	subq	%rdx, %r9
	cmpq	$4, %r9
	jb	LBB0_16
## %bb.7:
	movq	%r9, %r8
	andq	$-4, %r8
	movq	%rbx, %xmm0
	leaq	-4(%r8), %rsi
	movq	%rsi, %rbx
	shrq	$2, %rbx
	incq	%rbx
	movl	%ebx, %r10d
	andl	$3, %r10d
	cmpq	$12, %rsi
	jae	LBB0_9
## %bb.8:
	pxor	%xmm1, %xmm1
	xorl	%edi, %edi
	jmp	LBB0_11
LBB0_9:
	andq	$-4, %rbx
	leaq	(%rcx,%rdx,8), %rsi
	addq	$112, %rsi
	pxor	%xmm1, %xmm1
	xorl	%edi, %edi
	.p2align	4, 0x90
LBB0_10:                                ## =>This Inner Loop Header: Depth=1
	movdqu	-112(%rsi,%rdi,8), %xmm2
	paddq	%xmm0, %xmm2
	movdqu	-96(%rsi,%rdi,8), %xmm0
	paddq	%xmm1, %xmm0
	movdqu	-80(%rsi,%rdi,8), %xmm1
	movdqu	-64(%rsi,%rdi,8), %xmm3
	movdqu	-48(%rsi,%rdi,8), %xmm4
	paddq	%xmm1, %xmm4
	paddq	%xmm2, %xmm4
	movdqu	-32(%rsi,%rdi,8), %xmm2
	paddq	%xmm3, %xmm2
	paddq	%xmm0, %xmm2
	movdqu	-16(%rsi,%rdi,8), %xmm0
	paddq	%xmm4, %xmm0
	movdqu	(%rsi,%rdi,8), %xmm1
	paddq	%xmm2, %xmm1
	addq	$16, %rdi
	addq	$-4, %rbx
	jne	LBB0_10
LBB0_11:
	testq	%r10, %r10
	je	LBB0_14
## %bb.12:
	addq	%rdx, %rdi
	leaq	(%rcx,%rdi,8), %rsi
	addq	$16, %rsi
	shlq	$5, %r10
	xorl	%edi, %edi
	.p2align	4, 0x90
LBB0_13:                                ## =>This Inner Loop Header: Depth=1
	movdqu	-16(%rsi,%rdi), %xmm2
	paddq	%xmm2, %xmm0
	movdqu	(%rsi,%rdi), %xmm2
	paddq	%xmm2, %xmm1
	addq	$32, %rdi
	cmpq	%rdi, %r10
	jne	LBB0_13
LBB0_14:
	paddq	%xmm1, %xmm0
	pshufd	$238, %xmm0, %xmm1              ## xmm1 = xmm0[2,3,2,3]
	paddq	%xmm0, %xmm1
	movq	%xmm1, %rbx
	cmpq	%r8, %r9
	je	LBB0_17
## %bb.15:
	addq	%r8, %rdx
	.p2align	4, 0x90
LBB0_16:                                ## =>This Inner Loop Header: Depth=1
	addq	(%rcx,%rdx,8), %rbx
	incq	%rdx
	cmpq	%rdx, %rax
	jne	LBB0_16
LBB0_17:
	movq	8(%r14), %rcx
	testq	%rcx, %rcx
	je	LBB0_22
## %bb.18:
	imulq	16(%r14), %rcx
	movq	%rbx, %rax
	orq	%rcx, %rax
	shrq	$32, %rax
	je	LBB0_19
## %bb.20:
	movq	%rbx, %rax
	xorl	%edx, %edx
	divq	%rcx
	jmp	LBB0_21
LBB0_19:
	movl	%ebx, %eax
	xorl	%edx, %edx
	divl	%ecx
                                        ## kill: def $edx killed $edx def $rdx
LBB0_21:
	movq	%rbx, %rax
	subq	%rdx, %rax
	addq	%rcx, %rax
	testq	%rdx, %rdx
	cmovneq	%rax, %rbx
LBB0_22:
	movq	%rbx, %rax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.no_dead_strip	_stm32_dma_desc_residue
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function stm32_dma_desc_residue
_stm32_dma_desc_residue:                ; @stm32_dma_desc_residue
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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
	mov	x21, x2
	mov	x22, x1
	mov	x19, x0
	ldr	x8, [x0, #24]
	ldr	x23, [x8, #16]
	ldr	x24, [x0]
	bl	_stm32_dma_get_remaining_bytes
	mov	x20, x0
	mov	x0, x19
	bl	_stm32_dma_is_current_sg
	cbz	w0, LBB0_2
; %bb.1:
	ldr	x8, [x19, #24]
	b	LBB0_3
LBB0_2:
	add	x9, x21, #1
	ldr	x8, [x19, #24]
	ldr	x10, [x8]
	cmp	x9, x10
	csinc	x21, xzr, x21, eq
	ldr	x20, [x23, x24, lsl #3]
LBB0_3:
	ldr	w8, [x8, #8]
	cmp	w8, #0
	ccmp	x21, #0, #0, ne
	b.eq	LBB0_12
; %bb.4:
	ldrsw	x8, [x22]
	cmp	w8, w21
	b.le	LBB0_12
; %bb.5:
	ldr	x9, [x22, #8]
	sxtw	x13, w21
	sub	x11, x8, x13
	cmp	x11, #8
	b.hs	LBB0_7
; %bb.6:
	mov	x10, x13
	b	LBB0_10
LBB0_7:
	and	x12, x11, #0xfffffffffffffff8
	add	x10, x13, x12
	movi.2d	v0, #0000000000000000
	mov.d	v0[0], x20
	movi.2d	v1, #0000000000000000
	add	x13, x9, x13, lsl #3
	add	x13, x13, #32
	mov	x14, x12
	movi.2d	v2, #0000000000000000
	movi.2d	v3, #0000000000000000
LBB0_8:                                 ; =>This Inner Loop Header: Depth=1
	ldp	q4, q5, [x13, #-32]
	ldp	q6, q7, [x13], #64
	add.2d	v0, v4, v0
	add.2d	v1, v5, v1
	add.2d	v2, v6, v2
	add.2d	v3, v7, v3
	subs	x14, x14, #8
	b.ne	LBB0_8
; %bb.9:
	add.2d	v0, v1, v0
	add.2d	v0, v2, v0
	add.2d	v0, v3, v0
	addp.2d	d0, v0
	fmov	x20, d0
	cmp	x11, x12
	b.eq	LBB0_12
LBB0_10:
	add	x9, x9, x10, lsl #3
	sub	x8, x8, x10
LBB0_11:                                ; =>This Inner Loop Header: Depth=1
	ldr	x10, [x9], #8
	add	x20, x10, x20
	subs	x8, x8, #1
	b.ne	LBB0_11
LBB0_12:
	ldr	x8, [x19, #8]
	cbz	x8, LBB0_14
; %bb.13:
	ldr	x9, [x19, #16]
	mul	x8, x9, x8
	udiv	x9, x20, x8
	mul	x9, x9, x8
	add	x8, x9, x8
	cmp	x20, x9
	csel	x20, x20, x8, eq
LBB0_14:
	mov	x0, x20
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
	.cfi_endproc
                                        ; -- End function
	.no_dead_strip	_stm32_dma_desc_residue
.subsections_via_symbols
