	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function lp8788_get_battery_capacity
_lp8788_get_battery_capacity:           ## @lp8788_get_battery_capacity
	.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	%r12
	pushq	%rbx
	subq	$16, %rsp
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	LBB0_1
## %bb.2:
	movl	(%rax), %r12d
	testl	%r12d, %r12d
	je	LBB0_1
## %bb.3:
	movq	%rsi, %r14
	movq	%rdi, %r15
	movq	8(%rdi), %rdi
	movq	_LP8788_CHG_STATUS@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-36(%rbp), %rdx
	callq	_lp8788_read_byte
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_8
## %bb.4:
	movq	_LP8788_CHG_STATE_M@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	andl	-36(%rbp), %eax
	movq	_LP8788_CHG_STATE_S@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	sarl	%cl, %eax
	movq	_LP8788_MAINTENANCE@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jne	LBB0_6
## %bb.5:
	movq	_LP8788_MAX_BATT_CAPACITY@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, (%r14)
	xorl	%ebx, %ebx
	jmp	LBB0_8
LBB0_1:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_8:
	movl	%ebx, %eax
	addq	$16, %rsp
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_6:
	leaq	-40(%rbp), %rsi
	movq	%r15, %rdi
	callq	_lp8788_get_vbatt_adc
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_8
## %bb.7:
	movq	_LP8788_MAX_BATT_CAPACITY@GOTPCREL(%rip), %rcx
	movl	(%rcx), %eax
	imull	-40(%rbp), %eax
	xorl	%ebx, %ebx
	xorl	%edx, %edx
	divl	%r12d
	movl	%eax, (%r14)
	movl	(%rcx), %esi
	movl	%eax, %edi
	callq	_min
	movl	%eax, (%r14)
	jmp	LBB0_8
	.cfi_endproc
                                        ## -- End function
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_LP8788_CHG_STATUS,4,2          ## @LP8788_CHG_STATUS
	.comm	_LP8788_CHG_STATE_M,4,2         ## @LP8788_CHG_STATE_M
	.comm	_LP8788_CHG_STATE_S,4,2         ## @LP8788_CHG_STATE_S
	.comm	_LP8788_MAINTENANCE,4,2         ## @LP8788_MAINTENANCE
	.comm	_LP8788_MAX_BATT_CAPACITY,4,2   ## @LP8788_MAX_BATT_CAPACITY
	.no_dead_strip	_lp8788_get_battery_capacity
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function lp8788_get_battery_capacity
_lp8788_get_battery_capacity:           ; @lp8788_get_battery_capacity
	.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
	ldr	x8, [x0]
	cbz	x8, LBB0_5
; %bb.1:
	ldr	w21, [x8]
	cbz	w21, LBB0_5
; %bb.2:
	mov	x19, x1
	mov	x20, x0
	ldr	x0, [x0, #8]
Lloh0:
	adrp	x8, _LP8788_CHG_STATUS@GOTPAGE
Lloh1:
	ldr	x8, [x8, _LP8788_CHG_STATUS@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	add	x2, sp, #8
	bl	_lp8788_read_byte
	cbnz	w0, LBB0_6
; %bb.3:
	ldr	w8, [sp, #8]
Lloh3:
	adrp	x9, _LP8788_CHG_STATE_M@GOTPAGE
Lloh4:
	ldr	x9, [x9, _LP8788_CHG_STATE_M@GOTPAGEOFF]
Lloh5:
	ldr	w9, [x9]
	and	w8, w9, w8
Lloh6:
	adrp	x9, _LP8788_CHG_STATE_S@GOTPAGE
Lloh7:
	ldr	x9, [x9, _LP8788_CHG_STATE_S@GOTPAGEOFF]
Lloh8:
	ldr	w9, [x9]
	asr	w8, w8, w9
Lloh9:
	adrp	x9, _LP8788_MAINTENANCE@GOTPAGE
Lloh10:
	ldr	x9, [x9, _LP8788_MAINTENANCE@GOTPAGEOFF]
Lloh11:
	ldr	w9, [x9]
	cmp	w8, w9
	b.ne	LBB0_7
; %bb.4:
	mov	w0, #0
Lloh12:
	adrp	x8, _LP8788_MAX_BATT_CAPACITY@GOTPAGE
Lloh13:
	ldr	x8, [x8, _LP8788_MAX_BATT_CAPACITY@GOTPAGEOFF]
Lloh14:
	ldr	w8, [x8]
	b	LBB0_9
LBB0_5:
Lloh15:
	adrp	x8, _EINVAL@GOTPAGE
Lloh16:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh17:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_6:
	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_7:
	add	x1, sp, #12
	mov	x0, x20
	bl	_lp8788_get_vbatt_adc
	cbnz	w0, LBB0_6
; %bb.8:
Lloh18:
	adrp	x8, _LP8788_MAX_BATT_CAPACITY@GOTPAGE
Lloh19:
	ldr	x8, [x8, _LP8788_MAX_BATT_CAPACITY@GOTPAGEOFF]
	ldr	w9, [sp, #12]
	ldr	w10, [x8]
	mul	w9, w10, w9
	udiv	w0, w9, w21
	str	w0, [x19]
	ldr	w1, [x8]
	bl	_min
	mov	x8, x0
	mov	w0, #0
LBB0_9:
	str	w8, [x19]
	b	LBB0_6
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGot	Lloh18, Lloh19
	.cfi_endproc
                                        ; -- End function
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_LP8788_CHG_STATUS,4,2          ; @LP8788_CHG_STATUS
	.comm	_LP8788_CHG_STATE_M,4,2         ; @LP8788_CHG_STATE_M
	.comm	_LP8788_CHG_STATE_S,4,2         ; @LP8788_CHG_STATE_S
	.comm	_LP8788_MAINTENANCE,4,2         ; @LP8788_MAINTENANCE
	.comm	_LP8788_MAX_BATT_CAPACITY,4,2   ; @LP8788_MAX_BATT_CAPACITY
	.no_dead_strip	_lp8788_get_battery_capacity
.subsections_via_symbols
