	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function w9966_setup
_w9966_setup:                           ## @w9966_setup
	.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	$104, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r14
	movl	16(%rbp), %eax
	movq	___stack_chk_guard@GOTPCREL(%rip), %rdi
	movq	(%rdi), %rdi
	movq	%rdi, -48(%rbp)
	movl	%esi, -132(%rbp)
	movl	%edx, -128(%rbp)
	movl	%ecx, -124(%rbp)
	movl	%r8d, -120(%rbp)
	movaps	l___const.w9966_setup.saa7111_regs+16(%rip), %xmm0
	movaps	%xmm0, -96(%rbp)
	movaps	l___const.w9966_setup.saa7111_regs(%rip), %xmm0
	movaps	%xmm0, -112(%rbp)
	movl	%r9d, %ecx
	imull	%eax, %ecx
	addl	%ecx, %ecx
	movq	_W9966_SRAMSIZE@GOTPCREL(%rip), %rdx
	cmpl	(%rdx), %ecx
	jle	LBB0_2
## %bb.1:
	leaq	L_.str(%rip), %rdi
	xorl	%eax, %eax
	callq	_DPRINTF
	movl	$200, %r9d
	movl	$160, %eax
LBB0_2:
	andl	$-2, %r9d
	cmpl	$3, %r9d
	movl	$2, %ebx
	cmovgel	%r9d, %ebx
	cmpl	$2, %eax
	movl	$1, %r15d
	cmovgel	%eax, %r15d
	movq	_W9966_WND_MAX_W@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	cmpl	%eax, %ebx
	cmovgel	%eax, %ebx
	movq	_W9966_WND_MAX_H@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	cmpl	%eax, %r15d
	cmovgel	%eax, %r15d
	movl	%ebx, (%r14)
	movl	%r15d, 4(%r14)
	movq	_W9966_WND_MIN_X@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_W9966_WND_MAX_X@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	leaq	-132(%rbp), %rcx
	leaq	-124(%rbp), %r8
	leaq	-114(%rbp), %r9
	movl	%ebx, %edi
	callq	_w9966_calcscale
	testq	%rax, %rax
	jne	LBB0_12
## %bb.3:
	movq	_W9966_WND_MIN_Y@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_W9966_WND_MAX_Y@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	leaq	-128(%rbp), %rcx
	leaq	-120(%rbp), %r8
	leaq	-113(%rbp), %r9
	movl	%r15d, %edi
	callq	_w9966_calcscale
	testq	%rax, %rax
	je	LBB0_4
LBB0_12:
	movl	$-1, %eax
LBB0_13:
	movq	___stack_chk_guard@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	cmpq	-48(%rbp), %rcx
	jne	LBB0_15
## %bb.14:
	addq	$104, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_4:
	movl	%r15d, %r13d
	imull	%ebx, %r13d
	addl	%r13d, %r13d
	movl	-132(%rbp), %ecx
	movl	-124(%rbp), %r8d
	movl	-128(%rbp), %r9d
	movl	-120(%rbp), %r10d
	movzbl	-114(%rbp), %r11d
	andl	$127, %r11d
	movzbl	-113(%rbp), %r12d
	andl	$127, %r12d
	subq	$8, %rsp
	leaq	L_.str.1(%rip), %rdi
	movl	%ebx, %esi
	movl	%r15d, %edx
	xorl	%eax, %eax
	pushq	%r12
	pushq	%r11
	pushq	%r10
	callq	_DPRINTF
	addq	$32, %rsp
	movw	$6144, -80(%rbp)                ## imm = 0x1800
	movb	-113(%rbp), %al
	movb	%al, -78(%rbp)
	movb	-114(%rbp), %al
	movb	%al, -77(%rbp)
	movl	-132(%rbp), %eax
	movb	%al, -76(%rbp)
	shrl	$8, %eax
	andb	$3, %al
	movb	%al, -75(%rbp)
	movl	-128(%rbp), %eax
	movb	%al, -74(%rbp)
	shrl	$8, %eax
	andb	$3, %al
	movb	%al, -73(%rbp)
	movl	-124(%rbp), %eax
	movb	%al, -72(%rbp)
	shrl	$8, %eax
	andb	$3, %al
	movb	%al, -71(%rbp)
	movb	-120(%rbp), %al
	movb	%al, -70(%rbp)
	movq	_W9966_SRAMID@GOTPCREL(%rip), %rax
	movb	(%rax), %al
	movb	%al, -68(%rbp)
	movw	$0, -67(%rbp)
	movb	$0, -65(%rbp)
	movl	%r13d, %eax
	movb	%al, -64(%rbp)
	movb	%ah, -63(%rbp)
	shrl	$16, %eax
	andb	$7, %al
	movb	%al, -62(%rbp)
	movb	$64, -61(%rbp)
	movb	$0, -57(%rbp)
	movb	$0, 8(%r14)
	movl	$285212416, -56(%rbp)           ## imm = 0x10FFFF00
	movb	9(%r14), %al
	movb	%al, -102(%rbp)
	movb	10(%r14), %al
	movb	%al, -101(%rbp)
	movb	11(%r14), %al
	movb	%al, -100(%rbp)
	movb	12(%r14), %al
	movb	%al, -99(%rbp)
	movq	%r14, %rdi
	xorl	%esi, %esi
	movl	$3, %edx
	callq	_w9966_wReg
	cmpl	$-1, %eax
	je	LBB0_12
