	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ubi_io_read_ec_hdr             ## -- Begin function ubi_io_read_ec_hdr
	.p2align	4, 0x90
_ubi_io_read_ec_hdr:                    ## @ubi_io_read_ec_hdr
	.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
	movl	%ecx, %r13d
	movq	%rdx, %r15
	movl	%esi, %r14d
	movq	%rdi, %r12
	leaq	L_.str(%rip), %rdi
	callq	_dbg_io
	xorl	%edi, %edi
	testl	%r14d, %r14d
	js	LBB0_2
## %bb.1:
	cmpl	%r14d, (%r12)
	setg	%dil
LBB0_2:
	callq	_ubi_assert
	movq	_UBI_EC_HDR_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %r8d
	movq	%r12, %rdi
	movq	%r15, %rsi
	movl	%r14d, %edx
	xorl	%ecx, %ecx
	callq	_ubi_io_read
	movl	%eax, %ebx
	testl	%eax, %eax
	je	LBB0_5
## %bb.3:
	movq	_UBI_IO_BITFLIPS@GOTPCREL(%rip), %rax
	cmpl	(%rax), %ebx
	je	LBB0_5
## %bb.4:
	movl	%ebx, %edi
	callq	_mtd_is_eccerr
	testq	%rax, %rax
	je	LBB0_27
LBB0_5:
	movl	%r13d, -44(%rbp)                ## 4-byte Spill
	movl	4(%r15), %edi
	callq	_be32_to_cpu
	movq	%rax, %r13
	movq	_UBI_EC_HDR_MAGIC@GOTPCREL(%rip), %rax
	cmpq	(%rax), %r13
	jne	LBB0_6
## %bb.17:
	movq	%r12, -56(%rbp)                 ## 8-byte Spill
	movq	_UBI_CRC32_INIT@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_UBI_EC_HDR_SIZE_CRC@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r15, %rsi
	callq	_crc32
	movq	%rax, %r12
	movl	(%r15), %edi
	callq	_be32_to_cpu
	cmpq	%r12, %rax
	jne	LBB0_18
## %bb.22:
	movq	-56(%rbp), %r12                 ## 8-byte Reload
	movq	%r12, %rdi
	movq	%r15, %rsi
	callq	_validate_ec_hdr
	testl	%eax, %eax
	je	LBB0_24
## %bb.23:
	leaq	L_.str.4(%rip), %rsi
	movq	%r12, %rdi
	movl	%r14d, %edx
	callq	_ubi_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_27
LBB0_6:
	movl	%ebx, %edi
	callq	_mtd_is_eccerr
	testq	%rax, %rax
	jne	LBB0_7
## %bb.8:
	movq	_UBI_EC_HDR_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r15, %rdi
	movl	$255, %esi
	callq	_ubi_check_pattern
	testq	%rax, %rax
	je	LBB0_14
## %bb.9:
	cmpl	$0, -44(%rbp)                   ## 4-byte Folded Reload
	je	LBB0_11
## %bb.10:
	leaq	L_.str.1(%rip), %rsi
	movq	%r12, %rdi
	movl	%r14d, %edx
	xorl	%eax, %eax
	callq	_ubi_warn
LBB0_11:
	leaq	L_.str.1(%rip), %rdi
	movl	%r14d, %esi
	xorl	%eax, %eax
	callq	_dbg_bld
	testl	%ebx, %ebx
	je	LBB0_12
## %bb.13:
	movq	_UBI_IO_FF_BITFLIPS@GOTPCREL(%rip), %rax
	jmp	LBB0_26
LBB0_18:
	movq	%rax, %r13
	cmpl	$0, -44(%rbp)                   ## 4-byte Folded Reload
	je	LBB0_20
## %bb.19:
	leaq	L_.str.3(%rip), %rsi
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	movl	%r14d, %edx
	movq	%r12, %rcx
	movq	%r13, %r8
	xorl	%eax, %eax
	callq	_ubi_warn
	movq	%r15, %rdi
	callq	_ubi_dump_ec_hdr
