	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function c8sectpfe_elf_sanity_check
_c8sectpfe_elf_sanity_check:            ## @c8sectpfe_elf_sanity_check
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r14
	pushq	%rbx
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	movq	%rdi, %r14
	testq	%rsi, %rsi
	je	LBB0_1
## %bb.2:
	movq	%rsi, %rbx
	movslq	(%rsi), %rax
	cmpq	$31, %rax
	ja	LBB0_4
LBB0_3:
	movl	(%r14), %edi
	leaq	L_.str.1(%rip), %rsi
LBB0_21:
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_22
LBB0_1:
	movl	(%r14), %edi
	movq	_FIRMWARE_MEMDMA@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	leaq	L_.str(%rip), %rsi
	jmp	LBB0_6
LBB0_4:
	movq	8(%rbx), %rcx
	movq	(%rcx), %rdi
	movq	_EI_CLASS@GOTPCREL(%rip), %rdx
	movq	(%rdx), %rdx
	movsbl	(%rdi,%rdx), %edx
	movq	_ELFCLASS32@GOTPCREL(%rip), %rsi
	cmpb	(%rsi), %dl
	jne	LBB0_5
## %bb.7:
	movq	_EI_DATA@GOTPCREL(%rip), %rdx
	movq	(%rdx), %rdx
	movb	(%rdi,%rdx), %dl
	movq	_ELFDATA2LSB@GOTPCREL(%rip), %rsi
	cmpb	(%rsi), %dl
	jne	LBB0_8
## %bb.9:
	movq	8(%rcx), %rcx
	addq	$4, %rcx
	cmpq	%rax, %rcx
	ja	LBB0_3
## %bb.10:
	movq	_ELFMAG@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_SELFMAG@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	callq	_memcmp
	testq	%rax, %rax
	je	LBB0_12
## %bb.11:
	movl	(%r14), %edi
	leaq	L_.str.4(%rip), %rsi
	jmp	LBB0_21
LBB0_5:
	movl	(%r14), %edi
	leaq	L_.str.2(%rip), %rsi
LBB0_6:
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_dev_err
LBB0_22:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
LBB0_23:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r14
	popq	%rbp
	retq
LBB0_8:
	movl	(%r14), %edi
	leaq	L_.str.3(%rip), %rsi
	jmp	LBB0_21
LBB0_12:
	movq	8(%rbx), %rax
	movq	(%rax), %rcx
	movq	_EI_MAG0@GOTPCREL(%rip), %rdx
	movq	(%rdx), %rdx
	movb	(%rcx,%rdx), %dl
	movq	_ELFMAG0@GOTPCREL(%rip), %rsi
	cmpb	(%rsi), %dl
	jne	LBB0_16
## %bb.13:
	movq	_EI_MAG1@GOTPCREL(%rip), %rdx
	movq	(%rdx), %rdx
	movb	(%rcx,%rdx), %dl
	movq	_ELFMAG1@GOTPCREL(%rip), %rsi
	cmpb	(%rsi), %dl
	jne	LBB0_16
## %bb.14:
	movq	_EI_MAG2@GOTPCREL(%rip), %rdx
	movq	(%rdx), %rdx
	movb	(%rcx,%rdx), %dl
	movq	_ELFMAG2@GOTPCREL(%rip), %rsi
	cmpb	(%rsi), %dl
	jne	LBB0_16
## %bb.15:
	movq	_EI_MAG3@GOTPCREL(%rip), %rdx
	movq	(%rdx), %rdx
	movb	(%rcx,%rdx), %cl
	movq	_ELFMAG3@GOTPCREL(%rip), %rdx
	cmpb	(%rdx), %cl
	jne	LBB0_16
## %bb.17:
	movq	16(%rax), %rcx
	movq	_ET_EXEC@GOTPCREL(%rip), %rdx
	cmpq	(%rdx), %rcx
	jne	LBB0_18
## %bb.19:
	movslq	(%rbx), %rcx
	xorl	%ebx, %ebx
	cmpq	%rcx, 24(%rax)
	jle	LBB0_23
## %bb.20:
	movl	(%r14), %edi
	leaq	L_.str.7(%rip), %rsi
	jmp	LBB0_21
