	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_cpia2_remap_buffer             ## -- Begin function cpia2_remap_buffer
	.p2align	4, 0x90
_cpia2_remap_buffer:                    ## @cpia2_remap_buffer
	.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	%rsi, %r15
	movq	%rdi, %r14
	movq	(%rsi), %r12
	movq	8(%rsi), %rbx
	subq	%r12, %rbx
	movq	16(%rsi), %r13
	movq	_PAGE_SHIFT@GOTPCREL(%rip), %rax
	movb	(%rax), %cl
	shlq	%cl, %r13
	leaq	L_.str(%rip), %rdi
	movq	%r13, %rsi
	movq	%rbx, %rdx
	callq	_DBG
	leaq	32(%r14), %rdi
	callq	_video_is_registered
	testl	%eax, %eax
	je	LBB0_1
## %bb.3:
	movq	(%r14), %rsi
	movq	8(%r14), %rcx
	imulq	%rsi, %rcx
	cmpq	%rcx, %rbx
	jbe	LBB0_4
LBB0_9:
	movq	_EINVAL@GOTPCREL(%rip), %rcx
	jmp	LBB0_2
LBB0_1:
	movq	_ENODEV@GOTPCREL(%rip), %rcx
LBB0_2:
	xorl	%eax, %eax
	subl	(%rcx), %eax
LBB0_16:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_4:
	movq	%r13, %rax
	orq	%rsi, %rax
	shrq	$32, %rax
	je	LBB0_5
## %bb.6:
	movq	%r13, %rax
	xorl	%edx, %edx
	divq	%rsi
	testq	%rdx, %rdx
	je	LBB0_8
	jmp	LBB0_9
LBB0_5:
	movl	%r13d, %eax
	xorl	%edx, %edx
	divl	%esi
                                        ## kill: def $edx killed $edx def $rdx
	testq	%rdx, %rdx
	jne	LBB0_9
LBB0_8:
	leaq	(%rbx,%r13), %rax
	cmpq	%rcx, %rax
	ja	LBB0_9
## %bb.10:
	testq	%rbx, %rbx
	je	LBB0_15
## %bb.11:
	addq	24(%r14), %r13
	.p2align	4, 0x90
LBB0_12:                                ## =>This Inner Loop Header: Depth=1
	movq	%r13, %rdi
	callq	_kvirt_to_pa
	movq	_PAGE_SHIFT@GOTPCREL(%rip), %rcx
	movzbl	(%rcx), %ecx
	shrq	%cl, %rax
	movq	_PAGE_SIZE@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movq	_PAGE_SHARED@GOTPCREL(%rip), %rdx
	movl	(%rdx), %r8d
	movq	%r15, %rdi
	movq	%r12, %rsi
	movq	%rax, %rdx
	callq	_remap_pfn_range
	testq	%rax, %rax
	jne	LBB0_13
## %bb.14:                              ##   in Loop: Header=BB0_12 Depth=1
	movq	_PAGE_SIZE@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	addq	%rax, %r12
	addq	%rax, %r13
	subq	%rax, %rbx
	movl	$0, %eax
	cmovbq	%rax, %rbx
	ja	LBB0_12
LBB0_15:
	movl	$1, 16(%r14)
	xorl	%eax, %eax
	jmp	LBB0_16
LBB0_13:
	movq	_EAGAIN@GOTPCREL(%rip), %rcx
	jmp	LBB0_2
	.cfi_endproc
                                        ## -- End function
	.comm	_PAGE_SHIFT,8,3                 ## @PAGE_SHIFT
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"mmap offset:%ld size:%ld\n"

	.comm	_ENODEV,4,2                     ## @ENODEV
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_PAGE_SIZE,8,3                  ## @PAGE_SIZE
	.comm	_PAGE_SHARED,4,2                ## @PAGE_SHARED
	.comm	_EAGAIN,4,2                     ## @EAGAIN
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_cpia2_remap_buffer             ; -- Begin function cpia2_remap_buffer
	.p2align	2
_cpia2_remap_buffer:                    ; @cpia2_remap_buffer
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	mov	x20, x1
	mov	x19, x0
	ldp	x21, x8, [x1]
	sub	x22, x8, x21
	ldr	x8, [x1, #16]
Lloh0:
	adrp	x24, _PAGE_SHIFT@GOTPAGE
Lloh1:
	ldr	x24, [x24, _PAGE_SHIFT@GOTPAGEOFF]
	ldr	x9, [x24]
	lsl	x23, x8, x9
Lloh2:
	adrp	x0, l_.str@PAGE
Lloh3:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x23
	mov	x2, x22
	bl	_DBG
	add	x0, x19, #32
	bl	_video_is_registered
	cbz	w0, LBB0_4
; %bb.1:
	ldp	x9, x8, [x19]
	mul	x8, x8, x9
	cmp	x22, x8
	b.hi	LBB0_3
; %bb.2:
	udiv	x10, x23, x9
	msub	x9, x10, x9, x23
	add	x10, x23, x22
	cmp	x9, #0
	ccmp	x10, x8, #2, eq
	b.ls	LBB0_7
LBB0_3:
Lloh4:
	adrp	x8, _EINVAL@GOTPAGE
Lloh5:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
	b	LBB0_5
LBB0_4:
Lloh6:
	adrp	x8, _ENODEV@GOTPAGE
Lloh7:
	ldr	x8, [x8, _ENODEV@GOTPAGEOFF]
LBB0_5:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_6:
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
LBB0_7:
	cbz	x22, LBB0_11
; %bb.8:
	ldr	x8, [x19, #24]
	add	x23, x8, x23
Lloh8:
	adrp	x25, _PAGE_SIZE@GOTPAGE
Lloh9:
	ldr	x25, [x25, _PAGE_SIZE@GOTPAGEOFF]
Lloh10:
	adrp	x26, _PAGE_SHARED@GOTPAGE
Lloh11:
	ldr	x26, [x26, _PAGE_SHARED@GOTPAGEOFF]
LBB0_9:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x23
	bl	_kvirt_to_pa
	ldr	x8, [x24]
	lsr	x2, x0, x8
	ldr	x3, [x25]
	ldr	w4, [x26]
	mov	x0, x20
	mov	x1, x21
	bl	_remap_pfn_range
	cbnz	x0, LBB0_12
; %bb.10:                               ;   in Loop: Header=BB0_9 Depth=1
	ldr	x8, [x25]
	add	x21, x8, x21
	add	x23, x8, x23
	subs	x8, x22, x8
	csel	x22, xzr, x8, lo
	b.hi	LBB0_9
LBB0_11:
	mov	w0, #0
	mov	w8, #1
	str	w8, [x19, #16]
	b	LBB0_6
LBB0_12:
Lloh12:
	adrp	x8, _EAGAIN@GOTPAGE
Lloh13:
	ldr	x8, [x8, _EAGAIN@GOTPAGEOFF]
	b	LBB0_5
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh12, Lloh13
	.cfi_endproc
                                        ; -- End function
	.comm	_PAGE_SHIFT,8,3                 ; @PAGE_SHIFT
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"mmap offset:%ld size:%ld\n"

	.comm	_ENODEV,4,2                     ; @ENODEV
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_PAGE_SIZE,8,3                  ; @PAGE_SIZE
	.comm	_PAGE_SHARED,4,2                ; @PAGE_SHARED
	.comm	_EAGAIN,4,2                     ; @EAGAIN
.subsections_via_symbols
