	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function msg_queue_read
_msg_queue_read:                        ## @msg_queue_read
	.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
	movq	%rdx, %r13
	movq	%rsi, %r14
	movq	%rdi, %r15
	movq	(%rdi), %rax
	movq	(%rax), %r12
	callq	_msg_queue_open
	testl	%eax, %eax
	je	LBB0_2
## %bb.1:
	movl	%eax, %ebx
	movl	(%r14), %edx
	leaq	L_.str(%rip), %rsi
	movq	%r12, %rdi
	callq	_nvkm_error
	jmp	LBB0_12
LBB0_2:
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	_msg_queue_empty
	xorl	%ebx, %ebx
	testq	%rax, %rax
	jne	LBB0_11
## %bb.3:
	movq	_HDR_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	%r15, %rdi
	movq	%r14, %rsi
	movq	%r13, %rdx
	callq	_msg_queue_pop
	movq	_EINVAL@GOTPCREL(%rip), %rcx
	xorl	%ebx, %ebx
	subl	(%rcx), %ebx
	movq	_HDR_SIZE@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	cmpl	%ecx, %eax
	cmovel	%eax, %ebx
	testl	%eax, %eax
	cmovsl	%eax, %ebx
	testl	%ebx, %ebx
	js	LBB0_4
## %bb.5:
	movl	(%r13), %r8d
	movq	_MSG_BUF_SIZE@GOTPCREL(%rip), %rax
	cmpl	(%rax), %r8d
	jle	LBB0_7
## %bb.6:
	leaq	L_.str.2(%rip), %rsi
	movq	%r12, %rdi
	movl	%r8d, %edx
	callq	_nvkm_error
	movq	_ENOSPC@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_11
LBB0_4:
	leaq	L_.str.1(%rip), %rsi
LBB0_10:
	movq	%r12, %rdi
	movl	%ebx, %edx
	callq	_nvkm_error
	jmp	LBB0_11
LBB0_7:
	subl	%ecx, %r8d
	jle	LBB0_11
## %bb.8:
	addq	$4, %r13
	movq	%r15, %rdi
	movq	%r14, %rsi
	movq	%r13, %rdx
	movl	%r8d, %ecx
	movl	%r8d, %r13d
	callq	_msg_queue_pop
	xorl	%ebx, %ebx
	movq	_EINVAL@GOTPCREL(%rip), %rcx
	subl	(%rcx), %ebx
	cmpl	%r13d, %eax
	cmovel	%eax, %ebx
	testl	%eax, %eax
	cmovsl	%eax, %ebx
	testl	%ebx, %ebx
	js	LBB0_9
LBB0_11:
	movl	%ebx, %edx
	notl	%edx
	shrl	$31, %edx
	movq	%r15, %rdi
	movq	%r14, %rsi
	callq	_msg_queue_close
LBB0_12:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_9:
	leaq	L_.str.3(%rip), %rsi
	jmp	LBB0_10
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"fail to open queue %d\n"

	.comm	_HDR_SIZE,4,2                   ## @HDR_SIZE
	.comm	_EINVAL,4,2                     ## @EINVAL
L_.str.1:                               ## @.str.1
	.asciz	"failed to read message header: %d\n"

	.comm	_MSG_BUF_SIZE,4,2               ## @MSG_BUF_SIZE
L_.str.2:                               ## @.str.2
	.asciz	"message too big (%d bytes)\n"

	.comm	_ENOSPC,4,2                     ## @ENOSPC
L_.str.3:                               ## @.str.3
	.asciz	"failed to read message: %d\n"

	.no_dead_strip	_msg_queue_read
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function msg_queue_read
_msg_queue_read:                        ; @msg_queue_read
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	mov	x23, x2
	mov	x19, x1
	mov	x20, x0
	ldr	x8, [x0]
	ldr	x21, [x8]
	bl	_msg_queue_open
	cbz	w0, LBB0_2
; %bb.1:
	mov	x22, x0
	ldr	w2, [x19]
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x21
	bl	_nvkm_error
	b	LBB0_12
LBB0_2:
	mov	x0, x20
	mov	x1, x19
	bl	_msg_queue_empty
	cbz	x0, LBB0_4
; %bb.3:
	mov	w22, #0
	b	LBB0_11
LBB0_4:
Lloh2:
	adrp	x22, _HDR_SIZE@GOTPAGE
Lloh3:
	ldr	x22, [x22, _HDR_SIZE@GOTPAGEOFF]
	ldr	w3, [x22]
	mov	x0, x20
	mov	x1, x19
	mov	x2, x23
	bl	_msg_queue_pop
	ldr	w8, [x22]
	cmp	w0, w8
	ccmp	w0, #0, #8, ne
Lloh4:
	adrp	x25, _EINVAL@GOTPAGE
Lloh5:
	ldr	x25, [x25, _EINVAL@GOTPAGEOFF]
	ldr	w9, [x25]
	csneg	w22, w0, w9, lt
	tbnz	w22, #31, LBB0_7
; %bb.5:
	ldr	w2, [x23]
Lloh6:
	adrp	x9, _MSG_BUF_SIZE@GOTPAGE
Lloh7:
	ldr	x9, [x9, _MSG_BUF_SIZE@GOTPAGEOFF]
Lloh8:
	ldr	w9, [x9]
	cmp	w2, w9
	b.le	LBB0_9
; %bb.6:
Lloh9:
	adrp	x1, l_.str.2@PAGE
Lloh10:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	x0, x21
	bl	_nvkm_error
Lloh11:
	adrp	x8, _ENOSPC@GOTPAGE
Lloh12:
	ldr	x8, [x8, _ENOSPC@GOTPAGEOFF]
Lloh13:
	ldr	w8, [x8]
	neg	w22, w8
	b	LBB0_11
LBB0_7:
Lloh14:
	adrp	x1, l_.str.1@PAGE
Lloh15:
	add	x1, x1, l_.str.1@PAGEOFF
LBB0_8:
	mov	x0, x21
	mov	x2, x22
	bl	_nvkm_error
	b	LBB0_11
LBB0_9:
	subs	w24, w2, w8
	b.le	LBB0_11
; %bb.10:
	add	x2, x23, #4
	mov	x0, x20
	mov	x1, x19
	mov	x3, x24
	bl	_msg_queue_pop
	cmp	w0, w24
	ccmp	w0, #0, #8, ne
	ldr	w8, [x25]
	csneg	w22, w0, w8, lt
	tbnz	w22, #31, LBB0_13
LBB0_11:
	mvn	w8, w22
	lsr	w2, w8, #31
	mov	x0, x20
	mov	x1, x19
	bl	_msg_queue_close
LBB0_12:
	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
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
LBB0_13:
Lloh16:
	adrp	x1, l_.str.3@PAGE
Lloh17:
	add	x1, x1, l_.str.3@PAGEOFF
	b	LBB0_8
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpAdd	Lloh9, Lloh10
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpAdd	Lloh16, Lloh17
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"fail to open queue %d\n"

	.comm	_HDR_SIZE,4,2                   ; @HDR_SIZE
	.comm	_EINVAL,4,2                     ; @EINVAL
l_.str.1:                               ; @.str.1
	.asciz	"failed to read message header: %d\n"

	.comm	_MSG_BUF_SIZE,4,2               ; @MSG_BUF_SIZE
l_.str.2:                               ; @.str.2
	.asciz	"message too big (%d bytes)\n"

	.comm	_ENOSPC,4,2                     ; @ENOSPC
l_.str.3:                               ; @.str.3
	.asciz	"failed to read message: %d\n"

	.no_dead_strip	_msg_queue_read
.subsections_via_symbols
