// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xc0, %rsp
movl $0x0, -0x4(%rbp)
cmpl $0x2, -0x4(%rbp)
jae 0x9ff09
movl -0x4(%rbp), %edx
movl $0x10, %eax
movl $0x20, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
cmpl $0x8, -0xc(%rbp)
jae 0x9fef9
movl $0x0, -0x10(%rbp)
cmpl $0x4, -0x10(%rbp)
jae 0x9fee9
movl -0x4(%rbp), %eax
movl -0xc(%rbp), %ecx
shll %ecx
addl %ecx, %eax
movl -0x10(%rbp), %ecx
shll $0x4, %ecx
addl %ecx, %eax
movl %eax, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
cmpl $0x100, -0x18(%rbp)     # imm = 0x100
jae 0x9fed9
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x8(%rbp), %eax
jae 0x9fe79
movl -0x4(%rbp), %edi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movl -0x24(%rbp), %ecx
callq 0x9ffd0
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
subl -0x18(%rbp), %eax
movl %eax, %ecx
negl %ecx
cmovnsl %ecx, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x9fe6c
movl -0x2c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x9fe6a
jmp 0x9fe79
jmp 0x9fe6c
jmp 0x9fe6e
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x9fe22
cmpl $0xff, -0x1c(%rbp)
ja 0x9fe84
jmp 0x9fea3
leaq 0x186e1(%rip), %rdi     # 0xb856c
leaq 0x18491(%rip), %rsi     # 0xb8323
movl $0x78b, %edx            # imm = 0x78B
leaq 0x186e0(%rip), %rcx     # 0xb857e
callq 0x61a0
movl -0x20(%rbp), %eax
movl -0x1c(%rbp), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movw %ax, %dx
movl -0x14(%rbp), %eax
movl %eax, %ecx
leaq 0x6182d3(%rip), %rax    # 0x6b8190
shlq $0x9, %rcx
addq %rcx, %rax
movl -0x18(%rbp), %ecx
movw %dx, (%rax,%rcx,2)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x9fe00
jmp 0x9fedb
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x9fdda
jmp 0x9feeb
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x9fdc9
jmp 0x9fefb
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x9fda2
movl $0x0, -0xb4(%rbp)
cmpl $0x20, -0xb4(%rbp)
jge 0x9ff4f
movl -0xb4(%rbp), %ecx
shll $0x3, %ecx
movl -0xb4(%rbp), %eax
sarl $0x2, %eax
orl %eax, %ecx
movslq -0xb4(%rbp), %rax
movl %ecx, -0xb0(%rbp,%rax,4)
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x9ff13
movl $0x0, -0xb8(%rbp)
cmpl $0x110, -0xb8(%rbp)     # imm = 0x110
jge 0x9ffbd
movl -0xb8(%rbp), %edi
subl $0x8, %edi
xorl %esi, %esi
movl $0xff, %edx
callq 0xa1aa0
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %edi
movl $0x1f, %esi
callq 0xa00c0
cltq
movl -0xb0(%rbp,%rax,4), %eax
movb %al, %dl
movslq -0xb8(%rbp), %rcx
leaq 0x6201e7(%rip), %rax    # 0x6c0190
movb %dl, (%rax,%rcx)
movl -0xb8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb8(%rbp)
jmp 0x9ff59
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)