	.file	"extr_ar9003_calib.c_ar9003_hw_tx_iq_cal_outlier_detection.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	ar9003_hw_tx_iq_cal_outlier_detection, @function
ar9003_hw_tx_iq_cal_outlier_detection:
.LFB0:
	.cfi_startproc
	endbr64
	push	rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	mov	rbp, rsp
	.cfi_def_cfa_register 6
	push	r15
	push	r14
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	mov	r14, rsi
	push	r13
	push	r12
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	mov	r12, rdi
	push	rbx
	sub	rsp, 88
	.cfi_offset 3, -56
	mov	DWORD PTR -124[rbp], edx
	movsx	rcx, DWORD PTR MAX_MEASUREMENT[rip]
	mov	rdi, rsp
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR -56[rbp], rax
	xor	eax, eax
	movsx	rax, DWORD PTR AR9300_MAX_CHAINS[rip]
	lea	rsi, 0[0+rax*4]
	mov	rdx, rax
	imul	rax, rcx
	mov	QWORD PTR -80[rbp], rsi
	mov	rsi, rcx
	lea	rax, 15[0+rax*4]
	mov	rcx, rax
	and	rax, -4096
	sub	rdi, rax
	and	rcx, -16
	mov	rax, rdi
	cmp	rsp, rax
	je	.L3
.L49:
	sub	rsp, 4096
	or	QWORD PTR 4088[rsp], 0
	cmp	rsp, rax
	jne	.L49
.L3:
	and	ecx, 4095
	sub	rsp, rcx
	test	rcx, rcx
	jne	.L50
.L4:
	imul	edx, esi
	mov	rdi, rsp
	xor	esi, esi
	mov	r15, QWORD PTR 8[r12]
	mov	QWORD PTR -96[rbp], rdi
	xor	r13d, r13d
	sal	edx, 2
	call	memset@PLT
	mov	rax, QWORD PTR -80[rbp]
	shr	rax, 2
	cmp	DWORD PTR MAX_MEASUREMENT[rip], 1
	mov	QWORD PTR -72[rbp], rax
	jle	.L10
	mov	QWORD PTR -88[rbp], r15
	mov	r15d, r13d
	mov	r13, QWORD PTR -96[rbp]
	mov	QWORD PTR -104[rbp], r14
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L8:
	mov	ecx, DWORD PTR MAX_MEASUREMENT[rip]
	add	r15d, 1
	mov	eax, ecx
	shr	eax, 31
	add	eax, ecx
	sar	eax
	cmp	eax, r15d
	jle	.L51
.L9:
	mov	edi, r15d
	lea	ebx, [r15+r15]
	call	AR_PHY_TX_IQCAL_CORR_COEFF_B0@PLT
	mov	rdx, QWORD PTR -72[rbp]
	lea	ecx, 1[rbx]
	mov	rdi, r12
	imul	rcx, rdx
	imul	rbx, rdx
	lea	r14, 0[r13+rcx*4]
	lea	rbx, 0[r13+rbx*4]
	mov	DWORD PTR [r14], eax
	mov	DWORD PTR [rbx], eax
	call	AR_SREV_9485@PLT
	test	eax, eax
	jne	.L8
	mov	edi, r15d
	call	AR_PHY_TX_IQCAL_CORR_COEFF_B1@PLT
	mov	edi, r15d
	mov	DWORD PTR 4[r14], eax
	mov	DWORD PTR 4[rbx], eax
	call	AR_PHY_TX_IQCAL_CORR_COEFF_B2@PLT
	mov	DWORD PTR 8[r14], eax
	mov	DWORD PTR 8[rbx], eax
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L51:
	mov	r15, QWORD PTR -88[rbp]
	mov	r14, QWORD PTR -104[rbp]
.L10:
	mov	rax, QWORD PTR -80[rbp]
	mov	ecx, DWORD PTR AR9300_MAX_CHAINS[rip]
	xor	ebx, ebx
	shr	rax, 2
	mov	QWORD PTR -88[rbp], rax
	test	ecx, ecx
	jle	.L7
	mov	rax, rbx
	mov	rbx, r15
	mov	r15, rax
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L14:
	add	r15, 1
	cmp	DWORD PTR AR9300_MAX_CHAINS[rip], r15d
	jle	.L52
