// File: /workspace/github_cpp_makefile_star2_O1/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 $0x41d8, %rsp           # imm = 0x41D8
movq %r8, %rbx
movq %rcx, %r12
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %r14
movq (%rdi), %rdi
callq 0x3030
movq %rax, %rbp
movq (%r14), %rdi
callq 0x3480
movb $0x1, %cl
testl %eax, %eax
jne 0x15543
movq %rbp, 0x18(%rsp)
movq %r15, 0x58(%rsp)
movq %r13, 0x28(%rsp)
testq %rbx, %rbx
je 0x1548b
movq (%r14), %rdi
callq 0x3030
cmpq %rbx, %rax
jae 0x15541
movq %r14, %rdi
callq 0x150bc
movl %eax, %r13d
movq (%r14), %rdi
callq 0x3480
testl %eax, %eax
jne 0x15541
testq %rbx, %rbx
je 0x154bc
movq (%r14), %rdi
callq 0x3030
cmpq %rbx, %rax
jae 0x15541
movq %r12, 0x20(%rsp)
movq 0x28(%rsp), %rax
movl (%rax), %r15d
movq %r14, %rdi
callq 0x150bc
movl %eax, %r12d
movq (%r14), %rdi
callq 0x3480
testl %eax, %eax
jne 0x15541
testq %rbx, %rbx
je 0x154f2
movq (%r14), %rdi
callq 0x3030
cmpq %rbx, %rax
jae 0x15541
testw %r12w, %r12w
je 0x15502
movl $0x1, %ebp
subl %r12d, %ebp
jmp 0x1550c
movq %r14, %rdi
callq 0x150bc
movl %eax, %ebp
movq (%r14), %rdi
callq 0x3480
testl %eax, %eax
jne 0x15541
testq %rbx, %rbx
je 0x1552a
movq (%r14), %rdi
callq 0x3030
cmpq %rbx, %rax
jae 0x15541
movq %r14, %rdi
callq 0x150bc
movl %eax, %r12d
movq (%r14), %rdi
callq 0x3480
testl %eax, %eax
je 0x1555a
movb $0x1, %cl
andb $0x1, %cl
movl %ecx, %eax
addq $0x41d8, %rsp           # imm = 0x41D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %rbx, %rbx
je 0x1556c
movq (%r14), %rdi
callq 0x3030
cmpq %rbx, %rax
jae 0x15541
movl %r13d, 0x38(%rsp)
movl %r13d, %eax
sarl $0x4, %eax
movq %rax, 0xb0(%rsp)
leal (%r15,%rax), %r13d
addl %ebp, %r12d
movl %r12d, 0x68(%rsp)
movq 0x28(%rsp), %rax
movl (%rax), %r8d
leaq 0x123ed(%rip), %r12     # 0x27987
leaq 0x1150d(%rip), %rax     # 0x26aae
movq %rax, 0xb8(%rsp)
cmpl %r8d, %r13d
jle 0x155eb
movswl %bp, %r10d
testb $0x1, 0x38(%rsp)
leaq 0x114f0(%rip), %rcx     # 0x26aae
cmovneq %r12, %rcx
movswl 0x68(%rsp), %r11d
leaq 0x1167e(%rip), %rsi     # 0x26c4d
movl $0x3, %edi
movq 0x18(%rsp), %rdx
movl %r13d, %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x1d0d6
addq $0x10, %rsp
movslq %r13d, %rdx
movq 0x20(%rsp), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x6, %rcx
movq %rdx, 0x88(%rsp)
cmpq %rdx, %rcx
setbe %al
movq 0x28(%rsp), %rdx
movl (%rdx), %esi
cmpl %esi, %r13d
setl %dl
orb %al, %dl
je 0x15635
leaq 0x1166a(%rip), %rdi     # 0x26c8e
movl %r13d, %edx
xorl %eax, %eax
callq 0x3796
xorl %ecx, %ecx
jmp 0x15543
movl %r13d, 0x34(%rsp)
movl 0x38(%rsp), %ecx
movl %ecx, %eax
shrl %eax
andl $0x7, %eax
movq %rax, 0x50(%rsp)
movslq %esi, %rdx
testb $0x1, %cl
movq 0xb8(%rsp), %rax
cmovneq %r12, %rax
movq %rax, 0xb8(%rsp)
movq 0xb0(%rsp), %rax
leal (%r15,%rax), %r9d
incl %r9d
movq %rdx, %rdi
shlq $0x6, %rdi
orq $0x20, %rdi
movl $0x0, 0x6c(%rsp)
movl %eax, 0x3c(%rsp)
movl %esi, 0x60(%rsp)
movq 0x20(%rsp), %r12
movb $0x1, %cl
movl %r9d, 0x4c(%rsp)
movq %r15, 0x100(%rsp)
movl %ebp, 0x64(%rsp)
movq (%r12), %r13
movl -0x4(%r13,%rdi), %eax
imull -0x8(%r13,%rdi), %eax
movl $0x4, %r8d
testl %eax, %eax
jle 0x159e2
movq %rdx, 0x40(%rsp)
movl %esi, 0x10(%rsp)
leaq (%rdi,%r13), %r8
movw %bp, (%r13,%rdi)
movl 0x68(%rsp), %eax
movw %ax, 0x2(%r13,%rdi)
cmpw %ax, %bp
movq %rdi, 0x8(%rsp)
jge 0x15739
movq 0x28(%rsp), %rax
movl 0x34(%rsp), %edx
cmpl (%rax), %edx
jle 0x15739
movq %r14, %rdi
movq %r13, %r15
movq %r8, %r13
movl %r9d, %ebp
callq 0x150bc
movl %eax, %r12d
addw (%r13), %r12w
movw %r12w, (%r13)
movq %r14, %rdi
callq 0x150bc
movl %ebp, %r9d
movq %r13, %r8
movq %r15, %r13
movl 0x64(%rsp), %ebp
movq 0x8(%rsp), %rdi
movb $0x1, %cl
addl %r12d, %eax
movw %ax, 0x2(%r8)
leaq (%rdi,%r13), %rdx
addq $-0x20, %rdx
movzwl (%r8), %eax
cmpw 0x2(%r8), %ax
movq %rdx, 0xd0(%rsp)
jne 0x15828
movq %r13, 0xc8(%rsp)
movslq -0x8(%r8), %rax
movq %rdx, %rbp
movslq -0x4(%r8), %rsi
imulq %rax, %rsi
leaq 0x1a0(%rsp), %r12
movq %r12, %rdi
movq %r8, %r13
movq %r8, %rdx
leaq 0x108(%rsp), %rcx
callq 0xe312
movq %rbp, %rdi
movq %r12, %rsi
callq 0xfe18
movq 0x1a0(%rsp), %rdi
testq %rdi, %rdi
je 0x157b5
movq 0x1b0(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movl -0x8(%r13), %r12d
movl -0x4(%r13), %eax
movl %eax, 0xc0(%rsp)
movq 0x20(%rsp), %rdi
movl 0x10(%rsp), %ebp
movl %ebp, %esi
callq 0x11370
movq %rax, %r10
movswl (%r13), %r11d
movl $0x3, %edi
leaq 0x114e2(%rip), %rsi     # 0x26cca
movq 0x18(%rsp), %rdx
movl %ebp, %ecx
movl %r12d, %r8d
movl 0xc0(%rsp), %r9d
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x1d0d6
movq %r13, %r8
addq $0x10, %rsp
incl 0x60(%rsp)
movb $0x1, %cl
movl 0x4c(%rsp), %r9d
movq 0x8(%rsp), %rdi
movl 0x64(%rsp), %ebp
movq 0xc8(%rsp), %r13
movzwl 0x2(%r8), %eax
orw (%r8), %ax
jne 0x1584c
movq 0x20(%rsp), %r12
movl 0x10(%rsp), %esi
movq 0x40(%rsp), %rdx
movl $0x4, %r8d
jmp 0x159e2
movq %r8, 0xc8(%rsp)
movq %rdi, %r12
movq %r14, %rdi
callq 0x150bc
movl %eax, 0x8(%r13,%r12)
movq (%r14), %rdi
callq 0x3480
testl %eax, %eax
movq 0x20(%rsp), %r12
je 0x158ac
movq %r14, %rdi
movq 0xd0(%rsp), %rsi
movq %rbx, %rdx
callq 0x1c115
movl %eax, 0x3c(%rsp)
movl $0x1, %r8d
movb $0x1, %cl
movl 0x10(%rsp), %esi
movq 0x8(%rsp), %rdi
movq 0x40(%rsp), %rdx
movl 0x4c(%rsp), %r9d
jmp 0x159e2
testq %rbx, %rbx
je 0x158be
movq (%r14), %rdi
callq 0x3030
cmpq %rbx, %rax
jae 0x15875
movq %r12, %rdi
movq 0x8(%rsp), %r12
movl -0x8(%r13,%r12), %eax
movl %eax, 0xdc(%rsp)
movl -0x4(%r13,%r12), %eax
movq %rax, 0xd0(%rsp)
movl 0x10(%rsp), %esi
callq 0x11370
movq %rax, 0xc0(%rsp)
movswl (%r13,%r12), %eax
movq %rax, 0x160(%rsp)
movswl 0x2(%r13,%r12), %r10d
movl 0x8(%r13,%r12), %r11d
movl $0x3, %edi
leaq 0x113f5(%rip), %rsi     # 0x26d0a
movq 0x18(%rsp), %rdx
movq 0xb8(%rsp), %rcx
movl 0x10(%rsp), %r8d
movl 0xdc(%rsp), %r9d
xorl %eax, %eax
pushq 0x50(%rsp)
pushq %r11
pushq %r10
pushq 0x178(%rsp)
pushq 0xe0(%rsp)
pushq 0xf8(%rsp)
callq 0x1d0d6
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 0x113ef(%rip), %rsi     # 0x26d66
xorl %eax, %eax
callq 0x1d0d6
movl $0x3, %edi
leaq 0x11ffc(%rip), %rsi     # 0x27986
xorl %eax, %eax
callq 0x1d0d6
testb $0x1, 0x38(%rsp)
je 0x159b5
movq 0xc8(%rsp), %rax
movswl (%rax), %edi
movswl 0x2(%rax), %esi
movq 0x50(%rsp), %rdx
callq 0x112f8
testb %al, %al
je 0x159ba
xorl %r8d, %r8d
jmp 0x159c8
movl $0x1, %r8d
movl $0x0, 0x3c(%rsp)
movq 0x20(%rsp), %r12
movb $0x1, %cl
movl 0x10(%rsp), %esi
movl 0x4c(%rsp), %r9d
movq 0x8(%rsp), %rdi
movq 0x40(%rsp), %rdx
testb $0x3, %r8b
jne 0x15a0d
cmpq 0x88(%rsp), %rdx
leaq 0x1(%rdx), %rax
setge %dl
movl %edx, 0x6c(%rsp)
incl %esi
addq $0x40, %rdi
movq %rax, %rdx
cmpl %esi, %r9d
jne 0x156a6
testb $0x1, 0x6c(%rsp)
je 0x15a2f
movl 0x34(%rsp), %r13d
movl 0x60(%rsp), %ebp
cmpl %r13d, %ebp
jle 0x15a38
movq 0x28(%rsp), %rax
movl %r13d, (%rax)
jmp 0x15543
movl 0x3c(%rsp), %ecx
jmp 0x15543
xorps %xmm0, %xmm0
leaq 0xe0(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq 0x28(%rsp), %rax
movl (%rax), %edx
movq %r12, %rsi
movl %r13d, %ecx
movq 0x58(%rsp), %r8
callq 0x107aa
testb $0x1, 0x38(%rsp)
sete %al
cmpl $0x0, 0x50(%rsp)
setne %cl
movl $0x800, %edx            # imm = 0x800
movq %rdx, 0x8(%rsp)
orb %al, %cl
movq %rbx, 0x18(%rsp)
movq %r14, 0x10(%rsp)
jne 0x15b25
movslq %ebp, %r15
movq 0x20(%rsp), %rax
movq (%rax), %r12
shlq $0x6, %r15
movslq 0x1c(%r12,%r15), %rbx
movslq 0x18(%r12,%r15), %rbp
movq %r14, %rdi
callq 0x150bc
leal -0x1(%rax), %r14d
cmpl $0x7f, %r14d
jae 0x15aef
movq %rax, %r8
imulq %rbx, %rbp
shll $0x5, %r8d
movq %r8, %rdx
imulq %rbp, %rdx
shrq $0xc, %rdx
leaq 0x112aa(%rip), %rsi     # 0x26d83
movl $0x5, %edi
movq %rbp, %rcx
movq %r8, 0x8(%rsp)
xorl %eax, %eax
callq 0x1d0d6
jmp 0x15b12
addq %r15, %r12
movq 0x10(%rsp), %rdi
movq %r12, %rsi
movq 0x18(%rsp), %rdx
callq 0x1c115
movl %eax, 0x3c(%rsp)
movl $0x800, %eax            # imm = 0x800
movq %rax, 0x8(%rsp)
movl 0x3c(%rsp), %ebx
cmpl $0x7f, %r14d
movq 0x10(%rsp), %r14
jae 0x165e2
movq %r14, 0x148(%rsp)
movq $0x1000000, 0x150(%rsp) # imm = 0x1000000
movq $0x0, 0x158(%rsp)
movl $0x1000000, %r15d       # imm = 0x1000000
movl $0x1000000, %r12d       # imm = 0x1000000
shlq $0x8, 0x158(%rsp)
movq 0x148(%rsp), %rax
movq (%rax), %rdi
callq 0x34c0
cltq
orq %rax, 0x158(%rsp)
shrq $0x8, %r12
cmpq $0x1ff, %r15            # imm = 0x1FF
movq %r12, %r15
ja 0x15b51
testb $0x1, 0x38(%rsp)
je 0x163da
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movq $0x0, 0xa0(%rsp)
movl $0x8, %edi
callq 0x32b0
movq %rax, 0x90(%rsp)
movq %rax, 0x98(%rsp)
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0xa0(%rsp)
movq $0xffff, (%rax)         # imm = 0xFFFF
movq %rcx, 0x98(%rsp)
leaq 0x168(%rsp), %rdi
leaq 0x148(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
movl $0x2, %ecx
movl $0xd79435e, %r8d        # imm = 0xD79435E
callq 0x1c214
leaq 0x168(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x1c312
testb %al, %al
je 0x16593
movq 0x58(%rsp), %rcx
movl 0x14(%rcx), %eax
movl 0x18(%rcx), %r10d
movzwl 0x8(%rsp), %r8d
leaq 0x1a0(%rsp), %rdi
leaq 0x148(%rsp), %rsi
leaq 0xe0(%rsp), %rdx
leaq 0x90(%rsp), %rcx
movl $0x15550, %r9d          # imm = 0x15550
pushq %r10
pushq %rax
callq 0x1c3f4
addq $0x10, %rsp
movq 0xe8(%rsp), %rsi
subq 0xe0(%rsp), %rsi
sarq $0x3, %rsi
leaq 0x70(%rsp), %rdi
leaq 0x108(%rsp), %rdx
callq 0x18c64
movq 0x28(%rsp), %rax
movslq (%rax), %r14
cmpl 0x34(%rsp), %r14d
movq 0x20(%rsp), %r15
jg 0x16391
movq 0x100(%rsp), %rax
movq 0xb0(%rsp), %rcx
leal (%rax,%rcx), %r12d
incl %r12d
movl %r12d, 0x88(%rsp)
movq (%r15), %rdi
movq %r14, %rdx
shlq $0x6, %rdx
movzwl 0x20(%rdi,%rdx), %ecx
movzwl 0x22(%rdi,%rdx), %eax
movl $0x10, %ebp
cmpw %ax, %cx
je 0x1637f
addq %rdx, %rdi
testw %cx, %cx
movq %rdi, 0x8(%rsp)
movq %r14, 0x40(%rsp)
jle 0x15cfe
movw %cx, 0x24(%rdi)
jmp 0x15d19
testw %ax, %ax
js 0x15d10
movq 0x8(%rsp), %rdi
movw $0x0, 0x24(%rdi)
jmp 0x15d19
movq 0x8(%rsp), %rdi
movw %ax, 0x24(%rdi)
movslq 0x18(%rdi), %rax
movslq 0x1c(%rdi), %rsi
imulq %rax, %rsi
leaq 0x24(%rdi), %rdx
movq %rdx, %r13
callq 0xe944
cmpl $0x0, 0x50(%rsp)
jne 0x15e2a
movq 0x98(%rsp), %rax
subq 0x90(%rsp), %rax
cmpq $0x8, %rax
jne 0x15e2a
cmpw $0x0, (%r13)
jne 0x15e2a
movl $0x5, %edi
leaq 0x11070(%rip), %rsi     # 0x26dde
xorl %eax, %eax
callq 0x1d0d6
movq 0x8(%rsp), %rax
cmpl $0x0, 0x1c(%rax)
movq 0x40(%rsp), %r14
jle 0x1632f
xorl %ebp, %ebp
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x3480
testl %eax, %eax
jne 0x162be
cmpq $0x0, 0x18(%rsp)
je 0x15dc0
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x3030
cmpq 0x18(%rsp), %rax
jae 0x162be
movq 0x8(%rsp), %rbx
cmpl $0x0, 0x18(%rbx)
jle 0x15e1a
movslq %ebp, %r15
xorl %r12d, %r12d
movswl 0x20(%rbx), %edx
movswl 0x22(%rbx), %ecx
leaq 0x1a0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x5660
movslq 0x18(%rbx), %rcx
imulq %r15, %rcx
addq %r12, %rcx
movq (%rbx), %rdx
movq 0x8(%rbx), %rsi
subq %rdx, %rsi
sarq %rsi
cmpq %rcx, %rsi
leaq (%rdx,%rcx,2), %rcx
cmovbeq %r13, %rcx
movw %ax, (%rcx)
incq %r12
cmpl 0x18(%rbx), %r12d
jl 0x15dd1
incl %ebp
cmpl 0x1c(%rbx), %ebp
jl 0x15d8b
jmp 0x1632f
movl $0x5, %edi
leaq 0x10fe5(%rip), %rsi     # 0x26e1b
xorl %eax, %eax
callq 0x1d0d6
movq 0x78(%rsp), %rsi
subq 0x70(%rsp), %rsi
shrq $0x2, %rsi
addl $-0xd, %esi
movq 0x8(%rsp), %rbx
movl 0x18(%rbx), %edx
leaq 0x108(%rsp), %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
movl $0x1, %r9d
xorl %eax, %eax
pushq %rax
pushq %rax
pushq %rax
pushq %rax
callq 0xdc18
addq $0x20, %rsp
cmpl $0x0, 0x1c(%rbx)
jle 0x1630d
xorl %r12d, %r12d
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x3480
testl %eax, %eax
movq 0x28(%rsp), %r15
jne 0x162e6
cmpq $0x0, 0x18(%rsp)
je 0x15ebf
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x3030
cmpq 0x18(%rsp), %rax
jae 0x162e6
cmpl $0x0, 0x50(%rsp)
setne %bpl
movl (%r15), %ecx
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movl %r12d, %r14d
movl %r12d, %esi
movq 0x20(%rsp), %rdx
movq 0x58(%rsp), %r8
leaq 0x108(%rsp), %r9
callq 0x10c8d
movq %rbx, %rsi
cmpl $0x2, %r12d
setb %al
orb %bpl, %al
movl 0x18(%rbx), %eax
je 0x15ff0
testl %eax, %eax
jle 0x162ac
xorl %ebp, %ebp
movl 0x120(%rsp), %edx
movl $0x0, %r9d
testl %edx, %edx
jle 0x15f6f
movq 0x108(%rsp), %rax
movq 0x70(%rsp), %r8
xorl %r9d, %r9d
imull %ebp, %edx
movslq %edx, %rdx
addq %r9, %rdx
movswl (%rax,%rdx,2), %edx
movl %edx, (%r8,%r9,4)
movslq 0x120(%rsp), %rdx
movslq %ebp, %rdi
imulq %rdx, %rdi
addq %r9, %rdi
movswl 0x2(%rax,%rdi,2), %edx
movl %edx, 0x4(%r8,%r9,4)
addq $0x2, %r9
movslq 0x120(%rsp), %rdx
cmpq %rdx, %r9
jl 0x15f31
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movl %ebp, %edx
movl %r14d, %ecx
movq 0x50(%rsp), %r8
movq %rsi, %r12
callq 0x5122
movl %eax, %r15d
movswl 0x20(%r12), %edx
cwtl
subl %eax, %edx
movswl 0x22(%r12), %ecx
subl %eax, %ecx
leaq 0x1a0(%rsp), %rdi
movq %rbx, %rsi
callq 0x5660
addl %eax, %r15d
movl 0x18(%r12), %eax
imull %r14d, %eax
addl %ebp, %eax
cltq
movq (%r12), %rcx
movq 0x8(%r12), %rdx
subq %rcx, %rdx
sarq %rdx
cmpq %rax, %rdx
leaq (%rcx,%rax,2), %rax
cmovbeq %r13, %rax
movw %r15w, (%rax)
incl %ebp
cmpl 0x18(%r12), %ebp
movq %r12, %rsi
jl 0x15f10
jmp 0x162ac
testl %eax, %eax
jle 0x160dd
xorl %ebp, %ebp
movl 0x120(%rsp), %edx
movl $0x0, %r9d
testl %edx, %edx
jle 0x16059
movq 0x108(%rsp), %rax
movq 0x70(%rsp), %r8
xorl %r9d, %r9d
imull %ebp, %edx
movslq %edx, %rdx
addq %r9, %rdx
movswl (%rax,%rdx,2), %edx
movl %edx, (%r8,%r9,4)
movslq 0x120(%rsp), %rdx
movslq %ebp, %rdi
imulq %rdx, %rdi
addq %r9, %rdi
movswl 0x2(%rax,%rdi,2), %edx
movl %edx, 0x4(%r8,%r9,4)
addq $0x2, %r9
movslq 0x120(%rsp), %rdx
cmpq %rdx, %r9
jl 0x1601b
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movl %ebp, %edx
movl %r14d, %ecx
xorl %r8d, %r8d
movq %rsi, %r12
callq 0x5122
movl %eax, %r15d
movswl 0x20(%r12), %edx
cwtl
subl %eax, %edx
movswl 0x22(%r12), %ecx
subl %eax, %ecx
leaq 0x1a0(%rsp), %rdi
movq %rbx, %rsi
callq 0x5660
addl %eax, %r15d
movl 0x18(%r12), %eax
imull %r14d, %eax
addl %ebp, %eax
cltq
movq (%r12), %rcx
movq 0x8(%r12), %rdx
subq %rcx, %rdx
sarq %rdx
cmpq %rax, %rdx
leaq (%rcx,%rax,2), %rax
cmovbeq %r13, %rax
movw %r15w, (%rax)
leal 0x1(%rbp), %r15d
testl %ebp, %ebp
movq %r12, %rsi
jne 0x160e0
movl %r15d, %ebp
cmpl 0x18(%rsi), %r15d
jl 0x15ffa
jmp 0x160e0
xorl %r15d, %r15d
movl 0x18(%rsi), %eax
decl %eax
cmpl %eax, %r15d
jge 0x161c9
movl 0x120(%rsp), %edx
testl %edx, %edx
jle 0x1614a
movq 0x108(%rsp), %rax
movq 0x70(%rsp), %r9
xorl %r8d, %r8d
imull %r15d, %edx
movslq %edx, %rdx
addq %r8, %rdx
movswl (%rax,%rdx,2), %edx
movl %edx, (%r9,%r8,4)
movslq 0x120(%rsp), %rdx
movslq %r15d, %rdi
imulq %rdx, %rdi
addq %r8, %rdi
movswl 0x2(%rax,%rdi,2), %edx
movl %edx, 0x4(%r9,%r8,4)
addq $0x2, %r8
movslq 0x120(%rsp), %rdx
cmpq %rdx, %r8
jl 0x16109
jmp 0x1614d
xorl %r8d, %r8d
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movl %r15d, %edx
movl %r14d, %ecx
movq %rsi, %r12
callq 0x544e
movl %eax, %ebp
movswl 0x20(%r12), %edx
cwtl
subl %eax, %edx
movswl 0x22(%r12), %ecx
subl %eax, %ecx
leaq 0x1a0(%rsp), %rdi
movq %rbx, %rsi
callq 0x5660
addl %eax, %ebp
movl 0x18(%r12), %eax
imull %r14d, %eax
addl %r15d, %eax
cltq
movq (%r12), %rcx
movq 0x8(%r12), %rdx
subq %rcx, %rdx
sarq %rdx
cmpq %rax, %rdx
leaq (%rcx,%rax,2), %rax
cmovbeq %r13, %rax
movw %bp, (%rax)
incl %r15d
movl 0x18(%r12), %eax
decl %eax
cmpl %eax, %r15d
movq %r12, %rsi
jl 0x160ee
cmpl 0x18(%rsi), %r15d
jge 0x162ac
movl 0x120(%rsp), %edx
testl %edx, %edx
jle 0x1622f
movq 0x108(%rsp), %rax
movq 0x70(%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 0x120(%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 0x120(%rsp), %rdx
cmpq %rdx, %r9
jl 0x161ee
jmp 0x16232
xorl %r9d, %r9d
leaq 0x70(%rsp), %rbx
movq %rbx, %rdi
movl %r15d, %edx
movl %r14d, %ecx
xorl %r8d, %r8d
movq %rsi, %r12
callq 0x5122
movl %eax, %ebp
movswl 0x20(%r12), %edx
cwtl
subl %eax, %edx
movswl 0x22(%r12), %ecx
subl %eax, %ecx
leaq 0x1a0(%rsp), %rdi
movq %rbx, %rsi
callq 0x5660
addl %eax, %ebp
movl 0x18(%r12), %eax
imull %r14d, %eax
addl %r15d, %eax
cltq
movq (%r12), %rcx
movq 0x8(%r12), %rdx
subq %rcx, %rdx
sarq %rdx
cmpq %rax, %rdx
leaq (%rcx,%rax,2), %rax
cmovbeq %r13, %rax
movw %bp, (%rax)
incl %r15d
cmpl 0x18(%r12), %r15d
movq %r12, %rsi
jl 0x161d3
incl %r14d
movl %r14d, %r12d
cmpl 0x1c(%rsi), %r14d
jl 0x15e85
jmp 0x1630d
movl $0x3, %edi
leaq 0x10b21(%rip), %rsi     # 0x26deb
movl %ebp, %edx
movq %r14, %r15
movl %r14d, %ecx
xorl %eax, %eax
callq 0x1d0d6
movq 0x28(%rsp), %rax
movq %r15, %r14
movl %r14d, (%rax)
jmp 0x1632f
movl $0x3, %edi
leaq 0x10af9(%rip), %rsi     # 0x26deb
movl %r12d, %edx
movq 0x40(%rsp), %rcx
xorl %eax, %eax
callq 0x1d0d6
movq 0x28(%rsp), %rax
movq 0x40(%rsp), %rcx
movl %ecx, (%rax)
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0x1632a
movq 0x118(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq 0x40(%rsp), %r14
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x3480
movl $0xe, %ebp
testl %eax, %eax
je 0x16354
movq 0x20(%rsp), %r15
movl 0x88(%rsp), %r12d
jmp 0x1637f
cmpq $0x0, 0x18(%rsp)
movq 0x20(%rsp), %r15
movl 0x88(%rsp), %r12d
je 0x1637d
movq 0x10(%rsp), %rax
movq (%rax), %rdi
callq 0x3030
cmpq 0x18(%rsp), %rax
jae 0x1637f
xorl %ebp, %ebp
testb $0xf, %bpl
jne 0x16391
incq %r14
cmpl %r14d, %r12d
jne 0x15cc4
movq 0x28(%rsp), %rax
movl 0x34(%rsp), %ecx
movl %ecx, (%rax)
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x163b6
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq 0x41b8(%rsp), %rdi
testq %rdi, %rdi
je 0x163d3
movq 0x41c8(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movb $0x1, %bl
jmp 0x165b8
leaq 0x148(%rsp), %rax
movq %rax, 0x1a0(%rsp)
movq 0x28(%rsp), %rax
movslq (%rax), %r13
cmpl 0x34(%rsp), %r13d
movq 0x20(%rsp), %r12
movq 0x10(%rsp), %r14
jg 0x16584
movq 0x100(%rsp), %rax
movq 0xb0(%rsp), %rcx
addl %ecx, %eax
incl %eax
movl %eax, 0x58(%rsp)
movq (%r12), %rbp
movq %r13, %rdx
shlq $0x6, %rdx
movzwl 0x20(%rbp,%rdx), %ecx
movzwl 0x22(%rbp,%rdx), %eax
movl $0x7, %r15d
cmpw %ax, %cx
je 0x1656b
addq %rdx, %rbp
testw %cx, %cx
movq %r13, 0x8(%rsp)
jle 0x16456
movw %cx, 0x24(%rbp)
jmp 0x16467
testw %ax, %ax
js 0x16463
movw $0x0, 0x24(%rbp)
jmp 0x16467
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 0xe944
cmpl $0x0, 0x1c(%rbp)
jle 0x16533
xorl %ebx, %ebx
movq (%r14), %rdi
callq 0x3480
testl %eax, %eax
jne 0x1651e
cmpq $0x0, 0x18(%rsp)
je 0x164b5
movq (%r14), %rdi
callq 0x3030
cmpq 0x18(%rsp), %rax
jae 0x1651e
cmpl $0x0, 0x18(%rbp)
jle 0x16508
movslq %ebx, %r12
xorl %r15d, %r15d
movswl 0x20(%rbp), %esi
movswl 0x22(%rbp), %edx
subl %esi, %edx
leaq 0x1a0(%rsp), %rdi
callq 0x1c1c6
movslq 0x18(%rbp), %rcx
imulq %r12, %rcx
addq %r15, %rcx
movq (%rbp), %rdx
movq 0x8(%rbp), %rsi
subq %rdx, %rsi
sarq %rsi
cmpq %rcx, %rsi
leaq (%rdx,%rcx,2), %rcx
cmovbeq %r13, %rcx
movw %ax, (%rcx)
incq %r15
cmpl 0x18(%rbp), %r15d
jl 0x164c1
movl %ebx, %eax
incl %eax
movl %eax, %ebx
cmpl 0x1c(%rbp), %eax
movq 0x20(%rsp), %r12
jl 0x1648e
jmp 0x16533
movl $0x3, %edi
leaq 0x10892(%rip), %rsi     # 0x26dbc
movl %ebx, %edx
xorl %eax, %eax
callq 0x1d0d6
movq (%r14), %rdi
callq 0x3480
movl $0x5, %r15d
testl %eax, %eax
je 0x1654c
movq 0x8(%rsp), %r13
jmp 0x1656b
cmpq $0x0, 0x18(%rsp)
movq 0x8(%rsp), %r13
je 0x16568
movq (%r14), %rdi
callq 0x3030
cmpq 0x18(%rsp), %rax
jae 0x1656b
xorl %r15d, %r15d
cmpl $0x7, %r15d
je 0x16576
testl %r15d, %r15d
jne 0x16584
incq %r13
cmpl %r13d, 0x58(%rsp)
jne 0x1641f
movq 0x28(%rsp), %rax
movl 0x34(%rsp), %ecx
movl %ecx, (%rax)
movb $0x1, %bl
jmp 0x165e2
movq 0x28(%rsp), %rax
movslq (%rax), %rsi
shlq $0x6, %rsi
movq 0x20(%rsp), %rax
addq (%rax), %rsi
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rdx
callq 0x1c115
movl %eax, %ebx
leaq 0x168(%rsp), %rdi
callq 0x1c4ca
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x165e2
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x165ff
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movl %ebx, %ecx
jmp 0x15543
movq %rax, %rbx
jmp 0x16685
jmp 0x16625
jmp 0x16646
jmp 0x16668
jmp 0x166ce
movq %rax, %rbx
jmp 0x166af
jmp 0x166ce
jmp 0x16668
movq %rax, %rbx
jmp 0x166a2
jmp 0x166ce
jmp 0x166ce
jmp 0x166ce
jmp 0x16668
jmp 0x166ce
jmp 0x16646
jmp 0x16646
jmp 0x16646
movq %rax, %rbx
movq 0x108(%rsp), %rdi
testq %rdi, %rdi
je 0x1666b
movq 0x118(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
jmp 0x1666b
movq %rax, %rbx
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x16685
movq 0x80(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq 0x41b8(%rsp), %rdi
testq %rdi, %rdi
je 0x166a2
movq 0x41c8(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
leaq 0x168(%rsp), %rdi
callq 0x1c4ca
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x166d1
movq 0xa0(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
jmp 0x166d1
movq %rax, %rbx
movq 0xe0(%rsp), %rdi
testq %rdi, %rdi
je 0x166ee
movq 0xf0(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
movq %rbx, %rdi
callq 0x35a0