	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ivtv_stream_alloc              ## -- Begin function ivtv_stream_alloc
	.p2align	4, 0x90
_ivtv_stream_alloc:                     ## @ivtv_stream_alloc
	.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
	movl	(%rdi), %ecx
	testl	%ecx, %ecx
	je	LBB0_1
## %bb.2:
	movq	%rdi, %r12
	movq	32(%rdi), %r14
	leal	(,%rcx,4), %r15d
	movq	8(%rdi), %rax
	movq	_PCI_DMA_NONE@GOTPCREL(%rip), %rdx
	cmpq	(%rdx), %rax
	leaq	L_.str.2(%rip), %rax
	leaq	L_.str.1(%rip), %rsi
	cmoveq	%rax, %rsi
	movl	20(%rdi), %edx
	movl	16(%rdi), %r8d
	movl	%r8d, %eax
	imull	%ecx, %eax
	leal	1023(%rax), %r9d
	testl	%eax, %eax
	cmovnsl	%eax, %r9d
	sarl	$10, %r9d
	leaq	L_.str(%rip), %rdi
                                        ## kill: def $ecx killed $ecx killed $rcx
	callq	_IVTV_DEBUG_INFO
	movq	_GFP_KERNEL@GOTPCREL(%rip), %r13
	movq	___GFP_NOWARN@GOTPCREL(%rip), %rbx
	movl	(%rbx), %esi
	orl	(%r13), %esi
	movl	%r15d, %edi
	callq	_kzalloc
	movq	%rax, 64(%r12)
	testq	%rax, %rax
	je	LBB0_3
## %bb.4:
	movq	$0, 80(%r12)
	movl	(%rbx), %esi
	orl	(%r13), %esi
	movl	%r15d, %edi
	callq	_kzalloc
	movq	%rax, 56(%r12)
	testq	%rax, %rax
	je	LBB0_5
## %bb.6:
	movq	$0, 72(%r12)
	movl	(%rbx), %esi
	orl	(%r13), %esi
	movl	$4, %edi
	callq	_kzalloc
	movq	%rax, 40(%r12)
	testq	%rax, %rax
	je	LBB0_7
## %bb.8:
	movq	%r12, %rdi
	callq	_ivtv_might_use_dma
	testq	%rax, %rax
	je	LBB0_10
## %bb.9:
	movl	(%r14), %edi
	movq	40(%r12), %rsi
	movq	_PCI_DMA_TODEVICE@GOTPCREL(%rip), %rax
	movq	(%rax), %rcx
	movl	$4, %edx
	callq	_pci_map_single
	movq	%rax, 48(%r12)
	movq	%r12, %rdi
	callq	_ivtv_stream_sync_for_cpu
LBB0_10:
	cmpl	$0, (%r12)
	movl	$0, %r13d
	jle	LBB0_18
## %bb.11:
	leaq	24(%r12), %rax
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	xorl	%r13d, %r13d
	jmp	LBB0_12
	.p2align	4, 0x90
LBB0_17:                                ##   in Loop: Header=BB0_12 Depth=1
	movq	%r12, %rdi
	movq	%r14, %rsi
	movq	-48(%rbp), %rdx                 ## 8-byte Reload
	callq	_ivtv_enqueue
	incl	%r13d
	cmpl	(%r12), %r13d
	movq	___GFP_NOWARN@GOTPCREL(%rip), %rbx
	jge	LBB0_18
LBB0_12:                                ## =>This Inner Loop Header: Depth=1
	movl	(%rbx), %esi
	movq	_GFP_KERNEL@GOTPCREL(%rip), %r15
	orl	(%r15), %esi
	movl	$24, %edi
	callq	_kzalloc
	testq	%rax, %rax
	je	LBB0_18
