	.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	%r14
	pushq	%rbx
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	movq	(%rdi), %rax
	testq	%rax, %rax
	js	LBB0_9
## %bb.1:
	movq	%rdi, %rbx
	subq	$1, %rax
	movq	%rax, (%rdi)
	jae	LBB0_9
## %bb.2:
	movq	_AG_CNT_START@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, (%rbx)
	leaq	16(%rbx), %rdi
	callq	_atomic_read
	movl	%eax, %r14d
	movq	_D_FRAM@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	L_.str(%rip), %rdx
	movq	%rbx, %rdi
	movl	%r14d, %ecx
	callq	_gspca_dbg
	movl	8(%rbx), %eax
	movq	_SENSOR_PO2030N@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jne	LBB0_3
## %bb.14:
	movq	%rbx, %rdi
	movl	%r14d, %esi
	movl	$130, %edx
	movl	$20, %ecx
	movl	$15, %r8d
	movl	$1024, %r9d                     ## imm = 0x400
	popq	%rbx
	popq	%r14
	popq	%rbp
	jmp	_gspca_expo_autogain            ## TAILCALL
LBB0_3:
	leal	-151(%r14), %ecx
	cmpl	$-42, %ecx
	ja	LBB0_9
## %bb.4:
	leal	-128(%rax), %ecx
	cmpl	$2, %ecx
	jb	LBB0_11
## %bb.5:
	cmpl	$130, %eax
	je	LBB0_10
## %bb.6:
	cmpl	$131, %eax
	jne	LBB0_13
## %bb.7:
	movl	$130, %eax
	subl	%r14d, %eax
	sarl	$6, %eax
	addl	12(%rbx), %eax
	xorl	%esi, %esi
	testl	%eax, %eax
	cmovgl	%eax, %esi
	jmp	LBB0_8
LBB0_11:
	movl	$130, %eax
	subl	%r14d, %eax
	sarl	$2, %eax
	jmp	LBB0_12
LBB0_10:
	movl	12(%rbx), %eax
	sarl	$8, %eax
	movl	$130, %ecx
	subl	%r14d, %ecx
	sarl	$4, %ecx
	addl	%eax, %ecx
	xorl	%esi, %esi
	testl	%ecx, %ecx
	cmovgl	%ecx, %esi
	shll	$8, %esi
LBB0_8:
	movq	%rbx, %rdi
	callq	_expo_adjust
	movl	%eax, 12(%rbx)
LBB0_9:
	popq	%rbx
	popq	%r14
	popq	%rbp
	retq
LBB0_13:
	movl	$130, %eax
	subl	%r14d, %eax
	sarl	$6, %eax
LBB0_12:
	addl	12(%rbx), %eax
	xorl	%esi, %esi
	testl	%eax, %eax
	cmovgl	%eax, %esi
	movq	%rbx, %rdi
	callq	_expo_adjust
	movl	%eax, 12(%rbx)
	movq	%rbx, %rdi
	popq	%rbx
	popq	%r14
	popq	%rbp
	jmp	_setredblue                     ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_AG_CNT_START,8,3               ## @AG_CNT_START
	.comm	_D_FRAM,4,2                     ## @D_FRAM
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"mean lum %d\n"

	.comm	_SENSOR_PO2030N,4,2             ## @SENSOR_PO2030N
	.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
	ldr	x8, [x0]
	tbnz	x8, #63, LBB0_2
; %bb.1:
	mov	x19, x0
	sub	x9, x8, #1
	str	x9, [x0]
	cbz	x8, LBB0_3
LBB0_2:
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp], #32             ; 16-byte Folded Reload
	ret
LBB0_3:
Lloh0:
	adrp	x8, _AG_CNT_START@GOTPAGE
Lloh1:
	ldr	x8, [x8, _AG_CNT_START@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	str	x8, [x19]
	add	x0, x19, #16
	bl	_atomic_read
	mov	x20, x0
Lloh3:
	adrp	x8, _D_FRAM@GOTPAGE
Lloh4:
	ldr	x8, [x8, _D_FRAM@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
Lloh6:
	adrp	x2, l_.str@PAGE
Lloh7:
	add	x2, x2, l_.str@PAGEOFF
	mov	x0, x19
	mov	x3, x20
	bl	_gspca_dbg
	ldr	w8, [x19, #8]
Lloh8:
	adrp	x9, _SENSOR_PO2030N@GOTPAGE
Lloh9:
	ldr	x9, [x9, _SENSOR_PO2030N@GOTPAGEOFF]
Lloh10:
	ldr	w9, [x9]
	cmp	w8, w9
	b.ne	LBB0_5
; %bb.4:
	mov	x0, x19
	mov	x1, x20
	mov	w2, #130
	mov	w3, #20
	mov	w4, #15
	mov	w5, #1024
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp], #32             ; 16-byte Folded Reload
	b	_gspca_expo_autogain
LBB0_5:
	sub	w9, w20, #151
	cmn	w9, #42
	b.hi	LBB0_2
; %bb.6:
	sub	w9, w8, #128
	cmp	w9, #2
	b.lo	LBB0_10
; %bb.7:
	cmp	w8, #130
	b.eq	LBB0_11
; %bb.8:
	cmp	w8, #131
	b.ne	LBB0_13
; %bb.9:
	ldr	w8, [x19, #12]
	mov	w9, #130
	sub	w9, w9, w20
	add	w8, w8, w9, asr #6
	cmp	w8, #0
	csel	w1, w8, wzr, gt
	b	LBB0_12
LBB0_10:
	ldr	w8, [x19, #12]
	mov	w9, #130
	sub	w9, w9, w20
	add	w8, w8, w9, asr #2
	b	LBB0_14
LBB0_11:
	ldr	w8, [x19, #12]
	asr	w8, w8, #8
	mov	w9, #130
	sub	w9, w9, w20
	add	w8, w8, w9, asr #4
	cmp	w8, #0
	csel	w8, w8, wzr, gt
	lsl	w1, w8, #8
LBB0_12:
	mov	x0, x19
	bl	_expo_adjust
	str	w0, [x19, #12]
	b	LBB0_2
LBB0_13:
	ldr	w8, [x19, #12]
	mov	w9, #130
	sub	w9, w9, w20
	add	w8, w8, w9, asr #6
LBB0_14:
	cmp	w8, #0
	csel	w1, w8, wzr, gt
	mov	x0, x19
	bl	_expo_adjust
	str	w0, [x19, #12]
	mov	x0, x19
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp], #32             ; 16-byte Folded Reload
	b	_setredblue
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.cfi_endproc
                                        ; -- End function
	.comm	_AG_CNT_START,8,3               ; @AG_CNT_START
	.comm	_D_FRAM,4,2                     ; @D_FRAM
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"mean lum %d\n"

	.comm	_SENSOR_PO2030N,4,2             ; @SENSOR_PO2030N
	.no_dead_strip	_do_autogain
.subsections_via_symbols
