	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_BINLOAD_Loader                 ## -- Begin function BINLOAD_Loader
	.p2align	4, 0x90
_BINLOAD_Loader:                        ## @BINLOAD_Loader
	.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
	subq	$16, %rsp
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	movq	%rdi, %r14
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, -24(%rbp)
	movq	_BINLOAD_bin_file@GOTPCREL(%rip), %rbx
	movq	(%rbx), %rdi
	testq	%rdi, %rdi
	je	LBB0_2
## %bb.1:
	callq	_fclose
	movq	$0, (%rbx)
	movq	_BINLOAD_loading_basic@GOTPCREL(%rip), %rax
	movq	$0, (%rax)
LBB0_2:
	movq	_Atari800_machine_type@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	_Atari800_MACHINE_5200@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_4
## %bb.3:
	leaq	L_.str(%rip), %rdi
	xorl	%eax, %eax
	callq	_Log_print
	jmp	LBB0_19
LBB0_4:
	leaq	L_.str.1(%rip), %rsi
	movq	%r14, %rdi
	callq	_fopen
	movq	%rax, (%rbx)
	testq	%rax, %rax
	je	LBB0_5
## %bb.6:
	movq	_SIO_drive_status@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movq	(%rcx), %rcx
	movq	_SIO_NO_DISK@GOTPCREL(%rip), %rdx
	cmpq	(%rdx), %rcx
	jne	LBB0_8
## %bb.7:
	movl	$1, %edi
	callq	_SIO_DisableDrive
	movq	(%rbx), %rax
LBB0_8:
	leaq	-32(%rbp), %rdi
	movl	$1, %esi
	movl	$2, %edx
	movq	%rax, %rcx
	callq	_fread
	cmpl	$2, %eax
	jne	LBB0_17
## %bb.9:
	movl	-32(%rbp), %eax
	movl	-28(%rbp), %ecx
	cmpl	$255, %eax
	jne	LBB0_12
## %bb.10:
	cmpl	$255, %ecx
	jne	LBB0_12
## %bb.11:
	movq	_TRUE@GOTPCREL(%rip), %rbx
	movl	(%rbx), %eax
	movq	_BINLOAD_start_binloading@GOTPCREL(%rip), %rcx
	movl	%eax, (%rcx)
	xorl	%eax, %eax
	callq	_Atari800_Coldstart
	jmp	LBB0_20
LBB0_5:
	leaq	L_.str.2(%rip), %rdi
	jmp	LBB0_18
LBB0_12:
	orl	%eax, %ecx
	jne	LBB0_15
## %bb.13:
	movq	_BINLOAD_LOADING_BASIC_SAVED@GOTPCREL(%rip), %rax
	jmp	LBB0_14
LBB0_15:
	addl	$-48, %eax
	cmpl	$9, %eax
	ja	LBB0_17
## %bb.16:
	movq	_BINLOAD_LOADING_BASIC_LISTED@GOTPCREL(%rip), %rax
LBB0_14:
	movq	(%rax), %rax
	movq	_BINLOAD_loading_basic@GOTPCREL(%rip), %rcx
	movq	%rax, (%rcx)
	xorl	%eax, %eax
	callq	_ESC_UpdatePatches
	xorl	%eax, %eax
	callq	_Atari800_Coldstart
	movq	_TRUE@GOTPCREL(%rip), %rbx
	jmp	LBB0_20
LBB0_17:
	movq	(%rbx), %rdi
	callq	_fclose
	movq	$0, (%rbx)
	leaq	L_.str.3(%rip), %rdi
LBB0_18:
	movq	%r14, %rsi
	xorl	%eax, %eax
	callq	_Log_print
LBB0_19:
	movq	_FALSE@GOTPCREL(%rip), %rbx
LBB0_20:
	movl	(%rbx), %eax
	movq	___stack_chk_guard@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	cmpq	-24(%rbp), %rcx
	jne	LBB0_22
## %bb.21:
	addq	$16, %rsp
	popq	%rbx
	popq	%r14
	popq	%rbp
	retq
LBB0_22:
	callq	___stack_chk_fail
	.cfi_endproc
                                        ## -- End function
	.comm	_BINLOAD_bin_file,8,3           ## @BINLOAD_bin_file
	.comm	_BINLOAD_loading_basic,8,3      ## @BINLOAD_loading_basic
	.comm	_Atari800_machine_type,8,3      ## @Atari800_machine_type
	.comm	_Atari800_MACHINE_5200,8,3      ## @Atari800_MACHINE_5200
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"binload: can't run Atari programs directly on the 5200"

	.comm	_FALSE,4,2                      ## @FALSE