LBB0_16:
	movl	(%r14), %edi
	leaq	L_.str.5(%rip), %rsi
	jmp	LBB0_21
LBB0_18:
	movl	(%r14), %edi
	leaq	L_.str.6(%rip), %rsi
	jmp	LBB0_21
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"failed to load %s\n"

	.comm	_FIRMWARE_MEMDMA,4,2            ## @FIRMWARE_MEMDMA
	.comm	_EINVAL,4,2                     ## @EINVAL
L_.str.1:                               ## @.str.1
	.asciz	"Image is too small\n"

	.comm	_EI_CLASS,8,3                   ## @EI_CLASS
	.comm	_ELFCLASS32,1,0                 ## @ELFCLASS32
L_.str.2:                               ## @.str.2
	.asciz	"Unsupported class: %d\n"

	.comm	_EI_DATA,8,3                    ## @EI_DATA
	.comm	_ELFDATA2LSB,1,0                ## @ELFDATA2LSB
L_.str.3:                               ## @.str.3
	.asciz	"Unsupported firmware endianness\n"

	.comm	_ELFMAG,4,2                     ## @ELFMAG
	.comm	_SELFMAG,4,2                    ## @SELFMAG
L_.str.4:                               ## @.str.4
	.asciz	"Image is corrupted (bad magic)\n"

	.comm	_EI_MAG0,8,3                    ## @EI_MAG0
	.comm	_ELFMAG0,1,0                    ## @ELFMAG0
	.comm	_EI_MAG1,8,3                    ## @EI_MAG1
	.comm	_ELFMAG1,1,0                    ## @ELFMAG1
	.comm	_EI_MAG2,8,3                    ## @EI_MAG2
	.comm	_ELFMAG2,1,0                    ## @ELFMAG2
	.comm	_EI_MAG3,8,3                    ## @EI_MAG3
	.comm	_ELFMAG3,1,0                    ## @ELFMAG3
L_.str.5:                               ## @.str.5
	.asciz	"Invalid ELF magic\n"

	.comm	_ET_EXEC,8,3                    ## @ET_EXEC
L_.str.6:                               ## @.str.6
	.asciz	"Unsupported ELF header type\n"

L_.str.7:                               ## @.str.7
	.asciz	"Firmware size is too small\n"

	.no_dead_strip	_c8sectpfe_elf_sanity_check
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function c8sectpfe_elf_sanity_check
_c8sectpfe_elf_sanity_check:            ; @c8sectpfe_elf_sanity_check
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #48
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	mov	x19, x0
	cbz	x1, LBB0_3
; %bb.1:
	mov	x20, x1
	ldrsw	x8, [x1]
	cmp	w8, #31
	b.hi	LBB0_4
LBB0_2:
	ldr	w0, [x19]
Lloh0:
	adrp	x1, l_.str.1@PAGE
Lloh1:
	add	x1, x1, l_.str.1@PAGEOFF
	b	LBB0_11
LBB0_3:
	ldr	w0, [x19]
Lloh2:
	adrp	x8, _FIRMWARE_MEMDMA@GOTPAGE
Lloh3:
	ldr	x8, [x8, _FIRMWARE_MEMDMA@GOTPAGEOFF]
Lloh4:
	ldr	w8, [x8]
	str	x8, [sp]
Lloh5:
	adrp	x1, l_.str@PAGE
Lloh6:
	add	x1, x1, l_.str@PAGEOFF
	b	LBB0_11
