	.file	"extr_esp_ota_ops.c_esp_ota_begin.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.globl	esp_ota_begin
	.type	esp_ota_begin, @function
esp_ota_begin:
.LFB0:
	.cfi_startproc
	endbr64
	test	rdi, rdi
	je	.L22
	push	r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	push	r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	push	rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	push	rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	mov	rbx, rdx
	sub	rsp, 8
	.cfi_def_cfa_offset 48
	test	rdx, rdx
	je	.L25
	mov	rbp, rsi
	call	esp_partition_verify@PLT
	mov	r12, rax
	mov	rax, QWORD PTR ESP_ERR_NOT_FOUND[rip]
	test	r12, r12
	je	.L1
	mov	rdi, r12
	call	is_ota_partition@PLT
	test	eax, eax
	jne	.L6
.L25:
	mov	rax, QWORD PTR ESP_ERR_INVALID_ARG[rip]
.L1:
	add	rsp, 8
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	pop	rbx
	.cfi_def_cfa_offset 32
	pop	rbp
	.cfi_def_cfa_offset 24
	pop	r12
	.cfi_def_cfa_offset 16
	pop	r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L6:
	.cfi_restore_state
	xor	eax, eax
	call	esp_ota_get_running_partition@PLT
	cmp	r12, rax
	je	.L27
	test	rbp, rbp
	je	.L8
	cmp	QWORD PTR OTA_SIZE_UNKNOWN[rip], rbp
	jne	.L9
.L8:
	mov	rdx, QWORD PTR [r12]
	xor	esi, esi
	mov	rdi, r12
	call	esp_partition_erase_range@PLT
.L10:
	cmp	QWORD PTR ESP_OK[rip], rax
	jne	.L1
	mov	esi, 1
	mov	edi, 24
	call	calloc@PLT
	mov	r13, rax
	mov	rax, QWORD PTR ESP_ERR_NO_MEM[rip]
	test	r13, r13
	je	.L1
	mov	edx, DWORD PTR entries[rip]
	mov	rsi, r13
	lea	rdi, s_ota_ops_entries_head[rip]
	call	LIST_INSERT_HEAD@PLT
	test	rbp, rbp
	je	.L12
	cmp	QWORD PTR OTA_SIZE_UNKNOWN[rip], rbp
	je	.L12
.L13:
	mov	rax, QWORD PTR s_ota_ops_last_handle[rip]
	mov	QWORD PTR 0[r13], rbp
	mov	QWORD PTR 16[r13], r12
	add	rax, 1
	mov	QWORD PTR s_ota_ops_last_handle[rip], rax
	mov	QWORD PTR 8[r13], rax
	mov	QWORD PTR [rbx], rax
	mov	rax, QWORD PTR ESP_OK[rip]
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L22:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	mov	rax, QWORD PTR ESP_ERR_INVALID_ARG[rip]
	ret
	.p2align 4,,10
	.p2align 3
.L9:
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -40
	.cfi_offset 6, -32
	.cfi_offset 12, -24
	.cfi_offset 13, -16
	mov	rcx, QWORD PTR SPI_FLASH_SEC_SIZE[rip]
	mov	rax, rbp
	xor	edx, edx
	xor	esi, esi
	mov	rdi, r12
	div	rcx
	lea	rdx, 1[rax]
	imul	rdx, rcx
	call	esp_partition_erase_range@PLT
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L27:
	mov	rax, QWORD PTR ESP_ERR_OTA_PARTITION_CONFLICT[rip]
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L12:
	mov	rbp, QWORD PTR [r12]
	jmp	.L13
	.cfi_endproc
.LFE0:
	.size	esp_ota_begin, .-esp_ota_begin
	.comm	s_ota_ops_last_handle,8,8
	.comm	s_ota_ops_entries_head,4,4
	.comm	entries,4,4
	.comm	TAG,4,4
	.comm	SPI_FLASH_SEC_SIZE,8,8
	.comm	OTA_SIZE_UNKNOWN,8,8
	.comm	ESP_OTA_IMG_PENDING_VERIFY,8,8
	.comm	ESP_OK,8,8
	.comm	ESP_ERR_OTA_ROLLBACK_INVALID_STATE,8,8
	.comm	ESP_ERR_OTA_PARTITION_CONFLICT,8,8
	.comm	ESP_ERR_NO_MEM,8,8
	.comm	ESP_ERR_NOT_FOUND,8,8
	.comm	ESP_ERR_INVALID_ARG,8,8
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 2
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"extr_esp_ota_ops.c_esp_ota_begin.c"
	.text
	.global	__aeabi_uidiv
	.align	2
	.global	esp_ota_begin
	.syntax unified
	.arm
	.fpu softvfp
	.type	esp_ota_begin, %function
