	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function ov518_mode_init_regs
_ov518_mode_init_regs:                  ## @ov518_mode_init_regs
	.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	%r8d, %r9d
	movl	%ecx, %r12d
	movl	%edx, %r15d
	movl	%esi, %r13d
	movq	%rdi, %r14
	testl	%r8d, %r8d
	je	LBB0_2
## %bb.1:
	movl	(%r14), %r13d
	movl	4(%r14), %r15d
LBB0_2:
	leaq	L_.str(%rip), %rsi
	movl	$3, %edi
	movl	%r13d, %edx
	movl	%r15d, %ecx
	movl	%r12d, %r8d
	callq	_PDEBUG
	movl	%r13d, %eax
	andl	$15, %eax
	movl	%r15d, %ecx
	andl	$7, %ecx
	orl	%eax, %ecx
	je	LBB0_5
## %bb.3:
	leaq	L_.str.1(%rip), %rdi
LBB0_4:
	xorl	%ebx, %ebx
	movl	%r13d, %esi
	movl	%r15d, %edx
	xorl	%eax, %eax
	callq	_err
	jmp	LBB0_8
LBB0_5:
	cmpl	8(%r14), %r13d
	jl	LBB0_7
## %bb.6:
	cmpl	12(%r14), %r15d
	jge	LBB0_11
LBB0_7:
	leaq	L_.str.2(%rip), %rdi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_err
LBB0_8:
	movq	_EINVAL@GOTPCREL(%rip), %rax
LBB0_9:
	subl	(%rax), %ebx
LBB0_10:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_11:
	cmpl	$320, %r13d                     ## imm = 0x140
	setge	%al
	cmpl	$240, %r15d
	setge	%cl
	cmpb	%al, %cl
	je	LBB0_13
## %bb.12:
	leaq	L_.str.3(%rip), %rdi
	jmp	LBB0_4
LBB0_13:
	movq	%r14, %rdi
	callq	_ov51x_stop
	testq	%rax, %rax
	js	LBB0_26
## %bb.14:
	movq	%r14, %rdi
	movl	$43, %esi
	xorl	%edx, %edx
	callq	_reg_w
	movq	%r14, %rdi
	movl	$44, %esi
	xorl	%edx, %edx
	callq	_reg_w
	movq	%r14, %rdi
	movl	$45, %esi
	xorl	%edx, %edx
	callq	_reg_w
	movq	%r14, %rdi
	movl	$46, %esi
	xorl	%edx, %edx
	callq	_reg_w
	movq	%r14, %rdi
	movl	$59, %esi
	xorl	%edx, %edx
	callq	_reg_w
	movq	%r14, %rdi
	movl	$60, %esi
	xorl	%edx, %edx
	callq	_reg_w
	movq	%r14, %rdi
	movl	$61, %esi
	xorl	%edx, %edx
	callq	_reg_w
	movq	%r14, %rdi
	movl	$62, %esi
	xorl	%edx, %edx
	callq	_reg_w
	movq	16(%r14), %rax
	movq	_BRG_OV518@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_18
## %bb.15:
	movq	_ov518_color@GOTPCREL(%rip), %rax
	cmpq	$0, (%rax)
	je	LBB0_18
## %bb.16:
	movq	%r14, %rdi
	movl	$21, %esi
	xorl	%edx, %edx
	movl	$1, %ecx
	callq	_i2c_w_mask
	movq	_VIDEO_PALETTE_GREY@GOTPCREL(%rip), %rax
	cmpl	%r12d, (%rax)
	jne	LBB0_19
## %bb.17:
	movq	%r14, %rdi
	movl	$32, %esi
	xorl	%edx, %edx
	movl	$8, %ecx
	callq	_reg_w_mask
	movq	%r14, %rdi
	movl	$40, %esi
	xorl	%edx, %edx
	movl	$240, %ecx
	callq	_reg_w_mask
	movq	%r14, %rdi
	movl	$56, %esi
	xorl	%edx, %edx
	jmp	LBB0_20
LBB0_18:
	movq	_VIDEO_PALETTE_GREY@GOTPCREL(%rip), %rbx
	xorl	%edx, %edx
	cmpl	%r12d, (%rbx)
	setne	%dl
	shll	$7, %edx
	movq	%r14, %rdi
	movl	$40, %esi
	callq	_reg_w
	xorl	%edx, %edx
	cmpl	%r12d, (%rbx)
	setne	%dl
	shll	$7, %edx
	movq	%r14, %rdi
	movl	$56, %esi
	callq	_reg_w
	jmp	LBB0_21
