// File: /workspace/github_cpp_makefile_star2_O3/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 $0x118, %rsp            # imm = 0x118
cmpb $0x0, 0xa8(%rsi)
je 0x11881
xorl %ebp, %ebp
jmp 0x12192
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
cmpl $0x2, 0x38(%rsi)
movq (%rdi), %rsi
leaq 0x14cdd(%rip), %rax     # 0x26575
leaq 0x14cdb(%rip), %rdi     # 0x2657a
cmovlq %rax, %rdi
callq 0x3330
movslq 0x68(%r15), %rax
movq %rax, (%rsp)
leaq 0x30(%rax), %rsi
movl $0x1, %r13d
movq %r14, %rdi
movl $0x1, %edx
callq 0x121f0
movl 0x60(%r15), %eax
cmpl $0x2, %eax
jl 0x118e9
movl $0x1, %r13d
movl $0x1, %ecx
incl %r13d
leal 0x1(,%rcx,2), %ecx
cmpl %eax, %ecx
jl 0x118db
leal 0x26(%r13), %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0x121f0
movslq 0x30(%r15), %rsi
decq %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x121f0
movslq 0x34(%r15), %rsi
decq %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x121f0
movl 0x38(%r15), %esi
cmpl $0x2, %esi
movq %rbx, 0x8(%rsp)
jl 0x119aa
addl $-0x2, %esi
movq %r14, %rdi
movl $0x1, %edx
callq 0x121f0
movslq 0x3c(%r15), %rsi
decq %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x121f0
movq 0x40(%r15), %rax
cmpq %rax, 0x48(%r15)
je 0x1198a
xorl %ebx, %ebx
movslq (%rax,%rbx,4), %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x121f0
incq %rbx
movq 0x40(%r15), %rax
movq 0x48(%r15), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %rbx, %rcx
ja 0x11960
jmp 0x11994
movq (%r14), %rsi
xorl %edi, %edi
callq 0x33a0
movslq 0x58(%r15), %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x121f0
movq 0x8(%rsp), %rbx
movslq 0x70(%r15), %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x121f0
movslq 0x10(%rbx), %rsi
movq %r14, 0xa8(%rsp)
movq %r14, %rdi
movl $0x1, %edx
callq 0x121f0
movl 0x30(%r15), %ebp
movl 0x34(%r15), %r12d
movl 0x70(%r15), %edi
movq (%rsp), %rbx
movl %ebx, %esi
callq 0x5f4c
movq %rax, %r14
movl 0x70(%r15), %edi
callq 0x6035
movq %rax, %r10
leaq 0x14b7e(%rip), %rsi     # 0x2657f
movl $0x2, %edi
movl %ebx, %edx
movl %r13d, %ecx
movl %ebp, %r8d
movl %r12d, %r9d
xorl %eax, %eax
pushq %r10
pushq %r14
callq 0x1cede
addq $0x10, %rsp
pxor %xmm0, %xmm0
movdqa %xmm0, 0x30(%rsp)
movdqa %xmm0, 0x20(%rsp)
movl $0xffffffff, 0x40(%rsp) # imm = 0xFFFFFFFF
testl %ebx, %ebx
jle 0x1217c
movq 0x20(%r15), %r14
subq 0x18(%r15), %r14
shrq $0x5, %r14
movslq %r14d, %rsi
leaq 0x20(%rsp), %rdi
movl $0x1, %edx
callq 0x12233
testl %r14d, %r14d
jle 0x11b02
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
xorl %ebx, %ebx
leaq 0x20(%rsp), %r12
movq %r14, (%rsp)
movq 0x18(%r15), %rcx
movq %rbx, %r13
shlq $0x5, %r13
movl (%rcx,%r13), %eax
movl $0x0, %ebp
cmpl $0xa, %eax
ja 0x11ab0
movl $0x7d8, %edx            # imm = 0x7D8
btl %eax, %edx
movl $0x0, %ebp
jae 0x11ab0
addq %r13, %rcx
movq 0x10(%rcx), %rbp
subq 0x8(%rcx), %rbp
shrq $0x2, %rbp
movl %ebp, %ecx
shll $0x4, %ecx
addl %eax, %ecx
movslq %ecx, %rsi
movq %r12, %rdi
movl $0x1, %edx
callq 0x12233
testl %ebp, %ebp
jle 0x11af2
movl %ebp, %ebp
xorl %r14d, %r14d
movq 0x18(%r15), %rax
movq 0x8(%rax,%r13), %rax
movslq (%rax,%r14,4), %rsi
movq %r12, %rdi
movl $0x1, %edx
callq 0x12233
incq %r14
cmpq %r14, %rbp
jne 0x11ad0
incq %rbx
movq (%rsp), %r14
cmpq %r14, %rbx
jne 0x11a79
movq 0x8(%r15), %rcx
subq (%r15), %rcx
shrq $0x6, %rcx
pcmpeqd %xmm0, %xmm0
movdqa %xmm0, 0xb0(%rsp)
movl $0xffffffff, 0xc0(%rsp) # imm = 0xFFFFFFFF
testl %ecx, %ecx
movq 0x8(%rsp), %rbx
jle 0x120ab
xorl %r12d, %r12d
movq %rcx, (%rsp)
movslq %r12d, %r13
movq (%r15), %rax
movq %r13, %r14
shlq $0x6, %r14
cmpl $0x0, 0x18(%rax,%r14)
je 0x1209f
addq %r14, %rax
cmpl $0x0, 0x1c(%rax)
je 0x1209f
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rax
movq %rax, %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
cmpq %r13, %rdx
jbe 0x11b7c
leaq (%rcx,%r13,4), %rax
jmp 0x11b89
cmpq %rcx, %rax
je 0x11c78
addq $-0x4, %rax
movl (%rax), %ebp
pxor %xmm0, %xmm0
movdqa %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
movl $0x8, %edi
callq 0x32b0
movq %rax, 0x50(%rsp)
movq %rax, %rcx
addq $0x8, %rcx
movq %rcx, 0x60(%rsp)
movq $0xffff, (%rax)         # imm = 0xFFFF
movq %rcx, 0x58(%rsp)
cmpb $0x1, 0x1c(%rbx)
jne 0x11c3e
movl %r12d, %esi
movl $0x26, %ecx
movl %r12d, %eax
cmpl -0x4(%r15,%rcx,4), %eax
jle 0x11be6
movl (%r15,%rcx,4), %edx
cmpl %edx, %eax
cmovlel %edx, %eax
incq %rcx
cmpq $0x2a, %rcx
jne 0x11bd6
movq %rsi, 0xd8(%rsp)
movq (%r15), %rdx
leaq (%rdx,%r14), %rcx
cmpl %r12d, %eax
movl %r12d, %esi
cmovgl %eax, %esi
movslq %esi, %rsi
subq %rsi, %r13
leaq (%rdx,%r14), %rsi
addq $0x5c, %rsi
xorl %edx, %edx
cmpq %rdx, %r13
je 0x11c84
movl 0x18(%rcx), %edi
cmpl -0x4(%rsi), %edi
jne 0x11c7f
movl 0x1c(%rcx), %edi
decq %rdx
leaq 0x40(%rsi), %r8
cmpl (%rsi), %edi
movq %r8, %rsi
je 0x11c17
notl %edx
addl %r12d, %edx
movl %edx, %eax
jmp 0x11c84
leaq 0x20(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movq %rbx, %rdx
movl %ebp, %ecx
movl %r12d, %r8d
movl %r12d, %r9d
leaq 0x10(%rsp), %rax
pushq %rax
pushq %r15
callq 0x12276
addq $0x10, %rsp
testb %al, %al
movl $0x1, %ebp
movl $0xf, %eax
cmovnel %eax, %ebp
jmp 0x12072
xorl %ebp, %ebp
jmp 0x11b8b
movl %r12d, %eax
subl %edx, %eax
movl 0x20(%rbx), %ecx
leal (%rcx,%r12), %edx
cmpl %edx, %eax
leal -0x1(%rcx,%r12), %r13d
cmovll %eax, %r13d
testl %ecx, %ecx
cmovlel %eax, %r13d
movl $0xffffffff, 0x9c(%rsp) # imm = 0xFFFFFFFF
leaq 0x9c(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movq %rbx, %rdx
movl %ebp, 0x18(%rsp)
movl %ebp, %ecx
movl %r12d, %r8d
movl %r13d, %r9d
leaq 0x10(%rsp), %rax
pushq %rax
pushq %r15
callq 0x12879
addq $0x10, %rsp
movl $0x1, %ebp
testb %al, %al
je 0x1206c
movslq 0x38(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movq %rbx, %rdx
movl 0x18(%rsp), %ecx
movl %r12d, %r8d
movl %r13d, %r9d
leaq 0x10(%rsp), %rax
pushq %rax
pushq %r15
callq 0x130c4
addq $0x10, %rsp
testb %al, %al
je 0x1206c
movq 0x38(%rsp), %rax
movq %rax, 0xa0(%rsp)
cltq
movq 0x10(%rsp), %rcx
movq %rax, 0x68(%rsp)
movq %rcx, 0x70(%rsp)
subq %rcx, %rax
movq %rax, 0x78(%rsp)
movq %rax, %xmm1
punpckldq 0x1466f(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x14677(%rip), %xmm1    # 0x263d0
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0x146d3(%rip), %xmm0    # 0x26440
movq (%r15), %rbx
xorps %xmm4, %xmm4
xorpd %xmm1, %xmm1
cmpl %r13d, %r12d
jg 0x11ddb
leaq (%rbx,%r14), %rax
addq $0x22, %rax
movl %r13d, %ecx
subl %r12d, %ecx
incl %ecx
movl -0x6(%rax), %edx
imull -0xa(%rax), %edx
movswl (%rax), %edi
movswl -0x2(%rax), %r8d
movl %edi, %esi
subl %r8d, %esi
bsrl %esi, %esi
xorl $-0x20, %esi
addl $0x21, %esi
movss 0x146af(%rip), %xmm3    # 0x26460
cmpw %r8w, %di
je 0x11dbe
xorps %xmm3, %xmm3
cvtsi2ss %esi, %xmm3
xorps %xmm2, %xmm2
cvtsi2ss %edx, %xmm2
jle 0x11dcf
mulss %xmm2, %xmm3
addss %xmm3, %xmm1
addss %xmm2, %xmm4
addq $0x40, %rax
decl %ecx
jne 0x11d8c
xorps %xmm2, %xmm2
cvtsd2ss %xmm0, %xmm2
movaps %xmm1, %xmm0
addss 0x14677(%rip), %xmm0    # 0x26464
xorps %xmm3, %xmm3
cmpltss %xmm1, %xmm3
andps %xmm3, %xmm0
andnps %xmm1, %xmm3
orps %xmm0, %xmm3
movss %xmm2, 0x8c(%rsp)
divss %xmm4, %xmm2
movss %xmm2, 0x90(%rsp)
movaps %xmm3, 0xf0(%rsp)
movaps %xmm4, 0xe0(%rsp)
divss %xmm4, %xmm3
movaps %xmm3, 0x100(%rsp)
movl 0x18(%rbx,%r14), %eax
movl %eax, 0x98(%rsp)
movl 0x1c(%rbx,%r14), %eax
movl %eax, 0x94(%rsp)
movq %r15, %rdi
movl %r12d, %esi
callq 0x112e6
movq %rax, 0xd0(%rsp)
movswl 0x20(%rbx,%r14), %eax
movq %rax, 0xc8(%rsp)
movswl 0x22(%rbx,%r14), %ebx
movq 0x80(%rsp), %r10
movq 0x70(%rsp), %r11
subq %r10, %r11
xorps %xmm0, %xmm0
cvtss2sd 0x90(%rsp), %xmm0
xorps %xmm1, %xmm1
cvtss2sd 0x100(%rsp), %xmm1
movaps %xmm0, %xmm3
movsd 0x145a6(%rip), %xmm2    # 0x26448
mulsd %xmm2, %xmm3
divsd %xmm1, %xmm3
subsd %xmm3, %xmm2
subq $0x8, %rsp
movl $0x4, %edi
leaq 0x146f1(%rip), %rsi     # 0x265af
movl %r12d, %edx
movl %r13d, %ecx
movl 0xa0(%rsp), %r8d
movl 0x9c(%rsp), %r9d
movb $0x3, %al
pushq 0x70(%rsp)
pushq %r10
pushq %r11
pushq 0x98(%rsp)
pushq %rbx
pushq 0xf8(%rsp)
pushq 0x108(%rsp)
callq 0x1cede
addq $0x40, %rsp
movq 0x8(%rsp), %rbx
movss 0x8c(%rsp), %xmm0
ucomiss 0xf0(%rsp), %xmm0
jb 0x12035
movq 0x80(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x50(%rsp), %rsi
movq %rbx, %rdx
movl 0x18(%rsp), %ecx
movl %r12d, %r8d
movl %r13d, %r9d
leaq 0x10(%rsp), %rax
pushq %rax
pushq %r15
callq 0x12276
addq $0x10, %rsp
testb %al, %al
je 0x1206c
movq 0x38(%rsp), %rax
movq %rax, 0xa0(%rsp)
cltq
movq 0x10(%rsp), %rbp
subq %rbp, %rax
movq %rax, 0x18(%rsp)
movq %rax, %xmm0
punpckldq 0x14441(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x14449(%rip), %xmm0    # 0x263d0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x144a5(%rip), %xmm1    # 0x26440
xorps %xmm0, %xmm0
cvtss2sd 0xe0(%rsp), %xmm0
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
movss %xmm0, 0x68(%rsp)
movq (%r15), %rbx
movl 0x18(%rbx,%r14), %eax
movl %eax, 0x78(%rsp)
movl 0x1c(%rbx,%r14), %eax
movl %eax, 0x70(%rsp)
movq %r15, %rdi
movl %r12d, %esi
callq 0x112e6
movq %rax, %r10
movswl 0x20(%rbx,%r14), %r11d
movswl 0x22(%rbx,%r14), %ebx
subq 0x80(%rsp), %rbp
xorps %xmm0, %xmm0
cvtss2sd 0x68(%rsp), %xmm0
subq $0x8, %rsp
movl $0x4, %edi
leaq 0x14626(%rip), %rsi     # 0x2662e
movl %r12d, %edx
movl %r13d, %ecx
movl 0x80(%rsp), %r8d
movl 0x78(%rsp), %r9d
movb $0x1, %al
pushq %rbp
pushq 0x28(%rsp)
pushq %rbx
movq 0x28(%rsp), %rbx
pushq %r11
pushq %r10
callq 0x1cede
addq $0x30, %rsp
xorl %eax, %eax
movq 0xd8(%rsp), %rdx
movq 0xa0(%rsp), %rsi
movl 0x90(%r15,%rax,4), %ecx
cmpl %edx, %ecx
jl 0x1205f
cmpl %r13d, %ecx
jg 0x1205f
movl %esi, 0xb0(%rsp,%rax,4)
incq %rax
cmpq $0x5, %rax
jne 0x12047
xorl %ebp, %ebp
jmp 0x1206f
movl %r12d, %r13d
movl %r13d, %r12d
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x12089
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
cmpl $0xf, %ebp
je 0x1209b
testl %ebp, %ebp
movq (%rsp), %rcx
je 0x1209f
jmp 0x12181
movq (%rsp), %rcx
incl %r12d
cmpl %ecx, %r12d
jl 0x11b39
leaq 0x142ce(%rip), %rbx     # 0x26380
leaq 0x145d5(%rip), %r12     # 0x2668e
xorl %r14d, %r14d
xorl %r13d, %r13d
movl (%r14,%rbx), %edx
movl 0x90(%r15,%r14), %ecx
movl 0xb0(%rsp,%r14), %ebp
movl $0x3, %edi
movq %r12, %rsi
movl %ebp, %r8d
xorl %eax, %eax
callq 0x1cede
testl %ebp, %ebp
jns 0x120f5
movl 0x38(%rsp), %ebp
movl %ebp, 0xb0(%rsp,%r14)
movl %ebp, %eax
subl %r13d, %eax
movslq %eax, %rsi
movq 0xa8(%rsp), %rdi
movl $0x1, %edx
callq 0x121f0
addq $0x4, %r14
movl %ebp, %r13d
cmpq $0x14, %r14
jne 0x120bf
movq 0x8(%rsp), %rdi
cmpb $0x0, 0x24(%rdi)
je 0x12130
addq $0x40, %rdi
callq 0x13af0
movq $0x0, 0x38(%rsp)
movb $0x1, %bpl
cmpq $0x0, 0x30(%rsp)
movq 0xa8(%rsp), %rbx
je 0x12183
xorl %eax, %eax
movq 0x20(%rsp), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x38(%rsp)
movzbl (%rcx,%rax), %edi
cmpl %edi, 0x40(%rsp)
je 0x12183
movq (%rbx), %rsi
callq 0x33a0
movq 0x38(%rsp), %rax
cmpq 0x30(%rsp), %rax
jb 0x1214e
jmp 0x12183
movb $0x1, %bpl
jmp 0x12192
xorl %ebp, %ebp
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x12192
callq 0x33b0
movl %ebp, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x121b2
jmp 0x121d6
jmp 0x121d6
jmp 0x121b2
jmp 0x121b2
jmp 0x121b2
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x121d9
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
jmp 0x121d9
jmp 0x121d6
jmp 0x121d6
jmp 0x121d6
jmp 0x121d6
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x121e8
callq 0x33b0
movq %rbx, %rdi
callq 0x3590