// File: 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:
subq $0xe8, %rsp
movb %sil, %al
movq %rdi, 0xe0(%rsp)
andb $0x1, %al
movb %al, 0xdf(%rsp)
movq %rdx, 0xd0(%rsp)
movq 0xd0(%rsp), %rsi
leaq 0xb8(%rsp), %rdi
callq 0x4c50
leaq 0xb8(%rsp), %rdi
callq 0x4d50
cmpq $0x0, %rax
jne 0xdb3a
movq 0xe0(%rsp), %rsi
leaq 0xb8(%rsp), %rdi
callq 0xd270
jmp 0xdb12
jmp 0xdb3a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x54f0
jmp 0xe02b
testb $0x1, 0xdf(%rsp)
je 0xde67
leaq 0xb8(%rsp), %rdi
callq 0x4d50
subq $0x3, %rax
movl %eax, 0xa8(%rsp)
cmpl $0x0, 0xa8(%rsp)
jl 0xde62
movslq 0xa8(%rsp), %rsi
leaq 0xb8(%rsp), %rdi
callq 0x12190
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, 0xa7(%rsp)
movslq 0xa8(%rsp), %rsi
leaq 0xb8(%rsp), %rdi
callq 0x12190
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, 0xa6(%rsp)
movl 0xa8(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
leaq 0xb8(%rsp), %rdi
callq 0x12190
movl (%rax), %eax
movl %eax, 0xa0(%rsp)
movl 0xa8(%rsp), %eax
addl $0x2, %eax
movslq %eax, %rsi
leaq 0xb8(%rsp), %rdi
callq 0x12190
movl (%rax), %eax
movl %eax, 0x9c(%rsp)
movslq 0x9c(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0xe0(%rsp), %rdi
callq 0x4b80
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jb 0xdc48
movl 0x9c(%rsp), %esi
leaq 0x3907e(%rip), %rdi     # 0x46cbb
xorl %eax, %eax
callq 0x3a670
jmp 0xdc46
jmp 0xdc48
testb $0x1, 0xa6(%rsp)
je 0xdc65
movl 0x9c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x98(%rsp)
jmp 0xdc82
movq 0xe0(%rsp), %rax
movl 0x6c(%rax), %eax
movq 0xe0(%rsp), %rcx
addl 0x64(%rcx), %eax
movl %eax, 0x98(%rsp)
movl 0xa0(%rsp), %eax
movl %eax, 0x94(%rsp)
movl 0x94(%rsp), %eax
cmpl 0x9c(%rsp), %eax
jg 0xdd82
movq 0xe0(%rsp), %rdi
movl 0x98(%rsp), %eax
addl 0x94(%rsp), %eax
subl 0xa0(%rsp), %eax
movslq %eax, %rsi
callq 0x4ba0
movq %rax, %rdi
callq 0x4a30
cmpq $0x0, %rax
jne 0xdd0c
movq 0xe0(%rsp), %rdi
movl 0x98(%rsp), %eax
movl 0x94(%rsp), %ecx
addl %ecx, %eax
movl 0xa0(%rsp), %ecx
subl %ecx, %eax
movslq %eax, %rsi
callq 0x4ba0
movq %rax, %rdi
callq 0x129c0
jmp 0xdd0a
jmp 0xdd0c
testb $0x1, 0xa7(%rsp)
je 0xdd40
movq 0xe0(%rsp), %rdi
movl 0x94(%rsp), %esi
movl 0x98(%rsp), %edx
addl %esi, %edx
movl 0xa0(%rsp), %eax
subl %eax, %edx
callq 0xb760
jmp 0xdd3e
jmp 0xdd6a
movq 0xe0(%rsp), %rdi
movl 0x94(%rsp), %esi
movl 0x98(%rsp), %edx
addl %esi, %edx
movl 0xa0(%rsp), %eax
subl %eax, %edx
callq 0xc470
jmp 0xdd68
jmp 0xdd6a
jmp 0xdd6c
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0xdc90
movq 0xe0(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x127d0
movq %rax, 0x78(%rsp)
movslq 0x98(%rsp), %rsi
leaq 0x78(%rsp), %rdi
callq 0x12800
movq %rax, 0x80(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x12840
movq 0xe0(%rsp), %rdi
callq 0x127d0
movq %rax, 0x58(%rsp)
movslq 0x98(%rsp), %rsi
leaq 0x58(%rsp), %rdi
callq 0x12800
movq %rax, 0x60(%rsp)
movl 0x9c(%rsp), %eax
movl 0xa0(%rsp), %ecx
subl %ecx, %eax
incl %eax
movslq %eax, %rsi
leaq 0x60(%rsp), %rdi
callq 0x12800
movq %rax, 0x68(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x12840
movq 0x18(%rsp), %rdi
movq 0x88(%rsp), %rsi
movq 0x70(%rsp), %rdx
callq 0x12730
movq %rax, 0x20(%rsp)
jmp 0xde42
movq 0x20(%rsp), %rax
movq %rax, 0x50(%rsp)
movl 0xa8(%rsp), %eax
subl $0x3, %eax
movl %eax, 0xa8(%rsp)
jmp 0xdb60
jmp 0xe012
movl $0x0, 0x4c(%rsp)
movl 0x4c(%rsp), %eax
addl $0x2, %eax
cltq
movq %rax, 0x10(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x4d50
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
jae 0xe010
movslq 0x4c(%rsp), %rsi
leaq 0xb8(%rsp), %rdi
callq 0x12190
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, 0x4b(%rsp)
movslq 0x4c(%rsp), %rsi
leaq 0xb8(%rsp), %rdi
callq 0x12190
movl (%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, 0x4a(%rsp)
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rsi
leaq 0xb8(%rsp), %rdi
callq 0x12190
movl (%rax), %eax
movl %eax, 0x44(%rsp)
movl 0x4c(%rsp), %eax
addl $0x2, %eax
movslq %eax, %rsi
leaq 0xb8(%rsp), %rdi
callq 0x12190
movl (%rax), %eax
movl %eax, 0x40(%rsp)
movslq 0x40(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0xe0(%rsp), %rdi
callq 0x4b80
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jb 0xdf57
movl 0x40(%rsp), %esi
leaq 0x38d6f(%rip), %rdi     # 0x46cbb
xorl %eax, %eax
callq 0x3a670
jmp 0xdf55
jmp 0xdf57
testb $0x1, 0x4a(%rsp)
je 0xdf6b
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0xdf85
movq 0xe0(%rsp), %rax
movl 0x6c(%rax), %eax
movq 0xe0(%rsp), %rcx
addl 0x64(%rcx), %eax
movl %eax, 0x3c(%rsp)
movl 0x40(%rsp), %eax
subl 0x44(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
movl 0x44(%rsp), %eax
movl %eax, 0x34(%rsp)
movl 0x34(%rsp), %eax
cmpl 0x40(%rsp), %eax
jg 0xdffe
testb $0x1, 0x4b(%rsp)
je 0xdfce
movq 0xe0(%rsp), %rdi
movl 0x34(%rsp), %esi
movl 0x3c(%rsp), %edx
addl %esi, %edx
movl 0x44(%rsp), %eax
subl %eax, %edx
callq 0xbdf0
jmp 0xdfcc
jmp 0xdfef
movq 0xe0(%rsp), %rdi
movl 0x34(%rsp), %esi
movl 0x3c(%rsp), %edx
addl %esi, %edx
movl 0x44(%rsp), %eax
subl %eax, %edx
callq 0xcb90
jmp 0xdfed
jmp 0xdfef
jmp 0xdff1
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0xdf9c
jmp 0xe000
movl 0x4c(%rsp), %eax
addl $0x3, %eax
movl %eax, 0x4c(%rsp)
jmp 0xde6f
jmp 0xe012
leaq 0xb8(%rsp), %rdi
callq 0x54f0
movb $0x1, %al
andb $0x1, %al
addq $0xe8, %rsp
retq
movq 0xb0(%rsp), %rdi
callq 0x36a0
nopl (%rax,%rax)