	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function cobalt_buf_init
_cobalt_buf_init:                       ## @cobalt_buf_init
	.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	%rdi, %rbx
	movq	(%rdi), %rax
	movq	%rax, -80(%rbp)                 ## 8-byte Spill
	movq	8(%rdi), %rax
	movq	(%rax), %r14
	movq	32(%r14), %rax
	movq	%rax, -72(%rbp)                 ## 8-byte Spill
	movq	40(%r14), %rax
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	movq	_COBALT_MAX_WIDTH@GOTPCREL(%rip), %rcx
	movq	_COBALT_MAX_BPP@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	imull	(%rcx), %eax
	movq	_PAGE_SIZE@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	cltd
	idivl	%ecx
	addl	$2, %eax
	movslq	%eax, %r12
	movq	_COBALT_MAX_HEIGHT@GOTPCREL(%rip), %rax
	imulq	(%rax), %r12
	xorl	%r15d, %r15d
	movl	$7680, %eax                     ## imm = 0x1E00
	xorl	%edx, %edx
	idivl	%ecx
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	xorl	%esi, %esi
	callq	_vb2_dma_sg_plane_desc
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	movl	4(%r14), %r13d
	imull	(%r14), %r13d
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	_vb2_plane_size
	cmpl	%r13d, %eax
	jae	LBB0_2
## %bb.1:
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	_vb2_plane_size
	leaq	L_.str(%rip), %rdi
	movl	%eax, %esi
	movl	%r13d, %edx
	callq	_cobalt_info
	movq	_EINVAL@GOTPCREL(%rip), %rax
LBB0_8:
	subl	(%rax), %r15d
	jmp	LBB0_9
LBB0_2:
	movl	-44(%rbp), %eax                 ## 4-byte Reload
	movq	-80(%rbp), %rcx                 ## 8-byte Reload
	shlq	$4, %rcx
	movq	-72(%rbp), %rdx                 ## 8-byte Reload
	leaq	(%rdx,%rcx), %rbx
	cmpq	$0, (%rbx)
	movq	-64(%rbp), %r15                 ## 8-byte Reload
	jne	LBB0_4
## %bb.3:
	shlq	$5, %r12
	shll	$5, %eax
	addl	$32, %eax
	movslq	%eax, %rsi
	movq	(%r15), %rax
	movq	%rax, 8(%rdx,%rcx)
	cmpq	$0, 24(%r14)
	cmoveq	%r12, %rsi
	movq	%rbx, %rdi
	callq	_descriptor_list_allocate
	cmpq	$0, (%rbx)
	je	LBB0_7
LBB0_4:
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %ecx
	movl	4(%rax), %esi
	xorl	%edx, %edx
	cmpl	$0, 16(%r14)
	sete	%dl
	movl	(%r14), %eax
	movl	12(%r14), %r9d
	imull	8(%r14), %r9d
	movq	%r15, %rdi
	movl	%r13d, %r8d
	pushq	%rbx
	pushq	%rax
	callq	_descriptor_list_create
	addq	$16, %rsp
	testl	%eax, %eax
	je	LBB0_6
## %bb.5:
	movl	%eax, %r15d
	movq	%rbx, %rdi
	callq	_descriptor_list_free
	jmp	LBB0_9
LBB0_6:
	xorl	%r15d, %r15d
