	.file	"extr_file_slot.c_slot_autodetect.c"
	.intel_syntax noprefix
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s/saves/%s.gp%d"
.LC1:
	.string	"%s/saves/%s.srm"
.LC2:
	.string	"rb"
.LC3:
	.string	"MD-%04X.gp%d"
.LC4:
	.string	"MD-%04X.srm"
.LC5:
	.string	"00"
.LC6:
	.string	"GENP"
	.text
	.p2align 4
	.globl	slot_autodetect
	.type	slot_autodetect, @function
slot_autodetect:
.LFB0:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	push	r15
	push	r14
	push	r13
	push	r12
	push	rbx
	sub	rsp, 40
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR -56[rbp], rax
	xor	eax, eax
	test	rdx, rdx
	je	.L1
	movsx	rax, DWORD PTR MAXPATHLEN[rip]
	mov	rbx, rdx
	mov	rcx, rsp
	mov	r14d, edi
	mov	r12d, esi
	mov	r13, rsp
	add	rax, 15
	mov	rdx, rax
	and	rax, -4096
	sub	rcx, rax
	and	rdx, -16
	mov	rax, rcx
	cmp	rsp, rax
	je	.L5
.L25:
	sub	rsp, 4096
	or	QWORD PTR 4088[rsp], 0
	cmp	rsp, rax
	jne	.L25
.L5:
	and	edx, 4095
	sub	rsp, rdx
	test	rdx, rdx
	jne	.L26
.L6:
	xor	esi, esi
	mov	edx, 32
	mov	rdi, rbx
	mov	r15, rsp
	call	memset@PLT
	test	r12d, r12d
	je	.L27
	mov	edx, DWORD PTR rominfo[rip]
	test	r14d, r14d
	jle	.L12
	lea	ecx, -1[r14]
	lea	rsi, .LC3[rip]
	mov	rdi, rsp
	xor	eax, eax
	call	sprintf@PLT
.L13:
	mov	edx, DWORD PTR CARD_WORKAREA[rip]
	xor	esi, esi
	lea	rdi, SysArea[rip]
	sub	r12d, 1
	call	memset@PLT
	lea	rdi, .LC6[rip]
	lea	rsi, .LC5[rip]
	call	CARD_Init@PLT
	mov	edi, r12d
	call	CardMount@PLT
	test	rax, rax
	jne	.L28
.L11:
	mov	rsp, r13
.L1:
	mov	rax, QWORD PTR -56[rbp]
	xor	rax, QWORD PTR fs:40
	jne	.L29
	lea	rsp, -40[rbp]
	pop	rbx
	pop	r12
	pop	r13
	pop	r14
	pop	r15
	pop	rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
	.p2align 4,,10
	.p2align 3
.L27:
	.cfi_restore_state
	mov	rcx, QWORD PTR rom_filename[rip]
	mov	rdx, QWORD PTR DEFAULT_PATH[rip]
	test	r14d, r14d
	jle	.L8
	lea	r8d, -1[r14]
	lea	rsi, .LC0[rip]
	mov	rdi, rsp
	xor	eax, eax
	call	sprintf@PLT
.L9:
	lea	rsi, .LC2[rip]
	mov	rdi, r15
	call	fopen@PLT
	mov	r12, rax
	test	rax, rax
	je	.L11
	lea	r14, -60[rbp]
	mov	rdi, r15
	mov	rsi, r14
	call	stat@PLT
	mov	rdi, r14
	call	localtime@PLT
	mov	rdi, r12
	mov	rcx, QWORD PTR 16[rax]
	lea	rdx, 1900[rcx]
	mov	QWORD PTR 24[rbx], rdx
	mov	edx, DWORD PTR 12[rax]
	mov	DWORD PTR 16[rbx], edx
	mov	edx, DWORD PTR 8[rax]
	mov	DWORD PTR 12[rbx], edx
	mov	edx, DWORD PTR 4[rax]
	mov	eax, DWORD PTR [rax]
	mov	DWORD PTR 8[rbx], edx
	mov	DWORD PTR 4[rbx], eax
	call	fclose@PLT
	mov	DWORD PTR [rbx], 1
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L26:
	or	QWORD PTR -8[rsp+rdx], 0
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L8:
	lea	rsi, .LC1[rip]
	mov	rdi, rsp
	xor	eax, eax
	call	sprintf@PLT
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L12:
	lea	rsi, .LC4[rip]
	mov	rdi, rsp
	xor	eax, eax
	call	sprintf@PLT
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L28:
	lea	r14, -68[rbp]
	mov	rsi, r15
	mov	edi, r12d
	mov	rdx, r14
	call	CARD_Open@PLT
	cmp	rax, QWORD PTR CARD_ERROR_READY[rip]
	je	.L30
