	.file	"extr_cart.c_PicoCartLoad.c"
	.intel_syntax noprefix
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"out of memory (wanted %i)"
.LC1:
	.string	"read failed"
.LC2:
	.string	"BOOT"
.LC3:
	.string	"SMD format detected."
	.text
	.p2align 4
	.globl	PicoCartLoad
	.type	PicoCartLoad, @function
PicoCartLoad:
.LFB0:
	.cfi_startproc
	endbr64
	push	r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	push	r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	push	r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	push	r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	push	rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	push	rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	sub	rsp, 40
	.cfi_def_cfa_offset 96
	mov	QWORD PTR [rsp], rsi
	mov	QWORD PTR 8[rsp], rdx
	mov	DWORD PTR 24[rsp], ecx
	test	rdi, rdi
	je	.L14
	mov	edx, DWORD PTR [rdi]
	mov	r14, rdi
	mov	eax, 1
	test	edx, edx
	jle	.L1
	lea	eax, 3[rdx]
	mov	esi, ecx
	xor	ebx, ebx
	mov	r13d, 262144
	mov	r12d, eax
	mov	DWORD PTR 28[rsp], eax
	and	r12d, -4
	mov	edi, r12d
	call	PicoCartAlloc@PLT
	mov	QWORD PTR 16[rsp], rax
	mov	rbp, rax
	test	rax, rax
	je	.L38
	.p2align 4,,10
	.p2align 3
.L3:
	mov	esi, r12d
	mov	rdi, rbp
	mov	rdx, r14
	sub	esi, ebx
	cmp	esi, 262144
	cmovg	esi, r13d
	call	pm_read@PLT
	add	ebx, eax
	mov	r15d, eax
	cdqe
	add	rbp, rax
	imul	eax, ebx, 100
	cdq
	idiv	r12d
	mov	edi, eax
	call	PicoCartLoadProgressCB@PLT
	test	r15d, r15d
	jg	.L3
	test	ebx, ebx
	jle	.L39
	mov	eax, DWORD PTR 24[rsp]
	test	eax, eax
	jne	.L5
	mov	eax, DWORD PTR PicoAHW[rip]
	test	DWORD PTR PAHW_MCD[rip], eax
	jne	.L6
	cmp	r12d, 131072
	je	.L40
.L6:
	cmp	r12d, 16895
	jle	.L8
	mov	eax, DWORD PTR 28[rsp]
	and	eax, 16380
	cmp	eax, 512
	je	.L41
.L8:
	mov	rdi, QWORD PTR 16[rsp]
	mov	edx, r12d
	mov	rsi, rdi
	call	Byteswap@PLT
.L12:
	mov	rax, QWORD PTR [rsp]
	test	rax, rax
	je	.L13
	mov	rcx, QWORD PTR 16[rsp]
	mov	QWORD PTR [rax], rcx
.L13:
	mov	rcx, QWORD PTR 8[rsp]
	xor	eax, eax
	test	rcx, rcx
	je	.L1
	mov	DWORD PTR [rcx], r12d
.L1:
	add	rsp, 40
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	pop	rbx
	.cfi_def_cfa_offset 48
	pop	rbp
	.cfi_def_cfa_offset 40
	pop	r12
	.cfi_def_cfa_offset 32
	pop	r13
	.cfi_def_cfa_offset 24
	pop	r14
	.cfi_def_cfa_offset 16
	pop	r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L5:
	.cfi_restore_state
	cmp	r12d, 16895
	jle	.L12
	mov	eax, DWORD PTR 28[rsp]
	and	eax, 16380
	cmp	eax, 512
	jne	.L12
	mov	edi, DWORD PTR EL_STATUS[rip]
	lea	rsi, .LC3[rip]
	xor	eax, eax
	sub	r12d, 512
	call	elprintf@PLT
	mov	rdi, QWORD PTR 16[rsp]
	mov	edx, r12d
	lea	rsi, 512[rdi]
	call	memmove@PLT
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L14:
	add	rsp, 40
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	mov	eax, 1
	pop	rbx
	.cfi_def_cfa_offset 48
	pop	rbp
	.cfi_def_cfa_offset 40
	pop	r12
	.cfi_def_cfa_offset 32
	pop	r13
	.cfi_def_cfa_offset 24
	pop	r14
	.cfi_def_cfa_offset 16
	pop	r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L41:
	.cfi_restore_state
	mov	rcx, QWORD PTR 16[rsp]
	cmp	BYTE PTR 8832[rcx], 83
	movzx	eax, BYTE PTR 640[rcx]
	je	.L42
