	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function ivtvfb_init_io
_ivtvfb_init_io:                        ## @ivtvfb_init_io
	.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	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r12
	movq	16(%rdi), %r14
	leaq	8(%rdi), %rbx
	movq	%rbx, %rdi
	callq	_mutex_lock
	movq	%r12, %rdi
	callq	_ivtv_init_on_first_open
	movq	%rax, %r15
	movq	%rbx, %rdi
	callq	_mutex_unlock
	testq	%r15, %r15
	je	LBB0_2
## %bb.1:
	leaq	L_.str(%rip), %rdi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_IVTVFB_ERR
	movq	_ENXIO@GOTPCREL(%rip), %rax
	jmp	LBB0_10
LBB0_2:
	leaq	4(%r14), %r15
	movq	%r12, %rdi
	movq	%r14, %rsi
	movq	%r15, %rdx
	callq	_ivtvfb_get_framebuffer
	testq	%rax, %rax
	js	LBB0_7
## %bb.3:
	movl	$1704960, 4(%r14)               ## imm = 0x1A0400
	movq	_IVTV_DECODER_OFFSET@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	addl	(%r12), %eax
	movl	(%r14), %edx
	addl	%edx, %eax
	movl	%eax, 8(%r14)
	addl	4(%r12), %edx
	movl	%edx, 12(%r14)
	je	LBB0_8
## %bb.4:
	leaq	L_.str.3(%rip), %rdi
	movl	%eax, %esi
	movl	$1665, %ecx                     ## imm = 0x681
	callq	_IVTVFB_INFO
	movl	(%r15), %esi
	movl	$33, %ecx
	.p2align	4, 0x90
LBB0_5:                                 ## =>This Inner Loop Header: Depth=1
	leal	-2(%rcx), %eax
	movzbl	%al, %eax
	decl	%ecx
	btl	%eax, %esi
	jae	LBB0_5
## %bb.6:
	movl	8(%r14), %edi
	movl	$-1, %eax
                                        ## kill: def $cl killed $cl killed $rcx
	shll	%cl, %eax
	movl	%eax, %ecx
	notl	%ecx
	addl	%ecx, %esi
	addl	%edi, %esi
	andl	%eax, %edi
	movl	%edi, 16(%r14)
	andl	%eax, %esi
	movl	%esi, 20(%r14)
	subl	%edi, %esi
	callq	_arch_phys_wc_add
	movl	%eax, 24(%r14)
	movl	4(%r14), %edx
	movl	12(%r14), %edi
	xorl	%ebx, %ebx
	xorl	%esi, %esi
	callq	_memset_io
	jmp	LBB0_11
LBB0_7:
	leaq	L_.str.1(%rip), %rdi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_IVTVFB_ERR
	jmp	LBB0_9
LBB0_8:
	leaq	L_.str.2(%rip), %rdi
	xorl	%ebx, %ebx
	movl	$1704960, %esi                  ## imm = 0x1A0400
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	_IVTVFB_ERR
LBB0_9:
	movq	_EIO@GOTPCREL(%rip), %rax
LBB0_10:
	subl	(%rax), %ebx
LBB0_11:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Failed to initialize ivtv\n"

	.comm	_ENXIO,4,2                      ## @ENXIO
L_.str.1:                               ## @.str.1
	.asciz	"Firmware failed to respond\n"

	.comm	_EIO,4,2                        ## @EIO
	.comm	_IVTV_DECODER_OFFSET,4,2        ## @IVTV_DECODER_OFFSET
L_.str.2:                               ## @.str.2
	.asciz	"abort, video memory 0x%x @ 0x%lx isn't mapped!\n"