L_.str.1:                               ## @.str.1
	.asciz	"rb"

L_.str.2:                               ## @.str.2
	.asciz	"binload: can't open \"%s\""

	.comm	_SIO_drive_status,8,3           ## @SIO_drive_status
	.comm	_SIO_NO_DISK,8,3                ## @SIO_NO_DISK
	.comm	_TRUE,4,2                       ## @TRUE
	.comm	_BINLOAD_start_binloading,4,2   ## @BINLOAD_start_binloading
	.comm	_BINLOAD_LOADING_BASIC_SAVED,8,3 ## @BINLOAD_LOADING_BASIC_SAVED
	.comm	_BINLOAD_LOADING_BASIC_LISTED,8,3 ## @BINLOAD_LOADING_BASIC_LISTED
L_.str.3:                               ## @.str.3
	.asciz	"binload: \"%s\" not recognized as a DOS or BASIC program"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_BINLOAD_Loader                 ; -- Begin function BINLOAD_Loader
	.p2align	2
_BINLOAD_Loader:                        ; @BINLOAD_Loader
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #64
	.cfi_def_cfa_offset 64
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	mov	x19, x0
Lloh0:
	adrp	x8, ___stack_chk_guard@GOTPAGE
Lloh1:
	ldr	x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	str	x8, [sp, #24]
Lloh3:
	adrp	x20, _BINLOAD_bin_file@GOTPAGE
Lloh4:
	ldr	x20, [x20, _BINLOAD_bin_file@GOTPAGEOFF]
	ldr	x0, [x20]
	cbz	x0, LBB0_2
; %bb.1:
	bl	_fclose
	str	xzr, [x20]
Lloh5:
	adrp	x8, _BINLOAD_loading_basic@GOTPAGE
Lloh6:
	ldr	x8, [x8, _BINLOAD_loading_basic@GOTPAGEOFF]
Lloh7:
	str	xzr, [x8]
LBB0_2:
Lloh8:
	adrp	x8, _Atari800_machine_type@GOTPAGE
Lloh9:
	ldr	x8, [x8, _Atari800_machine_type@GOTPAGEOFF]
Lloh10:
	ldr	x8, [x8]
Lloh11:
	adrp	x9, _Atari800_MACHINE_5200@GOTPAGE
Lloh12:
	ldr	x9, [x9, _Atari800_MACHINE_5200@GOTPAGEOFF]
Lloh13:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_4
; %bb.3:
Lloh14:
	adrp	x0, l_.str@PAGE
Lloh15:
	add	x0, x0, l_.str@PAGEOFF
	b	LBB0_18
LBB0_4:
Lloh16:
	adrp	x1, l_.str.1@PAGE
Lloh17:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x19
	bl	_fopen
	str	x0, [x20]
	cbz	x0, LBB0_11
; %bb.5:
	mov	x3, x0
Lloh18:
	adrp	x8, _SIO_drive_status@GOTPAGE
Lloh19:
	ldr	x8, [x8, _SIO_drive_status@GOTPAGEOFF]
Lloh20:
	ldr	x8, [x8]
	ldr	x8, [x8]
Lloh21:
	adrp	x9, _SIO_NO_DISK@GOTPAGE
Lloh22:
	ldr	x9, [x9, _SIO_NO_DISK@GOTPAGEOFF]
Lloh23:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_7
; %bb.6:
	mov	w0, #1
	bl	_SIO_DisableDrive
	ldr	x3, [x20]
LBB0_7:
	add	x0, sp, #16
	mov	w1, #1
	mov	w2, #2
	bl	_fread
	cmp	w0, #2
	b.ne	LBB0_17
; %bb.8:
	ldp	w8, w9, [sp, #16]
	cmp	w8, #255
	b.ne	LBB0_12
; %bb.9:
	cmp	w9, #255
	b.ne	LBB0_12
; %bb.10:
Lloh24:
	adrp	x19, _TRUE@GOTPAGE
Lloh25:
	ldr	x19, [x19, _TRUE@GOTPAGEOFF]
	ldr	w8, [x19]
Lloh26:
	adrp	x9, _BINLOAD_start_binloading@GOTPAGE
Lloh27:
	ldr	x9, [x9, _BINLOAD_start_binloading@GOTPAGEOFF]
Lloh28:
	str	w8, [x9]
	bl	_Atari800_Coldstart
	b	LBB0_19
LBB0_11:
	str	x19, [sp]
Lloh29:
	adrp	x0, l_.str.2@PAGE
Lloh30:
	add	x0, x0, l_.str.2@PAGEOFF
	b	LBB0_18
LBB0_12:
	orr	w9, w8, w9
	cbnz	w9, LBB0_14
; %bb.13:
Lloh31:
	adrp	x8, _BINLOAD_LOADING_BASIC_SAVED@GOTPAGE
Lloh32:
	ldr	x8, [x8, _BINLOAD_LOADING_BASIC_SAVED@GOTPAGEOFF]
	b	LBB0_16
LBB0_14:
	sub	w8, w8, #48
	cmp	w8, #9
	b.hi	LBB0_17
; %bb.15:
Lloh33:
	adrp	x8, _BINLOAD_LOADING_BASIC_LISTED@GOTPAGE
Lloh34:
	ldr	x8, [x8, _BINLOAD_LOADING_BASIC_LISTED@GOTPAGEOFF]
LBB0_16:
	ldr	x8, [x8]
Lloh35:
	adrp	x9, _BINLOAD_loading_basic@GOTPAGE
Lloh36:
	ldr	x9, [x9, _BINLOAD_loading_basic@GOTPAGEOFF]
Lloh37:
	str	x8, [x9]
	bl	_ESC_UpdatePatches
	bl	_Atari800_Coldstart
Lloh38:
	adrp	x19, _TRUE@GOTPAGE
Lloh39:
	ldr	x19, [x19, _TRUE@GOTPAGEOFF]
	b	LBB0_19
LBB0_17:
	ldr	x0, [x20]
	bl	_fclose
	str	xzr, [x20]
	str	x19, [sp]
Lloh40:
	adrp	x0, l_.str.3@PAGE
Lloh41:
	add	x0, x0, l_.str.3@PAGEOFF
LBB0_18:
	bl	_Log_print
Lloh42:
	adrp	x19, _FALSE@GOTPAGE
Lloh43:
	ldr	x19, [x19, _FALSE@GOTPAGEOFF]
LBB0_19:
	ldr	w0, [x19]
	ldr	x8, [sp, #24]
Lloh44:
	adrp	x9, ___stack_chk_guard@GOTPAGE
Lloh45:
	ldr	x9, [x9, ___stack_chk_guard@GOTPAGEOFF]
Lloh46:
	ldr	x9, [x9]
	cmp	x9, x8
	b.ne	LBB0_21
; %bb.20:
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #64
	ret
LBB0_21:
	bl	___stack_chk_fail
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotStr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpAdd	Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotStr	Lloh26, Lloh27, Lloh28
	.loh AdrpLdrGot	Lloh24, Lloh25
	.loh AdrpAdd	Lloh29, Lloh30
	.loh AdrpLdrGot	Lloh31, Lloh32
	.loh AdrpLdrGot	Lloh33, Lloh34
	.loh AdrpLdrGot	Lloh38, Lloh39
	.loh AdrpLdrGotStr	Lloh35, Lloh36, Lloh37
	.loh AdrpAdd	Lloh40, Lloh41
	.loh AdrpLdrGot	Lloh42, Lloh43
	.loh AdrpLdrGotLdr	Lloh44, Lloh45, Lloh46
	.cfi_endproc
                                        ; -- End function
	.comm	_BINLOAD_bin_file,8,3           ; @BINLOAD_bin_file
	.comm	_BINLOAD_loading_basic,8,3      ; @BINLOAD_loading_basic
	.comm	_Atari800_machine_type,8,3      ; @Atari800_machine_type
	.comm	_Atari800_MACHINE_5200,8,3      ; @Atari800_MACHINE_5200
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"binload: can't run Atari programs directly on the 5200"

	.comm	_FALSE,4,2                      ; @FALSE
l_.str.1:                               ; @.str.1
	.asciz	"rb"

l_.str.2:                               ; @.str.2
	.asciz	"binload: can't open \"%s\""

	.comm	_SIO_drive_status,8,3           ; @SIO_drive_status
	.comm	_SIO_NO_DISK,8,3                ; @SIO_NO_DISK
	.comm	_TRUE,4,2                       ; @TRUE
	.comm	_BINLOAD_start_binloading,4,2   ; @BINLOAD_start_binloading
	.comm	_BINLOAD_LOADING_BASIC_SAVED,8,3 ; @BINLOAD_LOADING_BASIC_SAVED
	.comm	_BINLOAD_LOADING_BASIC_LISTED,8,3 ; @BINLOAD_LOADING_BASIC_LISTED
l_.str.3:                               ; @.str.3
	.asciz	"binload: \"%s\" not recognized as a DOS or BASIC program"

.subsections_via_symbols