## %bb.13:                              ##   in Loop: Header=BB0_12 Depth=1
	movq	%rax, %r14
	movl	16(%r12), %edi
	movl	$256, %eax                      ## imm = 0x100
	addl	%eax, %edi
	movl	(%rbx), %esi
	orl	(%r15), %esi
	callq	_kmalloc
	movq	%rax, (%r14)
	testq	%rax, %rax
	je	LBB0_14
## %bb.15:                              ##   in Loop: Header=BB0_12 Depth=1
	movq	%r14, %rdi
	addq	$16, %rdi
	callq	_INIT_LIST_HEAD
	movq	%r12, %rdi
	callq	_ivtv_might_use_dma
	testq	%rax, %rax
	je	LBB0_17
## %bb.16:                              ##   in Loop: Header=BB0_12 Depth=1
	movq	8(%r12), %rcx
	movq	32(%r12), %rax
	movl	(%rax), %edi
	movq	(%r14), %rsi
	movl	16(%r12), %edx
	movl	$256, %eax                      ## imm = 0x100
	addl	%eax, %edx
	callq	_pci_map_single
	movq	%rax, 8(%r14)
	movq	%r12, %rdi
	movq	%r14, %rsi
	callq	_ivtv_buf_sync_for_cpu
	jmp	LBB0_17
LBB0_1:
	xorl	%eax, %eax
	jmp	LBB0_21
LBB0_3:
	movl	20(%r12), %esi
	leaq	L_.str.3(%rip), %rdi
	callq	_IVTV_ERR
	jmp	LBB0_20
LBB0_5:
	movl	20(%r12), %esi
	leaq	L_.str.4(%rip), %rdi
	callq	_IVTV_ERR
	movq	64(%r12), %rdi
	callq	_kfree
	movq	$0, 64(%r12)
	jmp	LBB0_20
LBB0_7:
	movl	20(%r12), %esi
	leaq	L_.str.5(%rip), %rdi
	callq	_IVTV_ERR
	movq	64(%r12), %rdi
	callq	_kfree
	movq	$0, 64(%r12)
	movq	56(%r12), %rdi
	callq	_kfree
	movq	$0, 56(%r12)
	jmp	LBB0_20
LBB0_14:
	movq	%r14, %rdi
	callq	_kfree
LBB0_18:
	cmpl	(%r12), %r13d
	movl	$0, %eax
	je	LBB0_21
## %bb.19:
	movl	20(%r12), %esi
	leaq	L_.str.6(%rip), %rdi
	callq	_IVTV_ERR
	movq	%r12, %rdi
	callq	_ivtv_stream_free
LBB0_20:
	movq	_ENOMEM@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
LBB0_21:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Allocate %s%s stream: %d x %d buffers (%dkB total)\n"

	.comm	_PCI_DMA_NONE,8,3               ## @PCI_DMA_NONE
L_.str.1:                               ## @.str.1
	.asciz	"DMA "

L_.str.2:                               ## @.str.2
	.space	1

	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	___GFP_NOWARN,4,2               ## @__GFP_NOWARN
L_.str.3:                               ## @.str.3
	.asciz	"Could not allocate sg_pending for %s stream\n"

	.comm	_ENOMEM,4,2                     ## @ENOMEM
L_.str.4:                               ## @.str.4
	.asciz	"Could not allocate sg_processing for %s stream\n"

L_.str.5:                               ## @.str.5
	.asciz	"Could not allocate sg_dma for %s stream\n"

	.comm	_PCI_DMA_TODEVICE,8,3           ## @PCI_DMA_TODEVICE
L_.str.6:                               ## @.str.6
	.asciz	"Couldn't allocate buffers for %s stream\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_ivtv_stream_alloc              ; -- Begin function ivtv_stream_alloc
	.p2align	2
_ivtv_stream_alloc:                     ; @ivtv_stream_alloc
	.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
	ldr	w3, [x0]
	cbz	w3, LBB0_19
