	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function bq27xxx_battery_write_dm_block
_bq27xxx_battery_write_dm_block:        ## @bq27xxx_battery_write_dm_block
	.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
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	cmpl	$0, (%rsi)
	je	LBB0_17
## %bb.1:
	movq	%rsi, %r14
	movq	%rdi, %r15
	movq	_BQ27XXX_O_CFGUP@GOTPCREL(%rip), %rax
	movl	(%rax), %r12d
	andl	(%rdi), %r12d
	je	LBB0_3
## %bb.2:
	movq	%r15, %rdi
	callq	_bq27xxx_battery_set_cfgupdate
	testl	%eax, %eax
	js	LBB0_14
LBB0_3:
	movq	_BQ27XXX_DM_CTRL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	xorl	%edx, %edx
	movl	$1, %ecx
	callq	_bq27xxx_write
	testl	%eax, %eax
	js	LBB0_11
## %bb.4:
	movq	_BQ27XXX_DM_CLASS@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	12(%r14), %edx
	movq	%r15, %rdi
	movl	$1, %ecx
	callq	_bq27xxx_write
	testl	%eax, %eax
	js	LBB0_11
## %bb.5:
	movq	_BQ27XXX_DM_BLOCK@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	8(%r14), %edx
	movq	%r15, %rdi
	movl	$1, %ecx
	callq	_bq27xxx_write
	testl	%eax, %eax
	js	LBB0_11
## %bb.6:
	movl	$1, %edi
	callq	_BQ27XXX_MSLEEP
	movq	_BQ27XXX_DM_DATA@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	4(%r14), %edx
	movq	_BQ27XXX_DM_SZ@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	%r15, %rdi
	callq	_bq27xxx_write_block
	testl	%eax, %eax
	js	LBB0_11
## %bb.7:
	movq	_BQ27XXX_DM_CKSUM@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	movq	%r14, %rdi
	callq	_bq27xxx_battery_checksum_dm_block
	movq	%r15, %rdi
	movl	%ebx, %esi
	movl	%eax, %edx
	movl	$1, %ecx
	callq	_bq27xxx_write
	testl	%eax, %eax
	js	LBB0_11
## %bb.8:
	testl	%r12d, %r12d
	je	LBB0_15
## %bb.9:
	movl	$1, %edi
	callq	_BQ27XXX_MSLEEP
	movq	%r15, %rdi
	callq	_bq27xxx_battery_soft_reset
	testl	%eax, %eax
	jns	LBB0_16
LBB0_14:
	movl	%eax, %ebx
	jmp	LBB0_18
LBB0_11:
	movl	%eax, %ebx
	testl	%r12d, %r12d
	je	LBB0_13
## %bb.12:
	movq	%r15, %rdi
	callq	_bq27xxx_battery_soft_reset
LBB0_13:
	movl	4(%r15), %edi
	leaq	L_.str(%rip), %rsi
	movl	%ebx, %edx
	callq	_dev_err
	jmp	LBB0_18
LBB0_15:
	movl	$100, %edi
	callq	_BQ27XXX_MSLEEP
LBB0_16:
	movl	$0, (%r14)
LBB0_17:
	xorl	%ebx, %ebx
LBB0_18:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_BQ27XXX_O_CFGUP,4,2            ## @BQ27XXX_O_CFGUP
	.comm	_BQ27XXX_DM_CTRL,4,2            ## @BQ27XXX_DM_CTRL
	.comm	_BQ27XXX_DM_CLASS,4,2           ## @BQ27XXX_DM_CLASS
	.comm	_BQ27XXX_DM_BLOCK,4,2           ## @BQ27XXX_DM_BLOCK
	.comm	_BQ27XXX_DM_DATA,4,2            ## @BQ27XXX_DM_DATA
	.comm	_BQ27XXX_DM_SZ,4,2              ## @BQ27XXX_DM_SZ
	.comm	_BQ27XXX_DM_CKSUM,4,2           ## @BQ27XXX_DM_CKSUM
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"bus error writing chip memory: %d\n"

	.no_dead_strip	_bq27xxx_battery_write_dm_block
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function bq27xxx_battery_write_dm_block
_bq27xxx_battery_write_dm_block:        ; @bq27xxx_battery_write_dm_block
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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	w8, [x1]
	cbz	w8, LBB0_14
; %bb.1:
	mov	x20, x1
	mov	x19, x0
	ldr	w8, [x0]
Lloh0:
	adrp	x9, _BQ27XXX_O_CFGUP@GOTPAGE
Lloh1:
	ldr	x9, [x9, _BQ27XXX_O_CFGUP@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x9]
	ands	w22, w9, w8
	b.eq	LBB0_3
; %bb.2:
	mov	x0, x19
	bl	_bq27xxx_battery_set_cfgupdate
	tbnz	w0, #31, LBB0_10
