	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function cyapa_gen3_set_power_mode
_cyapa_gen3_set_power_mode:             ## @cyapa_gen3_set_power_mode
	.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
	movl	%esi, -48(%rbp)                 ## 4-byte Spill
	movq	(%rdi), %rax
	movq	_CYAPA_STATE_OP@GOTPCREL(%rip), %rdx
	xorl	%r14d, %r14d
	cmpq	(%rdx), %rax
	jne	LBB0_23
## %bb.1:
	movq	_SET_POWER_MODE_TRIES@GOTPCREL(%rip), %rax
	movl	(%rax), %r13d
	testl	%r13d, %r13d
	je	LBB0_2
## %bb.3:
	movq	%rdi, %r15
	movl	%ecx, -52(%rbp)                 ## 4-byte Spill
	movq	16(%rdi), %rax
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	movq	_CYAPA_CMD_POWER_MODE@GOTPCREL(%rip), %r12
	.p2align	4, 0x90
LBB0_4:                                 ## =>This Inner Loop Header: Depth=1
	movl	(%r12), %esi
	movq	%r15, %rdi
	callq	_cyapa_read_byte
	movl	%eax, %ebx
	testl	%eax, %eax
	jns	LBB0_6
## %bb.5:                               ##   in Loop: Header=BB0_4 Depth=1
	movq	_SET_POWER_MODE_DELAY@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leal	(%rdi,%rdi), %esi
                                        ## kill: def $edi killed $edi killed $rdi
	callq	_usleep_range
	movl	%ebx, %r14d
	decl	%r13d
	jne	LBB0_4
	jmp	LBB0_23
LBB0_2:
                                        ## implicit-def: $r14d
	jmp	LBB0_23
LBB0_6:
	movq	_PWR_MODE_MASK@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	andl	%ebx, %edi
	movl	$0, %r14d
	cmpl	-48(%rbp), %edi                 ## 4-byte Folded Reload
	je	LBB0_23
## %bb.7:
	movq	%rax, %r14
	callq	_cyapa_get_wait_time_for_pwr_cmd
	movq	_SET_POWER_MODE_TRIES@GOTPCREL(%rip), %rcx
	movl	(%rcx), %r13d
	testl	%r13d, %r13d
	je	LBB0_8
## %bb.9:
	movl	-48(%rbp), %ecx                 ## 4-byte Reload
	xorl	%ebx, %ecx
	andl	(%r14), %ecx
	xorl	%ebx, %ecx
	movl	%ecx, %ebx
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	.p2align	4, 0x90
LBB0_10:                                ## =>This Inner Loop Header: Depth=1
	movl	(%r12), %esi
	movq	%r15, %rdi
	movl	%ebx, %edx
	callq	_cyapa_write_byte
	testl	%eax, %eax
	je	LBB0_11
## %bb.12:                              ##   in Loop: Header=BB0_10 Depth=1
	movl	%eax, %r14d
	movq	_SET_POWER_MODE_DELAY@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leal	(%rdi,%rdi), %esi
                                        ## kill: def $edi killed $edi killed $rdi
	callq	_usleep_range
	decl	%r13d
	jne	LBB0_10
	jmp	LBB0_13
LBB0_8:
	movl	%ebx, %r14d
	movq	%rax, %rbx
	jmp	LBB0_14
LBB0_11:
	xorl	%r14d, %r14d
LBB0_13:
	movq	-48(%rbp), %rbx                 ## 8-byte Reload
LBB0_14:
	cmpq	$0, 8(%r15)
	movl	-52(%rbp), %ecx                 ## 4-byte Reload
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	je	LBB0_24
## %bb.15:
	testq	%rax, %rax
	je	LBB0_24
## %bb.16:
	cmpq	$0, (%rax)
	je	LBB0_24
## %bb.17:
	movq	_CYAPA_PM_RUNTIME_SUSPEND@GOTPCREL(%rip), %rax
	cmpl	%ecx, (%rax)
	je	LBB0_19
