	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_handle_kernel_image            ## -- Begin function handle_kernel_image
	.p2align	4, 0x90
_handle_kernel_image:                   ## @handle_kernel_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	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%r8, %r14
	movq	%rcx, %r15
	movq	%rdx, -64(%rbp)                 ## 8-byte Spill
	movq	%rsi, -56(%rbp)                 ## 8-byte Spill
	movq	%rdi, %rbx
	movq	_SZ_128M@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r9, -72(%rbp)                  ## 8-byte Spill
	movq	%r9, %rdi
	callq	_round_up
	movq	_TEXT_OFFSET@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movq	_PAGE_SIZE@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
	leal	(%rdx,%rdx,4), %edx
	subl	%edx, %ecx
	movslq	%ecx, %r12
	addq	%rax, %r12
	movq	%rbx, -48(%rbp)                 ## 8-byte Spill
	movq	%rbx, %rdi
	movq	%r12, %rsi
	movq	%r15, %rdx
	movq	%r14, %rcx
	callq	_reserve_kernel_base
	movq	%rax, %r13
	movq	_EFI_SUCCESS@GOTPCREL(%rip), %rax
	cmpq	(%rax), %r13
	jne	LBB0_1
## %bb.2:
	movq	-72(%rbp), %rbx                 ## 8-byte Reload
	movq	16(%rbp), %rax
	movq	(%rax), %rcx
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	movq	%rcx, (%rax)
	movq	_MAX_UNCOMP_KERNEL_SIZE@GOTPCREL(%rip), %rax
	addq	(%rax), %r12
	movl	$0, (%rsp)
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	movq	-56(%rbp), %rsi                 ## 8-byte Reload
	movq	%rcx, %rdx
	movq	%r12, %r8
	xorl	%r9d, %r9d
	callq	_efi_relocate_kernel
	movq	%rax, %r13
	movq	_EFI_SUCCESS@GOTPCREL(%rip), %rax
	cmpq	(%rax), %r13
	jne	LBB0_3
## %bb.4:
	movq	-48(%rbp), %rdx                 ## 8-byte Reload
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	movq	(%rax), %rax
	movq	-56(%rbp), %rcx                 ## 8-byte Reload
	addq	(%rcx), %rax
	movq	_ZIMAGE_OFFSET_LIMIT@GOTPCREL(%rip), %rcx
	addq	(%rcx), %rbx
	cmpq	%rbx, %rax
	jbe	LBB0_6
## %bb.5:
	leaq	L_.str.2(%rip), %rsi
	movq	%rdx, %rbx
	movq	%rdx, %rdi
	callq	_pr_efi_err
	movq	(%r14), %rsi
	movq	(%r15), %rdx
	movq	%rbx, %rdi
	callq	_efi_free
	movq	$0, (%r14)
	movq	-64(%rbp), %r14                 ## 8-byte Reload
	movq	(%r14), %rsi
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movq	(%rax), %rdx
	movq	%rbx, %rdi
	callq	_efi_free
	movq	$0, (%r14)
	movq	_EFI_LOAD_ERROR@GOTPCREL(%rip), %rax
	movq	(%rax), %r13
	jmp	LBB0_6
LBB0_1:
	leaq	L_.str(%rip), %rsi
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_pr_efi_err
	jmp	LBB0_6
LBB0_3:
	leaq	L_.str.1(%rip), %rsi
	movq	-48(%rbp), %rbx                 ## 8-byte Reload
	movq	%rbx, %rdi
	callq	_pr_efi_err
	movq	(%r14), %rsi
	movq	(%r15), %rdx
	movq	%rbx, %rdi
	callq	_efi_free
	movq	$0, (%r14)
LBB0_6:
	movq	%r13, %rax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_SZ_128M,4,2                    ## @SZ_128M
	.comm	_TEXT_OFFSET,4,2                ## @TEXT_OFFSET
	.comm	_PAGE_SIZE,4,2                  ## @PAGE_SIZE
	.comm	_EFI_SUCCESS,8,3                ## @EFI_SUCCESS
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Unable to allocate memory for uncompressed kernel.\n"

	.comm	_MAX_UNCOMP_KERNEL_SIZE,8,3     ## @MAX_UNCOMP_KERNEL_SIZE
L_.str.1:                               ## @.str.1
	.asciz	"Failed to relocate kernel.\n"

	.comm	_ZIMAGE_OFFSET_LIMIT,8,3        ## @ZIMAGE_OFFSET_LIMIT
L_.str.2:                               ## @.str.2
	.asciz	"Failed to relocate kernel, no low memory available.\n"

	.comm	_EFI_LOAD_ERROR,8,3             ## @EFI_LOAD_ERROR
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_handle_kernel_image            ; -- Begin function handle_kernel_image
	.p2align	2
_handle_kernel_image:                   ; @handle_kernel_image
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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	x26, x6
	mov	x24, x5
	mov	x19, x4
	mov	x22, x3
	mov	x21, x2
	mov	x23, x1
	mov	x20, x0