.L10:
	cmp	al, 83
	jne	.L8
	mov	rax, QWORD PTR 16[rsp]
	cmp	BYTE PTR 8833[rax], 69
	jne	.L8
.L11:
	mov	edi, DWORD PTR EL_STATUS[rip]
	lea	rsi, .LC3[rip]
	xor	eax, eax
	call	elprintf@PLT
	mov	rdi, QWORD PTR 16[rsp]
	mov	esi, r12d
	sub	r12d, 512
	call	DecodeSmd@PLT
	jmp	.L12
.L39:
	mov	edi, DWORD PTR EL_STATUS[rip]
	lea	rsi, .LC1[rip]
	xor	eax, eax
	call	elprintf@PLT
	mov	rdi, QWORD PTR 16[rsp]
	call	free@PLT
	mov	eax, 3
	jmp	.L1
.L38:
	mov	edi, DWORD PTR EL_STATUS[rip]
	mov	edx, r12d
	lea	rsi, .LC0[rip]
	call	elprintf@PLT
	mov	eax, 2
	jmp	.L1
.L40:
	mov	rax, QWORD PTR 16[rsp]
	mov	edx, 4
	lea	rsi, .LC2[rip]
	lea	rdi, 292[rax]
	call	strncmp@PLT
	test	eax, eax
	jne	.L7
.L9:
	mov	eax, DWORD PTR PAHW_MCD[rip]
	or	DWORD PTR PicoAHW[rip], eax
	jmp	.L8
.L42:
	cmp	al, 69
	jne	.L10
	jmp	.L11
.L7:
	mov	rax, QWORD PTR 16[rsp]
	mov	edx, 4
	lea	rsi, .LC2[rip]
	lea	rdi, 296[rax]
	call	strncmp@PLT
	test	eax, eax
	je	.L9
	jmp	.L8
	.cfi_endproc
.LFE0:
	.size	PicoCartLoad, .-PicoCartLoad
	.comm	PicoAHW,4,4
	.comm	PAHW_MCD,4,4
	.comm	EL_STATUS,4,4
	.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_cart.c_PicoCartLoad.c"
	.text
	.section	.rodata.str1.4,"aMS",%progbits,1
	.align	2
.LC0:
	.ascii	"out of memory (wanted %i)\000"
	.global	__aeabi_idiv
	.align	2
.LC1:
	.ascii	"read failed\000"
	.align	2
.LC2:
	.ascii	"BOOT\000"
	.align	2
.LC3:
	.ascii	"SMD format detected.\000"
	.text
	.align	2
	.global	PicoCartLoad
	.syntax unified
	.arm
	.fpu softvfp
	.type	PicoCartLoad, %function