## %bb.18:
	movq	_CYAPA_PM_RUNTIME_RESUME@GOTPCREL(%rip), %rax
	cmpl	%ecx, (%rax)
	je	LBB0_19
LBB0_24:
	movl	%ebx, %edi
	callq	_msleep
LBB0_23:
	movl	%r14d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_19:
	testl	%ebx, %ebx
	jle	LBB0_23
## %bb.20:
	cmpl	$9, %ebx
	jb	LBB0_22
LBB0_21:                                ## =>This Inner Loop Header: Depth=1
	movl	$8, %edi
	callq	_msleep
	addl	$-8, %ebx
	movq	%r15, %rdi
	callq	_cyapa_gen3_try_poll_handler
	cmpl	$8, %ebx
	ja	LBB0_21
LBB0_22:
	movl	%ebx, %edi
	callq	_msleep
	movq	%r15, %rdi
	callq	_cyapa_gen3_try_poll_handler
	jmp	LBB0_23
	.cfi_endproc
                                        ## -- End function
	.comm	_CYAPA_STATE_OP,8,3             ## @CYAPA_STATE_OP
	.comm	_SET_POWER_MODE_TRIES,4,2       ## @SET_POWER_MODE_TRIES
	.comm	_CYAPA_CMD_POWER_MODE,4,2       ## @CYAPA_CMD_POWER_MODE
	.comm	_SET_POWER_MODE_DELAY,4,2       ## @SET_POWER_MODE_DELAY
	.comm	_PWR_MODE_MASK,4,2              ## @PWR_MODE_MASK
	.comm	_CYAPA_PM_RUNTIME_SUSPEND,4,2   ## @CYAPA_PM_RUNTIME_SUSPEND
	.comm	_CYAPA_PM_RUNTIME_RESUME,4,2    ## @CYAPA_PM_RUNTIME_RESUME
	.no_dead_strip	_cyapa_gen3_set_power_mode
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function cyapa_gen3_set_power_mode
_cyapa_gen3_set_power_mode:             ; @cyapa_gen3_set_power_mode
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	ldr	x8, [x0]
Lloh0:
	adrp	x9, _CYAPA_STATE_OP@GOTPAGE
