	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function sc27xx_fgu_capacity_calibration
_sc27xx_fgu_capacity_calibration:       ## @sc27xx_fgu_capacity_calibration
	.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
	movl	%edx, %r14d
	movl	%esi, %r15d
	movq	%rdi, %rbx
	leaq	-32(%rbp), %rsi
	callq	_sc27xx_fgu_get_vbat_ocv
	testl	%eax, %eax
	je	LBB0_2
## %bb.1:
	movl	40(%rbx), %edi
	leaq	L_.str(%rip), %rsi
	callq	_dev_err
	jmp	LBB0_15
LBB0_2:
	leaq	-28(%rbp), %rsi
	movq	%rbx, %rdi
	callq	_sc27xx_fgu_get_status
	testl	%eax, %eax
	je	LBB0_4
## %bb.3:
	movl	40(%rbx), %edi
	leaq	L_.str.1(%rip), %rsi
	callq	_dev_err
	jmp	LBB0_15
LBB0_4:
	movl	-28(%rbp), %eax
	movq	_POWER_SUPPLY_STATUS_CHARGING@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	je	LBB0_15
## %bb.5:
	movl	-32(%rbp), %edx
	movq	32(%rbx), %rdi
	cmpl	(%rdi), %edx
	setg	%al
	cmpl	$100, %r15d
	setl	%cl
	jg	LBB0_12
## %bb.6:
	andb	%al, %cl
	jne	LBB0_12
## %bb.7:
	movslq	(%rbx), %rsi
	cmpl	-4(%rdi,%rsi,4), %edx
	jle	LBB0_13
## %bb.8:
	testl	%r15d, %r15d
	jle	LBB0_11
## %bb.9:
	movl	8(%rbx), %eax
	cmpl	4(%rbx), %edx
	jle	LBB0_16
## %bb.10:
	cmpl	%r15d, %eax
	jl	LBB0_15
LBB0_11:
                                        ## kill: def $esi killed $esi killed $rsi
	callq	_power_supply_ocv2cap_simple
	movq	%rbx, %rdi
	movl	%eax, %esi
	jmp	LBB0_14
LBB0_12:
	movq	%rbx, %rdi
	movl	$100, %esi
	jmp	LBB0_14
LBB0_13:
	movq	%rbx, %rdi
	xorl	%esi, %esi
LBB0_14:
	callq	_sc27xx_fgu_adjust_cap
LBB0_15:
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_16:
	cmpl	%r15d, %eax
	jl	LBB0_18
## %bb.17:
                                        ## kill: def $esi killed $esi killed $rsi
	callq	_power_supply_ocv2cap_simple
LBB0_18:
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_sc27xx_fgu_adjust_cap
	testl	%r14d, %r14d
	je	LBB0_15
## %bb.19:
	movq	32(%rbx), %rdi
	movslq	(%rbx), %rsi
	movl	-4(%rdi,%rsi,4), %edx
	movl	%edx, 4(%rbx)
                                        ## kill: def $esi killed $esi killed $rsi
	callq	_power_supply_ocv2cap_simple
	movl	%eax, 8(%rbx)
	movslq	4(%rbx), %rax
	imulq	$274877907, %rax, %rsi          ## imm = 0x10624DD3
	movq	%rsi, %rax
	shrq	$63, %rax
	sarq	$38, %rsi
	addl	%eax, %esi
	movq	%rbx, %rdi
                                        ## kill: def $esi killed $esi killed $rsi
	callq	_sc27xx_fgu_voltage_to_adc
	movl	24(%rbx), %edi
	movq	_SC27XX_FGU_LOW_OVERLOAD@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rsi
	addq	16(%rbx), %rsi
	movq	_SC27XX_FGU_LOW_OVERLOAD_MASK@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	movl	%eax, %ecx
	callq	_regmap_update_bits
	jmp	LBB0_15
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"get battery ocv error.\n"

L_.str.1:                               ## @.str.1
	.asciz	"get charger status error.\n"

	.comm	_POWER_SUPPLY_STATUS_CHARGING,4,2 ## @POWER_SUPPLY_STATUS_CHARGING
	.comm	_SC27XX_FGU_LOW_OVERLOAD,8,3    ## @SC27XX_FGU_LOW_OVERLOAD
	.comm	_SC27XX_FGU_LOW_OVERLOAD_MASK,4,2 ## @SC27XX_FGU_LOW_OVERLOAD_MASK
	.no_dead_strip	_sc27xx_fgu_capacity_calibration
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function sc27xx_fgu_capacity_calibration
_sc27xx_fgu_capacity_calibration:       ; @sc27xx_fgu_capacity_calibration
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #64
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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, x2
	mov	x21, x1
	mov	x19, x0
	add	x1, sp, #12
	bl	_sc27xx_fgu_get_vbat_ocv
	cbz	w0, LBB0_2