PicoCartLoad:
	@ args = 0, pretend = 0, frame = 8
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, r10, fp, lr}
	subs	r9, r0, #0
	sub	sp, sp, #12
	str	r1, [sp]
	beq	.L14
	ldr	r10, [r9]
	cmp	r10, #0
	ble	.L14
	mov	r8, r3
	add	r3, r10, #3
	bic	r6, r3, #3
	mov	r0, r6
	mov	r1, r8
	mov	r7, r2
	str	r3, [sp, #4]
	bl	PicoCartAlloc
	subs	fp, r0, #0
	movne	r10, fp
	movne	r5, #0
	beq	.L30
.L3:
	sub	r1, r6, r5
	cmp	r1, #262144
	movge	r1, #262144
	mov	r2, r9
	mov	r0, r10
	bl	pm_read
	mov	r4, r0
	add	r5, r5, r0
	add	r0, r5, r5, lsl #2
	add	r0, r0, r0, lsl #2
	mov	r1, r6
	lsl	r0, r0, #2
	bl	__aeabi_idiv
	bl	PicoCartLoadProgressCB
	cmp	r4, #0
	add	r10, r10, r4
	bgt	.L3
	cmp	r5, #0
	ble	.L31
	cmp	r8, #0
	bne	.L5
	ldr	r3, .L35
	ldr	r5, .L35+4
	ldr	r8, [r3]
	ldr	r4, [r5]
	and	r3, r4, r8
	cmp	r6, #131072
	cmpeq	r3, #0
	beq	.L32
	cmp	r6, #16896
	blt	.L8
	ldr	r3, .L35+8
	ldr	r2, [sp, #4]
	and	r2, r2, r3
	cmp	r2, #512
	beq	.L33
.L8:
	mov	r2, r6
	mov	r1, fp
	mov	r0, fp
	bl	Byteswap
.L11:
	mov	r0, #0
	ldr	r3, [sp]
	cmp	r3, #0
	strne	fp, [r3]
	cmp	r7, #0
	strne	r6, [r7]
	add	sp, sp, #12
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L14:
	mov	r0, #1
.L1:
	add	sp, sp, #12
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L5:
	cmp	r6, #16896
	blt	.L11
	ldr	r3, .L35+8
	ldr	r2, [sp, #4]
	and	r2, r2, r3
	cmp	r2, #512
	bne	.L11
	ldr	r3, .L35+12
	ldr	r1, .L35+16
	ldr	r0, [r3]
	sub	r6, r6, #512
	bl	elprintf
	mov	r2, r6
	mov	r0, fp
	add	r1, fp, #512
	bl	memmove
	b	.L11
.L32:
	mov	r2, #4
	ldr	r1, .L35+20
	add	r0, fp, #292
	bl	strncmp
	cmp	r0, #0
	beq	.L7
	mov	r2, #4
	ldr	r1, .L35+20
	add	r0, fp, #296
	bl	strncmp
	cmp	r0, #0
	bne	.L8
.L7:
	orr	r4, r4, r8
	str	r4, [r5]
	b	.L8
.L33:
	add	r3, fp, #8192
	ldrb	r1, [r3, #640]	@ zero_extendqisi2
	ldrb	r2, [fp, #640]	@ zero_extendqisi2
	cmp	r1, #83
	beq	.L34
.L9:
	cmp	r2, #83
	bne	.L8
	ldrb	r3, [r3, #641]	@ zero_extendqisi2
	cmp	r3, #69
	bne	.L8
.L10:
	ldr	r3, .L35+12
	ldr	r1, .L35+16
	ldr	r0, [r3]
	bl	elprintf
	mov	r1, r6
	mov	r0, fp
	sub	r6, r6, #512
	bl	DecodeSmd
	b	.L11
.L31:
	ldr	r3, .L35+12
	ldr	r1, .L35+24
	ldr	r0, [r3]
	bl	elprintf
	mov	r0, fp
	bl	free
	mov	r0, #3
	b	.L1
.L30:
	ldr	r3, .L35+12
	mov	r2, r6
	ldr	r0, [r3]
	ldr	r1, .L35+28
	bl	elprintf
	mov	r0, #2
	b	.L1
.L34:
	cmp	r2, #69
	bne	.L9
	b	.L10
.L36:
	.align	2
.L35:
	.word	PAHW_MCD
	.word	PicoAHW
	.word	16380
	.word	EL_STATUS
	.word	.LC3
	.word	.LC2
	.word	.LC1
	.word	.LC0
	.size	PicoCartLoad, .-PicoCartLoad
	.comm	PicoAHW,4,4
	.comm	PAHW_MCD,4,4
	.comm	EL_STATUS,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
