// File: 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 %r14
pushq %rbx
subq $0x4340, %rsp           # imm = 0x4340
movq %rdi, 0x4330(%rsp)
movq %rsi, 0x4328(%rsp)
movq %rdx, 0x4320(%rsp)
movq %rcx, 0x4318(%rsp)
movq %r8, 0x4310(%rsp)
movq 0x4330(%rsp), %rdi
callq 0x25410
movq %rax, 0x4308(%rsp)
movq 0x4330(%rsp), %rdi
callq 0x25a20
testb $0x1, %al
jne 0x25abb
cmpq $0x0, 0x4310(%rsp)
je 0x25ac8
movq 0x4330(%rsp), %rdi
callq 0x25410
cmpq 0x4310(%rsp), %rax
jb 0x25ac8
movb $0x1, 0x433f(%rsp)
jmp 0x271f3
movq 0x4330(%rsp), %rdi
callq 0x25360
movl %eax, 0x4304(%rsp)
movq 0x4330(%rsp), %rdi
callq 0x25a20
testb $0x1, %al
jne 0x25b0f
cmpq $0x0, 0x4310(%rsp)
je 0x25b1c
movq 0x4330(%rsp), %rdi
callq 0x25410
cmpq 0x4310(%rsp), %rax
jb 0x25b1c
movb $0x1, 0x433f(%rsp)
jmp 0x271f3
movq 0x4320(%rsp), %rax
movl (%rax), %eax
movl 0x4304(%rsp), %ecx
sarl $0x4, %ecx
addl %ecx, %eax
movl %eax, 0x4300(%rsp)
movl 0x4304(%rsp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, 0x42ff(%rsp)
movl 0x4304(%rsp), %eax
andl $0xe, %eax
sarl %eax
movl %eax, 0x42f8(%rsp)
movq 0x4330(%rsp), %rdi
callq 0x25360
movl %eax, %ecx
movl $0x1, %eax
subl %ecx, %eax
movw %ax, 0x42f6(%rsp)
movq 0x4330(%rsp), %rdi
callq 0x25a20
testb $0x1, %al
jne 0x25bb6
cmpq $0x0, 0x4310(%rsp)
je 0x25bc3
movq 0x4330(%rsp), %rdi
callq 0x25410
cmpq 0x4310(%rsp), %rax
jb 0x25bc3
movb $0x1, 0x433f(%rsp)
jmp 0x271f3
movswl 0x42f6(%rsp), %eax
cmpl $0x1, %eax
jne 0x25be5
movq 0x4330(%rsp), %rdi
callq 0x25360
movw %ax, 0x42f6(%rsp)
movq 0x4330(%rsp), %rdi
callq 0x25a20
testb $0x1, %al
jne 0x25c18
cmpq $0x0, 0x4310(%rsp)
je 0x25c25
movq 0x4330(%rsp), %rdi
callq 0x25410
cmpq 0x4310(%rsp), %rax
jb 0x25c25
movb $0x1, 0x433f(%rsp)
jmp 0x271f3
movswl 0x42f6(%rsp), %eax
movl %eax, 0x128(%rsp)
movq 0x4330(%rsp), %rdi
callq 0x25360
movl %eax, %ecx
movl 0x128(%rsp), %eax
addl %ecx, %eax
movw %ax, 0x42f4(%rsp)
movq 0x4330(%rsp), %rdi
callq 0x25a20
testb $0x1, %al
jne 0x25c87
cmpq $0x0, 0x4310(%rsp)
je 0x25c94
movq 0x4330(%rsp), %rdi
callq 0x25410
cmpq 0x4310(%rsp), %rax
jb 0x25c94
movb $0x1, 0x433f(%rsp)
jmp 0x271f3
movl 0x4300(%rsp), %eax
movq 0x4320(%rsp), %rcx
cmpl (%rcx), %eax
jle 0x25d0c
movq 0x4308(%rsp), %rdx
movb 0x42ff(%rsp), %sil
leaq 0x21cec(%rip), %rcx     # 0x479aa
leaq 0x22be9(%rip), %rax     # 0x488ae
testb $0x1, %sil
cmovneq %rax, %rcx
movq 0x4320(%rsp), %rax
movl (%rax), %r8d
movl 0x4300(%rsp), %r9d
movswl 0x42f6(%rsp), %r10d
movswl 0x42f4(%rsp), %eax
movl $0x3, %edi
leaq 0x21e4c(%rip), %rsi     # 0x47b49
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x3a770
movslq 0x4300(%rsp), %rax
movq %rax, 0x120(%rsp)
movq 0x4318(%rsp), %rdi
callq 0x4b80
movq %rax, %rcx
movq 0x120(%rsp), %rax
cmpq %rcx, %rax
jae 0x25d4c
movl 0x4300(%rsp), %eax
movq 0x4320(%rsp), %rcx
cmpl (%rcx), %eax
jge 0x25da4
movq 0x4320(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x118(%rsp)
movl 0x4300(%rsp), %eax
movl %eax, 0x11c(%rsp)
movq 0x4318(%rsp), %rdi
callq 0x4b80
movl 0x118(%rsp), %esi
movl 0x11c(%rsp), %edx
movq %rax, %rcx
leaq 0x21dfa(%rip), %rdi     # 0x47b8a
movb $0x0, %al
callq 0x3a670
movb $0x0, 0x433f(%rsp)
jmp 0x271f3
movq 0x4320(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x42f0(%rsp)
movq 0x4320(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x42ec(%rsp)
movl 0x42ec(%rsp), %eax
cmpl 0x4300(%rsp), %eax
jg 0x2628c
movq 0x4318(%rsp), %rdi
movslq 0x42ec(%rsp), %rsi
callq 0x4ba0
movq %rax, 0x42e0(%rsp)
movq 0x42e0(%rsp), %rax
movl 0x18(%rax), %eax
movq 0x42e0(%rsp), %rcx
imull 0x1c(%rcx), %eax
cmpl $0x0, %eax
jg 0x25e18
jmp 0x26276
movw 0x42f6(%rsp), %cx
movq 0x42e0(%rsp), %rax
movw %cx, 0x20(%rax)
movw 0x42f4(%rsp), %cx
movq 0x42e0(%rsp), %rax
movw %cx, 0x22(%rax)
movl 0x4300(%rsp), %eax
movq 0x4320(%rsp), %rcx
cmpl (%rcx), %eax
jle 0x25ec2
movswl 0x42f6(%rsp), %eax
movswl 0x42f4(%rsp), %ecx
cmpl %ecx, %eax
jge 0x25ec2
movq 0x4330(%rsp), %rdi
callq 0x25360
movl %eax, %edx
movq 0x42e0(%rsp), %rax
movswl 0x20(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x20(%rax)
movq 0x42e0(%rsp), %rax
movswl 0x20(%rax), %eax
movl %eax, 0x114(%rsp)
movq 0x4330(%rsp), %rdi
callq 0x25360
movl %eax, %ecx
movl 0x114(%rsp), %eax
addl %ecx, %eax
movw %ax, %cx
movq 0x42e0(%rsp), %rax
movw %cx, 0x22(%rax)
movq 0x42e0(%rsp), %rax
movswl 0x20(%rax), %eax
movq 0x42e0(%rsp), %rcx
movswl 0x22(%rcx), %ecx
cmpl %ecx, %eax
jne 0x2604d
movq 0x42e0(%rsp), %rax
movl 0x18(%rax), %ecx
movl 0x1c(%rax), %edx
imull %edx, %ecx
movslq %ecx, %rcx
movq %rcx, 0xf8(%rsp)
addq $0x20, %rax
movq %rax, 0x100(%rsp)
leaq 0x42c7(%rsp), %rdi
movq %rdi, 0x108(%rsp)
callq 0x12e60
movq 0xf8(%rsp), %rsi
movq 0x100(%rsp), %rdx
movq 0x108(%rsp), %rcx
leaq 0x42c8(%rsp), %rdi
callq 0x13a70
jmp 0x25f46
movq 0x42e0(%rsp), %rdi
leaq 0x42c8(%rsp), %rsi
callq 0x19b70
leaq 0x42c8(%rsp), %rdi
callq 0x13110
leaq 0x42c7(%rsp), %rdi
callq 0x12ef0
movq 0x4308(%rsp), %rax
movq %rax, 0xe0(%rsp)
movl 0x42ec(%rsp), %eax
movl %eax, 0xec(%rsp)
movq 0x42e0(%rsp), %rax
movl 0x18(%rax), %eax
movl %eax, 0xf0(%rsp)
movq 0x42e0(%rsp), %rax
movl 0x1c(%rax), %eax
movl %eax, 0xf4(%rsp)
movq 0x4318(%rsp), %rdi
movl 0x42ec(%rsp), %esi
callq 0x1ec10
movq 0xe0(%rsp), %rdx
movl 0xec(%rsp), %ecx
movl 0xf0(%rsp), %r8d
movl 0xf4(%rsp), %r9d
movq %rax, %r10
movq 0x42e0(%rsp), %rax
movswl 0x20(%rax), %eax
movl $0x3, %edi
leaq 0x21bc1(%rip), %rsi     # 0x47bc6
movq %r10, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x3a770
movl 0x42f0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x42f0(%rsp)
jmp 0x2604d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x42b8(%rsp)
movl %eax, 0x42b4(%rsp)
leaq 0x42c7(%rsp), %rdi
callq 0x12ef0
jmp 0x27208
movq 0x42e0(%rsp), %rax
movswl 0x20(%rax), %eax
cmpl $0x0, %eax
jne 0x26074
movq 0x42e0(%rsp), %rax
movswl 0x22(%rax), %eax
cmpl $0x0, %eax
jne 0x26074
jmp 0x26276
movq 0x4330(%rsp), %rdi
callq 0x25360
movl %eax, %ecx
movq 0x42e0(%rsp), %rax
movl %ecx, 0x28(%rax)
movq 0x4330(%rsp), %rdi
callq 0x25a20
testb $0x1, %al
jne 0x260c1
cmpq $0x0, 0x4310(%rsp)
je 0x260ec
movq 0x4330(%rsp), %rdi
callq 0x25410
cmpq 0x4310(%rsp), %rax
jb 0x260ec
movq 0x4330(%rsp), %rdi
movq 0x42e0(%rsp), %rsi
movq 0x4310(%rsp), %rdx
callq 0x362c0
andb $0x1, %al
movb %al, 0x433f(%rsp)
jmp 0x271f3
movq 0x4308(%rsp), %rax
movq %rax, 0xc8(%rsp)
movb 0x42ff(%rsp), %dl
leaq 0x218a0(%rip), %rax     # 0x479aa
leaq 0x2279d(%rip), %rcx     # 0x488ae
testb $0x1, %dl
cmovneq %rcx, %rax
movq %rax, 0xd0(%rsp)
movl 0x42ec(%rsp), %eax
movl %eax, 0xd8(%rsp)
movq 0x42e0(%rsp), %rax
movl 0x18(%rax), %eax
movl %eax, 0xdc(%rsp)
movq 0x42e0(%rsp), %rax
movl 0x1c(%rax), %ebp
movq 0x4318(%rsp), %rdi
movl 0x42ec(%rsp), %esi
callq 0x1ec10
movq 0xc8(%rsp), %rdx
movq 0xd0(%rsp), %rcx
movl 0xd8(%rsp), %r8d
movl 0xdc(%rsp), %r9d
movq %rax, %r14
movq 0x42e0(%rsp), %rax
movswl 0x20(%rax), %ebx
movq 0x42e0(%rsp), %rax
movswl 0x22(%rax), %r11d
movq 0x42e0(%rsp), %rax
movl 0x28(%rax), %r10d
movl 0x42f8(%rsp), %eax
movl $0x3, %edi
leaq 0x21a4c(%rip), %rsi     # 0x47c06
movl %ebp, (%rsp)
movq %r14, 0x8(%rsp)
movl %ebx, 0x10(%rsp)
movl %r11d, 0x18(%rsp)
movl %r10d, 0x20(%rsp)
movl %eax, 0x28(%rsp)
movb $0x0, %al
callq 0x3a770
movq 0x42e0(%rsp), %rax
movl 0x2c(%rax), %edx
movq 0x42e0(%rsp), %rax
movl 0x30(%rax), %ecx
movq 0x42e0(%rsp), %rax
movl 0x34(%rax), %r8d
movq 0x42e0(%rsp), %rax
movl 0x38(%rax), %r9d
movl $0x6, %edi
leaq 0x21a4d(%rip), %rsi     # 0x47c62
movb $0x0, %al
callq 0x3a770
movl $0x3, %edi
leaq 0x22685(%rip), %rsi     # 0x488ad
movb $0x0, %al
callq 0x3a770
testb $0x1, 0x42ff(%rsp)
je 0x26274
movq 0x42e0(%rsp), %rax
movw 0x20(%rax), %cx
movq 0x42e0(%rsp), %rax
movw 0x22(%rax), %ax
movl 0x42f8(%rsp), %edx
movswl %cx, %edi
movswl %ax, %esi
callq 0x1eac0
testb $0x1, %al
jne 0x26274
movb $0x0, 0x433f(%rsp)
jmp 0x271f3
jmp 0x26276
movl 0x42ec(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x42ec(%rsp)
jmp 0x25dc6
movl 0x42f0(%rsp), %eax
cmpl 0x4300(%rsp), %eax
jle 0x262ba
movl 0x4300(%rsp), %ecx
movq 0x4320(%rsp), %rax
movl %ecx, (%rax)
movb $0x1, 0x433f(%rsp)
jmp 0x271f3
leaq 0x4298(%rsp), %rdi
movq %rdi, 0xc0(%rsp)
callq 0x2bb50
movq 0xc0(%rsp), %rdi
movq 0x4318(%rsp), %rsi
movq 0x4320(%rsp), %rax
movl (%rax), %edx
movl 0x4300(%rsp), %ecx
movq 0x4328(%rsp), %r8
callq 0x1cfa0
jmp 0x262ff
movl $0x800, 0x4294(%rsp) # imm = 0x800
cmpl $0x0, 0x42f8(%rsp)
jne 0x26455
testb $0x1, 0x42ff(%rsp)
je 0x26455
movq 0x4318(%rsp), %rdi
movslq 0x42f0(%rsp), %rsi
callq 0x4ba0
movq %rax, 0x4288(%rsp)
movq 0x4288(%rsp), %rax
movl 0x18(%rax), %ecx
movl 0x1c(%rax), %eax
imull %ecx, %eax
cltq
movq %rax, 0x4280(%rsp)
movq 0x4330(%rsp), %rdi
callq 0x25360
movl %eax, 0xbc(%rsp)
jmp 0x26374
movl 0xbc(%rsp), %eax
movl %eax, 0x427c(%rsp)
cmpl $0x1, 0x427c(%rsp)
jl 0x26396
cmpl $0x7f, 0x427c(%rsp)
jle 0x263f5
movq 0x4330(%rsp), %rdi
movq 0x4288(%rsp), %rsi
movq 0x4310(%rsp), %rdx
callq 0x362c0
movb %al, 0xbb(%rsp)
jmp 0x263bc
movb 0xbb(%rsp), %al
andb $0x1, %al
movb %al, 0x433f(%rsp)
movl $0x1, 0x4278(%rsp)
jmp 0x271d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x42b8(%rsp)
movl %eax, 0x42b4(%rsp)
jmp 0x271e4
movl 0x427c(%rsp), %eax
shll $0x5, %eax
movl %eax, 0x4294(%rsp)
movq 0x4280(%rsp), %rax
movslq 0x4294(%rsp), %rcx
imulq %rcx, %rax
shrq $0xc, %rax
movq %rax, 0x4270(%rsp)
movq 0x4270(%rsp), %rdx
movq 0x4280(%rsp), %rcx
movl 0x4294(%rsp), %r8d
leaq 0x2183a(%rip), %rsi     # 0x47c7f
xorl %eax, %eax
movl $0x5, %edi
callq 0x3a770
jmp 0x26453
jmp 0x26455
movq 0x4330(%rsp), %rsi
leaq 0x4258(%rsp), %rdi
callq 0x363d0
jmp 0x2646c
testb $0x1, 0x42ff(%rsp)
jne 0x266d1
leaq 0x4250(%rsp), %rdi
leaq 0x4258(%rsp), %rsi
callq 0x36400
jmp 0x26491
movq 0x4320(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x424c(%rsp)
movl 0x424c(%rsp), %eax
cmpl 0x4300(%rsp), %eax
jg 0x266a8
movq 0x4318(%rsp), %rdi
movslq 0x424c(%rsp), %rsi
callq 0x4ba0
movq %rax, 0x4240(%rsp)
movq 0x4240(%rsp), %rax
movswl 0x20(%rax), %eax
movq 0x4240(%rsp), %rcx
movswl 0x22(%rcx), %ecx
cmpl %ecx, %eax
jne 0x264f4
jmp 0x26692
movq 0x4240(%rsp), %rdi
callq 0x13af0
movq 0x4240(%rsp), %rdi
movl 0x18(%rdi), %esi
movl 0x1c(%rdi), %edx
callq 0x36420
jmp 0x26516
movl $0x0, 0x423c(%rsp)
movl 0x423c(%rsp), %eax
movq 0x4240(%rsp), %rcx
cmpl 0x1c(%rcx), %eax
jge 0x26649
movq 0x4330(%rsp), %rdi
callq 0x25a20
testb $0x1, %al
jne 0x2657e
cmpq $0x0, 0x4310(%rsp)
je 0x2659f
movq 0x4330(%rsp), %rdi
callq 0x25410
movq %rax, 0xb0(%rsp)
jmp 0x2656c
movq 0xb0(%rsp), %rax
cmpq 0x4310(%rsp), %rax
jb 0x2659f
movl 0x423c(%rsp), %edx
leaq 0x2172c(%rip), %rsi     # 0x47cb8
xorl %eax, %eax
movl $0x3, %edi
callq 0x3a770
jmp 0x2659a
jmp 0x26649
movl $0x0, 0x4238(%rsp)
movl 0x4238(%rsp), %eax
movq 0x4240(%rsp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x26631
movq 0x4240(%rsp), %rax
movswl 0x20(%rax), %esi
movswl 0x22(%rax), %edx
subl %esi, %edx
leaq 0x4250(%rsp), %rdi
callq 0x36450
movl %eax, 0xac(%rsp)
jmp 0x265e6
movl 0xac(%rsp), %eax
movw %ax, 0xaa(%rsp)
movq 0x4240(%rsp), %rdi
movl 0x423c(%rsp), %esi
movl 0x4238(%rsp), %edx
callq 0x12110
movw 0xaa(%rsp), %cx
movw %cx, (%rax)
movl 0x4238(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4238(%rsp)
jmp 0x265aa
jmp 0x26633
movl 0x423c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x423c(%rsp)
jmp 0x26521
movq 0x4330(%rsp), %rdi
callq 0x25a20
testb $0x1, %al
jne 0x2668e
cmpq $0x0, 0x4310(%rsp)
je 0x26690
movq 0x4330(%rsp), %rdi
callq 0x25410
movq %rax, 0xa0(%rsp)
jmp 0x2667c
movq 0xa0(%rsp), %rax
cmpq 0x4310(%rsp), %rax
jb 0x26690
jmp 0x266a8
jmp 0x26692
movl 0x424c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x424c(%rsp)
jmp 0x264a2
movl 0x4300(%rsp), %ecx
movq 0x4320(%rsp), %rax
movl %ecx, (%rax)
movb $0x1, 0x433f(%rsp)
movl $0x1, 0x4278(%rsp)
jmp 0x271d5
leaq 0x4220(%rsp), %rdi
callq 0x20d80
jmp 0x266e0
leaq 0x41e8(%rsp), %rdi
leaq 0x4258(%rsp), %rsi
leaq 0x4298(%rsp), %rdx
movl $0x2, %ecx
movl $0xd79435e, %r8d        # imm = 0xD79435E
callq 0x364f0
jmp 0x2670a
leaq 0x41e8(%rsp), %rdi
leaq 0x4220(%rsp), %rsi
callq 0x36620
movb %al, 0x9f(%rsp)
jmp 0x26728
movb 0x9f(%rsp), %al
testb $0x1, %al
jne 0x267d4
jmp 0x26739
movq 0x4330(%rsp), %rax
movq %rax, 0x90(%rsp)
movq 0x4318(%rsp), %rdi
movq 0x4320(%rsp), %rax
movslq (%rax), %rsi
callq 0x4ba0
movq 0x90(%rsp), %rdi
movq %rax, %rsi
movq 0x4310(%rsp), %rdx
callq 0x362c0
movb %al, 0x9e(%rsp)
jmp 0x26782
movb 0x9e(%rsp), %al
andb $0x1, %al
movb %al, 0x433f(%rsp)
movl $0x1, 0x4278(%rsp)
jmp 0x2719d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x42b8(%rsp)
movl %eax, 0x42b4(%rsp)
jmp 0x271c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x42b8(%rsp)
movl %eax, 0x42b4(%rsp)
jmp 0x271b9
movzwl 0x4294(%rsp), %r8d
movq 0x4328(%rsp), %rax
movl 0x14(%rax), %ecx
movl 0x18(%rax), %edx
movq %rsp, %rax
movl %edx, 0x8(%rax)
movl %ecx, (%rax)
leaq 0x1b0(%rsp), %rdi
leaq 0x4258(%rsp), %rsi
leaq 0x4298(%rsp), %rdx
leaq 0x4220(%rsp), %rcx
movl $0x15550, %r9d          # imm = 0x15550
callq 0x36750
jmp 0x26820
leaq 0x4298(%rsp), %rdi
callq 0x13400
movq %rax, 0x80(%rsp)
leaq 0x197(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x12430
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
leaq 0x198(%rsp), %rdi
callq 0x12440
jmp 0x26869
leaq 0x197(%rsp), %rdi
callq 0x4e10
movq 0x4320(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x190(%rsp)
movl 0x190(%rsp), %eax
cmpl 0x4300(%rsp), %eax
jg 0x27141
movq 0x4318(%rsp), %rdi
movslq 0x190(%rsp), %rsi
callq 0x4ba0
movq %rax, 0x188(%rsp)
movq 0x188(%rsp), %rax
movswl 0x20(%rax), %eax
movq 0x188(%rsp), %rcx
movswl 0x22(%rcx), %ecx
cmpl %ecx, %eax
jne 0x268ff
jmp 0x2712b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x42b8(%rsp)
movl %eax, 0x42b4(%rsp)
leaq 0x197(%rsp), %rdi
callq 0x4e10
jmp 0x2718e
movq 0x188(%rsp), %rdi
callq 0x13af0
movq 0x188(%rsp), %rdi
movl 0x18(%rdi), %esi
movl 0x1c(%rdi), %edx
callq 0x36420
jmp 0x26921
leaq 0x4220(%rsp), %rdi
callq 0x30b30
cmpq $0x1, %rax
jne 0x26aca
cmpl $0x0, 0x42f8(%rsp)
jne 0x26aca
movq 0x188(%rsp), %rax
movswl 0x24(%rax), %eax
cmpl $0x0, %eax
jne 0x26aca
leaq 0x21378(%rip), %rsi     # 0x47cda
xorl %eax, %eax
movl $0x5, %edi
callq 0x3a770
jmp 0x26970
movl $0x0, 0x184(%rsp)
movl 0x184(%rsp), %eax
movq 0x188(%rsp), %rcx
cmpl 0x1c(%rcx), %eax
jge 0x26ac5
movq 0x4330(%rsp), %rdi
callq 0x25a20
testb $0x1, %al
jne 0x269d2
cmpq $0x0, 0x4310(%rsp)
je 0x26a24
movq 0x4330(%rsp), %rdi
callq 0x25410
movq %rax, 0x78(%rsp)
jmp 0x269c3
movq 0x78(%rsp), %rax
cmpq 0x4310(%rsp), %rax
jb 0x26a24
movl 0x184(%rsp), %edx
movl 0x190(%rsp), %ecx
leaq 0x21300(%rip), %rsi     # 0x47ce7
xorl %eax, %eax
movl $0x3, %edi
callq 0x3a770
jmp 0x269f5
movl 0x190(%rsp), %ecx
movq 0x4320(%rsp), %rax
movl %ecx, (%rax)
jmp 0x26ac5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x42b8(%rsp)
movl %eax, 0x42b4(%rsp)
jmp 0x27181
movl $0x0, 0x180(%rsp)
movl 0x180(%rsp), %eax
movq 0x188(%rsp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x26aad
movq 0x188(%rsp), %rax
movswl 0x20(%rax), %edx
movswl 0x22(%rax), %ecx
leaq 0x1b0(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x36930
movl %eax, 0x74(%rsp)
jmp 0x26a6e
movl 0x74(%rsp), %eax
movw %ax, 0x72(%rsp)
movq 0x188(%rsp), %rdi
movl 0x184(%rsp), %esi
movl 0x180(%rsp), %edx
callq 0x12110
movw 0x72(%rsp), %cx
movw %cx, (%rax)
movl 0x180(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x180(%rsp)
jmp 0x26a2f
jmp 0x26aaf
movl 0x184(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x184(%rsp)
jmp 0x2697b
jmp 0x270e8
leaq 0x21246(%rip), %rsi     # 0x47d17
xorl %eax, %eax
movl $0x5, %edi
callq 0x3a770
jmp 0x26adf
leaq 0x198(%rsp), %rdi
callq 0x4d50
movl %eax, %esi
addl $-0xd, %esi
movq 0x188(%rsp), %rax
movl 0x18(%rax), %edx
movq %rsp, %rax
movl $0x0, 0x18(%rax)
movl $0x0, 0x10(%rax)
movl $0x0, 0x8(%rax)
movl $0x0, (%rax)
leaq 0x140(%rsp), %rdi
xorl %r8d, %r8d
movl $0x1, %r9d
movl %r8d, %ecx
callq 0x12200
jmp 0x26b35
movl $0x0, 0x13c(%rsp)
movl 0x13c(%rsp), %eax
movq 0x188(%rsp), %rcx
cmpl 0x1c(%rcx), %eax
jge 0x270db
movq 0x4330(%rsp), %rdi
callq 0x25a20
testb $0x1, %al
jne 0x26b9b
cmpq $0x0, 0x4310(%rsp)
je 0x26bfa
movq 0x4330(%rsp), %rdi
callq 0x25410
movq %rax, 0x68(%rsp)
jmp 0x26b8c
movq 0x68(%rsp), %rax
cmpq 0x4310(%rsp), %rax
jb 0x26bfa
movl 0x13c(%rsp), %edx
movl 0x190(%rsp), %ecx
leaq 0x21137(%rip), %rsi     # 0x47ce7
xorl %eax, %eax
movl $0x3, %edi
callq 0x3a770
jmp 0x26bbe
movl 0x190(%rsp), %ecx
movq 0x4320(%rsp), %rax
movl %ecx, (%rax)
jmp 0x270db
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x42b8(%rsp)
movl %eax, 0x42b4(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x12380
jmp 0x27181
movq 0x188(%rsp), %rdi
movl 0x13c(%rsp), %esi
movq 0x4318(%rsp), %rdx
movq 0x4320(%rsp), %rax
movl (%rax), %ecx
movq 0x4328(%rsp), %r8
leaq 0x140(%rsp), %r9
callq 0x1e370
jmp 0x26c32
cmpl $0x1, 0x13c(%rsp)
jle 0x26c4a
cmpl $0x0, 0x42f8(%rsp)
je 0x26d73
movl $0x0, 0x138(%rsp)
movl 0x138(%rsp), %eax
movq 0x188(%rsp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x26d6e
movq 0x188(%rsp), %rsi
movl 0x138(%rsp), %edx
movl 0x13c(%rsp), %ecx
movl 0x42f8(%rsp), %r8d
movq 0x4318(%rsp), %r9
movq 0x4320(%rsp), %rax
movl (%rax), %edi
movq 0x4328(%rsp), %r10
movq %rsp, %rax
leaq 0x140(%rsp), %r11
movq %r11, 0x10(%rax)
movq %r10, 0x8(%rax)
movl %edi, (%rax)
leaq 0x198(%rsp), %rdi
callq 0x2c240
movw %ax, 0x66(%rsp)
jmp 0x26cce
movw 0x66(%rsp), %ax
movw %ax, 0x136(%rsp)
movq 0x188(%rsp), %rcx
movswl 0x20(%rcx), %edx
movswl 0x136(%rsp), %eax
subl %eax, %edx
movswl 0x22(%rcx), %ecx
subl %eax, %ecx
leaq 0x1b0(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x36930
movl %eax, 0x60(%rsp)
jmp 0x26d12
movl 0x60(%rsp), %eax
movw %ax, 0x134(%rsp)
movswl 0x134(%rsp), %eax
movswl 0x136(%rsp), %ecx
addl %ecx, %eax
movw %ax, 0x5e(%rsp)
movq 0x188(%rsp), %rdi
movl 0x13c(%rsp), %esi
movl 0x138(%rsp), %edx
callq 0x12110
movw 0x5e(%rsp), %cx
movw %cx, (%rax)
movl 0x138(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x138(%rsp)
jmp 0x26c55
jmp 0x270c3
movl $0x0, 0x130(%rsp)
movl 0x130(%rsp), %ecx
movq 0x188(%rsp), %rdx
xorl %eax, %eax
cmpl 0x18(%rdx), %ecx
movb %al, 0x5d(%rsp)
jge 0x26da7
cmpl $0x2, 0x130(%rsp)
setl %al
movb %al, 0x5d(%rsp)
movb 0x5d(%rsp), %al
testb $0x1, %al
jne 0x26db4
jmp 0x26eb5
movq 0x188(%rsp), %rsi
movl 0x130(%rsp), %edx
movl 0x13c(%rsp), %ecx
movl 0x42f8(%rsp), %r8d
movq 0x4318(%rsp), %r9
movq 0x4320(%rsp), %rax
movl (%rax), %edi
movq 0x4328(%rsp), %r10
movq %rsp, %rax
leaq 0x140(%rsp), %r11
movq %r11, 0x10(%rax)
movq %r10, 0x8(%rax)
movl %edi, (%rax)
leaq 0x198(%rsp), %rdi
callq 0x2c240
movw %ax, 0x5a(%rsp)
jmp 0x26e15
movw 0x5a(%rsp), %ax
movw %ax, 0x12e(%rsp)
movq 0x188(%rsp), %rcx
movswl 0x20(%rcx), %edx
movswl 0x12e(%rsp), %eax
subl %eax, %edx
movswl 0x22(%rcx), %ecx
subl %eax, %ecx
leaq 0x1b0(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x36930
movl %eax, 0x54(%rsp)
jmp 0x26e59
movl 0x54(%rsp), %eax
movw %ax, 0x12c(%rsp)
movswl 0x12c(%rsp), %eax
movswl 0x12e(%rsp), %ecx
addl %ecx, %eax
movw %ax, 0x52(%rsp)
movq 0x188(%rsp), %rdi
movl 0x13c(%rsp), %esi
movl 0x130(%rsp), %edx
callq 0x12110
movw 0x52(%rsp), %cx
movw %cx, (%rax)
movl 0x130(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x130(%rsp)
jmp 0x26d7e
jmp 0x26eb7
movl 0x130(%rsp), %eax
movq 0x188(%rsp), %rcx
movl 0x18(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x26fa6
movq 0x188(%rsp), %rsi
movl 0x130(%rsp), %edx
movl 0x13c(%rsp), %ecx
leaq 0x198(%rsp), %rdi
leaq 0x140(%rsp), %r8
callq 0x369a0
movw %ax, 0x50(%rsp)
jmp 0x26f06
movw 0x50(%rsp), %ax
movw %ax, 0x12e(%rsp)
movq 0x188(%rsp), %rcx
movswl 0x20(%rcx), %edx
movswl 0x12e(%rsp), %eax
subl %eax, %edx
movswl 0x22(%rcx), %ecx
subl %eax, %ecx
leaq 0x1b0(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x36930
movl %eax, 0x4c(%rsp)
jmp 0x26f4a
movl 0x4c(%rsp), %eax
movw %ax, 0x12c(%rsp)
movswl 0x12c(%rsp), %eax
movswl 0x12e(%rsp), %ecx
addl %ecx, %eax
movw %ax, 0x4a(%rsp)
movq 0x188(%rsp), %rdi
movl 0x13c(%rsp), %esi
movl 0x130(%rsp), %edx
callq 0x12110
movw 0x4a(%rsp), %cx
movw %cx, (%rax)
movl 0x130(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x130(%rsp)
jmp 0x26eb7
jmp 0x26fa8
movl 0x130(%rsp), %eax
movq 0x188(%rsp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x270c1
movq 0x188(%rsp), %rsi
movl 0x130(%rsp), %edx
movl 0x13c(%rsp), %ecx
movl 0x42f8(%rsp), %r8d
movq 0x4318(%rsp), %r9
movq 0x4320(%rsp), %rax
movl (%rax), %edi
movq 0x4328(%rsp), %r10
movq %rsp, %rax
leaq 0x140(%rsp), %r11
movq %r11, 0x10(%rax)
movq %r10, 0x8(%rax)
movl %edi, (%rax)
leaq 0x198(%rsp), %rdi
callq 0x2c240
movw %ax, 0x48(%rsp)
jmp 0x27021
movw 0x48(%rsp), %ax
movw %ax, 0x12e(%rsp)
movq 0x188(%rsp), %rcx
movswl 0x20(%rcx), %edx
movswl 0x12e(%rsp), %eax
subl %eax, %edx
movswl 0x22(%rcx), %ecx
subl %eax, %ecx
leaq 0x1b0(%rsp), %rdi
leaq 0x198(%rsp), %rsi
callq 0x36930
movl %eax, 0x44(%rsp)
jmp 0x27065
movl 0x44(%rsp), %eax
movw %ax, 0x12c(%rsp)
movswl 0x12c(%rsp), %eax
movswl 0x12e(%rsp), %ecx
addl %ecx, %eax
movw %ax, 0x42(%rsp)
movq 0x188(%rsp), %rdi
movl 0x13c(%rsp), %esi
movl 0x130(%rsp), %edx
callq 0x12110
movw 0x42(%rsp), %cx
movw %cx, (%rax)
movl 0x130(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x130(%rsp)
jmp 0x26fa8
jmp 0x270c3
jmp 0x270c5
movl 0x13c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x13c(%rsp)
jmp 0x26b40
leaq 0x140(%rsp), %rdi
callq 0x12380
movq 0x4330(%rsp), %rdi
callq 0x25a20
testb $0x1, %al
jne 0x27127
cmpq $0x0, 0x4310(%rsp)
je 0x27129
movq 0x4330(%rsp), %rdi
callq 0x25410
movq %rax, 0x38(%rsp)
jmp 0x27118
movq 0x38(%rsp), %rax
cmpq 0x4310(%rsp), %rax
jb 0x27129
jmp 0x27141
jmp 0x2712b
movl 0x190(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x190(%rsp)
jmp 0x26887
movl 0x4300(%rsp), %ecx
movq 0x4320(%rsp), %rax
movl %ecx, (%rax)
movb $0x1, 0x433f(%rsp)
movl $0x1, 0x4278(%rsp)
leaq 0x198(%rsp), %rdi
callq 0x54f0
leaq 0x1b0(%rsp), %rdi
callq 0x36a70
jmp 0x2719d
leaq 0x198(%rsp), %rdi
callq 0x54f0
leaq 0x1b0(%rsp), %rdi
callq 0x36a70
jmp 0x271b9
leaq 0x41e8(%rsp), %rdi
callq 0x36a90
leaq 0x4220(%rsp), %rdi
callq 0x22e10
jmp 0x271d5
leaq 0x41e8(%rsp), %rdi
callq 0x36a90
leaq 0x4220(%rsp), %rdi
callq 0x22e10
jmp 0x271e4
leaq 0x4298(%rsp), %rdi
callq 0x134e0
jmp 0x271f3
leaq 0x4298(%rsp), %rdi
callq 0x134e0
jmp 0x27208
movb 0x433f(%rsp), %al
andb $0x1, %al
addq $0x4340, %rsp           # imm = 0x4340
popq %rbx
popq %r14
popq %rbp
retq
movq 0x42b8(%rsp), %rdi
callq 0x36a0
nopw %cs:(%rax,%rax)
nop