	.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	8(%rdi), %rbx
	movl	(%rbx), %eax
	movq	_CT_AGC_START@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jne	LBB0_4
## %bb.1:
	movq	$0, 64(%rbx)
	xorl	%r14d, %r14d
	movq	%rbx, %rdi
	movl	$4, %esi
	xorl	%edx, %edx
	callq	_dib0090_write_reg
	movq	_rf_ramp_uhf@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	callq	_dib0090_set_rframp
	movq	_bb_ramp_boost@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	callq	_dib0090_set_bbramp
	movq	%rbx, %rdi
	movl	$50, %esi
	xorl	%edx, %edx
	callq	_dib0090_write_reg
	movq	%rbx, %rdi
	movl	$57, %esi
	xorl	%edx, %edx
	callq	_dib0090_write_reg
	movl	96(%rbx), %esi
	movq	%rbx, %rdi
	callq	_dib0090_wbd_target
	movq	24(%rbx), %rax
	movq	40(%rbx), %rdx
	movl	(%rax), %esi
	movq	_WBD_ALPHA@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	shll	%cl, %esi
	movl	%esi, 16(%rbx)
	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(%rbx)
	movq	_CT_AGC_STEP_0@GOTPCREL(%rip), %rax
LBB0_2:
	xorl	%r13d, %r13d
LBB0_3:
	movl	(%rax), %eax
	movl	%eax, (%rbx)
	movl	$10, %r15d
	movl	$1, %r12d
	jmp	LBB0_7
LBB0_4:
	movl	$10, %r15d
	movl	$1, %r12d
	cmpq	$0, 64(%rbx)
	je	LBB0_10
## %bb.5:
	xorl	%r14d, %r14d
LBB0_6:
	xorl	%r13d, %r13d
LBB0_7:
	cmpq	$0, 64(%rbx)
	jne	LBB0_9
## %bb.8:
	movq	%rbx, %rdi
	movq	%r13, %rsi
	movq	%r14, %rdx
	movl	%r12d, %ecx
	callq	_dib0090_gain_apply
LBB0_9:
	movl	%r15d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_10:
	movq	%rdi, %r13
	movq	%rbx, %rdi
	movl	$29, %esi
	callq	_dib0090_read_reg
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_dib0090_wbd_to_db
	movq	48(%rbx), %r14
	subq	%rax, %r14
	movl	(%rbx), %eax
	movq	_CT_AGC_STEP_0@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jne	LBB0_13
## %bb.11:
	testq	%r14, %r14
	js	LBB0_18
LBB0_12:
	movq	$0, 80(%rbx)
	movq	_CT_AGC_STEP_1@GOTPCREL(%rip), %rax
	jmp	LBB0_2
LBB0_13:
	movq	88(%rbx), %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	(%rbx), %eax
	movq	_CT_AGC_STEP_1@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %eax
	jne	LBB0_17
## %bb.14:
	movq	%r13, %rdi
	callq	_ABS
	cmpl	$50, %eax
	jl	LBB0_16
## %bb.15:
	movq	80(%rbx), %rax
	leaq	1(%rax), %rcx
	movq	%rcx, 80(%rbx)
	cmpq	$6, %rax
	jl	LBB0_7
LBB0_16:
	movq	%rbx, %rdi
	movl	$2, %esi
	movl	$39328, %edx                    ## imm = 0x99A0
	callq	_dib0090_write_reg
	movq	%rbx, %rdi
	movl	$4, %esi
	movl	$1, %edx
	callq	_dib0090_write_reg
	movq	_CT_AGC_STOP@GOTPCREL(%rip), %rax
	jmp	LBB0_3
LBB0_17:
	movl	$100, %r15d
	xorl	%r12d, %r12d
	jmp	LBB0_7
LBB0_18:
	cmpl	$0, 16(%rbx)
	jg	LBB0_6
	jmp	LBB0_12
	.cfi_endproc
                                        ## -- End function
	.comm	_CT_AGC_START,4,2               ## @CT_AGC_START
	.comm	_rf_ramp_uhf,4,2                ## @rf_ramp_uhf
	.comm	_bb_ramp_boost,4,2              ## @bb_ramp_boost
	.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_CBAND,8,3                 ## @BAND_CBAND
	.comm	_BAND_SBAND,8,3                 ## @BAND_SBAND
	.comm	_BAND_VHF,8,3                   ## @BAND_VHF
	.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	_rf_ramp_cband,4,2              ## @rf_ramp_cband
	.comm	_rf_ramp_sband,4,2              ## @rf_ramp_sband
	.comm	_rf_ramp_vhf,4,2                ## @rf_ramp_vhf
