	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.section	__TEXT,__literal8,8byte_literals
	.p2align	3                               ## -- Begin function Atari_Mouse
LCPI0_0:
	.quad	0x406c800000000000              ## double 228
	.section	__TEXT,__text,regular,pure_instructions
	.globl	_Atari_Mouse
	.p2align	4, 0x90
_Atari_Mouse:                           ## @Atari_Mouse
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	subq	$32, %rsp
	movq	_INPUT_mouse_mode@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	_INPUT_MOUSE_OFF@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	je	LBB0_6
## %bb.1:
	movq	_display@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_window@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	subq	$8, %rsp
	leaq	-8(%rbp), %rax
	leaq	-4(%rbp), %r10
	leaq	-12(%rbp), %r11
	leaq	-28(%rbp), %rdx
	leaq	-24(%rbp), %rcx
	leaq	-20(%rbp), %r8
	leaq	-16(%rbp), %r9
	pushq	%rax
	pushq	%r10
	pushq	%r11
	callq	_XQueryPointer
	addq	$32, %rsp
	testq	%rax, %rax
	je	LBB0_6
## %bb.2:
	movq	_INPUT_direct_mouse@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	movl	-12(%rbp), %eax
	je	LBB0_4
## %bb.3:
	movl	-4(%rbp), %ecx
	xorl	%edx, %edx
	testl	%eax, %eax
	cmovlel	%edx, %eax
	testl	%ecx, %ecx
	cmovgl	%ecx, %edx
	cvtsi2sd	%eax, %xmm0
	movq	_window_width@GOTPCREL(%rip), %rax
	cvtsi2sdq	(%rax), %xmm1
	movsd	LCPI0_0(%rip), %xmm2            ## xmm2 = mem[0],zero
	movapd	%xmm2, %xmm3
	divsd	%xmm1, %xmm3
	mulsd	%xmm0, %xmm3
	cvttsd2si	%xmm3, %eax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%edx, %xmm0
	movq	_window_height@GOTPCREL(%rip), %rcx
	xorps	%xmm1, %xmm1
	cvtsi2sdq	(%rcx), %xmm1
	divsd	%xmm1, %xmm2
	mulsd	%xmm0, %xmm2
	cvttsd2si	%xmm2, %ecx
	cmpl	$227, %eax
	movl	$227, %edx
	cmovgel	%edx, %eax
	cmpl	$227, %ecx
	cmovgel	%edx, %ecx
	movl	$227, %esi
	subl	%eax, %esi
	movq	_POKEY_POT_input@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	_INPUT_mouse_port@GOTPCREL(%rip), %r8
	movl	(%r8), %edi
	addl	%edi, %edi
	movslq	%edi, %rdi
	movl	%esi, (%rax,%rdi,4)
	subl	%ecx, %edx
	movl	(%r8), %ecx
	addl	%ecx, %ecx
	incl	%ecx
	movslq	%ecx, %rcx
	movl	%edx, (%rax,%rcx,4)
	jmp	LBB0_5
LBB0_4:
	movl	%eax, %ecx
	subl	_Atari_Mouse.last_x(%rip), %ecx
	movq	_INPUT_mouse_delta_x@GOTPCREL(%rip), %rdx
	movl	%ecx, (%rdx)
	movl	-4(%rbp), %ecx
	movl	%ecx, %edx
	subl	_Atari_Mouse.last_y(%rip), %edx
	movq	_INPUT_mouse_delta_y@GOTPCREL(%rip), %rsi
	movl	%edx, (%rsi)
	movl	%eax, _Atari_Mouse.last_x(%rip)
	movl	%ecx, _Atari_Mouse.last_y(%rip)
LBB0_5:
	movl	-8(%rbp), %eax
	movq	_Button1Mask@GOTPCREL(%rip), %rcx
	xorl	%edx, %edx
	movl	(%rcx), %ecx
	andl	%eax, %ecx
	setne	%dl
	movq	_Button3Mask@GOTPCREL(%rip), %rcx
	xorl	%esi, %esi
	movl	(%rcx), %ecx
	andl	%eax, %ecx
	setne	%sil
	leal	(%rdx,%rsi,2), %ecx
	movq	_Button2Mask@GOTPCREL(%rip), %rdx
	xorl	%esi, %esi
	andl	(%rdx), %eax
	setne	%sil
	leal	(%rcx,%rsi,4), %eax
	movq	_INPUT_mouse_buttons@GOTPCREL(%rip), %rcx
	movl	%eax, (%rcx)
LBB0_6:
	addq	$32, %rsp
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
.zerofill __DATA,__bss,_Atari_Mouse.last_x,4,2 ## @Atari_Mouse.last_x
.zerofill __DATA,__bss,_Atari_Mouse.last_y,4,2 ## @Atari_Mouse.last_y
	.comm	_INPUT_mouse_mode,8,3           ## @INPUT_mouse_mode
	.comm	_INPUT_MOUSE_OFF,8,3            ## @INPUT_MOUSE_OFF
	.comm	_display,4,2                    ## @display
	.comm	_window,4,2                     ## @window
	.comm	_INPUT_direct_mouse,8,3         ## @INPUT_direct_mouse
	.comm	_window_width,8,3               ## @window_width
	.comm	_window_height,8,3              ## @window_height
	.comm	_POKEY_POT_input,8,3            ## @POKEY_POT_input
	.comm	_INPUT_mouse_port,4,2           ## @INPUT_mouse_port
	.comm	_INPUT_mouse_delta_x,4,2        ## @INPUT_mouse_delta_x
	.comm	_INPUT_mouse_delta_y,4,2        ## @INPUT_mouse_delta_y
	.comm	_Button1Mask,4,2                ## @Button1Mask
	.comm	_Button3Mask,4,2                ## @Button3Mask
	.comm	_Button2Mask,4,2                ## @Button2Mask
	.comm	_INPUT_mouse_buttons,4,2        ## @INPUT_mouse_buttons
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_Atari_Mouse                    ; -- Begin function Atari_Mouse
	.p2align	2
_Atari_Mouse:                           ; @Atari_Mouse
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #64
	.cfi_def_cfa_offset 64
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
Lloh0:
	adrp	x8, _INPUT_mouse_mode@GOTPAGE
