	.file	"extr_phy.c_ath5k_combine_pwr_to_pdadc_curves.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	ath5k_combine_pwr_to_pdadc_curves, @function
ath5k_combine_pwr_to_pdadc_curves:
.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
	push	r13
	push	r12
	push	rbx
	sub	rsp, 120
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	mov	QWORD PTR -112[rbp], rdx
	mov	QWORD PTR -144[rbp], rdi
	mov	rbx, rsp
	mov	QWORD PTR -88[rbp], rsi
	mov	QWORD PTR -104[rbp], rcx
	mov	rax, QWORD PTR fs:40
	mov	QWORD PTR -56[rbp], rax
	xor	eax, eax
	movsx	rax, DWORD PTR AR5K_EEPROM_N_PD_GAINS[rip]
	lea	rax, 15[0+rax*8]
	mov	rdx, rax
	and	rax, -4096
	sub	rbx, rax
	and	rdx, -16
	mov	rax, rbx
	cmp	rsp, rax
	je	.L3
.L52:
	sub	rsp, 4096
	or	QWORD PTR 4088[rsp], 0
	cmp	rsp, rax
	jne	.L52
.L3:
	and	edx, 4095
	sub	rsp, rdx
	test	rdx, rdx
	jne	.L53
.L4:
	mov	r15, QWORD PTR -144[rbp]
	lea	rax, 7[rsp]
	mov	esi, DWORD PTR AR5K_PHY_TPC_RG5[rip]
	mov	rbx, rax
	and	rax, -8
	shr	rbx, 3
	mov	rdi, r15
	mov	QWORD PTR -80[rbp], rax
	mov	QWORD PTR -160[rbp], rbx
	mov	rbx, QWORD PTR [r15]
	call	ath5k_hw_reg_read@PLT
	mov	rdi, QWORD PTR -104[rbp]
	and	rax, QWORD PTR AR5K_PHY_TPC_RG5_PD_GAIN_OVERLAP[rip]
	mov	QWORD PTR -72[rbp], rax
	test	rdi, rdi
	je	.L5
	mov	rax, QWORD PTR 8[r15]
	xor	r11d, r11d
	xor	r15d, r15d
	mov	QWORD PTR -120[rbp], rax
	mov	eax, DWORD PTR AR5K_EEPROM_POWER_TABLE_SIZE[rip]
	mov	DWORD PTR -148[rbp], eax
	add	eax, eax
	cdqe
	mov	QWORD PTR -136[rbp], rax
	lea	rax, -1[rdi]
	mov	QWORD PTR -128[rbp], rax
	xor	eax, eax
	.p2align 4,,10
	.p2align 3
.L20:
	mov	rdx, QWORD PTR -112[rbp]
	mov	rdi, QWORD PTR -120[rbp]
	mov	r13d, DWORD PTR [rdx+r11*4]
	mov	rdi, QWORD PTR [rdi+r11*8]
	lea	r14d, 4[r13]
	movsx	r10, r14d
	cmp	r11, QWORD PTR -128[rbp]
	je	.L7
	mov	rdx, QWORD PTR -88[rbp]
	mov	r14d, DWORD PTR 4[rdx+r11*4]
	add	r14d, r13d
	mov	r10d, r14d
	shr	r10d, 31
	add	r10d, r14d
	sar	r10d
	movsx	r10, r10d
.L7:
	mov	rsi, QWORD PTR -80[rbp]
	mov	rdx, QWORD PTR AR5K_TUNE_MAX_TXPOWER[rip]
	mov	QWORD PTR [rsi+r11*8], r10
	cmp	rdx, r10
	jnb	.L8
	mov	QWORD PTR [rsi+r11*8], rdx
	mov	r10, rdx
.L8:
	mov	rdx, QWORD PTR -88[rbp]
	cmp	rax, 127
	setbe	r8b
	mov	r9d, DWORD PTR [rdx+r11*4]
	test	r11, r11
	je	.L28
	mov	rdx, QWORD PTR -80[rbp]
	mov	rcx, QWORD PTR [rdi]
	mov	r14d, 1
	mov	rdx, QWORD PTR -8[rdx+r11*8]
	mov	QWORD PTR -96[rbp], rdx
	mov	esi, DWORD PTR -96[rbp]
	sub	esi, DWORD PTR -72[rbp]
	sub	esi, r9d
	mov	r12d, esi
	mov	edx, esi
	mov	rsi, QWORD PTR 8[rdi]
	sub	rsi, rcx
	cmove	rsi, r14
	test	r12d, r12d
	jns	.L31
	test	r8b, r8b
	je	.L31
	mov	r12d, esi
	imul	esi, edx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L12:
	mov	rcx, QWORD PTR [rdi]
