	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function calc_codebook_idx
_calc_codebook_idx:                     ## @calc_codebook_idx
	.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	%rdx, %r14
	movq	%rdi, %rbx
	movq	(%rdx), %rax
	movq	8(%rdx), %rcx
	movl	(%rax,%rcx,4), %r15d
	movq	16(%rdx), %rdi
	xorl	%esi, %esi
	movl	$8, %edx
	callq	_memset
	movq	8(%r14), %rcx
	cmpq	$2, %rcx
	jb	LBB0_16
## %bb.1:
	cmpl	$7, (%rbx)
	jg	LBB0_16
## %bb.2:
	movq	(%r14), %rax
	movl	-4(%rax,%rcx,4), %edx
	movl	%edx, (%rax,%rcx,4)
	cmpq	$13, %rcx
	movl	%r15d, -44(%rbp)                ## 4-byte Spill
	jb	LBB0_4
## %bb.3:
	movdqu	(%rax), %xmm0
	movdqu	16(%rax), %xmm1
	movdqu	32(%rax), %xmm2
	paddd	%xmm1, %xmm2
	pshufd	$238, %xmm2, %xmm1              ## xmm1 = xmm2[2,3,2,3]
	paddd	%xmm2, %xmm1
	pshufd	$85, %xmm1, %xmm2               ## xmm2 = xmm1[1,1,1,1]
	paddd	%xmm1, %xmm2
	movd	%xmm2, %ecx
	pshufd	$238, %xmm0, %xmm1              ## xmm1 = xmm0[2,3,2,3]
	paddd	%xmm0, %xmm1
	pshufd	$85, %xmm1, %xmm0               ## xmm0 = xmm1[1,1,1,1]
	paddd	%xmm1, %xmm0
	movd	%xmm0, %edx
	addl	%edx, %ecx
	addl	$6, %ecx
	movslq	%ecx, %rcx
	imulq	$715827883, %rcx, %rdx          ## imm = 0x2AAAAAAB
	movq	%rdx, %rcx
	shrq	$63, %rcx
	sarq	$33, %rdx
	addl	%ecx, %edx
	movq	%rdx, -56(%rbp)                 ## 8-byte Spill
	jmp	LBB0_5
LBB0_4:
	xorl	%edx, %edx
	movq	%rdx, -56(%rbp)                 ## 8-byte Spill
	cmpq	$9, %rcx
	jb	LBB0_15
LBB0_5:
	movl	$9, %r12d
	.p2align	4, 0x90
LBB0_6:                                 ## =>This Inner Loop Header: Depth=1
	movl	-8(%rax,%r12,4), %r15d
	movl	-4(%rax,%r12,4), %r13d
	movl	(%rax,%r12,4), %ebx
	movl	%r15d, %edi
	movl	%ebx, %esi
	callq	_FFMIN
	movl	%r13d, %ecx
	subl	%eax, %ecx
	cmpl	$2, %ecx
	jg	LBB0_8
## %bb.7:                               ##   in Loop: Header=BB0_6 Depth=1
	addl	%r13d, %r13d
	addl	%r15d, %ebx
	subl	%ebx, %r13d
	cmpl	$3, %r13d
	jl	LBB0_9
LBB0_8:                                 ##   in Loop: Header=BB0_6 Depth=1
	movq	16(%r14), %rax
	movl	$1, -4(%rax,%r12,4)
LBB0_9:                                 ##   in Loop: Header=BB0_6 Depth=1
	movq	8(%r14), %rcx
	cmpq	%r12, %rcx
	jbe	LBB0_10
## %bb.17:                              ##   in Loop: Header=BB0_6 Depth=1
	movq	(%r14), %rax
	incq	%r12
	jmp	LBB0_6
LBB0_10:
	cmpq	$13, %rcx
	jb	LBB0_15
## %bb.11:
	xorl	%ebx, %ebx
	movq	_at9_q_unit_to_coeff_cnt@GOTPCREL(%rip), %r15
	jmp	LBB0_12
	.p2align	4, 0x90
LBB0_14:                                ##   in Loop: Header=BB0_12 Depth=1
	movq	8(%r14), %rcx
	leaq	1(%rbx), %rax
	addq	$13, %rbx
	cmpq	%rbx, %rcx
	movq	%rax, %rbx
	jbe	LBB0_15
LBB0_12:                                ## =>This Inner Loop Header: Depth=1
	movq	(%r14), %rax
	movl	44(%rax,%rbx,4), %esi
	movl	48(%rax,%rbx,4), %r12d
	movq	(%r15), %rcx
	movl	48(%rcx,%rbx,4), %r13d
	movl	52(%rax,%rbx,4), %edi
	callq	_FFMIN
	movq	16(%r14), %rcx
	cmpl	$0, 48(%rcx,%rbx,4)
	jne	LBB0_14
## %bb.13:                              ##   in Loop: Header=BB0_12 Depth=1
	xorl	%edx, %edx
	cmpl	$16, %r13d
	sete	%dl
	movl	%r12d, %esi
	subl	%eax, %esi
	cmpl	$2, %esi
	setge	%al
	movq	-56(%rbp), %rsi                 ## 8-byte Reload
                                        ## kill: def $esi killed $esi killed $rsi
	subl	%edx, %esi
	cmpl	%esi, %r12d
	setge	%dl
	andb	%al, %dl
	movzbl	%dl, %eax
	movl	%eax, 48(%rcx,%rbx,4)
	jmp	LBB0_14