LBB0_4:
	ldr	x9, [x20, #8]
	ldr	x0, [x9]
Lloh7:
	adrp	x10, _EI_CLASS@GOTPAGE
Lloh8:
	ldr	x10, [x10, _EI_CLASS@GOTPAGEOFF]
Lloh9:
	ldr	x10, [x10]
	ldrb	w10, [x0, x10]
Lloh10:
	adrp	x11, _ELFCLASS32@GOTPAGE
Lloh11:
	ldr	x11, [x11, _ELFCLASS32@GOTPAGEOFF]
	ldrb	w11, [x11]
	cmp	w10, w11
	b.ne	LBB0_9
; %bb.5:
Lloh12:
	adrp	x10, _EI_DATA@GOTPAGE
Lloh13:
	ldr	x10, [x10, _EI_DATA@GOTPAGEOFF]
Lloh14:
	ldr	x10, [x10]
	ldrb	w10, [x0, x10]
Lloh15:
	adrp	x11, _ELFDATA2LSB@GOTPAGE
Lloh16:
	ldr	x11, [x11, _ELFDATA2LSB@GOTPAGEOFF]
	ldrb	w11, [x11]
	cmp	w10, w11
	b.ne	LBB0_10
; %bb.6:
	ldr	x9, [x9, #8]
	add	x9, x9, #4
	cmp	x9, x8
	b.hi	LBB0_2
; %bb.7:
Lloh17:
	adrp	x8, _ELFMAG@GOTPAGE
Lloh18:
	ldr	x8, [x8, _ELFMAG@GOTPAGEOFF]
Lloh19:
	ldr	w1, [x8]
Lloh20:
	adrp	x8, _SELFMAG@GOTPAGE
Lloh21:
	ldr	x8, [x8, _SELFMAG@GOTPAGEOFF]
Lloh22:
	ldr	w2, [x8]
	bl	_memcmp
	cbz	x0, LBB0_13
; %bb.8:
	ldr	w0, [x19]
Lloh23:
	adrp	x1, l_.str.4@PAGE
Lloh24:
	add	x1, x1, l_.str.4@PAGEOFF
	b	LBB0_11
LBB0_9:
	sxtb	w8, w10
	ldr	w0, [x19]
	str	x8, [sp]
Lloh25:
	adrp	x1, l_.str.2@PAGE
Lloh26:
	add	x1, x1, l_.str.2@PAGEOFF
	b	LBB0_11
LBB0_10:
	ldr	w0, [x19]
Lloh27:
	adrp	x1, l_.str.3@PAGE
Lloh28:
	add	x1, x1, l_.str.3@PAGEOFF
LBB0_11:
	bl	_dev_err
Lloh29:
	adrp	x8, _EINVAL@GOTPAGE
Lloh30:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh31:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_12:
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	ret
LBB0_13:
	ldr	x8, [x20, #8]
	ldr	x9, [x8]
Lloh32:
	adrp	x10, _EI_MAG0@GOTPAGE
Lloh33:
	ldr	x10, [x10, _EI_MAG0@GOTPAGEOFF]
Lloh34:
	ldr	x10, [x10]
	ldrb	w10, [x9, x10]
Lloh35:
	adrp	x11, _ELFMAG0@GOTPAGE
Lloh36:
	ldr	x11, [x11, _ELFMAG0@GOTPAGEOFF]
	ldrb	w11, [x11]
	cmp	w10, w11
	b.ne	LBB0_20
; %bb.14:
Lloh37:
	adrp	x10, _EI_MAG1@GOTPAGE
Lloh38:
	ldr	x10, [x10, _EI_MAG1@GOTPAGEOFF]
Lloh39:
	ldr	x10, [x10]
	ldrb	w10, [x9, x10]
Lloh40:
	adrp	x11, _ELFMAG1@GOTPAGE
Lloh41:
	ldr	x11, [x11, _ELFMAG1@GOTPAGEOFF]
	ldrb	w11, [x11]
	cmp	w10, w11
	b.ne	LBB0_20
; %bb.15:
Lloh42:
	adrp	x10, _EI_MAG2@GOTPAGE
Lloh43:
	ldr	x10, [x10, _EI_MAG2@GOTPAGEOFF]
Lloh44:
	ldr	x10, [x10]
	ldrb	w10, [x9, x10]
Lloh45:
	adrp	x11, _ELFMAG2@GOTPAGE
Lloh46:
	ldr	x11, [x11, _ELFMAG2@GOTPAGEOFF]
	ldrb	w11, [x11]
	cmp	w10, w11
	b.ne	LBB0_20
; %bb.16:
Lloh47:
	adrp	x10, _EI_MAG3@GOTPAGE
Lloh48:
	ldr	x10, [x10, _EI_MAG3@GOTPAGEOFF]
Lloh49:
	ldr	x10, [x10]
	ldrb	w9, [x9, x10]
Lloh50:
	adrp	x10, _ELFMAG3@GOTPAGE
Lloh51:
	ldr	x10, [x10, _ELFMAG3@GOTPAGEOFF]
	ldrb	w10, [x10]
	cmp	w9, w10
	b.ne	LBB0_20
; %bb.17:
	ldr	x9, [x8, #16]
Lloh52:
	adrp	x10, _ET_EXEC@GOTPAGE
Lloh53:
	ldr	x10, [x10, _ET_EXEC@GOTPAGEOFF]
Lloh54:
	ldr	x10, [x10]
	cmp	x9, x10
	b.ne	LBB0_21
; %bb.18:
	ldr	x8, [x8, #24]
	ldrsw	x9, [x20]
	cmp	x8, x9
	b.le	LBB0_22
; %bb.19:
	ldr	w0, [x19]
Lloh55:
	adrp	x1, l_.str.7@PAGE
Lloh56:
	add	x1, x1, l_.str.7@PAGEOFF
	b	LBB0_11
LBB0_20:
	ldr	w0, [x19]
Lloh57:
	adrp	x1, l_.str.5@PAGE
Lloh58:
	add	x1, x1, l_.str.5@PAGEOFF
	b	LBB0_11
LBB0_21:
	ldr	w0, [x19]
Lloh59:
	adrp	x1, l_.str.6@PAGE
Lloh60:
	add	x1, x1, l_.str.6@PAGEOFF
	b	LBB0_11
LBB0_22:
	mov	w0, #0
	b	LBB0_12
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpAdd	Lloh23, Lloh24
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpLdrGot	Lloh35, Lloh36
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.loh AdrpLdrGot	Lloh40, Lloh41
	.loh AdrpLdrGotLdr	Lloh37, Lloh38, Lloh39
	.loh AdrpLdrGot	Lloh45, Lloh46
	.loh AdrpLdrGotLdr	Lloh42, Lloh43, Lloh44
	.loh AdrpLdrGot	Lloh50, Lloh51
	.loh AdrpLdrGotLdr	Lloh47, Lloh48, Lloh49
	.loh AdrpLdrGotLdr	Lloh52, Lloh53, Lloh54
	.loh AdrpAdd	Lloh55, Lloh56
	.loh AdrpAdd	Lloh57, Lloh58
	.loh AdrpAdd	Lloh59, Lloh60
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"failed to load %s\n"

	.comm	_FIRMWARE_MEMDMA,4,2            ; @FIRMWARE_MEMDMA
	.comm	_EINVAL,4,2                     ; @EINVAL
l_.str.1:                               ; @.str.1
	.asciz	"Image is too small\n"

	.comm	_EI_CLASS,8,3                   ; @EI_CLASS
	.comm	_ELFCLASS32,1,0                 ; @ELFCLASS32
l_.str.2:                               ; @.str.2
	.asciz	"Unsupported class: %d\n"

	.comm	_EI_DATA,8,3                    ; @EI_DATA
	.comm	_ELFDATA2LSB,1,0                ; @ELFDATA2LSB
l_.str.3:                               ; @.str.3
	.asciz	"Unsupported firmware endianness\n"

	.comm	_ELFMAG,4,2                     ; @ELFMAG
	.comm	_SELFMAG,4,2                    ; @SELFMAG
l_.str.4:                               ; @.str.4
	.asciz	"Image is corrupted (bad magic)\n"

	.comm	_EI_MAG0,8,3                    ; @EI_MAG0
	.comm	_ELFMAG0,1,0                    ; @ELFMAG0
	.comm	_EI_MAG1,8,3                    ; @EI_MAG1
	.comm	_ELFMAG1,1,0                    ; @ELFMAG1
	.comm	_EI_MAG2,8,3                    ; @EI_MAG2
	.comm	_ELFMAG2,1,0                    ; @ELFMAG2
	.comm	_EI_MAG3,8,3                    ; @EI_MAG3
	.comm	_ELFMAG3,1,0                    ; @ELFMAG3
l_.str.5:                               ; @.str.5
	.asciz	"Invalid ELF magic\n"

	.comm	_ET_EXEC,8,3                    ; @ET_EXEC
l_.str.6:                               ; @.str.6
	.asciz	"Unsupported ELF header type\n"

l_.str.7:                               ; @.str.7
	.asciz	"Firmware size is too small\n"

	.no_dead_strip	_c8sectpfe_elf_sanity_check
.subsections_via_symbols
