	.file	"extr_sd_fat_devoptab.c_sd_fat_open_r.c"
	.intel_syntax noprefix
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"r"
.LC1:
	.string	"a+"
.LC2:
	.string	"w"
.LC3:
	.string	"a"
.LC4:
	.string	"r+"
	.text
	.p2align 4
	.type	sd_fat_open_r, @function
sd_fat_open_r:
.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
	mov	r14, rdi
	mov	rdi, rdx
	push	r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	mov	r13, rdx
	push	r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	mov	r12d, ecx
	push	rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	mov	rbp, rsi
	push	rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	sub	rsp, 24
	.cfi_def_cfa_offset 80
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR 8[rsp], rax
	xor	eax, eax
	call	sd_fat_get_device_data@PLT
	test	rax, rax
	je	.L17
	mov	QWORD PTR 32[rbp], rax
	mov	rbx, rax
	mov	eax, r12d
	and	eax, 3
	cmp	eax, DWORD PTR O_RDONLY[rip]
	mov	DWORD PTR 0[rbp], r12d
	je	.L18
	cmp	eax, DWORD PTR O_WRONLY[rip]
	je	.L19
	cmp	eax, DWORD PTR O_RDWR[rip]
	jne	.L7
	and	r12d, DWORD PTR O_APPEND[rip]
	lea	r15, .LC1[rip]
	movabs	rax, 4294967297
	lea	rcx, .LC4[rip]
	mov	QWORD PTR 4[rbp], rax
	mov	DWORD PTR 12[rbp], r12d
	cmove	r15, rcx
.L5:
	mov	edi, DWORD PTR [rbx]
	mov	DWORD PTR [rsp], -1
	call	OSLockMutex@PLT
	mov	rsi, rbx
	mov	rdi, r13
	call	sd_fat_real_path@PLT
	mov	r12, rax
	test	r13, r13
	je	.L20
	mov	edi, DWORD PTR 8[rbx]
	mov	esi, DWORD PTR 4[rbx]
	mov	r9d, -1
	mov	r8, rsp
	mov	rcx, r15
	mov	rdx, rax
	call	FSOpenFile@PLT
	mov	rdi, r12
	mov	r13d, eax
	call	free@PLT
	test	r13d, r13d
	jne	.L9
	mov	esi, DWORD PTR 4[rbx]
	mov	edi, DWORD PTR 8[rbx]
	lea	rcx, 4[rsp]
	mov	r8d, -1
	mov	edx, DWORD PTR [rsp]
	call	FSGetStatFile@PLT
	mov	r12d, eax
	test	eax, eax
	je	.L10
	mov	esi, DWORD PTR 4[rbx]
	mov	edi, DWORD PTR 8[rbx]
	mov	ecx, -1
	mov	edx, DWORD PTR [rsp]
	call	FSCloseFile@PLT
	mov	DWORD PTR [r14], r12d
	mov	edi, DWORD PTR [rbx]
	call	OSUnlockMutex@PLT
	mov	eax, -1
.L1:
	mov	rdx, QWORD PTR 8[rsp]
	xor	rdx, QWORD PTR fs:40
	jne	.L21
	add	rsp, 24
	.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
.L19:
	.cfi_restore_state
	and	r12d, DWORD PTR O_APPEND[rip]
	lea	r15, .LC3[rip]
	movabs	rax, 4294967296
	lea	rcx, .LC2[rip]
	mov	QWORD PTR 4[rbp], rax
	mov	DWORD PTR 12[rbp], r12d
	cmove	r15, rcx
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L10:
	mov	eax, DWORD PTR [rsp]
	mov	edi, DWORD PTR [rbx]
	mov	QWORD PTR 24[rbp], 0
	mov	DWORD PTR 16[rbp], eax
	mov	eax, DWORD PTR 4[rsp]
	mov	DWORD PTR 20[rbp], eax
	call	OSUnlockMutex@PLT
	mov	eax, ebp
	jmp	.L1
	.p2align 4,,10
	.p2align 3
.L18:
	mov	DWORD PTR 4[rbp], 1
	lea	r15, .LC0[rip]
	mov	QWORD PTR 8[rbp], 0
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L9:
	mov	DWORD PTR [r14], r13d
	mov	edi, DWORD PTR [rbx]
	call	OSUnlockMutex@PLT
	mov	eax, -1
	jmp	.L1
.L7:
	mov	eax, DWORD PTR EACCES[rip]
	mov	DWORD PTR [r14], eax
	mov	eax, -1
	jmp	.L1
.L17:
	mov	eax, DWORD PTR ENODEV[rip]
	mov	DWORD PTR [r14], eax
	mov	eax, -1
	jmp	.L1
.L20:
	mov	eax, DWORD PTR ENOMEM[rip]
	mov	edi, DWORD PTR [rbx]
	mov	DWORD PTR [r14], eax
	call	OSUnlockMutex@PLT
	mov	eax, -1
	jmp	.L1
.L21:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE0:
	.size	sd_fat_open_r, .-sd_fat_open_r
	.comm	O_WRONLY,4,4
	.comm	O_RDWR,4,4
	.comm	O_RDONLY,4,4
	.comm	O_APPEND,4,4
	.comm	ENOMEM,4,4
	.comm	ENODEV,4,4
	.comm	EACCES,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_sd_fat_devoptab.c_sd_fat_open_r.c"
	.text
	.section	.rodata.str1.4,"aMS",%progbits,1
	.align	2
.LC0:
	.ascii	"r\000"
	.align	2
