	.file	"extr_mkzynfw.c_write_out_image.c"
	.intel_syntax noprefix
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"bootext file '%s' is too big"
.LC1:
	.string	"bootext end at %08x"
	.section	.rodata.str1.8,"aMS",@progbits,1
	.align 8
.LC2:
	.string	"ocsum=%04x, csum=%04x, fix=%04x"
	.text
	.p2align 4
	.globl	write_out_image
	.type	write_out_image, @function
write_out_image:
.LFB0:
	.cfi_startproc
	endbr64
	push	r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xor	esi, esi
	mov	edx, 40
	push	r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	push	r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	push	r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	push	rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	mov	rbp, rdi
	push	rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	sub	rsp, 104
	.cfi_def_cfa_offset 160
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR 88[rsp], rax
	xor	eax, eax
	lea	r13, 48[rsp]
	mov	rdi, r13
	call	memset@PLT
	mov	rax, QWORD PTR board[rip]
	mov	rsi, r13
	mov	rdi, rbp
	mov	edx, DWORD PTR 24[rax]
	mov	rbx, QWORD PTR [rax]
	mov	DWORD PTR 80[rsp], edx
	mov	edx, DWORD PTR OBJECT_TYPE_BOOTEXT[rip]
	mov	DWORD PTR 76[rsp], edx
	mov	edx, DWORD PTR ROMBIN_FLAG_OCSUM[rip]
	mov	DWORD PTR 72[rsp], edx
	call	write_out_header@PLT
	test	eax, eax
	je	.L14
.L1:
	mov	rcx, QWORD PTR 88[rsp]
	xor	rcx, QWORD PTR fs:40
	jne	.L15
	add	rsp, 104
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	pop	rbx
	.cfi_def_cfa_offset 48
	pop	rbp
	.cfi_def_cfa_offset 40
	pop	r12
	.cfi_def_cfa_offset 32
	pop	r13
	.cfi_def_cfa_offset 24
	pop	r14
	.cfi_def_cfa_offset 16
	pop	r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L14:
	.cfi_restore_state
	lea	r12, 28[rsp]
	mov	rdi, r12
	call	csum_init@PLT
	mov	rsi, QWORD PTR bootext_block[rip]
	mov	rdx, r12
	mov	rdi, rbp
	call	write_out_block@PLT
	test	eax, eax
	jne	.L1
	mov	rcx, QWORD PTR bootext_block[rip]
	mov	rdx, QWORD PTR board[rip]
	mov	rax, QWORD PTR [rcx]
	lea	r14, 40[rbx+rax]
	mov	rax, QWORD PTR 8[rdx]
	add	rax, QWORD PTR [rdx]
	cmp	rax, r14
	jl	.L16
	mov	esi, DWORD PTR MMAP_ALIGN[rip]
	mov	rdi, r14
	call	ALIGN@PLT
	mov	rcx, r12
	mov	edx, 255
	mov	rdi, rbp
	mov	rsi, rax
	mov	rbx, rax
	sub	rsi, r14
	call	write_out_padding@PLT
	test	eax, eax
	jne	.L1
	mov	rax, QWORD PTR board[rip]
	lea	rsi, 32[rsp]
	mov	rdx, r12
	mov	rdi, rbp
	mov	rcx, QWORD PTR 16[rax]
	add	rcx, rbx
	mov	QWORD PTR 32[rsp], rcx
	call	write_out_mmap@PLT
	test	eax, eax
	jne	.L1
	mov	rax, QWORD PTR board[rip]
	add	rbx, QWORD PTR MMAP_DATA_SIZE[rip]
	mov	rcx, rbx
	mov	rdx, rbx
	mov	r14, QWORD PTR [rax]
	mov	rax, QWORD PTR 8[rax]
	sub	rcx, r14
	cmp	rcx, rax
	jl	.L17
.L4:
	mov	eax, DWORD PTR num_blocks[rip]
	test	eax, eax
	jle	.L5
	xor	r14d, r14d
	.p2align 4,,10
	.p2align 3
