// File: cloudinary[P]fuif/encoding/context_predict.h
// Function: init_properties(std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>>&, Image const&, int, int, fuif_options&)
void init_properties(Ranges &pr, const Image &image, int beginc, int endc, fuif_options &options) {
    int offset=0;
//    for (int j=beginc-1; j>=image.nb_meta_channels && offset < options.max_properties; j--) {
    for (int j=beginc-1; j>=0 && offset < options.max_properties; j--) {
        if (image.channel[j].minval == image.channel[j].maxval) continue;
        if (image.channel[j].hshift < 0) continue;
        int minval = image.channel[j].minval;
        if (minval > 0) minval = 0;
        int maxval = image.channel[j].maxval;
        if (maxval < 0) maxval = 0;
        pr.push_back(std::pair<PropertyVal,PropertyVal>(0,fooabs((maxval > -minval ? maxval : minval))));
        offset++;
        pr.push_back(std::pair<PropertyVal,PropertyVal>(slog(minval),slog(maxval)));
        offset++;
//        pr.push_back(std::pair<PropertyVal,PropertyVal>(slog(minval-maxval),slog(maxval-minval)));
//        offset++;
    }

    pixel_type minval = LARGEST_VAL;
    pixel_type maxval = SMALLEST_VAL;
    int maxh = 0;
    int maxw = 0;
    for (int j=beginc; j<=endc; j++) {
        if (image.channel[j].minval < minval) minval = image.channel[j].minval;
        if (image.channel[j].maxval > maxval) maxval = image.channel[j].maxval;
        if (image.channel[j].h > maxh) maxh = image.channel[j].h;
        if (image.channel[j].w > maxw) maxw = image.channel[j].w;
    }
    if (minval > 0) minval = 0;
    if (maxval < 0) maxval = 0;

//    printf("range = %i..%i\n",minval,maxval);
    // neighbors
    pr.push_back(std::pair<PropertyVal,PropertyVal>(0,MAX(fooabs(minval),fooabs(maxval))));
    pr.push_back(std::pair<PropertyVal,PropertyVal>(0,MAX(fooabs(minval),fooabs(maxval))));
    pr.push_back(std::pair<PropertyVal,PropertyVal>(slog(minval),slog(maxval)));
    pr.push_back(std::pair<PropertyVal,PropertyVal>(slog(minval),slog(maxval)));

    // location
    pr.push_back(std::pair<PropertyVal,PropertyVal>(0,maxh-1));
    pr.push_back(std::pair<PropertyVal,PropertyVal>(0,maxw-1));

    // blah
    pr.push_back(std::pair<PropertyVal,PropertyVal>(minval+minval-maxval,maxval+maxval-minval));
    pr.push_back(std::pair<PropertyVal,PropertyVal>(minval+minval-maxval,maxval+maxval-minval));

    // FFV1
    pr.push_back(std::pair<PropertyVal,PropertyVal>(slog(minval-maxval),slog(maxval-minval)));
    pr.push_back(std::pair<PropertyVal,PropertyVal>(slog(minval-maxval),slog(maxval-minval)));
    pr.push_back(std::pair<PropertyVal,PropertyVal>(slog(minval-maxval),slog(maxval-minval)));
    pr.push_back(std::pair<PropertyVal,PropertyVal>(slog(minval-maxval),slog(maxval-minval)));
    pr.push_back(std::pair<PropertyVal,PropertyVal>(slog(minval-maxval),slog(maxval-minval)));

}

