	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function bram_save
_bram_save:                             ## @bram_save
	.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
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	_scd@GOTPCREL(%rip), %r12
	movq	24(%r12), %rsi
	xorl	%edi, %edi
	movl	$8192, %edx                     ## imm = 0x2000
	callq	_crc32
	movq	_brm_crc@GOTPCREL(%rip), %rbx
	movq	(%rbx), %rcx
	cmpq	(%rcx), %rax
	je	LBB0_5
## %bb.1:
	movl	$8160, %edi                     ## imm = 0x1FE0
	addq	24(%r12), %rdi
	movq	_brm_format@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	addq	$32, %rsi
	movl	$32, %edx
	callq	_memcmp
	testl	%eax, %eax
	je	LBB0_2
LBB0_5:
	cmpq	$0, 16(%r12)
	je	LBB0_15
## %bb.6:
	movq	8(%r12), %rsi
	movl	(%r12), %edx
	incl	%edx
	xorl	%edi, %edi
	callq	_crc32
	movq	(%rbx), %rcx
	cmpq	8(%rcx), %rax
	je	LBB0_15
## %bb.7:
	movq	8(%r12), %rax
	movslq	(%r12), %rcx
	leaq	(%rax,%rcx), %rdi
	addq	$-31, %rdi
	movq	_brm_format@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	addq	$32, %rsi
	movl	$32, %edx
	callq	_memcmp
	testl	%eax, %eax
	jne	LBB0_15
## %bb.8:
	movq	_CART_BRAM@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	leaq	L_.str(%rip), %rsi
	callq	_fopen
	testq	%rax, %rax
	je	LBB0_15
## %bb.9:
	movq	%rax, %r14
	movl	(%r12), %eax
	leal	1(%rax), %r15d
	movq	_CHUNKSIZE@GOTPCREL(%rip), %r13
	movl	(%r13), %esi
	xorl	%ebx, %ebx
	cmpl	%esi, %eax
	jl	LBB0_12
	.p2align	4, 0x90
LBB0_10:                                ## =>This Inner Loop Header: Depth=1
	movslq	%ebx, %rbx
	movq	8(%r12), %rdi
	addq	%rbx, %rdi
	movl	$1, %edx
	movq	%r14, %rcx
	callq	_fwrite
	movl	(%r13), %esi
	addl	%esi, %ebx
	subl	%esi, %r15d
	cmpl	%esi, %r15d
	jg	LBB0_10
## %bb.11:
	movslq	%ebx, %rbx
LBB0_12:
	testl	%r15d, %r15d
	je	LBB0_14
## %bb.13:
	addq	8(%r12), %rbx
	movq	%rbx, %rdi
	movl	%r15d, %esi
	movl	$1, %edx
	movq	%r14, %rcx
	callq	_fwrite
LBB0_14:
	movq	%r14, %rdi
	callq	_fclose
	movq	8(%r12), %rsi
	movl	(%r12), %edx
	incl	%edx
	xorl	%edi, %edi
	callq	_crc32
	movq	_brm_crc@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movq	%rax, 8(%rcx)
	jmp	LBB0_15
LBB0_2:
	movq	_region_code@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	addl	$-128, %eax
	cmpl	$2, %eax
	ja	LBB0_15
## %bb.3:
	cltq
	leaq	l_switch.table.bram_save(%rip), %rcx
	movq	(%rcx,%rax,8), %rax
	movl	(%rax), %edi
	leaq	L_.str(%rip), %rsi
	callq	_fopen
	testq	%rax, %rax
	je	LBB0_5
## %bb.4:
	movq	%rax, %r14
	movq	24(%r12), %rdi
	movl	$8192, %esi                     ## imm = 0x2000
	movl	$1, %edx
	movq	%rax, %rcx
	callq	_fwrite
	movq	%r14, %rdi
	callq	_fclose
	movq	24(%r12), %rsi
	xorl	%edi, %edi
	movl	$8192, %edx                     ## imm = 0x2000
	callq	_crc32
	movq	(%rbx), %rcx
	movq	%rax, (%rcx)
	jmp	LBB0_5
LBB0_15:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_scd,32,3                       ## @scd
	.comm	_brm_crc,8,3                    ## @brm_crc
	.comm	_brm_format,8,3                 ## @brm_format
	.comm	_region_code,4,2                ## @region_code
	.comm	_CD_BRAM_JP,4,2                 ## @CD_BRAM_JP
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"wb"

	.comm	_CD_BRAM_EU,4,2                 ## @CD_BRAM_EU
	.comm	_CD_BRAM_US,4,2                 ## @CD_BRAM_US
	.comm	_CART_BRAM,4,2                  ## @CART_BRAM
	.comm	_CHUNKSIZE,4,2                  ## @CHUNKSIZE
	.no_dead_strip	_bram_save
	.section	__DATA,__const
	.p2align	3                               ## @switch.table.bram_save
l_switch.table.bram_save:
	.quad	_CD_BRAM_US
	.quad	_CD_BRAM_JP
	.quad	_CD_BRAM_EU

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function bram_save
_bram_save:                             ; @bram_save
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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
Lloh0:
	adrp	x21, _scd@GOTPAGE