LBB0_3:
Lloh3:
	adrp	x8, _BQ27XXX_DM_CTRL@GOTPAGE
Lloh4:
	ldr	x8, [x8, _BQ27XXX_DM_CTRL@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
	mov	x0, x19
	mov	w2, #0
	mov	w3, #1
	bl	_bq27xxx_write
	tbnz	w0, #31, LBB0_11
; %bb.4:
Lloh6:
	adrp	x8, _BQ27XXX_DM_CLASS@GOTPAGE
Lloh7:
	ldr	x8, [x8, _BQ27XXX_DM_CLASS@GOTPAGEOFF]
Lloh8:
	ldr	w1, [x8]
	ldr	w2, [x20, #12]
	mov	x0, x19
	mov	w3, #1
	bl	_bq27xxx_write
	tbnz	w0, #31, LBB0_11
; %bb.5:
Lloh9:
	adrp	x8, _BQ27XXX_DM_BLOCK@GOTPAGE
Lloh10:
	ldr	x8, [x8, _BQ27XXX_DM_BLOCK@GOTPAGEOFF]
Lloh11:
	ldr	w1, [x8]
	ldr	w2, [x20, #8]
	mov	x0, x19
	mov	w3, #1
	bl	_bq27xxx_write
	tbnz	w0, #31, LBB0_11
; %bb.6:
	mov	w0, #1
	bl	_BQ27XXX_MSLEEP
Lloh12:
	adrp	x8, _BQ27XXX_DM_DATA@GOTPAGE
Lloh13:
	ldr	x8, [x8, _BQ27XXX_DM_DATA@GOTPAGEOFF]
Lloh14:
	ldr	w1, [x8]
	ldr	w2, [x20, #4]
Lloh15:
	adrp	x8, _BQ27XXX_DM_SZ@GOTPAGE
Lloh16:
	ldr	x8, [x8, _BQ27XXX_DM_SZ@GOTPAGEOFF]
Lloh17:
	ldr	w3, [x8]
	mov	x0, x19
	bl	_bq27xxx_write_block
	tbnz	w0, #31, LBB0_11
; %bb.7:
Lloh18:
	adrp	x8, _BQ27XXX_DM_CKSUM@GOTPAGE
Lloh19:
	ldr	x8, [x8, _BQ27XXX_DM_CKSUM@GOTPAGEOFF]
Lloh20:
	ldr	w21, [x8]
	mov	x0, x20
	bl	_bq27xxx_battery_checksum_dm_block
	mov	x2, x0
	mov	x0, x19
	mov	x1, x21
	mov	w3, #1
	bl	_bq27xxx_write
	tbnz	w0, #31, LBB0_11
; %bb.8:
	cbz	w22, LBB0_16
; %bb.9:
	mov	w0, #1
	bl	_BQ27XXX_MSLEEP
	mov	x0, x19
	bl	_bq27xxx_battery_soft_reset
	tbz	w0, #31, LBB0_17
LBB0_10:
	mov	x21, x0
	b	LBB0_15
LBB0_11:
	mov	x21, x0
	cbz	w22, LBB0_13
; %bb.12:
	mov	x0, x19
	bl	_bq27xxx_battery_soft_reset
LBB0_13:
	ldr	w0, [x19, #4]
Lloh21:
	adrp	x1, l_.str@PAGE
Lloh22:
	add	x1, x1, l_.str@PAGEOFF
	mov	x2, x21
	bl	_dev_err
	b	LBB0_15
LBB0_14:
	mov	w21, #0
LBB0_15:
	mov	x0, x21
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
LBB0_16:
	mov	w0, #100
	bl	_BQ27XXX_MSLEEP
LBB0_17:
	mov	w21, #0
	str	wzr, [x20]
	b	LBB0_15
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpAdd	Lloh21, Lloh22
	.cfi_endproc
                                        ; -- End function
	.comm	_BQ27XXX_O_CFGUP,4,2            ; @BQ27XXX_O_CFGUP
	.comm	_BQ27XXX_DM_CTRL,4,2            ; @BQ27XXX_DM_CTRL
	.comm	_BQ27XXX_DM_CLASS,4,2           ; @BQ27XXX_DM_CLASS
	.comm	_BQ27XXX_DM_BLOCK,4,2           ; @BQ27XXX_DM_BLOCK
	.comm	_BQ27XXX_DM_DATA,4,2            ; @BQ27XXX_DM_DATA
	.comm	_BQ27XXX_DM_SZ,4,2              ; @BQ27XXX_DM_SZ
	.comm	_BQ27XXX_DM_CKSUM,4,2           ; @BQ27XXX_DM_CKSUM
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"bus error writing chip memory: %d\n"

	.no_dead_strip	_bq27xxx_battery_write_dm_block
.subsections_via_symbols