.L7:
	mov	rcx, QWORD PTR blocks[rip]
	lea	rax, [r14+r14*2]
	lea	r15, [rcx+rax*8]
	mov	rax, QWORD PTR BLOCK_TYPE_BOOTEXT[rip]
	cmp	QWORD PTR 8[r15], rax
	je	.L6
	mov	esi, DWORD PTR 16[r15]
	mov	rdi, rdx
	mov	QWORD PTR 8[rsp], rdx
	call	ALIGN@PLT
	mov	rdx, QWORD PTR 8[rsp]
	mov	rcx, r12
	mov	rdi, rbp
	mov	rsi, rax
	mov	rbx, rax
	sub	rsi, rdx
	mov	edx, 255
	call	write_out_padding@PLT
	test	eax, eax
	jne	.L1
	mov	rdx, r12
	mov	rsi, r15
	mov	rdi, rbp
	call	write_out_block@PLT
	test	eax, eax
	jne	.L1
	add	rbx, QWORD PTR [r15]
	mov	rdx, rbx
.L6:
	add	r14, 1
	cmp	DWORD PTR num_blocks[rip], r14d
	jg	.L7
.L5:
	mov	rdi, rdx
	mov	esi, 4
	mov	QWORD PTR 8[rsp], rdx
	call	ALIGN@PLT
	mov	rdx, QWORD PTR 8[rsp]
	mov	rcx, r12
	mov	rdi, rbp
	sub	rax, rdx
	mov	edx, 255
	mov	rsi, rax
	call	write_out_padding@PLT
	test	eax, eax
	jne	.L1
	mov	rdi, r12
	call	csum_get@PLT
	lea	rdi, 56[rsp]
	mov	DWORD PTR 48[rsp], 2
	mov	r12, rax
	mov	rax, QWORD PTR 32[rsp]
	mov	QWORD PTR 64[rsp], rax
	call	read_magic@PLT
	test	eax, eax
	jne	.L1
	mov	rdi, QWORD PTR 56[rsp]
	call	BE16_TO_HOST@PLT
	mov	rcx, r12
	mov	edi, 2
	lea	rsi, .LC2[rip]
	mov	rdx, rax
	mov	QWORD PTR 56[rsp], rax
	sub	rax, r12
	lea	r8, -1[rax]
	cmp	rdx, r12
	cmovge	r8, rax
	xor	eax, eax
	mov	QWORD PTR 40[rsp], r8
	call	DBG@PLT
	mov	rdi, QWORD PTR 40[rsp]
	call	HOST_TO_BE16@PLT
	xor	ecx, ecx
	lea	rsi, 40[rsp]
	mov	rdi, rbp
	mov	edx, 2
	mov	QWORD PTR 40[rsp], rax
	call	write_out_data@PLT
	test	eax, eax
	jne	.L1
	mov	rsi, r13
	mov	rdi, rbp
	call	write_out_header@PLT
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L17:
	add	r14, rax
	mov	rcx, r12
	mov	edx, 255
	mov	rdi, rbp
	mov	rsi, r14
	sub	rsi, rbx
	call	write_out_padding@PLT
	test	eax, eax
	jne	.L1
	mov	rdx, r14
	lea	rsi, .LC1[rip]
	mov	edi, 2
	call	DBG@PLT
	mov	rdx, r14
	jmp	.L4
.L16:
	mov	esi, DWORD PTR 20[rcx]
	lea	rdi, .LC0[rip]
	call	ERR@PLT
	mov	eax, -1
	jmp	.L1
.L15:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE0:
	.size	write_out_image, .-write_out_image
	.comm	num_blocks,4,4
	.comm	bootext_block,8,8
	.comm	board,8,8
	.comm	blocks,8,8
	.comm	ROMBIN_FLAG_OCSUM,4,4
	.comm	OBJECT_TYPE_BOOTEXT,4,4
	.comm	MMAP_DATA_SIZE,8,8
	.comm	MMAP_ALIGN,4,4
	.comm	BLOCK_TYPE_BOOTEXT,8,8
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 2
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"extr_mkzynfw.c_write_out_image.c"
	.text
	.section	.rodata.str1.4,"aMS",%progbits,1
	.align	2
