	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function calc_ocv
_calc_ocv:                              ## @calc_ocv
	.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
	testq	%rsi, %rsi
	je	LBB0_9
## %bb.1:
	movq	%rdi, %r12
	movq	%rsi, -64(%rbp)                 ## 8-byte Spill
	xorl	%ebx, %ebx
	movl	$10, %r13d
	leaq	-44(%rbp), %r15
	xorl	%r14d, %r14d
	movq	%rdi, -56(%rbp)                 ## 8-byte Spill
	.p2align	4, 0x90
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	movq	_OCV_MODE_ACTIVE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r12, %rdi
	movq	%r15, %rdx
	callq	_measure_vbatt
	testl	%eax, %eax
	jne	LBB0_8
## %bb.3:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	%r15, %rsi
	movl	-44(%rbp), %r15d
	movq	%r12, %rdi
	movq	%rsi, %r12
	callq	_measure_current
	testl	%eax, %eax
	jne	LBB0_8
## %bb.4:                               ##   in Loop: Header=BB0_2 Depth=1
	addl	%r15d, %r14d
	addl	-44(%rbp), %ebx
	decl	%r13d
	movq	%r12, %r15
	movq	-56(%rbp), %r12                 ## 8-byte Reload
	jne	LBB0_2
## %bb.5:
	movslq	%r14d, %rax
	imulq	$1717986919, %rax, %r15         ## imm = 0x66666667
	movq	%r15, %rax
	shrq	$63, %rax
	sarq	$34, %r15
	addl	%eax, %r15d
	leaq	8(%r12), %r14
	movq	%r14, %rdi
	callq	_mutex_lock
	movq	-56(%rbp), %rdx                 ## 8-byte Reload
	cmpq	$0, 16(%rdx)
	movl	%r15d, %eax
	je	LBB0_7
## %bb.6:
	movslq	%ebx, %rax
	imulq	$1717986919, %rax, %rax         ## imm = 0x66666667
	movq	%rax, %rcx
	shrq	$63, %rcx
	sarq	$34, %rax
	addl	%ecx, %eax
	imull	(%rdx), %eax
	cltq
	imulq	$-274877907, %rax, %rax         ## imm = 0xEF9DB22D
	movq	%rax, %rcx
	shrq	$63, %rcx
	sarq	$38, %rax
	addl	%ecx, %eax
	addl	%r15d, %eax
LBB0_7:
	movq	-64(%rbp), %rbx                 ## 8-byte Reload
	movl	%eax, (%rbx)
	movq	%rdx, %r12
	movq	%r14, %rdi
	callq	_mutex_unlock
	movl	4(%r12), %edi
	movl	(%rbx), %ecx
	leaq	L_.str(%rip), %rsi
	movl	%r15d, %edx
	callq	_dev_dbg
	xorl	%eax, %eax
	jmp	LBB0_8
LBB0_9:
	movq	_EINVAL@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
LBB0_8:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_OCV_MODE_ACTIVE,4,2            ## @OCV_MODE_ACTIVE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"VBAT average:%d, OCV:%d\n"

	.no_dead_strip	_calc_ocv
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function calc_ocv
_calc_ocv:                              ; @calc_ocv
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #96
	.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
	cbz	x1, LBB0_8
; %bb.1:
	mov	x19, x1
	mov	x20, x0
	mov	w23, #0
	mov	w21, #0
	mov	w22, #10
Lloh0:
	adrp	x24, _OCV_MODE_ACTIVE@GOTPAGE
Lloh1:
	ldr	x24, [x24, _OCV_MODE_ACTIVE@GOTPAGEOFF]
LBB0_2:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w1, [x24]
	add	x2, sp, #12
	mov	x0, x20
	bl	_measure_vbatt
	cbnz	w0, LBB0_9
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	ldr	w25, [sp, #12]
	add	x1, sp, #12
	mov	x0, x20
	bl	_measure_current
	cbnz	w0, LBB0_9
; %bb.4:                                ;   in Loop: Header=BB0_2 Depth=1
	add	w21, w25, w21
	ldr	w8, [sp, #12]
	add	w23, w8, w23
	subs	w22, w22, #1
	b.ne	LBB0_2
; %bb.5:
	mov	w24, #26215
	movk	w24, #26214, lsl #16
	smull	x8, w21, w24
	lsr	x9, x8, #63
	asr	x8, x8, #34
	add	w21, w8, w9
	add	x22, x20, #8
	mov	x0, x22
	bl	_mutex_lock
	ldr	x9, [x20, #16]
	mov	x8, x21
	cbz	x9, LBB0_7
; %bb.6:
	smull	x8, w23, w24
	lsr	x9, x8, #63
	asr	x8, x8, #34
	add	w8, w8, w9
	ldr	w9, [x20]
	mul	w8, w9, w8
	mov	w9, #45613
	movk	w9, #61341, lsl #16
	smull	x8, w8, w9
	lsr	x9, x8, #63
	asr	x8, x8, #38
	add	w8, w8, w9
	add	w8, w8, w21
LBB0_7:
	str	w8, [x19]
	mov	x0, x22
	bl	_mutex_unlock
	ldr	w0, [x20, #4]
	ldr	w3, [x19]
Lloh2:
	adrp	x1, l_.str@PAGE
Lloh3:
	add	x1, x1, l_.str@PAGEOFF
	mov	x2, x21
	bl	_dev_dbg
	mov	w0, #0
	b	LBB0_9
LBB0_8:
Lloh4:
	adrp	x8, _EINVAL@GOTPAGE
Lloh5:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh6:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_9:
	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
	add	sp, sp, #96
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.cfi_endproc
                                        ; -- End function
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_OCV_MODE_ACTIVE,4,2            ; @OCV_MODE_ACTIVE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"VBAT average:%d, OCV:%d\n"

	.no_dead_strip	_calc_ocv
.subsections_via_symbols