.L15:
	mov	edi, r12d
	call	CARD_Unmount@PLT
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L30:
	mov	esi, DWORD PTR -68[rbp]
	lea	rdx, -64[rbp]
	mov	edi, r12d
	call	CARD_GetStatus@PLT
	mov	eax, DWORD PTR -64[rbp]
	lea	rdi, -60[rbp]
	mov	DWORD PTR -60[rbp], eax
	call	localtime@PLT
	mov	rdi, r14
	mov	rcx, QWORD PTR 16[rax]
	lea	rdx, 1900[rcx]
	mov	QWORD PTR 24[rbx], rdx
	mov	edx, DWORD PTR 12[rax]
	mov	DWORD PTR 16[rbx], edx
	mov	edx, DWORD PTR 8[rax]
	mov	DWORD PTR 12[rbx], edx
	mov	edx, DWORD PTR 4[rax]
	mov	eax, DWORD PTR [rax]
	mov	DWORD PTR 8[rbx], edx
	mov	DWORD PTR 4[rbx], eax
	call	CARD_Close@PLT
	mov	DWORD PTR [rbx], 1
	jmp	.L15
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE0:
	.size	slot_autodetect, .-slot_autodetect
	.comm	rominfo,4,4
	.comm	rom_filename,8,8
	.comm	SysArea,32,32
	.comm	MAXPATHLEN,4,4
	.comm	DEFAULT_PATH,8,8
	.comm	CARD_WORKAREA,4,4
	.comm	CARD_ERROR_READY,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_file_slot.c_slot_autodetect.c"
	.text
	.section	.rodata.str1.4,"aMS",%progbits,1
	.align	2
.LC0:
	.ascii	"%s/saves/%s.gp%d\000"
	.align	2
.LC1:
	.ascii	"%s/saves/%s.srm\000"
	.align	2
.LC2:
	.ascii	"rb\000"
	.align	2
.LC3:
	.ascii	"MD-%04X.gp%d\000"
	.align	2
.LC4:
	.ascii	"MD-%04X.srm\000"
	.align	2
.LC5:
	.ascii	"00\000"
	.align	2
.LC6:
	.ascii	"GENP\000"
	.section	.rodata.cst4,"aM",%progbits,4
	.align	2
.LC7:
	.word	__stack_chk_guard
	.text
	.align	2
	.global	slot_autodetect
	.syntax unified
	.arm
	.fpu softvfp
	.type	slot_autodetect, %function
