	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function sd_fat_open_r
_sd_fat_open_r:                         ## @sd_fat_open_r
	.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
	subq	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%ecx, %ebx
	movq	%rdx, %r12
	movq	%rsi, %r15
	movq	%rdi, %r14
	movq	%rdx, %rdi
	callq	_sd_fat_get_device_data
	testq	%rax, %rax
	je	LBB0_1
## %bb.3:
	movq	%rax, %r13
	movq	%rax, 32(%r15)
	movl	%ebx, (%r15)
	movl	%ebx, %eax
	andl	$3, %eax
	movq	_O_RDONLY@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jne	LBB0_5
## %bb.4:
	movq	%r14, -56(%rbp)                 ## 8-byte Spill
	movq	$1, 4(%r15)
	movl	$0, 12(%r15)
	leaq	L_.str(%rip), %rbx
	jmp	LBB0_10
LBB0_1:
	movq	_ENODEV@GOTPCREL(%rip), %rax
LBB0_2:
	movl	(%rax), %eax
	movl	%eax, (%r14)
	movl	$-1, %r12d
	jmp	LBB0_18
LBB0_5:
	movq	_O_WRONLY@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jne	LBB0_7
## %bb.6:
	movq	%r14, -56(%rbp)                 ## 8-byte Spill
	movabsq	$4294967296, %rax               ## imm = 0x100000000
	movq	%rax, 4(%r15)
	movq	_O_APPEND@GOTPCREL(%rip), %rax
	andl	(%rax), %ebx
	movl	%ebx, 12(%r15)
	leaq	L_.str.2(%rip), %rax
	leaq	L_.str.1(%rip), %rbx
	jmp	LBB0_9
LBB0_7:
	movq	_O_RDWR@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jne	LBB0_19
## %bb.8:
	movq	%r14, -56(%rbp)                 ## 8-byte Spill
	movabsq	$4294967297, %rax               ## imm = 0x100000001
	movq	%rax, 4(%r15)
	movq	_O_APPEND@GOTPCREL(%rip), %rax
	andl	(%rax), %ebx
	movl	%ebx, 12(%r15)
	leaq	L_.str.4(%rip), %rax
	leaq	L_.str.3(%rip), %rbx
LBB0_9:
	cmoveq	%rax, %rbx
LBB0_10:
	movl	$-1, -44(%rbp)
	movl	(%r13), %edi
	callq	_OSLockMutex
	movq	%r12, %rdi
	movq	%r13, %rsi
	callq	_sd_fat_real_path
	testq	%r12, %r12
	je	LBB0_11
## %bb.12:
	movq	%rax, %r14
	movl	4(%r13), %esi
	movl	8(%r13), %edi
	leaq	-44(%rbp), %r8
	movl	$-1, %r12d
	movq	%rax, %rdx
	movq	%rbx, %rcx
	movl	$-1, %r9d
	callq	_FSOpenFile
	movl	%eax, %ebx
	movq	%r14, %rdi
	callq	_free
	testl	%ebx, %ebx
	je	LBB0_13
## %bb.16:
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movl	%ebx, (%rax)
	jmp	LBB0_17
LBB0_11:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movq	-56(%rbp), %rcx                 ## 8-byte Reload
	movl	%eax, (%rcx)
	movl	(%r13), %edi
	callq	_OSUnlockMutex
	movl	$-1, %r12d
	jmp	LBB0_18
LBB0_13:
	movl	4(%r13), %esi
	movl	8(%r13), %edi
	movl	-44(%rbp), %edx
	leaq	-64(%rbp), %rcx
	movl	$-1, %r8d
	callq	_FSGetStatFile
	testl	%eax, %eax
	movq	-56(%rbp), %r14                 ## 8-byte Reload
	je	LBB0_15
## %bb.14:
	movl	%eax, %ebx
	movl	4(%r13), %esi
	movl	8(%r13), %edi
	movl	-44(%rbp), %edx
	movl	$-1, %r12d
	movl	$-1, %ecx
	callq	_FSCloseFile
	movl	%ebx, (%r14)
LBB0_17:
	movl	(%r13), %edi
	callq	_OSUnlockMutex
