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

	int	 md;
	int	 bias;
	int	 redbias;
	int	 greenbias;
	int	 bluebias;
	int	 alphabias;
	int	 gray;
	int	 red;
	int	 green;
	int	 blue;
	int	 alpha;

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

			if (in->InputBits(1) == 1) bias =     in->InputBits(3) + 1;
			else			   bias = 0 - in->InputBits(3);

			return gray + bias;
		case 3:
			red   = (Color(pixb1).GetRed()	 + Color(prevline[x]).GetRed())	  / 2;
			green = (Color(pixb1).GetGreen() + Color(prevline[x]).GetGreen()) / 2;
			blue  = (Color(pixb1).GetBlue()	 + Color(prevline[x]).GetBlue())  / 2;

			md = in->InputBits(2) + 2;

			if (in->InputBits(1) == 1) redbias   =	   in->InputBits(md) + 1;
			else			   redbias   = 0 - in->InputBits(md);

			if (in->InputBits(1) == 1) greenbias =	   in->InputBits(md) + 1;
			else			   greenbias = 0 - in->InputBits(md);

			if (in->InputBits(1) == 1) bluebias  =	   in->InputBits(md) + 1;
			else			   bluebias  = 0 - in->InputBits(md);

			return Color(red + redbias, green + greenbias, blue + bluebias);
		case 4:
			red   = (Color(pixb1).GetRed()	 + Color(prevline[x]).GetRed())	  / 2;
			green = (Color(pixb1).GetGreen() + Color(prevline[x]).GetGreen()) / 2;
			blue  = (Color(pixb1).GetBlue()	 + Color(prevline[x]).GetBlue())  / 2;
			alpha = (Color(pixb1).GetAlpha() + Color(prevline[x]).GetAlpha()) / 2;

			md = in->InputBits(2) + 2;

			if (in->InputBits(1) == 1) redbias   =	   in->InputBits(md) + 1;
			else			   redbias   = 0 - in->InputBits(md);

			if (in->InputBits(1) == 1) greenbias =	   in->InputBits(md) + 1;
			else			   greenbias = 0 - in->InputBits(md);

			if (in->InputBits(1) == 1) bluebias  =	   in->InputBits(md) + 1;
			else			   bluebias  = 0 - in->InputBits(md);

			if (in->InputBits(1) == 1) alphabias =	   in->InputBits(md) + 1;
			else			   alphabias = 0 - in->InputBits(md);

			return Color( (red   + redbias	)	 |
				     ((green + greenbias) <<  8) |
				     ((blue  + bluebias	) << 16) |
				     ((alpha + alphabias) << 24));
	}

	return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movl %ecx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