esp_ota_begin:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 0, uses_anonymous_args = 0
	clz	r3, r2
	cmp	r0, #0
	lsr	r3, r3, #5
	push	{r4, r5, r6, r7, r8, lr}
	movne	r4, r3
	moveq	r4, #1
	cmp	r4, #0
	beq	.L2
.L20:
	ldr	r3, .L25
	ldr	r0, [r3]
	pop	{r4, r5, r6, r7, r8, pc}
.L2:
	mov	r6, r1
	mov	r5, r2
	bl	esp_partition_verify
	subs	r7, r0, #0
	beq	.L22
	bl	is_ota_partition
	cmp	r0, #0
	beq	.L20
	bl	esp_ota_get_running_partition
	cmp	r7, r0
	beq	.L23
	cmp	r6, #0
	beq	.L7
	ldr	r3, .L25+4
	ldr	r3, [r3]
	cmp	r3, r6
	bne	.L8
.L7:
	mov	r1, #0
	mov	r0, r7
	ldr	r2, [r7]
	bl	esp_partition_erase_range
.L9:
	ldr	r8, .L25+8
	ldr	r3, [r8]
	cmp	r3, r0
	popne	{r4, r5, r6, r7, r8, pc}
	mov	r1, #1
	mov	r0, #12
	bl	calloc
	subs	r4, r0, #0
	beq	.L24
	ldr	r3, .L25+12
	mov	r1, r4
	ldr	r2, [r3]
	ldr	r0, .L25+16
	bl	LIST_INSERT_HEAD
	cmp	r6, #0
	beq	.L11
	ldr	r3, .L25+4
	ldr	r3, [r3]
	cmp	r3, r6
	beq	.L11
.L12:
	ldr	r2, .L25+20
	str	r6, [r4]
	ldr	r3, [r2]
	str	r7, [r4, #8]
	add	r3, r3, #1
	str	r3, [r2]
	str	r3, [r5]
	ldr	r0, [r8]
	str	r3, [r4, #4]
	pop	{r4, r5, r6, r7, r8, pc}
.L22:
	ldr	r3, .L25+24
	ldr	r0, [r3]
	pop	{r4, r5, r6, r7, r8, pc}
.L8:
	ldr	r3, .L25+28
	mov	r0, r6
	ldr	r8, [r3]
	mov	r1, r8
	bl	__aeabi_uidiv
	add	r0, r0, #1
	mul	r2, r8, r0
	mov	r1, r4
	mov	r0, r7
	bl	esp_partition_erase_range
	b	.L9
.L11:
	ldr	r6, [r7]
	b	.L12
.L23:
	ldr	r3, .L25+32
	ldr	r0, [r3]
	pop	{r4, r5, r6, r7, r8, pc}
.L24:
	ldr	r3, .L25+36
	ldr	r0, [r3]
	pop	{r4, r5, r6, r7, r8, pc}
.L26:
	.align	2
.L25:
	.word	ESP_ERR_INVALID_ARG
	.word	OTA_SIZE_UNKNOWN
	.word	ESP_OK
	.word	entries
	.word	s_ota_ops_entries_head
	.word	s_ota_ops_last_handle
	.word	ESP_ERR_NOT_FOUND
	.word	SPI_FLASH_SEC_SIZE
	.word	ESP_ERR_OTA_PARTITION_CONFLICT
	.word	ESP_ERR_NO_MEM
	.size	esp_ota_begin, .-esp_ota_begin
	.comm	s_ota_ops_last_handle,4,4
	.comm	s_ota_ops_entries_head,4,4
	.comm	entries,4,4
	.comm	TAG,4,4
	.comm	SPI_FLASH_SEC_SIZE,4,4
	.comm	OTA_SIZE_UNKNOWN,4,4
	.comm	ESP_OTA_IMG_PENDING_VERIFY,4,4
	.comm	ESP_OK,4,4
	.comm	ESP_ERR_OTA_ROLLBACK_INVALID_STATE,4,4
	.comm	ESP_ERR_OTA_PARTITION_CONFLICT,4,4
	.comm	ESP_ERR_NO_MEM,4,4
	.comm	ESP_ERR_NOT_FOUND,4,4
	.comm	ESP_ERR_INVALID_ARG,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