.L25:
	mov	eax, DWORD PTR [r12]
	bt	eax, r15d
	jnc	.L14
	mov	edx, DWORD PTR AR_PHY_CALIBRATED_GAINS_0[rip]
	mov	esi, DWORD PTR AR_PHY_TX_IQCAL_STATUS_B0[rip]
	mov	rdi, r12
	mov	DWORD PTR -80[rbp], r15d
	call	REG_READ_FIELD@PLT
	cmp	DWORD PTR MAX_MEASUREMENT[rip], eax
	mov	rdi, r12
	cmovle	eax, DWORD PTR MAX_MEASUREMENT[rip]
	mov	DWORD PTR -72[rbp], eax
	mov	r13d, eax
	call	AR_SREV_9550@PLT
	mov	ecx, DWORD PTR -80[rbp]
	test	eax, eax
	jne	.L15
	cmp	r13d, 1
	jg	.L53
.L15:
	mov	edx, DWORD PTR -72[rbp]
	lea	r9, 0[0+r15*8]
	test	edx, edx
	jle	.L24
.L16:
	lea	rax, 0[0+r15*4]
	xor	r13d, r13d
	mov	QWORD PTR -120[rbp], r15
	mov	r15, r14
	mov	QWORD PTR -112[rbp], rax
	movsx	rax, ecx
	mov	r14, rbx
	mov	rbx, r13
	mov	QWORD PTR -80[rbp], rax
	mov	r13, r9
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L55:
	mov	edx, DWORD PTR AR_PHY_TX_IQCAL_CORR_COEFF_00_COEFF_TABLE[rip]
	mov	rdi, r12
	call	REG_RMW_FIELD@PLT
.L21:
	test	r14, r14
	je	.L22
	mov	rax, QWORD PTR 16[r15]
	lea	rdi, 0[0+rbx*8]
	mov	rsi, QWORD PTR -112[rbp]
	mov	edx, DWORD PTR [rax]
	mov	rax, QWORD PTR [r14]
	mov	rax, QWORD PTR [rax+rdi]
	mov	DWORD PTR [rax+rsi], edx
.L22:
	add	rbx, 1
	cmp	DWORD PTR -72[rbp], ebx
	jle	.L54
.L23:
	lea	rax, 0[0+rbx*8]
	mov	rdi, QWORD PTR -96[rbp]
	mov	QWORD PTR -104[rbp], rax
	mov	rax, QWORD PTR [r15]
	mov	rax, QWORD PTR [rax+r13]
	mov	rax, QWORD PTR [rax+rbx*8]
	mov	ecx, DWORD PTR [rax]
	mov	rax, QWORD PTR 8[r15]
	mov	rax, QWORD PTR [rax+r13]
	sal	ecx, 7
	and	ecx, 16256
	mov	rax, QWORD PTR [rax+rbx*8]
	mov	eax, DWORD PTR [rax]
	and	eax, 127
	or	ecx, eax
	mov	rax, QWORD PTR 16[r15]
	mov	DWORD PTR [rax], ecx
	movsx	rax, ebx
	imul	rax, QWORD PTR -88[rbp]
	add	rax, QWORD PTR -80[rbp]
	mov	esi, DWORD PTR [rdi+rax*4]
	test	bl, 1
	je	.L55
	mov	edx, DWORD PTR AR_PHY_TX_IQCAL_CORR_COEFF_01_COEFF_TABLE[rip]
	mov	rdi, r12
	call	REG_RMW_FIELD@PLT
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L54:
	mov	rbx, r14
	mov	r14, r15
	mov	r15, QWORD PTR -120[rbp]
.L24:
	test	rbx, rbx
	je	.L14
	mov	rax, QWORD PTR 8[rbx]
	mov	esi, DWORD PTR -72[rbp]
	mov	DWORD PTR [rax+r15*4], esi
	add	r15, 1
	cmp	DWORD PTR AR9300_MAX_CHAINS[rip], r15d
	jg	.L25
	.p2align 4,,10
	.p2align 3
.L52:
	mov	r15, rbx