cmpl $0x0, -0x1c(%rbp)
jle 0x1189cb
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x15c(%rbp)
jmp 0x1189d5
xorl %eax, %eax
movl %eax, -0x15c(%rbp)
jmp 0x1189d5
movl -0x15c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x20(%rbp), %eax
movl %eax, -0x160(%rbp)
subl $0x1, %eax
je 0x118a13
jmp 0x1189ee
movl -0x160(%rbp), %eax
subl $0x3, %eax
je 0x118a7e
jmp 0x1189ff
movl -0x160(%rbp), %eax
subl $0x4, %eax
je 0x118c99
jmp 0x118f73
movl -0x2c(%rbp), %eax
movq -0x18(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
addl (%rcx,%rdx,4), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x48(%rbp)
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x5b960
cmpq $0x1, %rax
jne 0x118a57
movq -0x28(%rbp), %rdi
movl $0x3, %esi
callq 0x5b960
addq $0x1, %rax
movl %eax, -0x34(%rbp)
jmp 0x118a70
movq -0x28(%rbp), %rdi
movl $0x3, %esi
callq 0x5b960
movq %rax, %rcx
xorl %eax, %eax
subq %rcx, %rax
movl %eax, -0x34(%rbp)
movl -0x48(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x118f7a
movslq -0x2c(%rbp), %rsi
leaq -0x68(%rbp), %rdi
xorl %edx, %edx
callq 0x59be0
leaq -0x68(%rbp), %rdi
callq 0x59f20
movl %eax, -0x16c(%rbp)
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movslq (%rax,%rcx,4), %rsi
leaq -0x78(%rbp), %rdi
xorl %edx, %edx
callq 0x59be0
leaq -0x78(%rbp), %rdi
callq 0x59f20
movl %eax, %ecx
movl -0x16c(%rbp), %eax
addl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x4c(%rbp)
movslq -0x2c(%rbp), %rsi
leaq -0x88(%rbp), %rdi
xorl %edx, %edx
callq 0x59be0
leaq -0x88(%rbp), %rdi
callq 0x5d920
movl %eax, -0x168(%rbp)
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movslq (%rax,%rcx,4), %rsi
leaq -0x98(%rbp), %rdi
xorl %edx, %edx
callq 0x59be0
leaq -0x98(%rbp), %rdi
callq 0x5d920
movl %eax, %ecx
movl -0x168(%rbp), %eax
addl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x50(%rbp)
movslq -0x2c(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
xorl %edx, %edx
callq 0x59be0
leaq -0xa8(%rbp), %rdi
callq 0x5b650
movl %eax, -0x164(%rbp)
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movslq (%rax,%rcx,4), %rsi
leaq -0xb8(%rbp), %rdi
xorl %edx, %edx
callq 0x59be0
leaq -0xb8(%rbp), %rdi
callq 0x5b650
movl %eax, %ecx
movl -0x164(%rbp), %eax
addl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x54(%rbp)
movq -0x28(%rbp), %rdi
movl $0x2, %esi
callq 0x5b960
addq $0x2, %rax
movl %eax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x5b960
cmpq $0x1, %rax
jne 0x118bcd
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x5b960
addq $0x1, %rax
movl %eax, -0x38(%rbp)
jmp 0x118be4
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x5b960
movq %rax, %rcx
xorl %eax, %eax
subq %rcx, %rax
movl %eax, -0x38(%rbp)
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x5b960
cmpq $0x1, %rax
jne 0x118c0d
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x5b960
addq $0x1, %rax
movl %eax, -0x3c(%rbp)
jmp 0x118c24
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x5b960
movq %rax, %rcx
xorl %eax, %eax
subq %rcx, %rax
movl %eax, -0x3c(%rbp)
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x5b960
cmpq $0x1, %rax
jne 0x118c4d
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x5b960
addq $0x1, %rax
movl %eax, -0x40(%rbp)
jmp 0x118c64
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x5b960
movq %rax, %rcx
xorl %eax, %eax
subq %rcx, %rax
movl %eax, -0x40(%rbp)
movl -0x4c(%rbp), %esi
addl -0x38(%rbp), %esi
movl -0x50(%rbp), %edx
addl -0x3c(%rbp), %edx
movl -0x54(%rbp), %ecx
addl -0x40(%rbp), %ecx
leaq -0xc8(%rbp), %rdi
xorl %r8d, %r8d
callq 0x5a6b0
leaq -0xc8(%rbp), %rdi
callq 0x59210
movl %eax, -0x4(%rbp)
jmp 0x118f7a
movslq -0x2c(%rbp), %rsi
leaq -0xd8(%rbp), %rdi
xorl %edx, %edx
callq 0x59be0
leaq -0xd8(%rbp), %rdi
callq 0x59f20
movl %eax, -0x17c(%rbp)
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movslq (%rax,%rcx,4), %rsi
leaq -0xe8(%rbp), %rdi
xorl %edx, %edx
callq 0x59be0
leaq -0xe8(%rbp), %rdi
callq 0x59f20
movl %eax, %ecx
movl -0x17c(%rbp), %eax
addl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x4c(%rbp)
movslq -0x2c(%rbp), %rsi
leaq -0xf8(%rbp), %rdi
xorl %edx, %edx
callq 0x59be0
leaq -0xf8(%rbp), %rdi
callq 0x5d920
movl %eax, -0x178(%rbp)
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movslq (%rax,%rcx,4), %rsi
leaq -0x108(%rbp), %rdi
xorl %edx, %edx
callq 0x59be0
leaq -0x108(%rbp), %rdi
callq 0x5d920
movl %eax, %ecx
movl -0x178(%rbp), %eax
addl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x50(%rbp)
movslq -0x2c(%rbp), %rsi
leaq -0x118(%rbp), %rdi
xorl %edx, %edx
callq 0x59be0
leaq -0x118(%rbp), %rdi
callq 0x5b650
movl %eax, -0x174(%rbp)
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movslq (%rax,%rcx,4), %rsi
leaq -0x128(%rbp), %rdi
xorl %edx, %edx
callq 0x59be0
leaq -0x128(%rbp), %rdi
callq 0x5b650
movl %eax, %ecx
movl -0x174(%rbp), %eax
addl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x54(%rbp)
movslq -0x2c(%rbp), %rsi
leaq -0x138(%rbp), %rdi
xorl %edx, %edx
callq 0x59be0
leaq -0x138(%rbp), %rdi
callq 0x5bac0
movl %eax, -0x170(%rbp)
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movslq (%rax,%rcx,4), %rsi
leaq -0x148(%rbp), %rdi
xorl %edx, %edx
callq 0x59be0
leaq -0x148(%rbp), %rdi
callq 0x5bac0
movl %eax, %ecx
movl -0x170(%rbp), %eax
addl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x58(%rbp)
movq -0x28(%rbp), %rdi
movl $0x2, %esi
callq 0x5b960
addq $0x2, %rax
movl %eax, -0x30(%rbp)
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x5b960
cmpq $0x1, %rax
jne 0x118e53
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x5b960
addq $0x1, %rax
movl %eax, -0x38(%rbp)
jmp 0x118e6a
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x5b960
movq %rax, %rcx
xorl %eax, %eax
subq %rcx, %rax
movl %eax, -0x38(%rbp)
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x5b960
cmpq $0x1, %rax
jne 0x118e93
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x5b960
addq $0x1, %rax
movl %eax, -0x3c(%rbp)
jmp 0x118eaa
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x5b960
movq %rax, %rcx
xorl %eax, %eax
subq %rcx, %rax
movl %eax, -0x3c(%rbp)
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x5b960
cmpq $0x1, %rax
jne 0x118ed3
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x5b960
addq $0x1, %rax
movl %eax, -0x40(%rbp)
jmp 0x118eea
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x5b960
movq %rax, %rcx
xorl %eax, %eax
subq %rcx, %rax
movl %eax, -0x40(%rbp)
movq -0x28(%rbp), %rdi
movl $0x1, %esi
callq 0x5b960
cmpq $0x1, %rax
jne 0x118f13
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x5b960
addq $0x1, %rax
movl %eax, -0x44(%rbp)
jmp 0x118f2a
movq -0x28(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x5b960
movq %rax, %rcx
xorl %eax, %eax
subq %rcx, %rax
movl %eax, -0x44(%rbp)
movl -0x4c(%rbp), %eax
addl -0x38(%rbp), %eax
movl -0x50(%rbp), %ecx
addl -0x3c(%rbp), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movl -0x54(%rbp), %ecx
addl -0x40(%rbp), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movl -0x58(%rbp), %ecx
addl -0x44(%rbp), %ecx
shll $0x18, %ecx
orl %ecx, %eax
movslq %eax, %rsi
leaq -0x158(%rbp), %rdi
xorl %edx, %edx
callq 0x59be0
leaq -0x158(%rbp), %rdi
callq 0x59210
movl %eax, -0x4(%rbp)
jmp 0x118f7a
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
nopw %cs:(%rax,%rax)