// File: /workspace/github_cpp_makefile_star2_O2/cloudinary[P]fuif/transform/permute.h
// Function: meta_permute(Image&, std::vector<int, std::allocator<int>>&, bool)
void meta_permute(Image &input, std::vector<int> &parameters, bool use_channel=false) {
    int nb = input.channel.size() - input.nb_meta_channels;
    if (parameters.size() == 0 || use_channel) {
      input.nb_meta_channels++;
      Channel pch(nb, 1, 0, nb-1);
      pch.hshift = -1;
      input.channel.insert(input.channel.begin(),pch);
    } else if (parameters.size() <= nb) {
      std::vector<Channel> inchannel = input.channel;
      for (int i=0; i<parameters.size(); i++) {
        int c = parameters[i];
        if (c < 0 || c >= parameters.size()) {
            e_printf("Invalid permutation: channel %i is lost\n",c);
            input.error=true;
            return;
        }
        for (int j=0; j<i; j++) if (parameters[i] == parameters[j]) {
            e_printf("Invalid permutation: both %i and %i map from channel number %i\n",i,j,parameters[i]);
            input.error=true;
            return;
        }
        input.channel[input.nb_meta_channels+c] = inchannel[input.nb_meta_channels+i];
        v_printf(5,"[%i -> %i] ",i,c);
      }
    } else {
        e_printf("Incorrect number of parameters in Permute transform.\n");
        input.error=true;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %r14
movq %rdi, %rbx
xorb $0x1, %dl
movq 0x8(%rdi), %rsi
subq (%rdi), %rsi
shrq $0x6, %rsi
movl 0x6c(%rdi), %eax
subl %eax, %esi
movq 0x8(%r14), %rcx
subq (%r14), %rcx
setne %dil
testb %dl, %dil
jne 0x9aa5
incl %eax
movl %eax, 0x6c(%rbx)
leal -0x1(%rsi), %eax
andl $0x0, 0x18(%rsp)
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
andl $0x0, (%rsp)
movswl %ax, %r8d
leaq 0x28(%rsp), %r14
pushq $0x1
popq %rdx
movq %r14, %rdi
xorl %ecx, %ecx
movl %edx, %r9d
callq 0xa470
orl $-0x1, 0x2c(%r14)
movq (%rbx), %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0xa7c8
leaq 0x28(%rsp), %rdi
callq 0xabc2
jmp 0x9b81
sarq $0x2, %rcx
movslq %esi, %rax
cmpq %rax, %rcx
jbe 0x9acb
leaq 0x1450f(%rip), %rdi     # 0x1dfc7
xorl %eax, %eax
callq 0x16b80
movb $0x1, 0xa8(%rbx)
jmp 0x9b81
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
callq 0xaa0e
leaq 0x144dc(%rip), %r12     # 0x1dfbb
pushq $0x5
popq %rbp
xorl %r15d, %r15d
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r15, %rcx
jbe 0x9b77
movslq (%rax,%r15,4), %r13
testq %r13, %r13
js 0x9b90
cmpq %r13, %rcx
jbe 0x9b90
xorl %edx, %edx
cmpq %rdx, %r15
je 0x9b20
cmpl (%rax,%rdx,4), %r13d
je 0x9b5c
incq %rdx
jmp 0x9b10
movl 0x6c(%rbx), %eax
leal (%rax,%r15), %ecx
movslq %ecx, %rsi
shlq $0x6, %rsi
addq 0x28(%rsp), %rsi
addl %r13d, %eax
movslq %eax, %rdi
shlq $0x6, %rdi
addq (%rbx), %rdi
callq 0xa526
movl %ebp, %edi
movq %r12, %rsi
movl %r15d, %edx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x16c30
incq %r15
jmp 0x9ae5
leaq 0x14418(%rip), %rdi     # 0x1df7b
movl %r15d, %esi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x16b80
movb $0x1, 0xa8(%rbx)
leaq 0x28(%rsp), %rdi
callq 0xaa62
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x143bb(%rip), %rdi     # 0x1df52
movl %r13d, %esi
xorl %eax, %eax
callq 0x16b80
jmp 0x9b70
jmp 0x9ba7
jmp 0x9ba7
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xaa62
jmp 0x9bc3
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xabc2
movq %rbx, %rdi
callq 0x35d0