	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function bq27xxx_battery_set_config
_bq27xxx_battery_set_config:            ## @bq27xxx_battery_set_config
	.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	$56, %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, %r12
	movq	_BQ27XXX_DM_DESIGN_CAPACITY@GOTPCREL(%rip), %r13
	movl	(%r13), %edx
	leaq	-64(%rbp), %r14
	movq	%r14, %rdi
	movq	%r12, %rsi
	callq	_BQ27XXX_DM_BUF
	movq	_BQ27XXX_DM_TERMINATE_VOLTAGE@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	leaq	-88(%rbp), %rbx
	movq	%rbx, %rdi
	movq	%r12, %rsi
	callq	_BQ27XXX_DM_BUF
	movq	%r12, %rdi
	callq	_bq27xxx_battery_unseal
	testq	%rax, %rax
	js	LBB0_12
## %bb.1:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ecx, %ecx
	subl	(%rax), %ecx
	cmpl	%ecx, (%r15)
	je	LBB0_4
## %bb.2:
	cmpl	%ecx, 4(%r15)
	je	LBB0_4
## %bb.3:
	leaq	-64(%rbp), %rsi
	movq	%r12, %rdi
	callq	_bq27xxx_battery_read_dm_block
	movl	(%r13), %edx
	movslq	(%r15), %rax
	imulq	$274877907, %rax, %rcx          ## imm = 0x10624DD3
	movq	%rcx, %rax
	shrq	$63, %rax
	sarq	$38, %rcx
	addl	%eax, %ecx
	movq	%r12, %rdi
	leaq	-64(%rbp), %r13
	movq	%r13, %rsi
                                        ## kill: def $ecx killed $ecx killed $rcx
	callq	_bq27xxx_battery_update_dm_block
	movq	_BQ27XXX_DM_DESIGN_ENERGY@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movslq	4(%r15), %rax
	imulq	$274877907, %rax, %rcx          ## imm = 0x10624DD3
	movq	%rcx, %rax
	shrq	$63, %rax
	sarq	$38, %rcx
	addl	%eax, %ecx
	movq	%r12, %rdi
	movq	%r13, %rsi
                                        ## kill: def $ecx killed $ecx killed $rcx
	callq	_bq27xxx_battery_update_dm_block
	xorl	%ecx, %ecx
	movq	_EINVAL@GOTPCREL(%rip), %rax
	subl	(%rax), %ecx
LBB0_4:
	movl	8(%r15), %eax
	cmpl	%ecx, %eax
	je	LBB0_9
## %bb.5:
	movq	-64(%rbp), %rcx
	cmpq	-88(%rbp), %rcx
	jne	LBB0_7
## %bb.6:
	movq	-80(%rbp), %rcx
	cmpq	%rcx, -56(%rbp)
	je	LBB0_8
LBB0_7:
	movq	%r12, %rdi
	movq	%rbx, %rsi
	callq	_bq27xxx_battery_read_dm_block
	movl	8(%r15), %eax
	movq	%rbx, %r14
LBB0_8:
	movq	_BQ27XXX_DM_TERMINATE_VOLTAGE@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	cltq
	imulq	$274877907, %rax, %rcx          ## imm = 0x10624DD3
	movq	%rcx, %rax
	shrq	$63, %rax
	sarq	$38, %rcx
	addl	%eax, %ecx
	movq	%r12, %rdi
	movq	%r14, %rsi
                                        ## kill: def $ecx killed $ecx killed $rcx
	callq	_bq27xxx_battery_update_dm_block
LBB0_9:
	movq	-48(%rbp), %r14
	movq	-72(%rbp), %rbx
	leaq	-64(%rbp), %rsi
	movq	%r12, %rdi
	callq	_bq27xxx_battery_write_dm_block
	leaq	-88(%rbp), %rsi
	movq	%r12, %rdi
	callq	_bq27xxx_battery_write_dm_block
	movq	%r12, %rdi
	callq	_bq27xxx_battery_seal
	orq	%r14, %rbx
	je	LBB0_12
## %bb.10:
	movq	_BQ27XXX_O_CFGUP@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%r12)
	jne	LBB0_12
## %bb.11:
	movq	_BQ27XXX_REG_CTRL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_BQ27XXX_RESET@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r12, %rdi
	xorl	%ecx, %ecx
	callq	_bq27xxx_write
	movl	$300, %edi                      ## imm = 0x12C
	callq	_BQ27XXX_MSLEEP
LBB0_12:
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_BQ27XXX_DM_DESIGN_CAPACITY,4,2 ## @BQ27XXX_DM_DESIGN_CAPACITY
	.comm	_BQ27XXX_DM_TERMINATE_VOLTAGE,4,2 ## @BQ27XXX_DM_TERMINATE_VOLTAGE
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_BQ27XXX_DM_DESIGN_ENERGY,4,2   ## @BQ27XXX_DM_DESIGN_ENERGY
	.comm	_BQ27XXX_O_CFGUP,4,2            ## @BQ27XXX_O_CFGUP
	.comm	_BQ27XXX_REG_CTRL,4,2           ## @BQ27XXX_REG_CTRL
	.comm	_BQ27XXX_RESET,4,2              ## @BQ27XXX_RESET
	.no_dead_strip	_bq27xxx_battery_set_config
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function bq27xxx_battery_set_config
_bq27xxx_battery_set_config:            ; @bq27xxx_battery_set_config
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	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
	mov	x20, x1
	mov	x19, x0
Lloh0:
	adrp	x23, _BQ27XXX_DM_DESIGN_CAPACITY@GOTPAGE
Lloh1:
	ldr	x23, [x23, _BQ27XXX_DM_DESIGN_CAPACITY@GOTPAGEOFF]
	ldr	w1, [x23]
	add	x8, sp, #24
	bl	_BQ27XXX_DM_BUF
