	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function adi_connect
_adi_connect:                           ## @adi_connect
	.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, %rbx
	movq	%rdi, %r14
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	$16, %edi
	callq	_kzalloc
	testq	%rax, %rax
	je	LBB0_1
## %bb.2:
	movq	%rax, %r15
	movq	%r14, 8(%rax)
	movq	%r14, %rdi
	movq	%rax, %rsi
	callq	_gameport_set_drvdata
	movq	_GAMEPORT_MODE_RAW@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r14, %rdi
	movq	%rbx, %rsi
	callq	_gameport_open
	movl	%eax, %r12d
	testl	%eax, %eax
	jne	LBB0_24
## %bb.3:
	movq	%r14, %rdi
	callq	_adi_init_digital
	movq	%r15, %rdi
	callq	_adi_read_packet
	movq	(%r15), %rdi
	movq	(%rdi), %rax
	movq	_ADI_MIN_LEN_LENGTH@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jl	LBB0_5
## %bb.4:
	movl	$10, %esi
	callq	_adi_get_bits
	movq	%r15, %rdi
	movl	%eax, %esi
	callq	_adi_move_bits
	movq	(%r15), %rdi
LBB0_5:
	movq	%r15, %rsi
	callq	_adi_id_decode
	movq	(%r15), %rdi
	cmpq	$0, 8(%rdi)
	je	LBB0_8
## %bb.6:
	movq	%r15, %rsi
	xorl	%edx, %edx
	callq	_adi_init_input
	movl	%eax, %r12d
	testl	%eax, %eax
	jne	LBB0_23
## %bb.7:
	movq	(%r15), %rdi
LBB0_8:
	addq	$24, %rdi
	movq	%r15, %rsi
	callq	_adi_id_decode
	movq	(%r15), %rdi
	cmpq	$0, 32(%rdi)
	je	LBB0_11
## %bb.9:
	addq	$24, %rdi
	movq	%r15, %rsi
	movl	$1, %edx
	callq	_adi_init_input
	movl	%eax, %r12d
	testl	%eax, %eax
	jne	LBB0_23
## %bb.10:
	movq	(%r15), %rdi
LBB0_11:
	cmpq	$0, 8(%rdi)
	jne	LBB0_14
## %bb.12:
	cmpq	$0, 32(%rdi)
	je	LBB0_13
LBB0_14:
	movq	_adi_poll@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	callq	_gameport_set_poll_handler
	movq	%r14, %rdi
	movl	$20, %esi
	callq	_gameport_set_poll_interval
	movq	_ADI_INIT_DELAY@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_msleep
	movq	%r15, %rdi
	callq	_adi_read
	testq	%rax, %rax
	je	LBB0_16
## %bb.15:
	movq	_ADI_DATA_DELAY@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_msleep
	movq	%r15, %rdi
	callq	_adi_read
LBB0_16:
	movq	(%r15), %rdi
	cmpq	$0, 8(%rdi)
	jle	LBB0_19
## %bb.17:
	callq	_adi_init_center
	movq	(%r15), %rax
	movq	16(%rax), %rdi
	callq	_input_register_device
	movl	%eax, %r12d
	testl	%eax, %eax
	jne	LBB0_23
## %bb.18:
	movq	(%r15), %rdi
LBB0_19:
	xorl	%ebx, %ebx
	cmpq	$0, 32(%rdi)
	jle	LBB0_25
## %bb.20:
	addq	$24, %rdi
	callq	_adi_init_center
	movq	(%r15), %rax
	movq	40(%rax), %rdi
	callq	_input_register_device
	testl	%eax, %eax
	je	LBB0_25
## %bb.21:
	movl	%eax, %r12d
	movq	(%r15), %rax
	cmpq	$0, 8(%rax)
	jle	LBB0_23
## %bb.22:
	movq	16(%rax), %rdi
	callq	_input_unregister_device
	movq	(%r15), %rax
	movq	$0, 16(%rax)
	jmp	LBB0_23
