	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mips_readchar
_mips_readchar:                         ## @mips_readchar
	.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
	movl	%edi, %r15d
	movq	_mips_monitor_prompt@GOTPCREL(%rip), %r12
	movq	(%r12), %rdi
	callq	_strlen
	movl	%eax, %r14d
	cmpl	%eax, _mips_readchar.state(%rip)
	movl	$1, %ebx
	cmovnel	%r15d, %ebx
	movq	_mips_desc@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	%ebx, %esi
	callq	_serial_readchar
	movl	%eax, %r15d
	movq	_SERIAL_TIMEOUT@GOTPCREL(%rip), %r13
	cmpl	$-1, %ebx
	jne	LBB0_3
## %bb.1:
	cmpl	(%r13), %r15d
	jne	LBB0_3
## %bb.2:
	xorl	%eax, %eax
	callq	_target_mourn_inferior
	leaq	L_.str(%rip), %rdi
	callq	_error
LBB0_3:
	movq	_SERIAL_EOF@GOTPCREL(%rip), %rax
	cmpl	(%rax), %r15d
	jne	LBB0_5
## %bb.4:
	leaq	L_.str.1(%rip), %rdi
	xorl	%eax, %eax
	callq	_mips_error
LBB0_5:
	movq	_SERIAL_ERROR@GOTPCREL(%rip), %rax
	cmpl	(%rax), %r15d
	jne	LBB0_7
## %bb.6:
	movq	_errno@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_safe_strerror
	leaq	L_.str.2(%rip), %rdi
	movl	%eax, %esi
	xorl	%eax, %eax
	callq	_mips_error
LBB0_7:
	movq	_remote_debug@GOTPCREL(%rip), %rbx
	cmpl	$2, (%rbx)
	jl	LBB0_11
## %bb.8:
	movq	_gdb_stdlog@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	cmpl	(%r13), %r15d
	jne	LBB0_9
## %bb.10:
	leaq	L_.str.4(%rip), %rsi
	xorl	%eax, %eax
	callq	_fprintf_unfiltered
LBB0_11:
	cmpl	$64, %r15d
	jne	LBB0_12
	jmp	LBB0_13
LBB0_9:
	leaq	L_.str.3(%rip), %rsi
	movl	%r15d, %edx
	movl	%r15d, %ecx
	movl	%r15d, %r8d
	xorl	%eax, %eax
	callq	_fprintf_unfiltered
	cmpl	$64, %r15d
	je	LBB0_13
LBB0_12:
	cmpl	(%r13), %r15d
	jne	LBB0_19
LBB0_13:
	cmpl	%r14d, _mips_readchar.state(%rip)
	jne	LBB0_19
## %bb.14:
	movq	_mips_initializing@GOTPCREL(%rip), %rax
	cmpl	$0, (%rax)
	jne	LBB0_19
## %bb.15:
	movq	_mips_exiting@GOTPCREL(%rip), %rax
	cmpl	$0, (%rax)
	jne	LBB0_19
## %bb.16:
	cmpl	$0, (%rbx)
	jle	LBB0_18
## %bb.17:
	movq	_gdb_stdlog@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str.5(%rip), %rsi
	xorl	%eax, %eax
	callq	_fprintf_unfiltered
LBB0_18:
	movq	_mips_need_reply@GOTPCREL(%rip), %rax
	movq	$0, (%rax)
	xorl	%eax, %eax
	callq	_mips_initialize
	movl	$0, _mips_readchar.state(%rip)
	leaq	L_.str.6(%rip), %rdi
	callq	_error
LBB0_19:
	movq	(%r12), %rax
	movslq	_mips_readchar.state(%rip), %rcx
	xorl	%edx, %edx
	cmpl	(%rax,%rcx,4), %r15d
	leal	1(%rcx), %eax
	cmovel	%eax, %edx
	movl	%edx, _mips_readchar.state(%rip)
	movl	%r15d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
.zerofill __DATA,__bss,_mips_readchar.state,4,2 ## @mips_readchar.state
	.comm	_mips_monitor_prompt,8,3        ## @mips_monitor_prompt
	.comm	_watchdog,4,2                   ## @watchdog
	.comm	_mips_desc,4,2                  ## @mips_desc
	.comm	_SERIAL_TIMEOUT,4,2             ## @SERIAL_TIMEOUT
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Watchdog has expired.  Target detached.\n"

	.comm	_SERIAL_EOF,4,2                 ## @SERIAL_EOF
L_.str.1:                               ## @.str.1
	.asciz	"End of file from remote"

	.comm	_SERIAL_ERROR,4,2               ## @SERIAL_ERROR
