	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mlxsw_thermal_set_cur_state
_mlxsw_thermal_set_cur_state:           ## @mlxsw_thermal_set_cur_state
	.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
	movq	%rsi, %r15
	movq	%rdi, %rbx
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, -48(%rbp)
	movq	(%rdi), %r12
	movq	16(%r12), %rax
	movq	(%rax), %r13
	movq	_MLXSW_REG_MFSC_LEN@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	callq	____chkstk_darwin
	addq	$15, %rax
	andq	$-16, %rax
	subq	%rax, %rsp
	movq	%rsp, -56(%rbp)                 ## 8-byte Spill
	movq	%r12, %rdi
	movq	%rbx, %rsi
	callq	_mlxsw_get_cooling_device_idx
	movl	%eax, %r14d
	testl	%eax, %eax
	js	LBB0_1
## %bb.2:
	movq	_MLXSW_THERMAL_SPEED_MIN@GOTPCREL(%rip), %rax
	cmpq	%r15, (%rax)
	movq	%r13, -64(%rbp)                 ## 8-byte Spill
	ja	LBB0_8
## %bb.3:
	movq	_MLXSW_THERMAL_SPEED_MAX@GOTPCREL(%rip), %rax
	cmpq	%r15, (%rax)
	jb	LBB0_8
## %bb.4:
	movq	_MLXSW_THERMAL_MAX_STATE@GOTPCREL(%rip), %r13
	subq	(%r13), %r15
	xorl	%ebx, %ebx
	.p2align	4, 0x90
LBB0_5:                                 ## =>This Inner Loop Header: Depth=1
	movq	%r15, %rdi
	movq	%rbx, %rsi
	callq	_max
	movq	(%r12), %rcx
	movq	%rax, (%rcx,%rbx,8)
	incq	%rbx
	cmpq	(%r13), %rbx
	jbe	LBB0_5
## %bb.6:
	movq	-56(%rbp), %rbx                 ## 8-byte Reload
	movq	%rbx, %rdi
	movl	%r14d, %esi
	xorl	%edx, %edx
	callq	_mlxsw_reg_mfsc_pack
	movl	8(%r12), %r13d
	movq	_mfsc@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_MLXSW_REG
	movl	%r13d, %edi
	movl	%eax, %esi
	movq	%rbx, %rdx
	callq	_mlxsw_reg_query
	movl	%eax, %r13d
	testl	%eax, %eax
	jne	LBB0_13
## %bb.7:
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_mlxsw_reg_mfsc_pwm_duty_cycle_get
	movl	%eax, %edi
	callq	_mlxsw_duty_to_state
	movl	$0, %r13d
	cmpq	%rax, %r15
	movq	%rax, %r15
	jb	LBB0_13
LBB0_8:
	movq	_MLXSW_THERMAL_MAX_STATE@GOTPCREL(%rip), %rax
	cmpq	(%rax), %r15
	jbe	LBB0_10
## %bb.9:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%r13d, %r13d
	subl	(%rax), %r13d
	jmp	LBB0_13
LBB0_1:
	movl	%r14d, %r13d
	jmp	LBB0_13
LBB0_10:
	movq	(%r12), %rax
	movq	(%rax,%r15,8), %rdi
	callq	_mlxsw_state_to_duty
	movq	-56(%rbp), %rbx                 ## 8-byte Reload
	movq	%rbx, %rdi
	movl	%r14d, %esi
	movl	%eax, %edx
	callq	_mlxsw_reg_mfsc_pack
	movl	8(%r12), %r14d
	movq	_mfsc@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_MLXSW_REG
	movl	%r14d, %edi
	movl	%eax, %esi
	movq	%rbx, %rdx
	callq	_mlxsw_reg_write
	testl	%eax, %eax
	je	LBB0_11
## %bb.12:
	movl	%eax, %r13d
	leaq	L_.str(%rip), %rsi
	movq	-64(%rbp), %rdi                 ## 8-byte Reload
	callq	_dev_err
	jmp	LBB0_13
LBB0_11:
	xorl	%r13d, %r13d
LBB0_13:
	movq	___stack_chk_guard@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	cmpq	-48(%rbp), %rax
	jne	LBB0_15
## %bb.14:
	movl	%r13d, %eax
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_15:
	callq	___stack_chk_fail
	.cfi_endproc
                                        ## -- End function
	.comm	_MLXSW_REG_MFSC_LEN,4,2         ## @MLXSW_REG_MFSC_LEN
	.comm	_MLXSW_THERMAL_SPEED_MIN,8,3    ## @MLXSW_THERMAL_SPEED_MIN
	.comm	_MLXSW_THERMAL_SPEED_MAX,8,3    ## @MLXSW_THERMAL_SPEED_MAX
	.comm	_MLXSW_THERMAL_MAX_STATE,8,3    ## @MLXSW_THERMAL_MAX_STATE
	.comm	_mfsc,4,2                       ## @mfsc
	.comm	_EINVAL,4,2                     ## @EINVAL
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Failed to write PWM duty\n"

	.no_dead_strip	_mlxsw_thermal_set_cur_state
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mlxsw_thermal_set_cur_state
_mlxsw_thermal_set_cur_state:           ; @mlxsw_thermal_set_cur_state
	.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
	sub	sp, sp, #16
	mov	x24, x1
	mov	x1, x0
Lloh0:
	adrp	x8, ___stack_chk_guard@GOTPAGE
