	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_gp2x_touchpad_read             ## -- Begin function gp2x_touchpad_read
	.p2align	4, 0x90
_gp2x_touchpad_read:                    ## @gp2x_touchpad_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	%rbx
	subq	$24, %rsp
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r15
	movq	_touchdev@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	movl	$-1, %ebx
	testq	%rdi, %rdi
	js	LBB0_10
## %bb.1:
	movq	%rsi, %r14
	leaq	-40(%rbp), %rsi
	movl	$16, %edx
	callq	_read
	testl	%eax, %eax
	jle	LBB0_2
## %bb.3:
	movq	-40(%rbp), %rax
	testq	%rax, %rax
	jne	LBB0_5
## %bb.4:
	movb	$1, _gp2x_touchpad_read.zero_seen(%rip)
LBB0_5:
	testq	%r15, %r15
	je	LBB0_7
## %bb.6:
	movq	_touchcal@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movl	(%rcx), %edx
	imull	-32(%rbp), %edx
	addl	8(%rcx), %edx
	sarl	$16, %edx
	movl	%edx, (%r15)
LBB0_7:
	testq	%r14, %r14
	je	LBB0_9
## %bb.8:
	movq	_touchcal@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movl	16(%rcx), %edx
	imull	-28(%rbp), %edx
	addl	20(%rcx), %edx
	sarl	$16, %edx
	movl	%edx, (%r14)
LBB0_9:
	xorl	%ebx, %ebx
	cmpb	$0, _gp2x_touchpad_read.zero_seen(%rip)
	cmovnel	%eax, %ebx
LBB0_10:
	movl	%ebx, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_2:
	leaq	L_.str(%rip), %rdi
	callq	_perror
	jmp	LBB0_10
	.cfi_endproc
                                        ## -- End function
.zerofill __DATA,__bss,_gp2x_touchpad_read.zero_seen,1,2 ## @gp2x_touchpad_read.zero_seen
	.comm	_touchdev,8,3                   ## @touchdev
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"touch read failed"

	.comm	_touchcal,8,3                   ## @touchcal
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_gp2x_touchpad_read             ; -- Begin function gp2x_touchpad_read
	.p2align	2
_gp2x_touchpad_read:                    ; @gp2x_touchpad_read
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #48
	.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
	mov	x20, x0
Lloh0:
	adrp	x8, _touchdev@GOTPAGE
Lloh1:
	ldr	x8, [x8, _touchdev@GOTPAGEOFF]
Lloh2:
	ldr	x0, [x8]
	tbnz	x0, #63, LBB0_10
; %bb.1:
	mov	x19, x1
	mov	x1, sp
	mov	w2, #16
	bl	_read
	cmp	w0, #0
	b.le	LBB0_9
; %bb.2:
	ldr	x8, [sp]
	adrp	x9, _gp2x_touchpad_read.zero_seen@PAGE
	cbnz	x8, LBB0_4
; %bb.3:
	mov	w10, #1
	strb	w10, [x9, _gp2x_touchpad_read.zero_seen@PAGEOFF]
LBB0_4:
Lloh3:
	adrp	x10, _touchcal@GOTPAGE
Lloh4:
	ldr	x10, [x10, _touchcal@GOTPAGEOFF]
	cbz	x20, LBB0_6
; %bb.5:
	ldr	w11, [sp, #8]
	ldr	x12, [x10]
	ldr	w13, [x12]
	ldr	w12, [x12, #8]
	madd	w11, w13, w11, w12
	asr	w11, w11, #16
	str	w11, [x20]
LBB0_6:
	cbz	x19, LBB0_8
; %bb.7:
	ldr	w11, [sp, #12]
	ldr	x10, [x10]
	ldp	w12, w10, [x10, #16]
	madd	w10, w12, w11, w10
	asr	w10, w10, #16
	str	w10, [x19]
LBB0_8:
	ldrb	w9, [x9, _gp2x_touchpad_read.zero_seen@PAGEOFF]
	cmp	w9, #0
	csel	w0, w8, wzr, ne
	b	LBB0_11
LBB0_9:
Lloh5:
	adrp	x0, l_.str@PAGE
Lloh6:
	add	x0, x0, l_.str@PAGEOFF
	bl	_perror
LBB0_10:
	mov	w0, #-1
LBB0_11:
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpAdd	Lloh5, Lloh6
	.cfi_endproc
                                        ; -- End function
.zerofill __DATA,__bss,_gp2x_touchpad_read.zero_seen,1,2 ; @gp2x_touchpad_read.zero_seen
	.comm	_touchdev,8,3                   ; @touchdev
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"touch read failed"

	.comm	_touchcal,8,3                   ; @touchcal
.subsections_via_symbols
