// File: /workspace/github_cpp_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %ebp
movq %rdi, 0x8(%rsp)
movl %edx, 0x14(%rsp)
testl %edx, %edx
jle 0x108c9
cmpl $0x0, 0x10(%r8)
jle 0x108c9
movl 0x14(%rsp), %ebx
movq %rbx, %r14
shlq $0x6, %r14
addq $-0x20, %r14
xorl %edi, %edi
xorl %r9d, %r9d
movq %rsi, 0x20(%rsp)
movq %r8, 0x18(%rsp)
movq 0x8(%rsp), %r13
movq (%rsi), %rax
movzwl (%rax,%r14), %ecx
movzwl 0x2(%rax,%r14), %edx
cmpw %dx, %cx
je 0x108b2
cmpl $0x0, 0xc(%rax,%r14)
js 0x108b2
movl %r9d, 0x10(%rsp)
testw %dx, %dx
movl $0x0, %eax
cmovgl %edx, %eax
bsrw %ax, %r15w
xorl $-0x10, %r15d
addl $0x11, %r15d
testw %dx, %dx
cmovlel %edi, %r15d
testw %cx, %cx
movl %ecx, %edx
cmovnsl %edi, %edx
movswl %dx, %esi
negl %esi
bsrl %esi, %r12d
notl %r12d
orl $-0x20, %r12d
testw %cx, %cx
movzwl %ax, %ecx
cmovnsl %edi, %r12d
cmpl %esi, %ecx
jg 0x10868
movl %edx, %eax
movl %eax, %ecx
negw %cx
cmovsw %ax, %cx
movl %edi, (%rsp)
movswl %cx, %eax
movl %eax, 0x4(%rsp)
movq %r13, %rdi
movq %rsp, %rsi
callq 0x1884c
movl %r12d, (%rsp)
movzbl %r15b, %eax
movl %eax, 0x4(%rsp)
movq %r13, %rdi
movq %rsp, %rsi
callq 0x1884c
xorl %edi, %edi
movl 0x10(%rsp), %r9d
addl $0x2, %r9d
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %r8
cmpq $0x2, %rbx
jl 0x108c9
addq $-0x40, %r14
decq %rbx
cmpl 0x10(%r8), %r9d
jl 0x107f9
movl 0x14(%rsp), %edi
cmpl %ebp, %edi
jle 0x108e7
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movw $0x8001, %cx            # imm = 0x8001
movw $0x7fff, %ax            # imm = 0x7FFF
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x10943
movq (%rsi), %rax
movslq %edi, %rcx
shlq $0x6, %rcx
leaq (%rcx,%rax), %rdx
addq $0x22, %rdx
subl %edi, %ebp
incl %ebp
movw $0x7fff, %ax            # imm = 0x7FFF
movw $0x8001, %cx            # imm = 0x8001
xorl %r12d, %r12d
xorl %r15d, %r15d
movl -0x2(%rdx), %esi
cmpw %ax, %si
cmovgel %eax, %esi
movzwl (%rdx), %edi
cmpw %cx, %di
cmovlel %ecx, %edi
movl %esi, %eax
movl %edi, %ecx
movl -0xa(%rdx), %esi
movl -0x6(%rdx), %edi
cmpl %r15d, %edi
cmovgl %edi, %r15d
cmpl %r12d, %esi
cmovgl %esi, %r12d
addq $0x40, %rdx
decl %ebp
jne 0x1090b
decl %r15d
decl %r12d
testw %cx, %cx
movl $0x0, %edx
cmovgl %ecx, %edx
bsrw %dx, %bx
movl %edx, %esi
xorl $-0x10, %ebx
addl $0x11, %ebx
testw %cx, %cx
movl $0x0, %ecx
cmovlel %ecx, %ebx
testw %ax, %ax
movl %eax, %edx
cmovnsl %ecx, %edx
movswl %dx, %edi
movl %edi, %ecx
movq %rdi, 0x20(%rsp)
negl %ecx
bsrl %ecx, %ebp
notl %ebp
orl $-0x20, %ebp
testw %ax, %ax
movl $0x0, %eax
cmovnsl %eax, %ebp
movl %edi, %r13d
negw %r13w
movl %edx, 0x10(%rsp)
cmovsw %dx, %r13w
movl %esi, 0x18(%rsp)
cmpw %si, %r13w
movq %rsp, %rcx
cmovlel %esi, %r13d
movl %eax, (%rcx)
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %r13d
movl %r13d, 0x4(%rcx)
movq 0x8(%rsp), %r14
movq %r14, %rdi
movq %rcx, %rsi
callq 0x1884c
xorl %eax, %eax
movq %rsp, %rcx
movl %eax, (%rcx)
movl %r13d, 0x4(%rcx)
movq %rsp, %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x1884c
movl %ebp, (%r13)
movzbl %bl, %ebx
movl %ebx, 0x4(%r13)
movq %rsp, %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x1884c
movl %ebp, (%r13)
movl %ebx, 0x4(%r13)
movq %rsp, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1884c
xorl %ebp, %ebp
movl %ebp, (%rbx)
movl %r15d, 0x4(%rbx)
movq %rsp, %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1884c
movl %ebp, (%rbx)
movl %r12d, 0x4(%rbx)
movq %rsp, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x1884c
movq 0x20(%rsp), %r12
leal (%r12,%r12), %ebx
movl 0x18(%rsp), %r13d
movl %r13d, %ebp
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %ebp
subl %ebp, %ebx
addl %ebp, %ebp
subl %r12d, %ebp
movl %ebx, (%r15)
movl %ebp, 0x4(%r15)
movq %rsp, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x1884c
movl %ebx, (%r15)
movl %ebp, 0x4(%r15)
movq %r12, %r15
movl %r13d, %ebx
movq %rsp, %rsi
movq %r14, %rdi
callq 0x1884c
movl $0x0, %eax
subw %bx, %r15w
movswl %r15w, %r12d
je 0x10ab5
testw %r15w, %r15w
jle 0x10aa8
bsrl %r12d, %eax
xorl $-0x20, %eax
addl $0x21, %eax
jmp 0x10ab5
movl %r12d, %eax
negl %eax
bsrl %eax, %eax
notl %eax
orl $-0x20, %eax
movl %ebx, %r14d
movl 0x10(%rsp), %ebp
subw %bp, %r14w
movswl %r14w, %r13d
movl $0x0, %ecx
je 0x10aea
testw %r14w, %r14w
jle 0x10add
bsrl %r13d, %ecx
xorl $-0x20, %ecx
addl $0x21, %ecx
jmp 0x10aea
movl %r13d, %ecx
negl %ecx
bsrl %ecx, %ecx
notl %ecx
orl $-0x20, %ecx
movq %rsp, %rsi
movl %eax, (%rsi)
movl %ecx, 0x4(%rsi)
movq 0x8(%rsp), %rdi
callq 0x1884c
xorl %eax, %eax
movl $0x0, %ecx
cmpw %bx, %bp
je 0x10b27
testw %r15w, %r15w
jle 0x10b1a
bsrl %r12d, %ecx
xorl $-0x20, %ecx
addl $0x21, %ecx
jmp 0x10b27
movl %r12d, %ecx
negl %ecx
bsrl %ecx, %ecx
notl %ecx
orl $-0x20, %ecx
cmpw %bp, %bx
je 0x10b4b
testw %r14w, %r14w
jle 0x10b3e
bsrl %r13d, %eax
xorl $-0x20, %eax
addl $0x21, %eax
jmp 0x10b4b
movl %r13d, %eax
negl %eax
bsrl %eax, %eax
notl %eax
orl $-0x20, %eax
movq %rsp, %rsi
movl %ecx, (%rsi)
movl %eax, 0x4(%rsi)
movq 0x8(%rsp), %rdi
callq 0x1884c
xorl %eax, %eax
movl $0x0, %ecx
cmpw %bx, %bp
je 0x10b88
testw %r15w, %r15w
jle 0x10b7b
bsrl %r12d, %ecx
xorl $-0x20, %ecx
addl $0x21, %ecx
jmp 0x10b88
movl %r12d, %ecx
negl %ecx
bsrl %ecx, %ecx
notl %ecx
orl $-0x20, %ecx
cmpw %bp, %bx
je 0x10bac
testw %r14w, %r14w
jle 0x10b9f
bsrl %r13d, %eax
xorl $-0x20, %eax
addl $0x21, %eax
jmp 0x10bac
movl %r13d, %eax
negl %eax
bsrl %eax, %eax
notl %eax
orl $-0x20, %eax
movq %rsp, %rsi
movl %ecx, (%rsi)
movl %eax, 0x4(%rsi)
movq 0x8(%rsp), %rdi
callq 0x1884c
xorl %eax, %eax
movl $0x0, %ecx
cmpw %bx, %bp
je 0x10be9
testw %r15w, %r15w
jle 0x10bdc
bsrl %r12d, %ecx
xorl $-0x20, %ecx
addl $0x21, %ecx
jmp 0x10be9
movl %r12d, %ecx
negl %ecx
bsrl %ecx, %ecx
notl %ecx
orl $-0x20, %ecx
cmpw %bp, %bx
je 0x10c0d
testw %r14w, %r14w
jle 0x10c00
bsrl %r13d, %eax
xorl $-0x20, %eax
addl $0x21, %eax
jmp 0x10c0d
movl %r13d, %eax
negl %eax
bsrl %eax, %eax
notl %eax
orl $-0x20, %eax
movq %rsp, %rsi
movl %ecx, (%rsi)
movl %eax, 0x4(%rsi)
movq 0x8(%rsp), %rdi
callq 0x1884c
xorl %eax, %eax
movl $0x0, %ecx
cmpw %bx, %bp
je 0x10c49
testw %r15w, %r15w
jle 0x10c3d
bsrl %r12d, %ecx
xorl $-0x20, %ecx
addl $0x21, %ecx
jmp 0x10c49
negl %r12d
bsrl %r12d, %ecx
notl %ecx
orl $-0x20, %ecx
cmpw %bp, %bx
je 0x10c6c
testw %r14w, %r14w
jle 0x10c60
bsrl %r13d, %eax
xorl $-0x20, %eax
addl $0x21, %eax
jmp 0x10c6c
negl %r13d
bsrl %r13d, %eax
notl %eax
orl $-0x20, %eax
movq %rsp, %rsi
movl %ecx, (%rsi)
movl %eax, 0x4(%rsi)
movq 0x8(%rsp), %rdi
callq 0x1884c
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq