	.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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%ecx, %r15d
	movq	%rdx, %r14
	movl	%esi, %r12d
	movq	%rdi, %r13
	leaq	L_.str(%rip), %rdi
	callq	_dbg_io
	xorl	%edi, %edi
	testl	%r12d, %r12d
	js	LBB0_2
## %bb.1:
	cmpl	%r12d, (%r13)
	setg	%dil
LBB0_2:
	callq	_ubi_assert
	movq	_UBI_EC_HDR_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %r8d
	movq	%r13, %rdi
	movq	%r14, %rsi
	movl	%r12d, %edx
	xorl	%ecx, %ecx
	callq	_ubi_io_read
	movl	%eax, %ebx
	movq	_UBI_IO_BITFLIPS@GOTPCREL(%rip), %rax
	testl	%ebx, %ebx
	je	LBB0_5
## %bb.3:
	cmpl	(%rax), %ebx
	je	LBB0_5
## %bb.4:
	movq	_EBADMSG@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	addl	%ebx, %eax
	jne	LBB0_30
LBB0_5:
	movl	%r15d, -44(%rbp)                ## 4-byte Spill
	movl	4(%r14), %edi
	callq	_be32_to_cpu
	movq	_UBI_EC_HDR_MAGIC@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_9
## %bb.6:
	movq	_UBI_CRC32_INIT@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_UBI_EC_HDR_SIZE_CRC@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r14, %rsi
	callq	_crc32
	movq	%rax, %r15
	movl	(%r14), %edi
	callq	_be32_to_cpu
	cmpq	%r15, %rax
	jne	LBB0_15
## %bb.7:
	movq	%r13, %rdi
	movq	%r14, %rsi
	callq	_validate_ec_hdr
	testl	%eax, %eax
	je	LBB0_20
## %bb.8:
	leaq	L_.str.4(%rip), %rdi
	movl	%r12d, %esi
	callq	_ubi_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_30
LBB0_9:
	movq	%rax, %r15
	movq	_EBADMSG@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	addl	%ebx, %eax
	je	LBB0_13
## %bb.10:
	movq	_UBI_EC_HDR_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r14, %rdi
	movl	$255, %esi
	movq	%rcx, %rbx
	callq	_check_pattern
	movq	%rbx, %rcx
	testq	%rax, %rax
	je	LBB0_13
## %bb.11:
	cmpl	$0, -44(%rbp)                   ## 4-byte Folded Reload
	je	LBB0_26
## %bb.12:
	leaq	L_.str.1(%rip), %rdi
	movl	%r12d, %esi
	xorl	%eax, %eax
	callq	_ubi_warn
	jmp	LBB0_28
LBB0_13:
	cmpl	$0, -44(%rbp)                   ## 4-byte Folded Reload
	je	LBB0_18
## %bb.14:
	movq	(%rcx), %rcx
	leaq	L_.str.2(%rip), %rdi
	movl	%r12d, %esi
	movq	%r15, %rdx
	jmp	LBB0_17
LBB0_15:
	cmpl	$0, -44(%rbp)                   ## 4-byte Folded Reload
	je	LBB0_22
## %bb.16:
	leaq	L_.str.3(%rip), %rdi
	movl	%r12d, %esi
	movq	%r15, %rdx
	movq	%rax, %rcx
LBB0_17:
	xorl	%eax, %eax
	callq	_ubi_warn
	movq	%r14, %rdi
	callq	_ubi_dbg_dump_ec_hdr
	movq	_UBI_IO_BAD_EC_HDR@GOTPCREL(%rip), %rax
	jmp	LBB0_29
LBB0_18:
	movq	_UBI_IO_DEBUG@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_25
## %bb.19:
	movq	(%rcx), %rcx
	leaq	L_.str.2(%rip), %rdi
	movl	%r12d, %esi
	movq	%r15, %rdx
	jmp	LBB0_24
LBB0_20:
	testl	%ebx, %ebx
	je	LBB0_30
## %bb.21:
	movq	_UBI_IO_BITFLIPS@GOTPCREL(%rip), %rax
	jmp	LBB0_29
LBB0_22:
	movq	_UBI_IO_DEBUG@GOTPCREL(%rip), %rcx
	cmpq	$0, (%rcx)
	je	LBB0_25
## %bb.23:
	leaq	L_.str.3(%rip), %rdi
	movl	%r12d, %esi
	movq	%r15, %rdx
	movq	%rax, %rcx
LBB0_24:
	xorl	%eax, %eax
	callq	_dbg_msg
LBB0_25:
	movq	_UBI_IO_BAD_EC_HDR@GOTPCREL(%rip), %rax
	jmp	LBB0_29
LBB0_26:
	movq	_UBI_IO_DEBUG@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_28
