	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function cpc_tty_open
_cpc_tty_open:                          ## @cpc_tty_open
	.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
	testq	%rdi, %rdi
	je	LBB0_1
## %bb.2:
	movq	%rdi, %r15
	movl	(%rdi), %edx
	testl	%edx, %edx
	js	LBB0_4
## %bb.3:
	movq	_CPC_TTY_NPORTS@GOTPCREL(%rip), %rax
	cmpl	(%rax), %edx
	jge	LBB0_4
## %bb.6:
	movq	_cpc_tty_area@GOTPCREL(%rip), %r13
	movq	(%r13), %r14
	movq	%rdx, %rbx
	shlq	$6, %rbx
	movq	(%r14,%rbx), %rax
	movq	_CPC_TTY_ST_IDLE@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_8
## %bb.7:
	movl	8(%r14,%rbx), %esi
	leaq	L_.str.1(%rip), %rdi
	xorl	%ebx, %ebx
                                        ## kill: def $edx killed $edx killed $rdx
	xorl	%eax, %eax
	callq	_CPC_TTY_DBG
	jmp	LBB0_5
LBB0_1:
	movq	_ENODEV@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_18
LBB0_4:
	leaq	L_.str(%rip), %rdi
	xorl	%ebx, %ebx
	movl	%edx, %esi
	xorl	%eax, %eax
	callq	_CPC_TTY_DBG
LBB0_5:
	movq	_ENODEV@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	jmp	LBB0_18
LBB0_8:
	leaq	(%r14,%rbx), %r12
	addq	$16, %r12
	movq	16(%r14,%rbx), %rax
	testq	%rax, %rax
	jne	LBB0_17
## %bb.9:
	cmpq	$0, 56(%r14,%rbx)
	movq	%r14, %rcx
	jne	LBB0_12
## %bb.10:
	movq	_CPC_TTY_MAX_MTU@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_kmalloc
	movq	(%r13), %rcx
	movq	%rax, 56(%rcx,%rbx)
	testq	%rax, %rax
	je	LBB0_11
LBB0_12:
	movq	48(%rcx,%rbx), %rdi
	testq	%rdi, %rdi
	je	LBB0_16
## %bb.13:
	leaq	(%rcx,%rbx), %rax
	addq	$48, %rax
	.p2align	4, 0x90
LBB0_14:                                ## =>This Inner Loop Header: Depth=1
	movq	(%rdi), %rcx
	movq	%rcx, (%rax)
	callq	_kfree
	movq	(%r13), %rcx
	leaq	(%rcx,%rbx), %rax
	addq	$48, %rax
	movq	48(%rcx,%rbx), %rdi
	testq	%rdi, %rdi
	jne	LBB0_14
## %bb.15:
	movq	$0, (%rax)
	movq	(%r13), %rax
	movq	$0, 40(%rax,%rbx)
	movq	(%r13), %rcx
LBB0_16:
	movq	_CPC_TTY_ST_OPEN@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, (%rcx,%rbx)
	movq	%r15, 32(%rcx,%rbx)
	movq	(%r13), %rax
	addq	%rbx, %rax
	movq	%rax, 8(%r15)
	movl	24(%r14,%rbx), %edi
	movq	_CTL_DTR@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_cpc_tty_signal_on
	movq	(%r12), %rax
LBB0_17:
	incq	%rax
	movq	%rax, (%r12)
	movl	8(%r14,%rbx), %esi
	leaq	L_.str.3(%rip), %rdi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_CPC_TTY_DBG
LBB0_18:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_11:
	movl	8(%r14,%rbx), %esi
	leaq	L_.str.2(%rip), %rdi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_CPC_TTY_DBG
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	jmp	LBB0_18
	.cfi_endproc
                                        ## -- End function
	.comm	_ENODEV,4,2                     ## @ENODEV
	.comm	_CPC_TTY_NPORTS,4,2             ## @CPC_TTY_NPORTS
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"pc300_tty: open invalid port %d\n"

	.comm	_cpc_tty_area,8,3               ## @cpc_tty_area
	.comm	_CPC_TTY_ST_IDLE,8,3            ## @CPC_TTY_ST_IDLE
L_.str.1:                               ## @.str.1
	.asciz	"%s: open - invalid interface, port=%d\n"

	.comm	_CPC_TTY_MAX_MTU,4,2            ## @CPC_TTY_MAX_MTU
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
L_.str.2:                               ## @.str.2
	.asciz	"%s: error in memory allocation\n"

	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_CPC_TTY_ST_OPEN,8,3            ## @CPC_TTY_ST_OPEN
	.comm	_CTL_DTR,4,2                    ## @CTL_DTR
L_.str.3:                               ## @.str.3
	.asciz	"%s: opening TTY driver\n"

	.no_dead_strip	_cpc_tty_open
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function cpc_tty_open
_cpc_tty_open:                          ; @cpc_tty_open
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #96
	.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
	cbz	x0, LBB0_7
; %bb.1:
	mov	x19, x0
	ldr	w20, [x0]
	tbnz	w20, #31, LBB0_5
; %bb.2:
Lloh0:
	adrp	x8, _CPC_TTY_NPORTS@GOTPAGE
