	.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
	subq	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	16(%rsi), %r13
	movq	_PAGE_SHIFT@GOTPCREL(%rip), %rax
	movb	(%rax), %cl
	shlq	%cl, %r13
	testq	%rdi, %rdi
	je	LBB0_1
## %bb.3:
	movq	%rsi, %r14
	movq	%rdi, %rbx
	movq	(%rsi), %r12
	movq	8(%rsi), %r15
	subq	%r12, %r15
	leaq	L_.str(%rip), %rdi
	movq	%r13, %rsi
	movq	%r15, %rdx
	callq	_DBG
	movq	%r14, -56(%rbp)                 ## 8-byte Spill
	leaq	20(%rbx), %r14
	movq	%r14, %rdi
	callq	_mutex_lock_interruptible
	testq	%rax, %rax
	je	LBB0_5
## %bb.4:
	movq	_ERESTARTSYS@GOTPCREL(%rip), %rcx
	jmp	LBB0_2
LBB0_5:
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movq	%r14, -48(%rbp)                 ## 8-byte Spill
	cmpl	$0, 32(%rbx)
	je	LBB0_6
## %bb.7:
	movq	(%rbx), %rsi
	movq	8(%rbx), %rcx
	imulq	%rsi, %rcx
	cmpq	%rcx, %r15
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	jbe	LBB0_8
LBB0_13:
	callq	_mutex_unlock
	movq	_EINVAL@GOTPCREL(%rip), %rcx
	jmp	LBB0_2
LBB0_6:
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_mutex_unlock
LBB0_1:
	movq	_ENODEV@GOTPCREL(%rip), %rcx
LBB0_2:
	xorl	%eax, %eax
	subl	(%rcx), %eax
LBB0_20:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_8:
	movq	%rax, %r14
	movq	%r13, %rax
	orq	%rsi, %rax
	shrq	$32, %rax
	je	LBB0_9
## %bb.10:
	movq	%r13, %rax
	xorl	%edx, %edx
	divq	%rsi
	testq	%rdx, %rdx
	je	LBB0_12
	jmp	LBB0_13
LBB0_9:
	movl	%r13d, %eax
	xorl	%edx, %edx
	divl	%esi
                                        ## kill: def $edx killed $edx def $rdx
	testq	%rdx, %rdx
	jne	LBB0_13
LBB0_12:
	leaq	(%r15,%r13), %rax
	cmpq	%rcx, %rax
	ja	LBB0_13
## %bb.14:
	testq	%r15, %r15
	je	LBB0_19
## %bb.15:
	addq	24(%rbx), %r13
	.p2align	4, 0x90
LBB0_16:                                ## =>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	%r14, %rdi
	movq	%r12, %rsi
	movq	%rax, %rdx
	callq	_remap_pfn_range
	testq	%rax, %rax
	jne	LBB0_17
## %bb.18:                              ##   in Loop: Header=BB0_16 Depth=1
	movq	_PAGE_SIZE@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	addq	%rax, %r12
	addq	%rax, %r13
	subq	%rax, %r15
	movl	$0, %eax
	cmovbq	%rax, %r15
	ja	LBB0_16
LBB0_19:
	movl	$1, 16(%rbx)
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_mutex_unlock
	xorl	%eax, %eax
	jmp	LBB0_20
LBB0_17:
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_mutex_unlock
	movq	_EAGAIN@GOTPCREL(%rip), %rcx
	jmp	LBB0_2
	.cfi_endproc
                                        ## -- End function
	.comm	_PAGE_SHIFT,8,3                 ## @PAGE_SHIFT
	.comm	_ENODEV,4,2                     ## @ENODEV
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"mmap offset:%ld size:%ld\n"

	.comm	_ERESTARTSYS,4,2                ## @ERESTARTSYS
	.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	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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
	cbz	x0, LBB0_8
