// File: cloudinary[P]fuif/encoding/encoding.cpp
// Function: bool fuif_encode_channels<BlobIO, RacOutput24<BlobIO>, FinalPropertySymbolCoder<SimpleBitChance, RacOutput24<BlobIO>, 15>, false, true>(BlobIO&, Tree&, fuif_options&, int, int, int, Image const&, unsigned long&)
bool fuif_encode_channels(IO& io, Tree &tree, fuif_options &options, int predictor, int beginc, int endc, const Image &image, size_t &header_pos) {
  assert(endc >= beginc);
  write_big_endian_varint(io, ((endc-beginc) << 4) + (predictor << 1) + (compress?1:0));
  if (endc>beginc) v_printf(5,"Encoding%s channels %i-%i\n", (compress?"":" uncompressed"), beginc, endc);

  pixel_type global_minv=LARGEST_VAL;
  pixel_type global_maxv=SMALLEST_VAL;
  for (int i=beginc; i<=endc; i++) {
    const Channel &channel = image.channel[i];
    if (channel.w * channel.h <= 0) continue; // zero pixel channel? could happen
    pixel_type minv = channel.minval;
    pixel_type maxv = channel.maxval;
    if (minv<global_minv) global_minv=minv;
    if (maxv>global_maxv) global_maxv=maxv;
  }
  if (global_minv <= 0) {
    write_big_endian_varint(io, 1-global_minv);
  } else {
    write_big_endian_varint(io, 0);
    write_big_endian_varint(io, global_minv);
  }
  write_big_endian_varint(io, global_maxv-global_minv);


  int firstrealc = beginc;
  for (int i=beginc; i<=endc; i++) {
    const Channel &channel = image.channel[i];
    if (channel.w * channel.h <= 0) continue; // zero pixel channel? could happen

    pixel_type minv = channel.minval;
    pixel_type maxv = channel.maxval;

    if (endc > beginc && global_minv < global_maxv) {
      write_big_endian_varint(io, minv-global_minv);
      write_big_endian_varint(io, maxv-minv);
    }
    if (minv == maxv) { firstrealc++; }

    if (!check_bit_depth(minv,maxv,predictor)) return false;

    if (minv == 0 && maxv == 0) continue; // don't need quantization factor if it's all zeroes anyway

    write_big_endian_varint(io, channel.q);

    if (!learn) v_printf(6,"Encoding %ix%i channel %i with range %i..%i (predictor %i, quantization %i), (shift=%i,%i, cshift=%i,%i)\n", channel.w, channel.h, i, minv, maxv, predictor, channel.q, channel.hshift, channel.vshift, channel.hcshift, channel.vcshift);
    else  v_printf(7,"Learning %ix%i channel %i with range %i..%i (predictor %i)\n", channel.w, channel.h, i, minv, maxv, predictor);

    channel.setzero();
  }

  header_pos = io.ftell();

  if (firstrealc > endc) return true; // all trivial


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

  int predictability = 2048; // 50%
  {
    const Channel &channel = image.channel[firstrealc];
    if (predictor == 0 && compress) {
        uint64_t zeroes = 0;
        uint64_t pixels = channel.h*channel.w;
        for (int y=0; y<channel.h; y++)
          for (int x=0; x<channel.w; x++)
            if ( channel.value(y,x) == 0) zeroes++;
        int rounded = zeroes * 128 / pixels;
        if (rounded < 1) rounded = 1;
        if (rounded > 127) rounded = 127;
        write_big_endian_varint(io, rounded);
        predictability = rounded * 32;
        v_printf(5,"Found %i zeroes in %i pixels (zero chance=%i/4096)\n",zeroes,pixels,predictability);
    }
  }

  Rac rac(io);

  if (!compress) {
    UniformSymbolCoder<Rac> coder(rac);
    for (int i=beginc; i<=endc; i++) {
        const Channel &channel = image.channel[i];
        for (int y=0; y<channel.h; y++) {
            for (int x=0; x<channel.w; x++) {
                coder.write_int(channel.minval,channel.maxval,channel.value(y,x)); // TODO: use predictor? (only makes sense if the predictor residues have a smaller range)
                if (!learn && options.debug)
                    options.heatmap.channel[i].value(y,x) = (x);
            }
        }
    }
  } else {
    if (!learn) {
        // encode tree here
        MetaPropertySymbolCoder<FUIFBitChanceTree, Rac> metacoder(rac, propRanges);
        metacoder.write_tree(tree);
    }
    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++) {
        const Channel &channel = image.channel[i];
        pixel_type minv = channel.minval;
        pixel_type maxv = channel.maxval;
        if (minv==maxv) continue;
        int rowslearned=0;
        Channel references(properties.size() - NB_NONREF_PROPERTIES, channel.w, 0, 0);
        for (int y=0; y<channel.h; y++) {
            if (learn) { if (++rowslearned > options.nb_repeats*channel.h) break; }
            if (learn) y=rand()%channel.h; // try random rows, to avoid giving priority to the top of the image (because then the y property cannot be learned)
            precompute_references(channel, y, image, beginc, options, references);
            for (int x=0; x<channel.w; x++) {
                pixel_type guess;
        //        guess = predict_and_compute_properties_with_reference(properties, channel, x, y, predictor, image, beginc, options);
                guess = predict_and_compute_properties_with_precomputed_reference(properties, channel, x, y, predictor, image, beginc, options, references);
                pixel_type diff = channel.value(y,x)-guess;
                if (!learn && options.debug) {
                    int estimate = coder.estimate_int(properties, minv-guess, maxv-guess, diff);
                    options.heatmap.channel[i].value(y,x) = estimate;
                }
                coder.write_int(properties, minv-guess, maxv-guess, diff);
            }
            if (learn) { y=0; } // set to zero in case random row was channel.h-1
        }
    }
    coder.simplify();
  }

  rac.flush();
  io.flush();
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x4228, %rsp           # imm = 0x4228
movq 0x4258(%rsp), %rax
movq 0x4250(%rsp), %rax
movq %rdi, 0x4218(%rsp)
movq %rsi, 0x4210(%rsp)
movq %rdx, 0x4208(%rsp)
movl %ecx, 0x4204(%rsp)
movl %r8d, 0x4200(%rsp)
movl %r9d, 0x41fc(%rsp)
movq 0x4218(%rsp), %rdi
movl 0x41fc(%rsp), %eax
subl 0x4200(%rsp), %eax
shll $0x4, %eax
movl 0x4204(%rsp), %ecx
shll %ecx
addl %ecx, %eax
addl $0x1, %eax
movslq %eax, %rsi
movl $0x1, %edx
callq 0x20c60
movl 0x41fc(%rsp), %eax
cmpl 0x4200(%rsp), %eax
jle 0x22269
movl 0x4200(%rsp), %ecx
movl 0x41fc(%rsp), %r8d
movl $0x5, %edi
leaq 0x25734(%rip), %rsi     # 0x4798f
leaq 0x2664c(%rip), %rdx     # 0x488ae
movb $0x0, %al
callq 0x3a770
movw $0x7fff, 0x41fa(%rsp)   # imm = 0x7FFF
movw $0x8001, 0x41f8(%rsp)   # imm = 0x8001
movl 0x4200(%rsp), %eax
movl %eax, 0x41f4(%rsp)
movl 0x41f4(%rsp), %eax
cmpl 0x41fc(%rsp), %eax
jg 0x22362
movq 0x4250(%rsp), %rdi
movslq 0x41f4(%rsp), %rsi
callq 0x13390
movq %rax, 0x41e8(%rsp)
movq 0x41e8(%rsp), %rax
movl 0x18(%rax), %eax
movq 0x41e8(%rsp), %rcx
imull 0x1c(%rcx), %eax
cmpl $0x0, %eax
jg 0x222da
jmp 0x2234c
movq 0x41e8(%rsp), %rax
movw 0x20(%rax), %ax
movw %ax, 0x41e6(%rsp)
movq 0x41e8(%rsp), %rax
movw 0x22(%rax), %ax
movw %ax, 0x41e4(%rsp)
movswl 0x41e6(%rsp), %eax
movswl 0x41fa(%rsp), %ecx
cmpl %ecx, %eax
jge 0x22326
movw 0x41e6(%rsp), %ax
movw %ax, 0x41fa(%rsp)
movswl 0x41e4(%rsp), %eax
movswl 0x41f8(%rsp), %ecx
cmpl %ecx, %eax
jle 0x2234a
movw 0x41e4(%rsp), %ax
movw %ax, 0x41f8(%rsp)
jmp 0x2234c
movl 0x41f4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x41f4(%rsp)
jmp 0x2228b
movswl 0x41fa(%rsp), %eax
cmpl $0x0, %eax
jg 0x22395
movq 0x4218(%rsp), %rdi
movswl 0x41fa(%rsp), %ecx
movl $0x1, %eax
subl %ecx, %eax
movslq %eax, %rsi
movl $0x1, %edx
callq 0x20c60
jmp 0x223c6
movq 0x4218(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %edx
callq 0x20c60
movq 0x4218(%rsp), %rdi
movswq 0x41fa(%rsp), %rsi
movl $0x1, %edx
callq 0x20c60
movq 0x4218(%rsp), %rdi
movswl 0x41f8(%rsp), %eax
movswl 0x41fa(%rsp), %ecx
subl %ecx, %eax
movslq %eax, %rsi
movl $0x1, %edx
callq 0x20c60
movl 0x4200(%rsp), %eax
movl %eax, 0x41e0(%rsp)
movl 0x4200(%rsp), %eax
movl %eax, 0x41dc(%rsp)
movl 0x41dc(%rsp), %eax
cmpl 0x41fc(%rsp), %eax
jg 0x22650
movq 0x4250(%rsp), %rdi
movslq 0x41dc(%rsp), %rsi
callq 0x13390
movq %rax, 0x41d0(%rsp)
movq 0x41d0(%rsp), %rax
movl 0x18(%rax), %eax
movq 0x41d0(%rsp), %rcx
imull 0x1c(%rcx), %eax
cmpl $0x0, %eax
jg 0x2245b
jmp 0x2263a
movq 0x41d0(%rsp), %rax
movw 0x20(%rax), %ax
movw %ax, 0x41ce(%rsp)
movq 0x41d0(%rsp), %rax
movw 0x22(%rax), %ax
movw %ax, 0x41cc(%rsp)
movl 0x41fc(%rsp), %eax
cmpl 0x4200(%rsp), %eax
jle 0x224f5
movswl 0x41fa(%rsp), %eax
movswl 0x41f8(%rsp), %ecx
cmpl %ecx, %eax
jge 0x224f5
movq 0x4218(%rsp), %rdi
movswl 0x41ce(%rsp), %eax
movswl 0x41fa(%rsp), %ecx
subl %ecx, %eax
movslq %eax, %rsi
movl $0x1, %edx
callq 0x20c60
movq 0x4218(%rsp), %rdi
movswl 0x41cc(%rsp), %eax
movswl 0x41ce(%rsp), %ecx
subl %ecx, %eax
movslq %eax, %rsi
movl $0x1, %edx
callq 0x20c60
movswl 0x41ce(%rsp), %eax
movswl 0x41cc(%rsp), %ecx
cmpl %ecx, %eax
jne 0x2251a
movl 0x41e0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x41e0(%rsp)
movw 0x41ce(%rsp), %cx
movw 0x41cc(%rsp), %ax
movl 0x4204(%rsp), %edx
movswl %cx, %edi
movswl %ax, %esi
callq 0x1eac0
testb $0x1, %al
jne 0x2254d
movb $0x0, 0x4227(%rsp)
jmp 0x22d61
movswl 0x41ce(%rsp), %eax
cmpl $0x0, %eax
jne 0x2256c
movswl 0x41cc(%rsp), %eax
cmpl $0x0, %eax
jne 0x2256c
jmp 0x2263a
movq 0x4218(%rsp), %rdi
movq 0x41d0(%rsp), %rax
movslq 0x28(%rax), %rsi
movl $0x1, %edx
callq 0x20c60
movq 0x41d0(%rsp), %rax
movl 0x18(%rax), %edx
movq 0x41d0(%rsp), %rax
movl 0x1c(%rax), %ecx
movl 0x41dc(%rsp), %r8d
movswl 0x41ce(%rsp), %r9d
movswl 0x41cc(%rsp), %r15d
movl 0x4204(%rsp), %r14d
movq 0x41d0(%rsp), %rax
movl 0x28(%rax), %ebp
movq 0x41d0(%rsp), %rax
movl 0x2c(%rax), %ebx
movq 0x41d0(%rsp), %rax
movl 0x30(%rax), %r11d
movq 0x41d0(%rsp), %rax
movl 0x34(%rax), %r10d
movq 0x41d0(%rsp), %rax
movl 0x38(%rax), %eax
movl $0x6, %edi
leaq 0x253b1(%rip), %rsi     # 0x479b8
movl %r15d, (%rsp)
movl %r14d, 0x8(%rsp)
movl %ebp, 0x10(%rsp)
movl %ebx, 0x18(%rsp)
movl %r11d, 0x20(%rsp)
movl %r10d, 0x28(%rsp)
movl %eax, 0x30(%rsp)
movb $0x0, %al
callq 0x3a770
movq 0x41d0(%rsp), %rdi
callq 0x13af0
movl 0x41dc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x41dc(%rsp)
jmp 0x22409
movq 0x4218(%rsp), %rdi
callq 0x221a0
movslq %eax, %rcx
movq 0x4258(%rsp), %rax
movq %rcx, (%rax)
movl 0x41e0(%rsp), %eax
cmpl 0x41fc(%rsp), %eax
jle 0x22688
movb $0x1, 0x4227(%rsp)
jmp 0x22d61
leaq 0x41b0(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x2bb50
movq 0x60(%rsp), %rdi
movq 0x4250(%rsp), %rsi
movl 0x4200(%rsp), %edx
movl 0x41fc(%rsp), %ecx
movq 0x4208(%rsp), %r8
callq 0x1cfa0
jmp 0x226c4
movl $0x800, 0x41a0(%rsp) # imm = 0x800
movq 0x4250(%rsp), %rdi
movslq 0x41e0(%rsp), %rsi
callq 0x13390
movq %rax, 0x4198(%rsp)
cmpl $0x0, 0x4204(%rsp)
jne 0x2288b
movq $0x0, 0x4190(%rsp)
movq 0x4198(%rsp), %rax
movl 0x1c(%rax), %eax
movq 0x4198(%rsp), %rcx
imull 0x18(%rcx), %eax
cltq
movq %rax, 0x4188(%rsp)
movl $0x0, 0x4184(%rsp)
movl 0x4184(%rsp), %eax
movq 0x4198(%rsp), %rcx
cmpl 0x1c(%rcx), %eax
jge 0x227e6
movl $0x0, 0x4180(%rsp)
movl 0x4180(%rsp), %eax
movq 0x4198(%rsp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x227ce
movq 0x4198(%rsp), %rdi
movl 0x4184(%rsp), %esi
movl 0x4180(%rsp), %edx
callq 0x12ba0
cwtl
cmpl $0x0, %eax
jne 0x227b9
movq 0x4190(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x4190(%rsp)
jmp 0x227b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x41a8(%rsp)
movl %eax, 0x41a4(%rsp)
jmp 0x22d52
jmp 0x227bb
movl 0x4180(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4180(%rsp)
jmp 0x22755
jmp 0x227d0
movl 0x4184(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4184(%rsp)
jmp 0x22732
movq 0x4190(%rsp), %rax
shlq $0x7, %rax
xorl %ecx, %ecx
movl %ecx, %edx
divq 0x4188(%rsp)
movl %eax, 0x417c(%rsp)
cmpl $0x1, 0x417c(%rsp)
jge 0x2281a
movl $0x1, 0x417c(%rsp)
cmpl $0x7f, 0x417c(%rsp)
jle 0x2282f
movl $0x7f, 0x417c(%rsp)
movq 0x4218(%rsp), %rdi
movslq 0x417c(%rsp), %rsi
movl $0x1, %edx
callq 0x20c60
jmp 0x2284b
movl 0x417c(%rsp), %eax
shll $0x5, %eax
movl %eax, 0x41a0(%rsp)
movq 0x4190(%rsp), %rdx
movq 0x4188(%rsp), %rcx
movl 0x41a0(%rsp), %r8d
leaq 0x251a7(%rip), %rsi     # 0x47a22
xorl %eax, %eax
movl $0x5, %edi
callq 0x3a770
jmp 0x22889
jmp 0x2288b
movq 0x4218(%rsp), %rsi
leaq 0x4158(%rsp), %rdi
callq 0x2bb60
jmp 0x228a2
leaq 0x4120(%rsp), %rdi
leaq 0x4158(%rsp), %rsi
leaq 0x41b0(%rsp), %rdx
movl $0x2, %ecx
movl $0xd79435e, %r8d        # imm = 0xD79435E
callq 0x339d0
jmp 0x228cc
movq 0x4210(%rsp), %rsi
leaq 0x4120(%rsp), %rdi
callq 0x33b00
jmp 0x228e3
leaq 0x4120(%rsp), %rdi
callq 0x33b80
movq 0x4210(%rsp), %rcx
movzwl 0x41a0(%rsp), %r8d
movq 0x4208(%rsp), %rax
movl 0x14(%rax), %edx
movl 0x18(%rax), %esi
movq %rsp, %rax
movl %esi, 0x8(%rax)
movl %edx, (%rax)
leaq 0xe8(%rsp), %rdi
leaq 0x4158(%rsp), %rsi
leaq 0x41b0(%rsp), %rdx
movl $0x15550, %r9d          # imm = 0x15550
callq 0x33bb0
jmp 0x2293c
leaq 0x41b0(%rsp), %rdi
callq 0x13400
movq %rax, 0x50(%rsp)
leaq 0xcf(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x12430
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
leaq 0xd0(%rsp), %rdi
callq 0x12440
jmp 0x22979
leaq 0xcf(%rsp), %rdi
callq 0x4e10
movl 0x4200(%rsp), %eax
movl %eax, 0xc8(%rsp)
movl 0xc8(%rsp), %eax
cmpl 0x41fc(%rsp), %eax
jg 0x22ce0
movq 0x4250(%rsp), %rdi
movslq 0xc8(%rsp), %rsi
callq 0x13390
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
movw 0x20(%rax), %ax
movw %ax, 0xbe(%rsp)
movq 0xc0(%rsp), %rax
movw 0x22(%rax), %ax
movw %ax, 0xbc(%rsp)
movswl 0xbe(%rsp), %eax
movswl 0xbc(%rsp), %ecx
cmpl %ecx, %eax
jne 0x22a52
jmp 0x22cca
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x41a8(%rsp)
movl %eax, 0x41a4(%rsp)
leaq 0x4120(%rsp), %rdi
callq 0x33b80
jmp 0x22d52
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x41a8(%rsp)
movl %eax, 0x41a4(%rsp)
leaq 0xcf(%rsp), %rdi
callq 0x4e10
jmp 0x22d45
movl $0x0, 0xb8(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x4d50
movl %eax, %esi
addl $-0xd, %esi
movq 0xc0(%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 0x78(%rsp), %rdi
xorl %r8d, %r8d
movl $0x1, %r9d
movl %r8d, %ecx
callq 0x12200
jmp 0x22ab0
movl $0x0, 0x74(%rsp)
movl 0x74(%rsp), %eax
movq 0xc0(%rsp), %rcx
cmpl 0x1c(%rcx), %eax
jge 0x22cc0
movq 0xc0(%rsp), %rdi
movl 0x74(%rsp), %esi
movq 0x4250(%rsp), %rdx
movl 0x4200(%rsp), %ecx
movq 0x4208(%rsp), %r8
leaq 0x78(%rsp), %r9
callq 0x1e370
jmp 0x22afc
movl $0x0, 0x70(%rsp)
movl 0x70(%rsp), %eax
movq 0xc0(%rsp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x22cae
movq 0xc0(%rsp), %rsi
movl 0x70(%rsp), %edx
movl 0x74(%rsp), %ecx
movl 0x4204(%rsp), %r8d
movq 0x4250(%rsp), %r9
movl 0x4200(%rsp), %edi
movq 0x4208(%rsp), %r10
movq %rsp, %rax
leaq 0x78(%rsp), %r11
movq %r11, 0x10(%rax)
movq %r10, 0x8(%rax)
movl %edi, (%rax)
leaq 0xd0(%rsp), %rdi
callq 0x2c240
movw %ax, 0x4e(%rsp)
jmp 0x22b6e
movw 0x4e(%rsp), %ax
movw %ax, 0x6e(%rsp)
movq 0xc0(%rsp), %rdi
movl 0x74(%rsp), %esi
movl 0x70(%rsp), %edx
callq 0x12ba0
cwtl
movswl 0x6e(%rsp), %ecx
subl %ecx, %eax
movw %ax, 0x6c(%rsp)
movq 0x4208(%rsp), %rax
testb $0x1, 0x24(%rax)
je 0x22c66
movswl 0xbe(%rsp), %edx
movswl 0x6e(%rsp), %eax
subl %eax, %edx
movswl 0xbc(%rsp), %ecx
subl %eax, %ecx
movswl 0x6c(%rsp), %r8d
leaq 0xe8(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x33d90
movl %eax, 0x48(%rsp)
jmp 0x22be6
movl 0x48(%rsp), %eax
movl %eax, 0x68(%rsp)
movl 0x68(%rsp), %eax
movw %ax, 0x46(%rsp)
movq 0x4208(%rsp), %rdi
addq $0x40, %rdi
movslq 0xc8(%rsp), %rsi
callq 0x4ba0
movq %rax, %rdi
movl 0x74(%rsp), %esi
movl 0x70(%rsp), %edx
callq 0x12110
movw 0x46(%rsp), %cx
movw %cx, (%rax)
jmp 0x22c66
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x41a8(%rsp)
movl %eax, 0x41a4(%rsp)
jmp 0x22d38
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x41a8(%rsp)
movl %eax, 0x41a4(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x12380
jmp 0x22d38
movswl 0xbe(%rsp), %edx
movswl 0x6e(%rsp), %eax
subl %eax, %edx
movswl 0xbc(%rsp), %ecx
subl %eax, %ecx
movswl 0x6c(%rsp), %r8d
leaq 0xe8(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x33e10
jmp 0x22c9c
jmp 0x22c9e
movl 0x70(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x70(%rsp)
jmp 0x22b04
jmp 0x22cb0
movl 0x74(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x74(%rsp)
jmp 0x22ab8
leaq 0x78(%rsp), %rdi
callq 0x12380
movl 0xc8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc8(%rsp)
jmp 0x22994
movl $0x1, %edi
movl $0xa, %esi
xorl %edx, %edx
callq 0x33e80
jmp 0x22cf3
leaq 0xd0(%rsp), %rdi
callq 0x54f0
leaq 0xe8(%rsp), %rdi
callq 0x33e90
leaq 0x4158(%rsp), %rdi
callq 0x2bc70
jmp 0x22d1c
callq 0x2bce0
movb $0x1, 0x4227(%rsp)
leaq 0x41b0(%rsp), %rdi
callq 0x134e0
jmp 0x22d61
leaq 0xd0(%rsp), %rdi
callq 0x54f0
leaq 0xe8(%rsp), %rdi
callq 0x33e90
leaq 0x41b0(%rsp), %rdi
callq 0x134e0
jmp 0x22d78
movb 0x4227(%rsp), %al
andb $0x1, %al
addq $0x4228, %rsp           # imm = 0x4228
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x41a8(%rsp), %rdi
callq 0x36a0
nopw %cs:(%rax,%rax)
nop