	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.section	__TEXT,__literal16,16byte_literals
	.p2align	4                               ## -- Begin function via_build_sg_info
LCPI0_0:
	.long	1                               ## 0x1
	.space	4
	.space	4
	.space	4
	.section	__TEXT,__text,regular,pure_instructions
	.p2align	4, 0x90
_via_build_sg_info:                     ## @via_build_sg_info
	.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, %r12
	movq	%rsi, %r15
	movq	%rdi, %r14
	cmpl	$0, (%rdx)
	jne	LBB0_1
## %bb.2:
	movq	_DMA_FROM_DEVICE@GOTPCREL(%rip), %rax
	jmp	LBB0_3
LBB0_1:
	movq	_DMA_TO_DEVICE@GOTPCREL(%rip), %rax
LBB0_3:
	movl	(%rax), %eax
	movl	%eax, 16(%r15)
	movq	$0, 8(%r15)
	movq	_dr_via_sg_init@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, (%r15)
	movl	4(%r12), %eax
	testl	%eax, %eax
	jle	LBB0_5
## %bb.4:
	movl	8(%r12), %edx
	testl	%edx, %edx
	jle	LBB0_5
## %bb.8:
	movl	12(%r12), %esi
	movl	%esi, %ecx
	subl	%edx, %ecx
	movq	_PAGE_SIZE@GOTPCREL(%rip), %rdi
	movl	(%rdi), %edi
	addl	%edi, %edi
	cmpl	%edi, %ecx
	jle	LBB0_10
## %bb.9:
	leaq	L_.str.1(%rip), %rdi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_DRM_ERROR
	jmp	LBB0_7
LBB0_5:
	leaq	L_.str(%rip), %rdi
LBB0_6:
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_DRM_ERROR
LBB0_7:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
LBB0_29:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_10:
	cmpl	%edx, %esi
	jne	LBB0_13
## %bb.11:
	cmpl	%edx, 16(%r12)
	jne	LBB0_13
## %bb.12:
	imull	%eax, %edx
	movdqa	LCPI0_0(%rip), %xmm0            ## xmm0 = <1,u,u,u>
	pinsrd	$1, %edx, %xmm0
	pshufd	$84, %xmm0, %xmm0               ## xmm0 = xmm0[0,1,1,1]
	movdqu	%xmm0, 4(%r12)
	movl	$1, %eax
	movl	%edx, %esi
	jmp	LBB0_14
LBB0_13:
	cmpl	$2048, %eax                     ## imm = 0x800
	ja	LBB0_15
LBB0_14:
	movl	%esi, %ecx
	imull	%eax, %ecx
	cmpl	$16777217, %ecx                 ## imm = 0x1000001
	jl	LBB0_16
LBB0_15:
	leaq	L_.str.2(%rip), %rdi
	jmp	LBB0_6
LBB0_16:
	cmpl	%edx, %esi
	jl	LBB0_18
## %bb.17:
	movl	16(%r12), %ecx
	movl	%ecx, %edi
	negl	%edi
	cmovsl	%ecx, %edi
	cmpl	%edx, %edi
	jge	LBB0_19
LBB0_18:
	leaq	L_.str.3(%rip), %rdi
	jmp	LBB0_6
LBB0_19:
	testb	$15, 32(%r12)
	jne	LBB0_23
## %bb.20:
	testb	$3, 24(%r12)
	je	LBB0_21
LBB0_23:
	leaq	L_.str.4(%rip), %rdi
	jmp	LBB0_6
LBB0_21:
	cmpl	$2, %eax
	jb	LBB0_24
## %bb.22:
	andl	$15, %esi
	andl	$3, %ecx
	orl	%esi, %ecx
	jne	LBB0_23
LBB0_24:
	movq	%r15, %rdi
	movq	%r12, %rsi
	callq	_via_lock_all_dma_pages
	testl	%eax, %eax
	je	LBB0_26
## %bb.25:
	movl	%eax, %ebx
	leaq	L_.str.5(%rip), %rdi
	xorl	%eax, %eax
	callq	_DRM_ERROR
	movl	(%r14), %edi
	movq	%r15, %rsi
	callq	_via_free_sg_info
	jmp	LBB0_29