LBB0_15:
	movq	(%r14), %rax
	movl	-44(%rbp), %edx                 ## 4-byte Reload
	movl	%edx, (%rax,%rcx,4)
LBB0_16:
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_at9_q_unit_to_coeff_cnt,8,3    ## @at9_q_unit_to_coeff_cnt
	.no_dead_strip	_calc_codebook_idx
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function calc_codebook_idx
_calc_codebook_idx:                     ; @calc_codebook_idx
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	mov	x19, x2
	mov	x20, x0
	ldp	x8, x9, [x2]
	ldr	w22, [x8, x9, lsl #2]
	ldr	x0, [x2, #16]
	mov	w1, #0
	mov	w2, #8
	bl	_memset
	ldr	x9, [x19, #8]
	cmp	x9, #2
	b.lo	LBB0_18
; %bb.1:
	ldr	w8, [x20]
	cmp	w8, #7
	b.gt	LBB0_18
; %bb.2:
	ldr	x8, [x19]
	add	x10, x8, x9, lsl #2
	ldur	w11, [x10, #-4]
	str	w11, [x10]
	cmp	x9, #13
	b.lo	LBB0_4
; %bb.3:
	ldp	q2, q0, [x8, #16]
	ldr	q1, [x8]
	add.4s	v0, v2, v0
	add.4s	v0, v0, v1
	addv.4s	s0, v0
	fmov	w9, s0
	add	w9, w9, #6
	mov	w10, #43691
	movk	w10, #10922, lsl #16
	smull	x9, w9, w10
	lsr	x10, x9, #63
	asr	x9, x9, #33
	add	w23, w9, w10
	b	LBB0_6
LBB0_4:
	cmp	x9, #9
	b.lo	LBB0_17
; %bb.5:
	mov	w23, #0
LBB0_6:
	mov	x24, #0
	mov	w25, #1
LBB0_7:                                 ; =>This Inner Loop Header: Depth=1
	add	x8, x8, x24, lsl #2
	ldp	w20, w26, [x8, #28]
	ldr	w21, [x8, #36]
	mov	x0, x20
	mov	x1, x21
	bl	_FFMIN
	sub	w8, w26, w0
	cmp	w8, #2
	b.gt	LBB0_9
; %bb.8:                                ;   in Loop: Header=BB0_7 Depth=1
	lsl	w8, w26, #1
	add	w9, w21, w20
	sub	w8, w8, w9
	cmp	w8, #3
	b.lt	LBB0_10
LBB0_9:                                 ;   in Loop: Header=BB0_7 Depth=1
	ldr	x8, [x19, #16]
	add	x8, x8, x24, lsl #2
	str	w25, [x8, #32]
LBB0_10:                                ;   in Loop: Header=BB0_7 Depth=1
	add	x8, x24, #9
	ldr	x9, [x19, #8]
	cmp	x9, x8
	b.ls	LBB0_12
; %bb.11:                               ;   in Loop: Header=BB0_7 Depth=1
	ldr	x8, [x19]
	add	x24, x24, #1
	b	LBB0_7
LBB0_12:
	cmp	x9, #13
	b.lo	LBB0_17
; %bb.13:
	mov	x20, #0
Lloh0:
	adrp	x21, _at9_q_unit_to_coeff_cnt@GOTPAGE
Lloh1:
	ldr	x21, [x21, _at9_q_unit_to_coeff_cnt@GOTPAGEOFF]
	b	LBB0_15
LBB0_14:                                ;   in Loop: Header=BB0_15 Depth=1
	ldr	x9, [x19, #8]
	add	x8, x20, #13
	add	x20, x20, #1
	cmp	x9, x8
	b.ls	LBB0_17
LBB0_15:                                ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x19]
	lsl	x26, x20, #2
	add	x8, x8, x26
	ldr	x9, [x21]
	add	x9, x9, x26
	ldr	w25, [x9, #48]
	ldp	w24, w0, [x8, #48]
	ldr	w1, [x8, #44]
	bl	_FFMIN
	ldr	x8, [x19, #16]
	add	x8, x8, x26
	ldr	w9, [x8, #48]
	cbnz	w9, LBB0_14
; %bb.16:                               ;   in Loop: Header=BB0_15 Depth=1
	cmp	w25, #16
	cset	w9, eq
	sub	w10, w24, w0
	sub	w9, w23, w9
	cmp	w10, #1
	ccmp	w24, w9, #8, gt
	cset	w9, ge
	str	w9, [x8, #48]
	b	LBB0_14
LBB0_17:
	ldr	x8, [x19]
	str	w22, [x8, x9, lsl #2]
LBB0_18:
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.cfi_endproc
                                        ; -- End function
	.comm	_at9_q_unit_to_coeff_cnt,8,3    ; @at9_q_unit_to_coeff_cnt
	.no_dead_strip	_calc_codebook_idx
.subsections_via_symbols