LBB0_1:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_25
LBB0_13:
	movq	_ENODEV@GOTPCREL(%rip), %rax
	xorl	%r12d, %r12d
	subl	(%rax), %r12d
LBB0_23:
	movq	(%r15), %rax
	movq	16(%rax), %rdi
	callq	_input_free_device
	movq	(%r15), %rax
	movq	40(%rax), %rdi
	callq	_input_free_device
	movq	%r14, %rdi
	callq	_gameport_close
LBB0_24:
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	_gameport_set_drvdata
	movq	%r15, %rdi
	callq	_kfree
	movl	%r12d, %ebx
LBB0_25:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_GAMEPORT_MODE_RAW,4,2          ## @GAMEPORT_MODE_RAW
	.comm	_ADI_MIN_LEN_LENGTH,8,3         ## @ADI_MIN_LEN_LENGTH
	.comm	_ENODEV,4,2                     ## @ENODEV
	.comm	_adi_poll,4,2                   ## @adi_poll
	.comm	_ADI_INIT_DELAY,4,2             ## @ADI_INIT_DELAY
	.comm	_ADI_DATA_DELAY,4,2             ## @ADI_DATA_DELAY
	.no_dead_strip	_adi_connect
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function adi_connect
_adi_connect:                           ; @adi_connect
	.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	x21, x1
	mov	x19, x0
Lloh0:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh1:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	mov	w0, #16
	bl	_kzalloc
	cbz	x0, LBB0_21