LBB0_26:
	movl	(%r14), %edi
	xorl	%ebx, %ebx
	movq	%r12, %rsi
	movq	%r15, %rdx
	xorl	%ecx, %ecx
	callq	_via_map_blit_for_device
	movq	%r15, %rdi
	callq	_via_alloc_desc_pages
	testl	%eax, %eax
	je	LBB0_28
## %bb.27:
	movl	%eax, %r13d
	leaq	L_.str.6(%rip), %rdi
	xorl	%eax, %eax
	callq	_DRM_ERROR
	movl	(%r14), %edi
	movq	%r15, %rsi
	callq	_via_free_sg_info
	movl	%r13d, %ebx
	jmp	LBB0_29
LBB0_28:
	movl	(%r14), %edi
	movq	%r12, %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	_via_map_blit_for_device
	jmp	LBB0_29
	.cfi_endproc
                                        ## -- End function
	.comm	_DMA_TO_DEVICE,4,2              ## @DMA_TO_DEVICE
	.comm	_DMA_FROM_DEVICE,4,2            ## @DMA_FROM_DEVICE
	.comm	_dr_via_sg_init,4,2             ## @dr_via_sg_init
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Zero size bitblt.\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_PAGE_SIZE,4,2                  ## @PAGE_SIZE
L_.str.1:                               ## @.str.1
	.asciz	"Too large system memory stride. Stride: %d, Length: %d\n"

L_.str.2:                               ## @.str.2
	.asciz	"Too large PCI DMA bitblt.\n"

L_.str.3:                               ## @.str.3
	.asciz	"Invalid frame-buffer / memory stride.\n"

L_.str.4:                               ## @.str.4
	.asciz	"Invalid DRM bitblt alignment.\n"

L_.str.5:                               ## @.str.5
	.asciz	"Could not lock DMA pages.\n"

L_.str.6:                               ## @.str.6
	.asciz	"Could not allocate DMA descriptor pages.\n"

	.no_dead_strip	_via_build_sg_info
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function via_build_sg_info
_via_build_sg_info:                     ; @via_build_sg_info
	.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
Lloh0:
	adrp	x9, _DMA_TO_DEVICE@GOTPAGE
Lloh1:
	ldr	x9, [x9, _DMA_TO_DEVICE@GOTPAGEOFF]
	ldp	w10, w8, [x2]
	cmp	w10, #0
Lloh2:
	adrp	x10, _DMA_FROM_DEVICE@GOTPAGE