Lloh1:
	ldr	x9, [x9, _CYAPA_STATE_OP@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_7
; %bb.1:
Lloh3:
	adrp	x27, _SET_POWER_MODE_TRIES@GOTPAGE
Lloh4:
	ldr	x27, [x27, _SET_POWER_MODE_TRIES@GOTPAGEOFF]
	ldr	w22, [x27]
	cbz	w22, LBB0_5
; %bb.2:
	mov	x21, x3
	mov	x23, x1
	mov	x19, x0
	ldr	x24, [x0, #16]
Lloh5:
	adrp	x25, _CYAPA_CMD_POWER_MODE@GOTPAGE
Lloh6:
	ldr	x25, [x25, _CYAPA_CMD_POWER_MODE@GOTPAGEOFF]
Lloh7:
	adrp	x26, _SET_POWER_MODE_DELAY@GOTPAGE
Lloh8:
	ldr	x26, [x26, _SET_POWER_MODE_DELAY@GOTPAGEOFF]
LBB0_3:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w1, [x25]
	mov	x0, x19
	bl	_cyapa_read_byte
	mov	x20, x0
	tbz	w0, #31, LBB0_6
; %bb.4:                                ;   in Loop: Header=BB0_3 Depth=1
	sub	w22, w22, #1
	ldr	w0, [x26]
	lsl	w1, w0, #1
	bl	_usleep_range
	cbnz	w22, LBB0_3
	b	LBB0_8
LBB0_5:
                                        ; implicit-def: $w20
	b	LBB0_8
LBB0_6:
Lloh9:
	adrp	x28, _PWR_MODE_MASK@GOTPAGE
Lloh10:
	ldr	x28, [x28, _PWR_MODE_MASK@GOTPAGEOFF]
	ldr	w8, [x28]
	and	w0, w8, w20
	cmp	w0, w23
	b.ne	LBB0_9
LBB0_7:
	mov	w20, #0
LBB0_8:
	mov	x0, x20
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
LBB0_9:
	bl	_cyapa_get_wait_time_for_pwr_cmd
	mov	x22, x0
	ldr	w27, [x27]
	cbz	w27, LBB0_13
; %bb.10:
	ldr	w8, [x28]
	bic	w9, w20, w8
	and	w8, w8, w23
	orr	w23, w9, w8
LBB0_11:                                ; =>This Inner Loop Header: Depth=1
	ldr	w1, [x25]
	mov	x0, x19
	mov	x2, x23
	bl	_cyapa_write_byte
	mov	x20, x0
	cbz	w0, LBB0_13
; %bb.12:                               ;   in Loop: Header=BB0_11 Depth=1
	sub	w27, w27, #1
	ldr	w0, [x26]
	lsl	w1, w0, #1
	bl	_usleep_range
	cbnz	w27, LBB0_11
LBB0_13:
	ldr	x8, [x19, #8]
	cmp	x8, #0
	ccmp	x24, #0, #4, ne
	b.eq	LBB0_20
; %bb.14:
	ldr	x8, [x24]
	cbz	x8, LBB0_20
; %bb.15:
Lloh11:
	adrp	x8, _CYAPA_PM_RUNTIME_SUSPEND@GOTPAGE
Lloh12:
	ldr	x8, [x8, _CYAPA_PM_RUNTIME_SUSPEND@GOTPAGEOFF]
Lloh13:
	ldr	w8, [x8]
Lloh14:
	adrp	x9, _CYAPA_PM_RUNTIME_RESUME@GOTPAGE
Lloh15:
	ldr	x9, [x9, _CYAPA_PM_RUNTIME_RESUME@GOTPAGEOFF]
Lloh16:
	ldr	w9, [x9]
	cmp	w8, w21
	ccmp	w9, w21, #4, ne
	b.ne	LBB0_20
; %bb.16:
	cmp	w22, #1
	b.lt	LBB0_8
; %bb.17:
	cmp	w22, #9
	b.lo	LBB0_19
LBB0_18:                                ; =>This Inner Loop Header: Depth=1
	mov	w0, #8
	bl	_msleep
	sub	w22, w22, #8
	mov	x0, x19
	bl	_cyapa_gen3_try_poll_handler
	cmp	w22, #8
	b.hi	LBB0_18
LBB0_19:
	mov	x0, x22
	bl	_msleep
	mov	x0, x19
	bl	_cyapa_gen3_try_poll_handler
	b	LBB0_8
LBB0_20:
	mov	x0, x22
	bl	_msleep
	b	LBB0_8
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.cfi_endproc
                                        ; -- End function
	.comm	_CYAPA_STATE_OP,8,3             ; @CYAPA_STATE_OP
	.comm	_SET_POWER_MODE_TRIES,4,2       ; @SET_POWER_MODE_TRIES
	.comm	_CYAPA_CMD_POWER_MODE,4,2       ; @CYAPA_CMD_POWER_MODE
	.comm	_SET_POWER_MODE_DELAY,4,2       ; @SET_POWER_MODE_DELAY
	.comm	_PWR_MODE_MASK,4,2              ; @PWR_MODE_MASK
	.comm	_CYAPA_PM_RUNTIME_SUSPEND,4,2   ; @CYAPA_PM_RUNTIME_SUSPEND
	.comm	_CYAPA_PM_RUNTIME_RESUME,4,2    ; @CYAPA_PM_RUNTIME_RESUME
	.no_dead_strip	_cyapa_gen3_set_power_mode
.subsections_via_symbols
