	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_write_out_image                ## -- Begin function write_out_image
	.p2align	4, 0x90
_write_out_image:                       ## @write_out_image
	.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	$72, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r13
	leaq	-112(%rbp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	movl	$40, %edx
	callq	_memset
	movq	_board@GOTPCREL(%rip), %r14
	movq	(%r14), %rax
	movl	24(%rax), %ecx
	movl	%ecx, -80(%rbp)
	movq	_OBJECT_TYPE_BOOTEXT@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movl	%ecx, -84(%rbp)
	movq	_ROMBIN_FLAG_OCSUM@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movl	%ecx, -88(%rbp)
	movq	(%rax), %r15
	movq	%r13, %rdi
	movq	%rbx, %rsi
	callq	_write_out_header
	testl	%eax, %eax
	jne	LBB0_21
## %bb.1:
	leaq	-48(%rbp), %rbx
	movq	%rbx, %rdi
	callq	_csum_init
	movq	_bootext_block@GOTPCREL(%rip), %r12
	movq	(%r12), %rsi
	movq	%r13, %rdi
	movq	%rbx, %rdx
	callq	_write_out_block
	testl	%eax, %eax
	jne	LBB0_21
## %bb.2:
	movq	(%r12), %rax
	movq	(%rax), %rcx
	leaq	(%r15,%rcx), %rbx
	addq	$40, %rbx
	movq	(%r14), %rcx
	movq	8(%rcx), %rdx
	addq	(%rcx), %rdx
	cmpq	%rdx, %rbx
	jle	LBB0_4
## %bb.3:
	movl	20(%rax), %esi
	leaq	L_.str(%rip), %rdi
	callq	_ERR
	movl	$-1, %eax
	jmp	LBB0_21
LBB0_4:
	movq	_MMAP_ALIGN@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	callq	_ALIGN
	movq	%rax, %r15
	movq	%rax, %rsi
	subq	%rbx, %rsi
	leaq	-48(%rbp), %rcx
	movq	%r13, %rdi
	movl	$255, %edx
	callq	_write_out_padding
	testl	%eax, %eax
	jne	LBB0_21
## %bb.5:
	movq	(%r14), %rax
	movq	16(%rax), %rax
	addq	%r15, %rax
	movq	%rax, -64(%rbp)
	leaq	-64(%rbp), %rsi
	leaq	-48(%rbp), %rdx
	movq	%r13, %rdi
	callq	_write_out_mmap
	testl	%eax, %eax
	je	LBB0_6
LBB0_21:
	addq	$72, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_6:
	movq	_MMAP_DATA_SIZE@GOTPCREL(%rip), %rax
	addq	(%rax), %r15
	movq	(%r14), %rcx
	movq	(%rcx), %rax
	movq	8(%rcx), %r12
	movq	%r15, %rcx
	subq	%rax, %rcx
	cmpq	%r12, %rcx
	jge	LBB0_7
## %bb.8:
	addq	%rax, %r12
	movq	%r12, %rsi
	subq	%r15, %rsi
	leaq	-48(%rbp), %rcx
	movq	%r13, %rdi
	movl	$255, %edx
	callq	_write_out_padding
	testl	%eax, %eax
	jne	LBB0_21
## %bb.9:
	leaq	L_.str.1(%rip), %rsi
	movl	$2, %edi
	movq	%r12, %rdx
	xorl	%eax, %eax
	callq	_DBG
	jmp	LBB0_10
LBB0_7:
	movq	%r15, %r12
LBB0_10:
	movq	_num_blocks@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jle	LBB0_17
## %bb.11:
	xorl	%ebx, %ebx
	movq	_blocks@GOTPCREL(%rip), %rdx
	movq	_BLOCK_TYPE_BOOTEXT@GOTPCREL(%rip), %rsi
	leaq	-48(%rbp), %r14
	xorl	%r15d, %r15d
	jmp	LBB0_12
LBB0_16:                                ##   in Loop: Header=BB0_12 Depth=1
	incq	%r15
	movslq	%eax, %rcx
	addq	$24, %rbx
	cmpq	%rcx, %r15
	jge	LBB0_17
LBB0_12:                                ## =>This Inner Loop Header: Depth=1
	movq	(%rdx), %rdi
	movq	8(%rdi,%rbx), %rcx
	cmpq	(%rsi), %rcx
	je	LBB0_16
## %bb.13:                              ##   in Loop: Header=BB0_12 Depth=1
	movq	%rdi, -56(%rbp)                 ## 8-byte Spill
	movl	16(%rdi,%rbx), %esi
	movq	%r12, %rdi
	callq	_ALIGN
	movq	%r12, %rcx
	movq	%rax, %r12
	movq	%rax, %rsi
	subq	%rcx, %rsi
	movq	%r13, %rdi
	movl	$255, %edx
	movq	%r14, %rcx
	callq	_write_out_padding
	testl	%eax, %eax
	jne	LBB0_21
## %bb.14:                              ##   in Loop: Header=BB0_12 Depth=1
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	leaq	(%rax,%rbx), %rsi
	movq	%r13, %rdi
	movq	%r14, %rdx
	callq	_write_out_block
	testl	%eax, %eax
	jne	LBB0_21
## %bb.15:                              ##   in Loop: Header=BB0_12 Depth=1
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	addq	(%rax,%rbx), %r12
	movq	_num_blocks@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movq	_blocks@GOTPCREL(%rip), %rdx
	movq	_BLOCK_TYPE_BOOTEXT@GOTPCREL(%rip), %rsi
	leaq	-48(%rbp), %r14
	jmp	LBB0_16
LBB0_17:
	movq	%r12, %rdi
	movl	$4, %esi
	callq	_ALIGN
	subq	%r12, %rax
	leaq	-48(%rbp), %rcx
	movq	%r13, %rdi
	movq	%rax, %rsi
	movl	$255, %edx
	callq	_write_out_padding
	testl	%eax, %eax
	jne	LBB0_21
## %bb.18:
	leaq	-48(%rbp), %rdi
	callq	_csum_get
	movq	%rax, %r14
	movq	-64(%rbp), %rax
	movq	%rax, -96(%rbp)
	movl	$2, -112(%rbp)
	leaq	-104(%rbp), %rdi
	callq	_read_magic
	testl	%eax, %eax
	jne	LBB0_21
## %bb.19:
	movq	-104(%rbp), %rdi
	callq	_BE16_TO_HOST
	movq	%rax, -104(%rbp)
	movq	%r14, %rcx
	negq	%rcx
	cmpq	%r14, %rax
	movq	%r14, %rbx
	notq	%rbx
	cmovgeq	%rcx, %rbx
	addq	%rax, %rbx
	leaq	L_.str.2(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	movq	%r14, %rcx
	movq	%rbx, %r8
	xorl	%eax, %eax
	callq	_DBG
	movq	%rbx, %rdi
	callq	_HOST_TO_BE16
	movq	%rax, -72(%rbp)
	leaq	-72(%rbp), %rsi
	movq	%r13, %rdi
	movl	$2, %edx
	xorl	%ecx, %ecx
	callq	_write_out_data
	testl	%eax, %eax
	jne	LBB0_21
## %bb.20:
	leaq	-112(%rbp), %rsi
	movq	%r13, %rdi
	callq	_write_out_header
	jmp	LBB0_21
	.cfi_endproc
                                        ## -- End function
	.comm	_board,8,3                      ## @board
	.comm	_OBJECT_TYPE_BOOTEXT,4,2        ## @OBJECT_TYPE_BOOTEXT
	.comm	_ROMBIN_FLAG_OCSUM,4,2          ## @ROMBIN_FLAG_OCSUM
	.comm	_bootext_block,8,3              ## @bootext_block
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"bootext file '%s' is too big"

	.comm	_MMAP_ALIGN,4,2                 ## @MMAP_ALIGN
	.comm	_MMAP_DATA_SIZE,8,3             ## @MMAP_DATA_SIZE
L_.str.1:                               ## @.str.1
	.asciz	"bootext end at %08x"

	.comm	_num_blocks,4,2                 ## @num_blocks
	.comm	_blocks,8,3                     ## @blocks
	.comm	_BLOCK_TYPE_BOOTEXT,8,3         ## @BLOCK_TYPE_BOOTEXT
L_.str.2:                               ## @.str.2
	.asciz	"ocsum=%04x, csum=%04x, fix=%04x"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_write_out_image                ; -- Begin function write_out_image
	.p2align	2
_write_out_image:                       ; @write_out_image
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #176
	.cfi_def_cfa_offset 176
	stp	x28, x27, [sp, #80]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #96]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #112]            ; 16-byte Folded Spill
	stp	x22, x21, [sp, #128]            ; 16-byte Folded Spill
	stp	x20, x19, [sp, #144]            ; 16-byte Folded Spill
	stp	x29, x30, [sp, #160]            ; 16-byte Folded Spill
	add	x29, sp, #160
	.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, x0
	add	x0, sp, #32
	mov	w1, #0
	mov	w2, #40
	bl	_memset
Lloh0:
	adrp	x22, _board@GOTPAGE
Lloh1:
	ldr	x22, [x22, _board@GOTPAGEOFF]
	ldr	x8, [x22]
	ldr	w9, [x8, #24]
	str	w9, [sp, #64]
Lloh2:
	adrp	x9, _OBJECT_TYPE_BOOTEXT@GOTPAGE
Lloh3:
	ldr	x9, [x9, _OBJECT_TYPE_BOOTEXT@GOTPAGEOFF]
Lloh4:
	ldr	w9, [x9]
Lloh5:
	adrp	x10, _ROMBIN_FLAG_OCSUM@GOTPAGE
Lloh6:
	ldr	x10, [x10, _ROMBIN_FLAG_OCSUM@GOTPAGEOFF]
Lloh7:
	ldr	w10, [x10]
	stp	w10, w9, [sp, #56]
	ldr	x20, [x8]
	add	x1, sp, #32
	mov	x0, x19
	bl	_write_out_header
	cbnz	w0, LBB0_6
; %bb.1:
	add	x0, sp, #24
	bl	_csum_init
Lloh8:
	adrp	x21, _bootext_block@GOTPAGE
Lloh9:
	ldr	x21, [x21, _bootext_block@GOTPAGEOFF]
	ldr	x1, [x21]
	add	x2, sp, #24
	mov	x0, x19
	bl	_write_out_block
	cbnz	w0, LBB0_6
; %bb.2:
	ldr	x8, [x21]
	ldr	x9, [x8]
	add	x9, x20, x9
	add	x21, x9, #40
	ldr	x9, [x22]
	ldp	x10, x9, [x9]
	add	x9, x9, x10
	cmp	x21, x9
	b.le	LBB0_4
; %bb.3:
	ldr	w1, [x8, #20]
Lloh10:
	adrp	x0, l_.str@PAGE
Lloh11:
	add	x0, x0, l_.str@PAGEOFF
	bl	_ERR
	mov	w0, #-1
	b	LBB0_6
LBB0_4:
Lloh12:
	adrp	x8, _MMAP_ALIGN@GOTPAGE
Lloh13:
	ldr	x8, [x8, _MMAP_ALIGN@GOTPAGEOFF]
Lloh14:
	ldr	w1, [x8]
	mov	x0, x21
	bl	_ALIGN
	mov	x20, x0
	sub	x1, x0, x21
	add	x3, sp, #24
	mov	x0, x19
	mov	w2, #255
	bl	_write_out_padding
	cbnz	w0, LBB0_6
; %bb.5:
	ldr	x8, [x22]
	ldr	x8, [x8, #16]
	add	x8, x8, x20
	str	x8, [sp, #72]
	add	x1, sp, #72
	add	x2, sp, #24
	mov	x0, x19
	bl	_write_out_mmap
	cbz	w0, LBB0_7
LBB0_6:
	ldp	x29, x30, [sp, #160]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #144]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #128]            ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #112]            ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #96]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #80]             ; 16-byte Folded Reload
	add	sp, sp, #176
	ret
LBB0_7:
Lloh15:
	adrp	x8, _MMAP_DATA_SIZE@GOTPAGE
Lloh16:
	ldr	x8, [x8, _MMAP_DATA_SIZE@GOTPAGEOFF]
Lloh17:
	ldr	x10, [x8]
	ldr	x9, [x22]
	ldp	x8, x9, [x9]
	add	x20, x10, x20
	sub	x10, x20, x8
	cmp	x10, x9
	b.ge	LBB0_10
; %bb.8:
	add	x21, x9, x8
	sub	x1, x21, x20
	add	x3, sp, #24
	mov	x0, x19
	mov	w2, #255
	bl	_write_out_padding
	cbnz	w0, LBB0_6
; %bb.9:
Lloh18:
	adrp	x1, l_.str.1@PAGE
Lloh19:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	w0, #2
	mov	x2, x21
	bl	_DBG
	mov	x20, x21
LBB0_10:
Lloh20:
	adrp	x23, _num_blocks@GOTPAGE
Lloh21:
	ldr	x23, [x23, _num_blocks@GOTPAGEOFF]
	ldr	w8, [x23]
	cmp	w8, #1
	b.lt	LBB0_17
; %bb.11:
	mov	x24, #0
	mov	x25, #0
Lloh22:
	adrp	x26, _blocks@GOTPAGE
Lloh23:
	ldr	x26, [x26, _blocks@GOTPAGEOFF]
Lloh24:
	adrp	x27, _BLOCK_TYPE_BOOTEXT@GOTPAGE
Lloh25:
	ldr	x27, [x27, _BLOCK_TYPE_BOOTEXT@GOTPAGEOFF]
	b	LBB0_13
LBB0_12:                                ;   in Loop: Header=BB0_13 Depth=1
	add	x25, x25, #1
	add	x24, x24, #24
	cmp	x25, w8, sxtw
	b.ge	LBB0_17
LBB0_13:                                ; =>This Inner Loop Header: Depth=1
	ldr	x28, [x26]
	add	x21, x28, x24
	ldr	x9, [x21, #8]
	ldr	x10, [x27]
	cmp	x9, x10
	b.eq	LBB0_12
; %bb.14:                               ;   in Loop: Header=BB0_13 Depth=1
	ldr	w1, [x21, #16]
	mov	x0, x20
	bl	_ALIGN
	mov	x22, x0
	sub	x1, x0, x20
	add	x3, sp, #24
	mov	x0, x19
	mov	w2, #255
	bl	_write_out_padding
	cbnz	w0, LBB0_6
; %bb.15:                               ;   in Loop: Header=BB0_13 Depth=1
	add	x2, sp, #24
	mov	x0, x19
	mov	x1, x21
	bl	_write_out_block
	cbnz	w0, LBB0_6
; %bb.16:                               ;   in Loop: Header=BB0_13 Depth=1
	ldr	x8, [x28, x24]
	add	x20, x8, x22
	ldr	w8, [x23]
	b	LBB0_12
LBB0_17:
	mov	x0, x20
	mov	w1, #4
	bl	_ALIGN
	sub	x1, x0, x20
	add	x3, sp, #24
	mov	x0, x19
	mov	w2, #255
	bl	_write_out_padding
	cbnz	w0, LBB0_6
; %bb.18:
	add	x0, sp, #24
	bl	_csum_get
	mov	x20, x0
	ldr	x8, [sp, #72]
	str	x8, [sp, #48]
	mov	w8, #2
	str	w8, [sp, #32]
	add	x8, sp, #32
	add	x0, x8, #8
	bl	_read_magic
	cbnz	w0, LBB0_6
; %bb.19:
	ldr	x0, [sp, #40]
	bl	_BE16_TO_HOST
	mov	x2, x0
	str	x0, [sp, #40]
	neg	x8, x20
	cmp	x0, x20
	csinv	x8, x8, x20, ge
	add	x21, x8, x0
	stp	x20, x21, [sp]
Lloh26:
	adrp	x1, l_.str.2@PAGE
Lloh27:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	w0, #2
	bl	_DBG
	mov	x0, x21
	bl	_HOST_TO_BE16
	str	x0, [sp, #16]
	add	x1, sp, #16
	mov	x0, x19
	mov	w2, #2
	mov	x3, #0
	bl	_write_out_data
	cbnz	w0, LBB0_6
; %bb.20:
	add	x1, sp, #32
	mov	x0, x19
	bl	_write_out_header
	b	LBB0_6
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpAdd	Lloh18, Lloh19
	.loh AdrpLdrGot	Lloh20, Lloh21
	.loh AdrpLdrGot	Lloh24, Lloh25
	.loh AdrpLdrGot	Lloh22, Lloh23
	.loh AdrpAdd	Lloh26, Lloh27
	.cfi_endproc
                                        ; -- End function
	.comm	_board,8,3                      ; @board
	.comm	_OBJECT_TYPE_BOOTEXT,4,2        ; @OBJECT_TYPE_BOOTEXT
	.comm	_ROMBIN_FLAG_OCSUM,4,2          ; @ROMBIN_FLAG_OCSUM
	.comm	_bootext_block,8,3              ; @bootext_block
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"bootext file '%s' is too big"

	.comm	_MMAP_ALIGN,4,2                 ; @MMAP_ALIGN
	.comm	_MMAP_DATA_SIZE,8,3             ; @MMAP_DATA_SIZE
l_.str.1:                               ; @.str.1
	.asciz	"bootext end at %08x"

	.comm	_num_blocks,4,2                 ; @num_blocks
	.comm	_blocks,8,3                     ; @blocks
	.comm	_BLOCK_TYPE_BOOTEXT,8,3         ; @BLOCK_TYPE_BOOTEXT
l_.str.2:                               ; @.str.2
	.asciz	"ocsum=%04x, csum=%04x, fix=%04x"

.subsections_via_symbols
