// File: cloudinary[P]fuif/transform/2dmatch.h
// Function: fwd_match(Image&, std::vector<int, std::allocator<int>>&)
bool fwd_match(Image &input, std::vector<int> &parameters) {
    std::vector<int> adj_params = parameters; // use a copy so empty (default) parameters remain empty
    meta_match(input, adj_params);
    int c0 = input.nb_meta_channels + adj_params[0];
    int cn = input.nb_meta_channels + adj_params[1];
    if (c0 >= input.channel.size() || cn >= input.channel.size()) {
        e_printf("Error: match transform with incorrect parameters.\n");
        return false;
    }
    int maxdist = 10000, erodes = 1;
    if (adj_params.size() > 3) maxdist = adj_params[3];
    if (adj_params[0] == 0 && adj_params[1] == input.nb_channels-1 && adj_params[2] == 0) parameters.clear(); // we can use default parameters
    if (parameters.size() > 3) parameters.pop_back();
    bool softmatch = adj_params[2];
    Channel &m = input.channel[0];
    int w = input.channel[c0].w;
    int h = input.channel[c0].h;

    if (maxdist > 0) {
      v_printf(5,"Running heuristic to find matches (channels %i-%i)\n",c0,cn);
      offsets ot(maxdist + 1);
      make_offsets_table(ot);
      for (int y=0; y<h; y++) {
        if (y%10 == 0) v_printf(7,"Finding matches at row %i\n",y);
        for (int x=0; x<w; x++) {
            if (m.value(y,x)) continue;
            pixel_type z = find_good_match(input,c0,cn,x,y,ot);
            if (!z) continue;
            int count=0;
            for (int yy=0; y+yy<h; yy++) {
                int xl=0;
                for (; x+xl>=0; xl--) {
                    if (matches(input,c0,cn,x+xl,y+yy,z,ot,false)) {
                        if (m.value(y+yy,x+xl) == 0 || m.value(y+yy,x+xl) > z)
                        { m.value(y+yy,x+xl) = z; count++; }
                    }
                    else break;
                }
                xl++;
                int xr=1;
                for (; x+xr<w; xr++) {
                    if (matches(input,c0,cn,x+xr,y+yy,z,ot,false)) {
                        if (m.value(y+yy,x+xr) == 0 || m.value(y+yy,x+xr) > z)
                        { m.value(y+yy,x+xr) = z; count++; }
                    }
                    else break;
                }
                xr--;
                if (!xl && !xr) break;
            }
            v_printf(8,"Matched %i pixels from seed position (%i,%i)\n",count,x,y);
        }
      }
      for (int y=h-1; y>=0; y--) {
        for (int x=w-1; x>=0; x--) {
            if (m.value(y,x)) do_match(input,c0,cn,x,y,m.value(y,x),ot);
        }
      }
    } else {
      if (input.nb_frames < 2) {
        e_printf("This transform is meant for animations only.\n");
        return false;
      }
      v_printf(5,"Running simple heuristic to find matches from previous frames (channels %i-%i)\n",c0,cn);
      int fh = h / input.nb_frames;
      int offsetcode = 2*fh*fh + (fh&1); // this simple formula corresponds to the code to go exactly one frame up
      m.q = offsetcode;
      int minmatchcount = CLAMP(w/50,5,40); // arbitrary threshold

      for (int n=1; n <= -maxdist; n++)
      for (int y=n*fh; y<h; y++) {
        int matchcount=0;  // to reduce entropy in the match channel, only consider it a match if it matches enough pixels in a row
        bool firstmatch=true;
        for (int x=0; x<w; x++) {
            if (m.value(y,x)) continue;
            bool nomatch = false;
            for (int c=c0; c<=cn; c++)
                if (input.channel[c].value(y,x) != input.channel[c].value(y-n*fh,x)) nomatch=true;
            if (nomatch) { matchcount=0; firstmatch=true; continue; }
            matchcount++;
            if (matchcount >= minmatchcount) {
                if (firstmatch) {
                    for (int prev_x = x-matchcount+1; prev_x < x; prev_x++) {
                        m.value(y,prev_x) = n;
                    }
                }
                firstmatch=false;
                m.value(y,x) = n; // quantization multiplies this by offsetcode;
            }
        }
      }

      // vertical-only erode
/*
      for (int y=fh; y<=h; y++) {
        if (y<h) for (int x=0; x<w; x++) {
            if (m.value(y,x) > 0) {
                if (m.value(y-1,x) == 0
                    && (y+1<h && m.value(y+1,x) == 0)
                ) m.value(y,x) = -m.value(y,x); // if top and bottom are zero, flag this one
            }
        }
        for (int x=0; x<w; x++) {
            if (m.value(y-1,x) < 0) m.value(y-1,x) = 0;
        }
      }
*/

     // simple erode, reduces entropy and helps to avoid lossy artifacts accumulating at the edges

    for (int it=0; it<3; it++)
      for (int y=fh; y<=h; y++) {
        if (y<h) for (int x=0; x<w; x++) {
            if (m.value(y,x) > 0) {
                if (m.value(y-1,x) == 0
                    || (x>0 && m.value(y,x-1) == 0)
                    || (y+1<h && m.value(y+1,x) <= 0)
                    || (x+1<w && m.value(y,x+1) <= 0)
                ) m.value(y,x) = -m.value(y,x); // if any neighbor is zero, flag this one
            }
        }
//        for (int x=0; x<w; x++) {
//            if (m.value(y-1,x) < 0) m.value(y-1,x) = 0;
//        }
      }


      for (int y=fh; y<h; y++) {
        for (int x=0; x<w; x++) {
            if (m.value(y,x) > 0)
                for (int c=c0; c<=cn; c++)
                    input.channel[c].value(y,x) = 0;
            else if (m.value(y,x) < 0) m.value(y,x) *= -1;
        }
      }

    }
    return true;
}

