	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function r_io_def_mmap_write
_r_io_def_mmap_write:                   ## @r_io_def_mmap_write
	.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	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%ecx, %r14d
	movq	%rsi, %r15
	movq	%rdi, %rbx
	xorl	%edi, %edi
	testq	%rbx, %rbx
	je	LBB0_3
## %bb.1:
	testq	%r15, %r15
	je	LBB0_3
## %bb.2:
	cmpq	$0, 8(%r15)
	setne	%al
	testq	%rdx, %rdx
	setne	%cl
	andb	%al, %cl
	movzbl	%cl, %edi
LBB0_3:
	movq	%rdx, -72(%rbp)                 ## 8-byte Spill
	movl	$-1, %esi
	callq	_r_return_val_if_fail
	movl	(%rbx), %r13d
	movq	8(%r15), %r12
	cmpq	$0, 24(%r12)
	je	LBB0_13
## %bb.4:
	movslq	(%r15), %r15
	testq	%r15, %r15
	je	LBB0_23
## %bb.5:
	movl	%r13d, %eax
	cltd
	idivl	%r15d
	testl	%edx, %edx
	js	LBB0_31
## %bb.6:
	movl	%edx, -52(%rbp)                 ## 4-byte Spill
	movl	%r14d, %eax
	cltd
	idivl	%r15d
	movl	%r15d, %ebx
	subl	%edx, %ebx
	movq	%r14, -64(%rbp)                 ## 8-byte Spill
	addl	%r14d, %ebx
	leal	(%rbx,%r15), %r14d
	movl	%r14d, %edi
	callq	_malloc
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	testq	%rax, %rax
	je	LBB0_29
## %bb.7:
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	movl	$255, %esi
	movl	%r14d, %edx
	callq	_memset
	testl	%ebx, %ebx
	jle	LBB0_28
## %bb.8:
	subl	-52(%rbp), %r13d                ## 4-byte Folded Reload
	movl	%ebx, %eax
	movq	%rax, -80(%rbp)                 ## 8-byte Spill
	xorl	%ebx, %ebx
	movl	%r13d, %r14d
	.p2align	4, 0x90
LBB0_9:                                 ## =>This Inner Loop Header: Depth=1
	movl	16(%r12), %edi
	movq	_SEEK_SET@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movl	%r14d, %esi
	callq	_lseek
	movl	16(%r12), %edi
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	leaq	(%rax,%rbx), %rsi
	movl	%r15d, %edx
	callq	_read
	addq	%r15, %rbx
	addl	%r15d, %r14d
	cmpq	-80(%rbp), %rbx                 ## 8-byte Folded Reload
	jl	LBB0_9
## %bb.10:
	movslq	-52(%rbp), %rdi                 ## 4-byte Folded Reload
	addq	-48(%rbp), %rdi                 ## 8-byte Folded Reload
	movq	-72(%rbp), %rsi                 ## 8-byte Reload
	movq	-64(%rbp), %rdx                 ## 8-byte Reload
                                        ## kill: def $edx killed $edx killed $rdx
	callq	_memcpy
	xorl	%ebx, %ebx
	.p2align	4, 0x90
LBB0_11:                                ## =>This Inner Loop Header: Depth=1
	movl	16(%r12), %edi
	movq	_SEEK_SET@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movl	%r13d, %esi
	callq	_lseek
	movl	16(%r12), %edi
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	leaq	(%rax,%rbx), %rsi
	movl	%r15d, %edx
	callq	_write
	cmpl	%r15d, %eax
	jne	LBB0_30
## %bb.12:                              ##   in Loop: Header=BB0_11 Depth=1
	addq	%r15, %rbx
	addl	%r15d, %r13d
	cmpq	-80(%rbp), %rbx                 ## 8-byte Folded Reload
	jl	LBB0_11
	jmp	LBB0_29
LBB0_13:
	movq	%r14, -64(%rbp)                 ## 8-byte Spill
	movq	8(%r12), %rdi
	testq	%rdi, %rdi
	je	LBB0_18
## %bb.14:
	movq	_R_PERM_W@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%r12)
	je	LBB0_31
## %bb.15:
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	leal	(%rax,%r13), %r14d
	callq	_r_buf_size
	movl	%r14d, -48(%rbp)                ## 4-byte Spill
	cmpl	%eax, %r14d
	jg	LBB0_17
## %bb.16:
	movq	8(%r12), %rdi
	callq	_r_buf_size
	testl	%eax, %eax
	jne	LBB0_18
LBB0_17:
	movl	4(%r12), %edi
	movl	-48(%rbp), %esi                 ## 4-byte Reload
	callq	_r_file_truncate
LBB0_18:
	movl	4(%r12), %edi
	movl	(%rbx), %esi
	movq	-72(%rbp), %rdx                 ## 8-byte Reload
	movq	-64(%rbp), %rbx                 ## 8-byte Reload
	movl	%ebx, %ecx
	callq	_r_file_mmap_write
	cmpl	%ebx, %eax
	je	LBB0_21
## %bb.19:
	movl	4(%r15), %edi
	movl	%r13d, %esi
	xorl	%edx, %edx
	callq	_lseek
	testq	%rax, %rax
	js	LBB0_31
## %bb.20:
	movl	4(%r15), %edi
	movq	-72(%rbp), %rsi                 ## 8-byte Reload
	movl	%ebx, %edx
	callq	_write
	movl	%eax, %ebx
LBB0_21:
	movq	%r12, %rdi
	callq	_r_io_def_mmap_refresh_def_mmap_buf
	testl	%eax, %eax
	jne	LBB0_32
## %bb.22:
	leaq	L_.str(%rip), %rdi
	callq	_eprintf
	jmp	LBB0_32
LBB0_23:
	movl	16(%r12), %edi
	movl	%r13d, %esi
	xorl	%edx, %edx
	callq	_lseek
	testq	%rax, %rax
	js	LBB0_31
## %bb.24:
	movl	16(%r12), %edi
	movq	-72(%rbp), %rsi                 ## 8-byte Reload
	movl	%r14d, %edx
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_write                          ## TAILCALL
LBB0_31:
	movl	$-1, %ebx
	jmp	LBB0_32
LBB0_28:
	movl	-52(%rbp), %eax                 ## 4-byte Reload
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	addq	%rax, %rdi
	movq	-72(%rbp), %rsi                 ## 8-byte Reload
	movq	-64(%rbp), %rdx                 ## 8-byte Reload
                                        ## kill: def $edx killed $edx killed $rdx
	callq	_memcpy
LBB0_29:
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_free
	movq	-64(%rbp), %rbx                 ## 8-byte Reload
	jmp	LBB0_32
LBB0_30:
	movl	%eax, %r14d
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_free
	movl	%r14d, %ebx
LBB0_32:
	movl	%ebx, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_SEEK_SET,4,2                   ## @SEEK_SET
	.comm	_R_PERM_W,4,2                   ## @R_PERM_W
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"io_def_mmap: failed to refresh the def_mmap backed buffer.\n"

	.no_dead_strip	_r_io_def_mmap_write
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function r_io_def_mmap_write
_r_io_def_mmap_write:                   ; @r_io_def_mmap_write
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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
	mov	x19, x3
	mov	x21, x2
	mov	x22, x1
	mov	x23, x0
	mov	w0, #0
	cbz	x23, LBB0_3
; %bb.1:
	cbz	x22, LBB0_3