.L14:
	add	rax, 1
	add	ecx, esi
	cmovs	ecx, r15d
	cmp	rax, 127
	movsx	rcx, ecx
	mov	QWORD PTR -8[rbx+rax*8], rcx
	setbe	cl
	add	esi, r12d
	mov	r8d, ecx
	add	edx, 1
	jns	.L32
	test	cl, cl
	jne	.L12
.L32:
	movsx	rsi, edx
.L9:
	mov	r14, QWORD PTR -72[rbp]
	movsx	rcx, r9d
	sub	r13d, r9d
	movsx	r13, r13d
	sub	r14, rcx
	add	r14, r10
	mov	r10, r13
	cmp	r14, r13
	cmovbe	r10, r14
	cmp	r10, rsi
	jbe	.L15
	test	r8b, r8b
	je	.L15
	movsx	rcx, edx
	lea	r12d, 1[rdx]
	add	rcx, 1
	sub	r12d, eax
	.p2align 4,,10
	.p2align 3
.L16:
	lea	edx, [r12+rax]
	add	rax, 1
	mov	rsi, QWORD PTR [rdi+rsi*8]
	cmp	rax, 127
	setbe	r9b
	cmp	rcx, r10
	mov	QWORD PTR -8[rbx+rax*8], rsi
	mov	rsi, rcx
	setb	r8b
	add	rcx, 1
	test	r9b, r8b
	jne	.L16
.L15:
	cmp	r14, r10
	ja	.L54
.L17:
	add	r11, 1
	cmp	r11, QWORD PTR -104[rbp]
	jne	.L20
.L21:
	movsx	rcx, DWORD PTR AR5K_EEPROM_N_PD_GAINS[rip]
	cmp	rcx, QWORD PTR -104[rbp]
	jbe	.L25
	mov	rdx, QWORD PTR -104[rbp]
	mov	rsi, QWORD PTR -80[rbp]
	.p2align 4,,10
	.p2align 3
.L22:
	mov	rdi, QWORD PTR -8[rsi+rdx*8]
	mov	QWORD PTR [rsi+rdx*8], rdi
	add	rdx, 1
	cmp	rdx, rcx
	jne	.L22
.L25:
	mov	edx, DWORD PTR -148[rbp]
	add	edx, edx
	movsx	rdx, edx
	cmp	rdx, rax
	jbe	.L24
	lea	rax, [rbx+rax*8]
	lea	rcx, [rbx+rdx*8]
	.p2align 4,,10
	.p2align 3
.L26:
	mov	rdx, QWORD PTR -8[rax]
	add	rax, 8
	mov	QWORD PTR -8[rax], rdx
	cmp	rcx, rax
	jne	.L26
.L24:
	mov	rsi, QWORD PTR AR5K_PHY_TPC_RG5_PD_GAIN_OVERLAP[rip]
	mov	rdi, QWORD PTR -72[rbp]
	mov	r12d, DWORD PTR AR5K_PHY_TPC_RG5[rip]
	call	AR5K_REG_SM@PLT
	mov	r15, QWORD PTR -160[rbp]
	mov	rsi, QWORD PTR AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_1[rip]
	mov	ebx, eax
	mov	rdi, QWORD PTR 0[0+r15*8]
	call	AR5K_REG_SM@PLT
	mov	rdi, QWORD PTR 8[0+r15*8]
	mov	rsi, QWORD PTR AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_2[rip]
	or	ebx, eax
	call	AR5K_REG_SM@PLT
	mov	rdi, QWORD PTR 16[0+r15*8]
	mov	rsi, QWORD PTR AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_3[rip]
	or	ebx, eax
	call	AR5K_REG_SM@PLT
	mov	rdi, QWORD PTR 24[0+r15*8]
	mov	rsi, QWORD PTR AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_4[rip]
	or	ebx, eax
	call	AR5K_REG_SM@PLT
	mov	edx, r12d
	or	ebx, eax
	mov	esi, ebx
	mov	rbx, QWORD PTR -144[rbp]
	mov	rdi, rbx
	call	ath5k_hw_reg_write@PLT
	mov	rax, QWORD PTR -88[rbp]
	mov	eax, DWORD PTR [rax]
	mov	DWORD PTR 16[rbx], eax
	mov	rax, QWORD PTR -56[rbp]
	xor	rax, QWORD PTR fs:40
	jne	.L55
	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
