	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_savage_bci_emit_event          ## -- Begin function savage_bci_emit_event
	.p2align	4, 0x90
_savage_bci_emit_event:                 ## @savage_bci_emit_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	%r14
	pushq	%rbx
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	LBB0_3
## %bb.1:
	movl	4092(%rax), %r14d
	cmpl	8(%rdi), %r14d
	jge	LBB0_4
## %bb.2:
	incl	12(%rdi)
	jmp	LBB0_4
LBB0_3:
	movl	8(%rdi), %r14d
LBB0_4:
	incl	%r14d
	andl	$65535, %r14d                   ## imm = 0xFFFF
	jne	LBB0_6
## %bb.5:
	incl	12(%rdi)
	movl	$1, %r14d
LBB0_6:
	movl	%r14d, 8(%rdi)
	testq	%rax, %rax
	je	LBB0_8
## %bb.7:
	movl	%r14d, 4092(%rax)
LBB0_8:
	movq	_SAVAGE_WAIT_2D@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	movq	_SAVAGE_WAIT_3D@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, %ecx
	orl	%ebx, %ecx
	testl	%esi, %ecx
	je	LBB0_14
## %bb.9:
	movq	_BCI_CMD_WAIT@GOTPCREL(%rip), %rcx
	andl	%esi, %ebx
	je	LBB0_11
## %bb.10:
	movq	_BCI_CMD_WAIT_2D@GOTPCREL(%rip), %rdx
	movl	(%rdx), %ebx
LBB0_11:
	orl	(%rcx), %ebx
	andl	%esi, %eax
	je	LBB0_13
## %bb.12:
	movq	_BCI_CMD_WAIT_3D@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
LBB0_13:
	orl	%eax, %ebx
	movl	$2, %edi
	callq	_BEGIN_BCI
	movl	%ebx, %edi
	callq	_BCI_WRITE
	jmp	LBB0_15
LBB0_14:
	movl	$1, %edi
	callq	_BEGIN_BCI
LBB0_15:
	movq	_BCI_CMD_UPDATE_EVENT_TAG@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	orl	%r14d, %edi
	callq	_BCI_WRITE
	movl	%r14d, %eax
	popq	%rbx
	popq	%r14
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_BCI_LOCALS,4,2                 ## @BCI_LOCALS
	.comm	_SAVAGE_WAIT_2D,4,2             ## @SAVAGE_WAIT_2D
	.comm	_SAVAGE_WAIT_3D,4,2             ## @SAVAGE_WAIT_3D
	.comm	_BCI_CMD_WAIT,4,2               ## @BCI_CMD_WAIT
	.comm	_BCI_CMD_WAIT_2D,4,2            ## @BCI_CMD_WAIT_2D
	.comm	_BCI_CMD_WAIT_3D,4,2            ## @BCI_CMD_WAIT_3D
	.comm	_BCI_CMD_UPDATE_EVENT_TAG,4,2   ## @BCI_CMD_UPDATE_EVENT_TAG
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_savage_bci_emit_event          ; -- Begin function savage_bci_emit_event
	.p2align	2
_savage_bci_emit_event:                 ; @savage_bci_emit_event
	.cfi_startproc
; %bb.0:
	stp	x20, x19, [sp, #-32]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 32
	stp	x29, x30, [sp, #16]             ; 16-byte Folded Spill
	add	x29, sp, #16
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	ldr	x8, [x0]
	cbz	x8, LBB0_3
; %bb.1:
	ldr	w9, [x8, #4092]
	ldr	w10, [x0, #8]
	cmp	w9, w10
	b.ge	LBB0_4
; %bb.2:
	ldr	w10, [x0, #12]
	add	w10, w10, #1
	str	w10, [x0, #12]
	b	LBB0_4
LBB0_3:
	ldr	w9, [x0, #8]
LBB0_4:
	add	w9, w9, #1
	ands	w19, w9, #0xffff
	b.ne	LBB0_6
; %bb.5:
	ldr	w9, [x0, #12]
	add	w9, w9, #1
	str	w9, [x0, #12]
	mov	w19, #1
LBB0_6:
	str	w19, [x0, #8]
	cbz	x8, LBB0_8
; %bb.7:
	str	w19, [x8, #4092]
LBB0_8:
Lloh0:
	adrp	x8, _SAVAGE_WAIT_2D@GOTPAGE
Lloh1:
	ldr	x8, [x8, _SAVAGE_WAIT_2D@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x8]
Lloh3:
	adrp	x8, _SAVAGE_WAIT_3D@GOTPAGE
Lloh4:
	ldr	x8, [x8, _SAVAGE_WAIT_3D@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	orr	w10, w8, w9
	tst	w10, w1
	b.eq	LBB0_10
; %bb.9:
Lloh6:
	adrp	x10, _BCI_CMD_WAIT@GOTPAGE
Lloh7:
	ldr	x10, [x10, _BCI_CMD_WAIT@GOTPAGEOFF]
Lloh8:
	ldr	w10, [x10]
Lloh9:
	adrp	x11, _BCI_CMD_WAIT_2D@GOTPAGE
Lloh10:
	ldr	x11, [x11, _BCI_CMD_WAIT_2D@GOTPAGEOFF]
Lloh11:
	ldr	w11, [x11]
	tst	w9, w1
	csel	w9, wzr, w11, eq
	orr	w9, w9, w10
Lloh12:
	adrp	x10, _BCI_CMD_WAIT_3D@GOTPAGE
Lloh13:
	ldr	x10, [x10, _BCI_CMD_WAIT_3D@GOTPAGEOFF]
Lloh14:
	ldr	w10, [x10]
	tst	w8, w1
	csel	w8, wzr, w10, eq
	orr	w20, w9, w8
	mov	w0, #2
	bl	_BEGIN_BCI
	mov	x0, x20
	bl	_BCI_WRITE
	b	LBB0_11
LBB0_10:
	mov	w0, #1
	bl	_BEGIN_BCI
LBB0_11:
Lloh15:
	adrp	x8, _BCI_CMD_UPDATE_EVENT_TAG@GOTPAGE
Lloh16:
	ldr	x8, [x8, _BCI_CMD_UPDATE_EVENT_TAG@GOTPAGEOFF]
Lloh17:
	ldr	w8, [x8]
	orr	w0, w8, w19
	bl	_BCI_WRITE
	mov	x0, x19
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp], #32             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.cfi_endproc
                                        ; -- End function
	.comm	_BCI_LOCALS,4,2                 ; @BCI_LOCALS
	.comm	_SAVAGE_WAIT_2D,4,2             ; @SAVAGE_WAIT_2D
	.comm	_SAVAGE_WAIT_3D,4,2             ; @SAVAGE_WAIT_3D
	.comm	_BCI_CMD_WAIT,4,2               ; @BCI_CMD_WAIT
	.comm	_BCI_CMD_WAIT_2D,4,2            ; @BCI_CMD_WAIT_2D
	.comm	_BCI_CMD_WAIT_3D,4,2            ; @BCI_CMD_WAIT_3D
	.comm	_BCI_CMD_UPDATE_EVENT_TAG,4,2   ; @BCI_CMD_UPDATE_EVENT_TAG
.subsections_via_symbols
