	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function ps2mult_connect
_ps2mult_connect:                       ## @ps2mult_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	%r13
	pushq	%r12
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	cmpl	$0, 52(%rdi)
	je	LBB0_1
## %bb.3:
	movq	%rsi, %r13
	movq	%rdi, %r14
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	$56, %edi
	callq	_kzalloc
	testq	%rax, %rax
	je	LBB0_4
## %bb.5:
	movq	%rax, %r15
	movq	%rax, %rdi
	addq	$48, %rdi
	callq	_spin_lock_init
	movq	%r14, 40(%r15)
	movq	_PS2MULT_NUM_PORTS@GOTPCREL(%rip), %r12
	cmpl	$0, (%r12)
	jle	LBB0_6
## %bb.7:
	movq	%r13, -48(%rbp)                 ## 8-byte Spill
	movq	%r14, -56(%rbp)                 ## 8-byte Spill
	movl	$8, %r12d
	xorl	%ebx, %ebx
	movq	_ps2mult_controls@GOTPCREL(%rip), %r14
	.p2align	4, 0x90
LBB0_8:                                 ## =>This Inner Loop Header: Depth=1
	movq	(%r14), %rax
	movl	(%rax,%rbx,4), %eax
	movq	(%r15), %rcx
	movl	%eax, (%rcx,%r12)
	movq	%r15, %rdi
	movl	%ebx, %esi
	callq	_ps2mult_create_port
	testl	%eax, %eax
	jne	LBB0_16
## %bb.9:                               ##   in Loop: Header=BB0_8 Depth=1
	incq	%rbx
	movq	_PS2MULT_NUM_PORTS@GOTPCREL(%rip), %rax
	movslq	(%rax), %rax
	addq	$16, %r12
	cmpq	%rax, %rbx
	jl	LBB0_8
## %bb.10:
	movq	-56(%rbp), %r14                 ## 8-byte Reload
	movq	_PS2MULT_NUM_PORTS@GOTPCREL(%rip), %r12
	movq	-48(%rbp), %r13                 ## 8-byte Reload
	jmp	LBB0_11
LBB0_1:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	jmp	LBB0_2
LBB0_4:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
LBB0_2:
	xorl	%r13d, %r13d
	subl	(%rax), %r13d
	jmp	LBB0_21
LBB0_6:
	xorl	%ebx, %ebx
LBB0_11:
	movq	_PS2MULT_KBD_PORT@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	shlq	$4, %rax
	addq	(%r15), %rax
	movq	%rax, 24(%r15)
	movq	%rax, 32(%r15)
	movq	%r14, %rdi
	movq	%r15, %rsi
	callq	_serio_set_drvdata
	movq	%r14, %rdi
	movq	%r13, %rsi
	callq	_serio_open
	movl	%eax, %r13d
	testl	%eax, %eax
	jne	LBB0_17
## %bb.12:
	movq	%r15, %rdi
	callq	_ps2mult_reset
	cmpl	$0, (%r12)
	jle	LBB0_13
## %bb.14:
	leaq	16(%r14), %rax
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
	movq	%r14, -56(%rbp)                 ## 8-byte Spill
	xorl	%r14d, %r14d
	movq	%r15, -64(%rbp)                 ## 8-byte Spill
	.p2align	4, 0x90
LBB0_15:                                ## =>This Inner Loop Header: Depth=1
	movq	(%r15), %rax
	movq	%r12, %r15
	movq	(%rax,%rbx), %r12
	movl	12(%r12), %edx
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movl	8(%rax), %ecx
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	leaq	L_.str(%rip), %rsi
	callq	_dev_info
	movq	%r12, %rdi
	movq	%r15, %r12
	movq	-64(%rbp), %r15                 ## 8-byte Reload
	callq	_serio_register_port
	incq	%r14
	movslq	(%r12), %rax
	addq	$16, %rbx
	cmpq	%rax, %r14
	jl	LBB0_15
	jmp	LBB0_21
LBB0_16:
	movl	%eax, %r13d
LBB0_17:
	testl	%ebx, %ebx
	jle	LBB0_20
## %bb.18:
	movl	%ebx, %r14d
	leaq	1(%r14), %rbx
	shlq	$4, %r14
	addq	$-16, %r14
	.p2align	4, 0x90
LBB0_19:                                ## =>This Inner Loop Header: Depth=1
	movq	(%r15), %rax
	movq	(%rax,%r14), %rdi
	callq	_kfree
	decq	%rbx
	addq	$-16, %r14
	cmpq	$1, %rbx
	ja	LBB0_19
LBB0_20:
	movq	%r15, %rdi
	callq	_kfree