LBB0_9:
	movl	%r15d, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_7:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%r15d, %r15d
	jmp	LBB0_8
	.cfi_endproc
                                        ## -- End function
	.comm	_COBALT_MAX_WIDTH,4,2           ## @COBALT_MAX_WIDTH
	.comm	_COBALT_MAX_BPP,4,2             ## @COBALT_MAX_BPP
	.comm	_PAGE_SIZE,4,2                  ## @PAGE_SIZE
	.comm	_COBALT_MAX_HEIGHT,8,3          ## @COBALT_MAX_HEIGHT
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"data will not fit into plane (%lu < %u)\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.no_dead_strip	_cobalt_buf_init
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function cobalt_buf_init
_cobalt_buf_init:                       ; @cobalt_buf_init
	.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, x0
	ldp	x9, x8, [x0]
	str	x9, [sp, #8]                    ; 8-byte Folded Spill
	ldr	x23, [x8]
Lloh0:
	adrp	x8, _COBALT_MAX_WIDTH@GOTPAGE
Lloh1:
	ldr	x8, [x8, _COBALT_MAX_WIDTH@GOTPAGEOFF]
Lloh2:
	ldr	w20, [x8]
Lloh3:
	adrp	x8, _COBALT_MAX_BPP@GOTPAGE
Lloh4:
	ldr	x8, [x8, _COBALT_MAX_BPP@GOTPAGEOFF]
Lloh5:
	ldr	w26, [x8]
Lloh6:
	adrp	x8, _PAGE_SIZE@GOTPAGE
Lloh7:
	ldr	x8, [x8, _PAGE_SIZE@GOTPAGEOFF]
Lloh8:
	ldr	w22, [x8]
Lloh9:
	adrp	x8, _COBALT_MAX_HEIGHT@GOTPAGE
Lloh10:
	ldr	x8, [x8, _COBALT_MAX_HEIGHT@GOTPAGEOFF]
Lloh11:
	ldr	x28, [x8]
	ldp	x19, x25, [x23, #32]
	mov	w1, #0
	bl	_vb2_dma_sg_plane_desc
	mov	x24, x0
	ldp	w8, w9, [x23]
	mul	w27, w9, w8
	mov	x0, x21
	mov	w1, #0
	bl	_vb2_plane_size
	cmp	w0, w27
	b.hs	LBB0_3
; %bb.1:
	mov	x0, x21
	mov	w1, #0
	bl	_vb2_plane_size
	mov	x1, x0
Lloh12:
	adrp	x0, l_.str@PAGE
Lloh13:
	add	x0, x0, l_.str@PAGEOFF
	mov	x2, x27
	bl	_cobalt_info
Lloh14:
	adrp	x8, _EINVAL@GOTPAGE
Lloh15:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
LBB0_2:
	ldr	w8, [x8]
	neg	w19, w8
	b	LBB0_7
LBB0_3:
	str	x25, [sp]                       ; 8-byte Folded Spill
	ldr	x25, [sp, #8]                   ; 8-byte Folded Reload
	add	x21, x19, x25, lsl #4
	ldr	x8, [x21]
	cbnz	x8, LBB0_5
; %bb.4:
	mul	w8, w26, w20
	sdiv	w8, w8, w22
	add	w8, w8, #2
	sxtw	x8, w8
	mul	x8, x28, x8
	lsl	x8, x8, #5
	mov	w9, #7680
	sdiv	w9, w9, w22
	lsl	w9, w9, #5
	add	w9, w9, #32
	sxtw	x9, w9
	ldr	x10, [sp]                       ; 8-byte Folded Reload
	ldr	x10, [x10]
	add	x11, x19, x25, lsl #4
	str	x10, [x11, #8]
	ldr	x10, [x23, #24]
	cmp	x10, #0
	csel	x1, x8, x9, eq
	mov	x0, x21
	bl	_descriptor_list_allocate
	ldr	x8, [x21]
	cbz	x8, LBB0_8
LBB0_5:
	ldp	w9, w8, [x23, #12]
	cmp	w8, #0
	cset	w2, eq
	ldp	w3, w1, [x24]
	ldr	w8, [x23, #8]
	mul	w5, w9, w8
	ldr	w6, [x23]
	ldr	x0, [sp]                        ; 8-byte Folded Reload
	mov	x4, x27
	mov	x7, x21
	bl	_descriptor_list_create
	mov	x19, x0
	cbz	w0, LBB0_7
; %bb.6:
	mov	x0, x21
	bl	_descriptor_list_free
LBB0_7:
	mov	x0, x19
	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_8:
Lloh16:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh17:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
	b	LBB0_2
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh16, Lloh17
	.cfi_endproc
                                        ; -- End function
	.comm	_COBALT_MAX_WIDTH,4,2           ; @COBALT_MAX_WIDTH
	.comm	_COBALT_MAX_BPP,4,2             ; @COBALT_MAX_BPP
	.comm	_PAGE_SIZE,4,2                  ; @PAGE_SIZE
	.comm	_COBALT_MAX_HEIGHT,8,3          ; @COBALT_MAX_HEIGHT
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"data will not fit into plane (%lu < %u)\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.no_dead_strip	_cobalt_buf_init
.subsections_via_symbols
