	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function sahara_hw_descriptor_create
_sahara_hw_descriptor_create:           ## @sahara_hw_descriptor_create
	.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	%rdi, %r15
	movq	104(%rdi), %rbx
	movq	_FLAGS_NEW_KEY@GOTPCREL(%rip), %r14
	movl	(%r14), %eax
	testl	%eax, (%rbx)
	je	LBB0_1
## %bb.2:
	movl	96(%r15), %edi
	movl	16(%rbx), %esi
	movq	8(%rbx), %rdx
	callq	_memcpy
	movl	(%r14), %eax
	notl	%eax
	andl	%eax, (%rbx)
	movq	_FLAGS_CBC@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%r15)
	je	LBB0_4
## %bb.3:
	movq	_AES_BLOCK_SIZE@GOTPCREL(%rip), %rax
	movq	(%rax), %rcx
	movq	48(%r15), %rax
	movq	(%rax), %rax
	movq	%rcx, 16(%rax)
	movq	88(%r15), %rcx
	jmp	LBB0_5
LBB0_1:
	xorl	%r14d, %r14d
	jmp	LBB0_6
LBB0_4:
	movq	48(%r15), %rax
	movq	(%rax), %rax
	movq	$0, 16(%rax)
	xorl	%ecx, %ecx
LBB0_5:
	movq	%rcx, 40(%rax)
	movq	8(%rbx), %rcx
	movq	%rcx, 8(%rax)
	movq	80(%r15), %rcx
	movq	%rcx, 32(%rax)
	movq	40(%r15), %rcx
	movq	8(%rcx), %rcx
	movq	%rcx, (%rax)
	movq	%r15, %rdi
	callq	_sahara_aes_key_hdr
	movq	48(%r15), %rcx
	movq	(%rcx), %rcx
	movl	%eax, 24(%rcx)
	movl	$1, %r14d
LBB0_6:
	movq	16(%r15), %rdi
	movq	56(%r15), %rsi
	callq	_sg_nents_for_len
	movl	%eax, 4(%r15)
	testl	%eax, %eax
	js	LBB0_7
## %bb.8:
	movq	32(%r15), %rdi
	movq	56(%r15), %rsi
	callq	_sg_nents_for_len
	movl	%eax, 8(%r15)
	testl	%eax, %eax
	js	LBB0_9
## %bb.10:
	movslq	4(%r15), %rdx
	cltq
	addq	%rdx, %rax
	movq	_SAHARA_MAX_HW_LINK@GOTPCREL(%rip), %rcx
	movl	24(%r15), %edi
	cmpq	%rax, (%rcx)
	jge	LBB0_12
## %bb.11:
	leaq	L_.str.2(%rip), %rsi
	xorl	%ebx, %ebx
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	_dev_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	jmp	LBB0_33
LBB0_7:
	movl	24(%r15), %edi
	leaq	L_.str(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_err
	movl	4(%r15), %ebx
	jmp	LBB0_33
LBB0_9:
	movl	24(%r15), %edi
	leaq	L_.str.1(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_err
	movl	8(%r15), %ebx
	jmp	LBB0_33
LBB0_12:
	movq	16(%r15), %rsi
	movq	_DMA_TO_DEVICE@GOTPCREL(%rip), %rbx
	movl	(%rbx), %ecx
	callq	_dma_map_sg
	movl	24(%r15), %edi
	cmpl	4(%r15), %eax
	jne	LBB0_13
## %bb.16:
	movq	32(%r15), %rsi
	movslq	8(%r15), %rdx
	movq	_DMA_FROM_DEVICE@GOTPCREL(%rip), %r12
	movl	(%r12), %ecx
	callq	_dma_map_sg
                                        ## kill: def $eax killed $eax def $rax
	cmpl	8(%r15), %eax
	jne	LBB0_17
## %bb.18:
	movq	48(%r15), %rcx
	movq	64(%r15), %rdx
	movq	(%rdx), %rdi
	movq	(%rcx,%r14,8), %rsi
	movq	%rdi, 40(%rsi)
	movl	4(%r15), %ecx
	testl	%ecx, %ecx
	jle	LBB0_19
## %bb.20:
	movq	16(%r15), %rax
	xorl	%ebx, %ebx
	jmp	LBB0_21
	.p2align	4, 0x90
LBB0_23:                                ##   in Loop: Header=BB0_21 Depth=1
	movq	64(%r15), %rcx
	movq	8(%rcx,%rbx,8), %rcx
	incq	%rbx
	movq	%rcx, (%rdx)
	movq	%rax, %rdi
	callq	_sg_next
	movl	4(%r15), %ecx
LBB0_24:                                ##   in Loop: Header=BB0_21 Depth=1
	movslq	%ecx, %rdx
	cmpq	%rdx, %rbx
	jge	LBB0_25
LBB0_21:                                ## =>This Inner Loop Header: Depth=1
	movl	4(%rax), %esi
	movq	72(%r15), %rdx
	movq	(%rdx,%rbx,8), %rdx
	movl	%esi, 12(%rdx)
	movl	(%rax), %esi
	movl	%esi, 8(%rdx)
	leal	-1(%rcx), %esi
	cmpq	%rsi, %rbx
	jne	LBB0_23
## %bb.22:                              ##   in Loop: Header=BB0_21 Depth=1
	movq	$0, (%rdx)
	incq	%rbx
	jmp	LBB0_24
LBB0_13:
	leaq	L_.str.3(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_14
LBB0_17:
	movl	24(%r15), %edi
	leaq	L_.str.4(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_err
	movl	8(%r15), %edx
	movl	24(%r15), %edi
	movq	32(%r15), %rsi
	movl	(%r12), %ecx
	callq	_dma_unmap_sg
LBB0_14:
	movl	24(%r15), %edi
	movq	16(%r15), %rsi
	movl	4(%r15), %edx
	movl	(%rbx), %ecx
	callq	_dma_unmap_sg
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_33
LBB0_25:
	movq	64(%r15), %rdx
	movq	48(%r15), %rax
	movq	(%rax,%r14,8), %rsi
	movl	8(%r15), %eax
	jmp	LBB0_26
LBB0_19:
	xorl	%ebx, %ebx
LBB0_26:
	movl	%ebx, %r12d
	movq	(%rdx,%r12,8), %rcx
	movq	%rcx, 32(%rsi)
	testl	%eax, %eax
	jle	LBB0_32
## %bb.27:
	leal	(%rax,%r12), %ecx
	movq	32(%r15), %rdi
	movq	%r12, %rbx
	jmp	LBB0_28
	.p2align	4, 0x90
LBB0_30:                                ##   in Loop: Header=BB0_28 Depth=1
	movq	64(%r15), %rax
	movq	8(%rax,%rbx,8), %rax
	incq	%rbx
	movq	%rax, (%rdx)
	callq	_sg_next
	movq	%rax, %rdi
	movl	8(%r15), %eax
LBB0_31:                                ##   in Loop: Header=BB0_28 Depth=1
	leal	(%r12,%rax), %ecx
	cmpl	%ebx, %ecx
	jle	LBB0_32
LBB0_28:                                ## =>This Inner Loop Header: Depth=1
	movl	4(%rdi), %esi
	movq	72(%r15), %rdx
	movq	(%rdx,%rbx,8), %rdx
	movl	%esi, 12(%rdx)
	movl	(%rdi), %esi
	movl	%esi, 8(%rdx)
	decl	%ecx
	cmpq	%rcx, %rbx
	jne	LBB0_30
## %bb.29:                              ##   in Loop: Header=BB0_28 Depth=1
	movq	$0, (%rdx)
	incq	%rbx
	jmp	LBB0_31
LBB0_32:
	movq	%r15, %rdi
	callq	_sahara_aes_data_link_hdr
	movq	48(%r15), %rcx
	movq	(%rcx,%r14,8), %rcx
	movl	%eax, 24(%rcx)
	movq	56(%r15), %rax
	movq	%rax, 16(%rcx)
	movq	%rax, 8(%rcx)
	movq	$0, (%rcx)
	movq	%r15, %rdi
	callq	_sahara_dump_descriptors
	movq	%r15, %rdi
	callq	_sahara_dump_links
	movq	40(%r15), %rax
	movq	(%rax), %rsi
	movq	_SAHARA_REG_DAR@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r15, %rdi
	callq	_sahara_write
	xorl	%ebx, %ebx
LBB0_33:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_FLAGS_NEW_KEY,4,2              ## @FLAGS_NEW_KEY
	.comm	_FLAGS_CBC,4,2                  ## @FLAGS_CBC
	.comm	_AES_BLOCK_SIZE,8,3             ## @AES_BLOCK_SIZE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Invalid numbers of src SG.\n"

L_.str.1:                               ## @.str.1
	.asciz	"Invalid numbers of dst SG.\n"

	.comm	_SAHARA_MAX_HW_LINK,8,3         ## @SAHARA_MAX_HW_LINK
L_.str.2:                               ## @.str.2
	.asciz	"not enough hw links (%d)\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_DMA_TO_DEVICE,4,2              ## @DMA_TO_DEVICE
L_.str.3:                               ## @.str.3
	.asciz	"couldn't map in sg\n"

	.comm	_DMA_FROM_DEVICE,4,2            ## @DMA_FROM_DEVICE
L_.str.4:                               ## @.str.4
	.asciz	"couldn't map out sg\n"

	.comm	_SAHARA_REG_DAR,4,2             ## @SAHARA_REG_DAR
	.no_dead_strip	_sahara_hw_descriptor_create
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function sahara_hw_descriptor_create
_sahara_hw_descriptor_create:           ; @sahara_hw_descriptor_create
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #64
	.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
	mov	x19, x0
	ldr	x20, [x0, #104]
	ldr	w8, [x20]
Lloh0:
	adrp	x21, _FLAGS_NEW_KEY@GOTPAGE
Lloh1:
	ldr	x21, [x21, _FLAGS_NEW_KEY@GOTPAGEOFF]
	ldr	w9, [x21]
	tst	w9, w8
	b.eq	LBB0_3
; %bb.1:
	ldr	w0, [x19, #96]
	ldr	w1, [x20, #16]
	ldr	x2, [x20, #8]
	bl	_memcpy
	ldr	w8, [x21]
	ldr	w9, [x20]
	bic	w8, w9, w8
	str	w8, [x20]
	ldr	w8, [x19]
Lloh2:
	adrp	x9, _FLAGS_CBC@GOTPAGE
Lloh3:
	ldr	x9, [x9, _FLAGS_CBC@GOTPAGEOFF]
Lloh4:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_4
; %bb.2:
Lloh5:
	adrp	x8, _AES_BLOCK_SIZE@GOTPAGE
Lloh6:
	ldr	x8, [x8, _AES_BLOCK_SIZE@GOTPAGEOFF]
Lloh7:
	ldr	x9, [x8]
	ldr	x8, [x19, #48]
	ldr	x8, [x8]
	str	x9, [x8, #16]
	ldr	x9, [x19, #88]
	b	LBB0_5
LBB0_3:
	mov	x20, #0
	b	LBB0_6
LBB0_4:
	mov	x9, #0
	ldr	x8, [x19, #48]
	ldr	x8, [x8]
	str	xzr, [x8, #16]
LBB0_5:
	ldr	x10, [x20, #8]
	str	x10, [x8, #8]
	ldr	x10, [x19, #80]
	stp	x10, x9, [x8, #32]
	ldr	x9, [x19, #40]
	ldr	x9, [x9, #8]
	str	x9, [x8]
	mov	x0, x19
	bl	_sahara_aes_key_hdr
	ldr	x8, [x19, #48]
	ldr	x8, [x8]
	str	w0, [x8, #24]
	mov	w20, #1
LBB0_6:
	ldr	x0, [x19, #16]
	ldr	x1, [x19, #56]
	bl	_sg_nents_for_len
	str	w0, [x19, #4]
	tbnz	w0, #31, LBB0_10
; %bb.7:
	ldr	x0, [x19, #32]
	ldr	x1, [x19, #56]
	bl	_sg_nents_for_len
	str	w0, [x19, #8]
	tbnz	w0, #31, LBB0_11
; %bb.8:
	ldrsw	x2, [x19, #4]
	add	x8, x2, w0, sxtw
Lloh8:
	adrp	x9, _SAHARA_MAX_HW_LINK@GOTPAGE
Lloh9:
	ldr	x9, [x9, _SAHARA_MAX_HW_LINK@GOTPAGEOFF]
Lloh10:
	ldr	x9, [x9]
	ldr	w0, [x19, #24]
	cmp	x9, x8
	b.ge	LBB0_12
; %bb.9:
                                        ; kill: def $w8 killed $w8 killed $x8 def $x8
	str	x8, [sp]
Lloh11:
	adrp	x1, l_.str.2@PAGE
Lloh12:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_dev_err
	b	LBB0_23
LBB0_10:
	ldr	w0, [x19, #24]
Lloh13:
	adrp	x1, l_.str@PAGE
Lloh14:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
	ldr	w0, [x19, #4]
	b	LBB0_24
LBB0_11:
	ldr	w0, [x19, #24]
Lloh15:
	adrp	x1, l_.str.1@PAGE
Lloh16:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_dev_err
	ldr	w0, [x19, #8]
	b	LBB0_24
LBB0_12:
	ldr	x1, [x19, #16]
Lloh17:
	adrp	x21, _DMA_TO_DEVICE@GOTPAGE
Lloh18:
	ldr	x21, [x21, _DMA_TO_DEVICE@GOTPAGEOFF]
	ldr	w3, [x21]
	bl	_dma_map_sg
	mov	x8, x0
	ldr	w9, [x19, #4]
	ldr	w0, [x19, #24]
	cmp	w8, w9
	b.ne	LBB0_20
; %bb.13:
	ldr	x1, [x19, #32]
	ldrsw	x2, [x19, #8]
Lloh19:
	adrp	x22, _DMA_FROM_DEVICE@GOTPAGE
Lloh20:
	ldr	x22, [x22, _DMA_FROM_DEVICE@GOTPAGEOFF]
	ldr	w3, [x22]
	bl	_dma_map_sg
	ldr	w8, [x19, #8]
	cmp	w0, w8
	b.ne	LBB0_21
; %bb.14:
	ldr	x9, [x19, #64]
	ldr	x8, [x9]
	ldr	x10, [x19, #48]
	ldr	x10, [x10, x20, lsl #3]
	str	x8, [x10, #40]
	ldr	w8, [x19, #4]
	cmp	w8, #1
	b.lt	LBB0_25
; %bb.15:
	mov	x21, #0
	ldr	x0, [x19, #16]
	b	LBB0_17
LBB0_16:                                ;   in Loop: Header=BB0_17 Depth=1
	ldr	x8, [x19, #64]
	add	x21, x21, #1
	ldr	x8, [x8, x21, lsl #3]
	str	x8, [x9]
	bl	_sg_next
	ldr	w8, [x19, #4]
	cmp	x21, w8, sxtw
	b.ge	LBB0_19
LBB0_17:                                ; =>This Inner Loop Header: Depth=1
	ldr	x9, [x19, #72]
	ldr	x9, [x9, x21, lsl #3]
	ldr	d0, [x0]
	str	d0, [x9, #8]
	sub	w10, w8, #1
	cmp	x21, x10
	b.ne	LBB0_16
; %bb.18:                               ;   in Loop: Header=BB0_17 Depth=1
	str	xzr, [x9]
	add	x21, x21, #1
	cmp	x21, w8, sxtw
	b.lt	LBB0_17
LBB0_19:
	ldr	x9, [x19, #64]
	ldr	x8, [x19, #48]
	ldr	x10, [x8, x20, lsl #3]
	ldr	w0, [x19, #8]
	b	LBB0_26
LBB0_20:
Lloh21:
	adrp	x1, l_.str.3@PAGE
Lloh22:
	add	x1, x1, l_.str.3@PAGEOFF
	bl	_dev_err
	b	LBB0_22
LBB0_21:
	ldr	w0, [x19, #24]
Lloh23:
	adrp	x1, l_.str.4@PAGE
Lloh24:
	add	x1, x1, l_.str.4@PAGEOFF
	bl	_dev_err
	ldr	w0, [x19, #24]
	ldr	x1, [x19, #32]
	ldr	w2, [x19, #8]
	ldr	w3, [x22]
	bl	_dma_unmap_sg
LBB0_22:
	ldr	w0, [x19, #24]
	ldr	x1, [x19, #16]
	ldr	w2, [x19, #4]
	ldr	w3, [x21]
	bl	_dma_unmap_sg
LBB0_23:
Lloh25:
	adrp	x8, _EINVAL@GOTPAGE
Lloh26:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh27:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_24:
	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
	add	sp, sp, #64
	ret
LBB0_25:
	mov	w21, #0
LBB0_26:
	ldr	x8, [x9, w21, uxtw #3]
	str	x8, [x10, #32]
	cmp	w0, #1
	b.lt	LBB0_32
; %bb.27:
	mov	w21, w21
	add	w9, w0, w21
	ldr	x8, [x19, #32]
	mov	x22, x21
	b	LBB0_30
LBB0_28:                                ;   in Loop: Header=BB0_30 Depth=1
	ldr	x9, [x19, #64]
	add	x22, x22, #1
	ldr	x9, [x9, x22, lsl #3]
	str	x9, [x10]
	mov	x0, x8
	bl	_sg_next
	mov	x8, x0
	ldr	w0, [x19, #8]
LBB0_29:                                ;   in Loop: Header=BB0_30 Depth=1
	add	w9, w0, w21
	cmp	w9, w22
	b.le	LBB0_32
LBB0_30:                                ; =>This Inner Loop Header: Depth=1
	ldr	x10, [x19, #72]
	ldr	x10, [x10, x22, lsl #3]
	ldr	d0, [x8]
	str	d0, [x10, #8]
	sub	w9, w9, #1
	cmp	x22, x9
	b.ne	LBB0_28
; %bb.31:                               ;   in Loop: Header=BB0_30 Depth=1
	str	xzr, [x10]
	add	x22, x22, #1
	b	LBB0_29
LBB0_32:
	mov	x0, x19
	bl	_sahara_aes_data_link_hdr
	ldp	x8, x9, [x19, #48]
	ldr	x8, [x8, x20, lsl #3]
	str	w0, [x8, #24]
	stp	x9, x9, [x8, #8]
	str	xzr, [x8]
	mov	x0, x19
	bl	_sahara_dump_descriptors
	mov	x0, x19
	bl	_sahara_dump_links
	ldr	x8, [x19, #40]
	ldr	x1, [x8]
Lloh28:
	adrp	x8, _SAHARA_REG_DAR@GOTPAGE
Lloh29:
	ldr	x8, [x8, _SAHARA_REG_DAR@GOTPAGEOFF]
Lloh30:
	ldr	w2, [x8]
	mov	x0, x19
	bl	_sahara_write
	mov	w0, #0
	b	LBB0_24
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh11, Lloh12
	.loh AdrpAdd	Lloh13, Lloh14
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpLdrGot	Lloh17, Lloh18
	.loh AdrpLdrGot	Lloh19, Lloh20
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpAdd	Lloh23, Lloh24
	.loh AdrpLdrGotLdr	Lloh25, Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.cfi_endproc
                                        ; -- End function
	.comm	_FLAGS_NEW_KEY,4,2              ; @FLAGS_NEW_KEY
	.comm	_FLAGS_CBC,4,2                  ; @FLAGS_CBC
	.comm	_AES_BLOCK_SIZE,8,3             ; @AES_BLOCK_SIZE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Invalid numbers of src SG.\n"

l_.str.1:                               ; @.str.1
	.asciz	"Invalid numbers of dst SG.\n"

	.comm	_SAHARA_MAX_HW_LINK,8,3         ; @SAHARA_MAX_HW_LINK
l_.str.2:                               ; @.str.2
	.asciz	"not enough hw links (%d)\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_DMA_TO_DEVICE,4,2              ; @DMA_TO_DEVICE
l_.str.3:                               ; @.str.3
	.asciz	"couldn't map in sg\n"

	.comm	_DMA_FROM_DEVICE,4,2            ; @DMA_FROM_DEVICE
l_.str.4:                               ; @.str.4
	.asciz	"couldn't map out sg\n"

	.comm	_SAHARA_REG_DAR,4,2             ; @SAHARA_REG_DAR
	.no_dead_strip	_sahara_hw_descriptor_create
.subsections_via_symbols
