	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function ov965x_set_gain
_ov965x_set_gain:                       ## @ov965x_set_gain
	.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	%esi, %ebx
	movq	%rdi, %r12
	movq	8(%rdi), %rax
	cmpq	$0, 8(%rax)
	je	LBB0_4
## %bb.1:
	movq	_REG_COM8@GOTPCREL(%rip), %r14
	movl	(%r14), %esi
	leaq	-44(%rbp), %rdx
	movq	%r12, %rdi
	callq	_ov965x_read
	testl	%eax, %eax
	js	LBB0_30
## %bb.2:
	movq	8(%r12), %rax
	cmpq	$0, (%rax)
	movq	_COM8_AGC@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	je	LBB0_5
## %bb.3:
	orl	-44(%rbp), %edx
	jmp	LBB0_6
LBB0_4:
	xorl	%eax, %eax
	jmp	LBB0_7
LBB0_5:
	notl	%edx
	andl	-44(%rbp), %edx
LBB0_6:
	movl	%edx, -44(%rbp)
	movl	(%r14), %esi
	movq	%r12, %rdi
	callq	_ov965x_write
	testl	%eax, %eax
	js	LBB0_30
LBB0_7:
	testl	%ebx, %ebx
	jne	LBB0_30
## %bb.8:
	movq	(%r12), %rcx
	cmpq	$0, 8(%rcx)
	je	LBB0_30
## %bb.9:
	movl	(%rcx), %eax
	cmpl	$1023, %eax                     ## imm = 0x3FF
	ja	LBB0_17
## %bb.10:
	cmpl	$511, %eax                      ## imm = 0x1FF
	ja	LBB0_18
## %bb.11:
	cmpl	$255, %eax
	ja	LBB0_19
## %bb.12:
	cmpl	$127, %eax
	ja	LBB0_20
## %bb.13:
	cmpl	$63, %eax
	ja	LBB0_21
## %bb.14:
	xorl	%r14d, %r14d
	cmpl	$31, %eax
	ja	LBB0_22
## %bb.15:
	movl	$0, %ecx
	movl	$0, %r15d
	cmpl	$15, %eax
	ja	LBB0_24
## %bb.16:
	movl	$-1, %r14d
	movb	$1, %cl
                                        ## implicit-def: $r15d
	jmp	LBB0_24
LBB0_17:
	movl	$1008, %r15d                    ## imm = 0x3F0
	movl	$6, %r14d
	jmp	LBB0_23
LBB0_18:
	movl	$496, %r15d                     ## imm = 0x1F0
	movl	$5, %r14d
	jmp	LBB0_23
LBB0_19:
	movl	$240, %r15d
	movl	$4, %r14d
	jmp	LBB0_23
LBB0_20:
	movl	$112, %r15d
	movl	$3, %r14d
	jmp	LBB0_23
LBB0_21:
	movl	$48, %r15d
	movl	$2, %r14d
	jmp	LBB0_23
LBB0_22:
	movl	$16, %r15d
	movl	$1, %r14d
LBB0_23:
	xorl	%ecx, %ecx
LBB0_24:
	testb	%cl, %cl
	je	LBB0_26
## %bb.25:
	movq	_EINVAL@GOTPCREL(%rip), %rcx
	xorl	%eax, %eax
	subl	(%rcx), %eax
	jmp	LBB0_30
LBB0_26:
	movl	$-16, %ebx
	movl	%r14d, %ecx
	shll	%cl, %ebx
	addl	%eax, %ebx
	shrl	%cl, %ebx
	orl	%ebx, %r15d
	movq	_REG_GAIN@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movzbl	%r15b, %edx
	movq	%r12, %rdi
	callq	_ov965x_write
	testl	%eax, %eax
	js	LBB0_30
## %bb.27:
	movq	_REG_VREF@GOTPCREL(%rip), %r13
	movl	(%r13), %esi
	leaq	-44(%rbp), %rdx
	movq	%r12, %rdi
	callq	_ov965x_read
	testl	%eax, %eax
	js	LBB0_30
## %bb.28:
	movq	_VREF_GAIN_MASK@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	notl	%eax
	andl	-44(%rbp), %eax
	shrl	$2, %r15d
	andl	$192, %r15d
	orl	%eax, %r15d
	movl	%r15d, -44(%rbp)
	movl	(%r13), %esi
	movq	%r12, %rdi
	movl	%r15d, %edx
	callq	_ov965x_write
	testl	%eax, %eax
	js	LBB0_30
## %bb.29:
	andl	$15, %ebx
	orl	$16, %ebx
	movl	%r14d, %ecx
	shll	%cl, %ebx
	movq	(%r12), %rcx
	movl	%ebx, (%rcx)
