// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/misc/codecs.cpp
// Function: GetDelta(int*, int*, int, int)
int GetDelta(int line[], int prevline[], int x, int parts)
{
	int	 pixb1 = (x > 0 ? line[x - 1] : 0);

	int	 bias;
	int	 redbias;
	int	 greenbias;
	int	 bluebias;
	int	 alphabias;

	switch (parts)
	{
		case 1:
			bias = line[x] - (pixb1 + prevline[x]) / 2;

			if ((bias > -Math::Pow(2l, 3)) && (bias <= Math::Pow(2l, 3))) return 1;

			break;
		case 3:
			redbias	  = Color(line[x]).GetRed()   - (Color(pixb1).GetRed()	 + Color(prevline[x]).GetRed())	  / 2;
			greenbias = Color(line[x]).GetGreen() - (Color(pixb1).GetGreen() + Color(prevline[x]).GetGreen()) / 2;
			bluebias  = Color(line[x]).GetBlue()  - (Color(pixb1).GetBlue()	 + Color(prevline[x]).GetBlue())  / 2;

			if (((redbias > -Math::Pow(2l, 5)) && (redbias <= Math::Pow(2l, 5))) && ((greenbias > -Math::Pow(2l, 5)) && (greenbias <= Math::Pow(2l, 5))) && ((bluebias > -Math::Pow(2l, 5)) && (bluebias <= Math::Pow(2l, 5)))) return 1;

			break;
		case 4:
			redbias	  = Color(line[x]).GetRed()   - (Color(pixb1).GetRed()	 + Color(prevline[x]).GetRed())	  / 2;
			greenbias = Color(line[x]).GetGreen() - (Color(pixb1).GetGreen() + Color(prevline[x]).GetGreen()) / 2;
			bluebias  = Color(line[x]).GetBlue()  - (Color(pixb1).GetBlue()	 + Color(prevline[x]).GetBlue())  / 2;
			alphabias = Color(line[x]).GetAlpha() - (Color(pixb1).GetAlpha() + Color(prevline[x]).GetAlpha()) / 2;

			if (((redbias > -Math::Pow(2l, 5)) && (redbias <= Math::Pow(2l, 5))) && ((greenbias > -Math::Pow(2l, 5)) && (greenbias <= Math::Pow(2l, 5))) && ((bluebias > -Math::Pow(2l, 5)) && (bluebias <= Math::Pow(2l, 5))) && ((alphabias > -Math::Pow(2l, 5)) && (alphabias <= Math::Pow(2l, 5)))) return 1;

			break;
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testl %edx, %edx
jle 0xb298e
movl %edx, %eax
movl -0x4(%rdi,%rax,4), %ebx
jmp 0xb2990
xorl %ebx, %ebx
cmpl $0x4, %ecx
je 0xb2b19
cmpl $0x3, %ecx
je 0xb2a01
cmpl $0x1, %ecx
jne 0xb2c30
movslq %edx, %rcx
addl (%rsi,%rcx,4), %ebx
pushq $-0x2
popq %rsi
movl %ebx, %eax
cltd
idivl %esi
addl (%rdi,%rcx,4), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, (%rsp)
pushq $0x2
popq %rdi
pushq $0x3
popq %rsi
callq 0x570f0
xorpd 0x30acc(%rip), %xmm0    # 0xe34a0
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xb2c30
pushq $0x2
popq %rdi
pushq $0x3
popq %rsi
callq 0x570f0
ucomisd (%rsp), %xmm0
jb 0xb2c30
pushq $0x1
popq %rax
jmp 0xb2c32
movslq %edx, %rax
movl (%rdi,%rax,4), %ebp
movl $0xff, %r15d
movl %ebp, %ecx
andl %r15d, %ecx
movl (%rsi,%rax,4), %r14d
movl %ebx, %eax
andl %r15d, %eax
movl %r14d, %edx
andl %r15d, %edx
addl %eax, %edx
shrl %edx
subl %edx, %ecx
cvtsi2sd %ecx, %xmm0
movsd %xmm0, (%rsp)
pushq $0x2
popq %rdi
pushq $0x5
popq %rsi
callq 0x570f0
xorpd 0x30a5d(%rip), %xmm0    # 0xe34a0
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xb2c30
pushq $0x2
popq %rdi
pushq $0x5
popq %rsi
callq 0x570f0
ucomisd (%rsp), %xmm0
jb 0xb2c30
movl %ebp, %eax
shrl $0x8, %eax
andl %r15d, %eax
movl %ebx, %ecx
shrl $0x8, %ecx
movl %r14d, %edx
shrl $0x8, %edx
andl %r15d, %ecx
andl %r15d, %edx
addl %ecx, %edx
shrl %edx
subl %edx, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, (%rsp)
pushq $0x2
popq %rdi
pushq $0x5
popq %rsi
callq 0x570f0
xorpd 0x309fd(%rip), %xmm0    # 0xe34a0
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xb2c30
pushq $0x2
popq %rdi
pushq $0x5
popq %rsi
callq 0x570f0
ucomisd (%rsp), %xmm0
jb 0xb2c30
shrl $0x10, %ebp
andl %r15d, %ebp
shrl $0x10, %ebx
shrl $0x10, %r14d
andl %r15d, %ebx
andl %r15d, %r14d
addl %ebx, %r14d
shrl %r14d
subl %r14d, %ebp
cvtsi2sd %ebp, %xmm0
movsd %xmm0, (%rsp)
pushq $0x2
popq %rdi
pushq $0x5
popq %rsi
callq 0x570f0
xorpd 0x309a0(%rip), %xmm0    # 0xe34a0
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xb2c30
pushq $0x2
popq %rdi
pushq $0x5
jmp 0xb29e8
movslq %edx, %rax
movl (%rdi,%rax,4), %ebp
movl $0xff, %r15d
movl %ebp, %ecx
andl %r15d, %ecx
movl (%rsi,%rax,4), %r14d
movl %ebx, %eax
andl %r15d, %eax
movl %r14d, %edx
andl %r15d, %edx
addl %eax, %edx
shrl %edx
subl %edx, %ecx
cvtsi2sd %ecx, %xmm0
movsd %xmm0, (%rsp)
pushq $0x2
popq %rdi
pushq $0x5
popq %rsi
callq 0x570f0
xorpd 0x30945(%rip), %xmm0    # 0xe34a0
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xb2c30
pushq $0x2
popq %rdi
pushq $0x5
popq %rsi
callq 0x570f0
ucomisd (%rsp), %xmm0
jb 0xb2c30
movl %ebp, %eax
shrl $0x8, %eax
andl %r15d, %eax
movl %ebx, %ecx
shrl $0x8, %ecx
movl %r14d, %edx
shrl $0x8, %edx
andl %r15d, %ecx
andl %r15d, %edx
addl %ecx, %edx
shrl %edx
subl %edx, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, (%rsp)
pushq $0x2
popq %rdi
pushq $0x5
popq %rsi
callq 0x570f0
xorpd 0x308e5(%rip), %xmm0    # 0xe34a0
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xb2c30
pushq $0x2
popq %rdi
pushq $0x5
popq %rsi
callq 0x570f0
ucomisd (%rsp), %xmm0
jb 0xb2c30
movl %ebp, %eax
shrl $0x10, %eax
andl %r15d, %eax
movl %ebx, %ecx
shrl $0x10, %ecx
movl %r14d, %edx
shrl $0x10, %edx
andl %r15d, %ecx
andl %r15d, %edx
addl %ecx, %edx
shrl %edx
subl %edx, %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, (%rsp)
pushq $0x2
popq %rdi
pushq $0x5
popq %rsi
callq 0x570f0
xorpd 0x3088d(%rip), %xmm0    # 0xe34a0
movsd (%rsp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0xb2c30
pushq $0x2
popq %rdi
pushq $0x5
popq %rsi
callq 0x570f0
ucomisd (%rsp), %xmm0
jae 0xb2c3d
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
shrl $0x18, %ebp
shrl $0x18, %ebx
shrl $0x18, %r14d
jmp 0xb2adb