.L7:
	mov	edx, DWORD PTR AR_PHY_TX_IQCAL_CONTROL_3_IQCORR_EN[rip]
	mov	esi, DWORD PTR AR_PHY_TX_IQCAL_CONTROL_3[rip]
	mov	ecx, 1
	mov	rdi, r12
	call	REG_RMW_FIELD@PLT
	mov	edx, DWORD PTR AR_PHY_RX_IQCAL_CORR_B0_LOOPBACK_IQCORR_EN[rip]
	mov	ecx, 1
	mov	rdi, r12
	mov	esi, DWORD PTR AR_PHY_RX_IQCAL_CORR_B0[rip]
	call	REG_RMW_FIELD@PLT
	test	r15, r15
	je	.L1
	mov	eax, DWORD PTR -124[rbp]
	mov	edi, DWORD PTR TXIQCAL_DONE[rip]
	lea	rsi, 16[r15]
	test	eax, eax
	je	.L26
	call	set_bit@PLT
.L1:
	mov	rax, QWORD PTR -56[rbp]
	xor	rax, QWORD PTR fs:40
	jne	.L56
	lea	rsp, -40[rbp]
	pop	rbx
	pop	r12
	pop	r13
	pop	r14
	pop	r15
	pop	rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
	.p2align 4,,10
	.p2align 3
.L53:
	.cfi_restore_state
	mov	rax, QWORD PTR [r14]
	mov	r13d, DWORD PTR -72[rbp]
	mov	DWORD PTR -104[rbp], ecx
	lea	r9, 0[0+r15*8]
	mov	edx, DWORD PTR MAX_MAG_DELTA[rip]
	mov	QWORD PTR -80[rbp], r9
	mov	rdi, QWORD PTR [rax+r15*8]
	mov	esi, r13d
	call	ar9003_hw_detect_outlier@PLT
	mov	rax, QWORD PTR 8[r14]
	mov	edx, DWORD PTR MAX_PHS_DELTA[rip]
	mov	esi, r13d
	mov	rdi, QWORD PTR [rax+r15*8]
	call	ar9003_hw_detect_outlier@PLT
	mov	r9, QWORD PTR -80[rbp]
	mov	ecx, DWORD PTR -104[rbp]
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L26:
	call	clear_bit@PLT
	jmp	.L1
.L50:
	or	QWORD PTR -8[rsp+rcx], 0
	jmp	.L4
.L56:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE0:
	.size	ar9003_hw_tx_iq_cal_outlier_detection, .-ar9003_hw_tx_iq_cal_outlier_detection
	.comm	TXIQCAL_DONE,4,4
	.comm	MAX_PHS_DELTA,4,4
	.comm	MAX_MEASUREMENT,4,4
	.comm	MAX_MAG_DELTA,4,4
	.comm	AR_PHY_TX_IQCAL_STATUS_B0,4,4
	.comm	AR_PHY_TX_IQCAL_CORR_COEFF_01_COEFF_TABLE,4,4
	.comm	AR_PHY_TX_IQCAL_CORR_COEFF_00_COEFF_TABLE,4,4
	.comm	AR_PHY_TX_IQCAL_CONTROL_3_IQCORR_EN,4,4
	.comm	AR_PHY_TX_IQCAL_CONTROL_3,4,4
	.comm	AR_PHY_RX_IQCAL_CORR_B0_LOOPBACK_IQCORR_EN,4,4
	.comm	AR_PHY_RX_IQCAL_CORR_B0,4,4
	.comm	AR_PHY_CALIBRATED_GAINS_0,4,4
	.comm	AR9300_MAX_CHAINS,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 2
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"extr_ar9003_calib.c_ar9003_hw_tx_iq_cal_outlier_detection.c"
	.text
	.section	.rodata.cst4,"aM",%progbits,4
	.align	2