LBB0_30:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_REG_COM8,4,2                   ## @REG_COM8
	.comm	_COM8_AGC,4,2                   ## @COM8_AGC
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_REG_GAIN,4,2                   ## @REG_GAIN
	.comm	_REG_VREF,4,2                   ## @REG_VREF
	.comm	_VREF_GAIN_MASK,4,2             ## @VREF_GAIN_MASK
	.no_dead_strip	_ov965x_set_gain
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function ov965x_set_gain
_ov965x_set_gain:                       ; @ov965x_set_gain
	.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	x20, x1
	mov	x19, x0
	ldr	x8, [x0, #8]
	ldr	x8, [x8, #8]
	cbz	x8, LBB0_4
; %bb.1:
Lloh0:
	adrp	x21, _REG_COM8@GOTPAGE
Lloh1:
	ldr	x21, [x21, _REG_COM8@GOTPAGEOFF]
	ldr	w1, [x21]
	add	x2, sp, #12
	mov	x0, x19
	bl	_ov965x_read
	tbnz	w0, #31, LBB0_30
; %bb.2:
	ldr	x8, [x19, #8]
	ldr	x9, [x8]
Lloh2:
	adrp	x8, _COM8_AGC@GOTPAGE
Lloh3:
	ldr	x8, [x8, _COM8_AGC@GOTPAGEOFF]
Lloh4:
	ldr	w8, [x8]
	cbz	x9, LBB0_5
; %bb.3:
	ldr	w9, [sp, #12]
	orr	w2, w9, w8
	b	LBB0_6
LBB0_4:
	mov	w0, #0
	b	LBB0_7
LBB0_5:
	ldr	w9, [sp, #12]
	bic	w2, w9, w8
LBB0_6:
	str	w2, [sp, #12]
	ldr	w1, [x21]
	mov	x0, x19
	bl	_ov965x_write
	tbnz	w0, #31, LBB0_30
LBB0_7:
	cbnz	w20, LBB0_30
; %bb.8:
	ldr	x8, [x19]
	ldr	x9, [x8, #8]
	cbz	x9, LBB0_30
; %bb.9:
	ldr	w8, [x8]
	cmp	w8, #1023
	b.hi	LBB0_17
; %bb.10:
	cmp	w8, #511
	b.hi	LBB0_18
; %bb.11:
	cmp	w8, #255
	b.hi	LBB0_19
; %bb.12:
	cmp	w8, #127
	b.hi	LBB0_20
; %bb.13:
	cmp	w8, #63
	b.hi	LBB0_21
; %bb.14:
	cmp	w8, #31
	b.hi	LBB0_22
; %bb.15:
	cmp	w8, #15
	b.hi	LBB0_23
; %bb.16:
	mov	w20, #-1
	mov	w9, #1
                                        ; implicit-def: $w10
	b	LBB0_24
LBB0_17:
	mov	w9, #0
	mov	w10, #1008
	mov	w20, #6
	b	LBB0_24
LBB0_18:
	mov	w9, #0
	mov	w10, #496
	mov	w20, #5
	b	LBB0_24
LBB0_19:
	mov	w9, #0
	mov	w10, #240
	mov	w20, #4
	b	LBB0_24
LBB0_20:
	mov	w9, #0
	mov	w10, #112
	mov	w20, #3
	b	LBB0_24
LBB0_21:
	mov	w9, #0
	mov	w10, #48
	mov	w20, #2
	b	LBB0_24
LBB0_22:
	mov	w9, #0
	mov	w10, #16
	mov	w20, #1
	b	LBB0_24
LBB0_23:
	mov	w9, #0
	mov	w20, #0
	mov	w10, #0
LBB0_24:
	cbz	w9, LBB0_26
; %bb.25:
Lloh5:
	adrp	x8, _EINVAL@GOTPAGE
Lloh6:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh7:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_30
LBB0_26:
	mov	w9, #-16
	lsl	w9, w9, w20
	add	w8, w9, w8
	lsr	w21, w8, w20
	orr	w22, w21, w10
Lloh8:
	adrp	x8, _REG_GAIN@GOTPAGE
Lloh9:
	ldr	x8, [x8, _REG_GAIN@GOTPAGEOFF]
Lloh10:
	ldr	w1, [x8]
	and	w2, w22, #0xff
	mov	x0, x19
	bl	_ov965x_write
	tbnz	w0, #31, LBB0_30
; %bb.27:
Lloh11:
	adrp	x23, _REG_VREF@GOTPAGE
Lloh12:
	ldr	x23, [x23, _REG_VREF@GOTPAGEOFF]
	ldr	w1, [x23]
	add	x2, sp, #12
	mov	x0, x19
	bl	_ov965x_read
	tbnz	w0, #31, LBB0_30
; %bb.28:
Lloh13:
	adrp	x8, _VREF_GAIN_MASK@GOTPAGE
Lloh14:
	ldr	x8, [x8, _VREF_GAIN_MASK@GOTPAGEOFF]
Lloh15:
	ldr	w8, [x8]
	ldr	w9, [sp, #12]
	bic	w8, w9, w8
	lsr	w9, w22, #2
	and	w9, w9, #0xc0
	orr	w2, w8, w9
	str	w2, [sp, #12]
	ldr	w1, [x23]
	mov	x0, x19
	bl	_ov965x_write
	tbnz	w0, #31, LBB0_30
; %bb.29:
	mov	w8, #16
	bfxil	w8, w21, #0, #4
	lsl	w8, w8, w20
	ldr	x9, [x19]
	str	w8, [x9]
LBB0_30:
	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
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.cfi_endproc
                                        ; -- End function
	.comm	_REG_COM8,4,2                   ; @REG_COM8
	.comm	_COM8_AGC,4,2                   ; @COM8_AGC
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_REG_GAIN,4,2                   ; @REG_GAIN
	.comm	_REG_VREF,4,2                   ; @REG_VREF
	.comm	_VREF_GAIN_MASK,4,2             ; @VREF_GAIN_MASK
	.no_dead_strip	_ov965x_set_gain
.subsections_via_symbols