slot_autodetect:
	@ args = 0, pretend = 0, frame = 16
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, fp, lr}
	add	fp, sp, #24
	sub	sp, sp, #28
	ldr	r3, .L23
	subs	r5, r2, #0
	ldr	r3, [r3]
	str	r3, [fp, #-32]
	mov	r3,#0
	beq	.L1
	mov	r6, r1
	ldr	r3, .L23+4
	mov	r4, r0
	ldr	r3, [r3]
	mov	r7, sp
	add	r3, r3, #7
	bic	r3, r3, #7
	sub	sp, sp, r3
	mov	r2, #24
	mov	r1, #0
	mov	r0, r5
	bl	memset
	cmp	r6, #0
	add	r8, sp, #8
	beq	.L19
	ldr	r3, .L23+8
	cmp	r4, #0
	ldr	r2, [r3]
	ble	.L9
	mov	r0, r8
	ldr	r1, .L23+12
	sub	r3, r4, #1
	bl	sprintf
.L10:
	ldr	r3, .L23+16
	mov	r1, #0
	ldr	r2, [r3]
	ldr	r0, .L23+20
	bl	memset
	sub	r6, r6, #1
	ldr	r1, .L23+24
	ldr	r0, .L23+28
	bl	CARD_Init
	mov	r0, r6
	bl	CardMount
	cmp	r0, #0
	bne	.L20
.L8:
	mov	sp, r7
.L1:
	ldr	r3, .L23
	ldr	r2, [r3]
	ldr	r3, [fp, #-32]
	eors	r2, r3, r2
	mov	r3, #0
	bne	.L21
	sub	sp, fp, #24
	@ sp needed
	pop	{r4, r5, r6, r7, r8, fp, pc}
.L19:
	ldr	r2, .L23+32
	ldr	r3, .L23+36
	cmp	r4, #0
	ldr	r2, [r2]
	ldr	r3, [r3]
	ble	.L5
	sub	r4, r4, #1
	mov	r0, r8
	ldr	r1, .L23+40
	str	r4, [sp]
	bl	sprintf
.L6:
	mov	r0, r8
	ldr	r1, .L23+44
	bl	fopen
	subs	r4, r0, #0
	beq	.L8
	sub	r1, fp, #36
	mov	r0, r8
	bl	stat
	sub	r0, fp, #36
	bl	localtime
	mov	r3, r0
	ldr	r2, [r0, #16]
	ldr	ip, [r0, #12]
	add	r2, r2, #1888
	add	r2, r2, #12
	ldr	r1, [r0, #8]
	str	r2, [r5, #20]
	ldr	r2, [r3, #4]
	ldr	r3, [r3]
	mov	r0, r4
	str	r3, [r5, #4]
	str	ip, [r5, #16]
	str	r1, [r5, #12]
	str	r2, [r5, #8]
	bl	fclose
	mov	r3, #1
	str	r3, [r5]
	b	.L8
.L5:
	mov	r0, r8
	ldr	r1, .L23+48
	bl	sprintf
	b	.L6
.L9:
	mov	r0, r8
	ldr	r1, .L23+52
	bl	sprintf
	b	.L10
.L20:
	mov	r1, r8
	mov	r0, r6
	sub	r2, fp, #44
	bl	CARD_Open
	ldr	r3, .L23+56
	ldr	r3, [r3]
	cmp	r0, r3
	beq	.L22
.L12:
	mov	r0, r6
	bl	CARD_Unmount
	b	.L8
.L22:
	ldr	r1, [fp, #-44]
	sub	r2, fp, #40
	mov	r0, r6
	bl	CARD_GetStatus
	ldr	r3, [fp, #-40]
	sub	r0, fp, #36
	str	r3, [fp, #-36]
	bl	localtime
	mov	r3, r0
	ldr	r2, [r0, #16]
	ldr	ip, [r0, #12]
	add	r2, r2, #1888
	add	r2, r2, #12
	ldr	r1, [r0, #8]
	str	r2, [r5, #20]
	ldr	r2, [r3, #4]
	ldr	r3, [r3]
	sub	r0, fp, #44
	str	r3, [r5, #4]
	str	ip, [r5, #16]
	str	r1, [r5, #12]
	str	r2, [r5, #8]
	bl	CARD_Close
	mov	r3, #1
	str	r3, [r5]
	b	.L12
.L21:
	bl	__stack_chk_fail
.L24:
	.align	2
.L23:
	.word	.LC7
	.word	MAXPATHLEN
	.word	rominfo
	.word	.LC3
	.word	CARD_WORKAREA
	.word	SysArea
	.word	.LC5
	.word	.LC6
	.word	DEFAULT_PATH
	.word	rom_filename
	.word	.LC0
	.word	.LC2
	.word	.LC1
	.word	.LC4
	.word	CARD_ERROR_READY
	.size	slot_autodetect, .-slot_autodetect
	.comm	rominfo,4,4
	.comm	rom_filename,4,4
	.comm	SysArea,24,4
	.comm	MAXPATHLEN,4,4
	.comm	DEFAULT_PATH,4,4
	.comm	CARD_WORKAREA,4,4
	.comm	CARD_ERROR_READY,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
