// File: /workspace/github_cpp_makefile_star2_O3/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 $0x38, %rsp
movl %ecx, %ebp
movq %rdi, 0x30(%rsp)
movl %edx, 0x14(%rsp)
testl %edx, %edx
setg %cl
movq %r8, 0x20(%rsp)
movl 0x10(%r8), %eax
testl %eax, %eax
setg %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x10803
movl 0x14(%rsp), %ebx
movq %rbx, %r14
shlq $0x6, %r14
addq $-0x20, %r14
xorl %r8d, %r8d
xorl %r9d, %r9d
movq %rsi, 0x18(%rsp)
movq 0x30(%rsp), %r12
movq (%rsi), %rdi
movzwl (%rdi,%r14), %ecx
movzwl 0x2(%rdi,%r14), %edx
cmpw %dx, %cx
je 0x107ed
cmpl $0x0, 0xc(%rdi,%r14)
js 0x107ed
movl %r9d, 0x28(%rsp)
testw %dx, %dx
movl $0x0, %eax
cmovgl %edx, %eax
bsrw %ax, %r13w
xorl $-0x10, %r13d
addl $0x11, %r13d
testw %dx, %dx
cmovlel %r8d, %r13d
testw %cx, %cx
movl %ecx, %edx
cmovnsl %r8d, %edx
movswl %dx, %esi
negl %esi
bsrl %esi, %r15d
notl %r15d
orl $-0x20, %r15d
testw %cx, %cx
movzwl %ax, %ecx
cmovnsl %r8d, %r15d
cmpl %esi, %ecx
ja 0x10798
movl %edx, %eax
movl %eax, %ecx
negw %cx
cmovsw %ax, %cx
movl %r8d, 0xc(%rsp)
movswl %cx, %eax
movl %eax, 0x10(%rsp)
movq %r12, %rdi
leaq 0xc(%rsp), %rsi
callq 0x185bc
movl %r15d, 0xc(%rsp)
movzbl %r13b, %eax
movl %eax, 0x10(%rsp)
movq %r12, %rdi
leaq 0xc(%rsp), %rsi
callq 0x185bc
xorl %r8d, %r8d
movl 0x28(%rsp), %r9d
addl $0x2, %r9d
movq 0x20(%rsp), %rax
movl 0x10(%rax), %eax
movq 0x18(%rsp), %rsi
cmpq $0x2, %rbx
jb 0x10803
addq $-0x40, %r14
decq %rbx
cmpl %eax, %r9d
jl 0x10728
movl 0x14(%rsp), %edi
cmpl %ebp, %edi
jle 0x10821
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movw $0x8001, %cx            # imm = 0x8001
movw $0x7fff, %ax            # imm = 0x7FFF
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
jmp 0x1087e
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
movzwl -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 0x10845
decl %r15d
decl %r12d
testw %cx, %cx
movl $0x0, %edx
cmovgl %ecx, %edx
bsrw %dx, %bx
xorl $-0x10, %ebx
addl $0x11, %ebx
testw %cx, %cx
movl $0x0, %ecx
cmovlel %ecx, %ebx
testw %ax, %ax
movl %eax, %r13d
cmovnsl %ecx, %r13d
movswl %r13w, %ecx
movq %rcx, 0x28(%rsp)
negl %ecx
bsrl %ecx, %ebp
notl %ebp
orl $-0x20, %ebp
testw %ax, %ax
movl $0x0, %eax
cmovnsl %eax, %ebp
movl %r13d, 0x18(%rsp)
negl %r13d
movl %edx, 0x20(%rsp)
cmpw %r13w, %dx
leaq 0xc(%rsp), %rsi
cmovgl %edx, %r13d
movl %eax, (%rsi)
movl $0xffff, %eax           # imm = 0xFFFF
andl %eax, %r13d
movl %r13d, 0x4(%rsi)
movq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x185bc
xorl %eax, %eax
leaq 0xc(%rsp), %rcx
movl %eax, (%rcx)
movl %r13d, 0x4(%rcx)
leaq 0xc(%rsp), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x185bc
movl %ebp, (%r13)
movzbl %bl, %ebx
movl %ebx, 0x4(%r13)
leaq 0xc(%rsp), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x185bc
movl %ebp, (%r13)
movl %ebx, 0x4(%r13)
xorl %r13d, %r13d
leaq 0xc(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x185bc
movl %r13d, (%rbx)
movl %r15d, 0x4(%rbx)
leaq 0xc(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x185bc
movl %r13d, (%rbx)
movl %r12d, 0x4(%rbx)
leaq 0xc(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x185bc
movq 0x28(%rsp), %r12
leal (%r12,%r12), %ebx
movl 0x20(%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)
leaq 0xc(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x185bc
movl %ebx, (%r15)
movq %r14, %rbx
movl %ebp, 0x4(%r15)
movq %r12, %r15
leaq 0xc(%rsp), %rsi
movq %r14, %rdi
callq 0x185bc
subw %r13w, %r15w
jne 0x10a27
leaq 0xc(%rsp), %r14
xorl %r12d, %r12d
movq %r12, (%r14)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x185bc
movq %r12, (%r14)
leaq 0xc(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x185bc
movq %r12, (%r14)
leaq 0xc(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x185bc
xorl %r15d, %r15d
movq %r12, (%r14)
leaq 0xc(%rsp), %rsi
movq %rbx, %rdi
callq 0x185bc
xorl %eax, %eax
jmp 0x10bb4
movswl %r15w, %r14d
testw %r14w, %r14w
jle 0x10a3d
bsrl %r14d, %eax
xorl $-0x20, %eax
addl $0x21, %eax
jmp 0x10a4a
movl %r14d, %eax
negl %eax
bsrl %eax, %eax
notl %eax
orl $-0x20, %eax
subl 0x18(%rsp), %r13d
movswl %r13w, %r12d
testw %r12w, %r12w
jle 0x10a65
bsrl %r12d, %ecx
xorl $-0x20, %ecx
addl $0x21, %ecx
jmp 0x10a72
movl %r12d, %ecx
negl %ecx
bsrl %ecx, %ecx
notl %ecx
orl $-0x20, %ecx
leaq 0xc(%rsp), %rsi
movl %eax, (%rsi)
movl %ecx, 0x4(%rsi)
movq %rbx, %rdi
callq 0x185bc
testw %r15w, %r15w
jle 0x10a96
bsrl %r14d, %eax
xorl $-0x20, %eax
addl $0x21, %eax
jmp 0x10aa3
movl %r14d, %eax
negl %eax
bsrl %eax, %eax
notl %eax
orl $-0x20, %eax
testw %r13w, %r13w
jle 0x10ab5
bsrl %r12d, %ecx
xorl $-0x20, %ecx
addl $0x21, %ecx
jmp 0x10ac2
movl %r12d, %ecx
negl %ecx
bsrl %ecx, %ecx
notl %ecx
orl $-0x20, %ecx
leaq 0xc(%rsp), %rsi
movl %eax, (%rsi)
movl %ecx, 0x4(%rsi)
movq %rbx, %rdi
callq 0x185bc
testw %r15w, %r15w
jle 0x10ae6
bsrl %r14d, %eax
xorl $-0x20, %eax
addl $0x21, %eax
jmp 0x10af3
movl %r14d, %eax
negl %eax
bsrl %eax, %eax
notl %eax
orl $-0x20, %eax
testw %r13w, %r13w
jle 0x10b05
bsrl %r12d, %ecx
xorl $-0x20, %ecx
addl $0x21, %ecx
jmp 0x10b12
movl %r12d, %ecx
negl %ecx
bsrl %ecx, %ecx
notl %ecx
orl $-0x20, %ecx
leaq 0xc(%rsp), %rsi
movl %eax, (%rsi)
movl %ecx, 0x4(%rsi)
movq %rbx, %rdi
callq 0x185bc
testw %r15w, %r15w
jle 0x10b36
bsrl %r14d, %eax
xorl $-0x20, %eax
addl $0x21, %eax
jmp 0x10b43
movl %r14d, %eax
negl %eax
bsrl %eax, %eax
notl %eax
orl $-0x20, %eax
testw %r13w, %r13w
jle 0x10b55
bsrl %r12d, %ecx
xorl $-0x20, %ecx
addl $0x21, %ecx
jmp 0x10b62
movl %r12d, %ecx
negl %ecx
bsrl %ecx, %ecx
notl %ecx
orl $-0x20, %ecx
leaq 0xc(%rsp), %rsi
movl %eax, (%rsi)
movl %ecx, 0x4(%rsi)
movq %rbx, %rdi
callq 0x185bc
testw %r15w, %r15w
jle 0x10b88
bsrl %r14d, %r15d
xorl $-0x20, %r15d
addl $0x21, %r15d
jmp 0x10b96
negl %r14d
bsrl %r14d, %r15d
notl %r15d
orl $-0x20, %r15d
testw %r13w, %r13w
jle 0x10ba8
bsrl %r12d, %eax
xorl $-0x20, %eax
addl $0x21, %eax
jmp 0x10bb4
negl %r12d
bsrl %r12d, %eax
notl %eax
orl $-0x20, %eax
leaq 0xc(%rsp), %rsi
movl %r15d, (%rsi)
movl %eax, 0x4(%rsi)
movq %rbx, %rdi
callq 0x185bc
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq