	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_wiiuse_handshake               ## -- Begin function wiiuse_handshake
	.p2align	4, 0x90
_wiiuse_handshake:                      ## @wiiuse_handshake
	.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
	pushq	%rax
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movl	(%rdi), %eax
	cmpl	$2, %eax
	je	LBB0_11
## %bb.1:
	cmpl	$1, %eax
	je	LBB0_5
## %bb.2:
	testl	%eax, %eax
	jne	LBB0_13
## %bb.3:
	movl	$1, (%r14)
	movq	_WIIMOTE_LED_NONE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	xorl	%edx, %edx
	callq	_wiiuse_set_leds
	leaq	_wiiuse_handshake(%rip), %rsi
	movq	%r14, %rdi
	jmp	LBB0_4
LBB0_11:
	movl	8(%rbx), %edi
	callq	_BIG_ENDIAN_LONG
	movq	_EXP_ID_CODE_CLASSIC_WIIU_PRO@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jne	LBB0_7
## %bb.12:
	movq	%rbx, %rdi
	xorl	%esi, %esi
	movl	$8, %edx
	callq	_memset
	movq	_WIIMOTE_STATE_WIIU_PRO@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	callq	_WIIMOTE_ENABLE_STATE
LBB0_13:
	movl	(%rbx), %eax
	movl	12(%rbx), %ecx
	shrl	$4, %ecx
	andl	$3, %ecx
	leal	(%rcx,%rax,4), %edx
	movl	%edx, 8(%r14)
	movl	4(%rbx), %eax
	movl	12(%rbx), %ecx
	shrl	$2, %ecx
	andl	$3, %ecx
	leal	(%rcx,%rax,4), %ecx
	movl	%ecx, 12(%r14)
	movl	8(%rbx), %eax
	movl	12(%rbx), %esi
	andl	$3, %esi
	leal	(%rsi,%rax,4), %eax
	movl	%eax, 16(%r14)
	movl	16(%rbx), %esi
	movl	28(%rbx), %edi
	shll	$2, %esi
	shrl	$4, %edi
	andl	$3, %edi
	subl	%edx, %esi
	addl	%edi, %esi
	movl	%esi, 20(%r14)
	movl	20(%rbx), %edx
	movl	28(%rbx), %esi
	shll	$2, %edx
	shrl	$2, %esi
	andl	$3, %esi
	subl	%ecx, %edx
	addl	%esi, %edx
	movl	%edx, 24(%r14)
	movl	24(%rbx), %ecx
	movl	28(%rbx), %edx
	shll	$2, %ecx
	andl	$3, %edx
	subl	%eax, %ecx
	addl	%edx, %ecx
	movl	%ecx, 28(%r14)
	movq	%rbx, %rdi
	callq	___lwp_wkspace_free
	movq	_WIIMOTE_STATE_HANDSHAKE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	callq	_WIIMOTE_DISABLE_STATE
	movq	_WIIMOTE_STATE_HANDSHAKE_COMPLETE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	callq	_WIIMOTE_ENABLE_STATE
	movq	_WIIUSE_CONNECT@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 4(%r14)
	movq	%r14, %rdi
	xorl	%esi, %esi
LBB0_4:
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_wiiuse_status                  ## TAILCALL
LBB0_5:
	movl	%edx, %r15d
	movl	$2, (%r14)
	movl	$32, %edi
	callq	___lwp_wkspace_allocate
	cmpl	$3, %r15d
	jl	LBB0_6
## %bb.8:
	movq	_WM_CTRL_STATUS_BYTE1_ATTACHMENT@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	testl	%ecx, 8(%rbx)
	je	LBB0_6
## %bb.9:
	movq	_WM_EXP_ID@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	leaq	_wiiuse_handshake(%rip), %r8
	movq	%r14, %rdi
	movq	%rax, %rsi
	movl	$6, %ecx
	jmp	LBB0_10
LBB0_6:
	movq	%rax, %rbx
LBB0_7:
	incl	(%r14)
	movq	_WM_MEM_OFFSET_CALIBRATION@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	leaq	_wiiuse_handshake(%rip), %r8
	movq	%r14, %rdi
	movq	%rbx, %rsi
	movl	$7, %ecx