LBB0_21:
	movl	%r13d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_13:
	xorl	%r13d, %r13d
	jmp	LBB0_21
	.cfi_endproc
                                        ## -- End function
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_PS2MULT_NUM_PORTS,4,2          ## @PS2MULT_NUM_PORTS
	.comm	_ps2mult_controls,8,3           ## @ps2mult_controls
	.comm	_PS2MULT_KBD_PORT,8,3           ## @PS2MULT_KBD_PORT
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"%s port at %s\n"

	.no_dead_strip	_ps2mult_connect
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function ps2mult_connect
_ps2mult_connect:                       ; @ps2mult_connect
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	ldr	w8, [x0, #52]
	cbz	w8, LBB0_6
; %bb.1:
	mov	x21, x1
	mov	x20, x0
Lloh0:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh1:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	mov	w0, #56
	bl	_kzalloc
	cbz	x0, LBB0_7
; %bb.2:
	mov	x19, x0
	add	x0, x0, #48
	bl	_spin_lock_init
	str	x20, [x19, #40]
Lloh3:
	adrp	x24, _PS2MULT_NUM_PORTS@GOTPAGE
Lloh4:
	ldr	x24, [x24, _PS2MULT_NUM_PORTS@GOTPAGEOFF]
	ldr	w8, [x24]
	cmp	w8, #1
	b.lt	LBB0_9
; %bb.3:
	mov	x22, #0
	mov	w25, #8
Lloh5:
	adrp	x26, _ps2mult_controls@GOTPAGE
Lloh6:
	ldr	x26, [x26, _ps2mult_controls@GOTPAGEOFF]
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x26]
	ldr	w8, [x8, x22, lsl #2]
	ldr	x9, [x19]
	str	w8, [x9, x25]
	mov	x0, x19
	mov	x1, x22
	bl	_ps2mult_create_port
	cbnz	w0, LBB0_15
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	add	x22, x22, #1
	ldrsw	x8, [x24]
	add	x25, x25, #16
	cmp	x22, x8
	b.lt	LBB0_4
	b	LBB0_10
LBB0_6:
Lloh7:
	adrp	x8, _EINVAL@GOTPAGE
Lloh8:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
	b	LBB0_8
LBB0_7:
Lloh9:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh10:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
LBB0_8:
	ldr	w8, [x8]
	neg	w23, w8
	b	LBB0_20
LBB0_9:
	mov	w22, #0
LBB0_10:
	ldr	x8, [x19]
Lloh11:
	adrp	x9, _PS2MULT_KBD_PORT@GOTPAGE
Lloh12:
	ldr	x9, [x9, _PS2MULT_KBD_PORT@GOTPAGEOFF]
Lloh13:
	ldr	x9, [x9]
	add	x8, x8, x9, lsl #4
	stp	x8, x8, [x19, #24]
	mov	x0, x20
	mov	x1, x19
	bl	_serio_set_drvdata
	mov	x0, x20
	mov	x1, x21
	bl	_serio_open
	mov	x23, x0
	cbnz	w0, LBB0_16
; %bb.11:
	mov	x0, x19
	bl	_ps2mult_reset
	ldr	w8, [x24]
	cmp	w8, #1
	b.lt	LBB0_14
; %bb.12:
	mov	x25, #0
	mov	x26, #0
	add	x21, x20, #16
Lloh14:
	adrp	x22, l_.str@PAGE
Lloh15:
	add	x22, x22, l_.str@PAGEOFF
LBB0_13:                                ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x19]
	ldr	x23, [x8, x25]
	ldr	w2, [x23, #12]
	ldr	w3, [x20, #8]
	mov	x0, x21
	mov	x1, x22
	bl	_dev_info
	mov	x0, x23
	bl	_serio_register_port
	add	x26, x26, #1
	ldrsw	x8, [x24]
	add	x25, x25, #16
	cmp	x26, x8
	b.lt	LBB0_13
LBB0_14:
	mov	w23, #0
	b	LBB0_20
LBB0_15:
	mov	x23, x0
LBB0_16:
	cmp	w22, #1
	b.lt	LBB0_19
; %bb.17:
	mov	w8, w22
	add	x20, x8, #1
	lsl	x8, x8, #4
	sub	x21, x8, #16
LBB0_18:                                ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x19]
	ldr	x0, [x8, x21]
	bl	_kfree
	sub	x20, x20, #1
	sub	x21, x21, #16
	cmp	x20, #1
	b.hi	LBB0_18
LBB0_19:
	mov	x0, x19
	bl	_kfree
LBB0_20:
	mov	x0, x23
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpAdd	Lloh14, Lloh15
	.cfi_endproc
                                        ; -- End function
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_PS2MULT_NUM_PORTS,4,2          ; @PS2MULT_NUM_PORTS
	.comm	_ps2mult_controls,8,3           ; @ps2mult_controls
	.comm	_PS2MULT_KBD_PORT,8,3           ; @PS2MULT_KBD_PORT
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"%s port at %s\n"

	.no_dead_strip	_ps2mult_connect
.subsections_via_symbols
