// File: /workspace/github_c_makefile_star2_O1/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 $0xb8, %rsp
xorl %eax, %eax
movl $0xff, %edx
xorl %edi, %edi
xorl %r8d, %r8d
testq %rdi, %rdi
setne %r8b
shll $0x4, %r8d
addl $0x10, %r8d
xorl %ecx, %ecx
leaq (%rcx,%rcx), %rsi
movq %rsi, 0x18(%rsp)
movq %rcx, 0x8(%rsp)
movq %rcx, %rsi
shlq $0x4, %rsi
leaq 0x1227a(%rip), %rcx     # 0x7b8b0
addq %rcx, %rsi
movq %rsi, 0x10(%rsp)
xorl %esi, %esi
movq %rsi, %r9
shlq $0x4, %r9
addq 0x18(%rsp), %r9
addq %rdi, %r9
movq 0x10(%rsp), %rcx
movq %rsi, 0x20(%rsp)
movl (%rcx,%rsi,4), %ebp
shlq $0x9, %r9
leaq 0x65ab59(%rip), %rcx    # 0x6c41c0
addq %rcx, %r9
movq %r9, 0x28(%rsp)
xorl %r15d, %r15d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl $0x1, %esi
xorl %ecx, %ecx
xorl %r9d, %r9d
xorl %r13d, %r13d
leal -0x1(%rsi), %r10d
testq %rdi, %rdi
je 0x6969a
movl %r10d, %r11d
shrl $0x2, %r11d
orl %r9d, %r11d
jmp 0x696a0
movl %ecx, %r11d
orl %r10d, %r11d
addl %ebp, %r11d
cmpl %edx, %r11d
cmovgel %edx, %r11d
testl %r11d, %r11d
cmovlel %eax, %r11d
movl %r11d, %r14d
subl %r15d, %r14d
movl %r14d, %ebx
negl %ebx
cmovsl %r14d, %ebx
cmpq %r11, %r15
sete %r11b
cmpl %r12d, %ebx
cmovbl %ebx, %r12d
setb %bl
cmovbl %r10d, %r13d
testb %bl, %r11b
jne 0x696ed
leal 0x1(%rsi), %r10d
addl $0x8, %r9d
addl $0x10, %ecx
cmpl %r8d, %esi
movl %r10d, %esi
jb 0x69685
cmpl $0x100, %r12d           # imm = 0x100
jae 0x697cd
shll $0x8, %r12d
orl %r12d, %r13d
movq 0x28(%rsp), %rcx
movw %r13w, (%rcx,%r15,2)
incq %r15
cmpq $0x100, %r15            # imm = 0x100
jne 0x69672
movq 0x20(%rsp), %rsi
incq %rsi
cmpq $0x4, %rsi
jne 0x69640
movq 0x8(%rsp), %rcx
incq %rcx
cmpq $0x8, %rcx
jne 0x6961a
leaq 0x1(%rdi), %rcx
testq %rdi, %rdi
movq %rcx, %rdi
je 0x69606
xorl %eax, %eax
xorl %ecx, %ecx
movl %ecx, %edx
shrl $0x2, %edx
addl %eax, %edx
movl %edx, 0x30(%rsp,%rcx,4)
incq %rcx
addl $0x8, %eax
cmpq $0x20, %rcx
jne 0x69753
xorl %eax, %eax
movl $0x107, %ecx            # imm = 0x107
movl $0x8, %edx
leaq 0x662a43(%rip), %rsi    # 0x6cc1c0
cmpl %ecx, %eax
movl $0x107, %edi            # imm = 0x107
cmovll %eax, %edi
cmpl $0x9, %edi
cmovll %edx, %edi
movl %edi, %r8d
shll $0x5, %r8d
subl %edi, %r8d
leal -0x78(%r8), %edi
shrl $0x8, %edi
addl %r8d, %edi
addl $-0x78, %edi
shrl $0x8, %edi
movb 0x30(%rsp,%rdi,4), %dil
movb %dil, (%rax,%rsi)
incq %rax
cmpq $0x110, %rax            # imm = 0x110
jne 0x6977d
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x11c24(%rip), %rdi     # 0x7b3f8
leaq 0x119d4(%rip), %rsi     # 0x7b1af
leaq 0x11c28(%rip), %rcx     # 0x7b40a
movl $0x78b, %edx            # imm = 0x78B
callq 0x61b0