// File: cloudinary[P]fuif/encoding/encoding.cpp
// Function: bool fuif_decode<FileIO>(FileIO&, Image&, fuif_options)
bool fuif_decode(IO& io, Image &image, fuif_options options) {
    char buff[5];
    if (!io.gets(buff,5)) { e_printf("Could not read header from file: %s\n",io.getName()); return false; }
    bool multi_frame = false;
    if (!strcmp(buff,"FUAF")) { multi_frame = true; }
    else if (strcmp(buff,"FUIF")) { e_printf("%s is not a FUIF file\n",io.getName()); return false; }
    int nb_channels = read_big_endian_varint(io) - '0';
    int bit_depth = read_big_endian_varint(io) - '&';
    int w = read_big_endian_varint(io)+1;
    int h = read_big_endian_varint(io)+1;
    int nb_frames = 1;
    int loops = 0;
    int den = 0;
    std::vector<int> num;
    if (multi_frame) {
        nb_frames = read_big_endian_varint(io)+2;
        den = read_big_endian_varint(io)+1;
        int numerator = read_big_endian_varint(io);
        if (numerator) {
            num.push_back(numerator);
            for (int i=1; i<nb_frames; i++) num.push_back(read_big_endian_varint(io));
        }
        loops = read_big_endian_varint(io);
    }
    int colormodel = read_big_endian_varint(io);
    if (options.identify) {
        v_printf(1,"%s: %i-channel, %i-bit, ", io.getName(), nb_channels, bit_depth);
        if (multi_frame) v_printf(1,"%ix%i %s%s animation (%i frames)\n", w, h/nb_frames, colormodel_name(colormodel,nb_channels), colorprofile_name(colormodel), nb_frames);
        else v_printf(1,"%ix%i %s%s image\n", w, h, colormodel_name(colormodel,nb_channels), colorprofile_name(colormodel));
    }
    options.max_properties = read_big_endian_varint(io);

    v_printf(4,"Global option: up to %i back-referencing MANIAC properties.\n", options.max_properties);

    v_printf(7,"First part of header decoded (basic info). Read %i bytes so far.\n",io.ftell());

    if (!options.identify) {
        image = Image(w, h, (1<<bit_depth)-1, nb_channels, colormodel);
        image.nb_frames = nb_frames;
        image.den = den;
        image.num = num;
        image.loops = loops;
    }

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

    int responsive_offsets[5];
    int relative_offset = 0;
    for (int s=0; s<5; s++) {
        responsive_offsets[s] = read_big_endian_varint(io)*TRUNCATION_OFFSET_RESOLUTION + relative_offset;
        relative_offset = responsive_offsets[s];
    }
    relative_offset = io.ftell();
    for (int s=0; s<5; s++) {
        responsive_offsets[s] += relative_offset;
        if (s) v_printf(3,"Responsive truncation point for size 1/%i at position %i\n",responsive_sizes[s],responsive_offsets[s]);
        else v_printf(3,"Responsive truncation point for LQIP at position %i\n",responsive_offsets[s]);
    }



    if (!options.identify) {
    if (multi_frame) v_printf(2,"Decoding %i-channel, %i-bit, %ix%i %s%s animation (%i frames)", nb_channels, bit_depth, w, h/nb_frames, colormodel_name(colormodel,nb_channels), colorprofile_name(colormodel), nb_frames);
    else v_printf(2,"Decoding %i-channel, %i-bit, %ix%i %s%s image", nb_channels, bit_depth, w, h, colormodel_name(colormodel,nb_channels), colorprofile_name(colormodel));
    if (options.preview == 0) v_printf(2, " as a low-quality image placeholder");
    else if (options.preview > 0) v_printf(2," at scale 1:%i",responsive_sizes[options.preview]);
    v_printf(2,".\n");
    }


    v_printf(7,"Second part of header decoded (responsive offsets and global parameters; before transforms). Read %i bytes so far.\n",io.ftell());

    // decode transforms
    int nb_transforms = read_big_endian_varint(io);
    v_printf(2,"Image data underwent %i transformations: ",nb_transforms);
    for (int i=0; i<nb_transforms; i++) {
        int id_and_nb_params = read_big_endian_varint(io);
        Transform t(id_and_nb_params & 0xf);
        if (t.has_parameters()) {
            int nb_params = (id_and_nb_params >> 4);
            for (int j=0; j<nb_params; j++) t.parameters.push_back(read_big_endian_varint(io));
        }
        if (!options.identify) {
            t.meta_apply(image);
            image.transform.push_back(t);
        }
        if (i) v_printf(2,", ");
        v_printf(2,"%s",t.name());
        if (t.ID == TRANSFORM_PALETTE) {
            if (t.parameters[0] == t.parameters[1]) v_printf(3,"[Compact channel %i to ",t.parameters[0]);
            else v_printf(3,"[channels %i-%i with ",t.parameters[0],t.parameters[1]);
            v_printf(3,"%i colors]",t.parameters[2]);
        }
    }
    v_printf(2,"\n");
    v_printf(6,"Header decoded. Read %i bytes so far.\n",io.ftell());
    if (options.identify) return true;
    if (image.error) {
        e_printf("Corrupt file. Aborting.\n");
        return false;
    }

    nb_channels = image.channel.size();

    size_t bytes_to_load = 0;
    if (options.preview >= 0) bytes_to_load = responsive_offsets[options.preview];

    // decode channel data
    for (int i=0; i<nb_channels; i++) {
        if ((options.preview < 0 || io.ftell() < bytes_to_load) && !io.isEOF()) {
            if (! image.channel[i].w || ! image.channel[i].h ) continue; // skip empty channels
            if (!fuif_decode_channel<IO, FinalPropertySymbolCoder<FUIFBitChancePass2, RacIn<IO>, MAX_BIT_DEPTH> >(io, options, i, image, bytes_to_load)) return false;
            if (image.transform.size() > 0 && image.transform.back().ID == TRANSFORM_PERMUTE && image.transform.back().parameters.size() == 0 && i==0) inv_permute_meta(image);
        } else {
            v_printf(3,"Skipping decode of channels %i-%i.\n",i,nb_channels-1);
            break;
        }
    }
    v_printf(3,"Done decoding. Read %i bytes.\n",io.ftell());
    return true;
}

