	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function InitInsert
_InitInsert:                            ## @InitInsert
	.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	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movslq	(%rdi), %r14
	movq	_CARTRIDGE_NONE@GOTPCREL(%rip), %r12
	cmpl	(%r12), %r14d
	je	LBB0_6
## %bb.1:
	movq	%rdi, %rbx
	movl	4(%rdi), %edi
	movq	%rbx, %rsi
	callq	_InsertCartridge
	movl	%eax, %r15d
	testl	%eax, %eax
	js	LBB0_3
## %bb.2:
	movl	(%rbx), %eax
	jmp	LBB0_4
LBB0_3:
	movq	_CARTRIDGE_CANT_OPEN@GOTPCREL(%rip), %rax
	movq	_CARTRIDGE_BAD_FORMAT@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %r15d
	leaq	L_.str.2(%rip), %rcx
	leaq	L_.str.3(%rip), %rdi
	cmoveq	%rcx, %rdi
	cmpl	(%rax), %r15d
	movl	4(%rbx), %esi
	leaq	L_.str.1(%rip), %rdx
	cmovneq	%rdi, %rdx
	leaq	L_.str(%rip), %rdi
	callq	_Log_print
	movl	(%r12), %eax
	movl	%eax, (%rbx)
LBB0_4:
	movq	_CARTRIDGE_UNKNOWN@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jne	LBB0_6
## %bb.5:
	movq	_CARTRIDGE_kb@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpl	%r15d, (%rax,%r14,4)
	jne	LBB0_6
## %bb.7:
	movq	%rbx, %rdi
	movl	%r14d, %esi
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_CARTRIDGE_SetType              ## TAILCALL
LBB0_6:
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_CARTRIDGE_NONE,4,2             ## @CARTRIDGE_NONE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Error inserting cartridge \"%s\": %s"

	.comm	_CARTRIDGE_CANT_OPEN,4,2        ## @CARTRIDGE_CANT_OPEN
L_.str.1:                               ## @.str.1
	.asciz	"Can't open file"

	.comm	_CARTRIDGE_BAD_FORMAT,4,2       ## @CARTRIDGE_BAD_FORMAT
L_.str.2:                               ## @.str.2
	.asciz	"Bad format"

L_.str.3:                               ## @.str.3
	.asciz	"Bad checksum"

	.comm	_CARTRIDGE_UNKNOWN,4,2          ## @CARTRIDGE_UNKNOWN
	.comm	_CARTRIDGE_kb,8,3               ## @CARTRIDGE_kb
	.no_dead_strip	_InitInsert
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function InitInsert
_InitInsert:                            ; @InitInsert
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.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
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	ldrsw	x19, [x0]
Lloh0:
	adrp	x22, _CARTRIDGE_NONE@GOTPAGE
Lloh1:
	ldr	x22, [x22, _CARTRIDGE_NONE@GOTPAGEOFF]
	ldr	w8, [x22]
	cmp	w19, w8
	b.eq	LBB0_7
; %bb.1:
	mov	x20, x0
	ldr	w0, [x0, #4]
	mov	x1, x20
	bl	_InsertCartridge
	mov	x21, x0
	tbnz	w0, #31, LBB0_3
; %bb.2:
	ldr	w8, [x20]
	b	LBB0_4
LBB0_3:
	ldr	w1, [x20, #4]
Lloh2:
	adrp	x8, _CARTRIDGE_CANT_OPEN@GOTPAGE
Lloh3:
	ldr	x8, [x8, _CARTRIDGE_CANT_OPEN@GOTPAGEOFF]
Lloh4:
	adrp	x9, _CARTRIDGE_BAD_FORMAT@GOTPAGE
Lloh5:
	ldr	x9, [x9, _CARTRIDGE_BAD_FORMAT@GOTPAGEOFF]
Lloh6:
	ldr	w8, [x8]
Lloh7:
	ldr	w9, [x9]
Lloh8:
	adrp	x10, l_.str.3@PAGE
Lloh9:
	add	x10, x10, l_.str.3@PAGEOFF
Lloh10:
	adrp	x11, l_.str.2@PAGE
Lloh11:
	add	x11, x11, l_.str.2@PAGEOFF
	cmp	w21, w9
	csel	x9, x11, x10, eq
Lloh12:
	adrp	x10, l_.str.1@PAGE
Lloh13:
	add	x10, x10, l_.str.1@PAGEOFF
	cmp	w21, w8
	csel	x2, x10, x9, eq
Lloh14:
	adrp	x0, l_.str@PAGE
Lloh15:
	add	x0, x0, l_.str@PAGEOFF
	bl	_Log_print
	ldr	w8, [x22]
	str	w8, [x20]
LBB0_4:
Lloh16:
	adrp	x9, _CARTRIDGE_UNKNOWN@GOTPAGE
Lloh17:
	ldr	x9, [x9, _CARTRIDGE_UNKNOWN@GOTPAGEOFF]
Lloh18:
	ldr	w9, [x9]
	cmp	w8, w9
	b.ne	LBB0_7
; %bb.5:
Lloh19:
	adrp	x8, _CARTRIDGE_kb@GOTPAGE
Lloh20:
	ldr	x8, [x8, _CARTRIDGE_kb@GOTPAGEOFF]
Lloh21:
	ldr	x8, [x8]
	ldr	w8, [x8, x19, lsl #2]
	cmp	w8, w21
	b.ne	LBB0_7
; %bb.6:
	mov	x0, x20
	mov	x1, x19
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	b	_CARTRIDGE_SetType
LBB0_7:
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh7
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh6
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.cfi_endproc
                                        ; -- End function
	.comm	_CARTRIDGE_NONE,4,2             ; @CARTRIDGE_NONE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Error inserting cartridge \"%s\": %s"

	.comm	_CARTRIDGE_CANT_OPEN,4,2        ; @CARTRIDGE_CANT_OPEN
l_.str.1:                               ; @.str.1
	.asciz	"Can't open file"

	.comm	_CARTRIDGE_BAD_FORMAT,4,2       ; @CARTRIDGE_BAD_FORMAT
l_.str.2:                               ; @.str.2
	.asciz	"Bad format"

l_.str.3:                               ; @.str.3
	.asciz	"Bad checksum"

	.comm	_CARTRIDGE_UNKNOWN,4,2          ; @CARTRIDGE_UNKNOWN
	.comm	_CARTRIDGE_kb,8,3               ; @CARTRIDGE_kb
	.no_dead_strip	_InitInsert
.subsections_via_symbols