## %bb.5:
	movq	%r14, %rdi
	xorl	%esi, %esi
	xorl	%edx, %edx
	callq	_w9966_wReg
	cmpl	$-1, %eax
	je	LBB0_12
## %bb.6:
	movl	$1, %ebx
	.p2align	4, 0x90
LBB0_7:                                 ## =>This Inner Loop Header: Depth=1
	cmpq	$28, %rbx
	je	LBB0_8
## %bb.9:                               ##   in Loop: Header=BB0_7 Depth=1
	movzbl	-80(%rbp,%rbx), %edx
	movq	%r14, %rdi
	movl	%ebx, %esi
	callq	_w9966_wReg
	incq	%rbx
	cmpl	$-1, %eax
	jne	LBB0_7
	jmp	LBB0_12
LBB0_8:
	xorl	%ebx, %ebx
	.p2align	4, 0x90
LBB0_11:                                ## =>This Inner Loop Header: Depth=1
	movzbl	-112(%rbp,%rbx), %edx
	movq	%r14, %rdi
	movl	%ebx, %esi
	callq	_w9966_wReg_i2c
	cmpl	$-1, %eax
	je	LBB0_12
## %bb.10:                              ##   in Loop: Header=BB0_11 Depth=1
	incq	%rbx
	xorl	%eax, %eax
	cmpq	$32, %rbx
	jne	LBB0_11
	jmp	LBB0_13
LBB0_15:
	callq	___stack_chk_fail
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__const
	.p2align	4                               ## @__const.w9966_setup.saa7111_regs
l___const.w9966_setup.saa7111_regs:
	.ascii	"!\000\330#\000\200\200\000\210\020\200@@\000\001\000H\f\000\000\000\000\000\000\000\000\000q\347\000\000\300"

	.comm	_W9966_SRAMSIZE,4,2             ## @W9966_SRAMSIZE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"capture window exceeds SRAM size!.\n"

	.comm	_W9966_WND_MAX_W,4,2            ## @W9966_WND_MAX_W
	.comm	_W9966_WND_MAX_H,4,2            ## @W9966_WND_MAX_H
	.comm	_W9966_WND_MIN_X,4,2            ## @W9966_WND_MIN_X
	.comm	_W9966_WND_MAX_X,4,2            ## @W9966_WND_MAX_X
	.comm	_W9966_WND_MIN_Y,4,2            ## @W9966_WND_MIN_Y
	.comm	_W9966_WND_MAX_Y,4,2            ## @W9966_WND_MAX_Y
