	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_image_write                    ## -- Begin function image_write
	.p2align	4, 0x90
_image_write:                           ## @image_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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	xorl	%eax, %eax
	testq	%rdx, %rdx
	jle	LBB0_15
## %bb.1:
	movq	%rdx, %r15
	movq	%rsi, %rbx
	movl	%edi, %r12d
	incq	%r15
	movq	_secsz@GOTPCREL(%rip), %r14
	jmp	LBB0_4
	.p2align	4, 0x90
LBB0_2:                                 ##   in Loop: Header=BB0_4 Depth=1
	xorl	%edi, %edi
	movq	_CH_TYPE_MEMORY@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	sete	%dil
	callq	_assert
	movl	8(%r13), %edi
	movl	(%r14), %edx
	movq	%rbx, %rsi
	callq	_memcpy
LBB0_3:                                 ##   in Loop: Header=BB0_4 Depth=1
	incl	%r12d
	movslq	(%r14), %rax
	addq	%rax, %rbx
	decq	%r15
	cmpq	$1, %r15
	jle	LBB0_10
LBB0_4:                                 ## =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	callq	_is_empty_sector
	testl	%eax, %eax
	jne	LBB0_3
## %bb.5:                               ##   in Loop: Header=BB0_4 Depth=1
	movl	%r12d, %edi
	callq	_image_chunk_find
	testq	%rax, %rax
	je	LBB0_11
## %bb.6:                               ##   in Loop: Header=BB0_4 Depth=1
	movq	%rax, %r13
	movq	(%rax), %rax
	movq	_CH_TYPE_FILE@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	je	LBB0_12
## %bb.7:                               ##   in Loop: Header=BB0_4 Depth=1
	movq	_CH_TYPE_ZEROES@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_2
## %bb.8:                               ##   in Loop: Header=BB0_4 Depth=1
	movq	%r13, %rdi
	movl	%r12d, %esi
	callq	_image_chunk_memory
	testq	%rax, %rax
	je	LBB0_13
## %bb.9:                               ##   in Loop: Header=BB0_4 Depth=1
	movq	%rax, %r13
	movq	(%rax), %rax
	jmp	LBB0_2
LBB0_10:
	xorl	%eax, %eax
	jmp	LBB0_15
LBB0_11:
	movq	_ENXIO@GOTPCREL(%rip), %rax
	jmp	LBB0_14
LBB0_12:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	jmp	LBB0_14
LBB0_13:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
LBB0_14:
	movl	(%rax), %eax
LBB0_15:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_ENXIO,4,2                      ## @ENXIO
	.comm	_CH_TYPE_FILE,8,3               ## @CH_TYPE_FILE
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_CH_TYPE_ZEROES,8,3             ## @CH_TYPE_ZEROES
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_CH_TYPE_MEMORY,8,3             ## @CH_TYPE_MEMORY
	.comm	_secsz,4,2                      ## @secsz
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_image_write                    ; -- Begin function image_write
	.p2align	2
_image_write:                           ; @image_write
	.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
	cmp	x2, #1
	b.lt	LBB0_10
; %bb.1:
	mov	x19, x1
	mov	x20, x0
	add	x22, x2, #1
Lloh0:
	adrp	x23, _CH_TYPE_FILE@GOTPAGE
Lloh1:
	ldr	x23, [x23, _CH_TYPE_FILE@GOTPAGEOFF]
Lloh2:
	adrp	x24, _CH_TYPE_ZEROES@GOTPAGE
Lloh3:
	ldr	x24, [x24, _CH_TYPE_ZEROES@GOTPAGEOFF]
Lloh4:
	adrp	x25, _CH_TYPE_MEMORY@GOTPAGE
Lloh5:
	ldr	x25, [x25, _CH_TYPE_MEMORY@GOTPAGEOFF]
Lloh6:
	adrp	x26, _secsz@GOTPAGE
Lloh7:
	ldr	x26, [x26, _secsz@GOTPAGEOFF]
	b	LBB0_4
LBB0_2:                                 ;   in Loop: Header=BB0_4 Depth=1
	ldr	x9, [x25]
	cmp	x8, x9
	cset	w0, eq
	bl	_assert
	ldr	w0, [x21, #8]
	ldr	w2, [x26]
	mov	x1, x19
	bl	_memcpy
LBB0_3:                                 ;   in Loop: Header=BB0_4 Depth=1
	add	w20, w20, #1
	ldrsw	x8, [x26]
	add	x19, x19, x8
	sub	x22, x22, #1
	cmp	x22, #1
	b.le	LBB0_10
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x19
	bl	_is_empty_sector
	cbnz	w0, LBB0_3
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	mov	x0, x20
	bl	_image_chunk_find
	cbz	x0, LBB0_12
; %bb.6:                                ;   in Loop: Header=BB0_4 Depth=1
	mov	x21, x0
	ldr	x8, [x0]
	ldr	x9, [x23]
	cmp	x8, x9
	b.eq	LBB0_13
; %bb.7:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	x9, [x24]
	cmp	x8, x9
	b.ne	LBB0_2
; %bb.8:                                ;   in Loop: Header=BB0_4 Depth=1
	mov	x0, x21
	mov	x1, x20
	bl	_image_chunk_memory
	cbz	x0, LBB0_14
; %bb.9:                                ;   in Loop: Header=BB0_4 Depth=1
	mov	x21, x0
	ldr	x8, [x0]
	b	LBB0_2
LBB0_10:
	mov	w0, #0
LBB0_11:
	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_12:
Lloh8:
	adrp	x8, _ENXIO@GOTPAGE
Lloh9:
	ldr	x8, [x8, _ENXIO@GOTPAGEOFF]
Lloh10:
	ldr	w0, [x8]
	b	LBB0_11
LBB0_13:
Lloh11:
	adrp	x8, _EINVAL@GOTPAGE
Lloh12:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh13:
	ldr	w0, [x8]
	b	LBB0_11
LBB0_14:
Lloh14:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh15:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh16:
	ldr	w0, [x8]
	b	LBB0_11
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.cfi_endproc
                                        ; -- End function
	.comm	_ENXIO,4,2                      ; @ENXIO
	.comm	_CH_TYPE_FILE,8,3               ; @CH_TYPE_FILE
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_CH_TYPE_ZEROES,8,3             ; @CH_TYPE_ZEROES
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_CH_TYPE_MEMORY,8,3             ; @CH_TYPE_MEMORY
	.comm	_secsz,4,2                      ; @secsz
.subsections_via_symbols
