	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function do_autogain
_do_autogain:                           ## @do_autogain
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -24
	movq	%rdi, %rbx
	addq	$32, %rdi
	callq	_atomic_read
	cmpl	$-1, %eax
	je	LBB0_11
## %bb.1:
	movq	(%rbx), %rsi
	testq	%rsi, %rsi
	jle	LBB0_3
## %bb.2:
	decq	%rsi
	jmp	LBB0_10
LBB0_3:
	movq	_sensor_data@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movq	8(%rbx), %r8
	movq	24(%rbx), %rdi
	movq	_F_SIF@GOTPCREL(%rip), %rdx
	movl	(%rdx), %edx
	testl	%edx, (%rcx,%r8,4)
	movl	$13000, %ecx                    ## imm = 0x32C8
	movl	$5000, %edx                     ## imm = 0x1388
	cmovel	%ecx, %edx
	movl	$1500, %r9d                     ## imm = 0x5DC
	movl	$500, %ecx                      ## imm = 0x1F4
	cmovel	%r9d, %ecx
	testq	%rdi, %rdi
	je	LBB0_5
## %bb.4:
	imull	(%rdi), %edx
	movslq	%edx, %rdx
	imulq	$-2130574327, %rdx, %rdi        ## imm = 0x81020409
	shrq	$32, %rdi
	addl	%edi, %edx
	movl	%edx, %edi
	shrl	$31, %edi
	sarl	$6, %edx
	addl	%edi, %edx
LBB0_5:
	cmpl	$499, (%r8)                     ## imm = 0x1F3
	jg	LBB0_7
## %bb.6:
	movq	%rbx, %rdi
	movl	%eax, %esi
                                        ## kill: def $edx killed $edx killed $rdx
	callq	_gspca_coarse_grained_expo_autogain
	testq	%rax, %rax
	jne	LBB0_9
	jmp	LBB0_11
LBB0_7:
	movl	(%rsi), %esi
	leal	(%rsi,%rsi,8), %esi
	movslq	%esi, %rsi
	imulq	$1717986919, %rsi, %r8          ## imm = 0x66666667
	movq	%r8, %rsi
	shrq	$63, %rsi
	sarq	$34, %r8
	addl	%esi, %r8d
	movl	16(%rbx), %r9d
	movq	%rbx, %rdi
	movl	%eax, %esi
                                        ## kill: def $edx killed $edx killed $rdx
                                        ## kill: def $r8d killed $r8d killed $r8
	callq	_gspca_expo_autogain
	testq	%rax, %rax
	je	LBB0_11
LBB0_9:
	movq	_AUTOGAIN_IGNORE_FRAMES@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
LBB0_10:
	movq	%rsi, (%rbx)
LBB0_11:
	addq	$8, %rsp
	popq	%rbx
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_sensor_data,8,3                ## @sensor_data
	.comm	_F_SIF,4,2                      ## @F_SIF
	.comm	_AUTOGAIN_IGNORE_FRAMES,8,3     ## @AUTOGAIN_IGNORE_FRAMES
	.no_dead_strip	_do_autogain
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function do_autogain
_do_autogain:                           ; @do_autogain
	.cfi_startproc
; %bb.0:
	stp	x20, x19, [sp, #-32]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 32
	stp	x29, x30, [sp, #16]             ; 16-byte Folded Spill
	add	x29, sp, #16
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	mov	x19, x0
	add	x0, x0, #32
	bl	_atomic_read
	cmn	w0, #1
	b.eq	LBB0_9
; %bb.1:
	ldr	x8, [x19]
	subs	x9, x8, #1
	b.ge	LBB0_8
; %bb.2:
	mov	x1, x0
Lloh0:
	adrp	x9, _sensor_data@GOTPAGE
Lloh1:
	ldr	x9, [x9, _sensor_data@GOTPAGEOFF]
Lloh2:
	ldr	x10, [x9]
	ldr	x9, [x19, #8]
	ldr	w10, [x10, x9, lsl #2]
Lloh3:
	adrp	x11, _F_SIF@GOTPAGE
Lloh4:
	ldr	x11, [x11, _F_SIF@GOTPAGEOFF]
Lloh5:
	ldr	w11, [x11]
	tst	w11, w10
	mov	w10, #5000
	mov	w11, #13000
	csel	w2, w11, w10, eq
	mov	w10, #500
	mov	w11, #1500
	csel	w3, w11, w10, eq
	ldr	x10, [x19, #24]
	cbz	x10, LBB0_4
; %bb.3:
	ldr	w10, [x10]
	mul	w10, w10, w2
	mov	w11, #1033
	movk	w11, #33026, lsl #16
	smull	x11, w10, w11
	lsr	x11, x11, #32
	add	w10, w11, w10
	asr	w11, w10, #6
	add	w2, w11, w10, lsr #31
LBB0_4:
	ldr	w9, [x9]
	cmp	w9, #499
	b.gt	LBB0_6
; %bb.5:
	mov	x0, x19
	bl	_gspca_coarse_grained_expo_autogain
	cbnz	x0, LBB0_7
	b	LBB0_9
LBB0_6:
	ldr	w8, [x8]
	add	w8, w8, w8, lsl #3
	mov	w9, #26215
	movk	w9, #26214, lsl #16
	smull	x8, w8, w9
	lsr	x9, x8, #63
	asr	x8, x8, #34
	add	w4, w8, w9
	ldr	w5, [x19, #16]
	mov	x0, x19
	bl	_gspca_expo_autogain
	cbz	x0, LBB0_9
LBB0_7:
Lloh6:
	adrp	x8, _AUTOGAIN_IGNORE_FRAMES@GOTPAGE
Lloh7:
	ldr	x8, [x8, _AUTOGAIN_IGNORE_FRAMES@GOTPAGEOFF]
Lloh8:
	ldr	x9, [x8]
LBB0_8:
	str	x9, [x19]
LBB0_9:
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp], #32             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.cfi_endproc
                                        ; -- End function
	.comm	_sensor_data,8,3                ; @sensor_data
	.comm	_F_SIF,4,2                      ; @F_SIF
	.comm	_AUTOGAIN_IGNORE_FRAMES,8,3     ; @AUTOGAIN_IGNORE_FRAMES
	.no_dead_strip	_do_autogain
.subsections_via_symbols
