// File: /workspace/github_cpp_makefile_star2_O2/cloudinary[P]fuif/transform/squeeze.h
// Function: default_squeeze_parameters(std::vector<int, std::allocator<int>>&, Image const&)
void default_squeeze_parameters(std::vector<int> &parameters, const Image &image) {
    int nb_channels = image.nb_channels;
    // maybe other transforms have been applied before, but let's assume the first nb_channels channels
    // still contain the 'main' data

    parameters.clear();
    int w = image.channel[image.nb_meta_channels].w;
    int h = image.channel[image.nb_meta_channels].h;
    v_printf(7,"\nDefault squeeze parameters for %ix%i image: ",w,h);

    bool wide = (w>h);  // do horizontal first on wide images; vertical first on tall images
    if (nb_channels>2 && image.channel[image.nb_meta_channels+1].w == w && image.channel[image.nb_meta_channels+1].h == h) {
        // assume channels 1 and 2 are chroma, and can be squeezed first for 4:2:0 previews
        v_printf(7,"(4:2:0 chroma), ",w,h);
//        if (!wide) {
//        parameters.push_back(0+2); // vertical chroma squeeze
//        parameters.push_back(image.nb_meta_channels+1);
//        parameters.push_back(image.nb_meta_channels+2);
//        }
        parameters.push_back(1+2); // horizontal chroma squeeze
        parameters.push_back(image.nb_meta_channels+1);
        parameters.push_back(image.nb_meta_channels+2);
//        if (wide) {
        parameters.push_back(0+2); // vertical chroma squeeze
        parameters.push_back(image.nb_meta_channels+1);
        parameters.push_back(image.nb_meta_channels+2);
//        }
    }

    if (!wide) {
            if (h > MAX_FIRST_PREVIEW_SIZE) {
                parameters.push_back(0); // vertical squeeze
                parameters.push_back(image.nb_meta_channels);
                parameters.push_back(image.nb_meta_channels+nb_channels-1);
                h = (h+1)/2;
                v_printf(7,"Vertical (%ix%i), ",w,h);
            }
    }
    while ( w > MAX_FIRST_PREVIEW_SIZE || h > MAX_FIRST_PREVIEW_SIZE ) {
            if (w > MAX_FIRST_PREVIEW_SIZE) {
                parameters.push_back(1); // horizontal squeeze
                parameters.push_back(image.nb_meta_channels);
                parameters.push_back(image.nb_meta_channels+nb_channels-1);
                w = (w+1)/2;
                v_printf(7,"Horizontal (%ix%i), ",w,h);
            }
            if (h > MAX_FIRST_PREVIEW_SIZE) {
                parameters.push_back(0); // vertical squeeze
                parameters.push_back(image.nb_meta_channels);
                parameters.push_back(image.nb_meta_channels+nb_channels-1);
                h = (h+1)/2;
                v_printf(7,"Vertical (%ix%i), ",w,h);
            }
    }
    v_printf(7,"that's it\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r12
movq %rdi, %rbx
movl 0x64(%rsi), %eax
movl %eax, 0x4(%rsp)
movq (%rdi), %rax
cmpq %rax, 0x8(%rdi)
je 0x7f9d
movq %rax, 0x8(%rbx)
leaq 0x6c(%r12), %r14
movslq 0x6c(%r12), %rax
movq (%r12), %rcx
shlq $0x6, %rax
movl 0x18(%rcx,%rax), %ebp
movl 0x1c(%rcx,%rax), %r15d
leaq 0x15cda(%rip), %rsi     # 0x1dc99
pushq $0x7
popq %rdi
movl %ebp, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x16c30
cmpl $0x3, 0x4(%rsp)
jl 0x809a
movslq 0x6c(%r12), %rcx
movq (%r12), %rax
shlq $0x6, %rcx
cmpl %ebp, 0x58(%rax,%rcx)
jne 0x809a
addq %rcx, %rax
cmpl %r15d, 0x5c(%rax)
jne 0x809a
leaq 0x15cc3(%rip), %rsi     # 0x1dcc7
pushq $0x7
popq %rdi
movl %ebp, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x16c30
movq %rsp, %r12
movl $0x3, (%r12)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xb266
movl (%r14), %eax
incl %eax
movl %eax, (%r12)
movq %rsp, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0xb266
movl (%r14), %eax
addl $0x2, %eax
movl %eax, (%r12)
movq %rsp, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0xb266
movl $0x2, (%r12)
movq %rsp, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0xb266
movl (%r14), %eax
incl %eax
movl %eax, (%r12)
movq %rsp, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0xb266
movl (%r14), %eax
addl $0x2, %eax
movl %eax, (%r12)
movq %rsp, %rsi
movq %rbx, %rdi
callq 0xb266
cmpl %r15d, %ebp
setle %al
cmpl $0x9, %r15d
setge %cl
testb %cl, %al
je 0x8105
movq %rsp, %r12
andl $0x0, (%r12)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xb266
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa60a
movl 0x4(%rsp), %ecx
decl %ecx
movl (%r14), %eax
movl %ecx, 0x4(%rsp)
addl %ecx, %eax
movl %eax, (%r12)
movq %rsp, %rsi
movq %rbx, %rdi
callq 0xb266
incl %r15d
shrl %r15d
leaq 0x15be4(%rip), %rsi     # 0x1dcd8
pushq $0x7
popq %rdi
movl %ebp, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x16c30
jmp 0x8109
decl 0x4(%rsp)
movq %rsp, %r12
pushq $0x7
popq %r13
cmpl $0x8, %ebp
jg 0x811f
cmpl $0x9, %r15d
jl 0x81c6
cmpl $0x9, %ebp
jl 0x8170
movl $0x1, (%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xb266
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa60a
movl (%r14), %eax
addl 0x4(%rsp), %eax
movl %eax, (%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xb266
incl %ebp
shrl %ebp
movl %r13d, %edi
leaq 0x15b87(%rip), %rsi     # 0x1dceb
movl %ebp, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x16c30
cmpl $0x9, %r15d
jl 0x8110
andl $0x0, (%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xb266
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa60a
movl (%r14), %eax
addl 0x4(%rsp), %eax
movl %eax, (%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xb266
incl %r15d
shrl %r15d
movl %r13d, %edi
leaq 0x15b23(%rip), %rsi     # 0x1dcd8
movl %ebp, %edx
movl %r15d, %ecx
xorl %eax, %eax
callq 0x16c30
jmp 0x8110
leaq 0x15b33(%rip), %rsi     # 0x1dd00
pushq $0x7
popq %rdi
xorl %eax, %eax
callq 0x16c30
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq