	.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_8
## %bb.1:
	movq	%rdi, %rbx
	subq	$1, %rax
	movq	%rax, (%rdi)
	jae	LBB0_8
## %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), %edi
	leaq	L_.str(%rip), %rsi
	movl	%r14d, %edx
	callq	_PDEBUG
	leal	-151(%r14), %eax
	cmpl	$-42, %eax
	ja	LBB0_8
## %bb.3:
	movl	8(%rbx), %eax
	cmpl	$128, %eax
	je	LBB0_10
## %bb.4:
	cmpl	$129, %eax
	je	LBB0_9
## %bb.5:
	cmpl	$130, %eax
	jne	LBB0_12
## %bb.6:
	movl	$130, %eax
	subl	%r14d, %eax
	sarl	$6, %eax
	addl	12(%rbx), %eax
	xorl	%esi, %esi
	testl	%eax, %eax
	cmovgl	%eax, %esi
	jmp	LBB0_7
LBB0_10:
	movl	$130, %eax
	subl	%r14d, %eax
	sarl	$2, %eax
	jmp	LBB0_11
LBB0_9:
	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_7:
	movq	%rbx, %rdi
	callq	_setexposure
	movl	%eax, 12(%rbx)
LBB0_8:
	popq	%rbx
	popq	%r14
	popq	%rbp
	retq
LBB0_12:
	movl	$130, %eax
	subl	%r14d, %eax
	sarl	$6, %eax
LBB0_11:
	addl	12(%rbx), %eax
	xorl	%esi, %esi
	testl	%eax, %eax
	cmovgl	%eax, %esi
	movq	%rbx, %rdi
	callq	_setexposure
	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"

	.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_10
; %bb.1:
	mov	x19, x0
	sub	x9, x8, #1
	str	x9, [x0]
	cbnz	x8, LBB0_10
; %bb.2:
Lloh0:
	adrp	x8, _AG_CNT_START@GOTPAGE
Lloh1:
	ldr	x8, [x8, _AG_CNT_START@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	mov	x0, x19
	str	x8, [x0], #16
	bl	_atomic_read
	mov	x20, x0
Lloh3:
	adrp	x8, _D_FRAM@GOTPAGE
Lloh4:
	ldr	x8, [x8, _D_FRAM@GOTPAGEOFF]
Lloh5:
	ldr	w0, [x8]
Lloh6:
	adrp	x1, l_.str@PAGE
Lloh7:
	add	x1, x1, l_.str@PAGEOFF
	mov	x2, x20
	bl	_PDEBUG
	sub	w8, w20, #151
	cmn	w8, #42
	b.hi	LBB0_10
; %bb.3:
	ldr	w8, [x19, #8]
	cmp	w8, #128
	b.eq	LBB0_7
; %bb.4:
	cmp	w8, #129
	b.eq	LBB0_8
; %bb.5:
	cmp	w8, #130
	b.ne	LBB0_11
; %bb.6:
	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_9
LBB0_7:
	ldr	w8, [x19, #12]
	mov	w9, #130
	sub	w9, w9, w20
	add	w8, w8, w9, asr #2
	b	LBB0_12
LBB0_8:
	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_9:
	mov	x0, x19
	bl	_setexposure
	str	w0, [x19, #12]
LBB0_10:
	ldp	x29, x30, [sp, #16]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp], #32             ; 16-byte Folded Reload
	ret
LBB0_11:
	ldr	w8, [x19, #12]
	mov	w9, #130
	sub	w9, w9, w20
	add	w8, w8, w9, asr #6
LBB0_12:
	cmp	w8, #0
	csel	w1, w8, wzr, gt
	mov	x0, x19
	bl	_setexposure
	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 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"

	.no_dead_strip	_do_autogain
.subsections_via_symbols