L_.str.2:                               ## @.str.2
	.asciz	"Error reading from remote: %s"

	.comm	_errno,4,2                      ## @errno
	.comm	_remote_debug,4,2               ## @remote_debug
	.comm	_gdb_stdlog,4,2                 ## @gdb_stdlog
L_.str.3:                               ## @.str.3
	.asciz	"Read '%c' %d 0x%x\n"

L_.str.4:                               ## @.str.4
	.asciz	"Timed out in read\n"

	.comm	_mips_initializing,4,2          ## @mips_initializing
	.comm	_mips_exiting,4,2               ## @mips_exiting
L_.str.5:                               ## @.str.5
	.asciz	"Reinitializing MIPS debugging mode\n"

	.comm	_mips_need_reply,8,3            ## @mips_need_reply
L_.str.6:                               ## @.str.6
	.asciz	"Remote board reset, debug protocol re-initialized."

	.no_dead_strip	_mips_readchar
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mips_readchar
_mips_readchar:                         ; @mips_readchar
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #96
	.cfi_def_cfa_offset 96
	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
	mov	x19, x0
Lloh0:
	adrp	x22, _mips_monitor_prompt@GOTPAGE
Lloh1:
	ldr	x22, [x22, _mips_monitor_prompt@GOTPAGEOFF]
	ldr	x0, [x22]
	bl	_strlen
	mov	x20, x0
	adrp	x23, _mips_readchar.state@PAGE
	ldr	w8, [x23, _mips_readchar.state@PAGEOFF]
	cmp	w8, w0
	csinc	w21, w19, wzr, ne
Lloh2:
	adrp	x8, _mips_desc@GOTPAGE
Lloh3:
	ldr	x8, [x8, _mips_desc@GOTPAGEOFF]
Lloh4:
	ldr	w0, [x8]
	mov	x1, x21
	bl	_serial_readchar
	mov	x19, x0
Lloh5:
	adrp	x24, _SERIAL_TIMEOUT@GOTPAGE
Lloh6:
	ldr	x24, [x24, _SERIAL_TIMEOUT@GOTPAGEOFF]
	ldr	w8, [x24]
	cmn	w21, #1
	ccmp	w0, w8, #0, eq
	b.ne	LBB0_2
; %bb.1:
	bl	_target_mourn_inferior
Lloh7:
	adrp	x0, l_.str@PAGE
Lloh8:
	add	x0, x0, l_.str@PAGEOFF
	bl	_error
LBB0_2:
Lloh9:
	adrp	x8, _SERIAL_EOF@GOTPAGE
