	.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_4
## %bb.1:
	movq	%rdi, %rbx
	subq	$1, %rax
	movq	%rax, (%rdi)
	jae	LBB0_4
## %bb.2:
	movq	_AG_CNT_START@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, (%rbx)
	cmpl	$128, 8(%rbx)
	jne	LBB0_4
## %bb.3:
	movq	%rbx, %rdi
	movl	$34337, %esi                    ## imm = 0x8621
	movl	$1, %edx
	callq	_reg_r
	movq	(%rbx), %rax
	movl	(%rax), %r15d
	movq	%rbx, %rdi
	movl	$34338, %esi                    ## imm = 0x8622
	movl	$1, %edx
	callq	_reg_r
	movq	(%rbx), %rax
	imull	$77, (%rax), %r14d
	movq	%rbx, %rdi
	movl	$34339, %esi                    ## imm = 0x8623
	movl	$1, %edx
	callq	_reg_r
	movq	(%rbx), %rax
	movl	(%rax), %r12d
	movq	%rbx, %rdi
	movl	$34340, %esi                    ## imm = 0x8624
	movl	$1, %edx
	callq	_reg_r
	movq	(%rbx), %rax
	addl	(%rax), %r15d
	imull	$75, %r15d, %eax
	leal	(%r12,%r12,8), %ecx
	leal	(%rcx,%rcx,2), %r15d
	addl	%r12d, %r15d
	addl	%r12d, %r15d
	addl	%r14d, %r15d
	leal	(%rax,%r15), %ecx
	addl	$-33536, %ecx                   ## imm = 0xFFFF7D00
	cmpl	$-10497, %ecx                   ## imm = 0xD6FF
	ja	LBB0_4
## %bb.5:
	addl	%eax, %r15d
	sarl	$8, %r15d
	movq	%rbx, %rdi
	movl	$9, %esi
	movl	$16, %edx
	callq	_i2c_read
	movl	%eax, %r14d
	andl	$2047, %r14d                    ## imm = 0x7FF
	movq	%rbx, %rdi
	movl	$53, %esi
	movl	$16, %edx
	callq	_i2c_read
	movl	$110, %r12d
	subl	%r15d, %r12d
	movslq	%r12d, %rcx
	sarl	$4, %r12d
	addl	%r14d, %r12d
	imulq	$1374389535, %rcx, %rcx         ## imm = 0x51EB851F
	movq	%rcx, %rdx
	shrq	$63, %rdx
	sarq	$36, %rcx
	addl	%edx, %ecx
	addl	%eax, %ecx
	cmpl	$4, %ecx
	movl	$3, %r14d
	cmovll	%r14d, %ecx
	cmpl	$63, %ecx
	movl	$63, %esi
	cmovll	%ecx, %esi
	movq	%rbx, %rdi
	movl	$53, %edx
	callq	_i2c_write
	cmpl	$4, %r12d
	cmovgel	%r12d, %r14d
	orl	$2048, %r14d                    ## imm = 0x800
	cmpl	$599, %r12d                     ## imm = 0x257
	movl	$2646, %esi                     ## imm = 0xA56
	cmovll	%r14d, %esi
	movq	%rbx, %rdi
	movl	$9, %edx
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_i2c_write                      ## TAILCALL
LBB0_4:
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_AG_CNT_START,8,3               ## @AG_CNT_START
	.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_5
; %bb.1:
	mov	x19, x0
	sub	x9, x8, #1
	str	x9, [x0]
	cbnz	x8, LBB0_5
; %bb.2:
Lloh0:
	adrp	x8, _AG_CNT_START@GOTPAGE
Lloh1:
	ldr	x8, [x8, _AG_CNT_START@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	str	x8, [x19]
	ldr	w8, [x19, #8]
	cmp	w8, #128
	b.ne	LBB0_5
; %bb.3:
	mov	x0, x19
	mov	w1, #34337
	mov	w2, #1
	bl	_reg_r
	ldr	x8, [x19]
	ldr	w20, [x8]
	mov	x0, x19
	mov	w1, #34338
	mov	w2, #1
	bl	_reg_r
	ldr	x8, [x19]
	ldr	w21, [x8]
	mov	x0, x19
	mov	w1, #34339
	mov	w2, #1
	bl	_reg_r
	ldr	x8, [x19]
	ldr	w22, [x8]
	mov	x0, x19
	mov	w1, #34340
	mov	w2, #1
	bl	_reg_r
	ldr	x8, [x19]
	ldr	w8, [x8]
	mov	w9, #77
	mul	w9, w21, w9
	add	w8, w8, w20
	mov	w10, #75
	mov	w11, #29
	madd	w9, w22, w11, w9
	madd	w20, w8, w10, w9
	mov	w8, #-33536
	mov	w9, #-10497
	add	w8, w20, w8
	cmp	w8, w9
	b.hi	LBB0_5
; %bb.4:
	mov	x0, x19
	mov	w1, #9
	mov	w2, #16
	bl	_i2c_read
	and	w21, w0, #0x7ff
	mov	x0, x19
	mov	w1, #53
	mov	w2, #16
	bl	_i2c_read
	mov	w8, #110
	sub	w8, w8, w20, asr #8
	add	w20, w21, w8, asr #4
	mov	w9, #34079
	movk	w9, #20971, lsl #16
	smull	x8, w8, w9
	lsr	x9, x8, #63
	asr	x8, x8, #36
	add	w8, w8, w9
	add	w8, w0, w8
	mov	w21, #3
	cmp	w8, #3
	csel	w8, w8, w21, gt
	mov	w9, #63
	cmp	w8, #63
	csel	w1, w8, w9, lt
	mov	x0, x19
	mov	w2, #53
	bl	_i2c_write
	cmp	w20, #3
	csel	w8, w20, w21, gt
	orr	w8, w8, #0x800
	mov	w9, #2646
	cmp	w20, #598
	csel	w1, w9, w8, gt
	mov	x0, x19
	mov	w2, #9
	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	_i2c_write
LBB0_5:
	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 AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.cfi_endproc
                                        ; -- End function
	.comm	_AG_CNT_START,8,3               ; @AG_CNT_START
	.no_dead_strip	_do_autogain
.subsections_via_symbols
