	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_dib0090_gain_control           ## -- Begin function dib0090_gain_control
	.p2align	4, 0x90
_dib0090_gain_control:                  ## @dib0090_gain_control
	.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	%r13
	pushq	%r12
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	(%rdi), %r12
	movl	(%r12), %eax
	movq	_CT_AGC_START@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jne	LBB0_5
## %bb.1:
	movq	$0, 64(%r12)
	movq	%r12, %rdi
	movl	$4, %esi
	xorl	%edx, %edx
	callq	_dib0090_write_reg
	movq	8(%r12), %rax
	movq	_BAND_CBAND@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	je	LBB0_3
## %bb.2:
	movq	_BAND_VHF@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_7
LBB0_3:
	cmpq	$0, 96(%r12)
	je	LBB0_7
## %bb.4:
	movq	_bb_ramp_pwm_normal_socs@GOTPCREL(%rip), %rbx
	movq	_rf_ramp_pwm_cband_7090p@GOTPCREL(%rip), %rax
	jmp	LBB0_8
LBB0_5:
	movl	$10, %r15d
	movl	$1, %ecx
	cmpq	$0, 64(%r12)
	je	LBB0_14
## %bb.6:
	xorl	%r14d, %r14d
	xorl	%r13d, %r13d
	cmpq	$0, 64(%r12)
	jne	LBB0_13
	jmp	LBB0_12
LBB0_7:
	movq	_bb_ramp_pwm_normal@GOTPCREL(%rip), %rbx
	movq	_rf_ramp_pwm_uhf@GOTPCREL(%rip), %rax
LBB0_8:
	movl	(%rax), %esi
	movq	%r12, %rdi
	callq	_dib0090_set_rframp
	movl	(%rbx), %esi
	movq	%r12, %rdi
	callq	_dib0090_set_bbramp
	xorl	%r14d, %r14d
	movq	%r12, %rdi
	movl	$50, %esi
	xorl	%edx, %edx
	callq	_dib0090_write_reg
	movq	%r12, %rdi
	movl	$57, %esi
	xorl	%edx, %edx
	callq	_dib0090_write_reg
	movl	104(%r12), %esi
	movq	%r12, %rdi
	callq	_dib0090_wbd_target
	movq	24(%r12), %rax
	movq	40(%r12), %rdx
	movl	(%rax), %esi
	movq	_WBD_ALPHA@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	shll	%cl, %esi
	movl	%esi, 16(%r12)
	movl	(%rdx), %ecx
	addl	(%rax), %ecx
	movl	%ecx, %eax
	shrl	$31, %eax
	addl	%ecx, %eax
	sarl	%eax
	movq	_GAIN_ALPHA@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	shll	%cl, %eax
	movl	%eax, 32(%r12)
	movq	_CT_AGC_STEP_0@GOTPCREL(%rip), %rax
LBB0_9:
	xorl	%r13d, %r13d
LBB0_10:
	movl	(%rax), %eax
	movl	%eax, (%r12)
	movl	$10, %r15d
LBB0_11:
	movl	$1, %ecx
	cmpq	$0, 64(%r12)
	jne	LBB0_13
LBB0_12:
	movq	%r12, %rdi
	movq	%r13, %rsi
	movq	%r14, %rdx
	callq	_dib0090_gain_apply
LBB0_13:
	movl	%r15d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_14:
	movq	%rdi, %r13
	movq	%r12, %rdi
	callq	_dib0090_get_slow_adc_val
	movl	(%r12), %eax
	movq	_CT_AGC_STEP_0@GOTPCREL(%rip), %rdx
	xorl	%ecx, %ecx
	cmpl	(%rdx), %eax
	sete	%cl
	leaq	1(,%rcx,4), %r14
	xorl	%ebx, %ebx
	movq	%r14, %rax
	movq	%r14, -48(%rbp)                 ## 8-byte Spill
	.p2align	4, 0x90
LBB0_15:                                ## =>This Inner Loop Header: Depth=1
	movq	%r12, %rdi
	callq	_dib0090_get_slow_adc_val
	movq	%r12, %rdi
	movq	%rax, %rsi
	callq	_dib0090_wbd_to_db
	addq	%rax, %rbx
	decq	%r14
	jne	LBB0_15
