	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_tube_read_msg                  ## -- Begin function tube_read_msg
	.p2align	4, 0x90
_tube_read_msg:                         ## @tube_read_msg
	.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
	movq	%rdx, %r12
	movq	%rsi, %r14
	movl	(%rdi), %r15d
	movl	$0, (%rdx)
	testl	%ecx, %ecx
	je	LBB0_28
## %bb.1:
	movl	$4, %edx
	movl	%r15d, %edi
	movq	%r12, %rsi
	xorl	%eax, %eax
	callq	_read
	movl	%eax, %ebx
	testl	%eax, %eax
	je	LBB0_27
## %bb.2:
	cmpl	$-1, %ebx
	jne	LBB0_6
## %bb.3:
	movq	_errno@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	movq	_EINTR@GOTPCREL(%rip), %rax
	movl	$-1, %ebx
	cmpq	(%rax), %rdi
	je	LBB0_27
## %bb.4:
	movq	_EAGAIN@GOTPCREL(%rip), %rax
	cmpq	(%rax), %rdi
	je	LBB0_27
## %bb.5:
	callq	_strerror
	leaq	L_.str(%rip), %rdi
	movl	%eax, %esi
	xorl	%eax, %eax
	callq	_log_err
	jmp	LBB0_27
LBB0_28:
	movl	%r15d, %edi
	callq	_fd_set_block
	xorl	%ebx, %ebx
	testl	%eax, %eax
	jne	LBB0_8
	jmp	LBB0_27
LBB0_6:
	movl	%r15d, %edi
	callq	_fd_set_block
	testl	%eax, %eax
	je	LBB0_26
LBB0_7:
	cmpl	$4, %ebx
	je	LBB0_13
LBB0_8:
	movslq	%ebx, %rax
	leaq	(%r12,%rax), %rsi
	movl	$4, %edx
	subq	%rax, %rdx
	movl	%r15d, %edi
	xorl	%eax, %eax
	callq	_read
	testl	%eax, %eax
	je	LBB0_11
## %bb.9:
	cmpl	$-1, %eax
	je	LBB0_10
## %bb.12:
	addl	%eax, %ebx
	jmp	LBB0_7
LBB0_13:
	xorl	%edi, %edi
	cmpl	$131072, (%r12)                 ## imm = 0x20000
	setl	%dil
	callq	_log_assert
	movl	(%r12), %edi
	callq	_malloc
	movq	%rax, (%r14)
	testq	%rax, %rax
	je	LBB0_19
## %bb.14:
	movq	%rax, %rsi
	movl	(%r12), %eax
	testl	%eax, %eax
	jle	LBB0_24
## %bb.15:
	xorl	%ebx, %ebx
	.p2align	4, 0x90
LBB0_16:                                ## =>This Inner Loop Header: Depth=1
	movslq	%ebx, %rcx
	addq	%rcx, %rsi
	movslq	%eax, %rdx
	subq	%rcx, %rdx
	movl	%r15d, %edi
	xorl	%eax, %eax
	callq	_read
	testl	%eax, %eax
	je	LBB0_21
## %bb.17:                              ##   in Loop: Header=BB0_16 Depth=1
	cmpl	$-1, %eax
	je	LBB0_18
## %bb.22:                              ##   in Loop: Header=BB0_16 Depth=1
	addl	%eax, %ebx
	movl	(%r12), %eax
	cmpl	%eax, %ebx
	jge	LBB0_24
## %bb.23:                              ##   in Loop: Header=BB0_16 Depth=1
	movq	(%r14), %rsi
	jmp	LBB0_16
LBB0_11:
	movl	%r15d, %edi
	callq	_fd_set_nonblock
	jmp	LBB0_26
LBB0_10:
	movq	_errno@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	callq	_strerror
	leaq	L_.str(%rip), %rdi
	xorl	%ebx, %ebx
	movl	%eax, %esi
	xorl	%eax, %eax
	callq	_log_err
	jmp	LBB0_20
LBB0_19:
	leaq	L_.str.1(%rip), %rdi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_log_err
LBB0_20:
	movl	%r15d, %edi
	callq	_fd_set_nonblock
	jmp	LBB0_27
LBB0_24:
	movl	%r15d, %edi
	callq	_fd_set_nonblock
	movl	$1, %ebx
	testl	%eax, %eax
	jne	LBB0_27
	jmp	LBB0_25
LBB0_18:
	movq	_errno@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	callq	_strerror
	leaq	L_.str(%rip), %rdi
	xorl	%ebx, %ebx
	movl	%eax, %esi
	xorl	%eax, %eax
	callq	_log_err
	movl	%r15d, %edi
	callq	_fd_set_nonblock
	movq	(%r14), %rdi
	callq	_free
	jmp	LBB0_27
LBB0_21:
	movl	%r15d, %edi
	callq	_fd_set_nonblock
LBB0_25:
	movq	(%r14), %rdi
	callq	_free
LBB0_26:
	xorl	%ebx, %ebx
LBB0_27:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_errno,8,3                      ## @errno
	.comm	_EINTR,8,3                      ## @EINTR
	.comm	_EAGAIN,8,3                     ## @EAGAIN
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"tube msg read failed: %s"

L_.str.1:                               ## @.str.1
	.asciz	"tube read out of memory"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_tube_read_msg                  ; -- Begin function tube_read_msg
	.p2align	2
_tube_read_msg:                         ; @tube_read_msg
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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	x21, x2
	mov	x20, x1
	ldr	w19, [x0]
	str	wzr, [x2]
	cbz	w3, LBB0_5
; %bb.1:
	mov	w8, #4
	stp	x21, x8, [sp]
	mov	x0, x19
	bl	_read
	mov	x22, x0
	cbz	w0, LBB0_30