LBB0_10:
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_wiiuse_read_data               ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_WIIMOTE_LED_NONE,4,2           ## @WIIMOTE_LED_NONE
	.comm	_WM_CTRL_STATUS_BYTE1_ATTACHMENT,4,2 ## @WM_CTRL_STATUS_BYTE1_ATTACHMENT
	.comm	_WM_EXP_ID,4,2                  ## @WM_EXP_ID
	.comm	_EXP_ID_CODE_CLASSIC_WIIU_PRO,4,2 ## @EXP_ID_CODE_CLASSIC_WIIU_PRO
	.comm	_WIIMOTE_STATE_WIIU_PRO,4,2     ## @WIIMOTE_STATE_WIIU_PRO
	.comm	_WM_MEM_OFFSET_CALIBRATION,4,2  ## @WM_MEM_OFFSET_CALIBRATION
	.comm	_WIIMOTE_STATE_HANDSHAKE,4,2    ## @WIIMOTE_STATE_HANDSHAKE
	.comm	_WIIMOTE_STATE_HANDSHAKE_COMPLETE,4,2 ## @WIIMOTE_STATE_HANDSHAKE_COMPLETE
	.comm	_WIIUSE_CONNECT,4,2             ## @WIIUSE_CONNECT
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_wiiuse_handshake               ; -- Begin function wiiuse_handshake
	.p2align	2
_wiiuse_handshake:                      ; @wiiuse_handshake
	.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	x20, x1
	mov	x19, x0
	ldr	w8, [x0]
	cmp	w8, #2
	b.eq	LBB0_4
; %bb.1:
	cmp	w8, #1
	b.eq	LBB0_8
; %bb.2:
	cbnz	w8, LBB0_6
; %bb.3:
	mov	w8, #1
	str	w8, [x19]
Lloh0:
	adrp	x8, _WIIMOTE_LED_NONE@GOTPAGE