## %bb.16:
	movq	%rbx, %rax
	shrq	$32, %rax
	je	LBB0_18
## %bb.17:
	movq	%rbx, %rax
	cqto
	idivq	-48(%rbp)                       ## 8-byte Folded Reload
	jmp	LBB0_19
LBB0_18:
	movl	%ebx, %eax
	xorl	%edx, %edx
	divl	-48(%rbp)                       ## 4-byte Folded Reload
                                        ## kill: def $eax killed $eax def $rax
LBB0_19:
	movq	_CT_AGC_STEP_0@GOTPCREL(%rip), %rcx
	movq	48(%r12), %r14
	subq	%rax, %r14
	movl	(%r12), %eax
	cmpl	(%rcx), %eax
	jne	LBB0_22
## %bb.20:
	testq	%r14, %r14
	js	LBB0_27
LBB0_21:
	movq	$0, 80(%r12)
	movq	_CT_AGC_STEP_1@GOTPCREL(%rip), %rax
	jmp	LBB0_9
LBB0_22:
	movq	88(%r12), %rax
	movq	%r13, %rdi
	callq	*(%rax)
	imull	$355774, %eax, %eax             ## imm = 0x56DBE
	addl	$1048576, %eax                  ## imm = 0x100000
	sarl	$21, %eax
	movq	_ADC_TARGET@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	subl	%eax, %ecx
	movslq	%ecx, %r13
	movl	(%r12), %eax
	movq	_CT_AGC_STEP_1@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jne	LBB0_26
## %bb.23:
	movq	%r13, %rdi
	callq	_abs
	cmpl	$50, %eax
	jl	LBB0_25
## %bb.24:
	movq	80(%r12), %rax
	leaq	1(%rax), %rcx
	movq	%rcx, 80(%r12)
	cmpq	$6, %rax
	jl	LBB0_11
LBB0_25:
	movq	%r12, %rdi
	movl	$2, %esi
	movl	$39328, %edx                    ## imm = 0x99A0
	callq	_dib0090_write_reg
	movq	%r12, %rdi
	movl	$4, %esi
	movl	$1, %edx
	callq	_dib0090_write_reg
	movq	_CT_AGC_STOP@GOTPCREL(%rip), %rax
	jmp	LBB0_10
LBB0_26:
	movl	$100, %r15d
	xorl	%ecx, %ecx
	cmpq	$0, 64(%r12)
	jne	LBB0_13
	jmp	LBB0_12
LBB0_27:
	cmpl	$0, 16(%r12)
	jle	LBB0_21
## %bb.28:
	cmpq	$0, 96(%r12)
	jne	LBB0_21
## %bb.29:
	xorl	%r13d, %r13d
	jmp	LBB0_11
	.cfi_endproc
                                        ## -- End function
	.comm	_CT_AGC_START,4,2               ## @CT_AGC_START
	.comm	_BAND_CBAND,8,3                 ## @BAND_CBAND
	.comm	_BAND_VHF,8,3                   ## @BAND_VHF
	.comm	_rf_ramp_pwm_cband_7090p,4,2    ## @rf_ramp_pwm_cband_7090p
	.comm	_bb_ramp_pwm_normal_socs,4,2    ## @bb_ramp_pwm_normal_socs
	.comm	_rf_ramp_pwm_uhf,4,2            ## @rf_ramp_pwm_uhf
	.comm	_bb_ramp_pwm_normal,4,2         ## @bb_ramp_pwm_normal
	.comm	_WBD_ALPHA,4,2                  ## @WBD_ALPHA
	.comm	_GAIN_ALPHA,4,2                 ## @GAIN_ALPHA
	.comm	_CT_AGC_STEP_0,4,2              ## @CT_AGC_STEP_0
	.comm	_CT_AGC_STEP_1,4,2              ## @CT_AGC_STEP_1
	.comm	_ADC_TARGET,8,3                 ## @ADC_TARGET
	.comm	_CT_AGC_STOP,4,2                ## @CT_AGC_STOP
	.comm	_BAND_SBAND,8,3                 ## @BAND_SBAND
	.comm	_QAM_16,8,3                     ## @QAM_16
	.comm	_QAM_64,8,3                     ## @QAM_64
	.comm	_STANDARD_DAB,8,3               ## @STANDARD_DAB
	.comm	_STANDARD_DVBT,8,3              ## @STANDARD_DVBT
	.comm	_SYS_ISDBT,8,3                  ## @SYS_ISDBT
	.comm	_bb_ramp_boost,4,2              ## @bb_ramp_boost
	.comm	_rf_ramp_pwm_cband,4,2          ## @rf_ramp_pwm_cband
	.comm	_rf_ramp_pwm_vhf,4,2            ## @rf_ramp_pwm_vhf
	.comm	_rf_ramp_sband,4,2              ## @rf_ramp_sband
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_dib0090_gain_control           ; -- Begin function dib0090_gain_control
	.p2align	2
