// File: /workspace/github_cpp_makefile_star2_O3/cloudinary[P]fuif/encoding/encoding.cpp
// Function: bool fuif_decode_channel<FileIO, FinalPropertySymbolCoder<SimpleBitChance, RacInput24<FileIO>, 15>>(FileIO&, fuif_options&, int&, Image&, unsigned long)
bool fuif_decode_channel(IO& io, fuif_options &options, int &beginc, Image &image, size_t bytes_to_load) {

  long unsigned filepos = io.ftell();
  if (io.isEOF() || (bytes_to_load && io.ftell() >= bytes_to_load)) return true;
  int firstbyte = read_big_endian_varint(io);
  if (io.isEOF() || (bytes_to_load && io.ftell() >= bytes_to_load)) return true;
  int endc = beginc + (firstbyte >> 4);
  bool compress = (firstbyte & 1);
  int predictor = (firstbyte & 14)>>1;
  pixel_type global_minv = 1-read_big_endian_varint(io);
  if (io.isEOF() || (bytes_to_load && io.ftell() >= bytes_to_load)) return true;
  if (global_minv == 1) global_minv = read_big_endian_varint(io);
  if (io.isEOF() || (bytes_to_load && io.ftell() >= bytes_to_load)) return true;
  pixel_type global_maxv = global_minv + read_big_endian_varint(io);
  if (io.isEOF() || (bytes_to_load && io.ftell() >= bytes_to_load)) return true;
  if (endc>beginc) v_printf(3,"[File position %lu] Decoding%s channels %i-%i with range %i..%i\n", filepos, (compress?"":" uncompressed"), beginc, endc, global_minv, global_maxv);
  if (endc >= image.channel.size() || endc < beginc) {
    e_printf("Wrong channel range: %i-%i while we have only %i channels.\n",beginc,endc,image.channel.size());
    return false;
  }

  int firstrealc = beginc;
  for (int i=beginc; i<=endc; i++) {
    Channel &channel = image.channel[i];

    if (channel.w * channel.h <= 0) continue; //return true; // zero pixel channel? could happen

    channel.minval = global_minv;
    channel.maxval = global_maxv;
    if (endc>beginc && global_minv<global_maxv) {
        channel.minval += read_big_endian_varint(io);
        channel.maxval = channel.minval + read_big_endian_varint(io);
    }
    if (channel.minval == channel.maxval) {
        channel.data = std::vector<pixel_type>(channel.w * channel.h, channel.minval);
        v_printf(3,"[File position %lu] Decoding channel %i: %ix%i %s, constant %i\n", filepos, i, channel.w, channel.h, ch_describe(image,i), channel.minval);
        firstrealc++;
    }

    if (channel.minval == 0 && channel.maxval == 0) continue; // don't need quantization factor if it's all zeroes anyway

    channel.q = read_big_endian_varint(io);

    if (io.isEOF() || (bytes_to_load && io.ftell() >= bytes_to_load)) return corrupt_or_truncated(io,channel,bytes_to_load);

    v_printf(3,"[File position %lu] Decoding%s channel %i: %ix%i %s with range %i..%i (qf=%i), predictor %i", filepos, (compress?"":" uncompressed"), i, channel.w, channel.h, ch_describe(image,i), channel.minval, channel.maxval, channel.q, predictor);
    v_printf(6," (shift=%i,%i, cshift=%i,%i)", channel.hshift, channel.vshift, channel.hcshift, channel.vcshift);
    v_printf(3,"\n");

    if (compress && !check_bit_depth(channel.minval,channel.maxval,predictor)) return false;
  }

  if (firstrealc > endc) { beginc=endc; return true; } // all trivial

  Ranges propRanges;
  init_properties(propRanges, image, beginc, endc, options);

  int predictability = 2048;

  if (predictor == 0 && compress) {
        Channel &channel = image.channel[firstrealc];
        uint64_t pixels = channel.h*channel.w;
        int rounded = read_big_endian_varint(io);
        if (rounded < 1 || rounded > 127) {
            return corrupt_or_truncated(io, channel, bytes_to_load);
        }
        predictability = rounded * 32;
        uint64_t zeroes = pixels*predictability/4096;
        v_printf(5,"Estimating %i zeroes in %i pixels (zero chance=%i/4096)\n",zeroes,pixels,predictability);
  }

  // decode trees
  RacIn<IO> rac(io);

  if (!compress) {
    UniformSymbolCoder<RacIn<IO>> coder(rac);
    for (int i=beginc; i<=endc; i++) {
        Channel &channel = image.channel[i];
        if (channel.minval==channel.maxval) continue;
        channel.setzero();
        channel.resize(channel.w, channel.h);
        for (int y=0; y<channel.h; y++) {
          if (io.isEOF() || (bytes_to_load && io.ftell() >= bytes_to_load)) {
             v_printf(3,"Premature end-of-file at row %i.\n",y);
             break;
          }
          for (int x=0; x<channel.w; x++) {
             channel.value(y,x) = coder.read_int(channel.minval,channel.maxval-channel.minval);
          }
        }
        if (io.isEOF() || (bytes_to_load && io.ftell() >= bytes_to_load)) break;
    }
    beginc = endc;
    return true;
  }

  Tree tree;
  MetaPropertySymbolCoder<FUIFBitChanceTree, RacIn<IO>> metacoder(rac, propRanges);
  if (!metacoder.read_tree(tree)) return corrupt_or_truncated(io, image.channel[beginc], bytes_to_load);

  Coder coder(rac, propRanges, tree, predictability, CONTEXT_TREE_SPLIT_THRESHOLD, options.maniac_cutoff, options.maniac_alpha);
  Properties properties(propRanges.size());


  // planar
  for (int i=beginc; i<=endc; i++) {
    Channel &channel = image.channel[i];
    if (channel.minval==channel.maxval) continue;
    channel.setzero();
    channel.resize(channel.w, channel.h);

    if (tree.size() == 1 && predictor == 0 && channel.zero == 0) {
      // special optimized case: no meta-adaptation, no predictor, so no need to compute properties
      v_printf(5,"Fast track.\n");
      for (int y=0; y<channel.h; y++) {
        if (io.isEOF() || (bytes_to_load && io.ftell() >= bytes_to_load)) {
         v_printf(3,"Premature end-of-file at row %i of channel %i.\n",y,i);
         beginc = i;
         break;
        }
       for (int x=0; x<channel.w; x++) {
        channel.value(y,x) = coder.read_int(properties, channel.minval, channel.maxval);
       }
      }
    } else {

      v_printf(5,"Slow track.\n");

    Channel references(properties.size() - NB_NONREF_PROPERTIES, channel.w, 0, 0);
    for (int y=0; y<channel.h; y++) {
      if (io.isEOF() || (bytes_to_load && io.ftell() >= bytes_to_load)) {
         v_printf(3,"Premature end-of-file at row %i of channel %i.\n",y,i);
         beginc = i;
         break;
      }
      precompute_references(channel, y, image, beginc, options, references);
      if (y <= 1 || predictor) {
       for (int x=0; x<channel.w; x++) {
        pixel_type guess;
        guess = predict_and_compute_properties_with_precomputed_reference(properties, channel, x, y, predictor, image, beginc, options, references);
        pixel_type diff = coder.read_int(properties, channel.minval-guess, channel.maxval-guess);
        channel.value(y,x) = diff + guess;
       }
      } else {
       int x=0;
       pixel_type guess, diff;
       for (; x<channel.w && x<2; x++) {
        guess = predict_and_compute_properties_with_precomputed_reference(properties, channel, x, y, predictor, image, beginc, options, references);
        diff = coder.read_int(properties, channel.minval-guess, channel.maxval-guess);
        channel.value(y,x) = diff + guess;
       }
       for (; x<channel.w-1; x++) {
        guess = predict_and_compute_properties_with_precomputed_reference_no_edge_case(properties, channel, x, y, references);
        diff = coder.read_int(properties, channel.minval-guess, channel.maxval-guess);
        channel.value(y,x) = diff + guess;
       }
       for (; x<channel.w; x++) {
        guess = predict_and_compute_properties_with_precomputed_reference(properties, channel, x, y, predictor, image, beginc, options, references);
        diff = coder.read_int(properties, channel.minval-guess, channel.maxval-guess);
        channel.value(y,x) = diff + guess;
       }
      }
    }
    }
    if (io.isEOF() || (bytes_to_load && io.ftell() >= bytes_to_load)) break;
  }

  beginc = endc;
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x41a8, %rsp           # imm = 0x41A8
movq %r8, %rbx
movq %rcx, %r12
movq %rdx, %rbp
movq %rsi, %r15
movq %rdi, %r14
movq (%rdi), %rdi
callq 0x3030
movq %rax, %r13
movq (%r14), %rdi
callq 0x3470
movb $0x1, %cl
testl %eax, %eax
jne 0x154e3
movq %r13, 0x28(%rsp)
movq %r15, 0xb0(%rsp)
movq %rbp, 0x18(%rsp)
testq %rbx, %rbx
je 0x1541a
movq (%r14), %rdi
callq 0x3030
cmpq %rbx, %rax
jae 0x154e1
movq %r14, %rdi
callq 0x1504b
movl %eax, %r15d
movq (%r14), %rdi
callq 0x3470
testl %eax, %eax
jne 0x154e1
testq %rbx, %rbx
je 0x1544b
movq (%r14), %rdi
callq 0x3030
cmpq %rbx, %rax
jae 0x154e1
movq %r12, 0x20(%rsp)
movl %r15d, %ebp
sarl $0x4, %ebp
movq 0x18(%rsp), %rax
addl (%rax), %ebp
movq %r14, %rdi
callq 0x1504b
movl %eax, %r12d
movq (%r14), %rdi
callq 0x3470
testl %eax, %eax
jne 0x154e1
testq %rbx, %rbx
je 0x15486
movq (%r14), %rdi
callq 0x3030
cmpq %rbx, %rax
jae 0x154e1
testw %r12w, %r12w
je 0x15497
movl $0x1, %r13d
subl %r12d, %r13d
jmp 0x154a2
movq %r14, %rdi
callq 0x1504b
movl %eax, %r13d
movq 0x20(%rsp), %r12
movq (%r14), %rdi
callq 0x3470
testl %eax, %eax
jne 0x154e1
testq %rbx, %rbx
je 0x154c5
movq (%r14), %rdi
callq 0x3030
cmpq %rbx, %rax
jae 0x154e1
movl %r13d, 0xc(%rsp)
movq %r14, %rdi
callq 0x1504b
movl %eax, %r13d
movq (%r14), %rdi
callq 0x3470
testl %eax, %eax
je 0x154f7
movb $0x1, %cl
movl %ecx, %eax
addq $0x41a8, %rsp           # imm = 0x41A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rbx, %rbx
je 0x15509
movq (%r14), %rdi
callq 0x3030
cmpq %rbx, %rax
jae 0x154e1
movl %r13d, %esi
movl 0xc(%rsp), %eax
addl %eax, %esi
movq 0x18(%rsp), %r13
movl (%r13), %edx
cmpl %edx, %ebp
movl %esi, 0x34(%rsp)
jle 0x1556f
movswl %ax, %r10d
leaq 0x12459(%rip), %rax     # 0x27987
leaq 0x11577(%rip), %rcx     # 0x26aac
testb $0x1, %r15b
cmovneq %rax, %rcx
movswl %si, %r11d
leaq 0x11703(%rip), %rsi     # 0x26c4b
movl $0x3, %edi
movl %edx, %r8d
movq 0x28(%rsp), %rdx
movl %ebp, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x1cede
movl 0x44(%rsp), %esi
addq $0x10, %rsp
movl (%r13), %edx
movslq %ebp, %rax
movq 0x8(%r12), %rcx
subq (%r12), %rcx
sarq $0x6, %rcx
cmpq %rax, %rcx
jbe 0x158a7
cmpl %edx, %ebp
jl 0x158a7
movl %r15d, %eax
shrl %eax
andl $0x7, %eax
movq %rax, 0x50(%rsp)
leaq 0x123e3(%rip), %rax     # 0x27987
leaq 0x11501(%rip), %rdi     # 0x26aac
movl %r15d, 0x5c(%rsp)
testb $0x1, %r15b
cmovneq %rax, %rdi
movq %rdi, 0x130(%rsp)
movslq %edx, %r12
movq %rbp, 0x48(%rsp)
leal 0x1(%rbp), %eax
movl %eax, 0xbc(%rsp)
shlq $0x6, %r12
orq $0x20, %r12
movl %edx, 0x64(%rsp)
movb $0x1, %cl
movq 0x20(%rsp), %rax
movq (%rax), %r13
movl -0x4(%r13,%r12), %eax
imull -0x8(%r13,%r12), %eax
testl %eax, %eax
jle 0x1587b
movl %edx, 0x38(%rsp)
leaq (%r12,%r13), %rax
movq %rax, 0x10(%rsp)
movl 0xc(%rsp), %edx
movw %dx, (%r13,%r12)
movw %si, 0x2(%r13,%r12)
movl %esi, %eax
movl %edx, %ecx
cmpw %si, %dx
jge 0x15666
movl %esi, %eax
movl 0xc(%rsp), %ecx
movq 0x18(%rsp), %rdx
movq 0x48(%rsp), %rdi
cmpl (%rdx), %edi
jle 0x15666
movq %r14, %rdi
callq 0x1504b
movl %eax, %r15d
movq 0x10(%rsp), %rbp
addw (%rbp), %r15w
movw %r15w, (%rbp)
movq %r14, %rdi
callq 0x1504b
movl 0x34(%rsp), %esi
addl %r15d, %eax
movw %ax, 0x2(%rbp)
movzwl (%rbp), %ecx
leaq (%r12,%r13), %r15
addq $-0x20, %r15
cmpw %ax, %cx
jne 0x15749
movq %r13, 0xa8(%rsp)
movq 0x10(%rsp), %rdx
movslq -0x8(%rdx), %rax
movslq -0x4(%rdx), %rsi
imulq %rax, %rsi
leaq 0x170(%rsp), %rbp
movq %rbp, %rdi
leaq 0xd8(%rsp), %rcx
callq 0xe282
movq %r15, %rdi
movq %rbp, %rsi
callq 0xfda8
movq 0x170(%rsp), %rdi
testq %rdi, %rdi
je 0x156d0
movq 0x180(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq 0x10(%rsp), %r13
movl -0x8(%r13), %eax
movl %eax, 0xa0(%rsp)
movl -0x4(%r13), %eax
movl %eax, 0x60(%rsp)
movq 0x20(%rsp), %rdi
movl 0x38(%rsp), %ebp
movl %ebp, %esi
callq 0x112e6
movq %rax, %r10
movswl (%r13), %r11d
movl $0x3, %edi
leaq 0x115bc(%rip), %rsi     # 0x26cc8
movq 0x28(%rsp), %rdx
movl %ebp, %ecx
movl 0xa0(%rsp), %r8d
movl 0x60(%rsp), %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x1cede
addq $0x10, %rsp
incl 0x64(%rsp)
movzwl (%r13), %ecx
movzwl 0x2(%r13), %eax
movl 0x34(%rsp), %esi
movq 0xa8(%rsp), %r13
orw %cx, %ax
jne 0x15755
movb $0x1, %cl
jmp 0x15877
movq %r14, %rdi
callq 0x1504b
movl %eax, 0x8(%r13,%r12)
movq (%r14), %rdi
callq 0x3470
testl %eax, %eax
jne 0x161f9
testq %rbx, %rbx
je 0x15788
movq (%r14), %rdi
callq 0x3030
cmpq %rbx, %rax
jae 0x161fb
movl -0x8(%r13,%r12), %eax
movl %eax, 0x60(%rsp)
movl -0x4(%r13,%r12), %r15d
movq 0x20(%rsp), %rdi
movl 0x38(%rsp), %ebp
movl %ebp, %esi
callq 0x112e6
movq %rax, 0xa8(%rsp)
movswl (%r13,%r12), %eax
movq %rax, 0xa0(%rsp)
movswl 0x2(%r13,%r12), %r10d
movl 0x8(%r13,%r12), %r11d
movl $0x3, %edi
leaq 0x11535(%rip), %rsi     # 0x26d08
movq 0x28(%rsp), %rdx
movq 0x130(%rsp), %rcx
movl %ebp, %r8d
movl 0x60(%rsp), %r9d
xorl %eax, %eax
movq 0x50(%rsp), %rbp
pushq %rbp
pushq %r11
pushq %r10
pushq 0xb8(%rsp)
pushq 0xc8(%rsp)
pushq %r15
callq 0x1cede
addq $0x30, %rsp
movl 0xc(%r13,%r12), %edx
movl 0x10(%r13,%r12), %ecx
movl 0x14(%r13,%r12), %r8d
movl 0x18(%r13,%r12), %r9d
movl $0x6, %edi
leaq 0x11537(%rip), %rsi     # 0x26d64
xorl %eax, %eax
callq 0x1cede
movl $0x3, %edi
leaq 0x12146(%rip), %rsi     # 0x27986
xorl %eax, %eax
callq 0x1cede
testb $0x1, 0x5c(%rsp)
je 0x15871
movq 0x10(%rsp), %rax
movswl (%rax), %edi
movswl 0x2(%rax), %esi
movl %ebp, %edx
callq 0x11273
testb %al, %al
movb $0x1, %cl
movl 0x34(%rsp), %esi
movl 0x38(%rsp), %edx
jne 0x1587b
jmp 0x158b9
movb $0x1, %cl
movl 0x34(%rsp), %esi
movl 0x38(%rsp), %edx
incl %edx
addq $0x40, %r12
cmpl %edx, 0xbc(%rsp)
jne 0x155e0
movq 0x48(%rsp), %rsi
movl 0x64(%rsp), %ebp
cmpl %esi, %ebp
jle 0x158c0
movq 0x18(%rsp), %rax
movl %esi, (%rax)
jmp 0x154e3
leaq 0x113de(%rip), %rdi     # 0x26c8c
movl %edx, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x379e
xorl %ecx, %ecx
jmp 0x154e3
xorps %xmm0, %xmm0
leaq 0xc0(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq 0x18(%rsp), %rax
movl (%rax), %edx
movq %rsi, %rcx
movq 0x20(%rsp), %r12
movq %r12, %rsi
movq 0xb0(%rsp), %r8
callq 0x106d2
testb $0x1, 0x5c(%rsp)
sete %al
cmpl $0x0, 0x50(%rsp)
setne %cl
movl $0x800, %r15d           # imm = 0x800
orb %al, %cl
movq %rbx, 0x10(%rsp)
movq %r14, 0x40(%rsp)
jne 0x1597a
movslq %ebp, %r15
movq (%r12), %r12
shlq $0x6, %r15
movslq 0x1c(%r12,%r15), %rbx
movslq 0x18(%r12,%r15), %r13
movq %r14, %rdi
callq 0x1504b
leal -0x1(%rax), %ecx
cmpl $0x7f, %ecx
jae 0x16387
imulq %rbx, %r13
shll $0x5, %eax
movq %rax, %rdx
imulq %r13, %rdx
shrq $0xc, %rdx
leaq 0x11426(%rip), %rsi     # 0x26d81
movl $0x5, %edi
movq %r13, %rcx
movq %rax, %r15
movq %rax, %r8
xorl %eax, %eax
callq 0x1cede
movq 0x10(%rsp), %rbx
movq 0x40(%rsp), %r14
movq %r14, 0x118(%rsp)
movq $0x1000000, 0x120(%rsp) # imm = 0x1000000
movl $0x1000000, %r12d       # imm = 0x1000000
xorl %eax, %eax
movl $0x1000000, %r13d       # imm = 0x1000000
shlq $0x8, %rax
movq %rax, 0x128(%rsp)
movq 0x118(%rsp), %rax
movq (%rax), %rdi
callq 0x34b0
cltq
orq 0x128(%rsp), %rax
movq %rax, 0x128(%rsp)
shrq $0x8, %r13
cmpq $0x1ff, %r12            # imm = 0x1FF
movq %r13, %r12
ja 0x1599c
testb $0x1, 0x5c(%rsp)
je 0x16210
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movq $0x0, 0x90(%rsp)
movl $0x8, %edi
callq 0x32b0
movq %rax, 0x80(%rsp)
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x90(%rsp)
movq $0xffff, (%rax)         # imm = 0xFFFF
movq %rcx, 0x88(%rsp)
leaq 0x138(%rsp), %rdi
leaq 0x118(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
movl $0x2, %ecx
movl $0xd79435e, %r8d        # imm = 0xD79435E
callq 0x1c082
leaq 0x138(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x1c180
testb %al, %al
je 0x163a0
movq 0xb0(%rsp), %rcx
movl 0x14(%rcx), %eax
movl 0x18(%rcx), %r10d
movzwl %r15w, %r8d
leaq 0x170(%rsp), %rdi
leaq 0x118(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
leaq 0x80(%rsp), %rcx
movl $0x15550, %r9d          # imm = 0x15550
pushq %r10
pushq %rax
callq 0x1c262
addq $0x10, %rsp
movq 0xc8(%rsp), %rsi
subq 0xc0(%rsp), %rsi
sarq $0x3, %rsi
leaq 0x68(%rsp), %rdi
leaq 0xd8(%rsp), %rdx
callq 0x189c6
movq 0x18(%rsp), %rax
movl (%rax), %ebx
movq 0x48(%rsp), %r13
cmpl %r13d, %ebx
movq 0x20(%rsp), %r15
jle 0x15b35
movq 0x18(%rsp), %rax
movl %r13d, (%rax)
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x15b11
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq 0x4188(%rsp), %rdi
testq %rdi, %rdi
je 0x15b2e
movq 0x4198(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movb $0x1, %bl
jmp 0x163c5
movslq %ebx, %rdx
movq (%r15), %rdi
shlq $0x6, %rdx
movzwl 0x20(%rdi,%rdx), %ecx
movzwl 0x22(%rdi,%rdx), %eax
cmpw %ax, %cx
je 0x161e9
addq %rdx, %rdi
testw %cx, %cx
movl %ebx, 0xc(%rsp)
jle 0x15b64
movw %cx, 0x24(%rdi)
jmp 0x15b75
testw %ax, %ax
js 0x15b71
movw $0x0, 0x24(%rdi)
jmp 0x15b75
movw %ax, 0x24(%rdi)
movq 0x50(%rsp), %rbx
movslq 0x18(%rdi), %rax
movslq 0x1c(%rdi), %rsi
imulq %rax, %rsi
leaq 0x24(%rdi), %rdx
movq %rdi, 0x38(%rsp)
movq %rdx, 0x28(%rsp)
callq 0xe8d6
testl %ebx, %ebx
jne 0x15c98
movq 0x88(%rsp), %rax
subq 0x80(%rsp), %rax
cmpq $0x8, %rax
jne 0x15c98
movq 0x28(%rsp), %rax
cmpw $0x0, (%rax)
jne 0x15c98
movl $0x5, %edi
leaq 0x11206(%rip), %rsi     # 0x26ddc
xorl %eax, %eax
callq 0x1cede
movq 0x38(%rsp), %rax
cmpl $0x0, 0x1c(%rax)
movq 0x10(%rsp), %r12
movl 0xc(%rsp), %ebx
movq 0x40(%rsp), %r14
jle 0x161b9
xorl %r15d, %r15d
movq (%r14), %rdi
callq 0x3470
testl %eax, %eax
jne 0x1613b
testq %r12, %r12
je 0x15c23
movq (%r14), %rdi
callq 0x3030
cmpq %r12, %rax
jae 0x1613b
movq %r12, %r13
movq 0x38(%rsp), %rbp
cmpl $0x0, 0x18(%rbp)
jle 0x15c83
xorl %r12d, %r12d
movswl 0x20(%rbp), %edx
movswl 0x22(%rbp), %ecx
leaq 0x170(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x555a
movl 0x18(%rbp), %ecx
movl %r15d, %edx
imull %ecx, %edx
movslq %edx, %rdx
addq %r12, %rdx
movq (%rbp), %rsi
movq 0x8(%rbp), %rdi
subq %rsi, %rdi
sarq %rdi
cmpq %rdx, %rdi
leaq (%rsi,%rdx,2), %rdx
cmovbeq 0x28(%rsp), %rdx
movw %ax, (%rdx)
incq %r12
cmpl %ecx, %r12d
jl 0x15c34
incl %r15d
cmpl 0x1c(%rbp), %r15d
movq %r13, %r12
jl 0x15bfd
jmp 0x161b9
movl $0x5, %edi
leaq 0x11175(%rip), %rsi     # 0x26e19
xorl %eax, %eax
callq 0x1cede
movq 0x70(%rsp), %rsi
subq 0x68(%rsp), %rsi
shrq $0x2, %rsi
addl $-0xd, %esi
movq 0x38(%rsp), %rbx
movl 0x18(%rbx), %edx
leaq 0xd8(%rsp), %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
xorl %eax, %eax
pushq %rax
pushq %rax
pushq %rax
pushq %rax
callq 0xdb78
addq $0x20, %rsp
cmpl $0x0, 0x1c(%rbx)
movq 0x40(%rsp), %r14
jle 0x16193
xorl %ebp, %ebp
movq (%r14), %rdi
callq 0x3470
testl %eax, %eax
movq 0x18(%rsp), %r13
movq 0x50(%rsp), %r15
jne 0x1616a
cmpq $0x0, 0x10(%rsp)
je 0x15d2c
movq (%r14), %rdi
callq 0x3030
cmpq 0x10(%rsp), %rax
jae 0x1616a
testl %r15d, %r15d
setne %r15b
movl (%r13), %ecx
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
movl %ebp, %r12d
movl %ebp, %esi
movq 0x20(%rsp), %rdx
movq 0xb0(%rsp), %r8
leaq 0xd8(%rsp), %r9
callq 0x10bd6
movq %rbx, %rsi
cmpl $0x2, %ebp
setb %al
orb %r15b, %al
movl 0x18(%rbx), %eax
je 0x15e5e
testl %eax, %eax
jle 0x16129
xorl %r15d, %r15d
movl 0xf0(%rsp), %edx
movl $0x0, %r9d
testl %edx, %edx
jle 0x15dde
movq 0xd8(%rsp), %rax
movq 0x68(%rsp), %r8
xorl %r9d, %r9d
imull %r15d, %edx
movslq %edx, %rdx
addq %r9, %rdx
movswl (%rax,%rdx,2), %edx
movl %edx, (%r8,%r9,4)
movslq 0xf0(%rsp), %rdx
movslq %r15d, %rdi
imulq %rdx, %rdi
addq %r9, %rdi
movswl 0x2(%rax,%rdi,2), %edx
movl %edx, 0x4(%r8,%r9,4)
addq $0x2, %r9
movslq 0xf0(%rsp), %rdx
cmpq %rdx, %r9
jl 0x15d9f
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
movl %r15d, %edx
movl %r12d, %ecx
movq 0x50(%rsp), %r8
movq %rsi, %rbp
callq 0x5019
movl %eax, %r13d
movswl 0x20(%rbp), %edx
cwtl
subl %eax, %edx
movswl 0x22(%rbp), %ecx
subl %eax, %ecx
leaq 0x170(%rsp), %rdi
movq %rbx, %rsi
callq 0x555a
addl %eax, %r13d
movl 0x18(%rbp), %eax
movl %eax, %ecx
imull %r12d, %ecx
addl %r15d, %ecx
movslq %ecx, %rcx
movq (%rbp), %rdx
movq 0x8(%rbp), %rsi
subq %rdx, %rsi
sarq %rsi
cmpq %rcx, %rsi
leaq (%rdx,%rcx,2), %rcx
cmovbeq 0x28(%rsp), %rcx
movw %r13w, (%rcx)
incl %r15d
cmpl %eax, %r15d
movq %rbp, %rsi
jl 0x15d7e
jmp 0x16129
testl %eax, %eax
jle 0x15f5c
xorl %r15d, %r15d
movb $0x1, %r14b
movl 0xf0(%rsp), %edx
movl $0x0, %r9d
testl %edx, %edx
jle 0x15ecc
movq 0xd8(%rsp), %rax
movq 0x68(%rsp), %r8
xorl %r9d, %r9d
imull %r15d, %edx
movslq %edx, %rdx
addq %r9, %rdx
movswl (%rax,%rdx,2), %edx
movl %edx, (%r8,%r9,4)
movslq 0xf0(%rsp), %rdx
movslq %r15d, %rdi
imulq %rdx, %rdi
addq %r9, %rdi
movswl 0x2(%rax,%rdi,2), %edx
movl %edx, 0x4(%r8,%r9,4)
addq $0x2, %r9
movslq 0xf0(%rsp), %rdx
cmpq %rdx, %r9
jl 0x15e8d
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
movl %r15d, %edx
movl %r12d, %ecx
xorl %r8d, %r8d
movq %rsi, %rbp
callq 0x5019
movl %eax, %r13d
movswl 0x20(%rbp), %edx
cwtl
subl %eax, %edx
movswl 0x22(%rbp), %ecx
subl %eax, %ecx
leaq 0x170(%rsp), %rdi
movq %rbx, %rsi
callq 0x555a
addl %eax, %r13d
movl 0x18(%rbp), %eax
movl %eax, %ecx
imull %r12d, %ecx
addl %r15d, %ecx
movslq %ecx, %rcx
movq (%rbp), %rdx
movq 0x8(%rbp), %rsi
subq %rdx, %rsi
sarq %rsi
cmpq %rcx, %rsi
leaq (%rdx,%rcx,2), %rcx
cmovbeq 0x28(%rsp), %rcx
movw %r13w, (%rcx)
incl %r15d
cmpl %eax, %r15d
setl %cl
movl %r15d, %r13d
movl $0x1, %r15d
testb %cl, %r14b
movl $0x0, %r14d
movq %rbp, %rsi
jne 0x15e6c
jmp 0x15f5f
xorl %r13d, %r13d
leal -0x1(%rax), %edx
cmpl %edx, %r13d
movq 0x40(%rsp), %r14
jge 0x16048
movl 0xf0(%rsp), %edx
testl %edx, %edx
jle 0x15fcc
movq 0xd8(%rsp), %rax
movq 0x68(%rsp), %r9
xorl %r8d, %r8d
imull %r13d, %edx
movslq %edx, %rdx
addq %r8, %rdx
movswl (%rax,%rdx,2), %edx
movl %edx, (%r9,%r8,4)
movslq 0xf0(%rsp), %rdx
movslq %r13d, %rdi
imulq %rdx, %rdi
addq %r8, %rdi
movswl 0x2(%rax,%rdi,2), %edx
movl %edx, 0x4(%r9,%r8,4)
addq $0x2, %r8
movslq 0xf0(%rsp), %rdx
cmpq %rdx, %r8
jl 0x15f8b
jmp 0x15fcf
xorl %r8d, %r8d
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
movl %r13d, %edx
movl %r12d, %ecx
movq %rsi, %rbp
callq 0x5349
movl %eax, %r15d
movswl 0x20(%rbp), %edx
cwtl
subl %eax, %edx
movswl 0x22(%rbp), %ecx
subl %eax, %ecx
leaq 0x170(%rsp), %rdi
movq %rbx, %rsi
callq 0x555a
addl %eax, %r15d
movl 0x18(%rbp), %eax
movl %eax, %ecx
imull %r12d, %ecx
addl %r13d, %ecx
movslq %ecx, %rcx
movq (%rbp), %rdx
movq 0x8(%rbp), %rsi
subq %rdx, %rsi
sarq %rsi
cmpq %rcx, %rsi
leaq (%rdx,%rcx,2), %rcx
cmovbeq 0x28(%rsp), %rcx
movw %r15w, (%rcx)
incl %r13d
leal -0x1(%rax), %ecx
cmpl %ecx, %r13d
movq %rbp, %rsi
jl 0x15f70
cmpl %eax, %r13d
jge 0x16129
movl 0xf0(%rsp), %edx
testl %edx, %edx
jle 0x160ad
movq 0xd8(%rsp), %rax
movq 0x68(%rsp), %r8
xorl %r9d, %r9d
imull %r13d, %edx
movslq %edx, %rdx
addq %r9, %rdx
movswl (%rax,%rdx,2), %edx
movl %edx, (%r8,%r9,4)
movslq 0xf0(%rsp), %rdx
movslq %r13d, %rdi
imulq %rdx, %rdi
addq %r9, %rdi
movswl 0x2(%rax,%rdi,2), %edx
movl %edx, 0x4(%r8,%r9,4)
addq $0x2, %r9
movslq 0xf0(%rsp), %rdx
cmpq %rdx, %r9
jl 0x1606c
jmp 0x160b0
xorl %r9d, %r9d
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
movl %r13d, %edx
movl %r12d, %ecx
xorl %r8d, %r8d
movq %rsi, %rbp
callq 0x5019
movl %eax, %r15d
movswl 0x20(%rbp), %edx
cwtl
subl %eax, %edx
movswl 0x22(%rbp), %ecx
subl %eax, %ecx
leaq 0x170(%rsp), %rdi
movq %rbx, %rsi
callq 0x555a
addl %eax, %r15d
movl 0x18(%rbp), %eax
movl %eax, %ecx
imull %r12d, %ecx
addl %r13d, %ecx
movslq %ecx, %rcx
movq (%rbp), %rdx
movq 0x8(%rbp), %rsi
subq %rdx, %rsi
sarq %rsi
cmpq %rcx, %rsi
leaq (%rdx,%rcx,2), %rcx
cmovbeq 0x28(%rsp), %rcx
movw %r15w, (%rcx)
incl %r13d
cmpl %eax, %r13d
movq %rbp, %rsi
jl 0x16051
incl %r12d
movl %r12d, %ebp
cmpl 0x1c(%rsi), %r12d
jl 0x15cf7
jmp 0x16193
movl $0x3, %edi
leaq 0x10ca2(%rip), %rsi     # 0x26de9
movl %r15d, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x1cede
movq 0x18(%rsp), %rax
movl 0xc(%rsp), %ebx
movl %ebx, (%rax)
movq 0x10(%rsp), %r12
movq 0x40(%rsp), %r14
jmp 0x161b9
movl $0x3, %edi
leaq 0x10c73(%rip), %rsi     # 0x26de9
movl %ebp, %edx
movl 0xc(%rsp), %ecx
xorl %eax, %eax
callq 0x1cede
movq 0x18(%rsp), %rax
movl 0xc(%rsp), %ecx
movl %ecx, (%rax)
movq 0x40(%rsp), %r14
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x161b0
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movl 0xc(%rsp), %ebx
movq 0x10(%rsp), %r12
movq (%r14), %rdi
callq 0x3470
testl %eax, %eax
movq 0x20(%rsp), %r15
movq 0x48(%rsp), %r13
jne 0x15af2
testq %r12, %r12
je 0x161e9
movq (%r14), %rdi
callq 0x3030
cmpq %r12, %rax
jae 0x15af2
cmpl %r13d, %ebx
jge 0x15af2
incl %ebx
jmp 0x15b35
jmp 0x161fb
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x1be52
movl %eax, %ecx
jmp 0x154e3
leaq 0x118(%rsp), %rax
movq %rax, 0x170(%rsp)
movq 0x18(%rsp), %r15
movl (%r15), %r13d
cmpl 0x48(%rsp), %r13d
movq 0x20(%rsp), %r12
jle 0x16243
movq 0x48(%rsp), %rax
movl %eax, (%r15)
movb $0x1, %bl
jmp 0x163ef
movslq %r13d, %rdx
movq (%r12), %rbp
shlq $0x6, %rdx
movzwl 0x20(%rbp,%rdx), %ecx
movzwl 0x22(%rbp,%rdx), %eax
cmpw %ax, %cx
je 0x16374
addq %rdx, %rbp
testw %cx, %cx
movl %r13d, 0x28(%rsp)
jle 0x16274
movw %cx, 0x24(%rbp)
jmp 0x16285
testw %ax, %ax
js 0x16281
movw $0x0, 0x24(%rbp)
jmp 0x16285
movw %ax, 0x24(%rbp)
movslq 0x18(%rbp), %rax
movslq 0x1c(%rbp), %rsi
imulq %rax, %rsi
leaq 0x24(%rbp), %r13
movq %rbp, %rdi
movq %r13, %rdx
callq 0xe8d6
cmpl $0x0, 0x1c(%rbp)
jle 0x16344
xorl %r15d, %r15d
movq (%r14), %rdi
callq 0x3470
testl %eax, %eax
jne 0x1632e
testq %rbx, %rbx
je 0x162cb
movq (%r14), %rdi
callq 0x3030
cmpq %rbx, %rax
jae 0x1632e
cmpl $0x0, 0x18(%rbp)
jle 0x1631e
xorl %r12d, %r12d
movswl 0x20(%rbp), %esi
movswl 0x22(%rbp), %edx
subl %esi, %edx
leaq 0x170(%rsp), %rdi
callq 0x1bf34
movl 0x18(%rbp), %ecx
movl %r15d, %edx
imull %ecx, %edx
movslq %edx, %rdx
addq %r12, %rdx
movq (%rbp), %rsi
movq 0x8(%rbp), %rdi
subq %rsi, %rdi
sarq %rdi
cmpq %rdx, %rdi
leaq (%rsi,%rdx,2), %rdx
cmovbeq %r13, %rdx
movw %ax, (%rdx)
incq %r12
cmpl %ecx, %r12d
jl 0x162d4
incl %r15d
cmpl 0x1c(%rbp), %r15d
movq 0x20(%rsp), %r12
jl 0x162ad
jmp 0x16344
movl $0x3, %edi
leaq 0x10a80(%rip), %rsi     # 0x26dba
movl %r15d, %edx
xorl %eax, %eax
callq 0x1cede
movq (%r14), %rdi
callq 0x3470
testl %eax, %eax
movq 0x18(%rsp), %r15
movl 0x28(%rsp), %r13d
jne 0x16234
testq %rbx, %rbx
je 0x16374
movq (%r14), %rdi
callq 0x3030
cmpq %rbx, %rax
jae 0x16234
cmpl 0x48(%rsp), %r13d
jge 0x16234
incl %r13d
jmp 0x16243
addq %r15, %r12
movq 0x40(%rsp), %rdi
movq %r12, %rsi
movq 0x10(%rsp), %rdx
callq 0x1be52
movl %eax, %ebx
jmp 0x163ef
movq 0x18(%rsp), %rax
movslq (%rax), %rsi
shlq $0x6, %rsi
movq 0x20(%rsp), %rax
addq (%rax), %rsi
movq 0x40(%rsp), %rdi
movq 0x10(%rsp), %rdx
callq 0x1be52
movl %eax, %ebx
leaq 0x138(%rsp), %rdi
callq 0x1c338
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x163ef
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x1640c
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movl %ebx, %ecx
jmp 0x154e3
movq %rax, %rbx
jmp 0x1648f
jmp 0x16432
jmp 0x16475
jmp 0x16453
jmp 0x164d8
movq %rax, %rbx
jmp 0x164b9
jmp 0x164d8
jmp 0x16475
movq %rax, %rbx
jmp 0x164ac
jmp 0x164d8
jmp 0x164d8
jmp 0x164d8
jmp 0x16475
jmp 0x164d8
jmp 0x16453
jmp 0x16453
jmp 0x16453
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x16478
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
jmp 0x16478
movq %rax, %rbx
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x1648f
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq 0x4188(%rsp), %rdi
testq %rdi, %rdi
je 0x164ac
movq 0x4198(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
leaq 0x138(%rsp), %rdi
callq 0x1c338
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x164db
movq 0x90(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
jmp 0x164db
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x164f8
movq 0xd0(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x3590