	.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	$44, %rdi
	callq	_atomic_read
	cmpl	$-1, %eax
	je	LBB0_10
## %bb.1:
	cmpl	$0, 40(%rbx)
	je	LBB0_10
## %bb.2:
	movq	(%rbx), %rcx
	testq	%rcx, %rcx
	jle	LBB0_4
## %bb.3:
	decq	%rcx
	jmp	LBB0_9
LBB0_4:
	movq	_sensor_data@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movq	8(%rbx), %rdx
	movl	(%rcx,%rdx,4), %esi
	movq	_F_SIF@GOTPCREL(%rip), %rcx
	testl	%esi, (%rcx)
	movl	$13000, %ecx                    ## imm = 0x32C8
	movl	$5000, %edx                     ## imm = 0x1388
	cmovel	%ecx, %edx
	movl	$1500, %edi                     ## imm = 0x5DC
	movl	$500, %ecx                      ## imm = 0x1F4
	cmovel	%edi, %ecx
	movq	_F_COARSE_EXPO@GOTPCREL(%rip), %r8
	imull	16(%rbx), %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
	testl	%esi, (%r8)
	je	LBB0_6
## %bb.5:
	movq	%rbx, %rdi
	movl	%eax, %esi
                                        ## kill: def $edx killed $edx killed $rdx
	callq	_gspca_coarse_grained_expo_autogain
	testl	%eax, %eax
	jne	LBB0_8
	jmp	LBB0_10
LBB0_6:
	movq	_GAIN_KNEE@GOTPCREL(%rip), %rsi
	movl	(%rsi), %r8d
	movq	_EXPOSURE_KNEE@GOTPCREL(%rip), %rsi
	movl	(%rsi), %r9d
	movq	%rbx, %rdi
	movl	%eax, %esi
                                        ## kill: def $edx killed $edx killed $rdx
	callq	_gspca_auto_gain_n_exposure
	testl	%eax, %eax
	je	LBB0_10
LBB0_8:
	movq	_D_FRAM@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	24(%rbx), %ecx
	movl	32(%rbx), %edx
	leaq	L_.str(%rip), %rsi
	callq	_PDEBUG
	movq	_AUTOGAIN_IGNORE_FRAMES@GOTPCREL(%rip), %rax
	movq	(%rax), %rcx
LBB0_9:
	movq	%rcx, (%rbx)
LBB0_10:
	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	_F_COARSE_EXPO,4,2              ## @F_COARSE_EXPO
	.comm	_GAIN_KNEE,4,2                  ## @GAIN_KNEE
	.comm	_EXPOSURE_KNEE,4,2              ## @EXPOSURE_KNEE
	.comm	_D_FRAM,4,2                     ## @D_FRAM
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"autogain: gain changed: gain: %d expo: %d"

	.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, #44
	bl	_atomic_read
	cmn	w0, #1
	b.eq	LBB0_8
; %bb.1:
	ldr	w8, [x19, #40]
	cbz	w8, LBB0_8
; %bb.2:
	ldr	x8, [x19]
	subs	x8, x8, #1
	b.ge	LBB0_7
; %bb.3:
	mov	x1, x0
Lloh0:
	adrp	x8, _sensor_data@GOTPAGE
Lloh1:
	ldr	x8, [x8, _sensor_data@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	ldr	x9, [x19, #8]
	ldr	w8, [x8, x9, lsl #2]
Lloh3:
	adrp	x9, _F_SIF@GOTPAGE
Lloh4:
	ldr	x9, [x9, _F_SIF@GOTPAGEOFF]
Lloh5:
	ldr	w9, [x9]
	tst	w9, w8
	mov	w9, #5000
	mov	w10, #13000
	csel	w9, w10, w9, eq
	mov	w10, #500
	mov	w11, #1500
	csel	w3, w11, w10, eq
	ldr	w10, [x19, #16]
	mul	w9, w10, w9
	mov	w10, #1033
	movk	w10, #33026, lsl #16
	smull	x10, w9, w10
	lsr	x10, x10, #32
	add	w9, w10, w9
	asr	w10, w9, #6
	add	w2, w10, w9, lsr #31
Lloh6:
	adrp	x9, _F_COARSE_EXPO@GOTPAGE
Lloh7:
	ldr	x9, [x9, _F_COARSE_EXPO@GOTPAGEOFF]
Lloh8:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_5
; %bb.4:
	mov	x0, x19
	bl	_gspca_coarse_grained_expo_autogain
	cbnz	w0, LBB0_6
	b	LBB0_8
LBB0_5:
Lloh9:
	adrp	x8, _GAIN_KNEE@GOTPAGE
Lloh10:
	ldr	x8, [x8, _GAIN_KNEE@GOTPAGEOFF]
Lloh11:
	ldr	w4, [x8]
Lloh12:
	adrp	x8, _EXPOSURE_KNEE@GOTPAGE
Lloh13:
	ldr	x8, [x8, _EXPOSURE_KNEE@GOTPAGEOFF]
Lloh14:
	ldr	w5, [x8]
	mov	x0, x19
	bl	_gspca_auto_gain_n_exposure
	cbz	w0, LBB0_8
LBB0_6:
Lloh15:
	adrp	x8, _D_FRAM@GOTPAGE
Lloh16:
	ldr	x8, [x8, _D_FRAM@GOTPAGEOFF]
Lloh17:
	ldr	w0, [x8]
	ldr	w2, [x19, #32]
	ldr	w3, [x19, #24]
Lloh18:
	adrp	x1, l_.str@PAGE
Lloh19:
	add	x1, x1, l_.str@PAGEOFF
	bl	_PDEBUG
Lloh20:
	adrp	x8, _AUTOGAIN_IGNORE_FRAMES@GOTPAGE
Lloh21:
	ldr	x8, [x8, _AUTOGAIN_IGNORE_FRAMES@GOTPAGEOFF]
Lloh22:
	ldr	x8, [x8]
LBB0_7:
	str	x8, [x19]
LBB0_8:
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp], #32             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpAdd	Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.cfi_endproc
                                        ; -- End function
	.comm	_sensor_data,8,3                ; @sensor_data
	.comm	_F_SIF,4,2                      ; @F_SIF
	.comm	_F_COARSE_EXPO,4,2              ; @F_COARSE_EXPO
	.comm	_GAIN_KNEE,4,2                  ; @GAIN_KNEE
	.comm	_EXPOSURE_KNEE,4,2              ; @EXPOSURE_KNEE
	.comm	_D_FRAM,4,2                     ; @D_FRAM
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"autogain: gain changed: gain: %d expo: %d"

	.comm	_AUTOGAIN_IGNORE_FRAMES,8,3     ; @AUTOGAIN_IGNORE_FRAMES
	.no_dead_strip	_do_autogain
.subsections_via_symbols
