	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function ims_pcu_flash_firmware
_ims_pcu_flash_firmware:                ## @ims_pcu_flash_firmware
	.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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%edx, %r15d
	movq	%rdi, %r14
	movq	(%rsi), %r13
	movq	_ERASE_APP@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	movl	$2000, %r8d                     ## imm = 0x7D0
	callq	_ims_pcu_execute_bl_command
	testl	%eax, %eax
	je	LBB0_5
## %bb.1:
	movl	%eax, %r12d
	movl	12(%r14), %edi
	leaq	L_.str(%rip), %rsi
LBB0_2:
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	_dev_err
LBB0_4:
	movl	%r12d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_5:
	testq	%r13, %r13
	movq	%r14, %r12
	je	LBB0_13
## %bb.6:
	movl	$100, %ebx
	movl	%r15d, -44(%rbp)                ## 4-byte Spill
	jmp	LBB0_8
	.p2align	4, 0x90
LBB0_7:                                 ##   in Loop: Header=BB0_8 Depth=1
	movl	-48(%rbp), %ebx                 ## 4-byte Reload
	movl	%ebx, %eax
	xorl	%edx, %edx
	movl	-44(%rbp), %r15d                ## 4-byte Reload
	divl	%r15d
	movl	%eax, 8(%rsi)
	movq	%rsi, %r12
	movq	%r13, %rdi
	callq	_ihex_next_binrec
	movq	%rax, %r13
	addl	$100, %ebx
	testq	%rax, %rax
	je	LBB0_13
LBB0_8:                                 ## =>This Inner Loop Header: Depth=1
	movl	%ebx, -48(%rbp)                 ## 4-byte Spill
	movl	8(%r13), %edi
	callq	_be32_to_cpu
	movl	%eax, %r14d
	shrl	$31, %r14d
	addl	%eax, %r14d
	sarl	%r14d
	movl	4(%r13), %edi
	callq	_be16_to_cpu
	movq	%rax, %r15
	movq	16(%r12), %rbx
	leaq	20(%rbx), %rsi
	movl	%r14d, %edi
	callq	_put_unaligned_le32
	movq	%r15, 12(%rbx)
	movl	4(%rbx), %edi
	movl	(%r13), %esi
	movq	%r15, %rdx
	callq	_memcpy
	movq	_PROGRAM_DEVICE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rcx
	addq	$5, %rcx
	movq	_IMS_PCU_CMD_RESPONSE_TIMEOUT@GOTPCREL(%rip), %rax
	movl	(%rax), %r8d
	movq	%r12, %rdi
	xorl	%edx, %edx
	callq	_ims_pcu_execute_bl_command
	movq	%r12, %rsi
	testl	%eax, %eax
	jne	LBB0_15
## %bb.9:                               ##   in Loop: Header=BB0_8 Depth=1
	cmpl	(%rsi), %r14d
	jl	LBB0_7
## %bb.10:                              ##   in Loop: Header=BB0_8 Depth=1
	cmpl	4(%rsi), %r14d
	jge	LBB0_7
## %bb.11:                              ##   in Loop: Header=BB0_8 Depth=1
	movl	(%r13), %ecx
	movq	%rsi, %rbx
	movq	%rsi, %rdi
	movl	%r14d, %esi
	movq	%r15, %rdx
	callq	_ims_pcu_verify_block
	movq	%rbx, %rsi
	testl	%eax, %eax
	je	LBB0_7
## %bb.12:
	movl	%eax, %r12d
	jmp	LBB0_4
LBB0_13:
	movq	_PROGRAM_COMPLETE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r12, %rbx
	xorl	%r12d, %r12d
	movq	%rbx, %rdi
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	movl	$2000, %r8d                     ## imm = 0x7D0
	callq	_ims_pcu_execute_bl_command
	testl	%eax, %eax
	je	LBB0_4
## %bb.14:
	movl	12(%rbx), %edi
	leaq	L_.str.2(%rip), %rsi
	xorl	%r12d, %r12d
	jmp	LBB0_2
LBB0_15:
	movl	%eax, %r12d
	movl	12(%rsi), %edi
	leaq	L_.str.1(%rip), %rsi
	movl	%r14d, %edx
	movq	%r15, %rcx
	movl	%eax, %r8d
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_4
	.cfi_endproc
                                        ## -- End function
	.comm	_ERASE_APP,4,2                  ## @ERASE_APP
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Failed to erase application image, error: %d\n"

	.comm	_PROGRAM_DEVICE,4,2             ## @PROGRAM_DEVICE
	.comm	_IMS_PCU_CMD_RESPONSE_TIMEOUT,4,2 ## @IMS_PCU_CMD_RESPONSE_TIMEOUT
L_.str.1:                               ## @.str.1
	.asciz	"Failed to write block at 0x%08x, len %d, error: %d\n"

	.comm	_PROGRAM_COMPLETE,4,2           ## @PROGRAM_COMPLETE
L_.str.2:                               ## @.str.2
	.asciz	"Failed to send PROGRAM_COMPLETE, error: %d\n"

	.no_dead_strip	_ims_pcu_flash_firmware
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function ims_pcu_flash_firmware
_ims_pcu_flash_firmware:                ; @ims_pcu_flash_firmware
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x20, x2
	mov	x19, x0
	ldr	x21, [x1]