; %bb.1:
	mov	x20, x1
	mov	x19, x0
	ldp	x21, x8, [x1]
	sub	x22, x8, x21
	ldr	x8, [x1, #16]
Lloh0:
	adrp	x25, _PAGE_SHIFT@GOTPAGE
Lloh1:
	ldr	x25, [x25, _PAGE_SHIFT@GOTPAGEOFF]
	ldr	x9, [x25]
	lsl	x24, x8, x9
Lloh2:
	adrp	x0, l_.str@PAGE
Lloh3:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x24
	mov	x2, x22
	bl	_DBG
	add	x23, x19, #20
	mov	x0, x23
	bl	_mutex_lock_interruptible
	cbz	x0, LBB0_3
; %bb.2:
Lloh4:
	adrp	x8, _ERESTARTSYS@GOTPAGE
Lloh5:
	ldr	x8, [x8, _ERESTARTSYS@GOTPAGEOFF]
	b	LBB0_9
LBB0_3:
	ldr	w8, [x19, #32]
	cbz	w8, LBB0_7
; %bb.4:
	ldp	x9, x8, [x19]
	mul	x8, x8, x9
	cmp	x22, x8
	b.hi	LBB0_6
; %bb.5:
	udiv	x10, x24, x9
	msub	x9, x10, x9, x24
	add	x10, x24, x22
	cmp	x9, #0
	ccmp	x10, x8, #2, eq
	b.ls	LBB0_11
LBB0_6:
	mov	x0, x23
	bl	_mutex_unlock
Lloh6:
	adrp	x8, _EINVAL@GOTPAGE
Lloh7:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
	b	LBB0_9
LBB0_7:
	mov	x0, x23
	bl	_mutex_unlock
LBB0_8:
Lloh8:
	adrp	x8, _ENODEV@GOTPAGE
Lloh9:
	ldr	x8, [x8, _ENODEV@GOTPAGEOFF]
LBB0_9:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_10:
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
LBB0_11:
	cbz	x22, LBB0_15
; %bb.12:
	ldr	x8, [x19, #24]
	add	x24, x8, x24
Lloh10:
	adrp	x26, _PAGE_SIZE@GOTPAGE
Lloh11:
	ldr	x26, [x26, _PAGE_SIZE@GOTPAGEOFF]
Lloh12:
	adrp	x27, _PAGE_SHARED@GOTPAGE
Lloh13:
	ldr	x27, [x27, _PAGE_SHARED@GOTPAGEOFF]
LBB0_13:                                ; =>This Inner Loop Header: Depth=1
	mov	x0, x24
	bl	_kvirt_to_pa
	ldr	x8, [x25]
	lsr	x2, x0, x8
	ldr	x3, [x26]
	ldr	w4, [x27]
	mov	x0, x20
	mov	x1, x21
	bl	_remap_pfn_range
	cbnz	x0, LBB0_16
; %bb.14:                               ;   in Loop: Header=BB0_13 Depth=1
	ldr	x8, [x26]
	add	x21, x8, x21
	add	x24, x8, x24
	subs	x8, x22, x8
	csel	x22, xzr, x8, lo
	b.hi	LBB0_13
LBB0_15:
	mov	w8, #1
	str	w8, [x19, #16]
	mov	x0, x23
	bl	_mutex_unlock
	mov	w0, #0
	b	LBB0_10
LBB0_16:
	mov	x0, x23
	bl	_mutex_unlock
Lloh14:
	adrp	x8, _EAGAIN@GOTPAGE
Lloh15:
	ldr	x8, [x8, _EAGAIN@GOTPAGEOFF]
	b	LBB0_9
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh14, Lloh15
	.cfi_endproc
                                        ; -- End function
	.comm	_PAGE_SHIFT,8,3                 ; @PAGE_SHIFT
	.comm	_ENODEV,4,2                     ; @ENODEV
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"mmap offset:%ld size:%ld\n"

	.comm	_ERESTARTSYS,4,2                ; @ERESTARTSYS
	.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