Lloh10:
	ldr	x8, [x8, _SERIAL_EOF@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	cmp	w19, w8
	b.ne	LBB0_4
; %bb.3:
Lloh12:
	adrp	x0, l_.str.1@PAGE
Lloh13:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_mips_error
LBB0_4:
Lloh14:
	adrp	x8, _SERIAL_ERROR@GOTPAGE
Lloh15:
	ldr	x8, [x8, _SERIAL_ERROR@GOTPAGEOFF]
Lloh16:
	ldr	w8, [x8]
	cmp	w19, w8
	b.ne	LBB0_6
; %bb.5:
Lloh17:
	adrp	x8, _errno@GOTPAGE
Lloh18:
	ldr	x8, [x8, _errno@GOTPAGEOFF]
Lloh19:
	ldr	w0, [x8]
	bl	_safe_strerror
                                        ; kill: def $w0 killed $w0 def $x0
	str	x0, [sp]
Lloh20:
	adrp	x0, l_.str.2@PAGE
Lloh21:
	add	x0, x0, l_.str.2@PAGEOFF
	bl	_mips_error
LBB0_6:
Lloh22:
	adrp	x21, _remote_debug@GOTPAGE
Lloh23:
	ldr	x21, [x21, _remote_debug@GOTPAGEOFF]
	ldr	w8, [x21]
	cmp	w8, #2
	b.lt	LBB0_11
; %bb.7:
	ldr	w8, [x24]
Lloh24:
	adrp	x9, _gdb_stdlog@GOTPAGE
Lloh25:
	ldr	x9, [x9, _gdb_stdlog@GOTPAGEOFF]
Lloh26:
	ldr	w0, [x9]
	cmp	w19, w8
	b.ne	LBB0_9
; %bb.8:
Lloh27:
	adrp	x1, l_.str.4@PAGE
Lloh28:
	add	x1, x1, l_.str.4@PAGEOFF
	b	LBB0_10
LBB0_9:
	stp	x19, x19, [sp, #8]
	str	x19, [sp]
Lloh29:
	adrp	x1, l_.str.3@PAGE
Lloh30:
	add	x1, x1, l_.str.3@PAGEOFF
LBB0_10:
	bl	_fprintf_unfiltered
LBB0_11:
	ldr	w8, [x24]
	cmp	w19, #64
	ccmp	w19, w8, #4, ne
	b.ne	LBB0_16
; %bb.12:
	ldr	w8, [x23, _mips_readchar.state@PAGEOFF]
Lloh31:
	adrp	x9, _mips_initializing@GOTPAGE
Lloh32:
	ldr	x9, [x9, _mips_initializing@GOTPAGEOFF]
Lloh33:
	ldr	w9, [x9]
Lloh34:
	adrp	x10, _mips_exiting@GOTPAGE
Lloh35:
	ldr	x10, [x10, _mips_exiting@GOTPAGEOFF]
Lloh36:
	ldr	w10, [x10]
	cmp	w8, w20
	ccmp	w9, #0, #0, eq
	ccmp	w10, #0, #0, eq
	b.ne	LBB0_16
; %bb.13:
	ldr	w8, [x21]
	cmp	w8, #1
	b.lt	LBB0_15
; %bb.14:
Lloh37:
	adrp	x8, _gdb_stdlog@GOTPAGE
Lloh38:
	ldr	x8, [x8, _gdb_stdlog@GOTPAGEOFF]
Lloh39:
	ldr	w0, [x8]
Lloh40:
	adrp	x1, l_.str.5@PAGE
Lloh41:
	add	x1, x1, l_.str.5@PAGEOFF
	bl	_fprintf_unfiltered
LBB0_15:
Lloh42:
	adrp	x8, _mips_need_reply@GOTPAGE
Lloh43:
	ldr	x8, [x8, _mips_need_reply@GOTPAGEOFF]
Lloh44:
	str	xzr, [x8]
	bl	_mips_initialize
	str	wzr, [x23, _mips_readchar.state@PAGEOFF]
Lloh45:
	adrp	x0, l_.str.6@PAGE
Lloh46:
	add	x0, x0, l_.str.6@PAGEOFF
	bl	_error
LBB0_16:
	ldr	x8, [x22]
	ldrsw	x9, [x23, _mips_readchar.state@PAGEOFF]
	ldr	w8, [x8, x9, lsl #2]
	cmp	w19, w8
	csinc	w8, wzr, w9, ne
	str	w8, [x23, _mips_readchar.state@PAGEOFF]
	mov	x0, x19
	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
	add	sp, sp, #96
	ret
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpAdd	Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGot	Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpAdd	Lloh29, Lloh30
	.loh AdrpLdrGotLdr	Lloh34, Lloh35, Lloh36
	.loh AdrpLdrGotLdr	Lloh31, Lloh32, Lloh33
	.loh AdrpAdd	Lloh40, Lloh41
	.loh AdrpLdrGotLdr	Lloh37, Lloh38, Lloh39
	.loh AdrpAdd	Lloh45, Lloh46
	.loh AdrpLdrGotStr	Lloh42, Lloh43, Lloh44
	.cfi_endproc
                                        ; -- End function
.zerofill __DATA,__bss,_mips_readchar.state,4,2 ; @mips_readchar.state
	.comm	_mips_monitor_prompt,8,3        ; @mips_monitor_prompt
	.comm	_watchdog,4,2                   ; @watchdog
	.comm	_mips_desc,4,2                  ; @mips_desc
	.comm	_SERIAL_TIMEOUT,4,2             ; @SERIAL_TIMEOUT
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Watchdog has expired.  Target detached.\n"

	.comm	_SERIAL_EOF,4,2                 ; @SERIAL_EOF
l_.str.1:                               ; @.str.1
	.asciz	"End of file from remote"

	.comm	_SERIAL_ERROR,4,2               ; @SERIAL_ERROR
l_.str.2:                               ; @.str.2
	.asciz	"Error reading from remote: %s"

	.comm	_errno,4,2                      ; @errno
	.comm	_remote_debug,4,2               ; @remote_debug
	.comm	_gdb_stdlog,4,2                 ; @gdb_stdlog
l_.str.3:                               ; @.str.3
	.asciz	"Read '%c' %d 0x%x\n"

l_.str.4:                               ; @.str.4
	.asciz	"Timed out in read\n"

	.comm	_mips_initializing,4,2          ; @mips_initializing
	.comm	_mips_exiting,4,2               ; @mips_exiting
l_.str.5:                               ; @.str.5
	.asciz	"Reinitializing MIPS debugging mode\n"

	.comm	_mips_need_reply,8,3            ; @mips_need_reply
l_.str.6:                               ; @.str.6
	.asciz	"Remote board reset, debug protocol re-initialized."

	.no_dead_strip	_mips_readchar
.subsections_via_symbols
