	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_chdstream_open                 ## -- Begin function chdstream_open
	.p2align	4, 0x90
_chdstream_open:                        ## @chdstream_open
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r14
	pushq	%rbx
	subq	$48, %rsp
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	movl	%esi, %r14d
	movq	$0, -24(%rbp)
	movq	_CHD_OPEN_READ@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	xorl	%ebx, %ebx
	leaq	-24(%rbp), %rcx
	xorl	%edx, %edx
	callq	_chd_open
	movq	_CHDERR_NONE@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_3
## %bb.1:
	movq	-24(%rbp), %rdi
	leaq	-64(%rbp), %rdx
	movl	%r14d, %esi
	callq	_chdstream_find_track
	testl	%eax, %eax
	je	LBB0_2
## %bb.6:
	movl	$1, %edi
	movl	$80, %esi
	callq	_calloc
	testq	%rax, %rax
	je	LBB0_2
## %bb.7:
	movq	%rax, %rbx
	movq	-24(%rbp), %rdi
	callq	_chd_get_header
	movq	%rax, %r14
	movl	(%rax), %edi
	callq	_malloc
	movq	%rax, 72(%rbx)
	testq	%rax, %rax
	je	LBB0_3
## %bb.8:
	movl	-32(%rbp), %edi
	leaq	L_.str(%rip), %rsi
	callq	_strcmp
	testl	%eax, %eax
	je	LBB0_9
## %bb.10:
	movl	-32(%rbp), %edi
	leaq	L_.str.1(%rip), %rsi
	callq	_strcmp
	testl	%eax, %eax
	je	LBB0_9
## %bb.11:
	movl	-32(%rbp), %edi
	leaq	L_.str.2(%rip), %rsi
	callq	_strcmp
	testl	%eax, %eax
	je	LBB0_12
## %bb.13:
	movl	4(%r14), %eax
	jmp	LBB0_14
LBB0_2:
	xorl	%ebx, %ebx
LBB0_3:
	movq	%rbx, %rdi
	callq	_chdstream_close
	movq	-24(%rbp), %rdi
	testq	%rdi, %rdi
	je	LBB0_5
## %bb.4:
	callq	_chd_close
LBB0_5:
	xorl	%ebx, %ebx
LBB0_19:
	movq	%rbx, %rax
	addq	$48, %rsp
	popq	%rbx
	popq	%r14
	popq	%rbp
	retq
LBB0_9:
	movq	_SECTOR_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
LBB0_14:
	movl	%eax, (%rbx)
	movq	$0, 64(%rbx)
LBB0_15:
	movl	-32(%rbp), %edi
	movq	-64(%rbp), %rsi
	callq	_strcmp
	testl	%eax, %eax
	jne	LBB0_16
## %bb.17:
	movq	-40(%rbp), %rcx
	jmp	LBB0_18
LBB0_16:
	xorl	%ecx, %ecx
LBB0_18:
	movq	-24(%rbp), %rax
	movq	%rax, 56(%rbx)
	movl	(%r14), %eax
	cltd
	idivl	4(%r14)
	movl	%eax, 8(%rbx)
	movl	-48(%rbp), %eax
	movl	%eax, 48(%rbx)
	movslq	(%rbx), %rax
	imulq	%rax, %rcx
	movq	%rcx, 16(%rbx)
	imulq	-56(%rbp), %rax
	addq	%rcx, %rax
	movq	%rax, 24(%rbx)
	movq	$0, 40(%rbx)
	movl	$-1, 32(%rbx)
	jmp	LBB0_19
LBB0_12:
	movq	_SECTOR_SIZE@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, (%rbx)
	movq	$0, 64(%rbx)
	movl	$1, 4(%rbx)
	jmp	LBB0_15
	.cfi_endproc
                                        ## -- End function
	.comm	_CHD_OPEN_READ,4,2              ## @CHD_OPEN_READ
	.comm	_CHDERR_NONE,8,3                ## @CHDERR_NONE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"MODE1_RAW"

	.comm	_SECTOR_SIZE,8,3                ## @SECTOR_SIZE
L_.str.1:                               ## @.str.1
	.asciz	"MODE2_RAW"

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

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_chdstream_open                 ; -- Begin function chdstream_open
	.p2align	2
_chdstream_open:                        ; @chdstream_open
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	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
	mov	x20, x1
	str	xzr, [sp]