.LC0:
	.ascii	"bootext file '%s' is too big\000"
	.align	2
.LC1:
	.ascii	"bootext end at %08x\000"
	.align	2
.LC2:
	.ascii	"ocsum=%04x, csum=%04x, fix=%04x\000"
	.section	.rodata.cst4,"aM",%progbits,4
	.align	2
.LC3:
	.word	__stack_chk_guard
	.text
	.align	2
	.global	write_out_image
	.syntax unified
	.arm
	.fpu softvfp
	.type	write_out_image, %function
write_out_image:
	@ args = 0, pretend = 0, frame = 48
	@ frame_needed = 0, uses_anonymous_args = 0
	mov	r3, #0
	push	{r4, r5, r6, r7, r8, r9, r10, fp, lr}
	ldr	r7, .L21
	sub	sp, sp, #60
	ldr	r1, .L21+4
	str	r3, [sp, #40]
	str	r3, [sp, #44]
	str	r3, [sp, #48]
	str	r3, [sp, #28]
	str	r3, [sp, #32]
	str	r3, [sp, #36]
	ldr	r2, [r7]
	ldr	r3, .L21+8
	ldr	r1, [r1]
	ldr	lr, .L21+12
	ldr	ip, [r2, #12]
	ldr	r3, [r3]
	ldr	lr, [lr]
	str	lr, [sp, #52]
	mov	lr,#0
	ldr	r6, [r2]
	str	r1, [sp, #44]
	add	r1, sp, #28
	mov	r5, r0
	str	ip, [sp, #48]
	str	r3, [sp, #40]
	bl	write_out_header
	subs	r4, r0, #0
	beq	.L17
.L1:
	ldr	r3, .L21+12
	ldr	r2, [r3]
	ldr	r3, [sp, #52]
	eors	r2, r3, r2
	mov	r3, #0
	bne	.L18
	mov	r0, r4
	add	sp, sp, #60
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L17:
	ldr	r8, .L21+16
	add	r0, sp, #20
	bl	csum_init
	mov	r0, r5
	ldr	r1, [r8]
	add	r2, sp, #20
	bl	write_out_block
	subs	r4, r0, #0
	bne	.L1
	ldr	r2, [r7]
	ldr	r1, [r8]
	ldr	r3, [r2]
	ldr	r0, [r1]
	ldr	r2, [r2, #4]
	add	r6, r6, #24
	add	r6, r6, r0
	add	r3, r3, r2
	cmp	r3, r6
	blt	.L19
	ldr	r3, .L21+20
	mov	r0, r6
	ldr	r1, [r3]
	bl	ALIGN
	mov	r2, #255
	sub	r1, r0, r6
	mov	r8, r0
	add	r3, sp, #20
	mov	r0, r5
	bl	write_out_padding
	subs	r4, r0, #0
	bne	.L1
	ldr	r3, [r7]
	mov	r0, r5
	ldr	r3, [r3, #8]
	add	r2, sp, #20
	add	r3, r3, r8
	add	r1, sp, #16
	str	r3, [sp, #16]
	bl	write_out_mmap
	subs	r4, r0, #0
	bne	.L1
	ldr	r3, .L21+24
	ldr	r1, [r7]
	ldr	r2, [r3]
	ldr	r3, [r1]
	ldr	r6, [r1, #4]
	add	r2, r8, r2
	sub	r1, r2, r3
	cmp	r1, r6
	blt	.L20
.L4:
	ldr	r10, .L21+28
	ldr	r3, [r10]
	cmp	r3, #0
	ble	.L5
	ldr	fp, .L21+32
.L7:
	ldr	r3, .L21+36
	lsl	r9, r4, #4
	ldr	r8, [r3]
	ldr	r3, [fp]
	add	r6, r8, r4, lsl #4
	ldr	r1, [r6, #4]
	cmp	r1, r3
	beq	.L6
	mov	r0, r2
	ldr	r1, [r6, #8]
	str	r2, [sp, #12]
	bl	ALIGN
	ldr	r2, [sp, #12]
	mov	r7, r0
	sub	r1, r0, r2
	add	r3, sp, #20
	mov	r2, #255
	mov	r0, r5
	bl	write_out_padding
	cmp	r0, #0
	bne	.L13
	mov	r1, r6
	mov	r0, r5
	add	r2, sp, #20
	bl	write_out_block
	cmp	r0, #0
	bne	.L13
	ldr	r2, [r8, r9]
	add	r2, r7, r2
.L6:
	ldr	r3, [r10]
	add	r4, r4, #1
	cmp	r3, r4
	bgt	.L7
.L5:
	mov	r1, #4
	mov	r0, r2
	str	r2, [sp, #12]
	bl	ALIGN
	ldr	r2, [sp, #12]
	add	r3, sp, #20
	sub	r1, r0, r2
	mov	r2, #255
	mov	r0, r5
	bl	write_out_padding
	subs	r4, r0, #0
	bne	.L1
	add	r0, sp, #20
	bl	csum_get
	mov	r1, #2
	ldr	r2, [sp, #16]
	mov	r6, r0
	add	r0, sp, #32
	str	r1, [sp, #28]
	str	r2, [sp, #36]
	bl	read_magic
	subs	r4, r0, #0
	bne	.L1
	ldr	r0, [sp, #32]
	bl	BE16_TO_HOST
	sub	ip, r0, r6
	cmp	r0, r6
	sublt	ip, ip, #1
	mov	r2, r0
	mov	r3, r6
	ldr	r1, .L21+40
	str	ip, [sp]
	str	r0, [sp, #32]
	mov	r0, #2
	str	ip, [sp, #24]
	bl	DBG
	ldr	r0, [sp, #24]
	bl	HOST_TO_BE16
	mov	ip, r0
	mov	r3, #0
	mov	r2, #2
	mov	r0, r5
	add	r1, sp, #24
	str	ip, [sp, #24]
	bl	write_out_data
	subs	r4, r0, #0
	bne	.L1
	mov	r0, r5
	add	r1, sp, #28
	bl	write_out_header
	mov	r4, r0
	b	.L1
.L13:
	mov	r4, r0
	b	.L1
.L20:
	add	r6, r3, r6
	sub	r1, r6, r2
	mov	r0, r5
	mov	r2, #255
	add	r3, sp, #20
	bl	write_out_padding
	cmp	r0, #0
	bne	.L13
	mov	r2, r6
	mov	r0, #2
	ldr	r1, .L21+44
	str	r6, [sp, #12]
	bl	DBG
	ldr	r2, [sp, #12]
	b	.L4
.L19:
	ldr	r1, [r1, #12]
	ldr	r0, .L21+48
	bl	ERR
	mvn	r4, #0
	b	.L1
.L18:
	bl	__stack_chk_fail
.L22:
	.align	2
.L21:
	.word	board
	.word	OBJECT_TYPE_BOOTEXT
	.word	ROMBIN_FLAG_OCSUM
	.word	.LC3
	.word	bootext_block
	.word	MMAP_ALIGN
	.word	MMAP_DATA_SIZE
	.word	num_blocks
	.word	BLOCK_TYPE_BOOTEXT
	.word	blocks
	.word	.LC2
	.word	.LC1
	.word	.LC0
	.size	write_out_image, .-write_out_image
	.comm	num_blocks,4,4
	.comm	bootext_block,4,4
	.comm	board,4,4
	.comm	blocks,4,4
	.comm	ROMBIN_FLAG_OCSUM,4,4
	.comm	OBJECT_TYPE_BOOTEXT,4,4
	.comm	MMAP_DATA_SIZE,4,4
	.comm	MMAP_ALIGN,4,4
	.comm	BLOCK_TYPE_BOOTEXT,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