LBB0_18:
	movl	%r12d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_19:
	movq	_EACCES@GOTPCREL(%rip), %rax
	jmp	LBB0_2
LBB0_15:
	movl	-44(%rbp), %eax
	movl	%eax, 16(%r15)
	movq	$0, 24(%r15)
	movl	-64(%rbp), %eax
	movl	%eax, 20(%r15)
	movl	(%r13), %edi
	callq	_OSUnlockMutex
	movl	%r15d, %r12d
	jmp	LBB0_18
	.cfi_endproc
                                        ## -- End function
	.comm	_ENODEV,4,2                     ## @ENODEV
	.comm	_O_RDONLY,4,2                   ## @O_RDONLY
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"r"

	.comm	_O_WRONLY,4,2                   ## @O_WRONLY
	.comm	_O_APPEND,4,2                   ## @O_APPEND
L_.str.1:                               ## @.str.1
	.asciz	"a"

L_.str.2:                               ## @.str.2
	.asciz	"w"

	.comm	_O_RDWR,4,2                     ## @O_RDWR
L_.str.3:                               ## @.str.3
	.asciz	"a+"

L_.str.4:                               ## @.str.4
	.asciz	"r+"

	.comm	_EACCES,4,2                     ## @EACCES
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.no_dead_strip	_sd_fat_open_r
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.section	__TEXT,__literal8,8byte_literals
	.p2align	3                               ; -- Begin function sd_fat_open_r
lCPI0_0:
	.long	0                               ; 0x0
	.long	1                               ; 0x1
lCPI0_1:
	.long	1                               ; 0x1
	.long	0                               ; 0x0
	.section	__TEXT,__text,regular,pure_instructions
	.p2align	2
_sd_fat_open_r:                         ; @sd_fat_open_r
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	mov	x23, x3
	mov	x22, x2
	mov	x19, x1
	mov	x20, x0
	mov	x0, x2
	bl	_sd_fat_get_device_data
	cbz	x0, LBB0_3