// Assembly:
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rdi, 0x1b0(%rsp)
movq %rsi, 0x1a8(%rsp)
movl %edx, 0x1a4(%rsp)
movl %ecx, 0x1a0(%rsp)
movq %r8, 0x198(%rsp)
movl $0x0, 0x194(%rsp)
movl 0x1a4(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x190(%rsp)
xorl %eax, %eax
cmpl $0x0, 0x190(%rsp)
movb %al, 0xa7(%rsp)
jl 0x1d018
movl 0x194(%rsp), %eax
movq 0x198(%rsp), %rcx
cmpl 0x10(%rcx), %eax
setl %al
movb %al, 0xa7(%rsp)
movb 0xa7(%rsp), %al
testb $0x1, %al
jne 0x1d028
jmp 0x1d23c
movq 0x1a8(%rsp), %rdi
movslq 0x190(%rsp), %rsi
callq 0x13390
movswl 0x20(%rax), %eax
movl %eax, 0xa0(%rsp)
movq 0x1a8(%rsp), %rdi
movslq 0x190(%rsp), %rsi
callq 0x13390
movq %rax, %rcx
movl 0xa0(%rsp), %eax
movswl 0x22(%rcx), %ecx
cmpl %ecx, %eax
jne 0x1d074
jmp 0x1d226
movq 0x1a8(%rsp), %rdi
movslq 0x190(%rsp), %rsi
callq 0x13390
cmpl $0x0, 0x2c(%rax)
jge 0x1d094
jmp 0x1d226
movq 0x1a8(%rsp), %rdi
movslq 0x190(%rsp), %rsi
callq 0x13390
movswl 0x20(%rax), %eax
movl %eax, 0x18c(%rsp)
cmpl $0x0, 0x18c(%rsp)
jle 0x1d0c9
movl $0x0, 0x18c(%rsp)
movq 0x1a8(%rsp), %rdi
movslq 0x190(%rsp), %rsi
callq 0x13390
movswl 0x22(%rax), %eax
movl %eax, 0x188(%rsp)
cmpl $0x0, 0x188(%rsp)
jge 0x1d0fe
movl $0x0, 0x188(%rsp)
movq 0x1b0(%rsp), %rax
movq %rax, 0x98(%rsp)
movl $0x0, 0x17c(%rsp)
movl 0x188(%rsp), %eax
xorl %ecx, %ecx
subl 0x18c(%rsp), %ecx
cmpl %ecx, %eax
jle 0x1d13d
movl 0x188(%rsp), %eax
movl %eax, 0x94(%rsp)
jmp 0x1d14b
movl 0x18c(%rsp), %eax
movl %eax, 0x94(%rsp)
movl 0x94(%rsp), %eax
movswl %ax, %edi
callq 0x1cf80
movw %ax, 0x17a(%rsp)
leaq 0x180(%rsp), %rdi
leaq 0x17c(%rsp), %rsi
leaq 0x17a(%rsp), %rdx
callq 0x1f670
movq 0x98(%rsp), %rdi
leaq 0x180(%rsp), %rsi
callq 0x1f640
movl 0x194(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x194(%rsp)
movq 0x1b0(%rsp), %rax
movq %rax, 0x88(%rsp)
movl 0x18c(%rsp), %eax
movswl %ax, %edi
callq 0x1f6a0
movw %ax, 0x16e(%rsp)
movl 0x188(%rsp), %eax
movswl %ax, %edi
callq 0x1f6a0
movw %ax, 0x16c(%rsp)
leaq 0x170(%rsp), %rdi
leaq 0x16e(%rsp), %rsi
leaq 0x16c(%rsp), %rdx
callq 0x1f710
movq 0x88(%rsp), %rdi
leaq 0x170(%rsp), %rsi
callq 0x1f640
movl 0x194(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x194(%rsp)
movl 0x190(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x190(%rsp)
jmp 0x1cfe9
movw $0x7fff, 0x16a(%rsp)    # imm = 0x7FFF
movw $0x8001, 0x168(%rsp)    # imm = 0x8001
movl $0x0, 0x164(%rsp)
movl $0x0, 0x160(%rsp)
movl 0x1a4(%rsp), %eax
movl %eax, 0x15c(%rsp)
movl 0x15c(%rsp), %eax
cmpl 0x1a0(%rsp), %eax
jg 0x1d3ac
movq 0x1a8(%rsp), %rdi
movslq 0x15c(%rsp), %rsi
callq 0x13390
movswl 0x20(%rax), %eax
movswl 0x16a(%rsp), %ecx
cmpl %ecx, %eax
jge 0x1d2ce
movq 0x1a8(%rsp), %rdi
movslq 0x15c(%rsp), %rsi
callq 0x13390
movw 0x20(%rax), %ax
movw %ax, 0x16a(%rsp)
movq 0x1a8(%rsp), %rdi
movslq 0x15c(%rsp), %rsi
callq 0x13390
movswl 0x22(%rax), %eax
movswl 0x168(%rsp), %ecx
cmpl %ecx, %eax
jle 0x1d314
movq 0x1a8(%rsp), %rdi
movslq 0x15c(%rsp), %rsi
callq 0x13390
movw 0x22(%rax), %ax
movw %ax, 0x168(%rsp)
movq 0x1a8(%rsp), %rdi
movslq 0x15c(%rsp), %rsi
callq 0x13390
movl 0x1c(%rax), %eax
cmpl 0x164(%rsp), %eax
jle 0x1d354
movq 0x1a8(%rsp), %rdi
movslq 0x15c(%rsp), %rsi
callq 0x13390
movl 0x1c(%rax), %eax
movl %eax, 0x164(%rsp)
movq 0x1a8(%rsp), %rdi
movslq 0x15c(%rsp), %rsi
callq 0x13390
movl 0x18(%rax), %eax
cmpl 0x160(%rsp), %eax
jle 0x1d394
movq 0x1a8(%rsp), %rdi
movslq 0x15c(%rsp), %rsi
callq 0x13390
movl 0x18(%rax), %eax
movl %eax, 0x160(%rsp)
jmp 0x1d396
movl 0x15c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x15c(%rsp)
jmp 0x1d274
movswl 0x16a(%rsp), %eax
cmpl $0x0, %eax
jle 0x1d3c3
movw $0x0, 0x16a(%rsp)
movswl 0x168(%rsp), %eax
cmpl $0x0, %eax
jge 0x1d3da
movw $0x0, 0x168(%rsp)
movq 0x1b0(%rsp), %rax
movq %rax, 0x78(%rsp)
movl $0x0, 0x150(%rsp)
movswl 0x16a(%rsp), %edi
callq 0x1cf80
cwtl
movl %eax, 0x84(%rsp)
movswl 0x168(%rsp), %edi
callq 0x1cf80
movw %ax, %cx
movl 0x84(%rsp), %eax
movswl %cx, %ecx
cmpl %ecx, %eax
jle 0x1d439
movswl 0x16a(%rsp), %edi
callq 0x1cf80
movw %ax, 0x76(%rsp)
jmp 0x1d44b
movswl 0x168(%rsp), %edi
callq 0x1cf80
movw %ax, 0x76(%rsp)
movw 0x76(%rsp), %ax
movw %ax, 0x14e(%rsp)
leaq 0x154(%rsp), %rdi
leaq 0x150(%rsp), %rsi
leaq 0x14e(%rsp), %rdx
callq 0x1f670
movq 0x78(%rsp), %rdi
leaq 0x154(%rsp), %rsi
callq 0x1f640
movq 0x1b0(%rsp), %rax
movq %rax, 0x68(%rsp)
movl $0x0, 0x140(%rsp)
movswl 0x16a(%rsp), %edi
callq 0x1cf80
cwtl
movl %eax, 0x70(%rsp)
movswl 0x168(%rsp), %edi
callq 0x1cf80
movw %ax, %cx
movl 0x70(%rsp), %eax
movswl %cx, %ecx
cmpl %ecx, %eax
jle 0x1d4e0
movswl 0x16a(%rsp), %edi
callq 0x1cf80
movw %ax, 0x66(%rsp)
jmp 0x1d4f2
movswl 0x168(%rsp), %edi
callq 0x1cf80
movw %ax, 0x66(%rsp)
movw 0x66(%rsp), %ax
movw %ax, 0x13e(%rsp)
leaq 0x144(%rsp), %rdi
leaq 0x140(%rsp), %rsi
leaq 0x13e(%rsp), %rdx
callq 0x1f670
movq 0x68(%rsp), %rdi
leaq 0x144(%rsp), %rsi
callq 0x1f640
movq 0x1b0(%rsp), %rax
movq %rax, 0x8(%rsp)
movswl 0x16a(%rsp), %edi
callq 0x1f6a0
movw %ax, 0x132(%rsp)
movswl 0x168(%rsp), %edi
callq 0x1f6a0
movw %ax, 0x130(%rsp)
leaq 0x134(%rsp), %rdi
leaq 0x132(%rsp), %rsi
leaq 0x130(%rsp), %rdx
callq 0x1f710
movq 0x8(%rsp), %rdi
leaq 0x134(%rsp), %rsi
callq 0x1f640
movq 0x1b0(%rsp), %rax
movq %rax, 0x10(%rsp)
movswl 0x16a(%rsp), %edi
callq 0x1f6a0
movw %ax, 0x126(%rsp)
movswl 0x168(%rsp), %edi
callq 0x1f6a0
movw %ax, 0x124(%rsp)
leaq 0x128(%rsp), %rdi
leaq 0x126(%rsp), %rsi
leaq 0x124(%rsp), %rdx
callq 0x1f710
movq 0x10(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x1f640
movq 0x1b0(%rsp), %rax
movq %rax, 0x18(%rsp)
movl $0x0, 0x118(%rsp)
movl 0x164(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x114(%rsp)
leaq 0x11c(%rsp), %rdi
leaq 0x118(%rsp), %rsi
leaq 0x114(%rsp), %rdx
callq 0x1f740
movq 0x18(%rsp), %rdi
leaq 0x11c(%rsp), %rsi
callq 0x1f640
movq 0x1b0(%rsp), %rax
movq %rax, 0x20(%rsp)
movl $0x0, 0x108(%rsp)
movl 0x160(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x104(%rsp)
leaq 0x10c(%rsp), %rdi
leaq 0x108(%rsp), %rsi
leaq 0x104(%rsp), %rdx
callq 0x1f740
movq 0x20(%rsp), %rdi
leaq 0x10c(%rsp), %rsi
callq 0x1f640
movq 0x1b0(%rsp), %rax
movq %rax, 0x28(%rsp)
movswl 0x16a(%rsp), %eax
movswl 0x16a(%rsp), %ecx
addl %ecx, %eax
movswl 0x168(%rsp), %ecx
subl %ecx, %eax
movl %eax, 0xf8(%rsp)
movswl 0x168(%rsp), %eax
movswl 0x168(%rsp), %ecx
addl %ecx, %eax
movswl 0x16a(%rsp), %ecx
subl %ecx, %eax
movl %eax, 0xf4(%rsp)
leaq 0xfc(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
leaq 0xf4(%rsp), %rdx
callq 0x1f740
movq 0x28(%rsp), %rdi
leaq 0xfc(%rsp), %rsi
callq 0x1f640
movq 0x1b0(%rsp), %rax
movq %rax, 0x30(%rsp)
movswl 0x16a(%rsp), %eax
movswl 0x16a(%rsp), %ecx
addl %ecx, %eax
movswl 0x168(%rsp), %ecx
subl %ecx, %eax
movl %eax, 0xe8(%rsp)
movswl 0x168(%rsp), %eax
movswl 0x168(%rsp), %ecx
addl %ecx, %eax
movswl 0x16a(%rsp), %ecx
subl %ecx, %eax
movl %eax, 0xe4(%rsp)
leaq 0xec(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
leaq 0xe4(%rsp), %rdx
callq 0x1f740
movq 0x30(%rsp), %rdi
leaq 0xec(%rsp), %rsi
callq 0x1f640
movq 0x1b0(%rsp), %rax
movq %rax, 0x38(%rsp)
movswl 0x16a(%rsp), %eax
movswl 0x168(%rsp), %ecx
subl %ecx, %eax
movswl %ax, %edi
callq 0x1f6a0
movw %ax, 0xda(%rsp)
movswl 0x168(%rsp), %eax
movswl 0x16a(%rsp), %ecx
subl %ecx, %eax
movswl %ax, %edi
callq 0x1f6a0
movw %ax, 0xd8(%rsp)
leaq 0xdc(%rsp), %rdi
leaq 0xda(%rsp), %rsi
leaq 0xd8(%rsp), %rdx
callq 0x1f710
movq 0x38(%rsp), %rdi
leaq 0xdc(%rsp), %rsi
callq 0x1f640
movq 0x1b0(%rsp), %rax
movq %rax, 0x40(%rsp)
movswl 0x16a(%rsp), %eax
movswl 0x168(%rsp), %ecx
subl %ecx, %eax
movswl %ax, %edi
callq 0x1f6a0
movw %ax, 0xce(%rsp)
movswl 0x168(%rsp), %eax
movswl 0x16a(%rsp), %ecx
subl %ecx, %eax
movswl %ax, %edi
callq 0x1f6a0
movw %ax, 0xcc(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0xce(%rsp), %rsi
leaq 0xcc(%rsp), %rdx
callq 0x1f710
movq 0x40(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0x1f640
movq 0x1b0(%rsp), %rax
movq %rax, 0x48(%rsp)
movswl 0x16a(%rsp), %eax
movswl 0x168(%rsp), %ecx
subl %ecx, %eax
movswl %ax, %edi
callq 0x1f6a0
movw %ax, 0xc2(%rsp)
movswl 0x168(%rsp), %eax
movswl 0x16a(%rsp), %ecx
subl %ecx, %eax
movswl %ax, %edi
callq 0x1f6a0
movw %ax, 0xc0(%rsp)
leaq 0xc4(%rsp), %rdi
leaq 0xc2(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
callq 0x1f710
movq 0x48(%rsp), %rdi
leaq 0xc4(%rsp), %rsi
callq 0x1f640
movq 0x1b0(%rsp), %rax
movq %rax, 0x50(%rsp)
movswl 0x16a(%rsp), %eax
movswl 0x168(%rsp), %ecx
subl %ecx, %eax
movswl %ax, %edi
callq 0x1f6a0
movw %ax, 0xb6(%rsp)
movswl 0x168(%rsp), %eax
movswl 0x16a(%rsp), %ecx
subl %ecx, %eax
movswl %ax, %edi
callq 0x1f6a0
movw %ax, 0xb4(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0xb6(%rsp), %rsi
leaq 0xb4(%rsp), %rdx
callq 0x1f710
movq 0x50(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x1f640
movq 0x1b0(%rsp), %rax
movq %rax, 0x58(%rsp)
movswl 0x16a(%rsp), %eax
movswl 0x168(%rsp), %ecx
subl %ecx, %eax
movswl %ax, %edi
callq 0x1f6a0
movw %ax, 0xaa(%rsp)
movswl 0x168(%rsp), %eax
movswl 0x16a(%rsp), %ecx
subl %ecx, %eax
movswl %ax, %edi
callq 0x1f6a0
movw %ax, 0xa8(%rsp)
leaq 0xac(%rsp), %rdi
leaq 0xaa(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
callq 0x1f710
movq 0x58(%rsp), %rdi
leaq 0xac(%rsp), %rsi
callq 0x1f640
addq $0x1b8, %rsp            # imm = 0x1B8
retq
nopw %cs:(%rax,%rax)