LBB0_20:
	leaq	L_.str.3(%rip), %rdi
	movl	%r14d, %esi
	movq	%r12, %rdx
	movq	%r13, %rcx
	xorl	%eax, %eax
	callq	_dbg_bld
	testl	%ebx, %ebx
	je	LBB0_21
LBB0_7:
	movq	_UBI_IO_BAD_HDR_EBADMSG@GOTPCREL(%rip), %rax
LBB0_26:
	movl	(%rax), %ebx
LBB0_27:
	movl	%ebx, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_24:
	testl	%ebx, %ebx
	je	LBB0_27
## %bb.25:
	movq	_UBI_IO_BITFLIPS@GOTPCREL(%rip), %rax
	jmp	LBB0_26
LBB0_21:
	movq	_UBI_IO_BAD_HDR@GOTPCREL(%rip), %rax
	jmp	LBB0_26
LBB0_14:
	cmpl	$0, -44(%rbp)                   ## 4-byte Folded Reload
	movq	_UBI_EC_HDR_MAGIC@GOTPCREL(%rip), %rbx
	je	LBB0_16
## %bb.15:
	movq	(%rbx), %r8
	leaq	L_.str.2(%rip), %rsi
	movq	%r12, %rdi
	movl	%r14d, %edx
	movq	%r13, %rcx
	xorl	%eax, %eax
	callq	_ubi_warn
	movq	%r15, %rdi
	callq	_ubi_dump_ec_hdr
LBB0_16:
	movq	(%rbx), %rcx
	leaq	L_.str.2(%rip), %rdi
	movl	%r14d, %esi
	movq	%r13, %rdx
	xorl	%eax, %eax
	callq	_dbg_bld
	movq	_UBI_IO_BAD_HDR@GOTPCREL(%rip), %rax
	jmp	LBB0_26
LBB0_12:
	movq	_UBI_IO_FF@GOTPCREL(%rip), %rax
	jmp	LBB0_26
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"read EC header from PEB %d"

	.comm	_UBI_EC_HDR_SIZE,4,2            ## @UBI_EC_HDR_SIZE
	.comm	_UBI_IO_BITFLIPS,4,2            ## @UBI_IO_BITFLIPS
	.comm	_UBI_EC_HDR_MAGIC,8,3           ## @UBI_EC_HDR_MAGIC
	.comm	_UBI_IO_BAD_HDR_EBADMSG,4,2     ## @UBI_IO_BAD_HDR_EBADMSG
L_.str.1:                               ## @.str.1
	.asciz	"no EC header found at PEB %d, only 0xFF bytes"

	.comm	_UBI_IO_FF,4,2                  ## @UBI_IO_FF
	.comm	_UBI_IO_FF_BITFLIPS,4,2         ## @UBI_IO_FF_BITFLIPS
L_.str.2:                               ## @.str.2
	.asciz	"bad magic number at PEB %d: %08x instead of %08x"

	.comm	_UBI_IO_BAD_HDR,4,2             ## @UBI_IO_BAD_HDR
	.comm	_UBI_CRC32_INIT,4,2             ## @UBI_CRC32_INIT
	.comm	_UBI_EC_HDR_SIZE_CRC,4,2        ## @UBI_EC_HDR_SIZE_CRC
L_.str.3:                               ## @.str.3
	.asciz	"bad EC header CRC at PEB %d, calculated %#08x, read %#08x"

L_.str.4:                               ## @.str.4
	.asciz	"validation failed for PEB %d"

	.comm	_EINVAL,4,2                     ## @EINVAL
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ubi_io_read_ec_hdr             ; -- Begin function ubi_io_read_ec_hdr
	.p2align	2
_ubi_io_read_ec_hdr:                    ; @ubi_io_read_ec_hdr
	.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	x23, x3
	mov	x22, x2
	mov	x19, x1
	mov	x21, x0
Lloh0:
	adrp	x0, l_.str@PAGE
Lloh1:
	add	x0, x0, l_.str@PAGEOFF
	bl	_dbg_io
	tbnz	w19, #31, LBB0_2
; %bb.1:
	ldr	w8, [x21]
	cmp	w8, w19
	cset	w0, gt
	b	LBB0_3
LBB0_2:
	mov	w0, #0