## %bb.27:
	leaq	L_.str.1(%rip), %rdi
	movl	%r12d, %esi
	xorl	%eax, %eax
	callq	_dbg_msg
LBB0_28:
	movq	_UBI_IO_PEB_EMPTY@GOTPCREL(%rip), %rax
LBB0_29:
	movl	(%rax), %ebx
LBB0_30:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.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	_EBADMSG,4,2                    ## @EBADMSG
	.comm	_UBI_EC_HDR_MAGIC,8,3           ## @UBI_EC_HDR_MAGIC
L_.str.1:                               ## @.str.1
	.asciz	"no EC header found at PEB %d, only 0xFF bytes"

	.comm	_UBI_IO_DEBUG,8,3               ## @UBI_IO_DEBUG
	.comm	_UBI_IO_PEB_EMPTY,4,2           ## @UBI_IO_PEB_EMPTY
L_.str.2:                               ## @.str.2
	.asciz	"bad magic number at PEB %d: %08x instead of %08x"

	.comm	_UBI_IO_BAD_EC_HDR,4,2          ## @UBI_IO_BAD_EC_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	x21, x3
	mov	x20, x2
	mov	x19, x1
	mov	x22, 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, [x22]
	cmp	w8, w19
	cset	w0, gt
	b	LBB0_3
LBB0_2:
	mov	w0, #0
LBB0_3:
	bl	_ubi_assert
Lloh2:
	adrp	x26, _UBI_EC_HDR_SIZE@GOTPAGE
Lloh3:
	ldr	x26, [x26, _UBI_EC_HDR_SIZE@GOTPAGEOFF]
	ldr	w4, [x26]
	mov	x0, x22
	mov	x1, x20
	mov	x2, x19
	mov	w3, #0
	bl	_ubi_io_read
	mov	x23, x0
Lloh4:
	adrp	x25, _UBI_IO_BITFLIPS@GOTPAGE
Lloh5:
	ldr	x25, [x25, _UBI_IO_BITFLIPS@GOTPAGEOFF]
	ldr	w8, [x25]
	cmp	w0, #0
	ccmp	w0, w8, #4, ne
	b.eq	LBB0_5
; %bb.4:
Lloh6:
	adrp	x8, _EBADMSG@GOTPAGE
Lloh7:
	ldr	x8, [x8, _EBADMSG@GOTPAGEOFF]
Lloh8:
	ldr	w8, [x8]
	cmn	w23, w8
	b.ne	LBB0_29
