	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_mt76x2_phy_update_channel_gain ## -- Begin function mt76x2_phy_update_channel_gain
	.p2align	4, 0x90
_mt76x2_phy_update_channel_gain:        ## @mt76x2_phy_update_channel_gain
	.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
	subq	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r13
	movq	(%rdi), %rax
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	leaq	32(%rdi), %r14
	movq	%r14, %rdi
	callq	_mt76_get_min_avg_rssi
	testl	%eax, %eax
	movl	$-75, %ebx
	cmovnel	%eax, %ebx
	movl	%ebx, 8(%r13)
	movq	%r13, %rdi
	callq	_mt76x02_get_rssi_gain_thresh
	xorl	%r15d, %r15d
	cmpl	%eax, %ebx
	setg	%r15b
	movl	8(%r13), %ebx
	movq	%r13, %rdi
	callq	_mt76x02_get_low_rssi_gain_thresh
	xorl	%r12d, %r12d
	cmpl	%eax, %ebx
	setg	%r12b
	addl	%r15d, %r12d
	movl	12(%r13), %eax
	movl	%r12d, 12(%r13)
	testl	%eax, %eax
	js	LBB0_4
## %bb.1:
	xorl	%r12d, %eax
	andl	$2, %eax
	jne	LBB0_4
## %bb.2:
	movq	%r13, %rdi
	callq	_mt76x02_phy_adjust_vga_gain
	testq	%rax, %rax
	je	LBB0_14
## %bb.3:
	movq	%r13, %rdi
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_mt76x2_phy_set_gain_val        ## TAILCALL
LBB0_4:
	movq	(%r14), %r15
	movq	_NL80211_CHAN_WIDTH_80@GOTPCREL(%rip), %rax
	movq	(%rax), %rbx
	movq	_RXO@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	$14, %esi
	callq	_MT_BBP
	movq	%r13, %rdi
	movl	%eax, %esi
	cmpq	%rbx, %r15
	jne	LBB0_6
## %bb.5:
	movl	$5636625, %edx                  ## imm = 0x560211
	callq	_mt76_wr
	movq	_AGC@GOTPCREL(%rip), %rbx
	movl	(%rbx), %edi
	movl	$26, %esi
	callq	_MT_BBP
	movq	%r13, %rdi
	movl	%eax, %esi
	callq	_mt76_rr
                                        ## kill: def $eax killed $eax def $rax
	andl	$-16, %eax
	xorl	%ecx, %ecx
	cmpl	$2, %r12d
	setne	%cl
	leal	(%rax,%rcx,2), %r15d
	addl	$3, %r15d
	movl	(%rbx), %edi
	movl	$26, %esi
	callq	_MT_BBP
	movq	%r13, %rdi
	movl	%eax, %esi
	movl	%r15d, %edx
	jmp	LBB0_7
LBB0_6:
	movl	$5637155, %edx                  ## imm = 0x560423
LBB0_7:
	callq	_mt76_wr
	movq	%r13, %rdi
	callq	_mt76x2_has_ext_lna
	xorl	%ecx, %ecx
	testq	%rax, %rax
	sete	%cl
	leaq	10(,%rcx,4), %r15
	movq	40(%r13), %rax
	movq	(%rax), %rax
	movq	_NL80211_BAND_2GHZ@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_8
## %bb.11:
	movl	$555820588, %eax                ## imm = 0x2121262C
	cmpl	$2, %r12d
	movl	$286332182, %r12d               ## imm = 0x11111516
	je	LBB0_12
	jmp	LBB0_10
LBB0_8:
	movl	$134744072, %eax                ## imm = 0x8080808
	cmpl	$2, %r12d
	movl	$134744072, %r12d               ## imm = 0x8080808
	jne	LBB0_9
LBB0_12:
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	movq	_RXO@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	$18, %esi
	callq	_MT_BBP
	movq	%r13, %rdi
	movl	%eax, %esi
	movl	$-268392048, %edx               ## imm = 0xF000A990
	callq	_mt76_wr
	movq	_AGC@GOTPCREL(%rip), %r14
	movl	(%r14), %edi
	movl	$35, %esi
	callq	_MT_BBP
	movq	%r13, %rdi
	movl	%eax, %esi
	movl	$134744072, %edx                ## imm = 0x8080808
	callq	_mt76_wr
	movl	(%r14), %edi
	movl	$37, %esi
	callq	_MT_BBP
	movq	%r13, %rdi
	movl	%eax, %esi
	movl	$134744072, %edx                ## imm = 0x8080808
	callq	_mt76_wr
	movq	$0, 24(%r13)
	jmp	LBB0_13
