	.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	%r15
	pushq	%r14
	pushq	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	(%rdi), %rax
	testq	%rax, %rax
	js	LBB0_3
## %bb.1:
	movq	%rdi, %rbx
	subq	$1, %rax
	movq	%rax, (%rdi)
	jae	LBB0_3
## %bb.2:
	movq	_AG_CNT_START@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, (%rbx)
	movq	%rbx, %rdi
	callq	_Et_getgainG
	movl	%eax, %r14d
	movq	_ET_LUMA_CENTER@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	movl	$4, %edx
	callq	_reg_r
	movq	(%rbx), %rax
	movl	8(%rax), %ecx
	movl	12(%rax), %edx
	addl	(%rax), %edx
	imull	$232, 4(%rax), %eax
	sarl	%edx
	sarl	$10, %eax
	shll	$7, %ecx
	sarl	$10, %ecx
	imull	$672, %edx, %edi                ## imm = 0x2A0
	sarl	$10, %edi
	addl	%eax, %edi
	addl	%ecx, %edi
	callq	_LIMIT
	movl	%eax, %r15d
	movq	_D_FRAM@GOTPCREL(%rip), %r12
	movl	(%r12), %esi
	leaq	L_.str(%rip), %rdx
	movq	%rbx, %rdi
	movl	%eax, %ecx
	callq	_gspca_dbg
	leal	-149(%r15), %eax
	cmpl	$-42, %eax
	ja	LBB0_3
## %bb.4:
	movl	$128, %edi
	subl	%r15d, %edi
	sarl	$4, %edi
	addl	%r14d, %edi
	callq	_BLIMIT
	movl	%eax, %r14d
	movl	(%r12), %esi
	leaq	L_.str.1(%rip), %rdx
	movq	%rbx, %rdi
	movl	%eax, %ecx
	callq	_gspca_dbg
	movq	%rbx, %rdi
	movl	%r14d, %esi
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_Et_setgainG                    ## TAILCALL
LBB0_3:
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_AG_CNT_START,8,3               ## @AG_CNT_START
	.comm	_ET_LUMA_CENTER,4,2             ## @ET_LUMA_CENTER
	.comm	_D_FRAM,4,2                     ## @D_FRAM
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Etoms luma G %d\n"

L_.str.1:                               ## @.str.1
	.asciz	"Etoms Gbright %d\n"

	.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	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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
	ldr	x8, [x0]
	tbnz	x8, #63, LBB0_4
; %bb.1:
	mov	x19, x0
	sub	x9, x8, #1
	str	x9, [x0]
	cbnz	x8, LBB0_4
; %bb.2:
Lloh0:
	adrp	x8, _AG_CNT_START@GOTPAGE
Lloh1:
	ldr	x8, [x8, _AG_CNT_START@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	str	x8, [x19]
	mov	x0, x19
	bl	_Et_getgainG
	mov	x20, x0
Lloh3:
	adrp	x8, _ET_LUMA_CENTER@GOTPAGE
Lloh4:
	ldr	x8, [x8, _ET_LUMA_CENTER@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
	mov	x0, x19
	mov	w2, #4
	bl	_reg_r
	ldr	x8, [x19]
	ldp	w9, w10, [x8]
	ldp	w8, w11, [x8, #8]
	add	w9, w11, w9
	asr	w9, w9, #1
	mov	w11, #232
	mul	w10, w10, w11
	lsl	w8, w8, #7
	mov	w11, #672
	mul	w9, w9, w11
	asr	w9, w9, #10
	add	w9, w9, w10, asr #10
	add	w0, w9, w8, asr #10
	bl	_LIMIT
	mov	x21, x0
Lloh6:
	adrp	x22, _D_FRAM@GOTPAGE
Lloh7:
	ldr	x22, [x22, _D_FRAM@GOTPAGEOFF]
	ldr	w1, [x22]
Lloh8:
	adrp	x2, l_.str@PAGE
Lloh9:
	add	x2, x2, l_.str@PAGEOFF
	mov	x0, x19
	mov	x3, x21
	bl	_gspca_dbg
	sub	w8, w21, #149
	cmn	w8, #42
	b.hi	LBB0_4
; %bb.3:
	mov	w8, #128
	sub	w8, w8, w21
	add	w0, w20, w8, asr #4
	bl	_BLIMIT
	mov	x20, x0
	ldr	w1, [x22]
Lloh10:
	adrp	x2, l_.str.1@PAGE
Lloh11:
	add	x2, x2, l_.str.1@PAGEOFF
	mov	x0, x19
	mov	x3, x20
	bl	_gspca_dbg
	mov	x0, x19
	mov	x1, x20
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	b	_Et_setgainG
LBB0_4:
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.comm	_AG_CNT_START,8,3               ; @AG_CNT_START
	.comm	_ET_LUMA_CENTER,4,2             ; @ET_LUMA_CENTER
	.comm	_D_FRAM,4,2                     ; @D_FRAM
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Etoms luma G %d\n"

l_.str.1:                               ; @.str.1
	.asciz	"Etoms Gbright %d\n"

	.no_dead_strip	_do_autogain
.subsections_via_symbols
