	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_chdstream_read                 ## -- Begin function chdstream_read
	.p2align	4, 0x90
_chdstream_read:                        ## @chdstream_read
	.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	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdx, %rbx
	movq	%rsi, %r14
	movq	%rdi, %r13
	movl	64(%rdi), %edi
	callq	_chd_get_header
	movq	%rax, -72(%rbp)                 ## 8-byte Spill
	movq	(%r13), %rax
	movq	8(%r13), %rcx
	subq	%rcx, %rax
	cmpq	%rbx, %rax
	cmovaeq	%rbx, %rax
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	leaq	(%rax,%rcx), %rbx
	cmpq	%rcx, %rbx
	jbe	LBB0_17
## %bb.1:
	xorl	%r15d, %r15d
	movq	%r14, -64(%rbp)                 ## 8-byte Spill
	movq	%rbx, -80(%rbp)                 ## 8-byte Spill
	jmp	LBB0_2
	.p2align	4, 0x90
LBB0_6:                                 ##   in Loop: Header=BB0_2 Depth=1
	leaq	(%r14,%r15,4), %rdi
	xorl	%esi, %esi
	movq	%rbx, %rdx
	callq	_memset
LBB0_16:                                ##   in Loop: Header=BB0_2 Depth=1
	addq	%rbx, %r15
	addq	8(%r13), %rbx
	movq	%rbx, 8(%r13)
	movq	%rbx, %rcx
	movq	-80(%rbp), %rax                 ## 8-byte Reload
	cmpq	%rbx, %rax
	movq	%rax, %rbx
	jbe	LBB0_17
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	movq	16(%r13), %rsi
	movq	%rcx, %rax
	orq	%rsi, %rax
	shrq	$32, %rax
	je	LBB0_3
## %bb.4:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	%rcx, %rax
	xorl	%edx, %edx
	divq	%rsi
	movq	%rdx, %r12
	jmp	LBB0_5
	.p2align	4, 0x90
LBB0_3:                                 ##   in Loop: Header=BB0_2 Depth=1
	movl	%ecx, %eax
	xorl	%edx, %edx
	divl	%esi
	movl	%edx, %r12d
LBB0_5:                                 ##   in Loop: Header=BB0_2 Depth=1
	movq	%rsi, %rax
	subq	%r12, %rax
	subq	%rcx, %rbx
	cmpq	%rbx, %rax
	cmovbq	%rax, %rbx
	subq	24(%r13), %rcx
	jb	LBB0_6
## %bb.7:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	56(%r13), %rdi
	movq	%rcx, %rax
	orq	%rsi, %rax
	shrq	$32, %rax
	je	LBB0_8
## %bb.9:                               ##   in Loop: Header=BB0_2 Depth=1
	movq	%rcx, %rax
	xorl	%edx, %edx
	divq	%rsi
	jmp	LBB0_10
LBB0_8:                                 ##   in Loop: Header=BB0_2 Depth=1
	movl	%ecx, %eax
	xorl	%edx, %edx
	divl	%esi
                                        ## kill: def $eax killed $eax def $rax
LBB0_10:                                ##   in Loop: Header=BB0_2 Depth=1
	addq	%rdi, %rax
	movq	32(%r13), %rcx
	movq	%rax, %rdx
	orq	%rcx, %rdx
	shrq	$32, %rdx
	je	LBB0_11
## %bb.12:                              ##   in Loop: Header=BB0_2 Depth=1
	xorl	%edx, %edx
	divq	%rcx
	movq	%rdx, -48(%rbp)                 ## 8-byte Spill
	jmp	LBB0_13
LBB0_11:                                ##   in Loop: Header=BB0_2 Depth=1
                                        ## kill: def $eax killed $eax killed $rax
	xorl	%edx, %edx
	divl	%ecx
                                        ## kill: def $edx killed $edx def $rdx
	movq	%rdx, -48(%rbp)                 ## 8-byte Spill
                                        ## kill: def $eax killed $eax def $rax
LBB0_13:                                ##   in Loop: Header=BB0_2 Depth=1
	movq	-72(%rbp), %rcx                 ## 8-byte Reload
	movq	(%rcx), %r14
	movq	%r13, %rdi
	movq	%rax, %rsi
	callq	_chdstream_load_hunk
	testl	%eax, %eax
	je	LBB0_14
## %bb.15:                              ##   in Loop: Header=BB0_2 Depth=1
	movq	-48(%rbp), %rax                 ## 8-byte Reload
	imulq	%r14, %rax
	addq	48(%r13), %r12
	movq	-64(%rbp), %r14                 ## 8-byte Reload
	leaq	(%r14,%r15,4), %rdi
	addq	%rax, %r12
	addq	40(%r13), %r12
	movq	%r12, %rsi
	movq	%rbx, %rdx
	callq	_memcpy
	jmp	LBB0_16
LBB0_17:
	movq	-56(%rbp), %rax                 ## 8-byte Reload
LBB0_18:
                                        ## kill: def $eax killed $eax killed $rax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_14:
	movl	$-1, %eax
	jmp	LBB0_18
	.cfi_endproc
                                        ## -- End function
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_chdstream_read                 ; -- Begin function chdstream_read
	.p2align	2
_chdstream_read:                        ; @chdstream_read
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x21, x2
	mov	x19, x1
	mov	x20, x0
	ldr	w0, [x0, #64]
	bl	_chd_get_header
	ldp	x9, x8, [x20]
	sub	x9, x9, x8
	cmp	x9, x21
	csel	x9, x9, x21, lo
	stp	x9, x0, [sp]                    ; 16-byte Folded Spill
	add	x25, x9, x8
	cmp	x25, x8
	b.ls	LBB0_7
; %bb.1:
	mov	x26, #0
	b	LBB0_4
LBB0_2:                                 ;   in Loop: Header=BB0_4 Depth=1
	add	x0, x19, x26, lsl #2
	mov	w1, #0
	mov	x2, x23
	bl	_memset
LBB0_3:                                 ;   in Loop: Header=BB0_4 Depth=1
	add	x26, x23, x26
	ldr	x8, [x20, #8]
	add	x8, x8, x23
	cmp	x25, x8
	str	x8, [x20, #8]
	b.ls	LBB0_7
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	ldp	x9, x10, [x20, #16]
	udiv	x11, x8, x9
	msub	x27, x11, x9, x8
	sub	x11, x9, x27
	sub	x12, x25, x8
	cmp	x11, x12
	csel	x23, x11, x12, lo
	subs	x8, x8, x10
	b.lo	LBB0_2
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	x10, [x20, #56]
	udiv	x8, x8, x9
	add	x21, x8, x10
	ldr	x22, [x20, #32]
	ldr	x8, [sp, #8]                    ; 8-byte Folded Reload
	ldr	x28, [x8]
	udiv	x24, x21, x22
	mov	x0, x20
	mov	x1, x24
	bl	_chdstream_load_hunk
	cbz	w0, LBB0_9
; %bb.6:                                ;   in Loop: Header=BB0_4 Depth=1
	msub	x8, x24, x22, x21
	add	x0, x19, x26, lsl #2
	ldp	x10, x9, [x20, #40]
	add	x9, x9, x27
	madd	x8, x8, x28, x9
	add	x1, x8, x10
	mov	x2, x23
	bl	_memcpy
	b	LBB0_3
LBB0_7:
	ldr	x0, [sp]                        ; 8-byte Folded Reload
LBB0_8:
                                        ; kill: def $w0 killed $w0 killed $x0
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_9:
	mov	w0, #-1
	b	LBB0_8
	.cfi_endproc
                                        ; -- End function
.subsections_via_symbols