Lloh1:
	ldr	x8, [x8, _INPUT_mouse_mode@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
Lloh3:
	adrp	x9, _INPUT_MOUSE_OFF@GOTPAGE
Lloh4:
	ldr	x9, [x9, _INPUT_MOUSE_OFF@GOTPAGEOFF]
Lloh5:
	ldr	x9, [x9]
	cmp	x8, x9
	b.eq	LBB0_6
; %bb.1:
Lloh6:
	adrp	x8, _display@GOTPAGE
Lloh7:
	ldr	x8, [x8, _display@GOTPAGEOFF]
Lloh8:
	ldr	w0, [x8]
Lloh9:
	adrp	x8, _window@GOTPAGE
Lloh10:
	ldr	x8, [x8, _window@GOTPAGEOFF]
Lloh11:
	ldr	w1, [x8]
	add	x8, sp, #20
	str	x8, [sp]
	sub	x2, x29, #4
	sub	x3, x29, #8
	sub	x4, x29, #12
	sub	x5, x29, #16
	sub	x6, x29, #20
	add	x7, sp, #24
	bl	_XQueryPointer
	cbz	x0, LBB0_6
; %bb.2:
Lloh12:
	adrp	x8, _INPUT_direct_mouse@GOTPAGE
Lloh13:
	ldr	x8, [x8, _INPUT_direct_mouse@GOTPAGEOFF]
Lloh14:
	ldr	x9, [x8]
	ldur	w8, [x29, #-20]
	cbz	x9, LBB0_4
; %bb.3:
	ldr	w9, [sp, #24]
	cmp	w8, #0
	csel	w8, w8, wzr, gt
	cmp	w9, #0
	csel	w9, w9, wzr, gt
	scvtf	d0, w8
Lloh15:
	adrp	x8, _window_width@GOTPAGE
Lloh16:
	ldr	x8, [x8, _window_width@GOTPAGEOFF]
Lloh17:
	ldr	d1, [x8]
	scvtf	d1, d1
	mov	x8, #140737488355328
	movk	x8, #16492, lsl #48
	fmov	d2, x8
	fdiv	d1, d2, d1
	fmul	d0, d1, d0
	fcvtzs	w8, d0
	scvtf	d0, w9
Lloh18:
	adrp	x9, _window_height@GOTPAGE
Lloh19:
	ldr	x9, [x9, _window_height@GOTPAGEOFF]
Lloh20:
	ldr	d1, [x9]
	scvtf	d1, d1
	fdiv	d1, d2, d1
	fmul	d0, d1, d0
	fcvtzs	w9, d0
	mov	w10, #227
	cmp	w8, #227
	csel	w8, w8, w10, lt
	cmp	w9, #227
	csel	w9, w9, w10, lt
	sub	w8, w10, w8
Lloh21:
	adrp	x11, _POKEY_POT_input@GOTPAGE
Lloh22:
	ldr	x11, [x11, _POKEY_POT_input@GOTPAGEOFF]
Lloh23:
	ldr	x11, [x11]
Lloh24:
	adrp	x12, _INPUT_mouse_port@GOTPAGE
Lloh25:
	ldr	x12, [x12, _INPUT_mouse_port@GOTPAGEOFF]
	ldr	w13, [x12]
	lsl	w13, w13, #1
	str	w8, [x11, w13, sxtw #2]
	sub	w8, w10, w9
	ldr	w9, [x12]
	mov	w10, #1
	bfi	w10, w9, #1, #31
	str	w8, [x11, w10, sxtw #2]
	b	LBB0_5
LBB0_4:
	adrp	x9, _Atari_Mouse.last_x@PAGE
	ldr	w10, [x9, _Atari_Mouse.last_x@PAGEOFF]
	sub	w10, w8, w10
Lloh26:
	adrp	x11, _INPUT_mouse_delta_x@GOTPAGE
Lloh27:
	ldr	x11, [x11, _INPUT_mouse_delta_x@GOTPAGEOFF]
Lloh28:
	str	w10, [x11]
	ldr	w10, [sp, #24]
	adrp	x11, _Atari_Mouse.last_y@PAGE
	ldr	w12, [x11, _Atari_Mouse.last_y@PAGEOFF]
	sub	w12, w10, w12
Lloh29:
	adrp	x13, _INPUT_mouse_delta_y@GOTPAGE
Lloh30:
	ldr	x13, [x13, _INPUT_mouse_delta_y@GOTPAGEOFF]
Lloh31:
	str	w12, [x13]
	str	w8, [x9, _Atari_Mouse.last_x@PAGEOFF]
	str	w10, [x11, _Atari_Mouse.last_y@PAGEOFF]
LBB0_5:
	ldr	w8, [sp, #20]
Lloh32:
	adrp	x9, _Button1Mask@GOTPAGE
Lloh33:
	ldr	x9, [x9, _Button1Mask@GOTPAGEOFF]
Lloh34:
	ldr	w9, [x9]
	tst	w9, w8
	cset	w9, ne
Lloh35:
	adrp	x10, _Button3Mask@GOTPAGE
Lloh36:
	ldr	x10, [x10, _Button3Mask@GOTPAGEOFF]
Lloh37:
	ldr	w10, [x10]
	tst	w10, w8
	cset	w10, ne
	bfi	w9, w10, #1, #1
Lloh38:
	adrp	x10, _Button2Mask@GOTPAGE
Lloh39:
	ldr	x10, [x10, _Button2Mask@GOTPAGEOFF]
Lloh40:
	ldr	w10, [x10]
	tst	w10, w8
	cset	w8, ne
	bfi	w9, w8, #2, #1
Lloh41:
	adrp	x8, _INPUT_mouse_buttons@GOTPAGE
Lloh42:
	ldr	x8, [x8, _INPUT_mouse_buttons@GOTPAGEOFF]
Lloh43:
	str	w9, [x8]
LBB0_6:
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	add	sp, sp, #64
	ret
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotStr	Lloh29, Lloh30, Lloh31
	.loh AdrpLdrGotStr	Lloh26, Lloh27, Lloh28
	.loh AdrpLdrGotStr	Lloh41, Lloh42, Lloh43
	.loh AdrpLdrGotLdr	Lloh38, Lloh39, Lloh40
	.loh AdrpLdrGotLdr	Lloh35, Lloh36, Lloh37
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.cfi_endproc
                                        ; -- End function
.zerofill __DATA,__bss,_Atari_Mouse.last_x,4,2 ; @Atari_Mouse.last_x
.zerofill __DATA,__bss,_Atari_Mouse.last_y,4,2 ; @Atari_Mouse.last_y
	.comm	_INPUT_mouse_mode,8,3           ; @INPUT_mouse_mode
	.comm	_INPUT_MOUSE_OFF,8,3            ; @INPUT_MOUSE_OFF
	.comm	_display,4,2                    ; @display
	.comm	_window,4,2                     ; @window
	.comm	_INPUT_direct_mouse,8,3         ; @INPUT_direct_mouse
	.comm	_window_width,8,3               ; @window_width
	.comm	_window_height,8,3              ; @window_height
	.comm	_POKEY_POT_input,8,3            ; @POKEY_POT_input
	.comm	_INPUT_mouse_port,4,2           ; @INPUT_mouse_port
	.comm	_INPUT_mouse_delta_x,4,2        ; @INPUT_mouse_delta_x
	.comm	_INPUT_mouse_delta_y,4,2        ; @INPUT_mouse_delta_y
	.comm	_Button1Mask,4,2                ; @Button1Mask
	.comm	_Button3Mask,4,2                ; @Button3Mask
	.comm	_Button2Mask,4,2                ; @Button2Mask
	.comm	_INPUT_mouse_buttons,4,2        ; @INPUT_mouse_buttons
.subsections_via_symbols
