// File: /workspace/github_c_makefile_star2_O0/tvlabs[P]edge264/./edge264_slice.c
// Function: parse_ref_idx_cabac
static inline void CAFUNC(parse_ref_idx, unsigned f) {
	u8x16 v = {f, f, f, f, f, f, f, f, f, f, f, f, f, f, f, f};
	u8x16 bits = {1, 2, 4, 8, 16, 32, 64, 128};
	mb->refIdx_l = ((i64x2){mb->refIdx_l} & ~(i64x2)((v & bits) == bits))[0]; // set to 0 if parsed
	log_mb(ctx, "    ref_idx: {");
	for (unsigned u = f & ctx->num_ref_idx_mask; u; u &= u - 1) {
		int i = __builtin_ctz(u);
		int ref_idx = 0;
		#if !CABAC
			if (ctx->clip_ref_idx[i] == 1)
				ref_idx = get_u1(&ctx->t._gb) ^ 1;
			else
				ref_idx = get_ue16(&ctx->t._gb, ctx->clip_ref_idx[i]);
		#else
			if (get_ae(ctx, 54 + (mb->bits[0] >> inc8x8[4 + i] & 3))) {
				ref_idx = 1;
				mb->bits[0] |= 1 << bit8x8[4 + i];
				int ctxIdx = 58;
				while (ref_idx < 32 && get_ae(ctx, ctxIdx))
					ref_idx++, ctxIdx = 59;
			}
		#endif
		mb->refIdx[i] = ref_idx;
		log_mb(ctx, "\"%u\":%u,", i, ref_idx);
	}
	log_mb(ctx, "}\n");
	
	// clip and broadcast the values
	i8x16 refIdx_v = (i64x2){mb->refIdx_l};
	#if CABAC
		refIdx_v = min8(refIdx_v, (i64x2){(int64_t)ctx->clip_ref_idx_v});
	#endif
	if (!(f & 0x122)) { // 16xN
		refIdx_v = shuffle(refIdx_v, ((i8x16){0, 0, 2, 2, 4, 4, 6, 6, -1, -1, -1, -1, -1, -1, -1, -1}));
		#if CABAC
			mb->bits[0] |= (mb->bits[0] >> 2 & 0x080800) | (mb->bits[0] << 5 & 0x808000);
		#endif
	}
	if (!(f & 0x144)) { // Nx16
		refIdx_v = shuffle(refIdx_v, ((i8x16){0, 1, 0, 1, 4, 5, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1}));
		#if CABAC
			mb->bits[0] |= (mb->bits[0] >> 3 & 0x040400) | (mb->bits[0] << 4 & 0x808000);
		#endif
	}
	mb->refIdx_l = ((i64x2)refIdx_v)[0];
	
	// compute reference picture numbers
	mb->refPic_s[0] = ((i32x4)shufflen(ctx->t.RefPicList_v[0], refIdx_v))[0];
	mb->refPic_s[1] = ((i32x4)shufflen(ctx->t.RefPicList_v[2], refIdx_v))[1];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq %rdi, -0x168(%rbp)
movl %esi, -0x16c(%rbp)
vpbroadcastb -0x16c(%rbp), %xmm0
vmovdqa %xmm0, -0x180(%rbp)
vmovdqa 0x19d1f(%rip), %xmm0    # 0xc9310
vmovdqa %xmm0, -0x190(%rbp)
movq -0x168(%rbp), %rax
movq 0x680(%rax), %rax
vmovq 0x10(%rax), %xmm0
vmovdqa %xmm0, -0x1a0(%rbp)
vmovdqa -0x1a0(%rbp), %xmm1
vmovdqa -0x180(%rbp), %xmm0
vmovdqa -0x190(%rbp), %xmm2
vpand %xmm2, %xmm0, %xmm0
vpcmpeqb %xmm2, %xmm0, %xmm0
vpandn %xmm1, %xmm0, %xmm0
vmovq %xmm0, %rcx
movq -0x168(%rbp), %rax
movq 0x680(%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x168(%rbp), %rax
movswq 0x1cd0(%rax), %rax
cmpq $0x1000, %rax           # imm = 0x1000
jae 0xaf6c5
movq -0x168(%rbp), %rdi
addq $0x1cd2, %rdi           # imm = 0x1CD2
movq -0x168(%rbp), %rax
movswl 0x1cd0(%rax), %eax
cltq
addq %rax, %rdi
movq -0x168(%rbp), %rax
movswq 0x1cd0(%rax), %rax
movl $0x1000, %esi           # imm = 0x1000
subq %rax, %rsi
leaq 0x212b7(%rip), %rdx     # 0xd095c
movb $0x0, %al
callq 0x7070
movl %eax, %edx
movq -0x168(%rbp), %rax
movswl 0x1cd0(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x1cd0(%rax)
movl -0x16c(%rbp), %eax
movq -0x168(%rbp), %rcx
movzbl 0xdc1(%rcx), %ecx
andl %ecx, %eax
movl %eax, -0x1a4(%rbp)
cmpl $0x0, -0x1a4(%rbp)
je 0xaf8ad
movl -0x1a4(%rbp), %eax
tzcntl %eax, %eax
movl %eax, -0x1a8(%rbp)
movl $0x0, -0x1ac(%rbp)
movq -0x168(%rbp), %rdi
movq -0x168(%rbp), %rax
movq 0x680(%rax), %rax
movl 0x8(%rax), %esi
movl -0x1a8(%rbp), %eax
addl $0x4, %eax
movslq %eax, %rcx
leaq 0x1ff3d(%rip), %rax     # 0xcf670
movsbl (%rax,%rcx), %ecx
shrl %cl, %esi
andl $0x3, %esi
addl $0x36, %esi
callq 0xae5c0
cmpl $0x0, %eax
je 0xaf7ed
movl $0x1, -0x1ac(%rbp)
movl -0x1a8(%rbp), %eax
addl $0x4, %eax
movslq %eax, %rcx
leaq 0x1f2a6(%rip), %rax     # 0xcea10
movsbl (%rax,%rcx), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
movq -0x168(%rbp), %rax
movq 0x680(%rax), %rax
orl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
movl $0x3a, -0x1b0(%rbp)
xorl %eax, %eax
cmpl $0x20, -0x1ac(%rbp)
movb %al, -0x201(%rbp)
jge 0xaf7c4
movq -0x168(%rbp), %rdi
movl -0x1b0(%rbp), %esi
callq 0xae5c0
cmpl $0x0, %eax
setne %al
movb %al, -0x201(%rbp)
movb -0x201(%rbp), %al
testb $0x1, %al
jne 0xaf7d0
jmp 0xaf7eb
movl -0x1ac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1ac(%rbp)
movl $0x3b, -0x1b0(%rbp)
jmp 0xaf795
jmp 0xaf7ed
movl -0x1ac(%rbp), %eax
movb %al, %dl
movq -0x168(%rbp), %rax
movq 0x680(%rax), %rax
movslq -0x1a8(%rbp), %rcx
movb %dl, 0x10(%rax,%rcx)
movq -0x168(%rbp), %rax
movswq 0x1cd0(%rax), %rax
cmpq $0x1000, %rax           # imm = 0x1000
jae 0xaf891
movq -0x168(%rbp), %rdi
addq $0x1cd2, %rdi           # imm = 0x1CD2
movq -0x168(%rbp), %rax
movswl 0x1cd0(%rax), %eax
cltq
addq %rax, %rdi
movq -0x168(%rbp), %rax
movswq 0x1cd0(%rax), %rax
movl $0x1000, %esi           # imm = 0x1000
subq %rax, %rsi
movl -0x1a8(%rbp), %ecx
movl -0x1ac(%rbp), %r8d
leaq 0x210fa(%rip), %rdx     # 0xd096b
movb $0x0, %al
callq 0x7070
movl %eax, %edx
movq -0x168(%rbp), %rax
movswl 0x1cd0(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x1cd0(%rax)
jmp 0xaf893
movl -0x1a4(%rbp), %eax
subl $0x1, %eax
andl -0x1a4(%rbp), %eax
movl %eax, -0x1a4(%rbp)
jmp 0xaf6e1
movq -0x168(%rbp), %rax
movswq 0x1cd0(%rax), %rax
cmpq $0x1000, %rax           # imm = 0x1000
jae 0xaf923
movq -0x168(%rbp), %rdi
addq $0x1cd2, %rdi           # imm = 0x1CD2
movq -0x168(%rbp), %rax
movswl 0x1cd0(%rax), %eax
cltq
addq %rax, %rdi
movq -0x168(%rbp), %rax
movswq 0x1cd0(%rax), %rax
movl $0x1000, %esi           # imm = 0x1000
subq %rax, %rsi
leaq 0x213c9(%rip), %rdx     # 0xd0ccc
movb $0x0, %al
callq 0x7070
movl %eax, %edx
movq -0x168(%rbp), %rax
movswl 0x1cd0(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x1cd0(%rax)
movq -0x168(%rbp), %rax
movq 0x680(%rax), %rax
vmovq 0x10(%rax), %xmm0
vmovdqa %xmm0, -0x1d0(%rbp)
vmovdqa -0x1d0(%rbp), %xmm0
vmovdqa %xmm0, -0x1c0(%rbp)
vmovdqa -0x1c0(%rbp), %xmm1
movq -0x168(%rbp), %rax
vmovq 0xe08(%rax), %xmm0
vmovdqa %xmm0, -0x1e0(%rbp)
vmovdqa -0x1e0(%rbp), %xmm0
vmovdqa %xmm1, -0x10(%rbp)
vmovdqa %xmm0, -0x20(%rbp)
vmovdqa -0x10(%rbp), %xmm0
vmovdqa -0x20(%rbp), %xmm1
vpminsb %xmm1, %xmm0, %xmm0
vmovdqa %xmm0, -0x1c0(%rbp)
movl -0x16c(%rbp), %eax
andl $0x122, %eax            # imm = 0x122
cmpl $0x0, %eax
jne 0xafa60
vmovdqa -0x1c0(%rbp), %xmm1
vmovdqa 0x19966(%rip), %xmm0    # 0xc9320
vmovdqa %xmm0, -0x1f0(%rbp)
vmovdqa -0x1f0(%rbp), %xmm0
vmovdqa %xmm1, -0x130(%rbp)
vmovdqa %xmm0, -0x140(%rbp)
vmovdqa -0x130(%rbp), %xmm1
vmovdqa -0x140(%rbp), %xmm0
vmovdqa %xmm1, -0x110(%rbp)
vmovdqa %xmm0, -0x120(%rbp)
vmovdqa -0x110(%rbp), %xmm0
vmovdqa -0x120(%rbp), %xmm1
vpshufb %xmm1, %xmm0, %xmm0
vmovdqa %xmm0, -0x1c0(%rbp)
movq -0x168(%rbp), %rax
movq 0x680(%rax), %rax
movl 0x8(%rax), %ecx
shrl $0x2, %ecx
andl $0x80800, %ecx          # imm = 0x80800
movq -0x168(%rbp), %rax
movq 0x680(%rax), %rax
movl 0x8(%rax), %eax
shll $0x5, %eax
andl $0x808000, %eax         # imm = 0x808000
orl %eax, %ecx
movq -0x168(%rbp), %rax
movq 0x680(%rax), %rax
orl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
movl -0x16c(%rbp), %eax
andl $0x144, %eax            # imm = 0x144
cmpl $0x0, %eax
jne 0xafb2a
vmovdqa -0x1c0(%rbp), %xmm1
vmovdqa 0x198ac(%rip), %xmm0    # 0xc9330
vmovdqa %xmm0, -0x200(%rbp)
vmovdqa -0x200(%rbp), %xmm0
vmovdqa %xmm1, -0x150(%rbp)
vmovdqa %xmm0, -0x160(%rbp)
vmovdqa -0x150(%rbp), %xmm1
vmovdqa -0x160(%rbp), %xmm0
vmovdqa %xmm1, -0xf0(%rbp)
vmovdqa %xmm0, -0x100(%rbp)
vmovdqa -0xf0(%rbp), %xmm0
vmovdqa -0x100(%rbp), %xmm1
vpshufb %xmm1, %xmm0, %xmm0
vmovdqa %xmm0, -0x1c0(%rbp)
movq -0x168(%rbp), %rax
movq 0x680(%rax), %rax
movl 0x8(%rax), %ecx
shrl $0x3, %ecx
andl $0x40400, %ecx          # imm = 0x40400
movq -0x168(%rbp), %rax
movq 0x680(%rax), %rax
movl 0x8(%rax), %eax
shll $0x4, %eax
andl $0x808000, %eax         # imm = 0x808000
orl %eax, %ecx
movq -0x168(%rbp), %rax
movq 0x680(%rax), %rax
orl 0x8(%rax), %ecx
movl %ecx, 0x8(%rax)
movq -0x1c0(%rbp), %rcx
movq -0x168(%rbp), %rax
movq 0x680(%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x168(%rbp), %rax
vmovdqa 0x1a0(%rax), %xmm1
vmovdqa -0x1c0(%rbp), %xmm0
vmovdqa %xmm1, -0x70(%rbp)
vmovdqa %xmm0, -0x80(%rbp)
vmovdqa -0x70(%rbp), %xmm1
vmovdqa -0x80(%rbp), %xmm0
vmovdqa %xmm1, -0x50(%rbp)
vmovdqa %xmm0, -0x60(%rbp)
vmovdqa -0x50(%rbp), %xmm1
vmovdqa -0x60(%rbp), %xmm0
vmovdqa %xmm1, -0x30(%rbp)
vmovdqa %xmm0, -0x40(%rbp)
vmovdqa -0x30(%rbp), %xmm0
vmovdqa -0x40(%rbp), %xmm1
vpshufb %xmm1, %xmm0, %xmm0
vmovdqa -0x80(%rbp), %xmm2
vpxor %xmm1, %xmm1, %xmm1
vpcmpgtb %xmm2, %xmm1, %xmm2
vpor %xmm2, %xmm0, %xmm0
movq -0x168(%rbp), %rax
movq 0x680(%rax), %rax
vmovd %xmm0, 0x18(%rax)
movq -0x168(%rbp), %rax
vmovdqa 0x1c0(%rax), %xmm2
vmovdqa -0x1c0(%rbp), %xmm0
vmovdqa %xmm2, -0xd0(%rbp)
vmovdqa %xmm0, -0xe0(%rbp)
vmovdqa -0xd0(%rbp), %xmm2
vmovdqa -0xe0(%rbp), %xmm0
vmovdqa %xmm2, -0xb0(%rbp)
vmovdqa %xmm0, -0xc0(%rbp)
vmovdqa -0xb0(%rbp), %xmm2
vmovdqa -0xc0(%rbp), %xmm0
vmovdqa %xmm2, -0x90(%rbp)
vmovdqa %xmm0, -0xa0(%rbp)
vmovdqa -0x90(%rbp), %xmm0
vmovdqa -0xa0(%rbp), %xmm2
vpshufb %xmm2, %xmm0, %xmm0
vmovdqa -0xe0(%rbp), %xmm2
vpcmpgtb %xmm2, %xmm1, %xmm1
vpor %xmm1, %xmm0, %xmm0
vpextrd $0x1, %xmm0, %ecx
movq -0x168(%rbp), %rax
movq 0x680(%rax), %rax
movl %ecx, 0x1c(%rax)
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
nopl (%rax,%rax)