// File: kebwi[P]Trifid/src/Bayer.cpp
// Function: determineBlockColorOrder(int&, int&, int&, int&, int&, int&, int&, int&, int&, int&)
void determineBlockColorOrder(int &rx, int &ry, int &g1x, int &g1y, int &bx, int &by,
							int &redArrayPos, int &greenArrayPos, int &blueArrayPos,
							int &secondGreenUnusedPos)
{
	determineBlockCoord(R, rx, ry);
	determineBlockCoord(B, bx, by);
	assert(rx != bx && ry != by);
	
	g1x = 0;
	g1y = 0;
	if ((rx == 0 && ry == 0) || (bx == 0 && by == 0))
		g1x = 1;
	
	if (rx == 0 && ry == 0)
	{
		redArrayPos = 0;
		greenArrayPos = 1;
		blueArrayPos = 3;
		secondGreenUnusedPos = 2;
	}
	else if (rx == 1 && ry == 0)
	{
		redArrayPos = 1;
		greenArrayPos = 0;
		blueArrayPos = 2;
		secondGreenUnusedPos = 3;
	}
	else if (bx == 0 && by == 0)
	{
		redArrayPos = 3;
		greenArrayPos = 1;
		blueArrayPos = 0;
		secondGreenUnusedPos = 2;
	}
	else if (bx == 1 && by == 0)
	{
		redArrayPos = 2;
		greenArrayPos = 0;
		blueArrayPos = 1;
		secondGreenUnusedPos = 3;
	}
	else assert(false);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq 0x28(%rbp), %rax
movq 0x20(%rbp), %rax
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x8(%rbp), %rsi
movq -0x10(%rbp), %rdx
xorl %edi, %edi
callq 0x38180
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movl $0x2, %edi
callq 0x38180
movq -0x8(%rbp), %rax
movl (%rax), %ecx
movq -0x28(%rbp), %rdx
xorl %eax, %eax
cmpl (%rdx), %ecx
movb %al, -0x31(%rbp)
je 0x38326
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq -0x30(%rbp), %rcx
cmpl (%rcx), %eax
setne %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %al
testb $0x1, %al
jne 0x3832f
jmp 0x38331
jmp 0x38350
leaq 0x1560b(%rip), %rdi     # 0x4d943
leaq 0x155cc(%rip), %rsi     # 0x4d90b
movl $0x55, %edx
leaq 0x1560d(%rip), %rcx     # 0x4d958
callq 0x4240
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x38376
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x38388
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x38392
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x38392
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x383d1
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x383d1
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq 0x18(%rbp), %rax
movl $0x1, (%rax)
movq 0x20(%rbp), %rax
movl $0x3, (%rax)
movq 0x28(%rbp), %rax
movl $0x2, (%rax)
jmp 0x384ad
movq -0x8(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x38410
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x38410
movq 0x10(%rbp), %rax
movl $0x1, (%rax)
movq 0x18(%rbp), %rax
movl $0x0, (%rax)
movq 0x20(%rbp), %rax
movl $0x2, (%rax)
movq 0x28(%rbp), %rax
movl $0x3, (%rax)
jmp 0x384ab
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x3844c
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x3844c
movq 0x10(%rbp), %rax
movl $0x3, (%rax)
movq 0x18(%rbp), %rax
movl $0x1, (%rax)
movq 0x20(%rbp), %rax
movl $0x0, (%rax)
movq 0x28(%rbp), %rax
movl $0x2, (%rax)
jmp 0x384a9
movq -0x28(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x38488
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x38488
movq 0x10(%rbp), %rax
movl $0x2, (%rax)
movq 0x18(%rbp), %rax
movl $0x0, (%rax)
movq 0x20(%rbp), %rax
movl $0x1, (%rax)
movq 0x28(%rbp), %rax
movl $0x3, (%rax)
jmp 0x384a7
leaq 0x13835(%rip), %rdi     # 0x4bcc4
leaq 0x15475(%rip), %rsi     # 0x4d90b
movl $0x78, %edx
leaq 0x154b6(%rip), %rcx     # 0x4d958
callq 0x4240
jmp 0x384a9
jmp 0x384ab
jmp 0x384ad
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)