// File: /workspace/github_cpp_makefile_star2_O2/cloudinary[P]fuif/encoding/encoding.cpp
// Function: bool fuif_encode<FileIO>(FileIO&, Image const&, fuif_options&)
bool fuif_encode(IO& realio, const Image &image, fuif_options &options) {
    if (image.error) return false;
    if (image.nb_frames < 2) realio.fputs("FUIF");  // bytes 1-4 are fixed magic
    else realio.fputs("FUAF");                      // animation has different magic
    int nb_channels = image.real_nb_channels;
    write_big_endian_varint(realio, nb_channels + '0');
    int bit_depth = 1, maxval = 1;
    while (maxval < image.maxval) { bit_depth++; maxval = maxval*2 + 1; }
    write_big_endian_varint(realio, bit_depth + '&');
    write_big_endian_varint(realio, image.w-1);
    write_big_endian_varint(realio, image.h-1);
    if (image.nb_frames > 1) {
        write_big_endian_varint(realio, image.nb_frames-2);
        write_big_endian_varint(realio, image.den-1);
        if (image.num.size() == 0) write_big_endian_varint(realio, 0);
        else for (int i=0; i<image.num.size(); i++) write_big_endian_varint(realio, image.num[i]);
        write_big_endian_varint(realio, image.loops);
    }
    write_big_endian_varint(realio, image.colormodel);

    write_big_endian_varint(realio, options.max_properties);

    v_printf(2,"Encoding %i-channel, %i-bit, %ix%i %s%s image.\n", nb_channels, bit_depth, image.w, image.h, colormodel_name(image.colormodel,nb_channels), colorprofile_name(image.colormodel));

    BlobIO io;

    if (nb_channels < 1) return true; // is there any use for a zero-channel image?


    // encode transforms
    int nb_transforms = image.transform.size();
    write_big_endian_varint(io,nb_transforms);
    for (int i=0; i<nb_transforms; i++) {
        int id = image.transform[i].ID;
        int nb_params = (image.transform[i].has_parameters() ? image.transform[i].parameters.size() : 0);
        write_big_endian_varint(io, (nb_params << 4) + id);
        for (int j=0; j<nb_params; j++) write_big_endian_varint(io, image.transform[i].parameters[j]);
    }

    nb_channels = image.channel.size();

    int responsive_offsets[5] = {-1, -1, -1, -1, -1}; //   LQIP, 1/16 1/8 1/4 1/2

    // encode channel data
    for (int i=0; i<nb_channels; i++) {
        if (! image.channel[i].w || ! image.channel[i].h ) continue; // skip empty channels
        int predictor = 0;
        if (options.predictor.size() > i) predictor = options.predictor[i]; else if (options.predictor.size() > 0) predictor = options.predictor.back(); else predictor = 0;
//        if (predictor < 0) predictor = find_best_predictor(image.channel[i]);

        int j=i;
        Tree tree;
        size_t header_pos;

        if (!options.compress) {
            if (!fuif_encode_channels<BlobIO, RacOut<BlobIO>, FinalPropertySymbolCoder<FUIFBitChancePass2, RacOut<BlobIO>, MAX_BIT_DEPTH>, false, false >(io, tree, options, predictor, i, j, image, header_pos)) return false;
            continue;
        }

        // do several channels at a time (keep going until we hit a new downscale truncation point)
        for (int s=1; s<5; s++) if (j > image.downscales[s] && j < image.downscales[s+1]) j = image.downscales[s+1];

        // needed for interleaved (which we don't use), and maybe a good idea in any case: only clump same-dimension channels
        for (int k=i+1; k<=j; k++) if (image.channel[i].w != image.channel[k].w || image.channel[i].h != image.channel[k].h) { j=k-1; break; }

        if (options.max_group > 0 && j > i + options.max_group - 1) j = i + options.max_group - 1;

        DummyIO dummyio;
        if (!fuif_encode_channels<DummyIO, RacDummy<DummyIO>, PropertySymbolCoder<FUIFBitChancePass1, RacDummy<DummyIO>, MAX_BIT_DEPTH>, true, true >(dummyio, tree, options, predictor, i, j, image, header_pos)) return false;
        size_t before=io.ftell();
        if (!fuif_encode_channels<BlobIO, RacOut<BlobIO>, FinalPropertySymbolCoder<FUIFBitChancePass2, RacOut<BlobIO>, MAX_BIT_DEPTH>, false, true >(io, tree, options, predictor, i, j, image, header_pos)) return false;
        size_t after=io.ftell();
        float bits = (after-header_pos)*8.0;
        float pixels = 0.0;
        float ubits = 0.0;
        for (int k=i; k<=j; k++) {
            float chpixels = image.channel[k].w*image.channel[k].h;
            float uncompressed_bpp = maniac::util::ilog2(image.channel[k].maxval-image.channel[k].minval)+1;
            pixels += chpixels;
            if (image.channel[k].maxval > image.channel[k].minval)
                ubits += chpixels*uncompressed_bpp;
        }
        if (ubits > 0.0) ubits += 16; // rac flush might add 2 bytes
        float bpp=bits/pixels;
        float ubpp=ubits/pixels;

        v_printf(4,"Encoded channel %i-%i (%ix%i %s, range %i..%i), %i+%i bytes [%i-%i] (%f bpp; uncompressed estimate: %f bpp; %.2f%% reduction)\n", i,j, image.channel[i].w, image.channel[i].h, ch_describe(image,i), image.channel[i].minval, image.channel[i].maxval, after-header_pos, header_pos-before, before,after,
                bpp, ubpp, 100.0-100.0*bpp/ubpp);

        if ( bits >= ubits ) {
            io.fseek(before,SEEK_SET);
            if (!fuif_encode_channels<BlobIO, RacOut<BlobIO>, FinalPropertySymbolCoder<FUIFBitChancePass2, RacOut<BlobIO>, MAX_BIT_DEPTH>, false, false >(io, tree, options, predictor, i, j, image, header_pos)) return false;
            after=io.ftell();
            float bpp=(after-header_pos)*8.0/pixels;
            v_printf(4,"Rolled back. Encoded channel %i-%i UNCOMPRESSED (%ix%i %s, range %i..%i), %i+%i bytes (%f bpp)\n", i, j, image.channel[i].w, image.channel[i].h, ch_describe(image,i), image.channel[i].minval, image.channel[i].maxval, after-header_pos, header_pos-before, bpp);
        }
        for (int s=0; s<5; s++) {
            if (image.downscales[s] >= i && image.downscales[s] <= j) responsive_offsets[s] = after;
        }
        i=j;
    }

    int relative_offset = 0;
    for (int s=0; s<5; s++) {
        v_printf(3,"Responsive truncation point for size 1/%i after channel %i, at post-header position %i\n",responsive_sizes[s],image.downscales[s],responsive_offsets[s]);
        if (responsive_offsets[s] < 0) responsive_offsets[s] = io.ftell();
        int offset = responsive_offsets[s] - relative_offset;
        write_big_endian_varint(realio, (offset+TRUNCATION_OFFSET_RESOLUTION-1)/TRUNCATION_OFFSET_RESOLUTION);
        relative_offset = responsive_offsets[s];
    }

    if (options.debug) options.heatmap.recompute_minmax();

    io.fseek(0,SEEK_SET);
    int c;
    while ( (c=io.get_c()) != io.EOS ) realio.fputc(c); // TODO: copy the memory buffer more efficiently
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
cmpb $0x0, 0xa8(%rsi)
je 0xd20d
xorl %ebx, %ebx
jmp 0xda46
movq %rsi, %r15
movq %rdi, %rbp
movq %rdx, 0x8(%rsp)
cmpl $0x2, 0x38(%rsi)
leaq 0x11302(%rip), %rax     # 0x1e525
leaq 0x11300(%rip), %rsi     # 0x1e52a
cmovlq %rax, %rsi
callq 0xda98
movslq 0x68(%r15), %r14
movq %r14, %rsi
addq $0x30, %rsi
pushq $0x1
popq %rbx
movq %rbp, %rdi
movl %ebx, %edx
callq 0xdaa6
movl 0x60(%r15), %eax
pushq $0x27
popq %r12
cmpl %eax, %ebx
jge 0xd263
leal 0x1(,%rbx,2), %ebx
incq %r12
jmp 0xd253
pushq $0x1
popq %rbx
movq %rbp, %rdi
movq %r12, %rsi
movl %ebx, %edx
callq 0xdaa6
movslq 0x30(%r15), %rsi
decq %rsi
movq %rbp, %rdi
movl %ebx, %edx
callq 0xdaa6
movslq 0x34(%r15), %rsi
decq %rsi
movq %rbp, %rdi
movl %ebx, %edx
callq 0xdaa6
movl 0x38(%r15), %esi
addq $-0x26, %r12
cmpl $0x2, %esi
jl 0xd319
addl $-0x2, %esi
pushq $0x1
popq %rbx
movq %rbp, %rdi
movl %ebx, %edx
callq 0xdaa6
movslq 0x3c(%r15), %rsi
decq %rsi
movq %rbp, %rdi
movl %ebx, %edx
callq 0xdaa6
movq 0x40(%r15), %rax
movq 0x48(%r15), %rcx
cmpq %rax, %rcx
je 0xd2fd
xorl %r13d, %r13d
pushq $0x1
popq %rbx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r13, %rcx
jbe 0xd30a
movslq (%rax,%r13,4), %rsi
movq %rbp, %rdi
movl %ebx, %edx
callq 0xdaa6
incq %r13
movq 0x40(%r15), %rax
movq 0x48(%r15), %rcx
jmp 0xd2d6
pushq $0x1
popq %rdx
movq %rbp, %rdi
xorl %esi, %esi
callq 0xdaa6
movslq 0x58(%r15), %rsi
pushq $0x1
popq %rdx
movq %rbp, %rdi
callq 0xdaa6
movslq 0x70(%r15), %rsi
pushq $0x1
popq %rbx
movq %rbp, %rdi
movl %ebx, %edx
callq 0xdaa6
movq 0x8(%rsp), %rax
movslq 0x10(%rax), %rsi
movq %rbp, 0x80(%rsp)
movq %rbp, %rdi
movl %ebx, %edx
callq 0xdaa6
movl 0x30(%r15), %ebx
movl 0x34(%r15), %ebp
movl 0x70(%r15), %edi
movl %r14d, %esi
callq 0x4eec
movq %rax, %r13
movl 0x70(%r15), %edi
callq 0x4fd5
movq %rax, %r10
leaq 0x111c0(%rip), %rsi     # 0x1e52f
pushq $0x2
popq %rdi
movl %r14d, %edx
movl %r12d, %ecx
movl %ebx, %r8d
movl %ebp, %r9d
xorl %eax, %eax
pushq %r10
pushq %r13
callq 0x16c30
addq $0x10, %rsp
pxor %xmm0, %xmm0
movdqa %xmm0, 0x30(%rsp)
movdqa %xmm0, 0x20(%rsp)
orl $-0x1, 0x40(%rsp)
testl %r14d, %r14d
jle 0xda27
movq 0x20(%r15), %rbx
subq 0x18(%r15), %rbx
shrq $0x5, %rbx
movslq %ebx, %rsi
leaq 0x20(%rsp), %rdi
pushq $0x1
popq %rdx
callq 0xdaea
xorl %eax, %eax
testl %ebx, %ebx
cmovlel %eax, %ebx
leaq 0x20(%rsp), %r14
pushq $0x1
popq %rbp
xorl %r13d, %r13d
movq %rbx, (%rsp)
cmpq %rbx, %r13
je 0xd46a
movq 0x18(%r15), %rcx
movq %r13, 0x10(%rsp)
shlq $0x5, %r13
movl (%rcx,%r13), %eax
xorl %ebx, %ebx
cmpl $0xa, %eax
ja 0xd417
movl $0x7d8, %edx            # imm = 0x7D8
btl %eax, %edx
jae 0xd417
addq %r13, %rcx
movq 0x10(%rcx), %rbx
subq 0x8(%rcx), %rbx
shrq $0x2, %rbx
movl %ebx, %ecx
shll $0x4, %ecx
addl %eax, %ecx
movslq %ecx, %rsi
movq %r14, %rdi
movl %ebp, %edx
callq 0xdaea
testl %ebx, %ebx
movl $0x0, %eax
cmovlel %eax, %ebx
xorl %r12d, %r12d
cmpq %r12, %rbx
je 0xd459
movq 0x18(%r15), %rax
movq 0x8(%rax,%r13), %rax
movslq (%rax,%r12,4), %rsi
movq %r14, %rdi
movl %ebp, %edx
callq 0xdaea
incq %r12
jmp 0xd438
movq 0x10(%rsp), %r13
incq %r13
movq (%rsp), %rbx
jmp 0xd3dd
movq 0x8(%r15), %r12
subq (%r15), %r12
shrq $0x6, %r12
pcmpeqd %xmm0, %xmm0
orl $-0x1, 0xb0(%rsp)
movdqa %xmm0, 0xa0(%rsp)
xorl %r13d, %r13d
leaq 0x88(%rsp), %rdi
movq 0x8(%rsp), %r14
movq %r12, 0xb8(%rsp)
cmpl %r12d, %r13d
setge %al
movl %eax, 0x10(%rsp)
jge 0xd966
movslq %r13d, %rbx
movq (%r15), %rax
movq %rbx, %rbp
shlq $0x6, %rbp
cmpl $0x0, 0x18(%rax,%rbp)
je 0xd952
addq %rbp, %rax
cmpl $0x0, 0x1c(%rax)
je 0xd952
movq 0x28(%r14), %rcx
movq 0x30(%r14), %rax
movq %rax, %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %rbx, %rdx
jbe 0xd4f4
leaq (%rcx,%rbx,4), %rax
jmp 0xd501
cmpq %rcx, %rax
je 0xd95a
addq $-0x4, %rax
movl (%rax), %eax
movl %eax, (%rsp)
callq 0xdb2e
cmpb $0x1, 0x1c(%r14)
jne 0xd541
movl %r13d, %eax
pushq $0x1
popq %rcx
cmpq $0x5, %rcx
je 0xd586
leaq 0x1(%rcx), %rdx
cmpl 0x90(%r15,%rcx,4), %eax
movq %rdx, %rcx
jle 0xd518
movl 0x90(%r15,%rdx,4), %ecx
cmpl %ecx, %eax
cmovlel %ecx, %eax
movq %rdx, %rcx
jmp 0xd518
leaq 0x20(%rsp), %rdi
leaq 0x88(%rsp), %rbp
movq %rbp, %rsi
movq %r14, %rdx
movl (%rsp), %ecx
movl %r13d, %r8d
movl %r13d, %r9d
leaq 0x18(%rsp), %rax
pushq %rax
pushq %r15
callq 0xdb50
popq %rcx
popq %rdx
movl %eax, %ebx
movq %rbp, %rdi
callq 0x124b8
testb %bl, %bl
movq %rbp, %rdi
jne 0xd952
jmp 0xda38
movq (%r15), %rdx
movslq %eax, %rsi
leaq (%rdx,%rbp), %rdi
addq $0x5c, %rdi
addq %rbp, %rdx
movq %rbx, %rcx
cmpq %rsi, %rcx
jge 0xd5c0
movl 0x18(%rdx), %r8d
cmpl -0x4(%rdi), %r8d
jne 0xd5be
movl 0x1c(%rdx), %r8d
incq %rcx
leaq 0x40(%rdi), %r9
cmpl (%rdi), %r8d
movq %r9, %rdi
je 0xd59a
decl %ecx
movl %ecx, %eax
movl 0x20(%r14), %ecx
leal (%rcx,%r13), %edx
cmpl %edx, %eax
leal -0x1(%rcx,%r13), %r12d
cmovll %eax, %r12d
testl %ecx, %ecx
cmovlel %eax, %r12d
orl $-0x1, 0x7c(%rsp)
leaq 0x7c(%rsp), %rdi
leaq 0x88(%rsp), %rsi
movq %r14, %rdx
movl (%rsp), %ecx
movl %r13d, %r8d
movl %r12d, %r9d
leaq 0x18(%rsp), %rax
pushq %rax
pushq %r15
callq 0xdf56
popq %rcx
popq %rdx
testb %al, %al
je 0xda2b
movslq 0x38(%rsp), %rax
movq %rax, 0x60(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x88(%rsp), %rsi
movq %r14, %rdx
movl (%rsp), %ecx
movl %r13d, %r8d
movl %r12d, %r9d
leaq 0x18(%rsp), %rax
pushq %rax
pushq %r15
callq 0xe523
popq %rcx
popq %rdx
testb %al, %al
je 0xda2b
movq 0x38(%rsp), %r14
movslq %r14d, %rax
movq 0x18(%rsp), %rcx
movq %rax, 0x48(%rsp)
movq %rcx, 0x50(%rsp)
subq %rcx, %rax
movq %rax, 0x58(%rsp)
movq %rax, %xmm1
punpckldq 0x10ccc(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x10cd4(%rip), %xmm1    # 0x1e350
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x10d60(%rip), %xmm0    # 0x1e3f0
movq (%r15), %r9
movslq %r12d, %rax
leaq (%r9,%rbp), %rcx
addq $0x22, %rcx
xorps %xmm4, %xmm4
xorpd %xmm1, %xmm1
cmpq %rax, %rbx
jg 0xd6f4
movl -0x6(%rcx), %edx
imull -0xa(%rcx), %edx
movswl (%rcx), %edi
movswl -0x2(%rcx), %r8d
movl %edi, %esi
subl %r8d, %esi
bsrl %esi, %esi
xorl $-0x20, %esi
addl $0x21, %esi
movss 0x10d41(%rip), %xmm3    # 0x1e410
cmpw %r8w, %di
je 0xd6d9
cvtsi2ss %esi, %xmm3
cvtsi2ss %edx, %xmm2
jle 0xd6e7
mulss %xmm2, %xmm3
addss %xmm3, %xmm1
addss %xmm2, %xmm4
incq %rbx
addq $0x40, %rcx
jmp 0xd6a5
cvtsd2ss %xmm0, %xmm2
movaps %xmm1, %xmm0
addss 0x10d11(%rip), %xmm0    # 0x1e414
xorps %xmm3, %xmm3
cmpltss %xmm1, %xmm3
andps %xmm3, %xmm0
andnps %xmm1, %xmm3
orps %xmm0, %xmm3
movss %xmm2, 0x6c(%rsp)
divss %xmm4, %xmm2
movss %xmm2, 0x70(%rsp)
movaps %xmm3, 0xd0(%rsp)
movss %xmm4, 0x68(%rsp)
divss %xmm4, %xmm3
movaps %xmm3, 0xe0(%rsp)
movl 0x18(%r9,%rbp), %eax
movl %eax, 0x78(%rsp)
movl 0x1c(%r9,%rbp), %eax
movl %eax, 0x74(%rsp)
movq %r15, %rdi
movl %r13d, %esi
movq %r9, %rbx
callq 0xcd41
movq %rax, 0xc8(%rsp)
movswl 0x20(%rbx,%rbp), %eax
movq %rax, 0xc0(%rsp)
movswl 0x22(%rbx,%rbp), %ebx
movq 0x60(%rsp), %r11
movq 0x50(%rsp), %r10
subq %r11, %r10
cvtss2sd 0x70(%rsp), %xmm0
cvtss2sd 0xe0(%rsp), %xmm1
movaps %xmm0, %xmm3
movsd 0x10c59(%rip), %xmm2    # 0x1e3f8
mulsd %xmm2, %xmm3
divsd %xmm1, %xmm3
subsd %xmm3, %xmm2
subq $0x8, %rsp
pushq $0x4
popq %rdi
leaq 0x10da6(%rip), %rsi     # 0x1e55f
movl %r13d, %edx
movl %r12d, %ecx
movl 0x80(%rsp), %r8d
movl 0x7c(%rsp), %r9d
movb $0x3, %al
pushq 0x50(%rsp)
pushq %r11
pushq %r10
pushq 0x78(%rsp)
pushq %rbx
pushq 0xf0(%rsp)
pushq 0x100(%rsp)
callq 0x16c30
addq $0x40, %rsp
movss 0x6c(%rsp), %xmm0
ucomiss 0xd0(%rsp), %xmm0
jb 0xd906
movq 0x60(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x88(%rsp), %rsi
movq 0x8(%rsp), %rdx
movl (%rsp), %ecx
movl %r13d, %r8d
movl %r12d, %r9d
leaq 0x18(%rsp), %rax
pushq %rax
pushq %r15
callq 0xdb50
popq %rcx
popq %rdx
testb %al, %al
je 0xda2b
movq 0x38(%rsp), %r14
movslq %r14d, %rax
movq 0x18(%rsp), %rcx
movq %rcx, (%rsp)
subq %rcx, %rax
movq %rax, 0x10(%rsp)
movq %rax, %xmm0
punpckldq 0x10ad8(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x10ae0(%rip), %xmm0    # 0x1e350
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x10b6c(%rip), %xmm1    # 0x1e3f0
cvtss2sd 0x68(%rsp), %xmm0
divsd %xmm0, %xmm1
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x48(%rsp)
movq (%r15), %rbx
movl 0x18(%rbx,%rbp), %eax
movl %eax, 0x58(%rsp)
movl 0x1c(%rbx,%rbp), %eax
movl %eax, 0x50(%rsp)
movq %r15, %rdi
movl %r13d, %esi
callq 0xcd41
movq %rax, %r10
movswl 0x20(%rbx,%rbp), %r11d
movswl 0x22(%rbx,%rbp), %ebx
movq (%rsp), %rbp
subq 0x60(%rsp), %rbp
cvtss2sd 0x48(%rsp), %xmm0
subq $0x8, %rsp
pushq $0x4
popq %rdi
leaq 0x10cfd(%rip), %rsi     # 0x1e5de
movl %r13d, %edx
movl %r12d, %ecx
movl 0x60(%rsp), %r8d
movl 0x58(%rsp), %r9d
movb $0x1, %al
pushq %rbp
pushq 0x20(%rsp)
pushq %rbx
pushq %r11
pushq %r10
callq 0x16c30
addq $0x30, %rsp
xorl %eax, %eax
cmpq $0x5, %rax
je 0xd92d
movl 0x90(%r15,%rax,4), %ecx
cmpl %r13d, %ecx
jl 0xd928
cmpl %r12d, %ecx
jg 0xd928
movl %r14d, 0xa0(%rsp,%rax,4)
incq %rax
jmp 0xd908
leaq 0x88(%rsp), %rdi
callq 0x124b8
leaq 0x88(%rsp), %rdi
movl %r12d, %r13d
movq 0x8(%rsp), %r14
movq 0xb8(%rsp), %r12
incl %r13d
jmp 0xd4a2
movl $0x0, (%rsp)
jmp 0xd506
pushq $0x3
popq %r12
pushq $0x1
popq %r13
xorl %ebp, %ebp
xorl %r14d, %r14d
cmpq $0x14, %rbp
je 0xd9d7
leaq 0x10980(%rip), %rax     # 0x1e300
movl (%rbp,%rax), %edx
movl 0x90(%r15,%rbp), %ecx
movl 0xa0(%rsp,%rbp), %ebx
movl %r12d, %edi
leaq 0x10ca1(%rip), %rsi     # 0x1e63e
movl %ebx, %r8d
xorl %eax, %eax
callq 0x16c30
testl %ebx, %ebx
jns 0xd9b6
movl 0x38(%rsp), %ebx
movl %ebx, 0xa0(%rsp,%rbp)
movl %ebx, %eax
subl %r14d, %eax
movslq %eax, %rsi
movq 0x80(%rsp), %rdi
movl %r13d, %edx
callq 0xdaa6
addq $0x4, %rbp
movl %ebx, %r14d
jmp 0xd973
movq 0x8(%rsp), %rdi
cmpb $0x0, 0x24(%rdi)
je 0xd9eb
addq $0x40, %rdi
callq 0xec3a
andq $0x0, 0x38(%rsp)
movq 0x80(%rsp), %rbx
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
jae 0xda38
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x38(%rsp)
movzbl (%rcx,%rax), %esi
cmpl %esi, 0x40(%rsp)
je 0xda38
movq %rbx, %rdi
callq 0xec84
jmp 0xd9f9
movb $0x1, %bl
jmp 0xda3c
leaq 0x88(%rsp), %rdi
callq 0x124b8
movl 0x10(%rsp), %ebx
leaq 0x20(%rsp), %rdi
callq 0xec90
movl %ebx, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xda82
jmp 0xda82
jmp 0xda66
jmp 0xda66
jmp 0xda66
jmp 0xda66
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x124b8
jmp 0xda85
jmp 0xda82
jmp 0xda82
jmp 0xda82
jmp 0xda82
jmp 0xda82
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xec90
movq %rbx, %rdi
callq 0x35d0
nop