// File: /workspace/github_cpp_makefile_star2_O3/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 $0x48, %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 0xcdb8
incl %eax
movl %eax, 0x6c(%rbx)
leal -0x1(%rsi), %eax
xorl %r10d, %r10d
movswl %ax, %r8d
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movl $0x1, %edx
xorl %ecx, %ecx
movl $0x1, %r9d
pushq %r10
pushq %r10
pushq %r10
pushq %r10
callq 0xdb78
addq $0x20, %rsp
movl $0xffffffff, 0x2c(%r14) # imm = 0xFFFFFFFF
movq (%rbx), %rsi
movq %rbx, %rdi
movq %r14, %rdx
callq 0xde8a
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xced3
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
jmp 0xced3
sarq $0x2, %rcx
movslq %esi, %rax
cmpq %rax, %rcx
jbe 0xcdde
leaq 0x1927c(%rip), %rdi     # 0x26047
xorl %eax, %eax
callq 0x379e
movb $0x1, 0xa8(%rbx)
jmp 0xced3
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0xe0fe
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
je 0xceac
sarq $0x2, %rcx
xorl %r15d, %r15d
movslq (%rax,%r15,4), %r13
testq %r13, %r13
js 0xcee2
cmpq %r13, %rcx
jbe 0xcee2
testq %r15, %r15
je 0xce31
xorl %edx, %edx
cmpl (%rax,%rdx,4), %r13d
je 0xceae
incq %rdx
cmpq %rdx, %r15
jne 0xce1f
movl 0x6c(%rbx), %eax
leal (%rax,%r15), %ecx
movslq %ecx, %rbp
shlq $0x6, %rbp
addq 0x8(%rsp), %rbp
addl %r13d, %eax
movslq %eax, %r12
shlq $0x6, %r12
addq (%rbx), %r12
movq %r12, %rdi
movq %rbp, %rsi
callq 0xe5dc
movq 0x38(%rbp), %rax
movq %rax, 0x38(%r12)
movups 0x18(%rbp), %xmm0
movups 0x28(%rbp), %xmm1
movups %xmm1, 0x28(%r12)
movups %xmm0, 0x18(%r12)
movl $0x5, %edi
leaq 0x191b6(%rip), %rsi     # 0x2603b
movl %r15d, %edx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x1cede
incq %r15
movq (%r14), %rax
movq 0x8(%r14), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r15, %rcx
ja 0xce02
jmp 0xcec9
leaq 0x19146(%rip), %rdi     # 0x25ffb
movl %r15d, %esi
movl %r13d, %ecx
xorl %eax, %eax
callq 0x379e
movb $0x1, 0xa8(%rbx)
leaq 0x8(%rsp), %rdi
callq 0xe188
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x190e9(%rip), %rdi     # 0x25fd2
movl %r13d, %esi
xorl %eax, %eax
callq 0x379e
jmp 0xcec2
jmp 0xcf15
jmp 0xcf15
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0xcf22
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x32c0
jmp 0xcf22
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xe188
movq %rbx, %rdi
callq 0x3590