; %bb.1:
	ldr	w0, [x19, #40]
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
	b	LBB0_15
LBB0_2:
	add	x1, sp, #8
	mov	x0, x19
	bl	_sc27xx_fgu_get_status
	cbz	w0, LBB0_4
; %bb.3:
	ldr	w0, [x19, #40]
Lloh2:
	adrp	x1, l_.str.1@PAGE
Lloh3:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_dev_err
	b	LBB0_15
LBB0_4:
	ldr	w8, [sp, #8]
Lloh4:
	adrp	x9, _POWER_SUPPLY_STATUS_CHARGING@GOTPAGE
Lloh5:
	ldr	x9, [x9, _POWER_SUPPLY_STATUS_CHARGING@GOTPAGEOFF]
Lloh6:
	ldr	w9, [x9]
	cmp	w8, w9
	b.eq	LBB0_15
; %bb.5:
	ldr	w2, [sp, #12]
	ldr	x0, [x19, #32]
	ldr	w8, [x0]
	cmp	w2, w8
	cset	w8, gt
	cmp	w21, #100
	cset	w9, lt
	b.gt	LBB0_12
; %bb.6:
	and	w8, w9, w8
	cbnz	w8, LBB0_12
; %bb.7:
	ldr	w1, [x19]
	sub	w8, w1, #1
	ldr	w8, [x0, w8, sxtw #2]
	cmp	w2, w8
	b.le	LBB0_13
; %bb.8:
	cmp	w21, #1
	b.lt	LBB0_11
; %bb.9:
	ldp	w9, w8, [x19, #4]
	cmp	w2, w9
	b.le	LBB0_16
; %bb.10:
	cmp	w8, w21
	b.lt	LBB0_15
LBB0_11:
	bl	_power_supply_ocv2cap_simple
	mov	x1, x0
	mov	x0, x19
                                        ; kill: def $w1 killed $w1 killed $x1
	b	LBB0_14
LBB0_12:
	mov	x0, x19
	mov	w1, #100
	b	LBB0_14
LBB0_13:
	mov	x0, x19
	mov	w1, #0
LBB0_14:
	bl	_sc27xx_fgu_adjust_cap
LBB0_15:
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #64
	ret
LBB0_16:
	cmp	w8, w21
	b.lt	LBB0_18
; %bb.17:
	bl	_power_supply_ocv2cap_simple
	mov	x8, x0
LBB0_18:
	mov	x0, x19
	mov	x1, x8
	bl	_sc27xx_fgu_adjust_cap
	cbz	w20, LBB0_15
; %bb.19:
	ldr	x0, [x19, #32]
	ldr	w1, [x19]
	sub	w8, w1, #1
	ldr	w2, [x0, w8, sxtw #2]
	str	w2, [x19, #4]
	bl	_power_supply_ocv2cap_simple
	str	w0, [x19, #8]
	ldrsw	x8, [x19, #4]
	mov	w9, #19923
	movk	w9, #4194, lsl #16
	mul	x8, x8, x9
	lsr	x9, x8, #32
	lsr	x8, x8, #63
	add	w1, w8, w9, asr #6
	mov	x0, x19
	bl	_sc27xx_fgu_voltage_to_adc
	mov	x3, x0
	ldr	w0, [x19, #24]
Lloh7:
	adrp	x8, _SC27XX_FGU_LOW_OVERLOAD@GOTPAGE
Lloh8:
	ldr	x8, [x8, _SC27XX_FGU_LOW_OVERLOAD@GOTPAGEOFF]
	ldr	x9, [x19, #16]
Lloh9:
	ldr	x8, [x8]
	add	x1, x8, x9
Lloh10:
	adrp	x8, _SC27XX_FGU_LOW_OVERLOAD_MASK@GOTPAGE
Lloh11:
	ldr	x8, [x8, _SC27XX_FGU_LOW_OVERLOAD_MASK@GOTPAGEOFF]
Lloh12:
	ldr	w2, [x8]
	bl	_regmap_update_bits
	b	LBB0_15
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"get battery ocv error.\n"

l_.str.1:                               ; @.str.1
	.asciz	"get charger status error.\n"

	.comm	_POWER_SUPPLY_STATUS_CHARGING,4,2 ; @POWER_SUPPLY_STATUS_CHARGING
	.comm	_SC27XX_FGU_LOW_OVERLOAD,8,3    ; @SC27XX_FGU_LOW_OVERLOAD
	.comm	_SC27XX_FGU_LOW_OVERLOAD_MASK,4,2 ; @SC27XX_FGU_LOW_OVERLOAD_MASK
	.no_dead_strip	_sc27xx_fgu_capacity_calibration
.subsections_via_symbols