Lloh2:
	adrp	x22, _BQ27XXX_DM_TERMINATE_VOLTAGE@GOTPAGE
Lloh3:
	ldr	x22, [x22, _BQ27XXX_DM_TERMINATE_VOLTAGE@GOTPAGEOFF]
	ldr	w1, [x22]
	mov	x8, sp
	mov	x0, x19
	bl	_BQ27XXX_DM_BUF
	mov	x0, x19
	bl	_bq27xxx_battery_unseal
	tbnz	x0, #63, LBB0_13
; %bb.1:
	ldr	w8, [x20]
Lloh4:
	adrp	x21, _EINVAL@GOTPAGE
Lloh5:
	ldr	x21, [x21, _EINVAL@GOTPAGEOFF]
	ldr	w10, [x21]
	neg	w9, w10
	cmn	w8, w10
	b.eq	LBB0_4
; %bb.2:
	ldr	w8, [x20, #4]
	cmp	w8, w9
	b.eq	LBB0_4
; %bb.3:
	add	x1, sp, #24
	mov	x0, x19
	bl	_bq27xxx_battery_read_dm_block
	ldr	w2, [x23]
	ldrsw	x8, [x20]
	mov	w23, #19923
	movk	w23, #4194, lsl #16
	mul	x8, x8, x23
	lsr	x9, x8, #63
	asr	x8, x8, #38
	add	w3, w8, w9
	add	x1, sp, #24
	mov	x0, x19
	bl	_bq27xxx_battery_update_dm_block
Lloh6:
	adrp	x8, _BQ27XXX_DM_DESIGN_ENERGY@GOTPAGE
Lloh7:
	ldr	x8, [x8, _BQ27XXX_DM_DESIGN_ENERGY@GOTPAGEOFF]
Lloh8:
	ldr	w2, [x8]
	ldrsw	x8, [x20, #4]
	mul	x8, x8, x23
	lsr	x9, x8, #63
	asr	x8, x8, #38
	add	w3, w8, w9
	add	x1, sp, #24
	mov	x0, x19
	bl	_bq27xxx_battery_update_dm_block
	ldr	w8, [x21]
	neg	w9, w8
LBB0_4:
	ldr	w8, [x20, #8]
	cmp	w8, w9
	b.eq	LBB0_10
; %bb.5:
	ldr	x9, [sp, #24]
	ldr	x10, [sp]
	cmp	x9, x10
	b.ne	LBB0_8
; %bb.6:
	ldr	x9, [sp, #32]
	ldr	x10, [sp, #8]
	cmp	x9, x10
	b.ne	LBB0_8
; %bb.7:
	add	x21, sp, #24
	b	LBB0_9
LBB0_8:
	mov	x21, sp
	mov	x1, sp
	mov	x0, x19
	bl	_bq27xxx_battery_read_dm_block
	ldr	w8, [x20, #8]
LBB0_9:
	ldr	w2, [x22]
	mov	w9, #19923
	movk	w9, #4194, lsl #16
	smull	x8, w8, w9
	lsr	x9, x8, #63
	asr	x8, x8, #38
	add	w3, w8, w9
	mov	x0, x19
	mov	x1, x21
	bl	_bq27xxx_battery_update_dm_block
LBB0_10:
	ldr	x8, [sp, #40]
	ldr	x9, [sp, #16]
	orr	x20, x8, x9
	add	x1, sp, #24
	mov	x0, x19
	bl	_bq27xxx_battery_write_dm_block
	mov	x1, sp
	mov	x0, x19
	bl	_bq27xxx_battery_write_dm_block
	mov	x0, x19
	bl	_bq27xxx_battery_seal
	cbz	x20, LBB0_13
; %bb.11:
	ldr	w8, [x19]
Lloh9:
	adrp	x9, _BQ27XXX_O_CFGUP@GOTPAGE
Lloh10:
	ldr	x9, [x9, _BQ27XXX_O_CFGUP@GOTPAGEOFF]
Lloh11:
	ldr	w9, [x9]
	tst	w9, w8
	b.ne	LBB0_13
; %bb.12:
Lloh12:
	adrp	x8, _BQ27XXX_REG_CTRL@GOTPAGE
Lloh13:
	ldr	x8, [x8, _BQ27XXX_REG_CTRL@GOTPAGEOFF]
Lloh14:
	ldr	w1, [x8]
Lloh15:
	adrp	x8, _BQ27XXX_RESET@GOTPAGE
Lloh16:
	ldr	x8, [x8, _BQ27XXX_RESET@GOTPAGEOFF]
Lloh17:
	ldr	w2, [x8]
	mov	x0, x19
	mov	w3, #0
	bl	_bq27xxx_write
	mov	w0, #300
	bl	_BQ27XXX_MSLEEP
LBB0_13:
	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
	add	sp, sp, #112
	ret
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.cfi_endproc
                                        ; -- End function
	.comm	_BQ27XXX_DM_DESIGN_CAPACITY,4,2 ; @BQ27XXX_DM_DESIGN_CAPACITY
	.comm	_BQ27XXX_DM_TERMINATE_VOLTAGE,4,2 ; @BQ27XXX_DM_TERMINATE_VOLTAGE
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_BQ27XXX_DM_DESIGN_ENERGY,4,2   ; @BQ27XXX_DM_DESIGN_ENERGY
	.comm	_BQ27XXX_O_CFGUP,4,2            ; @BQ27XXX_O_CFGUP
	.comm	_BQ27XXX_REG_CTRL,4,2           ; @BQ27XXX_REG_CTRL
	.comm	_BQ27XXX_RESET,4,2              ; @BQ27XXX_RESET
	.no_dead_strip	_bq27xxx_battery_set_config
.subsections_via_symbols