LBB0_14:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_9:
	movq	(%r14), %rax
	movq	_NL80211_CHAN_WIDTH_80@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	movl	$269488148, %eax                ## imm = 0x10101014
	movl	$286331158, %r12d               ## imm = 0x11111116
	cmovel	%eax, %r12d
LBB0_10:
	movq	_RXO@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movl	$18, %esi
	callq	_MT_BBP
	movq	%r13, %rdi
	movl	%eax, %esi
	movl	$-268392047, %edx               ## imm = 0xF000A991
	callq	_mt76_wr
	movq	%r15, 24(%r13)
	movl	$555820588, -44(%rbp)           ## 4-byte Folded Spill
                                        ## imm = 0x2121262C
	xorl	%r15d, %r15d
LBB0_13:
	movq	-56(%rbp), %rbx                 ## 8-byte Reload
	movq	_AGC@GOTPCREL(%rip), %r14
	movl	(%r14), %edi
	movl	$35, %esi
	callq	_MT_BBP
	movq	%r13, %rdi
	movl	%eax, %esi
	movl	%r12d, %edx
	callq	_mt76_wr
	movl	(%r14), %edi
	movl	$37, %esi
	callq	_MT_BBP
	movq	%r13, %rdi
	movl	%eax, %esi
	movl	-44(%rbp), %edx                 ## 4-byte Reload
	callq	_mt76_wr
	movq	(%rbx), %rax
	subq	%r15, %rax
	movq	16(%r13), %rcx
	movq	%rax, (%rcx)
	movq	8(%rbx), %rax
	subq	%r15, %rax
	movq	16(%r13), %rcx
	movq	%rax, 8(%rcx)
	movq	%r13, %rdi
	callq	_mt76x2_phy_set_gain_val
	movq	_MT_RX_STAT_1@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r13, %rdi
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_mt76_rr                        ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_NL80211_CHAN_WIDTH_80,8,3      ## @NL80211_CHAN_WIDTH_80
	.comm	_RXO,4,2                        ## @RXO
	.comm	_AGC,4,2                        ## @AGC
	.comm	_NL80211_BAND_2GHZ,8,3          ## @NL80211_BAND_2GHZ
	.comm	_MT_RX_STAT_1,4,2               ## @MT_RX_STAT_1
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_mt76x2_phy_update_channel_gain ; -- Begin function mt76x2_phy_update_channel_gain
	.p2align	2
