// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/rg_etc1.cpp
// Function: rg_etc1::dither_block_555(rg_etc1::color_quad_u8*, rg_etc1::color_quad_u8 const*)
static void dither_block_555(color_quad_u8* dest, const color_quad_u8* block)
   {
      int err[8],*ep1 = err,*ep2 = err+4;
      uint8 *quant = g_quant5_tab+8;

      memset(dest, 0xFF, sizeof(color_quad_u8)*16);

      // process channels seperately
      for(int ch=0;ch<3;ch++)
      {
         uint8* bp = (uint8*)block;
         uint8* dp = (uint8*)dest;

         bp += ch; dp += ch;

         memset(err,0, sizeof(err));
         for(int y = 0; y < 4; y++)
         {
            // pixel 0
            dp[ 0] = quant[bp[ 0] + ((3*ep2[1] + 5*ep2[0]) >> 4)];
            ep1[0] = bp[ 0] - dp[ 0];

            // pixel 1
            dp[ 4] = quant[bp[ 4] + ((7*ep1[0] + 3*ep2[2] + 5*ep2[1] + ep2[0]) >> 4)];
            ep1[1] = bp[ 4] - dp[ 4];

            // pixel 2
            dp[ 8] = quant[bp[ 8] + ((7*ep1[1] + 3*ep2[3] + 5*ep2[2] + ep2[1]) >> 4)];
            ep1[2] = bp[ 8] - dp[ 8];

            // pixel 3
            dp[12] = quant[bp[12] + ((7*ep1[2] + 5*ep2[3] + ep2[2]) >> 4)];
            ep1[3] = bp[12] - dp[12];

            // advance to next line
            int* tmp = ep1; ep1 = ep2; ep2 = tmp;
            bp += 16;
            dp += 16;
         }
      }
   }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x40(%rbp)
leaq 0x61ee55(%rip), %rax    # 0x6c0190
addq $0x8, %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movl $0xff, %esi
movl $0x40, %edx
callq 0x62d0
movl $0x0, -0x4c(%rbp)
cmpl $0x3, -0x4c(%rbp)
jge 0xa154d
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x4c(%rbp), %ecx
movq -0x58(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movl -0x4c(%rbp), %ecx
movq -0x60(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
leaq -0x30(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x62d0
movl $0x0, -0x64(%rbp)
cmpl $0x4, -0x64(%rbp)
jge 0xa153d
movq -0x48(%rbp), %rax
movq -0x58(%rbp), %rcx
movzbl (%rcx), %ecx
movq -0x40(%rbp), %rdx
imull $0x3, 0x4(%rdx), %edx
movq -0x40(%rbp), %rsi
imull $0x5, (%rsi), %esi
addl %esi, %edx
sarl $0x4, %edx
addl %edx, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %cl
movq -0x60(%rbp), %rax
movb %cl, (%rax)
movq -0x58(%rbp), %rax
movzbl (%rax), %ecx
movq -0x60(%rbp), %rax
movzbl (%rax), %eax
subl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
movq -0x58(%rbp), %rcx
movzbl 0x4(%rcx), %ecx
movq -0x38(%rbp), %rdx
imull $0x7, (%rdx), %edx
movq -0x40(%rbp), %rsi
imull $0x3, 0x8(%rsi), %esi
addl %esi, %edx
movq -0x40(%rbp), %rsi
imull $0x5, 0x4(%rsi), %esi
addl %esi, %edx
movq -0x40(%rbp), %rsi
addl (%rsi), %edx
sarl $0x4, %edx
addl %edx, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %cl
movq -0x60(%rbp), %rax
movb %cl, 0x4(%rax)
movq -0x58(%rbp), %rax
movzbl 0x4(%rax), %ecx
movq -0x60(%rbp), %rax
movzbl 0x4(%rax), %eax
subl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x48(%rbp), %rax
movq -0x58(%rbp), %rcx
movzbl 0x8(%rcx), %ecx
movq -0x38(%rbp), %rdx
imull $0x7, 0x4(%rdx), %edx
movq -0x40(%rbp), %rsi
imull $0x3, 0xc(%rsi), %esi
addl %esi, %edx
movq -0x40(%rbp), %rsi
imull $0x5, 0x8(%rsi), %esi
addl %esi, %edx
movq -0x40(%rbp), %rsi
addl 0x4(%rsi), %edx
sarl $0x4, %edx
addl %edx, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %cl
movq -0x60(%rbp), %rax
movb %cl, 0x8(%rax)
movq -0x58(%rbp), %rax
movzbl 0x8(%rax), %ecx
movq -0x60(%rbp), %rax
movzbl 0x8(%rax), %eax
subl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x48(%rbp), %rax
movq -0x58(%rbp), %rcx
movzbl 0xc(%rcx), %ecx
movq -0x38(%rbp), %rdx
imull $0x7, 0x8(%rdx), %edx
movq -0x40(%rbp), %rsi
imull $0x5, 0xc(%rsi), %esi
addl %esi, %edx
movq -0x40(%rbp), %rsi
addl 0x8(%rsi), %edx
sarl $0x4, %edx
addl %edx, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %cl
movq -0x60(%rbp), %rax
movb %cl, 0xc(%rax)
movq -0x58(%rbp), %rax
movzbl 0xc(%rax), %ecx
movq -0x60(%rbp), %rax
movzbl 0xc(%rax), %eax
subl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x58(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x58(%rbp)
movq -0x60(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x60(%rbp)
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0xa13b0
jmp 0xa153f
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xa135d
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)