; %bb.1:
	mov	x21, x0
	str	x0, [x19, #32]
	str	w23, [x19]
	and	w8, w23, #0x3
Lloh0:
	adrp	x9, _O_RDONLY@GOTPAGE
Lloh1:
	ldr	x9, [x9, _O_RDONLY@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x9]
	cmp	w8, w9
	b.ne	LBB0_5
; %bb.2:
Lloh3:
	adrp	x8, lCPI0_1@PAGE
Lloh4:
	ldr	d0, [x8, lCPI0_1@PAGEOFF]
	stur	d0, [x19, #4]
	str	wzr, [x19, #12]
Lloh5:
	adrp	x23, l_.str@PAGE
Lloh6:
	add	x23, x23, l_.str@PAGEOFF
	b	LBB0_10
LBB0_3:
Lloh7:
	adrp	x8, _ENODEV@GOTPAGE
Lloh8:
	ldr	x8, [x8, _ENODEV@GOTPAGEOFF]
LBB0_4:
	ldr	w8, [x8]
	str	w8, [x20]
	b	LBB0_15
LBB0_5:
Lloh9:
	adrp	x9, _O_WRONLY@GOTPAGE
Lloh10:
	ldr	x9, [x9, _O_WRONLY@GOTPAGEOFF]
Lloh11:
	ldr	w9, [x9]
	cmp	w8, w9
	b.ne	LBB0_7
; %bb.6:
Lloh12:
	adrp	x8, lCPI0_0@PAGE
Lloh13:
	ldr	d0, [x8, lCPI0_0@PAGEOFF]
	stur	d0, [x19, #4]
Lloh14:
	adrp	x8, _O_APPEND@GOTPAGE
Lloh15:
	ldr	x8, [x8, _O_APPEND@GOTPAGEOFF]
Lloh16:
	ldr	w8, [x8]
	ands	w8, w8, w23
	str	w8, [x19, #12]
Lloh17:
	adrp	x8, l_.str.1@PAGE
Lloh18:
	add	x8, x8, l_.str.1@PAGEOFF
Lloh19:
	adrp	x9, l_.str.2@PAGE
Lloh20:
	add	x9, x9, l_.str.2@PAGEOFF
	b	LBB0_9
LBB0_7:
Lloh21:
	adrp	x9, _O_RDWR@GOTPAGE
Lloh22:
	ldr	x9, [x9, _O_RDWR@GOTPAGEOFF]
Lloh23:
	ldr	w9, [x9]
	cmp	w8, w9
	b.ne	LBB0_19
; %bb.8:
	movi.2s	v0, #1
	stur	d0, [x19, #4]
Lloh24:
	adrp	x8, _O_APPEND@GOTPAGE
Lloh25:
	ldr	x8, [x8, _O_APPEND@GOTPAGEOFF]
Lloh26:
	ldr	w8, [x8]
	ands	w8, w8, w23
	str	w8, [x19, #12]
Lloh27:
	adrp	x8, l_.str.3@PAGE
Lloh28:
	add	x8, x8, l_.str.3@PAGEOFF
Lloh29:
	adrp	x9, l_.str.4@PAGE
Lloh30:
	add	x9, x9, l_.str.4@PAGEOFF
LBB0_9:
	csel	x23, x9, x8, eq
LBB0_10:
	mov	w8, #-1
	str	w8, [sp, #12]
	ldr	w0, [x21]
	bl	_OSLockMutex
	mov	x0, x22
	mov	x1, x21
	bl	_sd_fat_real_path
	cbz	x22, LBB0_13
; %bb.11:
	mov	x24, x0
	ldp	w1, w0, [x21, #4]
	add	x4, sp, #12
	mov	x2, x24
	mov	x3, x23
	mov	w5, #-1
	bl	_FSOpenFile
	mov	x22, x0
	mov	x0, x24
	bl	_free
	cbz	w22, LBB0_17
; %bb.12:
	str	w22, [x20]
	b	LBB0_14
LBB0_13:
Lloh31:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh32:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh33:
	ldr	w8, [x8]
	str	w8, [x20]
LBB0_14:
	ldr	w0, [x21]
	bl	_OSUnlockMutex
LBB0_15:
	mov	w19, #-1
LBB0_16:
	mov	x0, x19
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #80
	ret
LBB0_17:
	ldp	w1, w0, [x21, #4]
	ldr	w2, [sp, #12]
	add	x3, sp, #8
	mov	w4, #-1
	bl	_FSGetStatFile
	cbz	w0, LBB0_20
; %bb.18:
	mov	x22, x0
	ldp	w1, w0, [x21, #4]
	ldr	w2, [sp, #12]
	mov	w19, #-1
	mov	w3, #-1
	bl	_FSCloseFile
	str	w22, [x20]
	b	LBB0_21
LBB0_19:
Lloh34:
	adrp	x8, _EACCES@GOTPAGE
Lloh35:
	ldr	x8, [x8, _EACCES@GOTPAGEOFF]
	b	LBB0_4
LBB0_20:
	ldp	w9, w8, [sp, #8]
	str	xzr, [x19, #24]
	stp	w8, w9, [x19, #16]
LBB0_21:
	ldr	w0, [x21]
	bl	_OSUnlockMutex
	b	LBB0_16
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpLdr	Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpAdd	Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpAdrp	Lloh12, Lloh14
	.loh AdrpLdr	Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpAdd	Lloh29, Lloh30
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh31, Lloh32, Lloh33
	.loh AdrpLdrGot	Lloh34, Lloh35
	.cfi_endproc
                                        ; -- End function
	.comm	_ENODEV,4,2                     ; @ENODEV
	.comm	_O_RDONLY,4,2                   ; @O_RDONLY
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"r"

	.comm	_O_WRONLY,4,2                   ; @O_WRONLY
	.comm	_O_APPEND,4,2                   ; @O_APPEND
l_.str.1:                               ; @.str.1
	.asciz	"a"

l_.str.2:                               ; @.str.2
	.asciz	"w"

	.comm	_O_RDWR,4,2                     ; @O_RDWR
l_.str.3:                               ; @.str.3
	.asciz	"a+"

l_.str.4:                               ; @.str.4
	.asciz	"r+"

	.comm	_EACCES,4,2                     ; @EACCES
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.no_dead_strip	_sd_fat_open_r
.subsections_via_symbols