.L54:
	.cfi_restore_state
	sal	r13, 3
	lea	rcx, -8[rdi+r13]
	mov	rsi, QWORD PTR [rcx]
	sub	rsi, QWORD PTR -16[rdi+r13]
	mov	rdi, rsi
	mov	esi, 1
	cmove	rdi, rsi
	cmp	edx, r14d
	jge	.L17
	mov	r8d, edx
	sub	r14d, 1
	mov	esi, edi
	mov	r9, QWORD PTR -136[rbp]
	sub	r8d, r10d
	sub	r14d, edx
	imul	edi, r8d
	lea	r8, 1[rax+r14]
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L19:
	mov	edx, DWORD PTR [rcx]
	add	rax, 1
	mov	r14d, 127
	add	edx, edi
	cmp	edx, 127
	cmovg	edx, r14d
	add	edi, esi
	movsx	rdx, edx
	mov	QWORD PTR -8[rbx+rax*8], rdx
	cmp	r8, rax
	je	.L17
.L18:
	cmp	r9, rax
	ja	.L19
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L28:
	xor	esi, esi
	xor	edx, edx
	jmp	.L9
.L53:
	or	QWORD PTR -8[rsp+rdx], 0
	jmp	.L4
.L5:
	mov	eax, DWORD PTR AR5K_EEPROM_POWER_TABLE_SIZE[rip]
	mov	DWORD PTR -148[rbp], eax
	xor	eax, eax
	jmp	.L21
.L55:
	call	__stack_chk_fail@PLT
.L31:
	movsx	rsi, r12d
	jmp	.L9
	.cfi_endproc
.LFE0:
	.size	ath5k_combine_pwr_to_pdadc_curves, .-ath5k_combine_pwr_to_pdadc_curves
	.comm	AR5K_TUNE_MAX_TXPOWER,8,8
	.comm	AR5K_PHY_TPC_RG5_PD_GAIN_OVERLAP,8,8
	.comm	AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_4,8,8
	.comm	AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_3,8,8
	.comm	AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_2,8,8
	.comm	AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_1,8,8
	.comm	AR5K_PHY_TPC_RG5,4,4
	.comm	AR5K_EEPROM_POWER_TABLE_SIZE,4,4
	.comm	AR5K_EEPROM_N_PD_GAINS,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_phy.c_ath5k_combine_pwr_to_pdadc_curves.c"
	.text
	.section	.rodata.cst4,"aM",%progbits,4
	.align	2
