	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_cros_ec_get_next_event         ## -- Begin function cros_ec_get_next_event
	.p2align	4, 0x90
_cros_ec_get_next_event:                ## @cros_ec_get_next_event
	.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	%rsi, %r14
	movq	%rdi, %rbx
	cmpl	$0, 16(%rdi)
	je	LBB0_1
## %bb.3:
	movq	%rbx, %rdi
	callq	_get_next_event
	movl	%eax, %r15d
	testq	%r14, %r14
	je	LBB0_10
## %bb.4:
	testl	%r15d, %r15d
	jle	LBB0_10
## %bb.5:
	movq	8(%rbx), %r12
	movq	%rbx, %rdi
	callq	_cros_ec_get_host_event
	movq	_EC_MKBP_EVENT_SENSOR_FIFO@GOTPCREL(%rip), %rdx
	xorl	%ecx, %ecx
	cmpq	(%rdx), %r12
	je	LBB0_9
## %bb.6:
	testl	%eax, %eax
	je	LBB0_8
## %bb.7:
	testl	%eax, (%rbx)
	je	LBB0_9
LBB0_8:
	movl	$1, %ecx
	jmp	LBB0_9
LBB0_1:
	movq	%rbx, %rdi
	callq	_get_keyboard_state_event
	movl	%eax, %r15d
	testq	%r14, %r14
	je	LBB0_10
## %bb.2:
	movl	$1, %ecx
	testl	%r15d, %r15d
	jle	LBB0_10
LBB0_9:
	movl	%ecx, (%r14)
LBB0_10:
	movl	%r15d, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_EC_MKBP_EVENT_SENSOR_FIFO,8,3  ## @EC_MKBP_EVENT_SENSOR_FIFO
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_cros_ec_get_next_event         ; -- Begin function cros_ec_get_next_event
	.p2align	2
_cros_ec_get_next_event:                ; @cros_ec_get_next_event
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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
	mov	x20, x1
	mov	x21, x0
	ldr	w8, [x0, #16]
	cbz	w8, LBB0_5
; %bb.1:
	mov	x0, x21
	bl	_get_next_event
	mov	x19, x0
	cbz	x20, LBB0_11
; %bb.2:
	cmp	w19, #1
	b.lt	LBB0_11
; %bb.3:
	ldr	x22, [x21, #8]
	mov	x0, x21
	bl	_cros_ec_get_host_event
Lloh0:
	adrp	x8, _EC_MKBP_EVENT_SENSOR_FIFO@GOTPAGE
Lloh1:
	ldr	x8, [x8, _EC_MKBP_EVENT_SENSOR_FIFO@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	cmp	x22, x8
	b.ne	LBB0_7
LBB0_4:
	mov	w8, #0
	b	LBB0_10
LBB0_5:
	mov	x0, x21
	bl	_get_keyboard_state_event
	mov	x19, x0
	cbz	x20, LBB0_11
; %bb.6:
	cmp	w19, #1
	b.ge	LBB0_9
	b	LBB0_11
LBB0_7:
	cbz	w0, LBB0_9
; %bb.8:
	ldr	w8, [x21]
	tst	w8, w0
	b.eq	LBB0_4
LBB0_9:
	mov	w8, #1
LBB0_10:
	str	w8, [x20]
LBB0_11:
	mov	x0, x19
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.cfi_endproc
                                        ; -- End function
	.comm	_EC_MKBP_EVENT_SENSOR_FIFO,8,3  ; @EC_MKBP_EVENT_SENSOR_FIFO
.subsections_via_symbols