Lloh0:
	adrp	x8, _SZ_128M@GOTPAGE
Lloh1:
	ldr	x8, [x8, _SZ_128M@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	mov	x0, x5
	bl	_round_up
Lloh3:
	adrp	x8, _TEXT_OFFSET@GOTPAGE
Lloh4:
	ldr	x8, [x8, _TEXT_OFFSET@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
Lloh6:
	adrp	x9, _PAGE_SIZE@GOTPAGE
Lloh7:
	ldr	x9, [x9, _PAGE_SIZE@GOTPAGEOFF]
Lloh8:
	ldr	w9, [x9]
	add	w9, w9, w9, lsl #2
	sub	w8, w8, w9
	add	x27, x0, w8, sxtw
	mov	x0, x20
	mov	x1, x27
	mov	x2, x22
	mov	x3, x19
	bl	_reserve_kernel_base
Lloh9:
	adrp	x28, _EFI_SUCCESS@GOTPAGE
Lloh10:
	ldr	x28, [x28, _EFI_SUCCESS@GOTPAGEOFF]
	ldr	x8, [x28]
	cmp	x0, x8
	b.ne	LBB0_4
; %bb.1:
	ldr	x2, [x26]
	str	x2, [x21]
Lloh11:
	adrp	x8, _MAX_UNCOMP_KERNEL_SIZE@GOTPAGE
Lloh12:
	ldr	x8, [x8, _MAX_UNCOMP_KERNEL_SIZE@GOTPAGEOFF]
Lloh13:
	ldr	x8, [x8]
	add	x4, x8, x27
	mov	x0, x20
	mov	x1, x23
	mov	x3, x2
	mov	w5, #0
	mov	w6, #0
	bl	_efi_relocate_kernel
	mov	x25, x0
	ldr	x8, [x28]
	cmp	x0, x8
	b.ne	LBB0_5
; %bb.2:
	ldr	x8, [x23]
	ldr	x9, [x21]
	add	x8, x9, x8
Lloh14:
	adrp	x9, _ZIMAGE_OFFSET_LIMIT@GOTPAGE
Lloh15:
	ldr	x9, [x9, _ZIMAGE_OFFSET_LIMIT@GOTPAGEOFF]
Lloh16:
	ldr	x9, [x9]
	add	x9, x9, x24
	cmp	x8, x9
	b.ls	LBB0_6
; %bb.3:
Lloh17:
	adrp	x1, l_.str.2@PAGE
Lloh18:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	x0, x20
	bl	_pr_efi_err
	ldr	x1, [x19]
	ldr	x2, [x22]
	mov	x0, x20
	bl	_efi_free
	str	xzr, [x19]
	ldr	x1, [x21]
	ldr	x2, [x23]
	mov	x0, x20
	bl	_efi_free
	str	xzr, [x21]
Lloh19:
	adrp	x8, _EFI_LOAD_ERROR@GOTPAGE
Lloh20:
	ldr	x8, [x8, _EFI_LOAD_ERROR@GOTPAGEOFF]
Lloh21:
	ldr	x25, [x8]
	b	LBB0_6
LBB0_4:
	mov	x25, x0
Lloh22:
	adrp	x1, l_.str@PAGE
Lloh23:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x20
	bl	_pr_efi_err
	b	LBB0_6
LBB0_5:
Lloh24:
	adrp	x1, l_.str.1@PAGE
Lloh25:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x20
	bl	_pr_efi_err
	ldr	x1, [x19]
	ldr	x2, [x22]
	mov	x0, x20
	bl	_efi_free
	str	xzr, [x19]
LBB0_6:
	mov	x0, x25
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpAdd	Lloh17, Lloh18
	.loh AdrpAdd	Lloh22, Lloh23
	.loh AdrpAdd	Lloh24, Lloh25
	.cfi_endproc
                                        ; -- End function
	.comm	_SZ_128M,4,2                    ; @SZ_128M
	.comm	_TEXT_OFFSET,4,2                ; @TEXT_OFFSET
	.comm	_PAGE_SIZE,4,2                  ; @PAGE_SIZE
	.comm	_EFI_SUCCESS,8,3                ; @EFI_SUCCESS
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Unable to allocate memory for uncompressed kernel.\n"

	.comm	_MAX_UNCOMP_KERNEL_SIZE,8,3     ; @MAX_UNCOMP_KERNEL_SIZE
l_.str.1:                               ; @.str.1
	.asciz	"Failed to relocate kernel.\n"

	.comm	_ZIMAGE_OFFSET_LIMIT,8,3        ; @ZIMAGE_OFFSET_LIMIT
l_.str.2:                               ; @.str.2
	.asciz	"Failed to relocate kernel, no low memory available.\n"

	.comm	_EFI_LOAD_ERROR,8,3             ; @EFI_LOAD_ERROR
.subsections_via_symbols