LBB0_19:
	movq	%r14, %rdi
	movl	$32, %esi
	movl	$8, %edx
	movl	$8, %ecx
	callq	_reg_w_mask
	movq	%r14, %rdi
	movl	$40, %esi
	movl	$128, %edx
	movl	$240, %ecx
	callq	_reg_w_mask
	movq	%r14, %rdi
	movl	$56, %esi
	movl	$128, %edx
LBB0_20:
	movl	$240, %ecx
	callq	_reg_w_mask
LBB0_21:
	leal	15(%r13), %ebx
	testl	%r13d, %r13d
	cmovnsl	%r13d, %ebx
	sarl	$4, %ebx
	leal	3(%r15), %r12d
	testl	%r15d, %r15d
	cmovnsl	%r15d, %r12d
	sarl	$2, %r12d
	movq	%r14, %rdi
	movl	$41, %esi
	movl	%ebx, %edx
	callq	_reg_w
	movq	%r14, %rdi
	movl	$42, %esi
	movl	%r12d, %edx
	callq	_reg_w
	movq	%r14, %rdi
	movl	$57, %esi
	movl	%ebx, %edx
	callq	_reg_w
	movq	%r14, %rdi
	movl	$58, %esi
	movl	%r12d, %edx
	callq	_reg_w
	movq	%r14, %rdi
	movl	$47, %esi
	movl	$128, %edx
	callq	_reg_w
	movq	%r14, %rdi
	movl	$81, %esi
	movl	$2, %edx
	callq	_reg_w
	movq	%r14, %rdi
	movl	$34, %esi
	movl	$24, %edx
	callq	_reg_w
	movq	%r14, %rdi
	movl	$35, %esi
	movl	$255, %edx
	callq	_reg_w
	movq	16(%r14), %rax
	movq	_BRG_OV518PLUS@GOTPCREL(%rip), %rbx
	cmpq	(%rbx), %rax
	movl	$33, %eax
	movl	$113, %esi
	cmovel	%eax, %esi
	movq	%r14, %rdi
	movl	$25, %edx
	callq	_reg_w
	movq	%r14, %rdi
	movl	$84, %esi
	movl	$35, %edx
	callq	_i2c_w
	movq	%r14, %rdi
	movl	$47, %esi
	movl	$128, %edx
	callq	_reg_w
	movq	16(%r14), %rax
	cmpq	(%rbx), %rax
	jne	LBB0_23
## %bb.22:
	movl	$2400, %r15d                    ## imm = 0x960
	movl	$108, %r12d
	movl	$540, %ebx                      ## imm = 0x21C
	movl	$148, %edx
	jmp	LBB0_24
LBB0_23:
	movl	$2000, %r15d                    ## imm = 0x7D0
	movl	$142, %r12d
	movl	$500, %ebx                      ## imm = 0x1F4
	movl	$159, %edx
LBB0_24:
	movq	%r14, %rdi
	movl	$36, %esi
	callq	_reg_w
	movq	%r14, %rdi
	movl	$37, %esi
	movl	$144, %edx
	callq	_reg_w
	movq	%r14, %rdi
	movl	$196, %esi
	movl	$400, %edx                      ## imm = 0x190
	movl	$2, %ecx
	callq	_ov518_reg_w32
	movq	%r14, %rdi
	movl	$198, %esi
	movl	%ebx, %edx
	movl	$2, %ecx
	callq	_ov518_reg_w32
	movq	%r14, %rdi
	movl	$199, %esi
	movl	%ebx, %edx
	movl	$2, %ecx
	callq	_ov518_reg_w32
	movq	%r14, %rdi
	movl	$200, %esi
	movl	%r12d, %edx
	movl	$2, %ecx
	callq	_ov518_reg_w32
	movq	%r14, %rdi
	movl	$202, %esi
	movl	$131098, %edx                   ## imm = 0x2001A
	movl	$3, %ecx
	callq	_ov518_reg_w32
	movq	%r14, %rdi
	movl	$203, %esi
	movl	$532, %edx                      ## imm = 0x214
	movl	$2, %ecx
	callq	_ov518_reg_w32
	movq	%r14, %rdi
	movl	$204, %esi
	movl	%r15d, %edx
	movl	$2, %ecx
	callq	_ov518_reg_w32
	movq	%r14, %rdi
	movl	$205, %esi
	movl	$32, %edx
	movl	$2, %ecx
	callq	_ov518_reg_w32
	movq	%r14, %rdi
	movl	$206, %esi
	movl	$608, %edx                      ## imm = 0x260
	movl	$2, %ecx
	callq	_ov518_reg_w32
	movq	%r14, %rdi
	movl	$47, %esi
	movl	$128, %edx
	callq	_reg_w
	movq	%r14, %rdi
	callq	_ov51x_restart
	testq	%rax, %rax
	js	LBB0_26