.LC1:
	.ascii	"a+\000"
	.align	2
.LC2:
	.ascii	"w\000"
	.align	2
.LC3:
	.ascii	"a\000"
	.align	2
.LC4:
	.ascii	"r+\000"
	.section	.rodata.cst4,"aM",%progbits,4
	.align	2
.LC5:
	.word	__stack_chk_guard
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	sd_fat_open_r, %function
sd_fat_open_r:
	@ args = 4, pretend = 0, frame = 16
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, lr}
	mov	r6, r3
	ldr	r3, .L22
	sub	sp, sp, #28
	mov	r9, r0
	mov	r0, r2
	mov	r7, r2
	mov	r5, r1
	ldr	r3, [r3]
	str	r3, [sp, #20]
	mov	r3,#0
	bl	sd_fat_get_device_data
	subs	r4, r0, #0
	beq	.L17
	ldr	r2, .L22+4
	and	r3, r6, #3
	ldr	r2, [r2]
	str	r4, [r5, #28]
	cmp	r3, r2
	str	r6, [r5]
	beq	.L18
	ldr	r2, .L22+8
	ldr	r2, [r2]
	cmp	r3, r2
	beq	.L19
	ldr	r2, .L22+12
	ldr	r2, [r2]
	cmp	r3, r2
	bne	.L7
	ldr	r3, .L22+16
	ldr	r1, .L22+20
	ldr	r3, [r3]
	mov	r2, #1
	and	r6, r6, r3
	ldr	r3, .L22+24
	cmp	r6, #0
	str	r6, [r5, #12]
	movne	r6, r1
	moveq	r6, r3
	str	r2, [r5, #4]
	str	r2, [r5, #8]
.L5:
	mvn	r8, #0
	ldr	r0, [r4]
	str	r8, [sp, #12]
	bl	OSLockMutex
	mov	r0, r7
	mov	r1, r4
	bl	sd_fat_real_path
	cmp	r7, #0
	mov	r7, r0
	beq	.L20
	add	r2, sp, #12
	mov	r3, r6
	ldr	r1, [r4, #4]
	ldr	r0, [r4, #8]
	stm	sp, {r2, r8}
	mov	r2, r7
	bl	FSOpenFile
	mov	r6, r0
	mov	r0, r7
	bl	free
	cmp	r6, #0
	bne	.L9
	ldr	r1, [r4, #4]
	ldr	r0, [r4, #8]
	ldr	r2, [sp, #12]
	str	r8, [sp]
	add	r3, sp, #16
	bl	FSGetStatFile
	subs	r6, r0, #0
	beq	.L10
	mov	r3, r8
	ldr	r2, [sp, #12]
	ldr	r1, [r4, #4]
	ldr	r0, [r4, #8]
	bl	FSCloseFile
	ldr	r0, [r4]
	str	r6, [r9]
	bl	OSUnlockMutex
	mov	r0, r8
.L1:
	ldr	r3, .L22
	ldr	r2, [r3]
	ldr	r3, [sp, #20]
	eors	r2, r3, r2
	mov	r3, #0
	bne	.L21
	add	sp, sp, #28
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, pc}
.L19:
	mov	r1, #0
	mov	r2, #1
	ldr	r3, .L22+16
	ldr	r0, .L22+28
	ldr	r3, [r3]
	str	r1, [r5, #4]
	and	r3, r3, r6
	ldr	r1, .L22+32
	cmp	r3, #0
	movne	r6, r0
	moveq	r6, r1
	str	r3, [r5, #12]
	str	r2, [r5, #8]
	b	.L5
.L10:
	ldr	r2, [sp, #12]
	ldr	r3, [sp, #16]
	ldr	r0, [r4]
	str	r6, [r5, #24]
	str	r2, [r5, #16]
	str	r3, [r5, #20]
	bl	OSUnlockMutex
	mov	r0, r5
	b	.L1
.L18:
	mov	r3, #0
	mov	r2, #1
	ldr	r6, .L22+36
	stmib	r5, {r2, r3}
	str	r3, [r5, #12]
	b	.L5
.L9:
	ldr	r0, [r4]
	str	r6, [r9]
	bl	OSUnlockMutex
	mov	r0, r8
	b	.L1
.L7:
	ldr	r3, .L22+40
	mvn	r0, #0
	ldr	r3, [r3]
	str	r3, [r9]
	b	.L1
.L17:
	ldr	r3, .L22+44
	mvn	r0, #0
	ldr	r3, [r3]
	str	r3, [r9]
	b	.L1
.L20:
	ldr	r3, .L22+48
	ldr	r0, [r4]
	ldr	r3, [r3]
	str	r3, [r9]
	bl	OSUnlockMutex
	mov	r0, r8
	b	.L1
.L21:
	bl	__stack_chk_fail
.L23:
	.align	2
.L22:
	.word	.LC5
	.word	O_RDONLY
	.word	O_WRONLY
	.word	O_RDWR
	.word	O_APPEND
	.word	.LC1
	.word	.LC4
	.word	.LC3
	.word	.LC2
	.word	.LC0
	.word	EACCES
	.word	ENODEV
	.word	ENOMEM
	.size	sd_fat_open_r, .-sd_fat_open_r
	.comm	O_WRONLY,4,4
	.comm	O_RDWR,4,4
	.comm	O_RDONLY,4,4
	.comm	O_APPEND,4,4
	.comm	ENOMEM,4,4
	.comm	ENODEV,4,4
	.comm	EACCES,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