_mt76x2_phy_update_channel_gain:        ; @mt76x2_phy_update_channel_gain
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x19, x0
	ldr	x22, [x0]
	add	x20, x0, #32
	mov	x0, x20
	bl	_mt76_get_min_avg_rssi
	mov	w8, #-75
	cmp	w0, #0
	csel	w21, w8, w0, eq
	str	w21, [x19, #8]
	mov	x0, x19
	bl	_mt76x02_get_rssi_gain_thresh
	cmp	w21, w0
	cset	w21, gt
	ldr	w23, [x19, #8]
	mov	x0, x19
	bl	_mt76x02_get_low_rssi_gain_thresh
	cmp	w23, w0
	cinc	w26, w21, gt
	ldr	w8, [x19, #12]
	str	w26, [x19, #12]
	tbnz	w8, #31, LBB0_4
; %bb.1:
	eor	w8, w26, w8
	tbnz	w8, #1, LBB0_4
; %bb.2:
	mov	x0, x19
	bl	_mt76x02_phy_adjust_vga_gain
	cbz	x0, LBB0_13
; %bb.3:
	mov	x0, x19
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	b	_mt76x2_phy_set_gain_val
LBB0_4:
	ldr	x21, [x20]
Lloh0:
	adrp	x27, _NL80211_CHAN_WIDTH_80@GOTPAGE
Lloh1:
	ldr	x27, [x27, _NL80211_CHAN_WIDTH_80@GOTPAGEOFF]
	ldr	x24, [x27]
Lloh2:
	adrp	x25, _RXO@GOTPAGE
Lloh3:
	ldr	x25, [x25, _RXO@GOTPAGEOFF]
	ldr	w0, [x25]
	mov	w1, #14
	bl	_MT_BBP
	mov	x1, x0
Lloh4:
	adrp	x23, _AGC@GOTPAGE
Lloh5:
	ldr	x23, [x23, _AGC@GOTPAGEOFF]
	cmp	x21, x24
	b.ne	LBB0_6
; %bb.5:
	mov	x0, x19
	mov	w2, #529
	movk	w2, #86, lsl #16
	bl	_mt76_wr
	ldr	w0, [x23]
	mov	w1, #26
	bl	_MT_BBP
	mov	x1, x0
	mov	x0, x19
	bl	_mt76_rr
	and	w8, w0, #0xfffffff0
	mov	w9, #5
	mov	w10, #3
	cmp	w26, #2
	csel	w9, w10, w9, eq
	orr	w21, w8, w9
	ldr	w0, [x23]
	mov	w1, #26
	bl	_MT_BBP
	mov	x1, x0
	mov	x0, x19
	mov	x2, x21
	b	LBB0_7
LBB0_6:
	mov	w8, #529
	movk	w8, #86, lsl #16
	add	w2, w8, #530
	mov	x0, x19
LBB0_7:
	bl	_mt76_wr
	mov	x0, x19
	bl	_mt76x2_has_ext_lna
	mov	w8, #10
	mov	w9, #14
	cmp	x0, #0
	csel	x24, x9, x8, eq
	ldr	x8, [x19, #40]
	ldr	x8, [x8]
Lloh6:
	adrp	x9, _NL80211_BAND_2GHZ@GOTPAGE
Lloh7:
	ldr	x9, [x9, _NL80211_BAND_2GHZ@GOTPAGEOFF]
Lloh8:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_10
; %bb.8:
	mov	w21, #5398
	movk	w21, #4369, lsl #16
	cmp	w26, #2
	b.ne	LBB0_15
; %bb.9:
	mov	w20, #9772
	movk	w20, #8481, lsl #16
	b	LBB0_12
LBB0_10:
	cmp	w26, #2
	b.ne	LBB0_14
; %bb.11:
	mov	w20, #134744072
	mov	w21, #134744072
LBB0_12:
	ldr	w0, [x25]
	mov	w1, #18
	bl	_MT_BBP
	mov	x1, x0
	mov	x0, x19
	mov	w2, #43408
	movk	w2, #61440, lsl #16
	bl	_mt76_wr
	ldr	w0, [x23]
	mov	w1, #35
	bl	_MT_BBP
	mov	x1, x0
	mov	x0, x19
	mov	w2, #134744072
	bl	_mt76_wr
	ldr	w0, [x23]
	mov	w1, #37
	bl	_MT_BBP
	mov	x1, x0
	mov	x0, x19
	mov	w2, #134744072
	bl	_mt76_wr
	str	xzr, [x19, #24]
	b	LBB0_16
LBB0_13:
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
LBB0_14:
	ldr	x8, [x20]
	ldr	x9, [x27]
	mov	w10, #5398
	movk	w10, #4369, lsl #16
	sub	w10, w10, #1024
	cmp	x8, x9
	mov	w8, #4116
	movk	w8, #4112, lsl #16
	csel	w21, w8, w10, eq
LBB0_15:
	mov	w20, #9772
	movk	w20, #8481, lsl #16
	ldr	w0, [x25]
	mov	w1, #18
	bl	_MT_BBP
	mov	x1, x0
	mov	w8, #43408
	movk	w8, #61440, lsl #16
	orr	w2, w8, #0x1
	mov	x0, x19
	bl	_mt76_wr
	str	x24, [x19, #24]
	mov	x24, #0
LBB0_16:
	ldr	w0, [x23]
	mov	w1, #35
	bl	_MT_BBP
	mov	x1, x0
	mov	x0, x19
	mov	x2, x21
	bl	_mt76_wr
	ldr	w0, [x23]
	mov	w1, #37
	bl	_MT_BBP
	mov	x1, x0
	mov	x0, x19
	mov	x2, x20
	bl	_mt76_wr
	ldr	x8, [x22]
	sub	x8, x8, x24
	ldr	x9, [x19, #16]
	str	x8, [x9]
	ldr	x8, [x22, #8]
	sub	x8, x8, x24
	ldr	x9, [x19, #16]
	str	x8, [x9, #8]
	mov	x0, x19
	bl	_mt76x2_phy_set_gain_val
Lloh9:
	adrp	x8, _MT_RX_STAT_1@GOTPAGE
Lloh10:
	ldr	x8, [x8, _MT_RX_STAT_1@GOTPAGEOFF]
Lloh11:
	ldr	w1, [x8]
	mov	x0, x19
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	b	_mt76_rr
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.comm	_NL80211_CHAN_WIDTH_80,8,3      ; @NL80211_CHAN_WIDTH_80
	.comm	_RXO,4,2                        ; @RXO
	.comm	_AGC,4,2                        ; @AGC
	.comm	_NL80211_BAND_2GHZ,8,3          ; @NL80211_BAND_2GHZ
	.comm	_MT_RX_STAT_1,4,2               ; @MT_RX_STAT_1
.subsections_via_symbols