Lloh0:
	adrp	x8, _CHD_OPEN_READ@GOTPAGE
Lloh1:
	ldr	x8, [x8, _CHD_OPEN_READ@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	mov	x3, sp
	mov	x2, #0
	bl	_chd_open
	mov	x19, #0
Lloh3:
	adrp	x8, _CHDERR_NONE@GOTPAGE
Lloh4:
	ldr	x8, [x8, _CHDERR_NONE@GOTPAGEOFF]
Lloh5:
	ldr	x8, [x8]
	cmp	x0, x8
	b.ne	LBB0_9
; %bb.1:
	ldr	x0, [sp]
	add	x2, sp, #8
	mov	x1, x20
	bl	_chdstream_find_track
	cbz	w0, LBB0_8
; %bb.2:
	mov	w0, #1
	mov	w1, #80
	bl	_calloc
	mov	x19, x0
	cbz	x0, LBB0_9
; %bb.3:
	ldr	x0, [sp]
	bl	_chd_get_header
	mov	x20, x0
	ldr	w0, [x0]
	bl	_malloc
	str	x0, [x19, #72]
	cbz	x0, LBB0_9
; %bb.4:
	ldr	w0, [sp, #40]
Lloh6:
	adrp	x1, l_.str@PAGE
Lloh7:
	add	x1, x1, l_.str@PAGEOFF
	bl	_strcmp
	cbz	w0, LBB0_13
; %bb.5:
	ldr	w0, [sp, #40]
Lloh8:
	adrp	x1, l_.str.1@PAGE
Lloh9:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_strcmp
	cbz	w0, LBB0_13
; %bb.6:
	ldr	w0, [sp, #40]
Lloh10:
	adrp	x1, l_.str.2@PAGE
Lloh11:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_strcmp
	cbz	w0, LBB0_16
; %bb.7:
	ldr	w8, [x20, #4]
	str	w8, [x19]
	b	LBB0_14
LBB0_8:
	mov	x19, #0
LBB0_9:
	mov	x0, x19
	bl	_chdstream_close
	ldr	x0, [sp]
	cbz	x0, LBB0_11
; %bb.10:
	bl	_chd_close
LBB0_11:
	mov	x19, #0
LBB0_12:
	mov	x0, x19
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	add	sp, sp, #80
	ret
LBB0_13:
Lloh12:
	adrp	x8, _SECTOR_SIZE@GOTPAGE
Lloh13:
	ldr	x8, [x8, _SECTOR_SIZE@GOTPAGEOFF]
Lloh14:
	ldr	x8, [x8]
	str	w8, [x19]
LBB0_14:
	str	xzr, [x19, #64]
LBB0_15:
	ldr	w0, [sp, #40]
	ldr	x1, [sp, #8]
	bl	_strcmp
	ldr	x8, [sp, #32]
	cmp	w0, #0
	csel	x8, x8, xzr, eq
	ldr	x9, [sp]
	str	x9, [x19, #56]
	ldp	w9, w10, [x20]
	sdiv	w9, w9, w10
	str	w9, [x19, #8]
	ldr	w9, [sp, #24]
	str	w9, [x19, #48]
	ldrsw	x9, [x19]
	mul	x8, x8, x9
	ldr	x10, [sp, #16]
	madd	x9, x10, x9, x8
	stp	x8, x9, [x19, #16]
	str	xzr, [x19, #40]
	mov	w8, #-1
	str	w8, [x19, #32]
	b	LBB0_12
LBB0_16:
Lloh15:
	adrp	x8, _SECTOR_SIZE@GOTPAGE
Lloh16:
	ldr	x8, [x8, _SECTOR_SIZE@GOTPAGEOFF]
Lloh17:
	ldr	x8, [x8]
	str	xzr, [x19, #64]
	mov	w9, #1
	stp	w8, w9, [x19]
	b	LBB0_15
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.cfi_endproc
                                        ; -- End function
	.comm	_CHD_OPEN_READ,4,2              ; @CHD_OPEN_READ
	.comm	_CHDERR_NONE,8,3                ; @CHDERR_NONE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"MODE1_RAW"

	.comm	_SECTOR_SIZE,8,3                ; @SECTOR_SIZE
l_.str.1:                               ; @.str.1
	.asciz	"MODE2_RAW"

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

.subsections_via_symbols