L_.str.3:                               ## @.str.3
	.asciz	"Framebuffer at 0x%lx, mapped to 0x%p, size %dk\n"

	.no_dead_strip	_ivtvfb_init_io
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function ivtvfb_init_io
_ivtvfb_init_io:                        ; @ivtvfb_init_io
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #64
	.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
	mov	x20, x0
	ldr	x19, [x0, #16]
	add	x21, x0, #8
	mov	x0, x21
	bl	_mutex_lock
	mov	x0, x20
	bl	_ivtv_init_on_first_open
	mov	x22, x0
	mov	x0, x21
	bl	_mutex_unlock
	cbz	x22, LBB0_2
; %bb.1:
Lloh0:
	adrp	x0, l_.str@PAGE
Lloh1:
	add	x0, x0, l_.str@PAGEOFF
	bl	_IVTVFB_ERR
Lloh2:
	adrp	x8, _ENXIO@GOTPAGE
Lloh3:
	ldr	x8, [x8, _ENXIO@GOTPAGEOFF]
	b	LBB0_10
LBB0_2:
	add	x21, x19, #4
	mov	x0, x20
	mov	x1, x19
	mov	x2, x21
	bl	_ivtvfb_get_framebuffer
	tbnz	x0, #63, LBB0_7
; %bb.3:
	mov	w8, #1024
	movk	w8, #26, lsl #16
Lloh4:
	adrp	x9, _IVTV_DECODER_OFFSET@GOTPAGE
Lloh5:
	ldr	x9, [x9, _IVTV_DECODER_OFFSET@GOTPAGEOFF]
Lloh6:
	ldr	w9, [x9]
	ldr	w10, [x19]
	ldp	w11, w12, [x20]
	add	w9, w9, w11
	add	w1, w9, w10
	stp	w8, w1, [x19, #4]
	adds	w2, w12, w10
	str	w2, [x19, #12]
	b.eq	LBB0_8
; %bb.4:
Lloh7:
	adrp	x0, l_.str.3@PAGE
Lloh8:
	add	x0, x0, l_.str.3@PAGEOFF
                                        ; kill: def $w1 killed $w1 killed $x1
	mov	w3, #1665
	bl	_IVTVFB_INFO
	ldr	w8, [x21]
	mov	w9, #33
LBB0_5:                                 ; =>This Inner Loop Header: Depth=1
	sub	w10, w9, #2
	sub	w9, w9, #1
	lsr	w10, w8, w10
	tbz	w10, #0, LBB0_5
; %bb.6:
	ldr	w10, [x19, #8]
	mov	w11, #-1
	lsl	w9, w11, w9
	mvn	w11, w9
	and	w0, w10, w9
	add	w8, w8, w11
	add	w8, w8, w10
	and	w8, w8, w9
	stp	w0, w8, [x19, #16]
	sub	w1, w8, w0
	bl	_arch_phys_wc_add
	str	w0, [x19, #24]
	ldr	w0, [x19, #12]
	ldr	w2, [x19, #4]
	mov	w1, #0
	bl	_memset_io
	mov	w0, #0
	b	LBB0_11
LBB0_7:
Lloh9:
	adrp	x0, l_.str.1@PAGE
Lloh10:
	add	x0, x0, l_.str.1@PAGEOFF
	b	LBB0_9
LBB0_8:
	stp	x8, x1, [sp]
Lloh11:
	adrp	x0, l_.str.2@PAGE
Lloh12:
	add	x0, x0, l_.str.2@PAGEOFF
LBB0_9:
	bl	_IVTVFB_ERR
Lloh13:
	adrp	x8, _EIO@GOTPAGE
Lloh14:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
LBB0_10:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_11:
	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
	add	sp, sp, #64
	ret
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpAdd	Lloh9, Lloh10
	.loh AdrpAdd	Lloh11, Lloh12
	.loh AdrpLdrGot	Lloh13, Lloh14
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Failed to initialize ivtv\n"

	.comm	_ENXIO,4,2                      ; @ENXIO
l_.str.1:                               ; @.str.1
	.asciz	"Firmware failed to respond\n"

	.comm	_EIO,4,2                        ; @EIO
	.comm	_IVTV_DECODER_OFFSET,4,2        ; @IVTV_DECODER_OFFSET
l_.str.2:                               ; @.str.2
	.asciz	"abort, video memory 0x%x @ 0x%lx isn't mapped!\n"

l_.str.3:                               ; @.str.3
	.asciz	"Framebuffer at 0x%lx, mapped to 0x%p, size %dk\n"

	.no_dead_strip	_ivtvfb_init_io
.subsections_via_symbols
