// File: /workspace/github_cpp_makefile_star2_O2/cloudinary[P]fuif/transform/squeeze.h
// Function: squeeze(Image&, bool, std::vector<int, std::allocator<int>>&)
bool squeeze(Image &input, bool inverse, std::vector<int> &parameters) {
    std::vector<int> adj_params = parameters; // use a copy so empty (default) parameters remain empty
    if (!adj_params.size()) default_squeeze_parameters(adj_params,input);

    if (inverse) {
      for (int i=adj_params.size()-3; i>=0; i-=3) {
        bool horizontal = adj_params[i]&1; // 0=vertical, 1=horizontal
        bool in_place = !(adj_params[i] & 2);
        int beginc = adj_params[i+1];
        int endc = adj_params[i+2];
        if (endc >= input.channel.size()) {
            e_printf("Invalid parameters for squeeze transform: channel %i does not exist\n",endc);
        }
        int offset;
        if (in_place) offset = endc+1; else offset = input.nb_meta_channels + input.nb_channels;
        for (int c=beginc; c<=endc; c++) {
            if (input.channel[offset+c-beginc].data.size() == 0) {
                // stop unsqueezing luma; keep unsqueezing chroma channels
//                if (input.channel[beginc].w == input.channel[c].w && input.channel[beginc].h == input.channel[c].h) continue;
                input.channel[offset+c-beginc].resize();
            }
            if (horizontal) inv_hsqueeze(input, c, offset+c-beginc);
            else inv_vsqueeze(input, c, offset+c-beginc);
        }
        input.channel.erase(input.channel.begin()+offset,input.channel.begin()+offset+(endc-beginc+1));
      }
    } else {
      for (int i=0; i+2<adj_params.size(); i+=3) {
        bool horizontal = adj_params[i]&1; // 0=vertical, 1=horizontal
        bool in_place = !(adj_params[i] & 2);
        int beginc = adj_params[i+1];
        int endc = adj_params[i+2];
        if (endc >= input.channel.size()) {
            e_printf("Invalid parameters for squeeze transform: channel %i does not exist\n",endc);
        }
        int offset;
        if (in_place) offset = endc+1; else offset = input.nb_meta_channels + input.nb_channels;
        int nb_chans = endc-beginc+1;
        for (int c=beginc; c<=endc; c++) {
            if (horizontal) fwd_hsqueeze(input, c, offset+c-beginc);
            else fwd_vsqueeze(input, c, offset+c-beginc);
        }
      }
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movq %rsp, %r14
movq %r14, %rdi
movq %rdx, %rsi
callq 0x5326
movq 0x8(%r14), %rax
cmpq (%r14), %rax
jne 0x83df
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x7f78
testb %bpl, %bpl
je 0x84d8
movq 0x8(%rsp), %rax
subq (%rsp), %rax
shrq $0x2, %rax
movl %eax, %eax
leaq -0x3(%rax), %rcx
testl %ecx, %ecx
js 0x856e
movq %rcx, 0x20(%rsp)
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movq (%rsp), %rdx
movl (%rdx,%rcx,4), %r14d
movslq -0x8(%rdx,%rax,4), %r12
movslq -0x4(%rdx,%rax,4), %r15
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x6, %rax
cmpq %r15, %rax
ja 0x8441
leaq 0x158d4(%rip), %rdi     # 0x1dd0b
movl %r15d, %esi
xorl %eax, %eax
callq 0x16b80
leal 0x1(%r15), %eax
movl 0x64(%rbx), %r13d
addl 0x6c(%rbx), %r13d
testb $0x2, %r14b
cmovel %eax, %r13d
movl %r13d, %ebp
movq %r12, 0x18(%rsp)
cmpq %r15, %r12
jg 0x84a8
movslq %ebp, %rax
movq (%rbx), %rdi
shlq $0x6, %rax
movq 0x8(%rdi,%rax), %rcx
cmpq (%rdi,%rax), %rcx
jne 0x847f
addq %rax, %rdi
callq 0xa72e
testb $0x1, %r14b
jne 0x8494
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
callq 0x4085
jmp 0x84a1
movq %rbx, %rdi
movl %r12d, %esi
movl %ebp, %edx
callq 0x3dc8
incq %r12
incl %ebp
jmp 0x845d
movslq %r13d, %rsi
shlq $0x6, %rsi
addq (%rbx), %rsi
subl 0x18(%rsp), %r15d
movslq %r15d, %rax
shlq $0x6, %rax
leaq (%rax,%rsi), %rdx
addq $0x40, %rdx
movq %rbx, %rdi
callq 0xa676
movq 0x20(%rsp), %rax
jmp 0x83f7
xorl %r13d, %r13d
leaq 0x2(%r13), %rcx
movq (%rsp), %rax
movq 0x8(%rsp), %rdx
subq %rax, %rdx
sarq $0x2, %rdx
cmpq %rcx, %rdx
jbe 0x856e
movl (%rax,%r13,4), %r14d
movl 0x4(%rax,%r13,4), %ebp
movslq 0x8(%rax,%r13,4), %r15
movq 0x8(%rbx), %rax
subq (%rbx), %rax
sarq $0x6, %rax
cmpq %r15, %rax
ja 0x8523
leaq 0x157f2(%rip), %rdi     # 0x1dd0b
movl %r15d, %esi
xorl %eax, %eax
callq 0x16b80
movl 0x64(%rbx), %r12d
addl 0x6c(%rbx), %r12d
leal 0x1(%r15), %eax
testb $0x2, %r14b
cmovel %eax, %r12d
cmpl %r15d, %ebp
jg 0x8565
testb $0x1, %r14b
jne 0x8551
movq %rbx, %rdi
movl %ebp, %esi
movl %r12d, %edx
callq 0x7bf1
jmp 0x855e
movq %rbx, %rdi
movl %ebp, %esi
movl %r12d, %edx
callq 0x78ba
incl %ebp
incl %r12d
jmp 0x8537
addq $0x3, %r13
jmp 0x84db
movq %rsp, %rdi
callq 0x5374
movb $0x1, %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8591
jmp 0x8591
jmp 0x8591
jmp 0x8591
jmp 0x8591
movq %rax, %rbx
movq %rsp, %rdi
callq 0x5374
movq %rbx, %rdi
callq 0x35d0