.LC0:
	.word	__stack_chk_guard
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	ath5k_combine_pwr_to_pdadc_curves, %function
ath5k_combine_pwr_to_pdadc_curves:
	@ args = 0, pretend = 0, frame = 56
	@ frame_needed = 1, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, r10, fp, lr}
	add	fp, sp, #32
	sub	sp, sp, #60
	mov	ip, r1
	ldr	r1, .L41
	mov	r10, r3
	ldr	r1, [r1]
	str	ip, [fp, #-92]
	lsl	r3, r1, #2
	add	r3, r3, #7
	bic	r3, r3, #7
	sub	sp, sp, r3
	ldr	r3, .L41+4
	str	r0, [fp, #-88]
	ldr	r1, [r3]
	ldr	r3, .L41+8
	mov	r6, ip
	ldr	r3, [r3]
	str	r3, [fp, #-40]
	mov	r3,#0
	ldr	r3, [r0]
	mov	r5, r0
	str	r3, [fp, #-52]
	mov	r4, r2
	bl	ath5k_hw_reg_read
	mov	ip, sp
	ldr	r3, .L41+12
	cmp	r10, #0
	ldr	r3, [r3]
	str	ip, [fp, #-84]
	and	r3, r0, r3
	str	r3, [fp, #-56]
	beq	.L2
	mov	r8, #0
	ldr	r2, .L41+16
	ldr	r1, [r5, #4]
	ldr	r2, [r2]
	str	r10, [fp, #-72]
	lsl	r2, r2, #1
	str	r2, [fp, #-80]
	sub	r2, r1, #4
	str	r2, [fp, #-60]
	mov	r3, r8
	sub	r2, r10, #1
	mov	r10, r6
	sub	lr, r4, #4
	str	lr, [fp, #-64]
	str	r2, [fp, #-76]
	sub	r9, ip, #4
.L14:
	ldr	r2, [fp, #-76]
	ldr	r7, [r10]
	cmp	r8, r2
	ldr	r2, [fp, #-60]
	ldrne	r6, [r10, #4]
	ldr	lr, [r2, #4]!
	str	r2, [fp, #-60]
	ldr	r2, [fp, #-64]
	ldr	r1, [r2, #4]!
	str	r2, [fp, #-64]
	moveq	r2, r1
	str	r1, [fp, #-48]
	ldrne	r2, [fp, #-48]
	addeq	r6, r2, #4
	addne	r6, r2, r6
	ldr	r2, .L41+20
	addne	r6, r6, r6, lsr #31
	ldr	r2, [r2]
	asrne	r6, r6, #1
	cmp	r2, r6
	str	r6, [r9, #4]
	movcc	r6, r2
	strcc	r2, [r9, #4]
	cmp	r3, #127
	movhi	ip, #0
	movls	ip, #1
	cmp	r8, #0
	beq	.L23
	ldm	lr, {r1, r5}
	ldr	r0, [fp, #-56]
	ldr	r2, [r9]
	sub	r5, r5, r1
	sub	r2, r2, r0
	cmp	r5, #1
	sub	r2, r2, r7
	movcc	r5, #1
	ands	r0, ip, r2, lsr #31
	mov	r0, r2
	beq	.L6
	ldr	ip, [fp, #-52]
	sub	r4, r3, #-1073741823
	mul	r0, r5, r2
	add	r4, ip, r4, lsl #2
	str	r6, [fp, #-68]
	b	.L8
.L7:
	ldr	r1, [lr]
.L8:
	add	r3, r3, #1
	cmp	r3, #127
	movhi	ip, #0
	movls	ip, #1
	add	r1, r1, r0
	add	r2, r2, #1
	bic	r1, r1, r1, asr #31
	ands	r6, ip, r2, lsr #31
	str	r1, [r4, #4]!
	add	r0, r0, r5
	bne	.L7
	mov	r0, r2
	ldr	r6, [fp, #-68]
.L6:
	ldr	r1, [fp, #-56]
	ldr	r4, [fp, #-48]
	sub	r1, r1, r7
	add	r6, r1, r6
	sub	r7, r4, r7
	cmp	r6, r7
	movcc	r1, r6
	movcs	r1, r7
	cmp	r1, r0
	movls	ip, #0
	andhi	ip, ip, #1
	cmp	ip, #0
	add	r10, r10, #4
	beq	.L9
	ldr	r4, [fp, #-52]
	sub	ip, r3, #-1073741823
	add	ip, r4, ip, lsl #2
.L10:
	add	r2, r2, #1
	add	r3, r3, #1
	cmp	r3, #127
	cmpls	r2, r1
	ldr	r4, [lr, r0, lsl #2]
	mov	r0, r2
	str	r4, [ip, #4]!
	bcc	.L10
.L9:
	cmp	r6, r1
	bhi	.L39
.L11:
	ldr	r2, [fp, #-72]
	add	r8, r8, #1
	cmp	r8, r2
	add	r9, r9, #4
	bne	.L14
	mov	r10, r2
.L15:
	ldr	r2, .L41
	ldr	r1, [r2]
	cmp	r1, r10
	bls	.L20
	ldr	r2, [fp, #-84]
	add	r2, r2, r10, lsl #2
	sub	r2, r2, #4
.L19:
	ldr	r0, [r2]
	add	r10, r10, #1
	cmp	r10, r1
	str	r0, [r2, #4]!
	bne	.L19
.L20:
	ldr	r2, [fp, #-80]
	cmp	r3, r2
	bcs	.L18
	ldr	r2, [fp, #-52]
	sub	r3, r3, #-1073741823
	sub	r1, r2, #4
	add	r3, r2, r3, lsl #2
	ldr	r2, [fp, #-80]
	add	r1, r1, r2, lsl #2
.L21:
	ldr	r2, [r3]
	str	r2, [r3, #4]!
	cmp	r1, r3
	bne	.L21
.L18:
	ldr	r3, .L41+12
	ldr	r0, [fp, #-56]
	ldr	r1, [r3]
	bl	AR5K_REG_SM
	ldr	r5, [fp, #-84]
	ldr	r3, .L41+24
	mov	r4, r0
	ldr	r1, [r3]
	ldr	r0, [r5]
	bl	AR5K_REG_SM
	mov	r3, r0
	ldr	r2, .L41+28
	ldr	r0, [r5, #4]
	ldr	r1, [r2]
	orr	r4, r4, r3
	bl	AR5K_REG_SM
	mov	r3, r0
	ldr	r2, .L41+32
	ldr	r0, [r5, #8]
	ldr	r1, [r2]
	orr	r4, r4, r3
	bl	AR5K_REG_SM
	mov	r3, r0
	ldr	r2, .L41+36
	ldr	r0, [r5, #12]
	ldr	r1, [r2]
	orr	r4, r4, r3
	bl	AR5K_REG_SM
	ldr	r3, .L41+4
	orr	r1, r4, r0
	ldr	r4, [fp, #-88]
	ldr	r2, [r3]
	mov	r0, r4
	bl	ath5k_hw_reg_write
	ldr	r3, [fp, #-92]
	ldr	r3, [r3]
	str	r3, [r4, #8]
	ldr	r3, .L41+8
	ldr	r2, [r3]
	ldr	r3, [fp, #-40]
	eors	r2, r3, r2
	mov	r3, #0
	bne	.L40
	sub	sp, fp, #32
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L39:
	sub	r7, r7, #-1073741823
	add	ip, lr, r7, lsl #2
	ldr	r0, [ip, #-4]
	ldr	lr, [lr, r7, lsl #2]
	sub	lr, lr, r0
	cmp	lr, #1
	movcc	lr, #1
	cmp	r2, r6
	bge	.L11
	add	r6, r6, r3
	sub	r0, r2, r1
	sub	r6, r6, r2
	ldr	r2, [fp, #-52]
	sub	r4, r3, #-1073741823
	mul	r0, lr, r0
	ldr	r1, [fp, #-80]
	add	r4, r2, r4, lsl #2
	b	.L12
.L13:
	ldr	r2, [ip]
	add	r3, r3, #1
	add	r2, r2, r0
	cmp	r2, #127
	movge	r2, #127
	cmp	r6, r3
	str	r2, [r4, #4]!
	add	r0, r0, lr
	beq	.L11
.L12:
	cmp	r1, r3
	bhi	.L13
	b	.L11
.L23:
	mov	r0, r8
	mov	r2, r8
	b	.L6
.L2:
	ldr	r2, .L41+16
	mov	r3, r10
	ldr	r2, [r2]
	lsl	r2, r2, #1
	str	r2, [fp, #-80]
	b	.L15
.L40:
	bl	__stack_chk_fail
.L42:
	.align	2
.L41:
	.word	AR5K_EEPROM_N_PD_GAINS
	.word	AR5K_PHY_TPC_RG5
	.word	.LC0
	.word	AR5K_PHY_TPC_RG5_PD_GAIN_OVERLAP
	.word	AR5K_EEPROM_POWER_TABLE_SIZE
	.word	AR5K_TUNE_MAX_TXPOWER
	.word	AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_1
	.word	AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_2
	.word	AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_3
	.word	AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_4
	.size	ath5k_combine_pwr_to_pdadc_curves, .-ath5k_combine_pwr_to_pdadc_curves
	.comm	AR5K_TUNE_MAX_TXPOWER,4,4
	.comm	AR5K_PHY_TPC_RG5_PD_GAIN_OVERLAP,4,4
	.comm	AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_4,4,4
	.comm	AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_3,4,4
	.comm	AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_2,4,4
	.comm	AR5K_PHY_TPC_RG5_PD_GAIN_BOUNDARY_1,4,4
	.comm	AR5K_PHY_TPC_RG5,4,4
	.comm	AR5K_EEPROM_POWER_TABLE_SIZE,4,4
	.comm	AR5K_EEPROM_N_PD_GAINS,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