; %bb.1:
	mov	x20, x0
	str	x19, [x0, #8]
	mov	x0, x19
	mov	x1, x20
	bl	_gameport_set_drvdata
Lloh3:
	adrp	x8, _GAMEPORT_MODE_RAW@GOTPAGE
Lloh4:
	ldr	x8, [x8, _GAMEPORT_MODE_RAW@GOTPAGEOFF]
Lloh5:
	ldr	w2, [x8]
	mov	x0, x19
	mov	x1, x21
	bl	_gameport_open
	mov	x21, x0
	cbnz	w0, LBB0_25
; %bb.2:
	mov	x0, x19
	bl	_adi_init_digital
	mov	x0, x20
	bl	_adi_read_packet
	ldr	x0, [x20]
	ldr	x8, [x0]
Lloh6:
	adrp	x9, _ADI_MIN_LEN_LENGTH@GOTPAGE
Lloh7:
	ldr	x9, [x9, _ADI_MIN_LEN_LENGTH@GOTPAGEOFF]
Lloh8:
	ldr	x9, [x9]
	cmp	x8, x9
	b.lt	LBB0_4
; %bb.3:
	mov	w1, #10
	bl	_adi_get_bits
	mov	x1, x0
	mov	x0, x20
	bl	_adi_move_bits
	ldr	x0, [x20]
LBB0_4:
	mov	x1, x20
	bl	_adi_id_decode
	ldr	x0, [x20]
	ldr	x8, [x0, #8]
	cbz	x8, LBB0_7
; %bb.5:
	mov	x1, x20
	mov	w2, #0
	bl	_adi_init_input
	mov	x21, x0
	cbnz	w0, LBB0_24
; %bb.6:
	ldr	x0, [x20]
LBB0_7:
	add	x0, x0, #24
	mov	x1, x20
	bl	_adi_id_decode
	ldr	x8, [x20]
	ldr	x9, [x8, #32]
	cbz	x9, LBB0_10
; %bb.8:
	add	x0, x8, #24
	mov	x1, x20
	mov	w2, #1
	bl	_adi_init_input
	mov	x21, x0
	cbnz	w0, LBB0_24
; %bb.9:
	ldr	x8, [x20]
LBB0_10:
	ldr	x9, [x8, #8]
	cbnz	x9, LBB0_12
; %bb.11:
	ldr	x8, [x8, #32]
	cbz	x8, LBB0_23
LBB0_12:
Lloh9:
	adrp	x8, _adi_poll@GOTPAGE
Lloh10:
	ldr	x8, [x8, _adi_poll@GOTPAGEOFF]
Lloh11:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_gameport_set_poll_handler
	mov	x0, x19
	mov	w1, #20
	bl	_gameport_set_poll_interval
Lloh12:
	adrp	x8, _ADI_INIT_DELAY@GOTPAGE
Lloh13:
	ldr	x8, [x8, _ADI_INIT_DELAY@GOTPAGEOFF]
Lloh14:
	ldr	w0, [x8]
	bl	_msleep
	mov	x0, x20
	bl	_adi_read
	cbz	x0, LBB0_14
; %bb.13:
Lloh15:
	adrp	x8, _ADI_DATA_DELAY@GOTPAGE
Lloh16:
	ldr	x8, [x8, _ADI_DATA_DELAY@GOTPAGEOFF]
Lloh17:
	ldr	w0, [x8]
	bl	_msleep
	mov	x0, x20
	bl	_adi_read
LBB0_14:
	ldr	x0, [x20]
	ldr	x8, [x0, #8]
	cmp	x8, #1
	b.lt	LBB0_17
; %bb.15:
	bl	_adi_init_center
	ldr	x8, [x20]
	ldr	x0, [x8, #16]
	bl	_input_register_device
	mov	x21, x0
	cbnz	w0, LBB0_24
; %bb.16:
	ldr	x0, [x20]
LBB0_17:
	ldr	x8, [x0, #32]
	cmp	x8, #1
	b.lt	LBB0_22
; %bb.18:
	add	x0, x0, #24
	bl	_adi_init_center
	ldr	x8, [x20]
	ldr	x0, [x8, #40]
	bl	_input_register_device
	mov	x21, x0
	cbz	w0, LBB0_26
; %bb.19:
	ldr	x8, [x20]
	ldr	x9, [x8, #8]
	cmp	x9, #1
	b.lt	LBB0_24
; %bb.20:
	ldr	x0, [x8, #16]
	bl	_input_unregister_device
	ldr	x8, [x20]
	str	xzr, [x8, #16]
	b	LBB0_24
LBB0_21:
Lloh18:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh19:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh20:
	ldr	w8, [x8]
	neg	w21, w8
	b	LBB0_26
LBB0_22:
	mov	w21, #0
	b	LBB0_26
LBB0_23:
Lloh21:
	adrp	x8, _ENODEV@GOTPAGE
Lloh22:
	ldr	x8, [x8, _ENODEV@GOTPAGEOFF]
Lloh23:
	ldr	w8, [x8]
	neg	w21, w8
LBB0_24:
	ldr	x8, [x20]
	ldr	x0, [x8, #16]
	bl	_input_free_device
	ldr	x8, [x20]
	ldr	x0, [x8, #40]
	bl	_input_free_device
	mov	x0, x19
	bl	_gameport_close
LBB0_25:
	mov	x0, x19
	mov	x1, #0
	bl	_gameport_set_drvdata
	mov	x0, x20
	bl	_kfree
LBB0_26:
	mov	x0, x21
	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
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.cfi_endproc
                                        ; -- End function
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_GAMEPORT_MODE_RAW,4,2          ; @GAMEPORT_MODE_RAW
	.comm	_ADI_MIN_LEN_LENGTH,8,3         ; @ADI_MIN_LEN_LENGTH
	.comm	_ENODEV,4,2                     ; @ENODEV
	.comm	_adi_poll,4,2                   ; @adi_poll
	.comm	_ADI_INIT_DELAY,4,2             ; @ADI_INIT_DELAY
	.comm	_ADI_DATA_DELAY,4,2             ; @ADI_DATA_DELAY
	.no_dead_strip	_adi_connect
.subsections_via_symbols