Lloh1:
	ldr	x8, [x8, _WIIMOTE_LED_NONE@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	mov	x0, x19
	mov	x2, #0
	bl	_wiiuse_set_leds
Lloh3:
	adrp	x1, _wiiuse_handshake@PAGE
Lloh4:
	add	x1, x1, _wiiuse_handshake@PAGEOFF
	mov	x0, x19
	b	LBB0_7
LBB0_4:
	ldr	w0, [x20, #8]
	bl	_BIG_ENDIAN_LONG
Lloh5:
	adrp	x8, _EXP_ID_CODE_CLASSIC_WIIU_PRO@GOTPAGE
Lloh6:
	ldr	x8, [x8, _EXP_ID_CODE_CLASSIC_WIIU_PRO@GOTPAGEOFF]
Lloh7:
	ldr	w8, [x8]
	cmp	w0, w8
	b.ne	LBB0_12
; %bb.5:
	mov	x0, x20
	mov	w1, #0
	mov	w2, #8
	bl	_memset
Lloh8:
	adrp	x8, _WIIMOTE_STATE_WIIU_PRO@GOTPAGE
Lloh9:
	ldr	x8, [x8, _WIIMOTE_STATE_WIIU_PRO@GOTPAGEOFF]
Lloh10:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_WIIMOTE_ENABLE_STATE
LBB0_6:
	ldr	w8, [x20]
	lsl	w8, w8, #2
	ldr	w9, [x20, #12]
	bfxil	w8, w9, #4, #2
	str	w8, [x19, #8]
	ldr	w9, [x20, #4]
	lsl	w9, w9, #2
	ldr	w10, [x20, #12]
	bfxil	w9, w10, #2, #2
	str	w9, [x19, #12]
	ldp	w10, w11, [x20, #8]
	bfi	w11, w10, #2, #30
	str	w11, [x19, #16]
	ldr	w10, [x20, #16]
	lsl	w10, w10, #2
	ldr	w12, [x20, #28]
	ubfx	w12, w12, #4, #2
	sub	w8, w10, w8
	add	w8, w8, w12
	str	w8, [x19, #20]
	ldr	w8, [x20, #20]
	lsl	w8, w8, #2
	ldr	w10, [x20, #28]
	ubfx	w10, w10, #2, #2
	sub	w8, w8, w9
	add	w8, w8, w10
	str	w8, [x19, #24]
	ldp	w8, w9, [x20, #24]
	lsl	w8, w8, #2
	and	w9, w9, #0x3
	sub	w8, w8, w11
	add	w8, w8, w9
	str	w8, [x19, #28]
	mov	x0, x20
	bl	___lwp_wkspace_free
Lloh11:
	adrp	x8, _WIIMOTE_STATE_HANDSHAKE@GOTPAGE
Lloh12:
	ldr	x8, [x8, _WIIMOTE_STATE_HANDSHAKE@GOTPAGEOFF]
Lloh13:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_WIIMOTE_DISABLE_STATE
Lloh14:
	adrp	x8, _WIIMOTE_STATE_HANDSHAKE_COMPLETE@GOTPAGE
Lloh15:
	ldr	x8, [x8, _WIIMOTE_STATE_HANDSHAKE_COMPLETE@GOTPAGEOFF]
Lloh16:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_WIIMOTE_ENABLE_STATE
Lloh17:
	adrp	x8, _WIIUSE_CONNECT@GOTPAGE
Lloh18:
	ldr	x8, [x8, _WIIUSE_CONNECT@GOTPAGEOFF]
Lloh19:
	ldr	w8, [x8]
	str	w8, [x19, #4]
	mov	x0, x19
	mov	x1, #0
LBB0_7:
	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
	b	_wiiuse_status
LBB0_8:
	mov	x21, x2
	mov	w8, #2
	str	w8, [x19]
	mov	w0, #32
	bl	___lwp_wkspace_allocate
	mov	x1, x0
	cmp	w21, #3
	b.lt	LBB0_11
; %bb.9:
	ldr	w8, [x20, #8]
Lloh20:
	adrp	x9, _WM_CTRL_STATUS_BYTE1_ATTACHMENT@GOTPAGE
Lloh21:
	ldr	x9, [x9, _WM_CTRL_STATUS_BYTE1_ATTACHMENT@GOTPAGEOFF]
Lloh22:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_11
; %bb.10:
Lloh23:
	adrp	x8, _WM_EXP_ID@GOTPAGE
Lloh24:
	ldr	x8, [x8, _WM_EXP_ID@GOTPAGEOFF]
Lloh25:
	adrp	x4, _wiiuse_handshake@PAGE
Lloh26:
	add	x4, x4, _wiiuse_handshake@PAGEOFF
Lloh27:
	ldr	w2, [x8]
	mov	x0, x19
	mov	w3, #6
	b	LBB0_13
LBB0_11:
	mov	x20, x1
LBB0_12:
	ldr	w8, [x19]
	add	w8, w8, #1
	str	w8, [x19]
Lloh28:
	adrp	x8, _WM_MEM_OFFSET_CALIBRATION@GOTPAGE
Lloh29:
	ldr	x8, [x8, _WM_MEM_OFFSET_CALIBRATION@GOTPAGEOFF]
Lloh30:
	adrp	x4, _wiiuse_handshake@PAGE
Lloh31:
	add	x4, x4, _wiiuse_handshake@PAGEOFF
Lloh32:
	ldr	w2, [x8]
	mov	x0, x19
	mov	x1, x20
	mov	w3, #7
LBB0_13:
	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
	b	_wiiuse_read_data
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh27
	.loh AdrpAdd	Lloh30, Lloh31
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh32
	.cfi_endproc
                                        ; -- End function
	.comm	_WIIMOTE_LED_NONE,4,2           ; @WIIMOTE_LED_NONE
	.comm	_WM_CTRL_STATUS_BYTE1_ATTACHMENT,4,2 ; @WM_CTRL_STATUS_BYTE1_ATTACHMENT
	.comm	_WM_EXP_ID,4,2                  ; @WM_EXP_ID
	.comm	_EXP_ID_CODE_CLASSIC_WIIU_PRO,4,2 ; @EXP_ID_CODE_CLASSIC_WIIU_PRO
	.comm	_WIIMOTE_STATE_WIIU_PRO,4,2     ; @WIIMOTE_STATE_WIIU_PRO
	.comm	_WM_MEM_OFFSET_CALIBRATION,4,2  ; @WM_MEM_OFFSET_CALIBRATION
	.comm	_WIIMOTE_STATE_HANDSHAKE,4,2    ; @WIIMOTE_STATE_HANDSHAKE
	.comm	_WIIMOTE_STATE_HANDSHAKE_COMPLETE,4,2 ; @WIIMOTE_STATE_HANDSHAKE_COMPLETE
	.comm	_WIIUSE_CONNECT,4,2             ; @WIIUSE_CONNECT
.subsections_via_symbols
