	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function ni_convert_power_state_to_smc
_ni_convert_power_state_to_smc:         ## @ni_convert_power_state_to_smc
	.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	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdx, %r15
	movq	%rsi, %r14
	movq	%rdi, %rbx
	callq	_evergreen_get_pi
	movq	%rax, -80(%rbp)                 ## 8-byte Spill
	movq	%rbx, %rdi
	callq	_ni_get_pi
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	movq	%r14, %rdi
	callq	_ni_get_ps
	movq	%rax, %r12
	movq	8(%rax), %rsi
	movslq	(%rax), %rax
	movl	-4(%rsi,%rax,4), %ecx
	movq	%rcx, -64(%rbp)                 ## 8-byte Spill
	movq	_ATOM_PPLIB_DISALLOW_ON_DC@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	testl	%ecx, (%r14)
	jne	LBB0_2
## %bb.1:
	movq	_PPSMC_SWSTATE_FLAG_DC@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	orl	%ecx, 16(%r15)
LBB0_2:
	movq	$0, (%r15)
	movq	_NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jle	LBB0_3
## %bb.18:
	movq	_EINVAL@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
	jmp	LBB0_19
LBB0_3:
	movq	%rbx, -48(%rbp)                 ## 8-byte Spill
	movq	%r14, -72(%rbp)                 ## 8-byte Spill
	testl	%eax, %eax
	jle	LBB0_13
## %bb.4:
	movq	8(%r15), %rdx
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_ni_convert_power_level_to_smc
	movq	_NISLANDS_DRIVER_STATE_ARB_INDEX@GOTPCREL(%rip), %rbx
	movq	(%rbx), %rdx
	movq	8(%r15), %rcx
	movq	%rdx, 16(%rcx)
	testl	%eax, %eax
	jne	LBB0_19
## %bb.5:
	xorl	%r13d, %r13d
	.p2align	4, 0x90
LBB0_6:                                 ## =>This Inner Loop Header: Depth=1
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	cmpl	$0, (%rax)
	je	LBB0_8
## %bb.7:                               ##   in Loop: Header=BB0_6 Depth=1
	movq	8(%r12), %rax
	movq	-64(%rbp), %rdx                 ## 8-byte Reload
	cmpl	%edx, (%rax,%r13,4)
	setl	%al
	jmp	LBB0_9
	.p2align	4, 0x90
LBB0_8:                                 ##   in Loop: Header=BB0_6 Depth=1
	cmpq	$2, %r13
	setb	%al
LBB0_9:                                 ##   in Loop: Header=BB0_6 Depth=1
	movq	_PPSMC_DISPLAY_WATERMARK_HIGH@GOTPCREL(%rip), %rdx
	testb	%al, %al
	je	LBB0_11
## %bb.10:                              ##   in Loop: Header=BB0_6 Depth=1
	movq	_PPSMC_DISPLAY_WATERMARK_LOW@GOTPCREL(%rip), %rdx
LBB0_11:                                ##   in Loop: Header=BB0_6 Depth=1
	movq	(%rdx), %rax
	leaq	(,%r13,2), %rdx
	addq	%r13, %rdx
	movq	%rax, 8(%rcx,%rdx,8)
	movq	-80(%rbp), %rax                 ## 8-byte Reload
	movq	(%rax), %rax
	movq	_NISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT@GOTPCREL(%rip), %rsi
	movq	(%rsi), %rsi
	addq	%r13, %rsi
	testq	%rax, %rax
	cmoveq	%rax, %rsi
	movq	%rsi, (%rcx,%rdx,8)
	incq	(%r15)
	incq	%r13
	movslq	(%r12), %rax
	cmpq	%rax, %r13
	jge	LBB0_13
## %bb.12:                              ##   in Loop: Header=BB0_6 Depth=1
	leaq	(,%r13,4), %rsi
	addq	8(%r12), %rsi
	leaq	(,%r13,8), %rax
	leaq	(%rax,%rax,2), %r14
	movq	8(%r15), %rdx
	addq	%r14, %rdx
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_ni_convert_power_level_to_smc
	movq	(%rbx), %rdx
	addq	%r13, %rdx
	movq	8(%r15), %rcx
	movq	%rdx, 16(%rcx,%r14)
	testl	%eax, %eax
	je	LBB0_6
LBB0_19:
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_13:
	movq	_NI_SMC_SOFT_REGISTER_watermark_threshold@GOTPCREL(%rip), %rax
	movl	(%rax), %r12d
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	leal	511(%rax), %edi
	testl	%eax, %eax
	cmovnsl	%eax, %edi
	sarl	$9, %edi
	callq	_cpu_to_be32
	movq	-48(%rbp), %r14                 ## 8-byte Reload
	movq	%r14, %rdi
	movl	%r12d, %esi
	movl	%eax, %edx
	callq	_rv770_write_smc_soft_register
	movq	%r14, %rdi
	movq	-72(%rbp), %rbx                 ## 8-byte Reload
	movq	%rbx, %rsi
	movq	%r15, %rdx
	callq	_ni_populate_smc_sp
	movq	%r14, %rdi
	movq	%rbx, %rsi
	movq	%r15, %rdx
	callq	_ni_populate_power_containment_values
	testl	%eax, %eax
	je	LBB0_15
