// File: /workspace/github_c_makefile_star2_O0/tvlabs[P]edge264/edge264_test.c
// Function: check_frame
static int check_frame()
{
	// check that the number of returned views is as expected
	if ((out.samples_mvc[0] != NULL) != (conf[1] != NULL)) {
		printf("Number of returned views (%d) does not match number of YUV files found (%d)\n", (out.samples_mvc[0] != NULL) + 1, (conf[1] != NULL) + 1);
		moveup = "";
		return -2;
	}
	
	// check that each macroblock matches the conformance buffer
	int cropt = out.frame_crop_offsets[0];
	int cropr = out.frame_crop_offsets[1];
	int cropb = out.frame_crop_offsets[2];
	int cropl = out.frame_crop_offsets[3];
	int pic_width_in_mbs = (cropl + out.width_Y + cropr) >> 4;
	int pic_height_in_mbs = (cropt + out.height_Y + cropb) >> 4;
	for (int view = 0; view < 2 && conf[view] != NULL; view += 1) {
		int id = view ? out.FrameId_mvc : out.FrameId;
		for (int row = 0; row < pic_width_in_mbs; row += 1) {
			for (int col = 0; col < pic_height_in_mbs; col += 1) {
				for (int iYCbCr = 0; iYCbCr < 3; iYCbCr++) {
					int stride = (iYCbCr == 0) ? out.stride_Y : out.stride_C;
					int depth = (iYCbCr == 0) ? out.pixel_depth_Y : out.pixel_depth_C;
					int sh_width = (iYCbCr > 0 && out.width_C < out.width_Y);
					int sh_height = (iYCbCr > 0 && out.height_C < out.height_Y);
					const uint8_t *p = (view ? out.samples_mvc : out.samples)[iYCbCr];
					const uint8_t *q = conf[view] +
						(iYCbCr > 0) * (out.width_Y << out.pixel_depth_Y) * out.height_Y +
						(iYCbCr > 1) * (out.width_C << out.pixel_depth_C) * out.height_C;
					int xl = max(col * 16 - cropl, 0) >> sh_width;
					int xr = min(col * 16 - cropl + 16, out.width_Y) >> sh_width;
					int invalid = 0;
					for (int y = max(row * 16 - cropt, 0) >> sh_height; xl < xr && y < min(row * 16 - cropt + 16, out.height_Y) >> sh_height; y++)
						invalid |= memcmp(p + y * stride + (xl << depth), q + y * (out.width_Y >> sh_width << depth) + (xl << depth), (xr - xl) << depth);
					if (invalid) {
						printf("Erroneous macroblock (id %d, row %d, column %d, %s plane):\n",
							id, row, col, (iYCbCr == 0) ? "Luma" : (iYCbCr == 1) ? "Cb" : "Cr");
						for (int y = (row * 16 - cropt) >> sh_height; y < (row * 16 - cropt + 16) >> sh_height; y++) {
							for (int x = (col * 16 - cropl) >> sh_width; x < (col * 16 - cropl + 16) >> sh_width; x++) {
								// FIXME 16 bit
								printf(y < 0 || y >= out.height_Y >> sh_height || x < 0 || x >= out.width_Y >> sh_width ? "    " :
									p[y * stride + x] == q[y * (out.width_Y >> sh_width) + x] ? " %3d" :
									RED " %3d" RESET, p[y * stride + x]);
							}
							printf("\n");
						}
						printf("Expected macroblock:\n");
						for (int y = (row * 16 - cropt) >> sh_height; y < (row * 16 - cropt + 16) >> sh_height; y++) {
							for (int x = (col * 16 - cropl) >> sh_width; x < (col * 16 - cropl + 16) >> sh_width; x++) {
								printf(y < 0 || y >= out.height_Y >> sh_height || x < 0 || x >= out.width_Y >> sh_width ? "    " :
									" %3d", q[y * (out.width_Y >> sh_width) + x]);
							}
							printf("\n");
						}
						moveup = "";
						return -2;
					}
				}
			}
		}
		conf[view] += (out.width_Y << out.pixel_depth_Y) * out.height_Y + (out.width_C << out.pixel_depth_C) * out.height_C * 2;
	}
	return 0;
}