_dib0090_gain_control:                  ; @dib0090_gain_control
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	ldr	x19, [x0]
	ldr	w8, [x19]
Lloh0:
	adrp	x9, _CT_AGC_START@GOTPAGE
Lloh1:
	ldr	x9, [x9, _CT_AGC_START@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x9]
	cmp	w8, w9
	b.ne	LBB0_4
; %bb.1:
	str	xzr, [x19, #64]
	mov	x0, x19
	mov	w1, #4
	mov	w2, #0
	bl	_dib0090_write_reg
	ldr	x8, [x19, #8]
Lloh3:
	adrp	x9, _BAND_CBAND@GOTPAGE
Lloh4:
	ldr	x9, [x9, _BAND_CBAND@GOTPAGEOFF]
Lloh5:
	ldr	x9, [x9]
Lloh6:
	adrp	x10, _BAND_VHF@GOTPAGE
Lloh7:
	ldr	x10, [x10, _BAND_VHF@GOTPAGEOFF]
Lloh8:
	ldr	x10, [x10]
	cmp	x8, x9
	ccmp	x8, x10, #4, ne
	b.ne	LBB0_6
; %bb.2:
	ldr	x8, [x19, #96]
	cbz	x8, LBB0_6
; %bb.3:
Lloh9:
	adrp	x20, _bb_ramp_pwm_normal_socs@GOTPAGE
Lloh10:
	ldr	x20, [x20, _bb_ramp_pwm_normal_socs@GOTPAGEOFF]
Lloh11:
	adrp	x8, _rf_ramp_pwm_cband_7090p@GOTPAGE
Lloh12:
	ldr	x8, [x8, _rf_ramp_pwm_cband_7090p@GOTPAGEOFF]
	b	LBB0_7
LBB0_4:
	ldr	x8, [x19, #64]
	cbz	x8, LBB0_12
; %bb.5:
	mov	x20, #0
	mov	x21, #0
	b	LBB0_9
LBB0_6:
Lloh13:
	adrp	x20, _bb_ramp_pwm_normal@GOTPAGE
Lloh14:
	ldr	x20, [x20, _bb_ramp_pwm_normal@GOTPAGEOFF]
Lloh15:
	adrp	x8, _rf_ramp_pwm_uhf@GOTPAGE
Lloh16:
	ldr	x8, [x8, _rf_ramp_pwm_uhf@GOTPAGEOFF]
LBB0_7:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_dib0090_set_rframp
	ldr	w1, [x20]
	mov	x0, x19
	bl	_dib0090_set_bbramp
	mov	x0, x19
	mov	w1, #50
	mov	w2, #0
	bl	_dib0090_write_reg
	mov	x0, x19
	mov	w1, #57
	mov	w2, #0
	bl	_dib0090_write_reg
	ldr	w1, [x19, #104]
	mov	x0, x19
	bl	_dib0090_wbd_target
	mov	x20, #0
	mov	x21, #0
	ldr	x8, [x19, #24]
Lloh17:
	adrp	x9, _WBD_ALPHA@GOTPAGE
Lloh18:
	ldr	x9, [x9, _WBD_ALPHA@GOTPAGEOFF]
	ldr	w10, [x8]
Lloh19:
	ldr	w9, [x9]
	lsl	w9, w10, w9
	str	w9, [x19, #16]
	ldr	w8, [x8]
	ldr	x9, [x19, #40]
	ldr	w9, [x9]
	add	w8, w9, w8
	cmp	w8, #0
	cinc	w8, w8, lt
Lloh20:
	adrp	x9, _GAIN_ALPHA@GOTPAGE
Lloh21:
	ldr	x9, [x9, _GAIN_ALPHA@GOTPAGEOFF]
	asr	w8, w8, #1
Lloh22:
	ldr	w9, [x9]
	lsl	w8, w8, w9
	str	w8, [x19, #32]
Lloh23:
	adrp	x8, _CT_AGC_STEP_0@GOTPAGE
Lloh24:
	ldr	x8, [x8, _CT_AGC_STEP_0@GOTPAGEOFF]
LBB0_8:
	ldr	w8, [x8]
	str	w8, [x19]
LBB0_9:
	mov	w22, #10
	mov	w3, #1
	ldr	x8, [x19, #64]
	cbnz	x8, LBB0_11
LBB0_10:
	mov	x0, x19
	mov	x1, x21
	mov	x2, x20
	bl	_dib0090_gain_apply
LBB0_11:
	mov	x0, x22
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
LBB0_12:
	mov	x21, x0
	mov	x0, x19
	bl	_dib0090_get_slow_adc_val
	ldr	w23, [x19]
Lloh25:
	adrp	x22, _CT_AGC_STEP_0@GOTPAGE
Lloh26:
	ldr	x22, [x22, _CT_AGC_STEP_0@GOTPAGEOFF]
	ldr	w24, [x22]
	mov	x0, x19
	bl	_dib0090_get_slow_adc_val
	mov	x1, x0
	mov	x0, x19
	bl	_dib0090_wbd_to_db
	mov	x20, x0
	mov	w8, #5
	cmp	w23, w24
	csinc	x23, x8, xzr, eq
	b.ne	LBB0_14
; %bb.13:
	mov	x0, x19
	bl	_dib0090_get_slow_adc_val
	mov	x1, x0
	mov	x0, x19
	bl	_dib0090_wbd_to_db
	add	x20, x0, x20
	mov	x0, x19
	bl	_dib0090_get_slow_adc_val
	mov	x1, x0
	mov	x0, x19
	bl	_dib0090_wbd_to_db
	add	x20, x0, x20
	mov	x0, x19
	bl	_dib0090_get_slow_adc_val
	mov	x1, x0
	mov	x0, x19
	bl	_dib0090_wbd_to_db
	add	x20, x0, x20
	mov	x0, x19
	bl	_dib0090_get_slow_adc_val
	mov	x1, x0
	mov	x0, x19
	bl	_dib0090_wbd_to_db
	add	x20, x0, x20
LBB0_14:
	sdiv	x8, x20, x23
	ldr	x9, [x19, #48]
	sub	x20, x9, x8
	ldr	w8, [x19]
	ldr	w9, [x22]
	cmp	w8, w9
	b.ne	LBB0_17
; %bb.15:
	tbnz	x20, #63, LBB0_22
LBB0_16:
	mov	x21, #0
	str	xzr, [x19, #80]
Lloh27:
	adrp	x8, _CT_AGC_STEP_1@GOTPAGE
Lloh28:
	ldr	x8, [x8, _CT_AGC_STEP_1@GOTPAGEOFF]
	b	LBB0_8
LBB0_17:
	ldr	x8, [x19, #88]
	ldr	x8, [x8]
	mov	x0, x21
	blr	x8
	mov	w8, #28094
	movk	w8, #5, lsl #16
	orr	w9, wzr, #0x100000
	madd	w8, w0, w8, w9
Lloh29:
	adrp	x9, _ADC_TARGET@GOTPAGE
Lloh30:
	ldr	x9, [x9, _ADC_TARGET@GOTPAGEOFF]
Lloh31:
	ldr	w9, [x9]
	sub	w8, w9, w8, asr #21
	sxtw	x21, w8
	ldr	w8, [x19]
Lloh32:
	adrp	x9, _CT_AGC_STEP_1@GOTPAGE
Lloh33:
	ldr	x9, [x9, _CT_AGC_STEP_1@GOTPAGEOFF]
Lloh34:
	ldr	w9, [x9]
	cmp	w8, w9
	b.ne	LBB0_21
; %bb.18:
	mov	x0, x21
	bl	_abs
	cmp	w0, #50
	b.lt	LBB0_20
; %bb.19:
	ldr	x8, [x19, #80]
	add	x9, x8, #1
	str	x9, [x19, #80]
	cmp	x8, #6
	b.lt	LBB0_9
LBB0_20:
	mov	x0, x19
	mov	w1, #2
	mov	w2, #39328
	bl	_dib0090_write_reg
	mov	x0, x19
	mov	w1, #4
	mov	w2, #1
	bl	_dib0090_write_reg
Lloh35:
	adrp	x8, _CT_AGC_STOP@GOTPAGE
Lloh36:
	ldr	x8, [x8, _CT_AGC_STOP@GOTPAGEOFF]
	b	LBB0_8
LBB0_21:
	mov	w3, #0
	mov	w22, #100
	ldr	x8, [x19, #64]
	cbnz	x8, LBB0_11
	b	LBB0_10
LBB0_22:
	ldr	w8, [x19, #16]
	cmp	w8, #1
	b.lt	LBB0_16
; %bb.23:
	ldr	x8, [x19, #96]
	cbnz	x8, LBB0_16
; %bb.24:
	mov	x21, #0
	b	LBB0_9
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh11, Lloh12
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh15, Lloh16
	.loh AdrpLdrGot	Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh23, Lloh24
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGot	Lloh25, Lloh26
	.loh AdrpLdrGot	Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.loh AdrpLdrGotLdr	Lloh29, Lloh30, Lloh31
	.loh AdrpLdrGot	Lloh35, Lloh36
	.cfi_endproc
                                        ; -- End function
	.comm	_CT_AGC_START,4,2               ; @CT_AGC_START
	.comm	_BAND_CBAND,8,3                 ; @BAND_CBAND
	.comm	_BAND_VHF,8,3                   ; @BAND_VHF
	.comm	_rf_ramp_pwm_cband_7090p,4,2    ; @rf_ramp_pwm_cband_7090p
	.comm	_bb_ramp_pwm_normal_socs,4,2    ; @bb_ramp_pwm_normal_socs
	.comm	_rf_ramp_pwm_uhf,4,2            ; @rf_ramp_pwm_uhf
	.comm	_bb_ramp_pwm_normal,4,2         ; @bb_ramp_pwm_normal
	.comm	_WBD_ALPHA,4,2                  ; @WBD_ALPHA
	.comm	_GAIN_ALPHA,4,2                 ; @GAIN_ALPHA
	.comm	_CT_AGC_STEP_0,4,2              ; @CT_AGC_STEP_0
	.comm	_CT_AGC_STEP_1,4,2              ; @CT_AGC_STEP_1
	.comm	_ADC_TARGET,8,3                 ; @ADC_TARGET
	.comm	_CT_AGC_STOP,4,2                ; @CT_AGC_STOP
	.comm	_BAND_SBAND,8,3                 ; @BAND_SBAND
	.comm	_QAM_16,8,3                     ; @QAM_16
	.comm	_QAM_64,8,3                     ; @QAM_64
	.comm	_STANDARD_DAB,8,3               ; @STANDARD_DAB
	.comm	_STANDARD_DVBT,8,3              ; @STANDARD_DVBT
	.comm	_SYS_ISDBT,8,3                  ; @SYS_ISDBT
	.comm	_bb_ramp_boost,4,2              ; @bb_ramp_boost
	.comm	_rf_ramp_pwm_cband,4,2          ; @rf_ramp_pwm_cband
	.comm	_rf_ramp_pwm_vhf,4,2            ; @rf_ramp_pwm_vhf
	.comm	_rf_ramp_sband,4,2              ; @rf_ramp_sband
.subsections_via_symbols