## %bb.14:
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movl	$0, (%rax)
LBB0_15:
	movq	%r14, %rdi
	movq	%rbx, %rsi
	movq	%r15, %rdx
	callq	_ni_populate_sq_ramping_values
	testl	%eax, %eax
	je	LBB0_17
## %bb.16:
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movl	$0, 4(%rax)
LBB0_17:
	movq	%r14, %rdi
	movq	%rbx, %rsi
	movq	%r15, %rdx
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_ni_populate_smc_t              ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_ATOM_PPLIB_DISALLOW_ON_DC,4,2  ## @ATOM_PPLIB_DISALLOW_ON_DC
	.comm	_PPSMC_SWSTATE_FLAG_DC,4,2      ## @PPSMC_SWSTATE_FLAG_DC
	.comm	_NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE,4,2 ## @NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_NISLANDS_DRIVER_STATE_ARB_INDEX,8,3 ## @NISLANDS_DRIVER_STATE_ARB_INDEX
	.comm	_PPSMC_DISPLAY_WATERMARK_LOW,8,3 ## @PPSMC_DISPLAY_WATERMARK_LOW
	.comm	_PPSMC_DISPLAY_WATERMARK_HIGH,8,3 ## @PPSMC_DISPLAY_WATERMARK_HIGH
	.comm	_NISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT,8,3 ## @NISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT
	.comm	_NI_SMC_SOFT_REGISTER_watermark_threshold,4,2 ## @NI_SMC_SOFT_REGISTER_watermark_threshold
	.no_dead_strip	_ni_convert_power_state_to_smc
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function ni_convert_power_state_to_smc
_ni_convert_power_state_to_smc:         ; @ni_convert_power_state_to_smc
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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
	mov	x19, x2
	mov	x20, x1
	mov	x21, x0
	bl	_evergreen_get_pi
	mov	x23, x0
	mov	x0, x21
	bl	_ni_get_pi
	str	x0, [sp, #8]                    ; 8-byte Folded Spill
	mov	x0, x20
	bl	_ni_get_ps
	mov	x24, x0
	ldr	x1, [x0, #8]
	ldr	w8, [x0]
	sub	w9, w8, #1
	ldr	w25, [x1, w9, sxtw #2]
	ldr	w9, [x20]
Lloh0:
	adrp	x10, _ATOM_PPLIB_DISALLOW_ON_DC@GOTPAGE
Lloh1:
	ldr	x10, [x10, _ATOM_PPLIB_DISALLOW_ON_DC@GOTPAGEOFF]
Lloh2:
	ldr	w10, [x10]
	tst	w10, w9
	b.ne	LBB0_2
; %bb.1:
Lloh3:
	adrp	x9, _PPSMC_SWSTATE_FLAG_DC@GOTPAGE
Lloh4:
	ldr	x9, [x9, _PPSMC_SWSTATE_FLAG_DC@GOTPAGEOFF]
Lloh5:
	ldr	w9, [x9]
	ldr	w10, [x19, #16]
	orr	w9, w10, w9
	str	w9, [x19, #16]
LBB0_2:
	str	xzr, [x19]
Lloh6:
	adrp	x9, _NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE@GOTPAGE
Lloh7:
	ldr	x9, [x9, _NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE@GOTPAGEOFF]
Lloh8:
	ldr	w9, [x9]
	cmp	w8, w9
	b.le	LBB0_4
; %bb.3:
Lloh9:
	adrp	x8, _EINVAL@GOTPAGE
Lloh10:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_12
LBB0_4:
	cmp	w8, #1
	b.lt	LBB0_13
; %bb.5:
	ldr	x2, [x19, #8]
	mov	x0, x21
	bl	_ni_convert_power_level_to_smc
Lloh12:
	adrp	x22, _NISLANDS_DRIVER_STATE_ARB_INDEX@GOTPAGE
Lloh13:
	ldr	x22, [x22, _NISLANDS_DRIVER_STATE_ARB_INDEX@GOTPAGEOFF]
	ldr	x9, [x22]
	ldr	x8, [x19, #8]
	str	x9, [x8, #16]
	cbnz	w0, LBB0_12
; %bb.6:
	mov	x27, #0
	mov	x28, #0
	mov	w26, #1
LBB0_7:                                 ; =>This Inner Loop Header: Depth=1
	ldr	x9, [sp, #8]                    ; 8-byte Folded Reload
	ldr	w9, [x9]
	cbz	w9, LBB0_9
; %bb.8:                                ;   in Loop: Header=BB0_7 Depth=1
	ldr	x9, [x24, #8]
	ldr	w9, [x9, x27]
	cmp	w9, w25
	cset	w9, lt
	b	LBB0_10
LBB0_9:                                 ;   in Loop: Header=BB0_7 Depth=1
	sub	x9, x26, #1
	cmp	x9, #2
	cset	w9, lo
LBB0_10:                                ;   in Loop: Header=BB0_7 Depth=1
	cmp	w9, #0
Lloh14:
	adrp	x9, _PPSMC_DISPLAY_WATERMARK_LOW@GOTPAGE
Lloh15:
	ldr	x9, [x9, _PPSMC_DISPLAY_WATERMARK_LOW@GOTPAGEOFF]
Lloh16:
	adrp	x10, _PPSMC_DISPLAY_WATERMARK_HIGH@GOTPAGE
Lloh17:
	ldr	x10, [x10, _PPSMC_DISPLAY_WATERMARK_HIGH@GOTPAGEOFF]
	csel	x9, x9, x10, ne
	ldr	x9, [x9]
	add	x8, x8, x28
	str	x9, [x8, #8]
	ldr	x9, [x23]
Lloh18:
	adrp	x10, _NISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT@GOTPAGE
Lloh19:
	ldr	x10, [x10, _NISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT@GOTPAGEOFF]
Lloh20:
	ldr	x10, [x10]
	add	x10, x26, x10
	sub	x10, x10, #1
	cmp	x9, #0
	csel	x9, xzr, x10, eq
	str	x9, [x8]
	ldr	x8, [x19]
	add	x8, x8, #1
	str	x8, [x19]
	ldrsw	x8, [x24]
	cmp	x26, x8
	b.ge	LBB0_13
; %bb.11:                               ;   in Loop: Header=BB0_7 Depth=1
	ldr	x8, [x24, #8]
	add	x8, x8, x27
	add	x1, x8, #4
	ldr	x8, [x19, #8]
	add	x8, x8, x28
	add	x2, x8, #24
	mov	x0, x21
	bl	_ni_convert_power_level_to_smc
	ldr	x8, [x22]
	add	x9, x26, x8
	ldr	x8, [x19, #8]
	add	x10, x8, x28
	str	x9, [x10, #40]
	add	x28, x28, #24
	add	x27, x27, #4
	add	x26, x26, #1
	cbz	w0, LBB0_7
LBB0_12:
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_13:
Lloh21:
	adrp	x8, _NI_SMC_SOFT_REGISTER_watermark_threshold@GOTPAGE
Lloh22:
	ldr	x8, [x8, _NI_SMC_SOFT_REGISTER_watermark_threshold@GOTPAGEOFF]
Lloh23:
	ldr	w23, [x8]
	add	w8, w25, #511
	cmp	w25, #0
	csel	w8, w8, w25, lt
	asr	w0, w8, #9
	bl	_cpu_to_be32
	mov	x2, x0
	mov	x0, x21
	mov	x1, x23
	bl	_rv770_write_smc_soft_register
	mov	x0, x21
	mov	x1, x20
	mov	x2, x19
	bl	_ni_populate_smc_sp
	mov	x0, x21
	mov	x1, x20
	mov	x2, x19
	bl	_ni_populate_power_containment_values
	cbz	w0, LBB0_15
; %bb.14:
	ldr	x8, [sp, #8]                    ; 8-byte Folded Reload
	str	wzr, [x8]
LBB0_15:
	mov	x0, x21
	mov	x1, x20
	mov	x2, x19
	bl	_ni_populate_sq_ramping_values
	cbz	w0, LBB0_17
; %bb.16:
	ldr	x8, [sp, #8]                    ; 8-byte Folded Reload
	str	wzr, [x8, #4]
LBB0_17:
	mov	x0, x21
	mov	x1, x20
	mov	x2, x19
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	b	_ni_populate_smc_t
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGot	Lloh16, Lloh17
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.cfi_endproc
                                        ; -- End function
	.comm	_ATOM_PPLIB_DISALLOW_ON_DC,4,2  ; @ATOM_PPLIB_DISALLOW_ON_DC
	.comm	_PPSMC_SWSTATE_FLAG_DC,4,2      ; @PPSMC_SWSTATE_FLAG_DC
	.comm	_NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE,4,2 ; @NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_NISLANDS_DRIVER_STATE_ARB_INDEX,8,3 ; @NISLANDS_DRIVER_STATE_ARB_INDEX
	.comm	_PPSMC_DISPLAY_WATERMARK_LOW,8,3 ; @PPSMC_DISPLAY_WATERMARK_LOW
	.comm	_PPSMC_DISPLAY_WATERMARK_HIGH,8,3 ; @PPSMC_DISPLAY_WATERMARK_HIGH
	.comm	_NISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT,8,3 ; @NISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT
	.comm	_NI_SMC_SOFT_REGISTER_watermark_threshold,4,2 ; @NI_SMC_SOFT_REGISTER_watermark_threshold
	.no_dead_strip	_ni_convert_power_state_to_smc
.subsections_via_symbols