LBB0_5:
	ldr	w0, [x20, #4]
	bl	_be32_to_cpu
Lloh9:
	adrp	x27, _UBI_EC_HDR_MAGIC@GOTPAGE
Lloh10:
	ldr	x27, [x27, _UBI_EC_HDR_MAGIC@GOTPAGEOFF]
	ldr	x8, [x27]
	cmp	x0, x8
	b.ne	LBB0_9
; %bb.6:
Lloh11:
	adrp	x8, _UBI_CRC32_INIT@GOTPAGE
Lloh12:
	ldr	x8, [x8, _UBI_CRC32_INIT@GOTPAGEOFF]
Lloh13:
	ldr	w0, [x8]
Lloh14:
	adrp	x8, _UBI_EC_HDR_SIZE_CRC@GOTPAGE
Lloh15:
	ldr	x8, [x8, _UBI_EC_HDR_SIZE_CRC@GOTPAGEOFF]
Lloh16:
	ldr	w2, [x8]
	mov	x1, x20
	bl	_crc32
	mov	x24, x0
	ldr	w0, [x20]
	bl	_be32_to_cpu
	cmp	x0, x24
	b.ne	LBB0_15
; %bb.7:
	mov	x0, x22
	mov	x1, x20
	bl	_validate_ec_hdr
	cbz	w0, LBB0_20
; %bb.8:
Lloh17:
	adrp	x0, l_.str.4@PAGE
Lloh18:
	add	x0, x0, l_.str.4@PAGEOFF
	mov	x1, x19
	bl	_ubi_err
Lloh19:
	adrp	x8, _EINVAL@GOTPAGE
Lloh20:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh21:
	ldr	w8, [x8]
	neg	w23, w8
	b	LBB0_29
LBB0_9:
	mov	x24, x0
Lloh22:
	adrp	x8, _EBADMSG@GOTPAGE
Lloh23:
	ldr	x8, [x8, _EBADMSG@GOTPAGEOFF]
Lloh24:
	ldr	w8, [x8]
	cmn	w23, w8
	b.eq	LBB0_13
; %bb.10:
	ldr	w2, [x26]
	mov	x0, x20
	mov	w1, #255
	bl	_check_pattern
	cbz	x0, LBB0_13
; %bb.11:
	cbz	w21, LBB0_25
; %bb.12:
Lloh25:
	adrp	x0, l_.str.1@PAGE
Lloh26:
	add	x0, x0, l_.str.1@PAGEOFF
	mov	x1, x19
	bl	_ubi_warn
	b	LBB0_27
LBB0_13:
	cbz	w21, LBB0_18
; %bb.14:
	ldr	x8, [x27]
	stp	x24, x8, [sp]
Lloh27:
	adrp	x0, l_.str.2@PAGE
Lloh28:
	add	x0, x0, l_.str.2@PAGEOFF
	b	LBB0_17
LBB0_15:
	cbz	w21, LBB0_21
; %bb.16:
	stp	x24, x0, [sp]
Lloh29:
	adrp	x0, l_.str.3@PAGE
Lloh30:
	add	x0, x0, l_.str.3@PAGEOFF
LBB0_17:
	mov	x1, x19
	bl	_ubi_warn
	mov	x0, x20
	bl	_ubi_dbg_dump_ec_hdr
	b	LBB0_24
LBB0_18:
Lloh31:
	adrp	x8, _UBI_IO_DEBUG@GOTPAGE
Lloh32:
	ldr	x8, [x8, _UBI_IO_DEBUG@GOTPAGEOFF]
Lloh33:
	ldr	x8, [x8]
	cbz	x8, LBB0_24
; %bb.19:
	ldr	x8, [x27]
	stp	x24, x8, [sp]
Lloh34:
	adrp	x0, l_.str.2@PAGE
Lloh35:
	add	x0, x0, l_.str.2@PAGEOFF
	b	LBB0_23
LBB0_20:
	ldr	w8, [x25]
	cmp	w23, #0
	csel	w23, wzr, w8, eq
	b	LBB0_29
LBB0_21:
Lloh36:
	adrp	x8, _UBI_IO_DEBUG@GOTPAGE
Lloh37:
	ldr	x8, [x8, _UBI_IO_DEBUG@GOTPAGEOFF]
Lloh38:
	ldr	x8, [x8]
	cbz	x8, LBB0_24
; %bb.22:
	stp	x24, x0, [sp]
Lloh39:
	adrp	x0, l_.str.3@PAGE
Lloh40:
	add	x0, x0, l_.str.3@PAGEOFF
LBB0_23:
	mov	x1, x19
	bl	_dbg_msg
LBB0_24:
Lloh41:
	adrp	x8, _UBI_IO_BAD_EC_HDR@GOTPAGE
Lloh42:
	ldr	x8, [x8, _UBI_IO_BAD_EC_HDR@GOTPAGEOFF]
	b	LBB0_28
LBB0_25:
Lloh43:
	adrp	x8, _UBI_IO_DEBUG@GOTPAGE
Lloh44:
	ldr	x8, [x8, _UBI_IO_DEBUG@GOTPAGEOFF]
Lloh45:
	ldr	x8, [x8]
	cbz	x8, LBB0_27
; %bb.26:
Lloh46:
	adrp	x0, l_.str.1@PAGE
Lloh47:
	add	x0, x0, l_.str.1@PAGEOFF
	mov	x1, x19
	bl	_dbg_msg
LBB0_27:
Lloh48:
	adrp	x8, _UBI_IO_PEB_EMPTY@GOTPAGE
Lloh49:
	ldr	x8, [x8, _UBI_IO_PEB_EMPTY@GOTPAGEOFF]
LBB0_28:
	ldr	w23, [x8]
LBB0_29:
	mov	x0, x23
	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 AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpAdd	Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpAdd	Lloh29, Lloh30
	.loh AdrpLdrGotLdr	Lloh31, Lloh32, Lloh33
	.loh AdrpAdd	Lloh34, Lloh35
	.loh AdrpLdrGotLdr	Lloh36, Lloh37, Lloh38
	.loh AdrpAdd	Lloh39, Lloh40
	.loh AdrpLdrGot	Lloh41, Lloh42
	.loh AdrpLdrGotLdr	Lloh43, Lloh44, Lloh45
	.loh AdrpAdd	Lloh46, Lloh47
	.loh AdrpLdrGot	Lloh48, Lloh49
	.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	_EBADMSG,4,2                    ; @EBADMSG
	.comm	_UBI_EC_HDR_MAGIC,8,3           ; @UBI_EC_HDR_MAGIC
l_.str.1:                               ; @.str.1
	.asciz	"no EC header found at PEB %d, only 0xFF bytes"

	.comm	_UBI_IO_DEBUG,8,3               ; @UBI_IO_DEBUG
	.comm	_UBI_IO_PEB_EMPTY,4,2           ; @UBI_IO_PEB_EMPTY
l_.str.2:                               ; @.str.2
	.asciz	"bad magic number at PEB %d: %08x instead of %08x"

	.comm	_UBI_IO_BAD_EC_HDR,4,2          ; @UBI_IO_BAD_EC_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
