// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/engine.c
// Function: setpalettefade
void setpalettefade(unsigned char r, unsigned char g, unsigned char b, unsigned char offset)
{
	int i,k;
	palette_t p;

	palfadergb.r = min(63,r) << 2;
	palfadergb.g = min(63,g) << 2;
	palfadergb.b = min(63,b) << 2;
	palfadedelta = min(63,offset) << 2;

	k = 0;
	for (i=0;i<256;i++) {
		if (usegammabrightness) p = curpalette[i];
		else {
			p.b = britable[curbrightness][ curpalette[i].b ];
			p.g	= britable[curbrightness][ curpalette[i].g ];
			p.r = britable[curbrightness][ curpalette[i].r ];
		}

		tempbuf[k++] =
			(curpalettefaded[i].b =
				p.b + ( ( ( (int)palfadergb.b - (int)p.b ) * (int)offset ) >> 6 ) ) >> 2;
		tempbuf[k++] =
			(curpalettefaded[i].g =
				p.g + ( ( ( (int)palfadergb.g - (int)p.g ) * (int)offset ) >> 6 ) ) >> 2;
		tempbuf[k++] =
			(curpalettefaded[i].r =
				p.r + ( ( ( (int)palfadergb.r - (int)p.r ) * (int)offset ) >> 6 ) ) >> 2;
		tempbuf[k++] = curpalettefaded[i].f = 0;
	}

	setpalette(0,256,(unsigned char*)tempbuf);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb %cl, %al
movb %dl, %cl
movb %sil, %dl
movb %dil, %sil
movb %sil, -0x1(%rbp)
movb %dl, -0x2(%rbp)
movb %cl, -0x3(%rbp)
movb %al, -0x4(%rbp)
movzbl -0x1(%rbp), %ecx
movl $0x3f, %eax
cmpl %ecx, %eax
jge 0x57c06
movl $0x3f, %eax
movl %eax, -0x14(%rbp)
jmp 0x57c0d
movzbl -0x1(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %eax
shll $0x2, %eax
movb %al, 0x19d986(%rip)     # 0x1f559f
movzbl -0x2(%rbp), %ecx
movl $0x3f, %eax
cmpl %ecx, %eax
jge 0x57c30
movl $0x3f, %eax
movl %eax, -0x18(%rbp)
jmp 0x57c37
movzbl -0x2(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
shll $0x2, %eax
movb %al, 0x19d95d(%rip)     # 0x1f55a0
movzbl -0x3(%rbp), %ecx
movl $0x3f, %eax
cmpl %ecx, %eax
jge 0x57c5a
movl $0x3f, %eax
movl %eax, -0x1c(%rbp)
jmp 0x57c61
movzbl -0x3(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
shll $0x2, %eax
movb %al, 0x19d934(%rip)     # 0x1f55a1
movzbl -0x4(%rbp), %ecx
movl $0x3f, %eax
cmpl %ecx, %eax
jge 0x57c84
movl $0x3f, %eax
movl %eax, -0x20(%rbp)
jmp 0x57c8b
movzbl -0x4(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
shll $0x2, %eax
movb %al, 0x19d90c(%rip)     # 0x1f55a3
movl $0x0, -0xc(%rbp)
movl $0x0, -0x8(%rbp)
cmpl $0x100, -0x8(%rbp)      # imm = 0x100
jge 0x57e6b
cmpl $0x0, 0x88fc3(%rip)     # 0xe0c7c
je 0x57cd1
movslq -0x8(%rbp), %rcx
leaq 0x41953a(%rip), %rax    # 0x471200
movl (%rax,%rcx,4), %eax
movl %eax, -0x10(%rbp)
jmp 0x57d51
movslq 0x19d88c(%rip), %rcx    # 0x1f5564
leaq 0x419d21(%rip), %rax    # 0x471a00
shlq $0x8, %rcx
addq %rcx, %rax
movslq -0x8(%rbp), %rdx
leaq 0x41950f(%rip), %rcx    # 0x471200
movzbl 0x2(%rcx,%rdx,4), %ecx
movb (%rax,%rcx), %al
movb %al, -0xe(%rbp)
movslq 0x19d861(%rip), %rcx    # 0x1f5564
leaq 0x419cf6(%rip), %rax    # 0x471a00
shlq $0x8, %rcx
addq %rcx, %rax
movslq -0x8(%rbp), %rdx
leaq 0x4194e4(%rip), %rcx    # 0x471200
movzbl 0x1(%rcx,%rdx,4), %ecx
movb (%rax,%rcx), %al
movb %al, -0xf(%rbp)
movslq 0x19d836(%rip), %rcx    # 0x1f5564
leaq 0x419ccb(%rip), %rax    # 0x471a00
shlq $0x8, %rcx
addq %rcx, %rax
movslq -0x8(%rbp), %rdx
leaq 0x4194b9(%rip), %rcx    # 0x471200
movzbl (%rcx,%rdx,4), %ecx
movb (%rax,%rcx), %al
movb %al, -0x10(%rbp)
movzbl -0xe(%rbp), %eax
movzbl 0x19d845(%rip), %ecx    # 0x1f55a1
movzbl -0xe(%rbp), %edx
subl %edx, %ecx
movzbl -0x4(%rbp), %edx
imull %edx, %ecx
sarl $0x6, %ecx
addl %ecx, %eax
movslq -0x8(%rbp), %rdx
leaq 0x419887(%rip), %rcx    # 0x471600
movb %al, 0x2(%rcx,%rdx,4)
movzbl %al, %eax
sarl $0x2, %eax
movb %al, %dl
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xc(%rbp)
movslq %eax, %rcx
leaq 0x3be796(%rip), %rax    # 0x416530
movb %dl, (%rax,%rcx)
movzbl -0xf(%rbp), %eax
movzbl 0x19d7f8(%rip), %ecx    # 0x1f55a0
movzbl -0xf(%rbp), %edx
subl %edx, %ecx
movzbl -0x4(%rbp), %edx
imull %edx, %ecx
sarl $0x6, %ecx
addl %ecx, %eax
movslq -0x8(%rbp), %rdx
leaq 0x41983b(%rip), %rcx    # 0x471600
movb %al, 0x1(%rcx,%rdx,4)
movzbl %al, %eax
sarl $0x2, %eax
movb %al, %dl
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xc(%rbp)
movslq %eax, %rcx
leaq 0x3be74a(%rip), %rax    # 0x416530
movb %dl, (%rax,%rcx)
movzbl -0x10(%rbp), %eax
movzbl 0x19d7ab(%rip), %ecx    # 0x1f559f
movzbl -0x10(%rbp), %edx
subl %edx, %ecx
movzbl -0x4(%rbp), %edx
imull %edx, %ecx
sarl $0x6, %ecx
addl %ecx, %eax
movslq -0x8(%rbp), %rdx
leaq 0x4197ef(%rip), %rcx    # 0x471600
movb %al, (%rcx,%rdx,4)
movzbl %al, %eax
sarl $0x2, %eax
movb %al, %dl
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xc(%rbp)
movslq %eax, %rcx
leaq 0x3be6ff(%rip), %rax    # 0x416530
movb %dl, (%rax,%rcx)
movslq -0x8(%rbp), %rcx
leaq 0x4197c1(%rip), %rax    # 0x471600
movb $0x0, 0x3(%rax,%rcx,4)
movl -0xc(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0xc(%rbp)
movslq %eax, %rcx
leaq 0x3be6d7(%rip), %rax    # 0x416530
movb $0x0, (%rax,%rcx)
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x57ca5
xorl %edi, %edi
movl $0x100, %esi            # imm = 0x100
leaq 0x3be6b7(%rip), %rdx    # 0x416530
callq 0xa6950
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)