LBB0_3:
	bl	_ubi_assert
Lloh2:
	adrp	x25, _UBI_EC_HDR_SIZE@GOTPAGE
Lloh3:
	ldr	x25, [x25, _UBI_EC_HDR_SIZE@GOTPAGEOFF]
	ldr	w4, [x25]
	mov	x0, x21
	mov	x1, x22
	mov	x2, x19
	mov	w3, #0
	bl	_ubi_io_read
	mov	x20, x0
Lloh4:
	adrp	x26, _UBI_IO_BITFLIPS@GOTPAGE
Lloh5:
	ldr	x26, [x26, _UBI_IO_BITFLIPS@GOTPAGEOFF]
	ldr	w8, [x26]
	cmp	w0, #0
	ccmp	w0, w8, #4, ne
	b.eq	LBB0_5
; %bb.4:
	mov	x0, x20
	bl	_mtd_is_eccerr
	cbz	x0, LBB0_26
LBB0_5:
	ldr	w0, [x22, #4]
	bl	_be32_to_cpu
Lloh6:
	adrp	x27, _UBI_EC_HDR_MAGIC@GOTPAGE
Lloh7:
	ldr	x27, [x27, _UBI_EC_HDR_MAGIC@GOTPAGEOFF]
	ldr	x8, [x27]
	cmp	x0, x8
	b.ne	LBB0_9
; %bb.6:
Lloh8:
	adrp	x8, _UBI_CRC32_INIT@GOTPAGE
Lloh9:
	ldr	x8, [x8, _UBI_CRC32_INIT@GOTPAGEOFF]
Lloh10:
	ldr	w0, [x8]
Lloh11:
	adrp	x8, _UBI_EC_HDR_SIZE_CRC@GOTPAGE
Lloh12:
	ldr	x8, [x8, _UBI_EC_HDR_SIZE_CRC@GOTPAGEOFF]
Lloh13:
	ldr	w2, [x8]
	mov	x1, x22
	bl	_crc32
	mov	x24, x0
	ldr	w0, [x22]
	bl	_be32_to_cpu
	cmp	x0, x24
	b.ne	LBB0_15
; %bb.7:
	mov	x0, x21
	mov	x1, x22
	bl	_validate_ec_hdr
	cbz	w0, LBB0_19
; %bb.8:
Lloh14:
	adrp	x1, l_.str.4@PAGE
Lloh15:
	add	x1, x1, l_.str.4@PAGEOFF
	mov	x0, x21
	mov	x2, x19
	bl	_ubi_err
Lloh16:
	adrp	x8, _EINVAL@GOTPAGE
Lloh17:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh18:
	ldr	w8, [x8]
	neg	w20, w8
	b	LBB0_26
LBB0_9:
	mov	x24, x0
	mov	x0, x20
	bl	_mtd_is_eccerr
	cbnz	x0, LBB0_18
; %bb.10:
	ldr	w2, [x25]
	mov	x0, x22
	mov	w1, #255
	bl	_ubi_check_pattern
	cbz	x0, LBB0_20
; %bb.11:
	cbz	w23, LBB0_13
; %bb.12:
Lloh19:
	adrp	x1, l_.str.1@PAGE
Lloh20:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x21
	mov	x2, x19
	bl	_ubi_warn
LBB0_13:
Lloh21:
	adrp	x0, l_.str.1@PAGE
Lloh22:
	add	x0, x0, l_.str.1@PAGEOFF
	mov	x1, x19
	bl	_dbg_bld
	cbz	w20, LBB0_24
; %bb.14:
Lloh23:
	adrp	x8, _UBI_IO_FF_BITFLIPS@GOTPAGE
Lloh24:
	ldr	x8, [x8, _UBI_IO_FF_BITFLIPS@GOTPAGEOFF]
	b	LBB0_25
LBB0_15:
	mov	x25, x0
	cbz	w23, LBB0_17
; %bb.16:
	stp	x24, x25, [sp]
Lloh25:
	adrp	x1, l_.str.3@PAGE
Lloh26:
	add	x1, x1, l_.str.3@PAGEOFF
	mov	x0, x21
	mov	x2, x19
	bl	_ubi_warn
	mov	x0, x22
	bl	_ubi_dump_ec_hdr
LBB0_17:
	stp	x24, x25, [sp]
Lloh27:
	adrp	x0, l_.str.3@PAGE
Lloh28:
	add	x0, x0, l_.str.3@PAGEOFF
	mov	x1, x19
	bl	_dbg_bld
	cbz	w20, LBB0_23
LBB0_18:
Lloh29:
	adrp	x8, _UBI_IO_BAD_HDR_EBADMSG@GOTPAGE
Lloh30:
	ldr	x8, [x8, _UBI_IO_BAD_HDR_EBADMSG@GOTPAGEOFF]
	b	LBB0_25
LBB0_19:
	ldr	w8, [x26]
	cmp	w20, #0
	csel	w20, wzr, w8, eq
	b	LBB0_26
LBB0_20:
	cbz	w23, LBB0_22
; %bb.21:
	ldr	x8, [x27]
	stp	x24, x8, [sp]
Lloh31:
	adrp	x1, l_.str.2@PAGE
Lloh32:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	x0, x21
	mov	x2, x19
	bl	_ubi_warn
	mov	x0, x22
	bl	_ubi_dump_ec_hdr
LBB0_22:
	ldr	x8, [x27]
	stp	x24, x8, [sp]
Lloh33:
	adrp	x0, l_.str.2@PAGE
Lloh34:
	add	x0, x0, l_.str.2@PAGEOFF
	mov	x1, x19
	bl	_dbg_bld
LBB0_23:
Lloh35:
	adrp	x8, _UBI_IO_BAD_HDR@GOTPAGE
Lloh36:
	ldr	x8, [x8, _UBI_IO_BAD_HDR@GOTPAGEOFF]
	b	LBB0_25
LBB0_24:
Lloh37:
	adrp	x8, _UBI_IO_FF@GOTPAGE
Lloh38:
	ldr	x8, [x8, _UBI_IO_FF@GOTPAGEOFF]
LBB0_25:
	ldr	w20, [x8]
LBB0_26:
	mov	x0, x20
	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 AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpLdrGot	Lloh23, Lloh24
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpLdrGot	Lloh29, Lloh30
	.loh AdrpAdd	Lloh31, Lloh32
	.loh AdrpAdd	Lloh33, Lloh34
	.loh AdrpLdrGot	Lloh35, Lloh36
	.loh AdrpLdrGot	Lloh37, Lloh38
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"read EC header from PEB %d"

	.comm	_UBI_EC_HDR_SIZE,4,2            ; @UBI_EC_HDR_SIZE
	.comm	_UBI_IO_BITFLIPS,4,2            ; @UBI_IO_BITFLIPS
	.comm	_UBI_EC_HDR_MAGIC,8,3           ; @UBI_EC_HDR_MAGIC
	.comm	_UBI_IO_BAD_HDR_EBADMSG,4,2     ; @UBI_IO_BAD_HDR_EBADMSG
l_.str.1:                               ; @.str.1
	.asciz	"no EC header found at PEB %d, only 0xFF bytes"

	.comm	_UBI_IO_FF,4,2                  ; @UBI_IO_FF
	.comm	_UBI_IO_FF_BITFLIPS,4,2         ; @UBI_IO_FF_BITFLIPS
l_.str.2:                               ; @.str.2
	.asciz	"bad magic number at PEB %d: %08x instead of %08x"

	.comm	_UBI_IO_BAD_HDR,4,2             ; @UBI_IO_BAD_HDR
	.comm	_UBI_CRC32_INIT,4,2             ; @UBI_CRC32_INIT
	.comm	_UBI_EC_HDR_SIZE_CRC,4,2        ; @UBI_EC_HDR_SIZE_CRC
l_.str.3:                               ; @.str.3
	.asciz	"bad EC header CRC at PEB %d, calculated %#08x, read %#08x"

l_.str.4:                               ; @.str.4
	.asciz	"validation failed for PEB %d"

	.comm	_EINVAL,4,2                     ; @EINVAL
.subsections_via_symbols