L_.str.1:                               ## @.str.1
	.asciz	"%dx%d, x: %d<->%d, y: %d<->%d, sx: %d/64, sy: %d/64.\n"

	.comm	_W9966_SRAMID,1,0               ## @W9966_SRAMID
	.no_dead_strip	_w9966_setup
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function w9966_setup
_w9966_setup:                           ; @w9966_setup
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #224
	.cfi_def_cfa_offset 224
	stp	x22, x21, [sp, #176]            ; 16-byte Folded Spill
	stp	x20, x19, [sp, #192]            ; 16-byte Folded Spill
	stp	x29, x30, [sp, #208]            ; 16-byte Folded Spill
	add	x29, sp, #208
	.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	x19, x0
Lloh0:
	adrp	x8, ___stack_chk_guard@GOTPAGE
Lloh1:
	ldr	x8, [x8, ___stack_chk_guard@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	stur	x8, [x29, #-40]
	stp	w2, w1, [sp, #88]
	stp	w4, w3, [sp, #80]
Lloh3:
	adrp	x8, l___const.w9966_setup.saa7111_regs@PAGE
Lloh4:
	add	x8, x8, l___const.w9966_setup.saa7111_regs@PAGEOFF
	ldp	q0, q1, [x8]
	stp	q0, q1, [sp, #96]
	mul	w8, w5, w6
Lloh5:
	adrp	x9, _W9966_SRAMSIZE@GOTPAGE
Lloh6:
	ldr	x9, [x9, _W9966_SRAMSIZE@GOTPAGEOFF]
Lloh7:
	ldr	w9, [x9]
	cmp	w9, w8, lsl #1
	b.ge	LBB0_2
; %bb.1:
Lloh8:
	adrp	x0, l_.str@PAGE
Lloh9:
	add	x0, x0, l_.str@PAGEOFF
	bl	_DPRINTF
	mov	w5, #200
	mov	w6, #160
LBB0_2:
	and	w8, w5, #0xfffffffe
	mov	w9, #2
	cmp	w8, #2
	csel	w8, w8, w9, gt
	cmp	w6, #1
	csinc	w9, w6, wzr, gt
Lloh10:
	adrp	x10, _W9966_WND_MAX_W@GOTPAGE
Lloh11:
	ldr	x10, [x10, _W9966_WND_MAX_W@GOTPAGEOFF]
Lloh12:
	ldr	w10, [x10]
Lloh13:
	adrp	x11, _W9966_WND_MAX_H@GOTPAGE
Lloh14:
	ldr	x11, [x11, _W9966_WND_MAX_H@GOTPAGEOFF]
	cmp	w8, w10
	csel	w20, w8, w10, lt
Lloh15:
	ldr	w8, [x11]
	cmp	w9, w8
	csel	w21, w9, w8, lt
	stp	w20, w21, [x19]
Lloh16:
	adrp	x8, _W9966_WND_MIN_X@GOTPAGE
Lloh17:
	ldr	x8, [x8, _W9966_WND_MIN_X@GOTPAGEOFF]
Lloh18:
	ldr	w1, [x8]
Lloh19:
	adrp	x8, _W9966_WND_MAX_X@GOTPAGE
Lloh20:
	ldr	x8, [x8, _W9966_WND_MAX_X@GOTPAGEOFF]
Lloh21:
	ldr	w2, [x8]
	add	x3, sp, #92
	add	x4, sp, #84
	add	x5, sp, #79
	mov	x0, x20
	bl	_w9966_calcscale
	cbnz	x0, LBB0_4
; %bb.3:
Lloh22:
	adrp	x8, _W9966_WND_MIN_Y@GOTPAGE
Lloh23:
	ldr	x8, [x8, _W9966_WND_MIN_Y@GOTPAGEOFF]
Lloh24:
	ldr	w1, [x8]
Lloh25:
	adrp	x8, _W9966_WND_MAX_Y@GOTPAGE
Lloh26:
	ldr	x8, [x8, _W9966_WND_MAX_Y@GOTPAGEOFF]
Lloh27:
	ldr	w2, [x8]
	add	x3, sp, #88
	add	x4, sp, #80
	add	x5, sp, #78
	mov	x0, x21
	bl	_w9966_calcscale
	cbz	x0, LBB0_7
LBB0_4:
	mov	w0, #-1
LBB0_5:
	ldur	x8, [x29, #-40]
Lloh28:
	adrp	x9, ___stack_chk_guard@GOTPAGE
Lloh29:
	ldr	x9, [x9, ___stack_chk_guard@GOTPAGEOFF]
Lloh30:
	ldr	x9, [x9]
	cmp	x9, x8
	b.ne	LBB0_15
; %bb.6:
	ldp	x29, x30, [sp, #208]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #192]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #176]            ; 16-byte Folded Reload
	add	sp, sp, #224
	ret
LBB0_7:
	mul	w8, w21, w20
	lsl	w22, w8, #1
	ldrb	w8, [sp, #79]
	and	w8, w8, #0x7f
	ldrb	w9, [sp, #78]
	and	w9, w9, #0x7f
	ldp	w12, w10, [sp, #88]
	ldp	w13, w11, [sp, #80]
	stp	x8, x9, [sp, #48]
	stp	x12, x13, [sp, #32]
	stp	x10, x11, [sp, #16]
Lloh31:
	adrp	x0, l_.str.1@PAGE
Lloh32:
	add	x0, x0, l_.str.1@PAGEOFF
	stp	x20, x21, [sp]
	bl	_DPRINTF
	mov	w8, #6144
	sturh	w8, [x29, #-68]
	ldrb	w8, [sp, #78]
	sturb	w8, [x29, #-66]
	ldrb	w8, [sp, #79]
	sturb	w8, [x29, #-65]
	ldr	w8, [sp, #92]
	sturb	w8, [x29, #-64]
	ubfx	w8, w8, #8, #2
	sturb	w8, [x29, #-63]
	ldr	w8, [sp, #88]
	sturb	w8, [x29, #-62]
	ubfx	w8, w8, #8, #2
	sturb	w8, [x29, #-61]
	ldr	w8, [sp, #84]
	sturb	w8, [x29, #-60]
	ubfx	w8, w8, #8, #2
	sturb	w8, [x29, #-59]
	ldr	w8, [sp, #80]
Lloh33:
	adrp	x9, _W9966_SRAMID@GOTPAGE
Lloh34:
	ldr	x9, [x9, _W9966_SRAMID@GOTPAGEOFF]
	sturb	w8, [x29, #-58]
	ldrb	w8, [x9]
	sturb	w8, [x29, #-56]
	sturh	wzr, [x29, #-55]
	sturb	wzr, [x29, #-53]
	sturb	w22, [x29, #-52]
	lsr	w8, w22, #8
	sturb	w8, [x29, #-51]
	ubfx	w8, w22, #16, #3
	sturb	w8, [x29, #-50]
	mov	w8, #64
	sturb	w8, [x29, #-49]
	sturb	wzr, [x29, #-45]
	strb	wzr, [x19, #8]
	mov	w8, #65280
	movk	w8, #4351, lsl #16
	stur	w8, [x29, #-44]
	ldur	w8, [x19, #9]
	stur	w8, [sp, #106]
	mov	x0, x19
	mov	w1, #0
	mov	w2, #3
	bl	_w9966_wReg
	cmn	w0, #1
	b.eq	LBB0_5
; %bb.8:
	mov	x0, x19
	mov	w1, #0
	mov	w2, #0
	bl	_w9966_wReg
	cmn	w0, #1
	b.eq	LBB0_5
; %bb.9:
	mov	w20, #1
	sub	x21, x29, #68
LBB0_10:                                ; =>This Inner Loop Header: Depth=1
	cmp	x20, #28
	b.eq	LBB0_12
; %bb.11:                               ;   in Loop: Header=BB0_10 Depth=1
	ldrb	w2, [x21, x20]
	mov	x0, x19
	mov	x1, x20
	bl	_w9966_wReg
	mov	x8, x0
	add	x20, x20, #1
	mov	w0, #-1
	cmn	w8, #1
	b.ne	LBB0_10
	b	LBB0_5
LBB0_12:
	mov	x20, #0
	add	x21, sp, #96
LBB0_13:                                ; =>This Inner Loop Header: Depth=1
	ldrb	w2, [x21, x20]
	mov	x0, x19
	mov	x1, x20
	bl	_w9966_wReg_i2c
	cmn	w0, #1
	b.eq	LBB0_5
; %bb.14:                               ;   in Loop: Header=BB0_13 Depth=1
	mov	w0, #0
	add	x20, x20, #1
	cmp	x20, #32
	b.ne	LBB0_13
	b	LBB0_5
LBB0_15:
	bl	___stack_chk_fail
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh25, Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.loh AdrpLdrGot	Lloh33, Lloh34
	.loh AdrpAdd	Lloh31, Lloh32
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__const
l___const.w9966_setup.saa7111_regs:     ; @__const.w9966_setup.saa7111_regs
	.ascii	"!\000\330#\000\200\200\000\210\020\200@@\000\001\000H\f\000\000\000\000\000\000\000\000\000q\347\000\000\300"

	.comm	_W9966_SRAMSIZE,4,2             ; @W9966_SRAMSIZE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"capture window exceeds SRAM size!.\n"

	.comm	_W9966_WND_MAX_W,4,2            ; @W9966_WND_MAX_W
	.comm	_W9966_WND_MAX_H,4,2            ; @W9966_WND_MAX_H
	.comm	_W9966_WND_MIN_X,4,2            ; @W9966_WND_MIN_X
	.comm	_W9966_WND_MAX_X,4,2            ; @W9966_WND_MAX_X
	.comm	_W9966_WND_MIN_Y,4,2            ; @W9966_WND_MIN_Y
	.comm	_W9966_WND_MAX_Y,4,2            ; @W9966_WND_MAX_Y
l_.str.1:                               ; @.str.1
	.asciz	"%dx%d, x: %d<->%d, y: %d<->%d, sx: %d/64, sy: %d/64.\n"

	.comm	_W9966_SRAMID,1,0               ; @W9966_SRAMID
	.no_dead_strip	_w9966_setup
.subsections_via_symbols