Lloh0:
	adrp	x8, _ERASE_APP@GOTPAGE
Lloh1:
	ldr	x8, [x8, _ERASE_APP@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	mov	x2, #0
	mov	x3, #0
	mov	w4, #2000
	bl	_ims_pcu_execute_bl_command
	cbz	w0, LBB0_3
; %bb.1:
	mov	x24, x0
	ldr	w0, [x19, #12]
Lloh3:
	adrp	x1, l_.str@PAGE
Lloh4:
	add	x1, x1, l_.str@PAGEOFF
	mov	x2, x24
LBB0_2:
	bl	_dev_err
	b	LBB0_14
LBB0_3:
	cbz	x21, LBB0_11
; %bb.4:
	mov	w25, #100
Lloh5:
	adrp	x26, _PROGRAM_DEVICE@GOTPAGE
Lloh6:
	ldr	x26, [x26, _PROGRAM_DEVICE@GOTPAGEOFF]
Lloh7:
	adrp	x27, _IMS_PCU_CMD_RESPONSE_TIMEOUT@GOTPAGE
Lloh8:
	ldr	x27, [x27, _IMS_PCU_CMD_RESPONSE_TIMEOUT@GOTPAGEOFF]
	b	LBB0_6
LBB0_5:                                 ;   in Loop: Header=BB0_6 Depth=1
	udiv	w8, w25, w20
	str	w8, [x19, #8]
	mov	x0, x21
	bl	_ihex_next_binrec
	mov	x21, x0
	add	w25, w25, #100
	cbz	x0, LBB0_11
LBB0_6:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w0, [x21, #8]
	bl	_be32_to_cpu
	cmp	w0, #0
	cinc	w8, w0, lt
	asr	w22, w8, #1
	ldr	w0, [x21, #4]
	bl	_be16_to_cpu
	mov	x23, x0
	ldr	x24, [x19, #16]
	add	x1, x24, #20
	mov	x0, x22
	bl	_put_unaligned_le32
	stur	x23, [x24, #12]
	ldr	w0, [x24, #4]
	ldr	w1, [x21]
	mov	x2, x23
	bl	_memcpy
	ldr	w1, [x26]
	add	x3, x23, #5
	ldr	w4, [x27]
	mov	x0, x19
	mov	x2, #0
	bl	_ims_pcu_execute_bl_command
	cbnz	w0, LBB0_15
; %bb.7:                                ;   in Loop: Header=BB0_6 Depth=1
	ldr	w8, [x19]
	cmp	w22, w8
	b.lt	LBB0_5
; %bb.8:                                ;   in Loop: Header=BB0_6 Depth=1
	ldr	w8, [x19, #4]
	cmp	w22, w8
	b.ge	LBB0_5
; %bb.9:                                ;   in Loop: Header=BB0_6 Depth=1
	ldr	w3, [x21]
	mov	x0, x19
	mov	x1, x22
	mov	x2, x23
	bl	_ims_pcu_verify_block
	cbz	w0, LBB0_5
; %bb.10:
	mov	x24, x0
	b	LBB0_14
LBB0_11:
Lloh9:
	adrp	x8, _PROGRAM_COMPLETE@GOTPAGE
Lloh10:
	ldr	x8, [x8, _PROGRAM_COMPLETE@GOTPAGEOFF]
Lloh11:
	ldr	w1, [x8]
	mov	x0, x19
	mov	x2, #0
	mov	x3, #0
	mov	w4, #2000
	bl	_ims_pcu_execute_bl_command
	cbz	w0, LBB0_13
; %bb.12:
	mov	x2, x0
	ldr	w0, [x19, #12]
Lloh12:
	adrp	x1, l_.str.2@PAGE
Lloh13:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_dev_err
LBB0_13:
	mov	w24, #0
LBB0_14:
	mov	x0, x24
	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
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_15:
	mov	x24, x0
	ldr	w0, [x19, #12]
	stp	x23, x24, [sp]
Lloh14:
	adrp	x1, l_.str.1@PAGE
Lloh15:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x2, x22
	b	LBB0_2
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpAdd	Lloh14, Lloh15
	.cfi_endproc
                                        ; -- End function
	.comm	_ERASE_APP,4,2                  ; @ERASE_APP
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Failed to erase application image, error: %d\n"

	.comm	_PROGRAM_DEVICE,4,2             ; @PROGRAM_DEVICE
	.comm	_IMS_PCU_CMD_RESPONSE_TIMEOUT,4,2 ; @IMS_PCU_CMD_RESPONSE_TIMEOUT
l_.str.1:                               ; @.str.1
	.asciz	"Failed to write block at 0x%08x, len %d, error: %d\n"

	.comm	_PROGRAM_COMPLETE,4,2           ; @PROGRAM_COMPLETE
l_.str.2:                               ; @.str.2
	.asciz	"Failed to send PROGRAM_COMPLETE, error: %d\n"

	.no_dead_strip	_ims_pcu_flash_firmware
.subsections_via_symbols