Lloh1:
	ldr	x21, [x21, _scd@GOTPAGEOFF]
	ldr	x1, [x21, #24]
	mov	w0, #0
	mov	w2, #8192
	bl	_crc32
Lloh2:
	adrp	x22, _brm_crc@GOTPAGE
Lloh3:
	ldr	x22, [x22, _brm_crc@GOTPAGEOFF]
	ldr	x8, [x22]
	ldr	x8, [x8]
	cmp	x0, x8
	b.eq	LBB0_2
; %bb.1:
	ldr	x8, [x21, #24]
	mov	w9, #8160
	add	x0, x8, x9
Lloh4:
	adrp	x8, _brm_format@GOTPAGE
Lloh5:
	ldr	x8, [x8, _brm_format@GOTPAGEOFF]
Lloh6:
	ldr	x8, [x8]
	add	x1, x8, #32
	mov	w2, #32
	bl	_memcmp
	cbz	w0, LBB0_8
LBB0_2:
	ldr	x8, [x21, #16]
	cbz	x8, LBB0_17
; %bb.3:
	ldr	x1, [x21, #8]
	ldr	w8, [x21]
	add	w2, w8, #1
	mov	w0, #0
	bl	_crc32
	ldr	x8, [x22]
	ldr	x8, [x8, #8]
	cmp	x0, x8
	b.eq	LBB0_17
; %bb.4:
	ldr	x8, [x21, #8]
	ldrsw	x9, [x21]
	add	x8, x8, x9
	sub	x0, x8, #31
Lloh7:
	adrp	x8, _brm_format@GOTPAGE
Lloh8:
	ldr	x8, [x8, _brm_format@GOTPAGEOFF]
Lloh9:
	ldr	x8, [x8]
	add	x1, x8, #32
	mov	w2, #32
	bl	_memcmp
	cbnz	w0, LBB0_17
; %bb.5:
Lloh10:
	adrp	x8, _CART_BRAM@GOTPAGE
Lloh11:
	ldr	x8, [x8, _CART_BRAM@GOTPAGEOFF]
Lloh12:
	ldr	w0, [x8]
Lloh13:
	adrp	x1, l_.str@PAGE
Lloh14:
	add	x1, x1, l_.str@PAGEOFF
	bl	_fopen
	cbz	x0, LBB0_17
; %bb.6:
	mov	x19, x0
	ldr	w8, [x21]
	add	w20, w8, #1
Lloh15:
	adrp	x23, _CHUNKSIZE@GOTPAGE
Lloh16:
	ldr	x23, [x23, _CHUNKSIZE@GOTPAGEOFF]
	ldr	w1, [x23]
	cmp	w8, w1
	b.ge	LBB0_11
; %bb.7:
	mov	x8, #0
	b	LBB0_14
LBB0_8:
Lloh17:
	adrp	x8, _region_code@GOTPAGE
Lloh18:
	ldr	x8, [x8, _region_code@GOTPAGEOFF]
Lloh19:
	ldr	w8, [x8]
	sub	w8, w8, #128
	cmp	w8, #2
	b.hi	LBB0_17
; %bb.9:
Lloh20:
	adrp	x9, l_switch.table.bram_save@PAGE
Lloh21:
	add	x9, x9, l_switch.table.bram_save@PAGEOFF
	ldr	x8, [x9, w8, sxtw #3]
	ldr	w0, [x8]
Lloh22:
	adrp	x1, l_.str@PAGE
Lloh23:
	add	x1, x1, l_.str@PAGEOFF
	bl	_fopen
	cbz	x0, LBB0_2
; %bb.10:
	mov	x19, x0
	ldr	x0, [x21, #24]
	mov	w1, #8192
	mov	w2, #1
	mov	x3, x19
	bl	_fwrite
	mov	x0, x19
	bl	_fclose
	ldr	x1, [x21, #24]
	mov	w0, #0
	mov	w2, #8192
	bl	_crc32
	ldr	x8, [x22]
	str	x0, [x8]
	b	LBB0_2
LBB0_11:
	mov	w24, #0
LBB0_12:                                ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x21, #8]
	add	x0, x8, w24, sxtw
	mov	w2, #1
	mov	x3, x19
	bl	_fwrite
	ldr	w1, [x23]
	add	w24, w1, w24
	sub	w20, w20, w1
	cmp	w20, w1
	b.gt	LBB0_12
; %bb.13:
	sxtw	x8, w24
LBB0_14:
	cbz	w20, LBB0_16
; %bb.15:
	ldr	x9, [x21, #8]
	add	x0, x9, x8
	mov	x1, x20
	mov	w2, #1
	mov	x3, x19
	bl	_fwrite
LBB0_16:
	mov	x0, x19
	bl	_fclose
	ldr	x1, [x21, #8]
	ldr	w8, [x21]
	add	w2, w8, #1
	mov	w0, #0
	bl	_crc32
	ldr	x8, [x22]
	str	x0, [x8, #8]
LBB0_17:
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpAdd	Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGot	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpAdd	Lloh22, Lloh23
	.loh AdrpAdd	Lloh20, Lloh21
	.cfi_endproc
                                        ; -- End function
	.comm	_scd,32,3                       ; @scd
	.comm	_brm_crc,8,3                    ; @brm_crc
	.comm	_brm_format,8,3                 ; @brm_format
	.comm	_region_code,4,2                ; @region_code
	.comm	_CD_BRAM_JP,4,2                 ; @CD_BRAM_JP
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"wb"

	.comm	_CD_BRAM_EU,4,2                 ; @CD_BRAM_EU
	.comm	_CD_BRAM_US,4,2                 ; @CD_BRAM_US
	.comm	_CART_BRAM,4,2                  ; @CART_BRAM
	.comm	_CHUNKSIZE,4,2                  ; @CHUNKSIZE
	.no_dead_strip	_bram_save
	.section	__DATA,__const
	.p2align	3                               ; @switch.table.bram_save
l_switch.table.bram_save:
	.quad	_CD_BRAM_US
	.quad	_CD_BRAM_JP
	.quad	_CD_BRAM_EU

.subsections_via_symbols