// Assembly:
subq $0xc8, %rsp
cmpq $0x0, 0x3dd9(%rip)      # 0x6238
setne %al
andb $0x1, %al
movzbl %al, %eax
cmpq $0x0, 0x3da9(%rip)      # 0x6218
setne %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x24ce
cmpq $0x0, 0x3db4(%rip)      # 0x6238
setne %al
andb $0x1, %al
movzbl %al, %esi
addl $0x1, %esi
cmpq $0x0, 0x3d81(%rip)      # 0x6218
setne %al
andb $0x1, %al
movzbl %al, %edx
addl $0x1, %edx
leaq 0x2296(%rip), %rdi      # 0x473f
movb $0x0, %al
callq 0x10b0
leaq 0x22d4(%rip), %rax      # 0x478b
movq %rax, 0x3c5a(%rip)      # 0x6118
movl $0xfffffffe, 0xc4(%rsp) # imm = 0xFFFFFFFE
jmp 0x2d93
movswl 0x3d9b(%rip), %eax      # 0x6270
movl %eax, 0xc0(%rsp)
movswl 0x3d8f(%rip), %eax      # 0x6272
movl %eax, 0xbc(%rsp)
movswl 0x3d83(%rip), %eax      # 0x6274
movl %eax, 0xb8(%rsp)
movswl 0x3d77(%rip), %eax      # 0x6276
movl %eax, 0xb4(%rsp)
movl 0xb4(%rsp), %eax
movswl 0x3d46(%rip), %ecx      # 0x625a
addl %ecx, %eax
addl 0xbc(%rsp), %eax
sarl $0x4, %eax
movl %eax, 0xb0(%rsp)
movl 0xc0(%rsp), %eax
movswl 0x3d29(%rip), %ecx      # 0x625e
addl %ecx, %eax
addl 0xb8(%rsp), %eax
sarl $0x4, %eax
movl %eax, 0xac(%rsp)
movl $0x0, 0xa8(%rsp)
xorl %eax, %eax
cmpl $0x2, 0xa8(%rsp)
movb %al, 0x57(%rsp)
jge 0x257e
movslq 0xa8(%rsp), %rcx
leaq 0x3c9e(%rip), %rax      # 0x6210
cmpq $0x0, (%rax,%rcx,8)
setne %al
movb %al, 0x57(%rsp)
movb 0x57(%rsp), %al
testb $0x1, %al
jne 0x258b
jmp 0x2d88
cmpl $0x0, 0xa8(%rsp)
je 0x25a1
movl 0x3cd1(%rip), %eax      # 0x626c
movl %eax, 0x50(%rsp)
jmp 0x25ab
movl 0x3cc1(%rip), %eax      # 0x6268
movl %eax, 0x50(%rsp)
movl 0x50(%rsp), %eax
movl %eax, 0xa4(%rsp)
movl $0x0, 0xa0(%rsp)
movl 0xa0(%rsp), %eax
cmpl 0xb0(%rsp), %eax
jge 0x2d15
movl $0x0, 0x9c(%rsp)
movl 0x9c(%rsp), %eax
cmpl 0xac(%rsp), %eax
jge 0x2cfd
movl $0x0, 0x98(%rsp)
cmpl $0x3, 0x98(%rsp)
jge 0x2ce5
cmpl $0x0, 0x98(%rsp)
jne 0x2624
movswl 0x3c44(%rip), %eax      # 0x6262
movl %eax, 0x4c(%rsp)
jmp 0x262f
movswl 0x3c39(%rip), %eax      # 0x6264
movl %eax, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
movl %eax, 0x94(%rsp)
cmpl $0x0, 0x98(%rsp)
jne 0x2651
movsbl 0x3c0d(%rip), %eax      # 0x6258
movl %eax, 0x48(%rsp)
jmp 0x265c
movsbl 0x3c01(%rip), %eax      # 0x6259
movl %eax, 0x48(%rsp)
movl 0x48(%rsp), %eax
movl %eax, 0x90(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x98(%rsp)
movb %al, 0x47(%rsp)
jle 0x268e
movswl 0x3bde(%rip), %eax      # 0x625c
movswl 0x3bd5(%rip), %ecx      # 0x625a
cmpl %ecx, %eax
setl %al
movb %al, 0x47(%rsp)
movb 0x47(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x8c(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x98(%rsp)
movb %al, 0x46(%rsp)
jle 0x26c5
movswl 0x3bab(%rip), %eax      # 0x6260
movswl 0x3ba2(%rip), %ecx      # 0x625e
cmpl %ecx, %eax
setl %al
movb %al, 0x46(%rsp)
movb 0x46(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x88(%rsp)
movl 0xa8(%rsp), %edx
leaq 0x3b3d(%rip), %rax      # 0x6220
movq %rax, %rcx
addq $0x18, %rcx
cmpl $0x0, %edx
cmovneq %rcx, %rax
movslq 0x98(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x80(%rsp)
movslq 0xa8(%rsp), %rcx
leaq 0x3afc(%rip), %rax      # 0x6210
movq (%rax,%rcx,8), %rax
cmpl $0x0, 0x98(%rsp)
setg %cl
andb $0x1, %cl
movzbl %cl, %ecx
movl %ecx, 0x3c(%rsp)
movswl 0x3b26(%rip), %edx      # 0x625a
movsbl 0x3b1d(%rip), %ecx      # 0x6258
shll %cl, %edx
movl 0x3c(%rsp), %ecx
imull %edx, %ecx
movswl 0x3b13(%rip), %edx      # 0x625e
imull %edx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
cmpl $0x1, 0x98(%rsp)
setg %cl
andb $0x1, %cl
movzbl %cl, %ecx
movl %ecx, 0x40(%rsp)
movswl 0x3aec(%rip), %edx      # 0x625c
movsbl 0x3ae2(%rip), %ecx      # 0x6259
shll %cl, %edx
movl 0x40(%rsp), %ecx
imull %edx, %ecx
movswl 0x3ad9(%rip), %edx      # 0x6260
imull %edx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, 0x78(%rsp)
movl 0x9c(%rsp), %edi
shll $0x4, %edi
subl 0xb4(%rsp), %edi
xorl %esi, %esi
callq 0x2db0
movl 0x8c(%rsp), %ecx
sarl %cl, %eax
movl %eax, 0x74(%rsp)
movl 0x9c(%rsp), %edi
shll $0x4, %edi
subl 0xb4(%rsp), %edi
addl $0x10, %edi
movswl 0x3a85(%rip), %esi      # 0x625a
callq 0x2de0
movl 0x8c(%rsp), %ecx
sarl %cl, %eax
movl %eax, 0x70(%rsp)
movl $0x0, 0x6c(%rsp)
movl 0xa0(%rsp), %edi
shll $0x4, %edi
subl 0xc0(%rsp), %edi
xorl %esi, %esi
callq 0x2db0
movl 0x88(%rsp), %ecx
sarl %cl, %eax
movl %eax, 0x68(%rsp)
movl 0x74(%rsp), %ecx
xorl %eax, %eax
cmpl 0x70(%rsp), %ecx
movb %al, 0x3b(%rsp)
jge 0x2866
movl 0x68(%rsp), %eax
movl %eax, 0x34(%rsp)
movl 0xa0(%rsp), %edi
shll $0x4, %edi
subl 0xc0(%rsp), %edi
addl $0x10, %edi
movswl 0x3a17(%rip), %esi      # 0x625e
callq 0x2de0
movl %eax, %edx
movl 0x34(%rsp), %eax
movl 0x88(%rsp), %ecx
sarl %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
setl %al
movb %al, 0x3b(%rsp)
movb 0x3b(%rsp), %al
testb $0x1, %al
jne 0x2873
jmp 0x290d
movq 0x80(%rsp), %rdi
movl 0x68(%rsp), %eax
imull 0x94(%rsp), %eax
cltq
addq %rax, %rdi
movl 0x74(%rsp), %eax
movl 0x90(%rsp), %ecx
shll %cl, %eax
cltq
addq %rax, %rdi
movq 0x78(%rsp), %rsi
movl 0x68(%rsp), %eax
movswl 0x39ac(%rip), %edx      # 0x625a
movl 0x8c(%rsp), %ecx
sarl %cl, %edx
movl 0x90(%rsp), %ecx
shll %cl, %edx
movl %edx, %ecx
imull %ecx, %eax
cltq
addq %rax, %rsi
movl 0x74(%rsp), %eax
movl 0x90(%rsp), %ecx
shll %cl, %eax
cltq
addq %rax, %rsi
movl 0x70(%rsp), %eax
subl 0x74(%rsp), %eax
movl 0x90(%rsp), %ecx
shll %cl, %eax
movslq %eax, %rdx
callq 0x1110
orl 0x6c(%rsp), %eax
movl %eax, 0x6c(%rsp)
movl 0x68(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x68(%rsp)
jmp 0x2814
cmpl $0x0, 0x6c(%rsp)
je 0x2ccd
movl 0xa4(%rsp), %eax
movl %eax, 0x28(%rsp)
movl 0xa0(%rsp), %eax
movl %eax, 0x2c(%rsp)
movl 0x9c(%rsp), %eax
movl %eax, 0x30(%rsp)
cmpl $0x0, 0x98(%rsp)
jne 0x2951
leaq 0x1e7e(%rip), %rax      # 0x47c8
movq %rax, 0x20(%rsp)
jmp 0x2972
movl 0x98(%rsp), %edx
leaq 0x1e71(%rip), %rax      # 0x47d0
leaq 0x1e67(%rip), %rcx      # 0x47cd
cmpl $0x1, %edx
cmoveq %rcx, %rax
movq %rax, 0x20(%rsp)
movl 0x30(%rsp), %ecx
movl 0x2c(%rsp), %edx
movl 0x28(%rsp), %esi
movq 0x20(%rsp), %r8
leaq 0x1e02(%rip), %rdi      # 0x478c
movb $0x0, %al
callq 0x10b0
movl 0xa0(%rsp), %eax
shll $0x4, %eax
subl 0xc0(%rsp), %eax
movl 0x88(%rsp), %ecx
sarl %cl, %eax
movl %eax, 0x64(%rsp)
movl 0x64(%rsp), %eax
movl 0xa0(%rsp), %edx
shll $0x4, %edx
subl 0xc0(%rsp), %edx
addl $0x10, %edx
movl 0x88(%rsp), %ecx
sarl %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0x2b33
movl 0x9c(%rsp), %eax
shll $0x4, %eax
subl 0xb4(%rsp), %eax
movl 0x8c(%rsp), %ecx
sarl %cl, %eax
movl %eax, 0x60(%rsp)
movl 0x60(%rsp), %eax
movl 0x9c(%rsp), %edx
shll $0x4, %edx
subl 0xb4(%rsp), %edx
addl $0x10, %edx
movl 0x8c(%rsp), %ecx
sarl %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0x2b15
cmpl $0x0, 0x64(%rsp)
jl 0x2a65
movl 0x64(%rsp), %eax
movswl 0x3829(%rip), %edx      # 0x625e
movl 0x88(%rsp), %ecx
sarl %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0x2a65
cmpl $0x0, 0x60(%rsp)
jl 0x2a65
movl 0x60(%rsp), %eax
movswl 0x3804(%rip), %edx      # 0x625a
movl 0x8c(%rsp), %ecx
sarl %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jl 0x2a73
leaq 0x1d67(%rip), %rax      # 0x47d3
movq %rax, 0x18(%rsp)
jmp 0x2ada
movq 0x80(%rsp), %rax
movl 0x64(%rsp), %ecx
imull 0x94(%rsp), %ecx
addl 0x60(%rsp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %edx
movq 0x78(%rsp), %rax
movl 0x64(%rsp), %ecx
movl %ecx, 0x14(%rsp)
movswl 0x37b4(%rip), %esi      # 0x625a
movl 0x8c(%rsp), %ecx
sarl %cl, %esi
movl 0x14(%rsp), %ecx
imull %esi, %ecx
addl 0x60(%rsp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %esi
leaq 0x1d15(%rip), %rax      # 0x47dd
leaq 0x1d09(%rip), %rcx      # 0x47d8
cmpl %esi, %edx
cmoveq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
movq 0x80(%rsp), %rax
movl 0x64(%rsp), %ecx
imull 0x94(%rsp), %ecx
addl 0x60(%rsp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %esi
movb $0x0, %al
callq 0x10b0
movl 0x60(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x60(%rsp)
jmp 0x29f8
leaq 0x1c6e(%rip), %rdi      # 0x478a
movb $0x0, %al
callq 0x10b0
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
jmp 0x29af
leaq 0x1cb1(%rip), %rdi      # 0x47eb
movb $0x0, %al
callq 0x10b0
movl 0xa0(%rsp), %eax
shll $0x4, %eax
subl 0xc0(%rsp), %eax
movl 0x88(%rsp), %ecx
sarl %cl, %eax
movl %eax, 0x5c(%rsp)
movl 0x5c(%rsp), %eax
movl 0xa0(%rsp), %edx
shll $0x4, %edx
subl 0xc0(%rsp), %edx
addl $0x10, %edx
movl 0x88(%rsp), %ecx
sarl %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0x2caf
movl 0x9c(%rsp), %eax
shll $0x4, %eax
subl 0xb4(%rsp), %eax
movl 0x8c(%rsp), %ecx
sarl %cl, %eax
movl %eax, 0x58(%rsp)
movl 0x58(%rsp), %eax
movl 0x9c(%rsp), %edx
shll $0x4, %edx
subl 0xb4(%rsp), %edx
addl $0x10, %edx
movl 0x8c(%rsp), %ecx
sarl %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
jge 0x2c91
movb $0x1, %al
cmpl $0x0, 0x5c(%rsp)
movb %al, 0x13(%rsp)
jl 0x2c32
movl 0x5c(%rsp), %eax
movl %eax, 0xc(%rsp)
movswl 0x366f(%rip), %edx      # 0x625e
movl 0x88(%rsp), %ecx
sarl %cl, %edx
movl 0xc(%rsp), %ecx
movb $0x1, %al
cmpl %edx, %ecx
movb %al, 0x13(%rsp)
jge 0x2c32
movb $0x1, %al
cmpl $0x0, 0x58(%rsp)
movb %al, 0x13(%rsp)
jl 0x2c32
movl 0x58(%rsp), %eax
movswl 0x363c(%rip), %edx      # 0x625a
movl 0x8c(%rsp), %ecx
sarl %cl, %edx
movl %edx, %ecx
cmpl %ecx, %eax
setge %al
movb %al, 0x13(%rsp)
movb 0x13(%rsp), %cl
leaq 0x1b9b(%rip), %rdi      # 0x47d8
leaq 0x1b8f(%rip), %rax      # 0x47d3
testb $0x1, %cl
cmovneq %rax, %rdi
movq 0x78(%rsp), %rax
movl 0x5c(%rsp), %ecx
movl %ecx, 0x8(%rsp)
movswl 0x35fb(%rip), %edx      # 0x625a
movl 0x8c(%rsp), %ecx
sarl %cl, %edx
movl 0x8(%rsp), %ecx
imull %edx, %ecx
addl 0x58(%rsp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %esi
movb $0x0, %al
callq 0x10b0
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x58(%rsp)
jmp 0x2ba8
leaq 0x1af2(%rip), %rdi      # 0x478a
movb $0x0, %al
callq 0x10b0
movl 0x5c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x5c(%rsp)
jmp 0x2b5f
leaq 0x1ad5(%rip), %rax      # 0x478b
movq %rax, 0x345b(%rip)      # 0x6118
movl $0xfffffffe, 0xc4(%rsp) # imm = 0xFFFFFFFE
jmp 0x2d93
jmp 0x2ccf
movl 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x98(%rsp)
jmp 0x25ff
jmp 0x2ce7
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x9c(%rsp)
jmp 0x25e0
jmp 0x2cff
movl 0xa0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa0(%rsp)
jmp 0x25c1
movswl 0x353e(%rip), %eax      # 0x625a
movsbl 0x3535(%rip), %ecx      # 0x6258
shll %cl, %eax
movswl 0x3532(%rip), %ecx      # 0x625e
imull %ecx, %eax
movswl 0x3526(%rip), %edx      # 0x625c
movsbl 0x351c(%rip), %ecx      # 0x6259
shll %cl, %edx
movl %edx, %ecx
movswl 0x3518(%rip), %edx      # 0x6260
imull %edx, %ecx
shll %ecx
addl %ecx, %eax
movslq 0xa8(%rsp), %rcx
leaq 0x34b2(%rip), %rdx      # 0x6210
movq (%rdx,%rcx,8), %rdx
cltq
addq %rax, %rdx
leaq 0x34a2(%rip), %rax      # 0x6210
movq %rdx, (%rax,%rcx,8)
movl 0xa8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xa8(%rsp)
jmp 0x2553
movl $0x0, 0xc4(%rsp)
movl 0xc4(%rsp), %eax
addq $0xc8, %rsp
retq
nopw %cs:(%rax,%rax)