Lloh3:
	ldr	x10, [x10, _DMA_FROM_DEVICE@GOTPAGEOFF]
	csel	x9, x10, x9, eq
	ldr	w9, [x9]
	str	w9, [x1, #16]
	str	xzr, [x1, #8]
Lloh4:
	adrp	x9, _dr_via_sg_init@GOTPAGE
Lloh5:
	ldr	x9, [x9, _dr_via_sg_init@GOTPAGEOFF]
Lloh6:
	ldr	w9, [x9]
	str	w9, [x1]
	cmp	w8, #1
	b.lt	LBB0_4
; %bb.1:
	mov	x21, x2
	ldr	w10, [x2, #8]
	cmp	w10, #0
	b.le	LBB0_4
; %bb.2:
	ldr	w9, [x21, #12]
	sub	w11, w9, w10
Lloh7:
	adrp	x12, _PAGE_SIZE@GOTPAGE
Lloh8:
	ldr	x12, [x12, _PAGE_SIZE@GOTPAGEOFF]
Lloh9:
	ldr	w12, [x12]
	cmp	w11, w12, lsl #1
	b.le	LBB0_7
; %bb.3:
	stp	x9, x10, [sp]
Lloh10:
	adrp	x0, l_.str.1@PAGE
Lloh11:
	add	x0, x0, l_.str.1@PAGEOFF
	b	LBB0_5
LBB0_4:
Lloh12:
	adrp	x0, l_.str@PAGE
Lloh13:
	add	x0, x0, l_.str@PAGEOFF
LBB0_5:
	bl	_DRM_ERROR
Lloh14:
	adrp	x8, _EINVAL@GOTPAGE
Lloh15:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh16:
	ldr	w8, [x8]
	neg	w22, w8
LBB0_6:
	mov	x0, x22
	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_7:
	mov	x19, x1
	mov	x20, x0
	cmp	w9, w10
	b.ne	LBB0_10
; %bb.8:
	ldr	w11, [x21, #16]
	cmp	w11, w10
	b.ne	LBB0_10
; %bb.9:
	mul	w10, w10, w8
	stp	w10, w10, [x21, #12]
	mov	w8, #1
	stp	w8, w10, [x21, #4]
	mov	x9, x10
	b	LBB0_11
LBB0_10:
	cmp	w8, #2048
	b.hi	LBB0_12
LBB0_11:
	mul	w11, w9, w8
	mov	w12, #1
	movk	w12, #256, lsl #16
	cmp	w11, w12
	b.lt	LBB0_13
LBB0_12:
Lloh17:
	adrp	x0, l_.str.2@PAGE
Lloh18:
	add	x0, x0, l_.str.2@PAGEOFF
	b	LBB0_5
LBB0_13:
	cmp	w9, w10
	b.lt	LBB0_15
; %bb.14:
	ldr	w11, [x21, #16]
	cmp	w11, #0
	cneg	w12, w11, mi
	cmp	w12, w10
	b.ge	LBB0_16
LBB0_15:
Lloh19:
	adrp	x0, l_.str.3@PAGE
Lloh20:
	add	x0, x0, l_.str.3@PAGEOFF
	b	LBB0_5
LBB0_16:
	ldrb	w10, [x21, #32]
	tst	w10, #0xf
	b.ne	LBB0_18
; %bb.17:
	ldrb	w10, [x21, #24]
	tst	w10, #0x3
	b.eq	LBB0_19
LBB0_18:
Lloh21:
	adrp	x0, l_.str.4@PAGE
Lloh22:
	add	x0, x0, l_.str.4@PAGEOFF
	b	LBB0_5
LBB0_19:
	cmp	w8, #2
	b.lo	LBB0_21
; %bb.20:
	and	w8, w9, #0xf
	and	w9, w11, #0x3
	orr	w8, w8, w9
	cbnz	w8, LBB0_18
LBB0_21:
	mov	x0, x19
	mov	x1, x21
	bl	_via_lock_all_dma_pages
	cbz	w0, LBB0_23
; %bb.22:
	mov	x22, x0
Lloh23:
	adrp	x0, l_.str.5@PAGE
Lloh24:
	add	x0, x0, l_.str.5@PAGEOFF
	b	LBB0_25
LBB0_23:
	ldr	w0, [x20]
	mov	x1, x21
	mov	x2, x19
	mov	w3, #0
	bl	_via_map_blit_for_device
	mov	x0, x19
	bl	_via_alloc_desc_pages
	mov	x22, x0
	cbz	w0, LBB0_26
; %bb.24:
Lloh25:
	adrp	x0, l_.str.6@PAGE
Lloh26:
	add	x0, x0, l_.str.6@PAGEOFF
LBB0_25:
	bl	_DRM_ERROR
	ldr	w0, [x20]
	mov	x1, x19
	bl	_via_free_sg_info
	b	LBB0_6
LBB0_26:
	ldr	w0, [x20]
	mov	x1, x21
	mov	x2, x19
	mov	w3, #1
	bl	_via_map_blit_for_device
	b	LBB0_6
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpAdd	Lloh17, Lloh18
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpAdd	Lloh23, Lloh24
	.loh AdrpAdd	Lloh25, Lloh26
	.cfi_endproc
                                        ; -- End function
	.comm	_DMA_TO_DEVICE,4,2              ; @DMA_TO_DEVICE
	.comm	_DMA_FROM_DEVICE,4,2            ; @DMA_FROM_DEVICE
	.comm	_dr_via_sg_init,4,2             ; @dr_via_sg_init
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Zero size bitblt.\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_PAGE_SIZE,4,2                  ; @PAGE_SIZE
l_.str.1:                               ; @.str.1
	.asciz	"Too large system memory stride. Stride: %d, Length: %d\n"

l_.str.2:                               ; @.str.2
	.asciz	"Too large PCI DMA bitblt.\n"

l_.str.3:                               ; @.str.3
	.asciz	"Invalid frame-buffer / memory stride.\n"

l_.str.4:                               ; @.str.4
	.asciz	"Invalid DRM bitblt alignment.\n"

l_.str.5:                               ; @.str.5
	.asciz	"Could not lock DMA pages.\n"

l_.str.6:                               ; @.str.6
	.asciz	"Could not allocate DMA descriptor pages.\n"

	.no_dead_strip	_via_build_sg_info
.subsections_via_symbols