Lloh1:
	ldr	x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	stur	x8, [x29, #-72]
	ldr	x20, [x0]
	ldr	x8, [x20, #16]
	ldr	x19, [x8]
Lloh3:
	adrp	x8, _MLXSW_REG_MFSC_LEN@GOTPAGE
Lloh4:
	ldr	x8, [x8, _MLXSW_REG_MFSC_LEN@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	mov	x9, x8
Lloh6:
	adrp	x16, ___chkstk_darwin@GOTPAGE
Lloh7:
	ldr	x16, [x16, ___chkstk_darwin@GOTPAGEOFF]
	blr	x16
	mov	x9, sp
	add	x8, x8, #15
	and	x8, x8, #0x1fffffff0
	sub	x21, x9, x8
	mov	sp, x21
	mov	x0, x20
	bl	_mlxsw_get_cooling_device_idx
	mov	x22, x0
	tbnz	w0, #31, LBB0_4
; %bb.1:
Lloh8:
	adrp	x8, _MLXSW_THERMAL_SPEED_MIN@GOTPAGE
Lloh9:
	ldr	x8, [x8, _MLXSW_THERMAL_SPEED_MIN@GOTPAGEOFF]
Lloh10:
	adrp	x9, _MLXSW_THERMAL_SPEED_MAX@GOTPAGE
Lloh11:
	ldr	x9, [x9, _MLXSW_THERMAL_SPEED_MAX@GOTPAGEOFF]
Lloh12:
	ldr	x8, [x8]
Lloh13:
	ldr	x9, [x9]
	cmp	x8, x24
	ccmp	x9, x24, #0, ls
Lloh14:
	adrp	x26, _MLXSW_THERMAL_MAX_STATE@GOTPAGE
Lloh15:
	ldr	x26, [x26, _MLXSW_THERMAL_MAX_STATE@GOTPAGEOFF]
	b.hs	LBB0_5
LBB0_2:
	ldr	x8, [x26]
	cmp	x24, x8
	b.ls	LBB0_10
; %bb.3:
Lloh16:
	adrp	x8, _EINVAL@GOTPAGE
Lloh17:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh18:
	ldr	w8, [x8]
	neg	w24, w8
	b	LBB0_12
LBB0_4:
	mov	x24, x22
	b	LBB0_12
LBB0_5:
	mov	x25, #0
	ldr	x8, [x26]
	sub	x23, x24, x8
LBB0_6:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x23
	mov	x1, x25
	bl	_max
	ldr	x8, [x20]
	str	x0, [x8, x25, lsl #3]
	add	x25, x25, #1
	ldr	x8, [x26]
	cmp	x25, x8
	b.ls	LBB0_6
; %bb.7:
	mov	x0, x21
	mov	x1, x22
	mov	w2, #0
	bl	_mlxsw_reg_mfsc_pack
	ldr	w24, [x20, #8]
Lloh19:
	adrp	x8, _mfsc@GOTPAGE
Lloh20:
	ldr	x8, [x8, _mfsc@GOTPAGEOFF]
Lloh21:
	ldr	w0, [x8]
	bl	_MLXSW_REG
	mov	x1, x0
	mov	x0, x24
	mov	x2, x21
	bl	_mlxsw_reg_query
	mov	x24, x0
	cbnz	w0, LBB0_12
; %bb.8:
	mov	x0, x21
	bl	_mlxsw_reg_mfsc_pwm_duty_cycle_get
	bl	_mlxsw_duty_to_state
	mov	x24, x0
	cmp	x23, x0
	b.hs	LBB0_2
; %bb.9:
	mov	w24, #0
	b	LBB0_12
LBB0_10:
	ldr	x8, [x20]
	ldr	x0, [x8, x24, lsl #3]
	bl	_mlxsw_state_to_duty
	mov	x2, x0
	mov	x0, x21
	mov	x1, x22
	bl	_mlxsw_reg_mfsc_pack
	ldr	w20, [x20, #8]
Lloh22:
	adrp	x8, _mfsc@GOTPAGE
Lloh23:
	ldr	x8, [x8, _mfsc@GOTPAGEOFF]
Lloh24:
	ldr	w0, [x8]
	bl	_MLXSW_REG
	mov	x1, x0
	mov	x0, x20
	mov	x2, x21
	bl	_mlxsw_reg_write
	mov	x24, x0
	cbz	w0, LBB0_12
; %bb.11:
Lloh25:
	adrp	x1, l_.str@PAGE
Lloh26:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x19
	bl	_dev_err
LBB0_12:
	ldur	x8, [x29, #-72]
Lloh27:
	adrp	x9, ___stack_chk_guard@GOTPAGE
Lloh28:
	ldr	x9, [x9, ___stack_chk_guard@GOTPAGEOFF]
Lloh29:
	ldr	x9, [x9]
	cmp	x9, x8
	b.ne	LBB0_14
; %bb.13:
	mov	x0, x24
	sub	sp, x29, #64
	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
LBB0_14:
	bl	___stack_chk_fail
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh12
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh27, Lloh28, Lloh29
	.cfi_endproc
                                        ; -- End function
	.comm	_MLXSW_REG_MFSC_LEN,4,2         ; @MLXSW_REG_MFSC_LEN
	.comm	_MLXSW_THERMAL_SPEED_MIN,8,3    ; @MLXSW_THERMAL_SPEED_MIN
	.comm	_MLXSW_THERMAL_SPEED_MAX,8,3    ; @MLXSW_THERMAL_SPEED_MAX
	.comm	_MLXSW_THERMAL_MAX_STATE,8,3    ; @MLXSW_THERMAL_MAX_STATE
	.comm	_mfsc,4,2                       ; @mfsc
	.comm	_EINVAL,4,2                     ; @EINVAL
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Failed to write PWM duty\n"

	.no_dead_strip	_mlxsw_thermal_set_cur_state
.subsections_via_symbols