; %bb.2:
	cmn	w22, #1
	b.ne	LBB0_6
; %bb.3:
Lloh0:
	adrp	x8, _errno@GOTPAGE
Lloh1:
	ldr	x8, [x8, _errno@GOTPAGEOFF]
Lloh2:
	ldr	x0, [x8]
Lloh3:
	adrp	x8, _EINTR@GOTPAGE
Lloh4:
	ldr	x8, [x8, _EINTR@GOTPAGEOFF]
Lloh5:
	ldr	x8, [x8]
Lloh6:
	adrp	x9, _EAGAIN@GOTPAGE
Lloh7:
	ldr	x9, [x9, _EAGAIN@GOTPAGEOFF]
Lloh8:
	ldr	x9, [x9]
	cmp	x0, x8
	ccmp	x0, x9, #4, ne
	b.ne	LBB0_19
; %bb.4:
	mov	w22, #-1
	b	LBB0_30
LBB0_5:
	mov	x0, x19
	bl	_fd_set_block
	mov	w22, #0
	cbnz	w0, LBB0_8
	b	LBB0_30
LBB0_6:
	mov	x0, x19
	bl	_fd_set_block
	cbz	w0, LBB0_29
; %bb.7:
	cmp	w22, #4
	b.eq	LBB0_12
LBB0_8:
	mov	w23, #4
LBB0_9:                                 ; =>This Inner Loop Header: Depth=1
	sxtw	x8, w22
	add	x9, x21, x8
	sub	x8, x23, x8
	stp	x9, x8, [sp]
	mov	x0, x19
	bl	_read
	cbz	w0, LBB0_23
; %bb.10:                               ;   in Loop: Header=BB0_9 Depth=1
	cmn	w0, #1
	b.eq	LBB0_20
; %bb.11:                               ;   in Loop: Header=BB0_9 Depth=1
	add	w22, w0, w22
	cmp	w22, #4
	b.ne	LBB0_9
LBB0_12:
	ldr	w8, [x21]
	cmp	w8, #32, lsl #12                ; =131072
	cset	w0, lt
	bl	_log_assert
	ldr	w0, [x21]
	bl	_malloc
	str	x0, [x20]
	cbz	x0, LBB0_21
; %bb.13:
	ldr	w8, [x21]
	cmp	w8, #1
	b.lt	LBB0_24
; %bb.14:
	mov	w22, #0
LBB0_15:                                ; =>This Inner Loop Header: Depth=1
	sxtw	x9, w22
	add	x10, x0, x9
	sxtw	x8, w8
	sub	x8, x8, x9
	stp	x10, x8, [sp]
	mov	x0, x19
	bl	_read
	cbz	w0, LBB0_27
; %bb.16:                               ;   in Loop: Header=BB0_15 Depth=1
	cmn	w0, #1
	b.eq	LBB0_26
; %bb.17:                               ;   in Loop: Header=BB0_15 Depth=1
	ldr	w8, [x21]
	add	w22, w0, w22
	cmp	w22, w8
	b.ge	LBB0_24
; %bb.18:                               ;   in Loop: Header=BB0_15 Depth=1
	ldr	x0, [x20]
	b	LBB0_15
LBB0_19:
	bl	_strerror
                                        ; kill: def $w0 killed $w0 def $x0
	str	x0, [sp]
Lloh9:
	adrp	x0, l_.str@PAGE
Lloh10:
	add	x0, x0, l_.str@PAGEOFF
	bl	_log_err
	mov	w22, #-1
	b	LBB0_30
LBB0_20:
Lloh11:
	adrp	x8, _errno@GOTPAGE
Lloh12:
	ldr	x8, [x8, _errno@GOTPAGEOFF]
Lloh13:
	ldr	x0, [x8]
	bl	_strerror
                                        ; kill: def $w0 killed $w0 def $x0
	str	x0, [sp]
Lloh14:
	adrp	x0, l_.str@PAGE
Lloh15:
	add	x0, x0, l_.str@PAGEOFF
	b	LBB0_22
LBB0_21:
Lloh16:
	adrp	x0, l_.str.1@PAGE
Lloh17:
	add	x0, x0, l_.str.1@PAGEOFF
LBB0_22:
	bl	_log_err
LBB0_23:
	mov	x0, x19
	bl	_fd_set_nonblock
	b	LBB0_29
LBB0_24:
	mov	x0, x19
	bl	_fd_set_nonblock
	cbz	w0, LBB0_28
; %bb.25:
	mov	w22, #1
	b	LBB0_30
LBB0_26:
Lloh18:
	adrp	x8, _errno@GOTPAGE
Lloh19:
	ldr	x8, [x8, _errno@GOTPAGEOFF]
Lloh20:
	ldr	x0, [x8]
	bl	_strerror
                                        ; kill: def $w0 killed $w0 def $x0
	str	x0, [sp]
Lloh21:
	adrp	x0, l_.str@PAGE
Lloh22:
	add	x0, x0, l_.str@PAGEOFF
	bl	_log_err
LBB0_27:
	mov	x0, x19
	bl	_fd_set_nonblock
LBB0_28:
	ldr	x0, [x20]
	bl	_free
LBB0_29:
	mov	w22, #0
LBB0_30:
	mov	x0, x22
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #80
	ret
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh9, Lloh10
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpAdd	Lloh16, Lloh17
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.cfi_endproc
                                        ; -- End function
	.comm	_errno,8,3                      ; @errno
	.comm	_EINTR,8,3                      ; @EINTR
	.comm	_EAGAIN,8,3                     ; @EAGAIN
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"tube msg read failed: %s"

l_.str.1:                               ; @.str.1
	.asciz	"tube read out of memory"

.subsections_via_symbols
