// File: /workspace/github_c_makefile_star2_O2/jonof[P]jftekwar/jfbuild/src/rg_etc1.cpp
// Function: rg_etc1::pack_etc1_block_init()
void pack_etc1_block_init()
   {
      for (uint diff = 0; diff < 2; diff++)
      {
         const uint limit = diff ? 32 : 16;

         for (uint inten = 0; inten < 8; inten++)
         {
            for (uint selector = 0; selector < 4; selector++)
            {
               const uint inverse_table_index = diff + (inten << 1) + (selector << 4);
               for (uint color = 0; color < 256; color++)
               {
                  uint best_error = cUINT32_MAX, best_packed_c = 0;
                  for (uint packed_c = 0; packed_c < limit; packed_c++)
                  {
                     int v = etc1_decode_value(diff, inten, selector, packed_c);
                     uint err = abs(v - static_cast<int>(color));  //JonoF
                     if (err < best_error)
                     {
                        best_error = err;
                        best_packed_c = packed_c;
                        if (!best_error) 
                           break;
                     }
                  }
                  RG_ETC1_ASSERT(best_error <= 255);
                  g_etc1_inverse_lookup[inverse_table_index][color] = static_cast<uint16>(best_packed_c | (best_error << 8));
               }
            }
         }
      }
      
      uint expand5[32];
      for(int i = 0; i < 32; i++)
         expand5[i] = (i << 3) | (i >> 2);

      for(int i = 0; i < 256 + 16; i++)
      {
         int v = clamp<int>(i - 8, 0, 255);
         g_quant5_tab[i] = static_cast<uint8>(expand5[mul_8bit(v,31)]);
      }
   }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
xorl %eax, %eax
movl $0xff, %edi
xorl %r8d, %r8d
cmpq $0x2, %r8
je 0x601f9
xorl %r9d, %r9d
testq %r8, %r8
setne %r9b
shll $0x4, %r9d
addl $0x10, %r9d
xorl %ecx, %ecx
cmpq $0x8, %rcx
je 0x601f1
leaq (%rcx,%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rsp)
movq %rcx, %rdx
shlq $0x4, %rdx
leaq 0x11abd(%rip), %rcx     # 0x71bc0
addq %rcx, %rdx
movq %rdx, 0x8(%rsp)
xorl %edx, %edx
cmpq $0x4, %rdx
je 0x601e5
movq %rdx, %r15
shlq $0x4, %r15
orq 0x10(%rsp), %r15
orq %r8, %r15
movq 0x8(%rsp), %rcx
movq %rdx, 0x18(%rsp)
leaq (%rcx,%rdx,4), %r12
shlq $0x9, %r15
leaq 0x65e071(%rip), %rcx    # 0x6be1b0
addq %rcx, %r15
xorl %r13d, %r13d
cmpq $0x100, %r13            # imm = 0x100
je 0x601d8
xorl %r10d, %r10d
xorl %esi, %esi
pushq $-0x1
popq %rdx
xorl %ebp, %ebp
xorl %r11d, %r11d
cmpl %r11d, %r9d
je 0x601ba
testq %r8, %r8
je 0x60174
movl %r11d, %ebx
shrl $0x2, %ebx
orl %r10d, %ebx
jmp 0x60179
movl %esi, %ebx
orl %r11d, %ebx
addl (%r12), %ebx
cmpl %edi, %ebx
cmovgel %edi, %ebx
testl %ebx, %ebx
cmovlel %eax, %ebx
movl %ebx, %ecx
subl %r13d, %ecx
movl %ecx, %r14d
negl %r14d
cmovsl %ecx, %r14d
cmpq %rbx, %r13
setne %cl
cmpl %edx, %r14d
cmovbl %r14d, %edx
setae %bl
cmovbl %r11d, %ebp
orb %cl, %bl
incl %r11d
addl $0x10, %esi
addl $0x8, %r10d
testb %bl, %bl
jne 0x6015f
cmpl $0x100, %edx            # imm = 0x100
jae 0x60273
shll $0x8, %edx
orl %edx, %ebp
movw %bp, (%r15,%r13,2)
incq %r13
jmp 0x60145
movq 0x18(%rsp), %rdx
incq %rdx
jmp 0x6010d
movq (%rsp), %rcx
incq %rcx
jmp 0x600de
incq %r8
jmp 0x600c0
xorl %eax, %eax
xorl %ecx, %ecx
cmpq $0x20, %rcx
je 0x60216
movl %ecx, %edx
shrl $0x2, %edx
addl %eax, %edx
movl %edx, 0x20(%rsp,%rcx,4)
incq %rcx
addl $0x8, %eax
jmp 0x601fd
xorl %eax, %eax
movl $0x107, %ecx            # imm = 0x107
pushq $0x8
popq %rdx
leaq 0x665f89(%rip), %rsi    # 0x6c61b0
cmpq $0x110, %rax            # imm = 0x110
je 0x60261
cmpl %ecx, %eax
movl $0x107, %edi            # imm = 0x107
cmovll %eax, %edi
cmpl $0x9, %edi
cmovll %edx, %edi
imull $0x1f, %edi, %edi
leal -0x78(%rdi), %r8d
shrl $0x8, %r8d
addl %r8d, %edi
addl $-0x78, %edi
shrl $0x8, %edi
movb 0x20(%rsp,%rdi,4), %dil
movb %dil, (%rax,%rsi)
incq %rax
jmp 0x60227
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x113fe(%rip), %rdi     # 0x71678
leaq 0x111ae(%rip), %rsi     # 0x7142f
leaq 0x11402(%rip), %rcx     # 0x7168a
movl $0x78b, %edx            # imm = 0x78B
callq 0x61b0