Lloh1:
	ldr	x8, [x8, _CPC_TTY_NPORTS@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	cmp	w20, w8
	b.ge	LBB0_5
; %bb.3:
Lloh3:
	adrp	x25, _cpc_tty_area@GOTPAGE
Lloh4:
	ldr	x25, [x25, _cpc_tty_area@GOTPAGEOFF]
	ldr	x23, [x25]
	lsl	x24, x20, #6
	ldr	x8, [x23, x24]
Lloh5:
	adrp	x9, _CPC_TTY_ST_IDLE@GOTPAGE
Lloh6:
	ldr	x9, [x9, _CPC_TTY_ST_IDLE@GOTPAGEOFF]
Lloh7:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_10
; %bb.4:
	add	x8, x23, x20, lsl #6
	ldr	w1, [x8, #8]
	str	x20, [sp]
Lloh8:
	adrp	x0, l_.str.1@PAGE
Lloh9:
	add	x0, x0, l_.str.1@PAGEOFF
	b	LBB0_6
LBB0_5:
Lloh10:
	adrp	x0, l_.str@PAGE
Lloh11:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x20
LBB0_6:
	bl	_CPC_TTY_DBG
LBB0_7:
Lloh12:
	adrp	x8, _ENODEV@GOTPAGE
Lloh13:
	ldr	x8, [x8, _ENODEV@GOTPAGEOFF]
LBB0_8:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_9:
	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
	add	sp, sp, #96
	ret
LBB0_10:
	add	x21, x23, x20, lsl #6
	mov	x22, x21
	ldr	x8, [x22, #16]!
	cbnz	x8, LBB0_17
; %bb.11:
	ldr	x8, [x21, #56]
	mov	x9, x23
	cbnz	x8, LBB0_13
; %bb.12:
Lloh14:
	adrp	x8, _CPC_TTY_MAX_MTU@GOTPAGE
Lloh15:
	ldr	x8, [x8, _CPC_TTY_MAX_MTU@GOTPAGEOFF]
Lloh16:
	ldr	w0, [x8]
Lloh17:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh18:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh19:
	ldr	w1, [x8]
	bl	_kmalloc
	ldr	x9, [x25]
	add	x8, x9, x20, lsl #6
	str	x0, [x8, #56]
	cbz	x0, LBB0_18
LBB0_13:
	add	x8, x9, x20, lsl #6
	ldr	x0, [x8, #48]!
	cbz	x0, LBB0_16
LBB0_14:                                ; =>This Inner Loop Header: Depth=1
	ldr	x9, [x0]
	str	x9, [x8]
	bl	_kfree
	ldr	x8, [x25]
	add	x8, x8, x20, lsl #6
	ldr	x0, [x8, #48]!
	cbnz	x0, LBB0_14
; %bb.15:
	str	xzr, [x8]
	ldr	x8, [x25]
	add	x8, x8, x20, lsl #6
	str	xzr, [x8, #40]
	ldr	x9, [x25]
LBB0_16:
Lloh20:
	adrp	x8, _CPC_TTY_ST_OPEN@GOTPAGE
Lloh21:
	ldr	x8, [x8, _CPC_TTY_ST_OPEN@GOTPAGEOFF]
Lloh22:
	ldr	x8, [x8]
	add	x9, x9, x24
	str	x8, [x9]
	str	x19, [x9, #32]
	ldr	x8, [x25]
	add	x8, x8, x24
	str	x8, [x19, #8]
	add	x8, x23, x24
	ldr	w0, [x8, #24]
Lloh23:
	adrp	x8, _CTL_DTR@GOTPAGE
Lloh24:
	ldr	x8, [x8, _CTL_DTR@GOTPAGEOFF]
Lloh25:
	ldr	w1, [x8]
	bl	_cpc_tty_signal_on
	ldr	x8, [x22]
LBB0_17:
	add	x8, x8, #1
	str	x8, [x22]
	ldr	w1, [x21, #8]
Lloh26:
	adrp	x0, l_.str.3@PAGE
Lloh27:
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_CPC_TTY_DBG
	mov	w0, #0
	b	LBB0_9
LBB0_18:
	add	x8, x23, x20, lsl #6
	ldr	w1, [x8, #8]
Lloh28:
	adrp	x0, l_.str.2@PAGE
Lloh29:
	add	x0, x0, l_.str.2@PAGEOFF
	bl	_CPC_TTY_DBG
Lloh30:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh31:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
	b	LBB0_8
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpAdd	Lloh26, Lloh27
	.loh AdrpLdrGot	Lloh30, Lloh31
	.loh AdrpAdd	Lloh28, Lloh29
	.cfi_endproc
                                        ; -- End function
	.comm	_ENODEV,4,2                     ; @ENODEV
	.comm	_CPC_TTY_NPORTS,4,2             ; @CPC_TTY_NPORTS
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"pc300_tty: open invalid port %d\n"

	.comm	_cpc_tty_area,8,3               ; @cpc_tty_area
	.comm	_CPC_TTY_ST_IDLE,8,3            ; @CPC_TTY_ST_IDLE
l_.str.1:                               ; @.str.1
	.asciz	"%s: open - invalid interface, port=%d\n"

	.comm	_CPC_TTY_MAX_MTU,4,2            ; @CPC_TTY_MAX_MTU
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
l_.str.2:                               ; @.str.2
	.asciz	"%s: error in memory allocation\n"

	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_CPC_TTY_ST_OPEN,8,3            ; @CPC_TTY_ST_OPEN
	.comm	_CTL_DTR,4,2                    ; @CTL_DTR
l_.str.3:                               ; @.str.3
	.asciz	"%s: opening TTY driver\n"

	.no_dead_strip	_cpc_tty_open
.subsections_via_symbols