// Assembly:
subq $0x258, %rsp            # imm = 0x258
movq %rdi, 0x248(%rsp)
movq %rsi, 0x240(%rsp)
movq 0x240(%rsp), %rsi
leaq 0x228(%rsp), %rdi
movq %rdi, 0x160(%rsp)
callq 0x4c50
movq 0x160(%rsp), %rsi
movq 0x248(%rsp), %rdi
callq 0xecc0
jmp 0xf51b
movq 0x248(%rsp), %rax
movl 0x6c(%rax), %eax
movl %eax, 0x150(%rsp)
leaq 0x228(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x12190
movq %rax, %rcx
movl 0x150(%rsp), %eax
addl (%rcx), %eax
movl %eax, 0x218(%rsp)
movq 0x248(%rsp), %rax
movl 0x6c(%rax), %eax
movl %eax, 0x154(%rsp)
leaq 0x228(%rsp), %rdi
movl $0x1, %esi
callq 0x12190
movq %rax, %rcx
movl 0x154(%rsp), %eax
addl (%rcx), %eax
movl %eax, 0x214(%rsp)
movslq 0x218(%rsp), %rax
movq %rax, 0x158(%rsp)
movq 0x248(%rsp), %rdi
callq 0x4b80
movq %rax, %rcx
movq 0x158(%rsp), %rax
cmpq %rcx, %rax
jae 0xf5e2
movslq 0x214(%rsp), %rax
movq %rax, 0x148(%rsp)
movq 0x248(%rsp), %rdi
callq 0x4b80
movq %rax, %rcx
movq 0x148(%rsp), %rax
cmpq %rcx, %rax
jb 0xf623
leaq 0x3773e(%rip), %rdi     # 0x46d27
xorl %eax, %eax
callq 0x3a670
jmp 0xf5f2
movb $0x0, 0x257(%rsp)
movl $0x1, 0x210(%rsp)
jmp 0x106e7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x220(%rsp)
movl %eax, 0x21c(%rsp)
jmp 0x10705
movl $0x2710, 0x20c(%rsp) # imm = 0x2710
movl $0x1, 0x208(%rsp)
leaq 0x228(%rsp), %rdi
callq 0x4d50
cmpq $0x3, %rax
jbe 0xf667
leaq 0x228(%rsp), %rdi
movl $0x3, %esi
callq 0x12190
movl (%rax), %eax
movl %eax, 0x20c(%rsp)
leaq 0x228(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x12190
cmpl $0x0, (%rax)
jne 0xf6c7
leaq 0x228(%rsp), %rdi
movl $0x1, %esi
callq 0x12190
movl (%rax), %eax
movq 0x248(%rsp), %rcx
movl 0x64(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0xf6c7
leaq 0x228(%rsp), %rdi
movl $0x2, %esi
callq 0x12190
cmpl $0x0, (%rax)
jne 0xf6c7
movq 0x240(%rsp), %rdi
callq 0x121e0
movq 0x240(%rsp), %rdi
callq 0x4d50
cmpq $0x3, %rax
jbe 0xf6e7
movq 0x240(%rsp), %rdi
callq 0x13540
leaq 0x228(%rsp), %rdi
movl $0x2, %esi
callq 0x12190
cmpl $0x0, (%rax)
setne %al
andb $0x1, %al
movb %al, 0x207(%rsp)
movq 0x248(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x4ba0
movq %rax, 0x1f8(%rsp)
movq 0x248(%rsp), %rdi
movslq 0x218(%rsp), %rsi
callq 0x4ba0
movl 0x18(%rax), %eax
movl %eax, 0x1f4(%rsp)
movq 0x248(%rsp), %rdi
movslq 0x218(%rsp), %rsi
callq 0x4ba0
movl 0x1c(%rax), %eax
movl %eax, 0x1f0(%rsp)
cmpl $0x0, 0x20c(%rsp)
jle 0xfee3
movl 0x218(%rsp), %edx
movl 0x214(%rsp), %ecx
leaq 0x3766b(%rip), %rsi     # 0x46ded
xorl %eax, %eax
movl $0x5, %edi
callq 0x3a770
jmp 0xf790
movl 0x20c(%rsp), %eax
incl %eax
cltq
movq %rax, 0x138(%rsp)
leaq 0x1d7(%rsp), %rdi
movq %rdi, 0x140(%rsp)
callq 0x13440
movq 0x138(%rsp), %rsi
movq 0x140(%rsp), %rdx
leaq 0x1d8(%rsp), %rdi
callq 0x13450
jmp 0xf7d7
leaq 0x1d7(%rsp), %rdi
callq 0x134d0
leaq 0x1d8(%rsp), %rdi
callq 0xe1d0
movl $0x0, 0x1d0(%rsp)
movl 0x1d0(%rsp), %eax
cmpl 0x1f0(%rsp), %eax
jge 0xfd85
movl 0x1d0(%rsp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0xf88e
movl 0x1d0(%rsp), %edx
leaq 0x375ef(%rip), %rsi     # 0x46e21
xorl %eax, %eax
movl $0x7, %edi
callq 0x3a770
jmp 0xf840
jmp 0xf88e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x220(%rsp)
movl %eax, 0x21c(%rsp)
leaq 0x1d7(%rsp), %rdi
callq 0x134d0
jmp 0x10705
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x220(%rsp)
movl %eax, 0x21c(%rsp)
leaq 0x1d8(%rsp), %rdi
callq 0x134e0
jmp 0x10705
movl $0x0, 0x1cc(%rsp)
movl 0x1cc(%rsp), %eax
cmpl 0x1f4(%rsp), %eax
jge 0xfd6d
movq 0x1f8(%rsp), %rdi
movl 0x1d0(%rsp), %esi
movl 0x1cc(%rsp), %edx
callq 0x12110
movq %rax, 0x130(%rsp)
jmp 0xf8d2
movq 0x130(%rsp), %rax
cmpw $0x0, (%rax)
je 0xf8e5
jmp 0xfd57
movq 0x248(%rsp), %rdi
movl 0x218(%rsp), %esi
movl 0x214(%rsp), %edx
movl 0x1cc(%rsp), %ecx
movl 0x1d0(%rsp), %r8d
leaq 0x1d8(%rsp), %r9
callq 0xf170
movw %ax, 0x12e(%rsp)
jmp 0xf921
movw 0x12e(%rsp), %ax
movw %ax, 0x1ca(%rsp)
cmpw $0x0, 0x1ca(%rsp)
jne 0xf941
jmp 0xfd57
movl $0x0, 0x1c4(%rsp)
movl $0x0, 0x1c0(%rsp)
movl 0x1d0(%rsp), %eax
addl 0x1c0(%rsp), %eax
cmpl 0x1f0(%rsp), %eax
jge 0xfd2a
movl $0x0, 0x1bc(%rsp)
movl 0x1cc(%rsp), %eax
addl 0x1bc(%rsp), %eax
cmpl $0x0, %eax
jl 0xfb24
movq 0x248(%rsp), %rdi
movl 0x218(%rsp), %esi
movl 0x214(%rsp), %edx
movl 0x1cc(%rsp), %ecx
movl 0x1bc(%rsp), %eax
addl %eax, %ecx
movl 0x1d0(%rsp), %r8d
movl 0x1c0(%rsp), %eax
addl %eax, %r8d
movswl 0x1ca(%rsp), %r9d
movq %rsp, %rax
leaq 0x1d8(%rsp), %r10
movq %r10, (%rax)
movl $0x0, 0x8(%rax)
callq 0xef00
movb %al, 0x12d(%rsp)
jmp 0xf9f8
movb 0x12d(%rsp), %al
testb $0x1, %al
jne 0xfa08
jmp 0xfb0a
movq 0x1f8(%rsp), %rdi
movl 0x1d0(%rsp), %esi
movl 0x1c0(%rsp), %eax
addl %eax, %esi
movl 0x1cc(%rsp), %edx
movl 0x1bc(%rsp), %eax
addl %eax, %edx
callq 0x12110
movq %rax, 0x120(%rsp)
jmp 0xfa3f
movq 0x120(%rsp), %rax
movswl (%rax), %eax
cmpl $0x0, %eax
je 0xfa9d
movq 0x1f8(%rsp), %rdi
movl 0x1d0(%rsp), %esi
movl 0x1c0(%rsp), %eax
addl %eax, %esi
movl 0x1cc(%rsp), %edx
movl 0x1bc(%rsp), %eax
addl %eax, %edx
callq 0x12110
movq %rax, 0x118(%rsp)
jmp 0xfa86
movq 0x118(%rsp), %rax
movswl (%rax), %eax
movswl 0x1ca(%rsp), %ecx
cmpl %ecx, %eax
jle 0xfb08
movw 0x1ca(%rsp), %ax
movw %ax, 0x10e(%rsp)
movq 0x1f8(%rsp), %rdi
movl 0x1d0(%rsp), %esi
movl 0x1c0(%rsp), %eax
addl %eax, %esi
movl 0x1cc(%rsp), %edx
movl 0x1bc(%rsp), %eax
addl %eax, %edx
callq 0x12110
movq %rax, 0x110(%rsp)
jmp 0xfae4
movq 0x110(%rsp), %rax
movw 0x10e(%rsp), %cx
movw %cx, (%rax)
movl 0x1c4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c4(%rsp)
jmp 0xfb0c
jmp 0xfb24
jmp 0xfb0e
movl 0x1bc(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x1bc(%rsp)
jmp 0xf97d
movl 0x1bc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1bc(%rsp)
movl $0x1, 0x1b8(%rsp)
movl 0x1cc(%rsp), %eax
addl 0x1b8(%rsp), %eax
cmpl 0x1f4(%rsp), %eax
jge 0xfceb
movq 0x248(%rsp), %rdi
movl 0x218(%rsp), %esi
movl 0x214(%rsp), %edx
movl 0x1cc(%rsp), %ecx
movl 0x1b8(%rsp), %eax
addl %eax, %ecx
movl 0x1d0(%rsp), %r8d
movl 0x1c0(%rsp), %eax
addl %eax, %r8d
movswl 0x1ca(%rsp), %r9d
movq %rsp, %rax
leaq 0x1d8(%rsp), %r10
movq %r10, (%rax)
movl $0x0, 0x8(%rax)
callq 0xef00
movb %al, 0x10d(%rsp)
jmp 0xfbbf
movb 0x10d(%rsp), %al
testb $0x1, %al
jne 0xfbcf
jmp 0xfcd1
movq 0x1f8(%rsp), %rdi
movl 0x1d0(%rsp), %esi
movl 0x1c0(%rsp), %eax
addl %eax, %esi
movl 0x1cc(%rsp), %edx
movl 0x1b8(%rsp), %eax
addl %eax, %edx
callq 0x12110
movq %rax, 0x100(%rsp)
jmp 0xfc06
movq 0x100(%rsp), %rax
movswl (%rax), %eax
cmpl $0x0, %eax
je 0xfc64
movq 0x1f8(%rsp), %rdi
movl 0x1d0(%rsp), %esi
movl 0x1c0(%rsp), %eax
addl %eax, %esi
movl 0x1cc(%rsp), %edx
movl 0x1b8(%rsp), %eax
addl %eax, %edx
callq 0x12110
movq %rax, 0xf8(%rsp)
jmp 0xfc4d
movq 0xf8(%rsp), %rax
movswl (%rax), %eax
movswl 0x1ca(%rsp), %ecx
cmpl %ecx, %eax
jle 0xfccf
movw 0x1ca(%rsp), %ax
movw %ax, 0xee(%rsp)
movq 0x1f8(%rsp), %rdi
movl 0x1d0(%rsp), %esi
movl 0x1c0(%rsp), %eax
addl %eax, %esi
movl 0x1cc(%rsp), %edx
movl 0x1b8(%rsp), %eax
addl %eax, %edx
callq 0x12110
movq %rax, 0xf0(%rsp)
jmp 0xfcab
movq 0xf0(%rsp), %rax
movw 0xee(%rsp), %cx
movw %cx, (%rax)
movl 0x1c4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c4(%rsp)
jmp 0xfcd3
jmp 0xfceb
jmp 0xfcd5
movl 0x1b8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1b8(%rsp)
jmp 0xfb40
movl 0x1b8(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x1b8(%rsp)
cmpl $0x0, 0x1bc(%rsp)
jne 0xfd12
cmpl $0x0, 0x1b8(%rsp)
jne 0xfd12
jmp 0xfd2a
jmp 0xfd14
movl 0x1c0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c0(%rsp)
jmp 0xf957
movl 0x1c4(%rsp), %edx
movl 0x1cc(%rsp), %ecx
movl 0x1d0(%rsp), %r8d
leaq 0x370f5(%rip), %rsi     # 0x46e3c
xorl %eax, %eax
movl $0x8, %edi
callq 0x3a770
jmp 0xfd55
jmp 0xfd57
movl 0x1cc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1cc(%rsp)
jmp 0xf899
jmp 0xfd6f
movl 0x1d0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1d0(%rsp)
jmp 0xf7fc
movl 0x1f0(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x1b4(%rsp)
cmpl $0x0, 0x1b4(%rsp)
jl 0xfed1
movl 0x1f4(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x1b0(%rsp)
cmpl $0x0, 0x1b0(%rsp)
jl 0xfeb9
movq 0x1f8(%rsp), %rdi
movl 0x1b4(%rsp), %esi
movl 0x1b0(%rsp), %edx
callq 0x12110
movq %rax, 0xe0(%rsp)
jmp 0xfde8
movq 0xe0(%rsp), %rax
cmpw $0x0, (%rax)
je 0xfea1
movq 0x248(%rsp), %rax
movq %rax, 0xc0(%rsp)
movl 0x218(%rsp), %eax
movl %eax, 0xc8(%rsp)
movl 0x214(%rsp), %eax
movl %eax, 0xcc(%rsp)
movl 0x1b0(%rsp), %edx
movl %edx, 0xd0(%rsp)
movl 0x1b4(%rsp), %esi
movl %esi, 0xd4(%rsp)
movq 0x1f8(%rsp), %rdi
callq 0x12110
movq %rax, 0xd8(%rsp)
jmp 0xfe59
movl 0xd4(%rsp), %r8d
movl 0xd0(%rsp), %ecx
movl 0xcc(%rsp), %edx
movl 0xc8(%rsp), %esi
movq 0xc0(%rsp), %rdi
movq 0xd8(%rsp), %rax
movswl (%rax), %r9d
movq %rsp, %rax
leaq 0x1d8(%rsp), %r10
movq %r10, (%rax)
callq 0xf080
jmp 0xfe9f
jmp 0xfea1
jmp 0xfea3
movl 0x1b0(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x1b0(%rsp)
jmp 0xfdb5
jmp 0xfebb
movl 0x1b4(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x1b4(%rsp)
jmp 0xfd96
leaq 0x1d8(%rsp), %rdi
callq 0x134e0
jmp 0x106d4
movq 0x248(%rsp), %rax
cmpl $0x2, 0x38(%rax)
jge 0xff19
leaq 0x36f72(%rip), %rdi     # 0x46e6a
xorl %eax, %eax
callq 0x3a670
jmp 0xff01
movb $0x0, 0x257(%rsp)
movl $0x1, 0x210(%rsp)
jmp 0x106e7
movl 0x218(%rsp), %edx
movl 0x214(%rsp), %ecx
leaq 0x36f6a(%rip), %rsi     # 0x46e98
xorl %eax, %eax
movl $0x5, %edi
callq 0x3a770
jmp 0xff3c
movl 0x1f0(%rsp), %eax
movq 0x248(%rsp), %rcx
cltd
idivl 0x38(%rcx)
movl %eax, 0x1ac(%rsp)
movl 0x1ac(%rsp), %eax
shll %eax
imull 0x1ac(%rsp), %eax
movl 0x1ac(%rsp), %ecx
andl $0x1, %ecx
addl %ecx, %eax
movl %eax, 0x1a8(%rsp)
movl 0x1a8(%rsp), %ecx
movq 0x1f8(%rsp), %rax
movl %ecx, 0x28(%rax)
movl 0x1f4(%rsp), %eax
movl $0x32, %ecx
cltd
idivl %ecx
cmpl $0x5, %eax
jge 0xffae
movl $0x5, %eax
movl %eax, 0xbc(%rsp)
jmp 0xfff4
movl 0x1f4(%rsp), %eax
movl $0x32, %ecx
cltd
idivl %ecx
cmpl $0x28, %eax
jle 0xffd0
movl $0x28, %eax
movl %eax, 0xb8(%rsp)
jmp 0xffe6
movl 0x1f4(%rsp), %eax
movl $0x32, %ecx
cltd
idivl %ecx
movl %eax, 0xb8(%rsp)
movl 0xb8(%rsp), %eax
movl %eax, 0xbc(%rsp)
movl 0xbc(%rsp), %eax
movl %eax, 0x1a4(%rsp)
movl $0x1, 0x1a0(%rsp)
movl 0x1a0(%rsp), %eax
xorl %ecx, %ecx
subl 0x20c(%rsp), %ecx
cmpl %ecx, %eax
jg 0x10314
movl 0x1a0(%rsp), %eax
imull 0x1ac(%rsp), %eax
movl %eax, 0x19c(%rsp)
movl 0x19c(%rsp), %eax
cmpl 0x1f0(%rsp), %eax
jge 0x102fc
movl $0x0, 0x198(%rsp)
movb $0x1, 0x197(%rsp)
movl $0x0, 0x190(%rsp)
movl 0x190(%rsp), %eax
cmpl 0x1f4(%rsp), %eax
jge 0x102e4
movq 0x1f8(%rsp), %rdi
movl 0x19c(%rsp), %esi
movl 0x190(%rsp), %edx
callq 0x12110
movq %rax, 0xb0(%rsp)
jmp 0x100a6
movq 0xb0(%rsp), %rax
cmpw $0x0, (%rax)
je 0x100b9
jmp 0x102ce
movb $0x0, 0x18f(%rsp)
movl 0x218(%rsp), %eax
movl %eax, 0x188(%rsp)
movl 0x188(%rsp), %eax
cmpl 0x214(%rsp), %eax
jg 0x101a8
movq 0x248(%rsp), %rdi
movslq 0x188(%rsp), %rsi
callq 0x4ba0
movq %rax, %rdi
movl 0x19c(%rsp), %esi
movl 0x190(%rsp), %edx
callq 0x12110
movq %rax, 0xa8(%rsp)
jmp 0x10118
movq 0xa8(%rsp), %rax
movswl (%rax), %eax
movl %eax, 0x9c(%rsp)
movq 0x248(%rsp), %rdi
movslq 0x188(%rsp), %rsi
callq 0x4ba0
movq %rax, %rdi
movl 0x19c(%rsp), %esi
movl 0x1a0(%rsp), %eax
movl 0x1ac(%rsp), %ecx
imull %ecx, %eax
subl %eax, %esi
movl 0x190(%rsp), %edx
callq 0x12110
movq %rax, 0xa0(%rsp)
jmp 0x10172
movl 0x9c(%rsp), %eax
movq 0xa0(%rsp), %rcx
movswl (%rcx), %ecx
cmpl %ecx, %eax
je 0x10190
movb $0x1, 0x18f(%rsp)
jmp 0x10192
movl 0x188(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x188(%rsp)
jmp 0x100cf
testb $0x1, 0x18f(%rsp)
je 0x101ca
movl $0x0, 0x198(%rsp)
movb $0x1, 0x197(%rsp)
jmp 0x102ce
movl 0x198(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x198(%rsp)
movl 0x198(%rsp), %eax
cmpl 0x1a4(%rsp), %eax
jl 0x102cc
testb $0x1, 0x197(%rsp)
je 0x10282
movl 0x190(%rsp), %eax
subl 0x198(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x184(%rsp)
movl 0x184(%rsp), %eax
cmpl 0x190(%rsp), %eax
jge 0x10280
movw 0x1a0(%rsp), %ax
movw %ax, 0x8e(%rsp)
movq 0x1f8(%rsp), %rdi
movl 0x19c(%rsp), %esi
movl 0x184(%rsp), %edx
callq 0x12110
movq %rax, 0x90(%rsp)
jmp 0x1025a
movq 0x90(%rsp), %rax
movw 0x8e(%rsp), %cx
movw %cx, (%rax)
movl 0x184(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x184(%rsp)
jmp 0x10215
jmp 0x10282
movb $0x0, 0x197(%rsp)
movw 0x1a0(%rsp), %ax
movw %ax, 0x7e(%rsp)
movq 0x1f8(%rsp), %rdi
movl 0x19c(%rsp), %esi
movl 0x190(%rsp), %edx
callq 0x12110
movq %rax, 0x80(%rsp)
jmp 0x102bc
movq 0x80(%rsp), %rax
movw 0x7e(%rsp), %cx
movw %cx, (%rax)
jmp 0x102ce
movl 0x190(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x190(%rsp)
jmp 0x1006d
jmp 0x102e6
movl 0x19c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x19c(%rsp)
jmp 0x1003b
jmp 0x102fe
movl 0x1a0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1a0(%rsp)
jmp 0x1000d
movl $0x0, 0x180(%rsp)
cmpl $0x3, 0x180(%rsp)
jge 0x10562
movl 0x1ac(%rsp), %eax
movl %eax, 0x17c(%rsp)
movl 0x17c(%rsp), %eax
cmpl 0x1f0(%rsp), %eax
jg 0x1054a
movl 0x17c(%rsp), %eax
cmpl 0x1f0(%rsp), %eax
jge 0x10532
movl $0x0, 0x178(%rsp)
movl 0x178(%rsp), %eax
cmpl 0x1f4(%rsp), %eax
jge 0x10530
movq 0x1f8(%rsp), %rdi
movl 0x17c(%rsp), %esi
movl 0x178(%rsp), %edx
callq 0x12110
movq %rax, 0x70(%rsp)
jmp 0x103a4
movq 0x70(%rsp), %rax
movswl (%rax), %eax
cmpl $0x0, %eax
jle 0x10518
movq 0x1f8(%rsp), %rdi
movl 0x17c(%rsp), %esi
decl %esi
movl 0x178(%rsp), %edx
callq 0x12110
movq %rax, 0x68(%rsp)
jmp 0x103d9
movq 0x68(%rsp), %rax
movswl (%rax), %eax
cmpl $0x0, %eax
je 0x104b5
cmpl $0x0, 0x178(%rsp)
jle 0x10429
movq 0x1f8(%rsp), %rdi
movl 0x17c(%rsp), %esi
movl 0x178(%rsp), %edx
decl %edx
callq 0x12110
movq %rax, 0x60(%rsp)
jmp 0x10418
movq 0x60(%rsp), %rax
movswl (%rax), %eax
cmpl $0x0, %eax
je 0x104b5
movl 0x17c(%rsp), %eax
addl $0x1, %eax
cmpl 0x1f0(%rsp), %eax
jge 0x1046d
movq 0x1f8(%rsp), %rdi
movl 0x17c(%rsp), %esi
incl %esi
movl 0x178(%rsp), %edx
callq 0x12110
movq %rax, 0x58(%rsp)
jmp 0x10460
movq 0x58(%rsp), %rax
movswl (%rax), %eax
cmpl $0x0, %eax
jle 0x104b5
movl 0x178(%rsp), %eax
addl $0x1, %eax
cmpl 0x1f4(%rsp), %eax
jge 0x10516
movq 0x1f8(%rsp), %rdi
movl 0x17c(%rsp), %esi
movl 0x178(%rsp), %edx
incl %edx
callq 0x12110
movq %rax, 0x50(%rsp)
jmp 0x104a8
movq 0x50(%rsp), %rax
movswl (%rax), %eax
cmpl $0x0, %eax
jg 0x10516
movq 0x1f8(%rsp), %rdi
movl 0x17c(%rsp), %esi
movl 0x178(%rsp), %edx
callq 0x12110
movq %rax, 0x48(%rsp)
jmp 0x104d7
movq 0x48(%rsp), %rax
movw (%rax), %ax
negw %ax
movw %ax, 0x3e(%rsp)
movq 0x1f8(%rsp), %rdi
movl 0x17c(%rsp), %esi
movl 0x178(%rsp), %edx
callq 0x12110
movq %rax, 0x40(%rsp)
jmp 0x10509
movq 0x40(%rsp), %rax
movw 0x3e(%rsp), %cx
movw %cx, (%rax)
jmp 0x10518
jmp 0x1051a
movl 0x178(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x178(%rsp)
jmp 0x1036e
jmp 0x10532
jmp 0x10534
movl 0x17c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x17c(%rsp)
jmp 0x1033b
jmp 0x1054c
movl 0x180(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x180(%rsp)
jmp 0x1031f
movl 0x1ac(%rsp), %eax
movl %eax, 0x174(%rsp)
movl 0x174(%rsp), %eax
cmpl 0x1f0(%rsp), %eax
jge 0x106d2
movl $0x0, 0x170(%rsp)
movl 0x170(%rsp), %eax
cmpl 0x1f4(%rsp), %eax
jge 0x106ba
movq 0x1f8(%rsp), %rdi
movl 0x174(%rsp), %esi
movl 0x170(%rsp), %edx
callq 0x12110
movq %rax, 0x30(%rsp)
jmp 0x105c5
movq 0x30(%rsp), %rax
movswl (%rax), %eax
cmpl $0x0, %eax
jle 0x10641
movl 0x218(%rsp), %eax
movl %eax, 0x16c(%rsp)
movl 0x16c(%rsp), %eax
cmpl 0x214(%rsp), %eax
jg 0x1063f
movq 0x248(%rsp), %rdi
movslq 0x16c(%rsp), %rsi
callq 0x4ba0
movq %rax, %rdi
movl 0x174(%rsp), %esi
movl 0x170(%rsp), %edx
callq 0x12110
movq %rax, 0x28(%rsp)
jmp 0x10622
movq 0x28(%rsp), %rax
movw $0x0, (%rax)
movl 0x16c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x16c(%rsp)
jmp 0x105e0
jmp 0x106a2
movq 0x1f8(%rsp), %rdi
movl 0x174(%rsp), %esi
movl 0x170(%rsp), %edx
callq 0x12110
movq %rax, 0x20(%rsp)
jmp 0x10663
movq 0x20(%rsp), %rax
movswl (%rax), %eax
cmpl $0x0, %eax
jge 0x106a0
movq 0x1f8(%rsp), %rdi
movl 0x174(%rsp), %esi
movl 0x170(%rsp), %edx
callq 0x12110
movq %rax, 0x18(%rsp)
jmp 0x10692
movq 0x18(%rsp), %rax
movswl (%rax), %ecx
imull $-0x1, %ecx, %ecx
movw %cx, (%rax)
jmp 0x106a2
jmp 0x106a4
movl 0x170(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x170(%rsp)
jmp 0x1058f
jmp 0x106bc
movl 0x174(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x174(%rsp)
jmp 0x10570
jmp 0x106d4
movb $0x1, 0x257(%rsp)
movl $0x1, 0x210(%rsp)
leaq 0x228(%rsp), %rdi
callq 0x54f0
movb 0x257(%rsp), %al
andb $0x1, %al
addq $0x258, %rsp            # imm = 0x258
retq
leaq 0x228(%rsp), %rdi
callq 0x54f0
movq 0x220(%rsp), %rdi
callq 0x36a0
nop