.LC0:
	.word	__stack_chk_guard
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	ar9003_hw_tx_iq_cal_outlier_detection, %function
ar9003_hw_tx_iq_cal_outlier_detection:
	@ args = 0, pretend = 0, frame = 24
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, r10, fp, lr}
	add	fp, sp, #32
	sub	sp, sp, #28
	ldr	r3, .L35
	mov	r8, r0
	ldr	r4, [r3]
	ldr	r3, .L35+4
	mov	ip, r2
	ldr	r6, [r3]
	str	ip, [fp, #-60]
	mul	r3, r4, r6
	lsl	r3, r3, #2
	add	r0, r3, #7
	bic	r0, r0, #7
	sub	sp, sp, r0
	mov	r7, sp
	mov	r2, r3
	ldr	r3, .L35+8
	mov	r5, r1
	mov	r0, r7
	mov	r1, #0
	ldr	r3, [r3]
	str	r3, [fp, #-40]
	mov	r3,#0
	ldr	r10, [r8, #4]
	bl	memset
	lsl	r3, r4, #2
	cmp	r6, #1
	str	r3, [fp, #-48]
	ble	.L2
	mov	r9, #0
	mov	r2, #1
	lsr	r3, r3, #2
	str	r10, [fp, #-52]
	str	r5, [fp, #-56]
	mov	r10, r2
	mov	r5, r9
	mov	r9, r3
	b	.L4
.L3:
	ldr	r3, .L35+4
	add	r5, r5, #1
	ldr	r2, [r3]
	add	r10, r10, #2
	add	r2, r2, r2, lsr #31
	cmp	r5, r2, asr #1
	bge	.L32
.L4:
	mov	r0, r5
	bl	AR_PHY_TX_IQCAL_CORR_COEFF_B0
	mov	r2, r0
	mul	r6, r10, r9
	mul	r4, r9, r5
	str	r2, [r7, r6, lsl #2]
	mov	r0, r8
	str	r2, [r7, r4, lsl #3]
	bl	AR_SREV_9485
	cmp	r0, #0
	add	r6, r7, r6, lsl #2
	add	r4, r7, r4, lsl #3
	bne	.L3
	mov	r0, r5
	bl	AR_PHY_TX_IQCAL_CORR_COEFF_B1
	mov	r2, r0
	mov	r0, r5
	str	r2, [r6, #4]
	str	r2, [r4, #4]
	bl	AR_PHY_TX_IQCAL_CORR_COEFF_B2
	str	r0, [r6, #8]
	str	r0, [r4, #8]
	b	.L3
.L32:
	ldr	r3, .L35
	ldr	r10, [fp, #-52]
	ldr	r5, [fp, #-56]
	ldr	r4, [r3]
.L2:
	cmp	r4, #0
	ble	.L21
	ldr	r3, [fp, #-48]
	mov	r9, #0
	lsr	r3, r3, #2
	str	r3, [fp, #-52]
	str	r7, [fp, #-56]
	b	.L20
.L9:
	ldr	r3, .L35
	add	r9, r9, #1
	ldr	r3, [r3]
	cmp	r3, r9
	ble	.L21
.L20:
	ldr	r3, [r8]
	asr	r3, r3, r9
	tst	r3, #1
	beq	.L9
	ldr	r3, .L35+12
	mov	r0, r8
	ldr	r2, [r3]
	ldr	r3, .L35+16
	ldr	r1, [r3]
	bl	REG_READ_FIELD
	mov	r7, r0
	ldr	r3, .L35+4
	mov	r0, r8
	ldr	r3, [r3]
	cmp	r7, r3
	movlt	r3, r7
	mov	r4, r3
	str	r3, [fp, #-48]
	bl	AR_SREV_9550
	cmp	r4, #1
	mov	r3, r4
	movle	r3, #0
	movgt	r3, #1
	cmp	r0, #0
	movne	r3, #0
	cmp	r3, #0
	bne	.L33
	ldr	r3, [fp, #-48]
	cmp	r3, #0
	lslgt	r6, r9, #2
	ble	.L19
.L11:
	mov	r4, #0
.L18:
	ldr	r3, [r5]
	ldr	r2, [r5, #4]
	ldr	r3, [r3, r6]
	ldr	r2, [r2, r6]
	ldr	r3, [r3, r4, lsl #2]
	ldr	r2, [r2, r4, lsl #2]
	ldr	r3, [r3]
	ldr	r2, [r2]
	lsl	r3, r3, #7
	and	r2, r2, #127
	and	r3, r3, #16256
	orr	r3, r3, r2
	ldr	r2, [fp, #-52]
	ldr	r1, [r5, #8]
	mla	r2, r4, r2, r9
	str	r3, [r1]
	ldr	r1, [fp, #-56]
	tst	r4, #1
	ldr	r1, [r1, r2, lsl #2]
	ldreq	r2, .L35+20
	ldrne	r2, .L35+24
	mov	r0, r8
	ldr	r2, [r2]
	bl	REG_RMW_FIELD
	cmp	r10, #0
	ldrne	r3, [r10]
	ldrne	r2, [r5, #8]
	lsl	r7, r4, #2
	ldrne	r3, [r3, r7]
	ldrne	r2, [r2]
	add	r4, r4, #1
	strne	r2, [r3, r6]
	ldr	r3, [fp, #-48]
	cmp	r3, r4
	bgt	.L18
.L19:
	cmp	r10, #0
	ldrne	r3, [r10, #4]
	ldrne	r2, [fp, #-48]
	strne	r2, [r3, r9, lsl #2]
	b	.L9
.L21:
	ldr	r3, .L35+28
	ldr	r2, .L35+32
	ldr	r1, [r3]
	ldr	r2, [r2]
	mov	r3, #1
	mov	r0, r8
	bl	REG_RMW_FIELD
	ldr	r3, .L35+36
	ldr	r2, .L35+40
	ldr	r1, [r3]
	mov	r0, r8
	mov	r3, #1
	ldr	r2, [r2]
	bl	REG_RMW_FIELD
	cmp	r10, #0
	beq	.L1
	ldr	r2, [fp, #-60]
	ldr	r3, .L35+44
	cmp	r2, #0
	ldr	r0, [r3]
	add	r1, r10, #8
	beq	.L22
	bl	set_bit
.L1:
	ldr	r3, .L35+8
	ldr	r2, [r3]
	ldr	r3, [fp, #-40]
	eors	r2, r3, r2
	mov	r3, #0
	bne	.L34
	sub	sp, fp, #32
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L22:
	bl	clear_bit
	b	.L1
.L33:
	ldr	r3, [r5]
	ldr	r4, [fp, #-48]
	ldr	r2, .L35+48
	mov	r1, r4
	ldr	r0, [r3, r9, lsl #2]
	ldr	r2, [r2]
	bl	ar9003_hw_detect_outlier
	ldr	r3, [r5, #4]
	ldr	r2, .L35+52
	mov	r1, r4
	ldr	r2, [r2]
	ldr	r0, [r3, r9, lsl #2]
	lsl	r6, r9, #2
	bl	ar9003_hw_detect_outlier
	b	.L11
.L34:
	bl	__stack_chk_fail
.L36:
	.align	2
.L35:
	.word	AR9300_MAX_CHAINS
	.word	MAX_MEASUREMENT
	.word	.LC0
	.word	AR_PHY_CALIBRATED_GAINS_0
	.word	AR_PHY_TX_IQCAL_STATUS_B0
	.word	AR_PHY_TX_IQCAL_CORR_COEFF_00_COEFF_TABLE
	.word	AR_PHY_TX_IQCAL_CORR_COEFF_01_COEFF_TABLE
	.word	AR_PHY_TX_IQCAL_CONTROL_3
	.word	AR_PHY_TX_IQCAL_CONTROL_3_IQCORR_EN
	.word	AR_PHY_RX_IQCAL_CORR_B0
	.word	AR_PHY_RX_IQCAL_CORR_B0_LOOPBACK_IQCORR_EN
	.word	TXIQCAL_DONE
	.word	MAX_MAG_DELTA
	.word	MAX_PHS_DELTA
	.size	ar9003_hw_tx_iq_cal_outlier_detection, .-ar9003_hw_tx_iq_cal_outlier_detection
	.comm	TXIQCAL_DONE,4,4
	.comm	MAX_PHS_DELTA,4,4
	.comm	MAX_MEASUREMENT,4,4
	.comm	MAX_MAG_DELTA,4,4
	.comm	AR_PHY_TX_IQCAL_STATUS_B0,4,4
	.comm	AR_PHY_TX_IQCAL_CORR_COEFF_01_COEFF_TABLE,4,4
	.comm	AR_PHY_TX_IQCAL_CORR_COEFF_00_COEFF_TABLE,4,4
	.comm	AR_PHY_TX_IQCAL_CONTROL_3_IQCORR_EN,4,4
	.comm	AR_PHY_TX_IQCAL_CONTROL_3,4,4
	.comm	AR_PHY_RX_IQCAL_CORR_B0_LOOPBACK_IQCORR_EN,4,4
	.comm	AR_PHY_RX_IQCAL_CORR_B0,4,4
	.comm	AR_PHY_CALIBRATED_GAINS_0,4,4
	.comm	AR9300_MAX_CHAINS,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
