// File: /workspace/github_c_makefile_star2_O0/jonof[P]jftekwar/jfbuild/src/rg_etc1.cpp
// Function: rg_etc1::pack_etc1_block(void*, unsigned int const*, rg_etc1::etc1_pack_params&)
unsigned int pack_etc1_block(void* pETC1_block, const unsigned int* pSrc_pixels_rgba, etc1_pack_params& pack_params)
   {
      const color_quad_u8* pSrc_pixels = reinterpret_cast<const color_quad_u8*>(pSrc_pixels_rgba);
      etc1_block& dst_block = *static_cast<etc1_block*>(pETC1_block);

#ifdef RG_ETC1_BUILD_DEBUG
      // Ensure all alpha values are 0xFF.
      for (uint i = 0; i < 16; i++)
      {
         RG_ETC1_ASSERT(pSrc_pixels[i].a == 255);
      }
#endif

      color_quad_u8 src_pixel0(pSrc_pixels[0]);

      // Check for solid block.
      const uint32 first_pixel_u32 = pSrc_pixels->m_u32;
      int r;
      for (r = 15; r >= 1; --r)
         if (pSrc_pixels[r].m_u32 != first_pixel_u32)
            break;
      if (!r)
         return static_cast<unsigned int>(16 * pack_etc1_block_solid_color(dst_block, &pSrc_pixels[0].r, pack_params));
      
      color_quad_u8 dithered_pixels[16];
      if (pack_params.m_dithering)
      {
         dither_block_555(dithered_pixels, pSrc_pixels);
         pSrc_pixels = dithered_pixels;
      }

      etc1_optimizer optimizer;

      uint64 best_error = cUINT64_MAX;
      uint best_flip = false, best_use_color4 = false;
      
      uint8 best_selectors[2][8];
      etc1_optimizer::results best_results[2];
      for (uint i = 0; i < 2; i++)
      {
         best_results[i].m_n = 8;
         best_results[i].m_pSelectors = best_selectors[i];
      }
      
      uint8 selectors[3][8];
      etc1_optimizer::results results[3];
      
      for (uint i = 0; i < 3; i++)
      {
         results[i].m_n = 8;
         results[i].m_pSelectors = selectors[i];
      }
            
      color_quad_u8 subblock_pixels[8];

      etc1_optimizer::params params(pack_params);
      params.m_num_src_pixels = 8;
      params.m_pSrc_pixels = subblock_pixels;

      for (uint flip = 0; flip < 2; flip++)
      {
         for (uint use_color4 = 0; use_color4 < 2; use_color4++)
         {
            uint64 trial_error = 0;

            uint subblock;
            for (subblock = 0; subblock < 2; subblock++)
            {
               if (flip)
                  memcpy(subblock_pixels, pSrc_pixels + subblock * 8, sizeof(color_quad_u8) * 8);
               else
               {
                  const color_quad_u8* pSrc_col = pSrc_pixels + subblock * 2;
                  subblock_pixels[0] = pSrc_col[0]; subblock_pixels[1] = pSrc_col[4]; subblock_pixels[2] = pSrc_col[8]; subblock_pixels[3] = pSrc_col[12];
                  subblock_pixels[4] = pSrc_col[1]; subblock_pixels[5] = pSrc_col[5]; subblock_pixels[6] = pSrc_col[9]; subblock_pixels[7] = pSrc_col[13];
               }

               results[2].m_error = cUINT64_MAX;
               if ((params.m_quality >= cMediumQuality) && ((subblock) || (use_color4)))
               {
                  const uint32 subblock_pixel0_u32 = subblock_pixels[0].m_u32;
                  for (r = 7; r >= 1; --r)
                     if (subblock_pixels[r].m_u32 != subblock_pixel0_u32)
                        break;
                  if (!r)
                  {
                     pack_etc1_block_solid_color_constrained(results[2], 8, &subblock_pixels[0].r, pack_params, !use_color4, (subblock && !use_color4) ? &results[0].m_block_color_unscaled : NULL);
                  }
               }

               params.m_use_color4 = (use_color4 != 0);
               params.m_constrain_against_base_color5 = false;

               if ((!use_color4) && (subblock))
               {
                  params.m_constrain_against_base_color5 = true;
                  params.m_base_color5 = results[0].m_block_color_unscaled;
               }
                              
               if (params.m_quality == cHighQuality)
               {
                  static const int s_scan_delta_0_to_4[] = { -4, -3, -2, -1, 0, 1, 2, 3, 4 };
                  params.m_scan_delta_size = RG_ETC1_ARRAY_SIZE(s_scan_delta_0_to_4);
                  params.m_pScan_deltas = s_scan_delta_0_to_4;
               }
               else if (params.m_quality == cMediumQuality)
               {
                  static const int s_scan_delta_0_to_1[] = { -1, 0, 1 };
                  params.m_scan_delta_size = RG_ETC1_ARRAY_SIZE(s_scan_delta_0_to_1);
                  params.m_pScan_deltas = s_scan_delta_0_to_1;
               }
               else
               {
                  static const int s_scan_delta_0[] = { 0 };
                  params.m_scan_delta_size = RG_ETC1_ARRAY_SIZE(s_scan_delta_0);
                  params.m_pScan_deltas = s_scan_delta_0;
               }
               
               optimizer.init(params, results[subblock]);
               if (!optimizer.compute())
                  break;
                              
               if (params.m_quality >= cMediumQuality)
               {
                  // TODO: Fix fairly arbitrary/unrefined thresholds that control how far away to scan for potentially better solutions.
                  const uint refinement_error_thresh0 = 3000;
                  const uint refinement_error_thresh1 = 6000;
                  if (results[subblock].m_error > refinement_error_thresh0)
                  {
                     if (params.m_quality == cMediumQuality)
                     {
                        static const int s_scan_delta_2_to_3[] = { -3, -2, 2, 3 };
                        params.m_scan_delta_size = RG_ETC1_ARRAY_SIZE(s_scan_delta_2_to_3);
                        params.m_pScan_deltas = s_scan_delta_2_to_3;
                     }
                     else
                     {
                        static const int s_scan_delta_5_to_5[] = { -5, 5 };
                        static const int s_scan_delta_5_to_8[] = { -8, -7, -6, -5, 5, 6, 7, 8 };
                        if (results[subblock].m_error > refinement_error_thresh1)
                        {
                           params.m_scan_delta_size = RG_ETC1_ARRAY_SIZE(s_scan_delta_5_to_8);
                           params.m_pScan_deltas = s_scan_delta_5_to_8;
                        }
                        else
                        {
                           params.m_scan_delta_size = RG_ETC1_ARRAY_SIZE(s_scan_delta_5_to_5);
                           params.m_pScan_deltas = s_scan_delta_5_to_5;
                        }
                     }

                     if (!optimizer.compute())
                        break;
                  }

                  if (results[2].m_error < results[subblock].m_error)
                     results[subblock] = results[2];
               }
                            
               trial_error += results[subblock].m_error;
               if (trial_error >= best_error)
                  break;
            }

            if (subblock < 2)
               continue;

            best_error = trial_error;
            best_results[0] = results[0];
            best_results[1] = results[1];
            best_flip = flip;
            best_use_color4 = use_color4;
            
         } // use_color4

      } // flip

      int dr = best_results[1].m_block_color_unscaled.r - best_results[0].m_block_color_unscaled.r;
      int dg = best_results[1].m_block_color_unscaled.g - best_results[0].m_block_color_unscaled.g;
      int db = best_results[1].m_block_color_unscaled.b - best_results[0].m_block_color_unscaled.b;
      RG_ETC1_ASSERT(best_use_color4 || (rg_etc1::minimum(dr, dg, db) >= cETC1ColorDeltaMin) && (rg_etc1::maximum(dr, dg, db) <= cETC1ColorDeltaMax));
           
      if (best_use_color4)
      {
         dst_block.m_bytes[0] = static_cast<uint8>(best_results[1].m_block_color_unscaled.r | (best_results[0].m_block_color_unscaled.r << 4));
         dst_block.m_bytes[1] = static_cast<uint8>(best_results[1].m_block_color_unscaled.g | (best_results[0].m_block_color_unscaled.g << 4));
         dst_block.m_bytes[2] = static_cast<uint8>(best_results[1].m_block_color_unscaled.b | (best_results[0].m_block_color_unscaled.b << 4));
      }
      else
      {
         if (dr < 0) dr += 8; dst_block.m_bytes[0] = static_cast<uint8>((best_results[0].m_block_color_unscaled.r << 3) | dr);
         if (dg < 0) dg += 8; dst_block.m_bytes[1] = static_cast<uint8>((best_results[0].m_block_color_unscaled.g << 3) | dg);
         if (db < 0) db += 8; dst_block.m_bytes[2] = static_cast<uint8>((best_results[0].m_block_color_unscaled.b << 3) | db);
      }
      
      dst_block.m_bytes[3] = static_cast<uint8>( (best_results[1].m_block_inten_table << 2) | (best_results[0].m_block_inten_table << 5) | ((~best_use_color4 & 1) << 1) | best_flip );
      
      uint selector0 = 0, selector1 = 0;
      if (best_flip)
      {
         // flipped:
         // { 0, 0 }, { 1, 0 }, { 2, 0 }, { 3, 0 },               
         // { 0, 1 }, { 1, 1 }, { 2, 1 }, { 3, 1 } 
         //
         // { 0, 2 }, { 1, 2 }, { 2, 2 }, { 3, 2 },
         // { 0, 3 }, { 1, 3 }, { 2, 3 }, { 3, 3 }
         const uint8* pSelectors0 = best_results[0].m_pSelectors;
         const uint8* pSelectors1 = best_results[1].m_pSelectors;
         for (int x = 3; x >= 0; --x)
         {
            uint b;
            b = g_selector_index_to_etc1[pSelectors1[4 + x]];
            selector0 = (selector0 << 1) | (b & 1); selector1 = (selector1 << 1) | (b >> 1);

            b = g_selector_index_to_etc1[pSelectors1[x]];
            selector0 = (selector0 << 1) | (b & 1); selector1 = (selector1 << 1) | (b >> 1);

            b = g_selector_index_to_etc1[pSelectors0[4 + x]];
            selector0 = (selector0 << 1) | (b & 1); selector1 = (selector1 << 1) | (b >> 1);

            b = g_selector_index_to_etc1[pSelectors0[x]];
            selector0 = (selector0 << 1) | (b & 1); selector1 = (selector1 << 1) | (b >> 1);
         }
      }
      else
      {
         // non-flipped:
         // { 0, 0 }, { 0, 1 }, { 0, 2 }, { 0, 3 },
         // { 1, 0 }, { 1, 1 }, { 1, 2 }, { 1, 3 }
         //
         // { 2, 0 }, { 2, 1 }, { 2, 2 }, { 2, 3 },
         // { 3, 0 }, { 3, 1 }, { 3, 2 }, { 3, 3 }
         for (int subblock = 1; subblock >= 0; --subblock)
         {
            const uint8* pSelectors = best_results[subblock].m_pSelectors + 4;
            for (uint i = 0; i < 2; i++)
            {
               uint b;
               b = g_selector_index_to_etc1[pSelectors[3]];
               selector0 = (selector0 << 1) | (b & 1); selector1 = (selector1 << 1) | (b >> 1);

               b = g_selector_index_to_etc1[pSelectors[2]];
               selector0 = (selector0 << 1) | (b & 1); selector1 = (selector1 << 1) | (b >> 1);

               b = g_selector_index_to_etc1[pSelectors[1]];
               selector0 = (selector0 << 1) | (b & 1); selector1 = (selector1 << 1) | (b >> 1);

               b = g_selector_index_to_etc1[pSelectors[0]];
               selector0 = (selector0 << 1) | (b & 1);selector1 = (selector1 << 1) | (b >> 1);

               pSelectors -= 4;
            }
         }
      }
                  
      dst_block.m_bytes[4] = static_cast<uint8>(selector1 >> 8); dst_block.m_bytes[5] = static_cast<uint8>(selector1 & 0xFF);
      dst_block.m_bytes[6] = static_cast<uint8>(selector0 >> 8); dst_block.m_bytes[7] = static_cast<uint8>(selector0 & 0xFF);

      return static_cast<unsigned int>(best_error);
   }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x400, %rsp            # imm = 0x400
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rsi
leaq -0x34(%rbp), %rdi
callq 0xa2de0
movq -0x28(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x38(%rbp)
movl $0xf, -0x3c(%rbp)
cmpl $0x1, -0x3c(%rbp)
jl 0xa0159
movq -0x28(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x38(%rbp), %eax
je 0xa014c
jmp 0xa0159
jmp 0xa014e
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xa0134
cmpl $0x0, -0x3c(%rbp)
jne 0xa017c
movq -0x30(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xa0f70
shlq $0x4, %rax
movl %eax, -0x4(%rbp)
jmp 0xa0f61
leaq -0x80(%rbp), %rax
movq %rax, %rcx
addq $0x40, %rcx
movq %rcx, -0x378(%rbp)
movq %rax, -0x370(%rbp)
movq -0x370(%rbp), %rdi
movq %rdi, -0x380(%rbp)
callq 0xa1c30
movq -0x380(%rbp), %rax
movq -0x378(%rbp), %rcx
addq $0x4, %rax
cmpq %rcx, %rax
movq %rax, -0x370(%rbp)
jne 0xa0195
movq -0x20(%rbp), %rax
testb $0x1, 0x4(%rax)
je 0xa01e5
leaq -0x80(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0xa1310
leaq -0x80(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq -0x178(%rbp), %rdi
callq 0xa2e00
movq $-0x1, -0x180(%rbp)
movl $0x0, -0x184(%rbp)
movl $0x0, -0x188(%rbp)
leaq -0x1f0(%rbp), %rax
movq %rax, %rcx
addq $0x50, %rcx
movq %rcx, -0x390(%rbp)
movq %rax, -0x388(%rbp)
movq -0x388(%rbp), %rdi
movq %rdi, -0x398(%rbp)
callq 0xa2e50
movq -0x398(%rbp), %rax
movq -0x390(%rbp), %rcx
addq $0x28, %rax
cmpq %rcx, %rax
movq %rax, -0x388(%rbp)
jne 0xa022c
movl $0x0, -0x1f4(%rbp)
cmpl $0x2, -0x1f4(%rbp)
jae 0xa02cc
movl -0x1f4(%rbp), %eax
movl %eax, %ecx
leaq -0x1f0(%rbp), %rax
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0x8, 0x10(%rax)
movl -0x1f4(%rbp), %eax
leaq -0x1a0(%rbp), %rcx
shlq $0x3, %rax
addq %rax, %rcx
movl -0x1f4(%rbp), %eax
movl %eax, %edx
leaq -0x1f0(%rbp), %rax
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x18(%rax)
movl -0x1f4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1f4(%rbp)
jmp 0xa0267
leaq -0x290(%rbp), %rax
movq %rax, %rcx
addq $0x78, %rcx
movq %rcx, -0x3a8(%rbp)
movq %rax, -0x3a0(%rbp)
movq -0x3a0(%rbp), %rdi
movq %rdi, -0x3b0(%rbp)
callq 0xa2e50
movq -0x3b0(%rbp), %rax
movq -0x3a8(%rbp), %rcx
addq $0x28, %rax
cmpq %rcx, %rax
movq %rax, -0x3a0(%rbp)
jne 0xa02e8
movl $0x0, -0x294(%rbp)
cmpl $0x3, -0x294(%rbp)
jae 0xa0388
movl -0x294(%rbp), %eax
movl %eax, %ecx
leaq -0x290(%rbp), %rax
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl $0x8, 0x10(%rax)
movl -0x294(%rbp), %eax
leaq -0x210(%rbp), %rcx
shlq $0x3, %rax
addq %rax, %rcx
movl -0x294(%rbp), %eax
movl %eax, %edx
leaq -0x290(%rbp), %rax
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x18(%rax)
movl -0x294(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x294(%rbp)
jmp 0xa0323
leaq -0x2c0(%rbp), %rax
movq %rax, %rcx
addq $0x20, %rcx
movq %rcx, -0x3c0(%rbp)
movq %rax, -0x3b8(%rbp)
movq -0x3b8(%rbp), %rdi
movq %rdi, -0x3c8(%rbp)
callq 0xa1c30
movq -0x3c8(%rbp), %rax
movq -0x3c0(%rbp), %rcx
addq $0x4, %rax
cmpq %rcx, %rax
movq %rax, -0x3b8(%rbp)
jne 0xa03a4
movq -0x20(%rbp), %rsi
leaq -0x2f8(%rbp), %rdi
callq 0xa2e70
movl $0x8, -0x2f0(%rbp)
leaq -0x2c0(%rbp), %rax
movq %rax, -0x2e8(%rbp)
movl $0x0, -0x2fc(%rbp)
cmpl $0x2, -0x2fc(%rbp)
jae 0xa0976
movl $0x0, -0x300(%rbp)
cmpl $0x2, -0x300(%rbp)
jae 0xa0960
movq $0x0, -0x308(%rbp)
movl $0x0, -0x30c(%rbp)
cmpl $0x2, -0x30c(%rbp)
jae 0xa08ed
cmpl $0x0, -0x2fc(%rbp)
je 0xa0499
movq -0x28(%rbp), %rax
movl -0x30c(%rbp), %ecx
shll $0x3, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,4), %rdx
movq %rdx, -0x2c0(%rbp)
movq 0x8(%rax,%rcx,4), %rdx
movq %rdx, -0x2b8(%rbp)
movq 0x10(%rax,%rcx,4), %rdx
movq %rdx, -0x2b0(%rbp)
movq 0x18(%rax,%rcx,4), %rax
movq %rax, -0x2a8(%rbp)
jmp 0xa0585
movq -0x28(%rbp), %rax
movl -0x30c(%rbp), %ecx
shll %ecx
movl %ecx, %ecx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x318(%rbp)
movq -0x318(%rbp), %rsi
leaq -0x2c0(%rbp), %rdi
callq 0xa1ff0
movq -0x318(%rbp), %rsi
addq $0x10, %rsi
leaq -0x2c0(%rbp), %rdi
addq $0x4, %rdi
callq 0xa1ff0
movq -0x318(%rbp), %rsi
addq $0x20, %rsi
leaq -0x2c0(%rbp), %rdi
addq $0x8, %rdi
callq 0xa1ff0
movq -0x318(%rbp), %rsi
addq $0x30, %rsi
leaq -0x2c0(%rbp), %rdi
addq $0xc, %rdi
callq 0xa1ff0
movq -0x318(%rbp), %rsi
addq $0x4, %rsi
leaq -0x2c0(%rbp), %rdi
addq $0x10, %rdi
callq 0xa1ff0
movq -0x318(%rbp), %rsi
addq $0x14, %rsi
leaq -0x2c0(%rbp), %rdi
addq $0x14, %rdi
callq 0xa1ff0
movq -0x318(%rbp), %rsi
addq $0x24, %rsi
leaq -0x2c0(%rbp), %rdi
addq $0x18, %rdi
callq 0xa1ff0
movq -0x318(%rbp), %rsi
addq $0x34, %rsi
leaq -0x2c0(%rbp), %rdi
addq $0x1c, %rdi
callq 0xa1ff0
movq $-0x1, -0x240(%rbp)
cmpl $0x1, -0x2f8(%rbp)
jl 0xa069c
cmpl $0x0, -0x30c(%rbp)
jne 0xa05b3
cmpl $0x0, -0x300(%rbp)
je 0xa069c
movl -0x2c0(%rbp), %eax
movl %eax, -0x31c(%rbp)
movl $0x7, -0x3c(%rbp)
cmpl $0x1, -0x3c(%rbp)
jl 0xa05ee
movslq -0x3c(%rbp), %rax
movl -0x2c0(%rbp,%rax,4), %eax
cmpl -0x31c(%rbp), %eax
je 0xa05e1
jmp 0xa05ee
jmp 0xa05e3
movl -0x3c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xa05c6
cmpl $0x0, -0x3c(%rbp)
jne 0xa069a
leaq -0x290(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x3e8(%rbp)
leaq -0x2c0(%rbp), %rax
movq %rax, -0x3e0(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x3d8(%rbp)
cmpl $0x0, -0x300(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0x3c9(%rbp)
cmpl $0x0, -0x30c(%rbp)
je 0xa065b
cmpl $0x0, -0x300(%rbp)
jne 0xa065b
leaq -0x290(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x3f0(%rbp)
jmp 0xa0666
xorl %eax, %eax
movq %rax, -0x3f0(%rbp)
jmp 0xa0666
movq -0x3d8(%rbp), %rcx
movq -0x3e0(%rbp), %rdx
movq -0x3e8(%rbp), %rdi
movb -0x3c9(%rbp), %al
movq -0x3f0(%rbp), %r9
movzbl %al, %r8d
andl $0x1, %r8d
movl $0x8, %esi
callq 0xa1560
jmp 0xa069c
cmpl $0x0, -0x300(%rbp)
setne %al
andb $0x1, %al
movb %al, -0x2e0(%rbp)
movb $0x0, -0x2c8(%rbp)
cmpl $0x0, -0x300(%rbp)
jne 0xa06e9
cmpl $0x0, -0x30c(%rbp)
je 0xa06e9
movb $0x1, -0x2c8(%rbp)
leaq -0x290(%rbp), %rsi
addq $0x8, %rsi
leaq -0x2f8(%rbp), %rdi
addq $0x2c, %rdi
callq 0xa1ff0
cmpl $0x2, -0x2f8(%rbp)
jne 0xa070c
movl $0x9, -0x2d0(%rbp)
leaq 0x185bd(%rip), %rax     # 0xb8cc0
movq %rax, -0x2d8(%rbp)
jmp 0xa0749
cmpl $0x1, -0x2f8(%rbp)
jne 0xa072f
movl $0x3, -0x2d0(%rbp)
leaq 0x185be(%rip), %rax     # 0xb8ce4
movq %rax, -0x2d8(%rbp)
jmp 0xa0747
movl $0x1, -0x2d0(%rbp)
leaq 0x185b0(%rip), %rax     # 0xb8cf0
movq %rax, -0x2d8(%rbp)
jmp 0xa0749
movl -0x30c(%rbp), %eax
leaq -0x290(%rbp), %rdx
imulq $0x28, %rax, %rax
addq %rax, %rdx
leaq -0x178(%rbp), %rdi
leaq -0x2f8(%rbp), %rsi
callq 0x9fa70
leaq -0x178(%rbp), %rdi
callq 0x9e870
testb $0x1, %al
jne 0xa0785
jmp 0xa08ed
cmpl $0x1, -0x2f8(%rbp)
jl 0xa089e
movl $0xbb8, -0x320(%rbp)    # imm = 0xBB8
movl $0x1770, -0x324(%rbp)   # imm = 0x1770
movl -0x30c(%rbp), %eax
movl %eax, %ecx
leaq -0x290(%rbp), %rax
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
cmpq $0xbb8, (%rax)          # imm = 0xBB8
jbe 0xa0856
cmpl $0x1, -0x2f8(%rbp)
jne 0xa07ec
movl $0x4, -0x2d0(%rbp)
leaq 0x1851d(%rip), %rax     # 0xb8d00
movq %rax, -0x2d8(%rbp)
jmp 0xa083f
movl -0x30c(%rbp), %eax
movl %eax, %ecx
leaq -0x290(%rbp), %rax
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
cmpq $0x1770, (%rax)         # imm = 0x1770
jbe 0xa0825
movl $0x8, -0x2d0(%rbp)
leaq 0x18504(%rip), %rax     # 0xb8d20
movq %rax, -0x2d8(%rbp)
jmp 0xa083d
movl $0x2, -0x2d0(%rbp)
leaq 0x184da(%rip), %rax     # 0xb8d10
movq %rax, -0x2d8(%rbp)
jmp 0xa083f
leaq -0x178(%rbp), %rdi
callq 0x9e870
testb $0x1, %al
jne 0xa0854
jmp 0xa08ed
jmp 0xa0856
movq -0x240(%rbp), %rax
movl -0x30c(%rbp), %ecx
movl %ecx, %edx
leaq -0x290(%rbp), %rcx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
cmpq (%rcx), %rax
jae 0xa089c
leaq -0x290(%rbp), %rsi
addq $0x50, %rsi
movl -0x30c(%rbp), %eax
leaq -0x290(%rbp), %rdi
imulq $0x28, %rax, %rax
addq %rax, %rdi
callq 0xa2eb0
jmp 0xa089e
movl -0x30c(%rbp), %eax
movl %eax, %ecx
leaq -0x290(%rbp), %rax
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
addq -0x308(%rbp), %rax
movq %rax, -0x308(%rbp)
movq -0x308(%rbp), %rax
cmpq -0x180(%rbp), %rax
jb 0xa08d7
jmp 0xa08ed
jmp 0xa08d9
movl -0x30c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30c(%rbp)
jmp 0xa0440
cmpl $0x2, -0x30c(%rbp)
jae 0xa08f8
jmp 0xa094c
movq -0x308(%rbp), %rax
movq %rax, -0x180(%rbp)
leaq -0x290(%rbp), %rsi
leaq -0x1f0(%rbp), %rdi
callq 0xa2eb0
leaq -0x290(%rbp), %rsi
addq $0x28, %rsi
leaq -0x1f0(%rbp), %rdi
addq $0x28, %rdi
callq 0xa2eb0
movl -0x2fc(%rbp), %eax
movl %eax, -0x184(%rbp)
movl -0x300(%rbp), %eax
movl %eax, -0x188(%rbp)
movl -0x300(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x300(%rbp)
jmp 0xa041e
jmp 0xa0962
movl -0x2fc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2fc(%rbp)
jmp 0xa0407
movzbl -0x1c0(%rbp), %eax
movzbl -0x1e8(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x328(%rbp)
movzbl -0x1bf(%rbp), %eax
movzbl -0x1e7(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x32c(%rbp)
movzbl -0x1be(%rbp), %eax
movzbl -0x1e6(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x330(%rbp)
movb $0x1, %al
cmpl $0x0, -0x188(%rbp)
movb %al, -0x3f1(%rbp)
jne 0xa0a1e
movl -0x328(%rbp), %edi
movl -0x32c(%rbp), %esi
movl -0x330(%rbp), %edx
callq 0xa2c60
movl %eax, %ecx
xorl %eax, %eax
cmpl $-0x4, %ecx
movb %al, -0x3f2(%rbp)
jl 0xa0a12
movl -0x328(%rbp), %edi
movl -0x32c(%rbp), %esi
movl -0x330(%rbp), %edx
callq 0xa2c90
cmpl $0x3, %eax
setle %al
movb %al, -0x3f2(%rbp)
movb -0x3f2(%rbp), %al
movb %al, -0x3f1(%rbp)
movb -0x3f1(%rbp), %al
testb $0x1, %al
jne 0xa0a2a
jmp 0xa0a2c
jmp 0xa0a4b
leaq 0x17b70(%rip), %rdi     # 0xb85a3
leaq 0x178e9(%rip), %rsi     # 0xb8323
movl $0x947, %edx            # imm = 0x947
leaq 0x17bdd(%rip), %rcx     # 0xb8623
callq 0x61a0
cmpl $0x0, -0x188(%rbp)
je 0xa0aac
movzbl -0x1c0(%rbp), %eax
movzbl -0x1e8(%rbp), %ecx
shll $0x4, %ecx
orl %ecx, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, (%rax)
movzbl -0x1bf(%rbp), %eax
movzbl -0x1e7(%rbp), %ecx
shll $0x4, %ecx
orl %ecx, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x1(%rax)
movzbl -0x1be(%rbp), %eax
movzbl -0x1e6(%rbp), %ecx
shll $0x4, %ecx
orl %ecx, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x2(%rax)
jmp 0xa0b3e
cmpl $0x0, -0x328(%rbp)
jge 0xa0ac4
movl -0x328(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x328(%rbp)
movzbl -0x1e8(%rbp), %eax
shll $0x3, %eax
orl -0x328(%rbp), %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, (%rax)
cmpl $0x0, -0x32c(%rbp)
jge 0xa0af4
movl -0x32c(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x32c(%rbp)
movzbl -0x1e7(%rbp), %eax
shll $0x3, %eax
orl -0x32c(%rbp), %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x1(%rax)
cmpl $0x0, -0x330(%rbp)
jge 0xa0b25
movl -0x330(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x330(%rbp)
movzbl -0x1e6(%rbp), %eax
shll $0x3, %eax
orl -0x330(%rbp), %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x2(%rax)
movl -0x1bc(%rbp), %eax
shll $0x2, %eax
movl -0x1e4(%rbp), %ecx
shll $0x5, %ecx
orl %ecx, %eax
movl -0x188(%rbp), %ecx
xorl $-0x1, %ecx
andl $0x1, %ecx
shll %ecx
orl %ecx, %eax
orl -0x184(%rbp), %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x3(%rax)
movl $0x0, -0x334(%rbp)
movl $0x0, -0x338(%rbp)
cmpl $0x0, -0x184(%rbp)
je 0xa0d40
movq -0x1d8(%rbp), %rax
movq %rax, -0x340(%rbp)
movq -0x1b0(%rbp), %rax
movq %rax, -0x348(%rbp)
movl $0x3, -0x34c(%rbp)
cmpl $0x0, -0x34c(%rbp)
jl 0xa0d3b
movq -0x348(%rbp), %rax
movl -0x34c(%rbp), %ecx
addl $0x4, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x1815b(%rip), %rax     # 0xb8d40
movzbl (%rax,%rcx), %eax
movl %eax, -0x350(%rbp)
movl -0x334(%rbp), %eax
shll %eax
movl -0x350(%rbp), %ecx
andl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x334(%rbp)
movl -0x338(%rbp), %eax
shll %eax
movl -0x350(%rbp), %ecx
shrl %ecx
orl %ecx, %eax
movl %eax, -0x338(%rbp)
movq -0x348(%rbp), %rax
movslq -0x34c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x18105(%rip), %rax     # 0xb8d40
movzbl (%rax,%rcx), %eax
movl %eax, -0x350(%rbp)
movl -0x334(%rbp), %eax
shll %eax
movl -0x350(%rbp), %ecx
andl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x334(%rbp)
movl -0x338(%rbp), %eax
shll %eax
movl -0x350(%rbp), %ecx
shrl %ecx
orl %ecx, %eax
movl %eax, -0x338(%rbp)
movq -0x340(%rbp), %rax
movl -0x34c(%rbp), %ecx
addl $0x4, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x180aa(%rip), %rax     # 0xb8d40
movzbl (%rax,%rcx), %eax
movl %eax, -0x350(%rbp)
movl -0x334(%rbp), %eax
shll %eax
movl -0x350(%rbp), %ecx
andl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x334(%rbp)
movl -0x338(%rbp), %eax
shll %eax
movl -0x350(%rbp), %ecx
shrl %ecx
orl %ecx, %eax
movl %eax, -0x338(%rbp)
movq -0x340(%rbp), %rax
movslq -0x34c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl %eax, %ecx
leaq 0x18054(%rip), %rax     # 0xb8d40
movzbl (%rax,%rcx), %eax
movl %eax, -0x350(%rbp)
movl -0x334(%rbp), %eax
shll %eax
movl -0x350(%rbp), %ecx
andl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x334(%rbp)
movl -0x338(%rbp), %eax
shll %eax
movl -0x350(%rbp), %ecx
shrl %ecx
orl %ecx, %eax
movl %eax, -0x338(%rbp)
movl -0x34c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34c(%rbp)
jmp 0xa0bb8
jmp 0xa0f0b
movl $0x1, -0x354(%rbp)
cmpl $0x0, -0x354(%rbp)
jl 0xa0f09
movslq -0x354(%rbp), %rcx
leaq -0x1f0(%rbp), %rax
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
addq $0x4, %rax
movq %rax, -0x360(%rbp)
movl $0x0, -0x364(%rbp)
cmpl $0x2, -0x364(%rbp)
jae 0xa0ef3
movq -0x360(%rbp), %rax
movzbl 0x3(%rax), %eax
movl %eax, %ecx
leaq 0x17f9a(%rip), %rax     # 0xb8d40
movzbl (%rax,%rcx), %eax
movl %eax, -0x368(%rbp)
movl -0x334(%rbp), %eax
shll %eax
movl -0x368(%rbp), %ecx
andl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x334(%rbp)
movl -0x338(%rbp), %eax
shll %eax
movl -0x368(%rbp), %ecx
shrl %ecx
orl %ecx, %eax
movl %eax, -0x338(%rbp)
movq -0x360(%rbp), %rax
movzbl 0x2(%rax), %eax
movl %eax, %ecx
leaq 0x17f4b(%rip), %rax     # 0xb8d40
movzbl (%rax,%rcx), %eax
movl %eax, -0x368(%rbp)
movl -0x334(%rbp), %eax
shll %eax
movl -0x368(%rbp), %ecx
andl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x334(%rbp)
movl -0x338(%rbp), %eax
shll %eax
movl -0x368(%rbp), %ecx
shrl %ecx
orl %ecx, %eax
movl %eax, -0x338(%rbp)
movq -0x360(%rbp), %rax
movzbl 0x1(%rax), %eax
movl %eax, %ecx
leaq 0x17efc(%rip), %rax     # 0xb8d40
movzbl (%rax,%rcx), %eax
movl %eax, -0x368(%rbp)
movl -0x334(%rbp), %eax
shll %eax
movl -0x368(%rbp), %ecx
andl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x334(%rbp)
movl -0x338(%rbp), %eax
shll %eax
movl -0x368(%rbp), %ecx
shrl %ecx
orl %ecx, %eax
movl %eax, -0x338(%rbp)
movq -0x360(%rbp), %rax
movzbl (%rax), %eax
movl %eax, %ecx
leaq 0x17eae(%rip), %rax     # 0xb8d40
movzbl (%rax,%rcx), %eax
movl %eax, -0x368(%rbp)
movl -0x334(%rbp), %eax
shll %eax
movl -0x368(%rbp), %ecx
andl $0x1, %ecx
orl %ecx, %eax
movl %eax, -0x334(%rbp)
movl -0x338(%rbp), %eax
shll %eax
movl -0x368(%rbp), %ecx
shrl %ecx
orl %ecx, %eax
movl %eax, -0x338(%rbp)
movq -0x360(%rbp), %rax
addq $-0x4, %rax
movq %rax, -0x360(%rbp)
movl -0x364(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x364(%rbp)
jmp 0xa0d85
jmp 0xa0ef5
movl -0x354(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x354(%rbp)
jmp 0xa0d4a
jmp 0xa0f0b
movl -0x338(%rbp), %eax
shrl $0x8, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x4(%rax)
movl -0x338(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x5(%rax)
movl -0x334(%rbp), %eax
shrl $0x8, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x6(%rax)
movl -0x334(%rbp), %eax
andl $0xff, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x7(%rax)
movq -0x180(%rbp), %rax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x400, %rsp            # imm = 0x400
popq %rbp
retq
nopl (%rax)