.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	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	x19, [x0, #8]
	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_3
; %bb.1:
	str	xzr, [x19, #64]
	mov	x0, x19
	mov	w1, #4
	mov	w2, #0
	bl	_dib0090_write_reg
Lloh3:
	adrp	x8, _rf_ramp_uhf@GOTPAGE
Lloh4:
	ldr	x8, [x8, _rf_ramp_uhf@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_dib0090_set_rframp
Lloh6:
	adrp	x8, _bb_ramp_boost@GOTPAGE
Lloh7:
	ldr	x8, [x8, _bb_ramp_boost@GOTPAGEOFF]
Lloh8:
	ldr	w1, [x8]
	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, #96]
	mov	x0, x19
	bl	_dib0090_wbd_target
	mov	x20, #0
	mov	x21, #0
	ldr	x8, [x19, #24]
Lloh9:
	adrp	x9, _WBD_ALPHA@GOTPAGE
Lloh10:
	ldr	x9, [x9, _WBD_ALPHA@GOTPAGEOFF]
	ldr	w10, [x8]
Lloh11:
	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
Lloh12:
	adrp	x9, _GAIN_ALPHA@GOTPAGE
Lloh13:
	ldr	x9, [x9, _GAIN_ALPHA@GOTPAGEOFF]
	asr	w8, w8, #1
Lloh14:
	ldr	w9, [x9]
	lsl	w8, w8, w9
	str	w8, [x19, #32]
Lloh15:
	adrp	x8, _CT_AGC_STEP_0@GOTPAGE
Lloh16:
	ldr	x8, [x8, _CT_AGC_STEP_0@GOTPAGEOFF]
LBB0_2:
	ldr	w8, [x8]
	str	w8, [x19]
	b	LBB0_6
LBB0_3:
	ldr	x8, [x19, #64]
	cbz	x8, LBB0_9
; %bb.4:
	mov	x20, #0
LBB0_5:
	mov	x21, #0
LBB0_6:
	mov	w22, #10
	mov	w3, #1
	ldr	x8, [x19, #64]
	cbnz	x8, LBB0_8
LBB0_7:
	mov	x0, x19
	mov	x1, x21
	mov	x2, x20
	bl	_dib0090_gain_apply
LBB0_8:
	mov	x0, x22
	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
LBB0_9:
	mov	x21, x0
	mov	x0, x19
	mov	w1, #29
	bl	_dib0090_read_reg
	mov	x1, x0
	mov	x0, x19
	bl	_dib0090_wbd_to_db
	ldr	x8, [x19, #48]
	sub	x20, x8, x0
	ldr	w8, [x19]
Lloh17:
	adrp	x9, _CT_AGC_STEP_0@GOTPAGE
Lloh18:
	ldr	x9, [x9, _CT_AGC_STEP_0@GOTPAGEOFF]
Lloh19:
	ldr	w9, [x9]
	cmp	w8, w9
	b.ne	LBB0_12
; %bb.10:
	tbnz	x20, #63, LBB0_17
LBB0_11:
	mov	x21, #0
	str	xzr, [x19, #80]
Lloh20:
	adrp	x8, _CT_AGC_STEP_1@GOTPAGE
Lloh21:
	ldr	x8, [x8, _CT_AGC_STEP_1@GOTPAGEOFF]
	b	LBB0_2
LBB0_12:
	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
Lloh22:
	adrp	x9, _ADC_TARGET@GOTPAGE
Lloh23:
	ldr	x9, [x9, _ADC_TARGET@GOTPAGEOFF]
Lloh24:
	ldr	w9, [x9]
	sub	w8, w9, w8, asr #21
	sxtw	x21, w8
	ldr	w8, [x19]
Lloh25:
	adrp	x9, _CT_AGC_STEP_1@GOTPAGE
Lloh26:
	ldr	x9, [x9, _CT_AGC_STEP_1@GOTPAGEOFF]
Lloh27:
	ldr	w9, [x9]
	cmp	w8, w9
	b.ne	LBB0_16
; %bb.13:
	mov	x0, x21
	bl	_ABS
	cmp	w0, #50
	b.lt	LBB0_15
; %bb.14:
	ldr	x8, [x19, #80]
	add	x9, x8, #1
	str	x9, [x19, #80]
	cmp	x8, #6
	b.lt	LBB0_6
LBB0_15:
	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
Lloh28:
	adrp	x8, _CT_AGC_STOP@GOTPAGE
Lloh29:
	ldr	x8, [x8, _CT_AGC_STOP@GOTPAGEOFF]
	b	LBB0_2
LBB0_16:
	mov	w3, #0
	mov	w22, #100
	ldr	x8, [x19, #64]
	cbnz	x8, LBB0_8
	b	LBB0_7
LBB0_17:
	ldr	w8, [x19, #16]
	cmp	w8, #0
	b.gt	LBB0_5
	b	LBB0_11
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGot	Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh25, Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpLdrGot	Lloh28, Lloh29
	.cfi_endproc
                                        ; -- End function
	.comm	_CT_AGC_START,4,2               ; @CT_AGC_START
	.comm	_rf_ramp_uhf,4,2                ; @rf_ramp_uhf
	.comm	_bb_ramp_boost,4,2              ; @bb_ramp_boost
	.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_CBAND,8,3                 ; @BAND_CBAND
	.comm	_BAND_SBAND,8,3                 ; @BAND_SBAND
	.comm	_BAND_VHF,8,3                   ; @BAND_VHF
	.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	_rf_ramp_cband,4,2              ; @rf_ramp_cband
	.comm	_rf_ramp_sband,4,2              ; @rf_ramp_sband
	.comm	_rf_ramp_vhf,4,2                ; @rf_ramp_vhf
.subsections_via_symbols
