// File: /workspace/github_c_makefile_star2_O0/tvlabs[P]edge264/./edge264_slice.c
// Function: parse_chroma_residual_cabac
static void CAFUNC(parse_chroma_residual)
{
	// As in Intra16x16, DC blocks are parsed to ctx->c[0..15], then transformed to ctx->c[16..31]
	if (mb->f.CodedBlockPatternChromaDC) { // valid also for 4:0:0
		#if !CABAC
			ctx->scan_s = (i8x4){0, 4, 2, 6};
			parse_residual_block_2x2_cavlc(ctx);
			ctx->scan_s = (i8x4){1, 5, 3, 7};
			parse_residual_block_2x2_cavlc(ctx);
		#else
			ctx->ctxIdxOffsets_l = ctxIdxOffsets_chromaDC[0]; // FIXME 4:2:2
			ctx->sig_inc_v[0] = ctx->last_inc_v[0] = sig_inc_chromaDC[0];
			ctx->coeff_abs_inc_l = (i8x8){6, 7, 8, 8};
			if (get_ae(ctx, ctx->ctxIdxOffsets[0] + ctx->inc.coded_block_flags_16x16[1])) {
				mb->f.coded_block_flags_16x16[1] = 1;
				ctx->scan_s = (i8x4){0, 4, 2, 6};
				parse_residual_coeffs_cabac(ctx, 0, 3);
			}
			if (get_ae(ctx, ctx->ctxIdxOffsets[0] + ctx->inc.coded_block_flags_16x16[2])) {
				mb->f.coded_block_flags_16x16[2] = 1;
				ctx->scan_s = (i8x4){1, 5, 3, 7};
				parse_residual_coeffs_cabac(ctx, 0, 3);
			}
		#endif
		transform_dc2x2(ctx);
		
		// Eight or sixteen 4x4 AC blocks for the Cb/Cr components
		if (mb->f.CodedBlockPatternChromaAC) {
			#if CABAC
				ctx->sig_inc_v[0] = ctx->last_inc_v[0] = sig_inc_4x4;
				ctx->ctxIdxOffsets_l = ctxIdxOffsets_chromaAC[0];
				ctx->coeff_abs_inc_l = (i8x8){6, 7, 8, 9, 9};
			#endif
			ctx->scan_v[0] = scan_4x4[0];
			for (int i4x4 = 0; i4x4 < 8; i4x4++) {
				int iYCbCr = 1 + (i4x4 >> 2);
				uint8_t *samples = ctx->samples_mb[iYCbCr] + y420[i4x4] * ctx->t.stride[1] + x420[i4x4];
				int nA = *((int8_t *)mb->nC + 16 + ctx->ACbCr_int8[i4x4]);
				int nB = *((int8_t *)mb->nC + 16 + ctx->BCbCr_int8[i4x4]);
				#if !CABAC
					if (parse_residual_block_4x4_cavlc(ctx, 16 + i4x4, nA, nB, 1))
						add_idct4x4(ctx, iYCbCr, i4x4, samples);
					else
						add_dc4x4(ctx, iYCbCr, i4x4, samples);
				#else
					if (get_ae(ctx, ctx->ctxIdxOffsets[0] + ctx->nC_inc[1][i4x4] + nA + nB * 2)) {
						mb->nC[16 + i4x4] = 1;
						parse_residual_coeffs_cabac(ctx, 1, 15);
						add_idct4x4(ctx, iYCbCr, i4x4, samples);
					} else {
						add_dc4x4(ctx, iYCbCr, i4x4, samples);
					}
				#endif
			}
		}
		ctx->c_v[4] = ctx->c_v[5] = (i8x16){};
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x680(%rax), %rax
cmpb $0x0, 0x26(%rax)
je 0x4de7d
movq 0x7f4d8(%rip), %rcx     # 0xcd070
movq -0x8(%rbp), %rax
movq %rcx, 0x1a10(%rax)
vmovdqa 0x7f4d5(%rip), %xmm0    # 0xcd080
movq -0x8(%rbp), %rax
vmovdqa %xmm0, 0x1a60(%rax)
movq -0x8(%rbp), %rax
vmovdqa %xmm0, 0x1a20(%rax)
movq $0x8080706, -0x10(%rbp) # imm = 0x8080706
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x1a18(%rax)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movswl 0x1a10(%rax), %esi
movq -0x8(%rbp), %rax
movsbl 0x6c9(%rax), %eax
addl %eax, %esi
callq 0x4b0e0
cmpl $0x0, %eax
je 0x4dc33
movq -0x8(%rbp), %rax
movq 0x680(%rax), %rax
movb $0x1, 0x29(%rax)
movl $0x6020400, -0x14(%rbp) # imm = 0x6020400
movl -0x14(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1aa0(%rax)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x3, %edx
callq 0x4d750
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movswl 0x1a10(%rax), %esi
movq -0x8(%rbp), %rax
movsbl 0x6ca(%rax), %eax
addl %eax, %esi
callq 0x4b0e0
cmpl $0x0, %eax
je 0x4dc8c
movq -0x8(%rbp), %rax
movq 0x680(%rax), %rax
movb $0x1, 0x2a(%rax)
movl $0x7030501, -0x18(%rbp) # imm = 0x7030501
movl -0x18(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1aa0(%rax)
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movl $0x3, %edx
callq 0x4d750
movq -0x8(%rbp), %rdi
callq 0x3dde0
movq -0x8(%rbp), %rax
movq 0x680(%rax), %rax
cmpb $0x0, 0x27(%rax)
je 0x4de57
movq -0x8(%rbp), %rax
vmovdqa 0x7b90a(%rip), %xmm0    # 0xc95c0
vmovdqa %xmm0, 0x1a60(%rax)
movq -0x8(%rbp), %rax
vmovdqa %xmm0, 0x1a20(%rax)
movq 0x7f3cf(%rip), %rcx     # 0xcd0a0
movq -0x8(%rbp), %rax
movq %rcx, 0x1a10(%rax)
movabsq $0x909080706, %rax      # imm = 0x909080706
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x1a18(%rax)
vmovdqa 0x7e4af(%rip), %xmm0    # 0xcc1b0
movq -0x8(%rbp), %rax
vmovdqa %xmm0, 0x1aa0(%rax)
movl $0x0, -0x24(%rbp)
cmpl $0x8, -0x24(%rbp)
jge 0x4de55
movl -0x24(%rbp), %eax
sarl $0x2, %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movslq -0x28(%rbp), %rcx
movq 0x668(%rax,%rcx,8), %rax
movslq -0x24(%rbp), %rdx
leaq 0x7ebdb(%rip), %rcx     # 0xcc920
movsbl (%rcx,%rdx), %ecx
movq -0x8(%rbp), %rdx
movzwl 0x36(%rdx), %edx
imull %edx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rdx
leaq 0x7ebc3(%rip), %rcx     # 0xcc928
movsbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x680(%rax), %rax
movq -0x8(%rbp), %rcx
movslq -0x24(%rbp), %rdx
movswl 0xbc0(%rcx,%rdx,2), %ecx
movslq %ecx, %rcx
movsbl 0x50(%rax,%rcx), %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rax
movq 0x680(%rax), %rax
movq -0x8(%rbp), %rcx
movslq -0x24(%rbp), %rdx
movslq 0xbe0(%rcx,%rdx,4), %rcx
movsbl 0x50(%rax,%rcx), %eax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movswl 0x1a10(%rax), %esi
movq -0x8(%rbp), %rax
movslq -0x24(%rbp), %rcx
movsbl 0x710(%rax,%rcx), %eax
addl %eax, %esi
addl -0x34(%rbp), %esi
movl -0x38(%rbp), %eax
shll %eax
addl %eax, %esi
callq 0x4b0e0
cmpl $0x0, %eax
je 0x4de32
movq -0x8(%rbp), %rax
movq 0x680(%rax), %rax
movl -0x24(%rbp), %ecx
addl $0x10, %ecx
movslq %ecx, %rcx
movb $0x1, 0x40(%rax,%rcx)
movq -0x8(%rbp), %rdi
movl $0x1, %esi
movl $0xf, %edx
callq 0x4d750
movq -0x8(%rbp), %rdi
movl -0x28(%rbp), %esi
movl -0x24(%rbp), %edx
movq -0x30(%rbp), %rcx
callq 0x34030
jmp 0x4de45
movq -0x8(%rbp), %rdi
movl -0x28(%rbp), %esi
movl -0x24(%rbp), %edx
movq -0x30(%rbp), %rcx
callq 0x3ebb0
jmp 0x4de47
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x4dd14
jmp 0x4de57
vpxor %xmm0, %xmm0, %xmm0
vmovdqa %xmm0, -0x50(%rbp)
vmovdqa -0x50(%rbp), %xmm0
movq -0x8(%rbp), %rax
vmovdqa %xmm0, 0x1bb0(%rax)
movq -0x8(%rbp), %rax
vmovdqa %xmm0, 0x1ba0(%rax)
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)