## %bb.25:
	movq	_OV511_RESET_NOREGS@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r14, %rdi
	callq	_ov51x_reset
	xorl	%ebx, %ebx
	testq	%rax, %rax
	jns	LBB0_10
LBB0_26:
	movq	_EIO@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	jmp	LBB0_9
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"width:%d, height:%d, mode:%d, sub:%d"

L_.str.1:                               ## @.str.1
	.asciz	"Invalid size (%d, %d)"

	.comm	_EINVAL,4,2                     ## @EINVAL
L_.str.2:                               ## @.str.2
	.asciz	"Requested dimensions are too small"

L_.str.3:                               ## @.str.3
	.asciz	"Invalid width/height combination (%d, %d)"

	.comm	_EIO,4,2                        ## @EIO
	.comm	_BRG_OV518,8,3                  ## @BRG_OV518
	.comm	_ov518_color,8,3                ## @ov518_color
	.comm	_VIDEO_PALETTE_GREY,4,2         ## @VIDEO_PALETTE_GREY
	.comm	_BRG_OV518PLUS,8,3              ## @BRG_OV518PLUS
	.comm	_OV511_RESET_NOREGS,4,2         ## @OV511_RESET_NOREGS
	.no_dead_strip	_ov518_mode_init_regs
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function ov518_mode_init_regs
_ov518_mode_init_regs:                  ; @ov518_mode_init_regs
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	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
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	mov	x5, x4
	mov	x22, x3
	mov	x21, x2
	mov	x20, x1
	mov	x19, x0
	cbz	w4, LBB0_2
; %bb.1:
	ldp	w20, w21, [x19]
LBB0_2:
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	mov	w0, #3
	mov	x2, x20
	mov	x3, x21
	mov	x4, x22
	bl	_PDEBUG
	and	w8, w20, #0xf
	and	w9, w21, #0x7
	orr	w8, w8, w9
	cbz	w8, LBB0_4
; %bb.3:
	stp	x20, x21, [sp]
Lloh2:
	adrp	x0, l_.str.1@PAGE
Lloh3:
	add	x0, x0, l_.str.1@PAGEOFF
	b	LBB0_7