; %bb.1:
	mov	x19, x0
	ldr	x21, [x0, #32]
	lsl	w20, w3, #2
	ldr	x8, [x0, #8]
Lloh0:
	adrp	x9, _PCI_DMA_NONE@GOTPAGE
Lloh1:
	ldr	x9, [x9, _PCI_DMA_NONE@GOTPAGEOFF]
Lloh2:
	adrp	x10, l_.str.1@PAGE
Lloh3:
	add	x10, x10, l_.str.1@PAGEOFF
Lloh4:
	ldr	x9, [x9]
Lloh5:
	adrp	x11, l_.str.2@PAGE
Lloh6:
	add	x11, x11, l_.str.2@PAGEOFF
	cmp	x8, x9
	csel	x1, x11, x10, eq
	ldp	w4, w2, [x0, #16]
	mul	w8, w4, w3
	add	w9, w8, #1023
	cmp	w8, #0
	csel	w8, w9, w8, lt
	asr	w5, w8, #10
Lloh7:
	adrp	x0, l_.str@PAGE
Lloh8:
	add	x0, x0, l_.str@PAGEOFF
	bl	_IVTV_DEBUG_INFO
Lloh9:
	adrp	x22, _GFP_KERNEL@GOTPAGE
Lloh10:
	ldr	x22, [x22, _GFP_KERNEL@GOTPAGEOFF]
	ldr	w8, [x22]
Lloh11:
	adrp	x23, ___GFP_NOWARN@GOTPAGE
Lloh12:
	ldr	x23, [x23, ___GFP_NOWARN@GOTPAGEOFF]
	ldr	w9, [x23]
	orr	w1, w9, w8
	mov	x0, x20
	bl	_kzalloc
	str	x0, [x19, #64]
	cbz	x0, LBB0_13
; %bb.2:
	str	xzr, [x19, #80]
	ldr	w8, [x22]
	ldr	w9, [x23]
	orr	w1, w9, w8
	mov	x0, x20
	bl	_kzalloc
	str	x0, [x19, #56]
	cbz	x0, LBB0_14
; %bb.3:
	str	xzr, [x19, #72]
	ldr	w8, [x22]
	ldr	w9, [x23]
	orr	w1, w9, w8
	mov	w0, #4
	bl	_kzalloc
	str	x0, [x19, #40]
	cbz	x0, LBB0_15
; %bb.4:
	mov	x0, x19
	bl	_ivtv_might_use_dma
	cbz	x0, LBB0_6
; %bb.5:
	ldr	w0, [x21]
	ldr	x1, [x19, #40]
Lloh13:
	adrp	x8, _PCI_DMA_TODEVICE@GOTPAGE
Lloh14:
	ldr	x8, [x8, _PCI_DMA_TODEVICE@GOTPAGEOFF]
Lloh15:
	ldr	x3, [x8]
	mov	w2, #4
	bl	_pci_map_single
	str	x0, [x19, #48]
	mov	x0, x19
	bl	_ivtv_stream_sync_for_cpu
LBB0_6:
	ldr	w8, [x19]
	cmp	w8, #1
	b.lt	LBB0_16
; %bb.7:
	mov	w24, #0
	add	x20, x19, #24
	b	LBB0_9
LBB0_8:                                 ;   in Loop: Header=BB0_9 Depth=1
	mov	x0, x19
	mov	x1, x21
	mov	x2, x20
	bl	_ivtv_enqueue
	add	w24, w24, #1
	ldr	w8, [x19]
	cmp	w24, w8
	b.ge	LBB0_18
LBB0_9:                                 ; =>This Inner Loop Header: Depth=1
	ldr	w8, [x22]
	ldr	w9, [x23]
	orr	w1, w9, w8
	mov	w0, #24
	bl	_kzalloc
	cbz	x0, LBB0_18
; %bb.10:                               ;   in Loop: Header=BB0_9 Depth=1
	mov	x21, x0
	ldr	w8, [x19, #16]
	add	w0, w8, #256
	ldr	w8, [x22]
	ldr	w9, [x23]
	orr	w1, w9, w8
	bl	_kmalloc
	str	x0, [x21]
	cbz	x0, LBB0_17
; %bb.11:                               ;   in Loop: Header=BB0_9 Depth=1
	add	x0, x21, #16
	bl	_INIT_LIST_HEAD
	mov	x0, x19
	bl	_ivtv_might_use_dma
	cbz	x0, LBB0_8
; %bb.12:                               ;   in Loop: Header=BB0_9 Depth=1
	ldr	x8, [x19, #32]
	ldr	w0, [x8]
	ldr	x1, [x21]
	ldr	w8, [x19, #16]
	add	w2, w8, #256
	ldr	x3, [x19, #8]
	bl	_pci_map_single
	str	x0, [x21, #8]
	mov	x0, x19
	mov	x1, x21
	bl	_ivtv_buf_sync_for_cpu
	b	LBB0_8
LBB0_13:
	ldr	w1, [x19, #20]
Lloh16:
	adrp	x0, l_.str.3@PAGE
Lloh17:
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_IVTV_ERR
	b	LBB0_21
LBB0_14:
	ldr	w1, [x19, #20]
Lloh18:
	adrp	x0, l_.str.4@PAGE
Lloh19:
	add	x0, x0, l_.str.4@PAGEOFF
	bl	_IVTV_ERR
	ldr	x0, [x19, #64]
	bl	_kfree
	str	xzr, [x19, #64]
	b	LBB0_21
LBB0_15:
	ldr	w1, [x19, #20]
Lloh20:
	adrp	x0, l_.str.5@PAGE
Lloh21:
	add	x0, x0, l_.str.5@PAGEOFF
	bl	_IVTV_ERR
	ldr	x0, [x19, #64]
	bl	_kfree
	str	xzr, [x19, #64]
	ldr	x0, [x19, #56]
	bl	_kfree
	str	xzr, [x19, #56]
	b	LBB0_21
LBB0_16:
	mov	w24, #0
	b	LBB0_18
LBB0_17:
	mov	x0, x21
	bl	_kfree
LBB0_18:
	ldr	w8, [x19]
	cmp	w24, w8
	b.ne	LBB0_20
LBB0_19:
	mov	w0, #0
	b	LBB0_22
LBB0_20:
	ldr	w1, [x19, #20]
Lloh22:
	adrp	x0, l_.str.6@PAGE
Lloh23:
	add	x0, x0, l_.str.6@PAGEOFF
	bl	_IVTV_ERR
	mov	x0, x19
	bl	_ivtv_stream_free
LBB0_21:
Lloh24:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh25:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh26:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_22:
	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	Lloh11, Lloh12
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh4
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpAdd	Lloh16, Lloh17
	.loh AdrpAdd	Lloh18, Lloh19
	.loh AdrpAdd	Lloh20, Lloh21
	.loh AdrpAdd	Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Allocate %s%s stream: %d x %d buffers (%dkB total)\n"

	.comm	_PCI_DMA_NONE,8,3               ; @PCI_DMA_NONE
l_.str.1:                               ; @.str.1
	.asciz	"DMA "

l_.str.2:                               ; @.str.2
	.space	1

	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	___GFP_NOWARN,4,2               ; @__GFP_NOWARN
l_.str.3:                               ; @.str.3
	.asciz	"Could not allocate sg_pending for %s stream\n"

	.comm	_ENOMEM,4,2                     ; @ENOMEM
l_.str.4:                               ; @.str.4
	.asciz	"Could not allocate sg_processing for %s stream\n"

l_.str.5:                               ; @.str.5
	.asciz	"Could not allocate sg_dma for %s stream\n"

	.comm	_PCI_DMA_TODEVICE,8,3           ; @PCI_DMA_TODEVICE
l_.str.6:                               ; @.str.6
	.asciz	"Couldn't allocate buffers for %s stream\n"

.subsections_via_symbols