// Assembly:
subq $0x2d8, %rsp            # imm = 0x2D8
movq %rdx, 0x130(%rsp)
movq %rdi, 0x2c8(%rsp)
movq %rsi, 0x2c0(%rsp)
movq %rdx, 0x2b8(%rsp)
movq 0x2c8(%rsp), %rdi
leaq 0x2b3(%rsp), %rsi
movl $0x5, %edx
callq 0x25320
cmpq $0x0, %rax
jne 0x24412
movq 0x2c8(%rsp), %rdi
callq 0x25350
movq %rax, %rsi
leaq 0x231e4(%rip), %rdi     # 0x475e2
movb $0x0, %al
callq 0x3a670
movb $0x0, 0x2d7(%rsp)
jmp 0x252f8
movb $0x0, 0x2b2(%rsp)
leaq 0x2b3(%rsp), %rdi
leaq 0x2304d(%rip), %rsi     # 0x47476
callq 0x34e0
cmpl $0x0, %eax
jne 0x2443d
movb $0x1, 0x2b2(%rsp)
jmp 0x24483
leaq 0x2b3(%rsp), %rdi
leaq 0x23025(%rip), %rsi     # 0x47471
callq 0x34e0
cmpl $0x0, %eax
je 0x24481
movq 0x2c8(%rsp), %rdi
callq 0x25350
movq %rax, %rsi
leaq 0x2319a(%rip), %rdi     # 0x47607
movb $0x0, %al
callq 0x3a670
movb $0x0, 0x2d7(%rsp)
jmp 0x252f8
jmp 0x24483
movq 0x2c8(%rsp), %rdi
callq 0x25360
subl $0x30, %eax
movl %eax, 0x2ac(%rsp)
movq 0x2c8(%rsp), %rdi
callq 0x25360
subl $0x26, %eax
movl %eax, 0x2a8(%rsp)
movq 0x2c8(%rsp), %rdi
callq 0x25360
addl $0x1, %eax
movl %eax, 0x2a4(%rsp)
movq 0x2c8(%rsp), %rdi
callq 0x25360
addl $0x1, %eax
movl %eax, 0x2a0(%rsp)
movl $0x1, 0x29c(%rsp)
movl $0x0, 0x298(%rsp)
movl $0x0, 0x294(%rsp)
leaq 0x278(%rsp), %rdi
callq 0x125e0
testb $0x1, 0x2b2(%rsp)
je 0x2465b
movq 0x2c8(%rsp), %rdi
callq 0x25360
movl %eax, 0x12c(%rsp)
jmp 0x24531
movl 0x12c(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x29c(%rsp)
movq 0x2c8(%rsp), %rdi
callq 0x25360
movl %eax, 0x128(%rsp)
jmp 0x24558
movl 0x128(%rsp), %eax
incl %eax
movl %eax, 0x294(%rsp)
movq 0x2c8(%rsp), %rdi
callq 0x25360
movl %eax, 0x124(%rsp)
jmp 0x2457e
movl 0x124(%rsp), %eax
movl %eax, 0x268(%rsp)
cmpl $0x0, 0x268(%rsp)
je 0x24637
leaq 0x278(%rsp), %rdi
leaq 0x268(%rsp), %rsi
callq 0x12560
jmp 0x245b1
movl $0x1, 0x264(%rsp)
movl 0x264(%rsp), %eax
cmpl 0x29c(%rsp), %eax
jge 0x24635
movq 0x2c8(%rsp), %rdi
callq 0x25360
movl %eax, 0x120(%rsp)
jmp 0x245e2
movl 0x120(%rsp), %eax
movl %eax, 0x260(%rsp)
leaq 0x278(%rsp), %rdi
leaq 0x260(%rsp), %rsi
callq 0x121b0
jmp 0x24607
jmp 0x24609
movl 0x264(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x264(%rsp)
jmp 0x245bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
jmp 0x252e9
jmp 0x24637
movq 0x2c8(%rsp), %rdi
callq 0x25360
movl %eax, 0x11c(%rsp)
jmp 0x2464d
movl 0x11c(%rsp), %eax
movl %eax, 0x298(%rsp)
movq 0x2c8(%rsp), %rdi
callq 0x25360
movl %eax, 0x118(%rsp)
jmp 0x24671
movq 0x130(%rsp), %rax
movl 0x118(%rsp), %ecx
movl %ecx, 0x25c(%rsp)
testb $0x1, 0x4(%rax)
je 0x24805
movq 0x2c8(%rsp), %rdi
callq 0x25350
movq %rax, 0x110(%rsp)
jmp 0x246a8
movq 0x110(%rsp), %rdx
movl 0x2ac(%rsp), %ecx
movl 0x2a8(%rsp), %r8d
leaq 0x22f58(%rip), %rsi     # 0x4761e
xorl %eax, %eax
movl $0x1, %edi
callq 0x3a770
jmp 0x246d4
testb $0x1, 0x2b2(%rsp)
je 0x2477f
movl 0x2a4(%rsp), %eax
movl %eax, 0x100(%rsp)
movl 0x2a0(%rsp), %eax
movl 0x29c(%rsp), %ecx
cltd
idivl %ecx
movl %eax, 0x104(%rsp)
movl 0x25c(%rsp), %edi
movl 0x2ac(%rsp), %esi
callq 0x41c0
movq %rax, 0x108(%rsp)
jmp 0x24725
movl 0x25c(%rsp), %edi
callq 0x4380
movq %rax, 0xf8(%rsp)
jmp 0x2473b
movq 0xf8(%rsp), %r9
movq 0x108(%rsp), %r8
movl 0x104(%rsp), %ecx
movl 0x100(%rsp), %edx
movl 0x29c(%rsp), %esi
movq %rsp, %rax
movl %esi, (%rax)
leaq 0x22ecb(%rip), %rsi     # 0x47637
xorl %eax, %eax
movl $0x1, %edi
callq 0x3a770
jmp 0x2477a
jmp 0x24803
movl 0x2a4(%rsp), %eax
movl %eax, 0xe8(%rsp)
movl 0x2a0(%rsp), %eax
movl %eax, 0xec(%rsp)
movl 0x25c(%rsp), %edi
movl 0x2ac(%rsp), %esi
callq 0x41c0
movq %rax, 0xf0(%rsp)
jmp 0x247b8
movl 0x25c(%rsp), %edi
callq 0x4380
movq %rax, 0xe0(%rsp)
jmp 0x247ce
movq 0xe0(%rsp), %r9
movq 0xf0(%rsp), %r8
movl 0xec(%rsp), %ecx
movl 0xe8(%rsp), %edx
leaq 0x22e66(%rip), %rsi     # 0x47659
xorl %eax, %eax
movl $0x1, %edi
callq 0x3a770
jmp 0x24801
jmp 0x24803
jmp 0x24805
movq 0x2c8(%rsp), %rdi
callq 0x25360
movl %eax, 0xdc(%rsp)
jmp 0x2481b
movq 0x130(%rsp), %rax
movl 0xdc(%rsp), %ecx
movl %ecx, 0x10(%rax)
movl 0x10(%rax), %edx
leaq 0x22e34(%rip), %rsi     # 0x4766b
xorl %eax, %eax
movl $0x4, %edi
callq 0x3a770
jmp 0x24845
movq 0x2c8(%rsp), %rdi
callq 0x25410
movq %rax, 0xd0(%rsp)
jmp 0x2485c
movq 0xd0(%rsp), %rdx
leaq 0x22e3d(%rip), %rsi     # 0x476a8
xorl %eax, %eax
movl $0x7, %edi
callq 0x3a770
jmp 0x24879
movq 0x130(%rsp), %rax
testb $0x1, 0x4(%rax)
jne 0x24945
movl 0x2a4(%rsp), %esi
movl 0x2a0(%rsp), %edx
movb 0x2a8(%rsp), %cl
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
decl %ecx
movl 0x2ac(%rsp), %r8d
movl 0x25c(%rsp), %r9d
leaq 0x1a8(%rsp), %rdi
callq 0x25430
jmp 0x248ca
movq 0x2c0(%rsp), %rdi
leaq 0x1a8(%rsp), %rsi
movq %rsi, 0xc8(%rsp)
callq 0x25650
movq 0xc8(%rsp), %rdi
callq 0x12ab0
movl 0x29c(%rsp), %ecx
movq 0x2c0(%rsp), %rax
movl %ecx, 0x38(%rax)
movl 0x294(%rsp), %ecx
movq 0x2c0(%rsp), %rax
movl %ecx, 0x3c(%rax)
movq 0x2c0(%rsp), %rdi
addq $0x40, %rdi
leaq 0x278(%rsp), %rsi
callq 0x25730
jmp 0x24933
movl 0x298(%rsp), %ecx
movq 0x2c0(%rsp), %rax
movl %ecx, 0x58(%rax)
cmpl $0x1, 0x2ac(%rsp)
jge 0x24967
movb $0x1, 0x2d7(%rsp)
movl $0x1, 0x1a4(%rsp)
jmp 0x252da
movl $0x0, 0x18c(%rsp)
movl $0x0, 0x188(%rsp)
cmpl $0x5, 0x188(%rsp)
jge 0x249e6
movq 0x2c8(%rsp), %rdi
callq 0x25360
movl %eax, 0xc4(%rsp)
jmp 0x2499d
movl 0xc4(%rsp), %ecx
shll $0x0, %ecx
addl 0x18c(%rsp), %ecx
movslq 0x188(%rsp), %rax
movl %ecx, 0x190(%rsp,%rax,4)
movslq 0x188(%rsp), %rax
movl 0x190(%rsp,%rax,4), %eax
movl %eax, 0x18c(%rsp)
movl 0x188(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x188(%rsp)
jmp 0x2497d
movq 0x2c8(%rsp), %rdi
callq 0x25410
movq %rax, 0xb8(%rsp)
jmp 0x249fd
movq 0xb8(%rsp), %rax
movl %eax, 0x18c(%rsp)
movl $0x0, 0x184(%rsp)
cmpl $0x5, 0x184(%rsp)
jge 0x24aba
movl 0x18c(%rsp), %ecx
movslq 0x184(%rsp), %rax
addl 0x190(%rsp,%rax,4), %ecx
movl %ecx, 0x190(%rsp,%rax,4)
cmpl $0x0, 0x184(%rsp)
je 0x24a7c
movslq 0x184(%rsp), %rax
leaq 0x22875(%rip), %rcx     # 0x472d0
movl (%rcx,%rax,4), %edx
movl 0x190(%rsp,%rax,4), %ecx
leaq 0x22c7e(%rip), %rsi     # 0x476ea
xorl %eax, %eax
movl $0x3, %edi
callq 0x3a770
jmp 0x24a7a
jmp 0x24aa2
movslq 0x184(%rsp), %rax
movl 0x190(%rsp,%rax,4), %edx
leaq 0x22c92(%rip), %rsi     # 0x47724
xorl %eax, %eax
movl $0x3, %edi
callq 0x3a770
jmp 0x24aa0
jmp 0x24aa2
jmp 0x24aa4
movl 0x184(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x184(%rsp)
jmp 0x24a17
movq 0x130(%rsp), %rax
testb $0x1, 0x4(%rax)
jne 0x24cc9
testb $0x1, 0x2b2(%rsp)
je 0x24ba6
movl 0x2ac(%rsp), %esi
movl %esi, 0xa0(%rsp)
movl 0x2a8(%rsp), %eax
movl %eax, 0xa4(%rsp)
movl 0x2a4(%rsp), %eax
movl %eax, 0xa8(%rsp)
movl 0x2a0(%rsp), %eax
movl 0x29c(%rsp), %ecx
cltd
idivl %ecx
movl %eax, 0xac(%rsp)
movl 0x25c(%rsp), %edi
callq 0x41c0
movq %rax, 0xb0(%rsp)
jmp 0x24b32
movl 0x25c(%rsp), %edi
callq 0x4380
movq %rax, 0x98(%rsp)
jmp 0x24b48
movl 0xac(%rsp), %r9d
movl 0xa8(%rsp), %r8d
movl 0xa4(%rsp), %ecx
movl 0xa0(%rsp), %edx
movq 0xb0(%rsp), %rsi
movq 0x98(%rsp), %rdi
movl 0x29c(%rsp), %r10d
movq %rsp, %rax
movl %r10d, 0x10(%rax)
movq %rdi, 0x8(%rax)
movq %rsi, (%rax)
leaq 0x22bc6(%rip), %rsi     # 0x47759
xorl %eax, %eax
movl $0x2, %edi
callq 0x3a770
jmp 0x24ba1
jmp 0x24c53
movl 0x2ac(%rsp), %esi
movl %esi, 0x80(%rsp)
movl 0x2a8(%rsp), %eax
movl %eax, 0x84(%rsp)
movl 0x2a4(%rsp), %eax
movl %eax, 0x88(%rsp)
movl 0x2a0(%rsp), %eax
movl %eax, 0x8c(%rsp)
movl 0x25c(%rsp), %edi
callq 0x41c0
movq %rax, 0x90(%rsp)
jmp 0x24bf4
movl 0x25c(%rsp), %edi
callq 0x4380
movq %rax, 0x78(%rsp)
jmp 0x24c07
movl 0x8c(%rsp), %r9d
movl 0x88(%rsp), %r8d
movl 0x84(%rsp), %ecx
movl 0x80(%rsp), %edx
movq 0x90(%rsp), %rsi
movq 0x78(%rsp), %rdi
movq %rsp, %rax
movq %rdi, 0x8(%rax)
movq %rsi, (%rax)
leaq 0x22b54(%rip), %rsi     # 0x47797
xorl %eax, %eax
movl $0x2, %edi
callq 0x3a770
jmp 0x24c51
jmp 0x24c53
movq 0x130(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x24c77
leaq 0x22b5e(%rip), %rsi     # 0x477c5
xorl %eax, %eax
movl $0x2, %edi
callq 0x3a770
jmp 0x24c75
jmp 0x24cb2
movq 0x130(%rsp), %rax
cmpl $0x0, (%rax)
jle 0x24cb0
movq 0x130(%rsp), %rax
movslq (%rax), %rcx
leaq 0x2263a(%rip), %rax     # 0x472d0
movl (%rax,%rcx,4), %edx
leaq 0x22b49(%rip), %rsi     # 0x477e9
xorl %eax, %eax
movl $0x2, %edi
callq 0x3a770
jmp 0x24cae
jmp 0x24cb0
jmp 0x24cb2
leaq 0x21d34(%rip), %rsi     # 0x469ed
xorl %eax, %eax
movl $0x2, %edi
callq 0x3a770
jmp 0x24cc7
jmp 0x24cc9
movq 0x2c8(%rsp), %rdi
callq 0x25410
movq %rax, 0x70(%rsp)
jmp 0x24cdd
movq 0x70(%rsp), %rdx
leaq 0x22b0f(%rip), %rsi     # 0x477f8
xorl %eax, %eax
movl $0x7, %edi
callq 0x3a770
jmp 0x24cf7
movq 0x2c8(%rsp), %rdi
callq 0x25360
movl %eax, 0x6c(%rsp)
jmp 0x24d0a
movl 0x6c(%rsp), %eax
movl %eax, 0x180(%rsp)
movl 0x180(%rsp), %edx
leaq 0x22b49(%rip), %rsi     # 0x4786c
xorl %eax, %eax
movl $0x2, %edi
callq 0x3a770
jmp 0x24d31
movl $0x0, 0x17c(%rsp)
movl 0x17c(%rsp), %eax
cmpl 0x180(%rsp), %eax
jge 0x24ffc
movq 0x2c8(%rsp), %rdi
callq 0x25360
movl %eax, 0x68(%rsp)
jmp 0x24d63
movl 0x68(%rsp), %eax
movl %eax, 0x178(%rsp)
movl 0x178(%rsp), %esi
andl $0xf, %esi
leaq 0x158(%rsp), %rdi
callq 0x259f0
jmp 0x24d87
leaq 0x158(%rsp), %rdi
callq 0x20d20
movb %al, 0x67(%rsp)
jmp 0x24d9a
movb 0x67(%rsp), %al
testb $0x1, %al
jne 0x24da7
jmp 0x24e4f
movl 0x178(%rsp), %eax
sarl $0x4, %eax
movl %eax, 0x154(%rsp)
movl $0x0, 0x150(%rsp)
movl 0x150(%rsp), %eax
cmpl 0x154(%rsp), %eax
jge 0x24e4d
leaq 0x160(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x2c8(%rsp), %rdi
callq 0x25360
movl %eax, 0x60(%rsp)
jmp 0x24df3
movq 0x58(%rsp), %rdi
movl 0x60(%rsp), %eax
movl %eax, 0x14c(%rsp)
leaq 0x14c(%rsp), %rsi
callq 0x121b0
jmp 0x24e12
jmp 0x24e14
movl 0x150(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x150(%rsp)
jmp 0x24dc3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x270(%rsp)
movl %eax, 0x26c(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x4b60
jmp 0x252e9
jmp 0x24e4f
movq 0x130(%rsp), %rax
testb $0x1, 0x4(%rax)
jne 0x24e91
movq 0x2c0(%rsp), %rsi
leaq 0x158(%rsp), %rdi
callq 0x11f60
jmp 0x24e74
movq 0x2c0(%rsp), %rdi
addq $0x18, %rdi
leaq 0x158(%rsp), %rsi
callq 0x4be0
jmp 0x24e8f
jmp 0x24e91
cmpl $0x0, 0x17c(%rsp)
je 0x24eb2
leaq 0x21de3(%rip), %rsi     # 0x46c85
xorl %eax, %eax
movl $0x2, %edi
callq 0x3a770
jmp 0x24eb0
jmp 0x24eb2
leaq 0x158(%rsp), %rdi
callq 0x4b10
movq %rax, 0x50(%rsp)
jmp 0x24ec6
movq 0x50(%rsp), %rdx
leaq 0x229c4(%rip), %rsi     # 0x47896
xorl %eax, %eax
movl $0x2, %edi
callq 0x3a770
jmp 0x24ee0
cmpl $0x6, 0x158(%rsp)
jne 0x24fd9
leaq 0x158(%rsp), %rdi
addq $0x8, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x12190
movl (%rax), %eax
movl %eax, 0x4c(%rsp)
leaq 0x158(%rsp), %rdi
addq $0x8, %rdi
movl $0x1, %esi
callq 0x12190
movq %rax, %rcx
movl 0x4c(%rsp), %eax
cmpl (%rcx), %eax
jne 0x24f5d
leaq 0x160(%rsp), %rdi
xorl %eax, %eax
movl %eax, 0x48(%rsp)
movl %eax, %esi
callq 0x12190
movq %rax, %rcx
movl 0x48(%rsp), %eax
movl (%rcx), %edx
leaq 0x2294a(%rip), %rsi     # 0x47899
movl $0x3, %edi
callq 0x3a770
jmp 0x24f5b
jmp 0x24fae
leaq 0x160(%rsp), %rdi
movq %rdi, 0x38(%rsp)
xorl %eax, %eax
movl %eax, 0x44(%rsp)
movl %eax, %esi
callq 0x12190
movq 0x38(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x40(%rsp)
movl $0x1, %esi
callq 0x12190
movl 0x40(%rsp), %edx
movq %rax, %rcx
movl 0x44(%rsp), %eax
movl (%rcx), %ecx
leaq 0x22911(%rip), %rsi     # 0x478b1
movl $0x3, %edi
callq 0x3a770
jmp 0x24fac
jmp 0x24fae
leaq 0x160(%rsp), %rdi
movl $0x2, %esi
callq 0x12190
movl (%rax), %edx
leaq 0x228fe(%rip), %rsi     # 0x478c7
xorl %eax, %eax
movl $0x3, %edi
callq 0x3a770
jmp 0x24fd7
jmp 0x24fd9
leaq 0x158(%rsp), %rdi
callq 0x4b60
movl 0x17c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x17c(%rsp)
jmp 0x24d3c
leaq 0x238aa(%rip), %rsi     # 0x488ad
xorl %eax, %eax
movl $0x2, %edi
callq 0x3a770
jmp 0x25011
movq 0x2c8(%rsp), %rdi
callq 0x25410
movq %rax, 0x30(%rsp)
jmp 0x25025
movq 0x30(%rsp), %rdx
leaq 0x228a1(%rip), %rsi     # 0x478d2
xorl %eax, %eax
movl $0x6, %edi
callq 0x3a770
jmp 0x2503f
movq 0x130(%rsp), %rax
testb $0x1, 0x4(%rax)
je 0x25065
movb $0x1, 0x2d7(%rsp)
movl $0x1, 0x1a4(%rsp)
jmp 0x252da
movq 0x2c0(%rsp), %rax
testb $0x1, 0xa8(%rax)
je 0x2509e
leaq 0x2287c(%rip), %rdi     # 0x478f9
xorl %eax, %eax
callq 0x3a670
jmp 0x25086
movb $0x0, 0x2d7(%rsp)
movl $0x1, 0x1a4(%rsp)
jmp 0x252da
movq 0x2c0(%rsp), %rdi
callq 0x4b80
movq %rax, %rcx
movq 0x130(%rsp), %rax
movl %ecx, 0x2ac(%rsp)
movq $0x0, 0x140(%rsp)
cmpl $0x0, (%rax)
jl 0x250e9
movq 0x130(%rsp), %rax
movslq (%rax), %rax
movslq 0x190(%rsp,%rax,4), %rax
movq %rax, 0x140(%rsp)
movl $0x0, 0x13c(%rsp)
movl 0x13c(%rsp), %eax
cmpl 0x2ac(%rsp), %eax
jge 0x25299
movq 0x130(%rsp), %rax
cmpl $0x0, (%rax)
jl 0x2513c
movq 0x2c8(%rsp), %rdi
callq 0x25410
movq %rax, 0x28(%rsp)
jmp 0x25129
movq 0x28(%rsp), %rax
cmpq 0x140(%rsp), %rax
jae 0x2525a
movq 0x2c8(%rsp), %rdi
callq 0x25a20
movb %al, 0x27(%rsp)
jmp 0x2514f
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x2525a
jmp 0x2515d
movq 0x2c0(%rsp), %rdi
movslq 0x13c(%rsp), %rsi
callq 0x4ba0
cmpl $0x0, 0x18(%rax)
je 0x25193
movq 0x2c0(%rsp), %rdi
movslq 0x13c(%rsp), %rsi
callq 0x4ba0
cmpl $0x0, 0x1c(%rax)
jne 0x25198
jmp 0x25283
movq 0x130(%rsp), %rsi
movq 0x2c8(%rsp), %rdi
movq 0x2c0(%rsp), %rcx
movq 0x140(%rsp), %r8
leaq 0x13c(%rsp), %rdx
callq 0x25a40
movb %al, 0x26(%rsp)
jmp 0x251cb
movb 0x26(%rsp), %al
testb $0x1, %al
jne 0x251ed
jmp 0x251d5
movb $0x0, 0x2d7(%rsp)
movl $0x1, 0x1a4(%rsp)
jmp 0x252da
movq 0x2c0(%rsp), %rdi
addq $0x18, %rdi
callq 0x4a70
cmpq $0x0, %rax
jbe 0x25258
movq 0x2c0(%rsp), %rdi
addq $0x18, %rdi
callq 0x4a90
cmpl $0x9, (%rax)
jne 0x25258
movq 0x2c0(%rsp), %rdi
addq $0x18, %rdi
callq 0x4a90
movq %rax, %rdi
addq $0x8, %rdi
callq 0x4d50
cmpq $0x0, %rax
jne 0x25258
cmpl $0x0, 0x13c(%rsp)
jne 0x25258
movq 0x2c0(%rsp), %rdi
callq 0x1ef50
jmp 0x25256
jmp 0x25258
jmp 0x25281
movl 0x13c(%rsp), %edx
movl 0x2ac(%rsp), %ecx
decl %ecx
leaq 0x226a1(%rip), %rsi     # 0x47912
xorl %eax, %eax
movl $0x3, %edi
callq 0x3a770
jmp 0x2527f
jmp 0x25299
jmp 0x25283
movl 0x13c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x13c(%rsp)
jmp 0x250f4
movq 0x2c8(%rsp), %rdi
callq 0x25410
movq %rax, 0x18(%rsp)
jmp 0x252ad
movq 0x18(%rsp), %rdx
leaq 0x2267d(%rip), %rsi     # 0x47936
xorl %eax, %eax
movl $0x3, %edi
callq 0x3a770
jmp 0x252c7
movb $0x1, 0x2d7(%rsp)
movl $0x1, 0x1a4(%rsp)
leaq 0x278(%rsp), %rdi
callq 0x54f0
jmp 0x252f8
leaq 0x278(%rsp), %rdi
callq 0x54f0
jmp 0x25309
movb 0x2d7(%rsp), %al
andb $0x1, %al
addq $0x2d8, %rsp            # imm = 0x2D8
retq
movq 0x270(%rsp), %rdi
callq 0x36a0
nopw %cs:(%rax,%rax)