LBB0_4:
	ldr	w8, [x19, #8]
	cmp	w20, w8
	b.lt	LBB0_6
; %bb.5:
	ldr	w8, [x19, #12]
	cmp	w21, w8
	b.ge	LBB0_10
LBB0_6:
Lloh4:
	adrp	x0, l_.str.2@PAGE
Lloh5:
	add	x0, x0, l_.str.2@PAGEOFF
LBB0_7:
	bl	_err
Lloh6:
	adrp	x8, _EINVAL@GOTPAGE
Lloh7:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
LBB0_8:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_9:
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #80
	ret
LBB0_10:
	cmp	w20, #319
	cset	w8, gt
	cmp	w21, #239
	cset	w9, gt
	cmp	w9, w8
	b.eq	LBB0_12
; %bb.11:
                                        ; kill: def $w21 killed $w21 killed $x21 def $x21
                                        ; kill: def $w20 killed $w20 killed $x20 def $x20
	stp	x20, x21, [sp]
Lloh8:
	adrp	x0, l_.str.3@PAGE
Lloh9:
	add	x0, x0, l_.str.3@PAGEOFF
	b	LBB0_7
LBB0_12:
	mov	x0, x19
	bl	_ov51x_stop
	tbnz	x0, #63, LBB0_26
; %bb.13:
	mov	x0, x19
	mov	w1, #43
	mov	w2, #0
	bl	_reg_w
	mov	x0, x19
	mov	w1, #44
	mov	w2, #0
	bl	_reg_w
	mov	x0, x19
	mov	w1, #45
	mov	w2, #0
	bl	_reg_w
	mov	x0, x19
	mov	w1, #46
	mov	w2, #0
	bl	_reg_w
	mov	x0, x19
	mov	w1, #59
	mov	w2, #0
	bl	_reg_w
	mov	x0, x19
	mov	w1, #60
	mov	w2, #0
	bl	_reg_w
	mov	x0, x19
	mov	w1, #61
	mov	w2, #0
	bl	_reg_w
	mov	x0, x19
	mov	w1, #62
	mov	w2, #0
	bl	_reg_w
	ldr	x8, [x19, #16]
Lloh10:
	adrp	x9, _BRG_OV518@GOTPAGE
Lloh11:
	ldr	x9, [x9, _BRG_OV518@GOTPAGEOFF]
Lloh12:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_17
; %bb.14:
Lloh13:
	adrp	x8, _ov518_color@GOTPAGE
Lloh14:
	ldr	x8, [x8, _ov518_color@GOTPAGEOFF]
Lloh15:
	ldr	x8, [x8]
	cbz	x8, LBB0_17
; %bb.15:
	mov	x0, x19
	mov	w1, #21
	mov	w2, #0
	mov	w3, #1
	bl	_i2c_w_mask
Lloh16:
	adrp	x8, _VIDEO_PALETTE_GREY@GOTPAGE
Lloh17:
	ldr	x8, [x8, _VIDEO_PALETTE_GREY@GOTPAGEOFF]
Lloh18:
	ldr	w8, [x8]
	mov	x0, x19
	mov	w1, #32
	cmp	w8, w22
	b.ne	LBB0_18
; %bb.16:
	mov	w2, #0
	mov	w3, #8
	bl	_reg_w_mask
	mov	x0, x19
	mov	w1, #40
	mov	w2, #0
	mov	w3, #240
	bl	_reg_w_mask
	mov	x0, x19
	mov	w1, #56
	mov	w2, #0
	b	LBB0_19
LBB0_17:
Lloh19:
	adrp	x23, _VIDEO_PALETTE_GREY@GOTPAGE
Lloh20:
	ldr	x23, [x23, _VIDEO_PALETTE_GREY@GOTPAGEOFF]
	ldr	w8, [x23]
	cmp	w8, w22
	cset	w8, ne
	lsl	w2, w8, #7
	mov	x0, x19
	mov	w1, #40
	bl	_reg_w
	ldr	w8, [x23]
	cmp	w8, w22
	cset	w8, ne
	lsl	w2, w8, #7
	mov	x0, x19
	mov	w1, #56
	bl	_reg_w
	b	LBB0_20
LBB0_18:
	mov	w2, #8
	mov	w3, #8
	bl	_reg_w_mask
	mov	x0, x19
	mov	w1, #40
	mov	w2, #128
	mov	w3, #240
	bl	_reg_w_mask
	mov	x0, x19
	mov	w1, #56
	mov	w2, #128
LBB0_19:
	mov	w3, #240
	bl	_reg_w_mask
LBB0_20:
	add	w8, w20, #15
	cmp	w20, #0
	csel	w8, w8, w20, lt
	asr	w20, w8, #4
	add	w8, w21, #3
	cmp	w21, #0
	csel	w8, w8, w21, lt
	asr	w21, w8, #2
	mov	x0, x19
	mov	w1, #41
	mov	x2, x20
	bl	_reg_w
	mov	x0, x19
	mov	w1, #42
	mov	x2, x21
	bl	_reg_w
	mov	x0, x19
	mov	w1, #57
	mov	x2, x20
	bl	_reg_w
	mov	x0, x19
	mov	w1, #58
	mov	x2, x21
	bl	_reg_w
	mov	x0, x19
	mov	w1, #47
	mov	w2, #128
	bl	_reg_w
	mov	x0, x19
	mov	w1, #81
	mov	w2, #2
	bl	_reg_w
	mov	x0, x19
	mov	w1, #34
	mov	w2, #24
	bl	_reg_w
	mov	x0, x19
	mov	w1, #35
	mov	w2, #255
	bl	_reg_w
Lloh21:
	adrp	x20, _BRG_OV518PLUS@GOTPAGE
Lloh22:
	ldr	x20, [x20, _BRG_OV518PLUS@GOTPAGEOFF]
	ldr	x8, [x19, #16]
	ldr	x9, [x20]
	cmp	x8, x9
	mov	w8, #113
	mov	w9, #33
	csel	w1, w9, w8, eq
	mov	x0, x19
	mov	w2, #25
	bl	_reg_w
	mov	x0, x19
	mov	w1, #84
	mov	w2, #35
	bl	_i2c_w
	mov	x0, x19
	mov	w1, #47
	mov	w2, #128
	bl	_reg_w
	ldr	x8, [x19, #16]
	ldr	x9, [x20]
	cmp	x8, x9
	b.ne	LBB0_22
; %bb.21:
	mov	w20, #2400
	mov	w21, #108
	mov	w22, #540
	mov	w2, #148
	b	LBB0_23
LBB0_22:
	mov	w20, #2000
	mov	w21, #142
	mov	w22, #500
	mov	w2, #159
LBB0_23:
	mov	x0, x19
	mov	w1, #36
	bl	_reg_w
	mov	x0, x19
	mov	w1, #37
	mov	w2, #144
	bl	_reg_w
	mov	x0, x19
	mov	w1, #196
	mov	w2, #400
	mov	w3, #2
	bl	_ov518_reg_w32
	mov	x0, x19
	mov	w1, #198
	mov	x2, x22
	mov	w3, #2
	bl	_ov518_reg_w32
	mov	x0, x19
	mov	w1, #199
	mov	x2, x22
	mov	w3, #2
	bl	_ov518_reg_w32
	mov	x0, x19
	mov	w1, #200
	mov	x2, x21
	mov	w3, #2
	bl	_ov518_reg_w32
	mov	x0, x19
	mov	w1, #202
	mov	w2, #26
	movk	w2, #2, lsl #16
	mov	w3, #3
	bl	_ov518_reg_w32
	mov	x0, x19
	mov	w1, #203
	mov	w2, #532
	mov	w3, #2
	bl	_ov518_reg_w32
	mov	x0, x19
	mov	w1, #204
	mov	x2, x20
	mov	w3, #2
	bl	_ov518_reg_w32
	mov	x0, x19
	mov	w1, #205
	mov	w2, #32
	mov	w3, #2
	bl	_ov518_reg_w32
	mov	x0, x19
	mov	w1, #206
	mov	w2, #608
	mov	w3, #2
	bl	_ov518_reg_w32
	mov	x0, x19
	mov	w1, #47
	mov	w2, #128
	bl	_reg_w
	mov	x0, x19
	bl	_ov51x_restart
	tbnz	x0, #63, LBB0_26
; %bb.24:
Lloh23:
	adrp	x8, _OV511_RESET_NOREGS@GOTPAGE
Lloh24:
	ldr	x8, [x8, _OV511_RESET_NOREGS@GOTPAGEOFF]
Lloh25:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_ov51x_reset
	tbnz	x0, #63, LBB0_26
; %bb.25:
	mov	w0, #0
	b	LBB0_9
LBB0_26:
Lloh26:
	adrp	x8, _EIO@GOTPAGE
Lloh27:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
	b	LBB0_8
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpAdd	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGot	Lloh19, Lloh20
	.loh AdrpLdrGot	Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGot	Lloh26, Lloh27
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"width:%d, height:%d, mode:%d, sub:%d"

l_.str.1:                               ; @.str.1
	.asciz	"Invalid size (%d, %d)"

	.comm	_EINVAL,4,2                     ; @EINVAL
l_.str.2:                               ; @.str.2
	.asciz	"Requested dimensions are too small"

l_.str.3:                               ; @.str.3
	.asciz	"Invalid width/height combination (%d, %d)"

	.comm	_EIO,4,2                        ; @EIO
	.comm	_BRG_OV518,8,3                  ; @BRG_OV518
	.comm	_ov518_color,8,3                ; @ov518_color
	.comm	_VIDEO_PALETTE_GREY,4,2         ; @VIDEO_PALETTE_GREY
	.comm	_BRG_OV518PLUS,8,3              ; @BRG_OV518PLUS
	.comm	_OV511_RESET_NOREGS,4,2         ; @OV511_RESET_NOREGS
	.no_dead_strip	_ov518_mode_init_regs
.subsections_via_symbols