; %bb.2:
	ldr	x8, [x22, #8]
	cmp	x21, #0
	ccmp	x8, #0, #4, ne
	cset	w0, ne
LBB0_3:
	mov	w1, #-1
	bl	_r_return_val_if_fail
	ldr	w24, [x23]
	ldr	x20, [x22, #8]
	ldr	x8, [x20, #24]
	cbz	x8, LBB0_13
; %bb.4:
	ldrsw	x22, [x22]
	cbz	w22, LBB0_23
; %bb.5:
	sdiv	w8, w24, w22
	mul	w23, w8, w22
	subs	w27, w24, w23
	b.mi	LBB0_25
; %bb.6:
	sdiv	w8, w19, w22
	neg	w9, w19
	madd	w8, w8, w22, w9
	add	w8, w22, w8
	add	w26, w8, w19
	add	w25, w26, w22
	mov	x0, x25
	bl	_malloc
	mov	x24, x0
	cbz	x0, LBB0_27
; %bb.7:
	mov	x0, x24
	mov	w1, #255
	mov	x2, x25
	bl	_memset
	cmp	w26, #0
	b.le	LBB0_26
; %bb.8:
	str	w27, [sp, #12]                  ; 4-byte Folded Spill
	mov	x28, #0
Lloh0:
	adrp	x27, _SEEK_SET@GOTPAGE
Lloh1:
	ldr	x27, [x27, _SEEK_SET@GOTPAGEOFF]
	mov	x25, x23
LBB0_9:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w0, [x20, #16]
	ldr	w2, [x27]
	mov	x1, x25
	bl	_lseek
	ldr	w0, [x20, #16]
	add	x1, x24, x28
	mov	x2, x22
	bl	_read
	add	w25, w25, w22
	add	x28, x28, x22
	cmp	x28, x26
	b.lt	LBB0_9
; %bb.10:
	ldr	w8, [sp, #12]                   ; 4-byte Folded Reload
	add	x0, x24, w8, sxtw
	mov	x1, x21
	mov	x2, x19
	bl	_memcpy
	mov	x25, #0
LBB0_11:                                ; =>This Inner Loop Header: Depth=1
	ldr	w0, [x20, #16]
	ldr	w2, [x27]
	mov	x1, x23
	bl	_lseek
	ldr	w0, [x20, #16]
	add	x1, x24, x25
	mov	x2, x22
	bl	_write
	cmp	w0, w22
	b.ne	LBB0_28
; %bb.12:                               ;   in Loop: Header=BB0_11 Depth=1
	add	w23, w23, w22
	add	x25, x25, x22
	cmp	x25, x26
	b.lt	LBB0_11
	b	LBB0_27
LBB0_13:
	ldr	x0, [x20, #8]
	cbz	x0, LBB0_18
; %bb.14:
	ldr	w8, [x20]
Lloh2:
	adrp	x9, _R_PERM_W@GOTPAGE
Lloh3:
	ldr	x9, [x9, _R_PERM_W@GOTPAGEOFF]
Lloh4:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_25
; %bb.15:
	add	w25, w24, w19
	bl	_r_buf_size
	cmp	w25, w0
	b.gt	LBB0_17
; %bb.16:
	ldr	x0, [x20, #8]
	bl	_r_buf_size
	cbnz	w0, LBB0_18
LBB0_17:
	ldr	w0, [x20, #4]
	mov	x1, x25
	bl	_r_file_truncate
LBB0_18:
	ldr	w0, [x20, #4]
	ldr	w1, [x23]
	mov	x2, x21
	mov	x3, x19
	bl	_r_file_mmap_write
	cmp	w0, w19
	b.eq	LBB0_21
; %bb.19:
	ldr	w0, [x22, #4]
	mov	x1, x24
	mov	w2, #0
	bl	_lseek
	tbnz	x0, #63, LBB0_25
; %bb.20:
	ldr	w0, [x22, #4]
	mov	x1, x21
	mov	x2, x19
	bl	_write
	mov	x19, x0
LBB0_21:
	mov	x0, x20
	bl	_r_io_def_mmap_refresh_def_mmap_buf
	cbnz	w0, LBB0_29
; %bb.22:
Lloh5:
	adrp	x0, l_.str@PAGE
Lloh6:
	add	x0, x0, l_.str@PAGEOFF
	bl	_eprintf
	b	LBB0_29
LBB0_23:
	ldr	w0, [x20, #16]
	mov	x1, x24
	mov	w2, #0
	bl	_lseek
	tbnz	x0, #63, LBB0_25
; %bb.24:
	ldr	w0, [x20, #16]
	mov	x1, x21
	mov	x2, x19
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	b	_write
LBB0_25:
	mov	w19, #-1
	b	LBB0_29
LBB0_26:
	add	x0, x24, w27, uxtw
	mov	x1, x21
	mov	x2, x19
	bl	_memcpy
LBB0_27:
	mov	x0, x24
	bl	_free
	b	LBB0_29
LBB0_28:
	mov	x21, x0
	mov	x0, x24
	bl	_free
	mov	x19, x21
LBB0_29:
	mov	x0, x19
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpAdd	Lloh5, Lloh6
	.cfi_endproc
                                        ; -- End function
	.comm	_SEEK_SET,4,2                   ; @SEEK_SET
	.comm	_R_PERM_W,4,2                   ; @R_PERM_W
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"io_def_mmap: failed to refresh the def_mmap backed buffer.\n"

	.no_dead_strip	_r_io_def_mmap_write
.subsections_via_symbols
