#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ free_ivector(int *, int /*<<< orphan*/, int);
int *ivector(int /*<<< orphan*/, int);
int /*<<< orphan*/ resample_shuffle(int *, int, int, long *);
void permut_locations_of_groups_within_cat(int n, int *cati, int Ncat,
                                           double *x, double *y, double *z,
                                           double **Mdij, int *groupi,
                                           double *xmix, double *ymix,
                                           double *zmix, double **Mdijmix,
                                           long *seed) {
  int i, j, i2, j2, k, *loci;
  int *locg, *group, newgroup, ng, g;
  loci = ivector(0, n);
  locg = ivector(0, n);
  group = ivector(0, n);
  for (k = 1; k <= Ncat; k++) {
    ng = 0;
    for (i = 1; i <= n; i++)
      if (cati[i] == k) {
        newgroup = 1;
        for (g = ng; g >= 1; g--)
          if (groupi[i] == group[g]) {
            newgroup = 0;
            break;
          }
        if (newgroup) {
          ng++;
          group[ng] = groupi[i];
          locg[ng] = i;
        }
      }
    resample_shuffle(locg, 1, ng, seed);
    for (i = 1; i <= n; i++)
      if (cati[i] == k)
        loci[i] = locg[groupi[i]];
    for (i = 1; i <= n; i++)
      if (cati[i] == k) {
        if (Mdij[0][0] != 1.) {
          xmix[i] = x[loci[i]];
          ymix[i] = y[loci[i]];
          zmix[i] = z[loci[i]];
        }
        if (Mdij[0][0] == 1.)
          for (i2 = 1; i2 <= n; i2++)
            if (cati[i2] == k) {
              Mdijmix[i][i2] = Mdij[loci[i]][loci[i2]];
            }
      }
  }
  free_ivector(loci, 0, n);
  free_ivector(locg, 0, n);
  free_ivector(group, 0, n);
}


x86 assembly (clang, -O0):
<permut_locations_of_groups_within_cat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x40(%rbp),%rax
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x4(%rbp),%esi
xor    %edi,%edi
call   1040 <ivector@plt>
mov    %rax,-0x50(%rbp)
mov    -0x4(%rbp),%esi
xor    %edi,%edi
call   1040 <ivector@plt>
mov    %rax,-0x58(%rbp)
mov    -0x4(%rbp),%esi
xor    %edi,%edi
call   1040 <ivector@plt>
mov    %rax,-0x60(%rbp)
movl   $0x1,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     145f <permut_locations_of_groups_within_cat+0x32f>
movl   $0x0,-0x68(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1276 <permut_locations_of_groups_within_cat+0x146>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x44(%rbp),%eax
jne    1263 <permut_locations_of_groups_within_cat+0x133>
movl   $0x1,-0x64(%rbp)
mov    -0x68(%rbp),%eax
mov    %eax,-0x6c(%rbp)
cmpl   $0x1,-0x6c(%rbp)
jl     1227 <permut_locations_of_groups_within_cat+0xf7>
mov    0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x60(%rbp),%rcx
movslq -0x6c(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    1214 <permut_locations_of_groups_within_cat+0xe4>
movl   $0x0,-0x64(%rbp)
jmp    1227 <permut_locations_of_groups_within_cat+0xf7>
jmp    1219 <permut_locations_of_groups_within_cat+0xe9>
mov    -0x6c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x6c(%rbp)
jmp    11e2 <permut_locations_of_groups_within_cat+0xb2>
cmpl   $0x0,-0x64(%rbp)
je     125e <permut_locations_of_groups_within_cat+0x12e>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
mov    0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x60(%rbp),%rax
movslq -0x68(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x34(%rbp),%edx
mov    -0x58(%rbp),%rax
movslq -0x68(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    1263 <permut_locations_of_groups_within_cat+0x133>
jmp    1268 <permut_locations_of_groups_within_cat+0x138>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11b5 <permut_locations_of_groups_within_cat+0x85>
mov    -0x58(%rbp),%rdi
mov    -0x68(%rbp),%edx
mov    0x40(%rbp),%rcx
mov    $0x1,%esi
call   1050 <resample_shuffle@plt>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     12e3 <permut_locations_of_groups_within_cat+0x1b3>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x44(%rbp),%eax
jne    12d0 <permut_locations_of_groups_within_cat+0x1a0>
mov    -0x58(%rbp),%rax
mov    0x18(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x50(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    12d5 <permut_locations_of_groups_within_cat+0x1a5>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1292 <permut_locations_of_groups_within_cat+0x162>
movl   $0x1,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     144c <permut_locations_of_groups_within_cat+0x31c>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x44(%rbp),%eax
jne    1439 <permut_locations_of_groups_within_cat+0x309>
mov    0x10(%rbp),%rax
mov    (%rax),%rax
movsd  (%rax),%xmm0
movsd  0xce3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1332 <permut_locations_of_groups_within_cat+0x202>
jp     1332 <permut_locations_of_groups_within_cat+0x202>
jmp    1398 <permut_locations_of_groups_within_cat+0x268>
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
mov    -0x50(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
mov    -0x50(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x30(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    0x10(%rbp),%rax
mov    (%rax),%rax
movsd  (%rax),%xmm0
movsd  0xc55(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1434 <permut_locations_of_groups_within_cat+0x304>
jp     1434 <permut_locations_of_groups_within_cat+0x304>
movl   $0x1,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     142f <permut_locations_of_groups_within_cat+0x2ff>
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x44(%rbp),%eax
jne    141c <permut_locations_of_groups_within_cat+0x2ec>
mov    0x10(%rbp),%rax
mov    -0x50(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x50(%rbp),%rcx
movslq -0x3c(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x38(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1421 <permut_locations_of_groups_within_cat+0x2f1>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    13c2 <permut_locations_of_groups_within_cat+0x292>
jmp    1434 <permut_locations_of_groups_within_cat+0x304>
jmp    1439 <permut_locations_of_groups_within_cat+0x309>
jmp    143e <permut_locations_of_groups_within_cat+0x30e>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12ea <permut_locations_of_groups_within_cat+0x1ba>
jmp    1451 <permut_locations_of_groups_within_cat+0x321>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    119b <permut_locations_of_groups_within_cat+0x6b>
mov    -0x50(%rbp),%rdi
mov    -0x4(%rbp),%edx
xor    %esi,%esi
call   1030 <free_ivector@plt>
mov    -0x58(%rbp),%rdi
mov    -0x4(%rbp),%edx
xor    %esi,%esi
call   1030 <free_ivector@plt>
mov    -0x60(%rbp),%rdi
mov    -0x4(%rbp),%edx
xor    %esi,%esi
call   1030 <free_ivector@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<permut_locations_of_groups_within_cat>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r9,%r14
mov    %r8,0x68(%rsp)
mov    %rcx,0x60(%rsp)
mov    %edx,%r12d
mov    %rsi,%rbp
mov    %edi,%ebx
mov    0xf0(%rsp),%rax
mov    %rax,0x28(%rsp)
mov    0xe8(%rsp),%r15
mov    0xe0(%rsp),%rax
mov    %rax,0x80(%rsp)
mov    0xd8(%rsp),%rax
mov    %rax,0x78(%rsp)
mov    0xd0(%rsp),%rax
mov    %rax,0x70(%rsp)
mov    0xc8(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    0xc0(%rsp),%rax
mov    %rax,0x58(%rsp)
xor    %edi,%edi
mov    %ebx,%esi
call   1040 <ivector@plt>
mov    %rax,%r13
xor    %edi,%edi
mov    %ebx,%esi
call   1040 <ivector@plt>
mov    %rax,0x8(%rsp)
xor    %edi,%edi
mov    %ebx,%esi
call   1040 <ivector@plt>
mov    %r15,%rdi
mov    %rbx,%r8
mov    %rax,%r15
mov    %r12d,0x1c(%rsp)
test   %r12d,%r12d
jle    14d7 <permut_locations_of_groups_within_cat+0x3a7>
mov    %r14,%rcx
lea    0x1(%r8),%ebx
lea    -0x1(%rbx),%r14
lea    -0x2(%rbx),%rax
mov    %rax,0x30(%rsp)
mov    %r14,%rax
mov    %r14,0x38(%rsp)
and    $0xfffffffffffffffe,%r14
neg    %r14
mov    $0x1,%r12d
mov    %r8,0x20(%rsp)
mov    %rcx,0x50(%rsp)
mov    %rdi,0x48(%rsp)
mov    %rbx,0x40(%rsp)
jmp    1263 <permut_locations_of_groups_within_cat+0x133>
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
xor    %edx,%edx
mov    0x28(%rsp),%rcx
call   1050 <resample_shuffle@plt>
mov    0x20(%rsp),%r8
lea    0x1(%r12),%eax
cmp    0x1c(%rsp),%r12d
mov    %eax,%r12d
mov    0x40(%rsp),%rbx
je     14d7 <permut_locations_of_groups_within_cat+0x3a7>
test   %r8d,%r8d
jle    1230 <permut_locations_of_groups_within_cat+0x100>
xor    %edx,%edx
mov    $0x1,%eax
mov    0x10(%rsp),%r8
jmp    129d <permut_locations_of_groups_within_cat+0x16d>
cs nopw 0x0(%rax,%rax,1)
movslq %edx,%rsi
add    $0x1,%edx
mov    %ecx,0x4(%r15,%rsi,4)
mov    0x8(%rsp),%rcx
mov    %eax,0x4(%rcx,%rsi,4)
add    $0x1,%rax
cmp    %rbx,%rax
je     12d0 <permut_locations_of_groups_within_cat+0x1a0>
cmp    %r12d,0x0(%rbp,%rax,4)
jne    1294 <permut_locations_of_groups_within_cat+0x164>
mov    (%r8,%rax,4),%ecx
mov    %edx,%esi
test   %edx,%edx
jle    1280 <permut_locations_of_groups_within_cat+0x150>
xchg   %ax,%ax
mov    %esi,%edi
cmp    (%r15,%rdi,4),%ecx
je     1294 <permut_locations_of_groups_within_cat+0x164>
lea    -0x1(%rsi),%edi
cmp    $0x2,%esi
mov    %edi,%esi
jge    12b0 <permut_locations_of_groups_within_cat+0x180>
jmp    1280 <permut_locations_of_groups_within_cat+0x150>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rsp),%rdi
mov    $0x1,%esi
mov    0x28(%rsp),%rcx
call   1050 <resample_shuffle@plt>
mov    0x20(%rsp),%r8
test   %r8d,%r8d
mov    0x50(%rsp),%r9
mov    0x68(%rsp),%r10
mov    0x60(%rsp),%r11
mov    0x48(%rsp),%rdi
mov    0x58(%rsp),%rbx
movsd  0xcf3(%rip),%xmm1
jle    124b <permut_locations_of_groups_within_cat+0x11b>
cmpq   $0x0,0x30(%rsp)
je     137f <permut_locations_of_groups_within_cat+0x24f>
mov    $0x1,%eax
jmp    1342 <permut_locations_of_groups_within_cat+0x212>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%r14,%rax,1),%rcx
add    $0x2,%rcx
add    $0x2,%rax
cmp    $0x1,%rcx
je     1384 <permut_locations_of_groups_within_cat+0x254>
cmp    %r12d,0x0(%rbp,%rax,4)
jne    135f <permut_locations_of_groups_within_cat+0x22f>
mov    0x10(%rsp),%rcx
movslq (%rcx,%rax,4),%rcx
mov    0x8(%rsp),%rdx
mov    (%rdx,%rcx,4),%ecx
mov    %ecx,0x0(%r13,%rax,4)
cmp    %r12d,0x4(%rbp,%rax,4)
jne    1330 <permut_locations_of_groups_within_cat+0x200>
mov    0x10(%rsp),%rcx
movslq 0x4(%rcx,%rax,4),%rcx
mov    0x8(%rsp),%rdx
mov    (%rdx,%rcx,4),%ecx
mov    %ecx,0x4(%r13,%rax,4)
jmp    1330 <permut_locations_of_groups_within_cat+0x200>
mov    $0x1,%eax
testb  $0x1,0x38(%rsp)
je     13a8 <permut_locations_of_groups_within_cat+0x278>
cmp    %r12d,0x0(%rbp,%rax,4)
jne    13a8 <permut_locations_of_groups_within_cat+0x278>
mov    0x10(%rsp),%rcx
movslq (%rcx,%rax,4),%rcx
mov    0x8(%rsp),%rdx
mov    (%rdx,%rcx,4),%ecx
mov    %ecx,0x0(%r13,%rax,4)
test   %r8d,%r8d
jle    124b <permut_locations_of_groups_within_cat+0x11b>
mov    $0x1,%eax
jmp    13cf <permut_locations_of_groups_within_cat+0x29f>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rax
cmp    0x40(%rsp),%rax
je     124b <permut_locations_of_groups_within_cat+0x11b>
cmp    %r12d,0x0(%rbp,%rax,4)
jne    13c0 <permut_locations_of_groups_within_cat+0x290>
mov    (%rbx),%rcx
movsd  (%rcx),%xmm0
ucomisd %xmm1,%xmm0
jne    13e5 <permut_locations_of_groups_within_cat+0x2b5>
jnp    1429 <permut_locations_of_groups_within_cat+0x2f9>
movslq 0x0(%r13,%rax,4),%rdx
movsd  (%r11,%rdx,8),%xmm0
mov    0x70(%rsp),%rsi
movsd  %xmm0,(%rsi,%rax,8)
movsd  (%r10,%rdx,8),%xmm0
mov    0x78(%rsp),%rsi
movsd  %xmm0,(%rsi,%rax,8)
movsd  (%r9,%rdx,8),%xmm0
mov    0x80(%rsp),%rdx
movsd  %xmm0,(%rdx,%rax,8)
movsd  (%rcx),%xmm0
ucomisd %xmm1,%xmm0
jne    13c0 <permut_locations_of_groups_within_cat+0x290>
jp     13c0 <permut_locations_of_groups_within_cat+0x290>
cmpq   $0x0,0x30(%rsp)
je     149b <permut_locations_of_groups_within_cat+0x36b>
mov    $0x1,%ecx
jmp    1452 <permut_locations_of_groups_within_cat+0x322>
nopl   0x0(%rax,%rax,1)
lea    (%r14,%rcx,1),%rdx
add    $0x2,%rdx
add    $0x2,%rcx
cmp    $0x1,%rdx
je     14a0 <permut_locations_of_groups_within_cat+0x370>
cmp    %r12d,0x0(%rbp,%rcx,4)
jne    1475 <permut_locations_of_groups_within_cat+0x345>
movslq 0x0(%r13,%rax,4),%rdx
mov    (%rbx,%rdx,8),%rdx
movslq 0x0(%r13,%rcx,4),%rsi
movsd  (%rdx,%rsi,8),%xmm0
mov    (%rdi,%rax,8),%rdx
movsd  %xmm0,(%rdx,%rcx,8)
cmp    %r12d,0x4(%rbp,%rcx,4)
jne    1440 <permut_locations_of_groups_within_cat+0x310>
movslq 0x0(%r13,%rax,4),%rdx
mov    (%rbx,%rdx,8),%rdx
movslq 0x4(%r13,%rcx,4),%rsi
movsd  (%rdx,%rsi,8),%xmm0
mov    (%rdi,%rax,8),%rdx
movsd  %xmm0,0x8(%rdx,%rcx,8)
jmp    1440 <permut_locations_of_groups_within_cat+0x310>
mov    $0x1,%ecx
testb  $0x1,0x38(%rsp)
je     13c0 <permut_locations_of_groups_within_cat+0x290>
cmp    %r12d,0x0(%rbp,%rcx,4)
jne    13c0 <permut_locations_of_groups_within_cat+0x290>
movslq 0x0(%r13,%rax,4),%rdx
mov    (%rbx,%rdx,8),%rdx
movslq 0x0(%r13,%rcx,4),%rsi
movsd  (%rdx,%rsi,8),%xmm0
mov    (%rdi,%rax,8),%rdx
movsd  %xmm0,(%rdx,%rcx,8)
jmp    13c0 <permut_locations_of_groups_within_cat+0x290>
mov    %r13,%rdi
xor    %esi,%esi
mov    %r8d,%edx
mov    %r8,%rbx
call   1030 <free_ivector@plt>
mov    0x8(%rsp),%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1030 <free_ivector@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    %ebx,%edx
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free_ivector@plt>

LLVM IR (-O0):
define void @permut_locations_of_groups_within_cat(i32 %0, i32* %1, i32 %2, double* %3, double* %4, double* %5, double** %6, i32* %7, double* %8, double* %9, double* %10, double** %11, i64* %12) {
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32
%17 = alloca double*
%18 = alloca double*
%19 = alloca double*
%20 = alloca double**
%21 = alloca i32*
%22 = alloca double*
%23 = alloca double*
%24 = alloca double*
%25 = alloca double**
%26 = alloca i64*
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32*
%33 = alloca i32*
%34 = alloca i32*
%35 = alloca i32
%36 = alloca i32
%37 = alloca i32
store i32 %0, i32* %14
store i32* %1, i32** %15
store i32 %2, i32* %16
store double* %3, double** %17
store double* %4, double** %18
store double* %5, double** %19
store double** %6, double*** %20
store i32* %7, i32** %21
store double* %8, double** %22
store double* %9, double** %23
store double* %10, double** %24
store double** %11, double*** %25
store i64* %12, i64** %26
%38 = load i32, i32* %14
%39 = call i32* @ivector(i32 0, i32 %38)
store i32* %39, i32** %32
%40 = load i32, i32* %14
%41 = call i32* @ivector(i32 0, i32 %40)
store i32* %41, i32** %33
%42 = load i32, i32* %14
%43 = call i32* @ivector(i32 0, i32 %42)
store i32* %43, i32** %34
store i32 1, i32* %31
br label %44
44: ; preds = %260, %13
%45 = load i32, i32* %31
%46 = load i32, i32* %16
%47 = icmp sle i32 %45, %46
br i1 %47, label %48, label %263
48: ; preds = %44
store i32 0, i32* %36
store i32 1, i32* %27
br label %49
49: ; preds = %105, %48
%50 = load i32, i32* %27
%51 = load i32, i32* %14
%52 = icmp sle i32 %50, %51
br i1 %52, label %53, label %108
53: ; preds = %49
%54 = load i32*, i32** %15
%55 = load i32, i32* %27
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %54, i64 %56
%58 = load i32, i32* %57
%59 = load i32, i32* %31
%60 = icmp eq i32 %58, %59
br i1 %60, label %61, label %104
61: ; preds = %53
store i32 1, i32* %35
%62 = load i32, i32* %36
store i32 %62, i32* %37
br label %63
63: ; preds = %80, %61
%64 = load i32, i32* %37
%65 = icmp sge i32 %64, 1
br i1 %65, label %66, label %83
66: ; preds = %63
%67 = load i32*, i32** %21
%68 = load i32, i32* %27
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %67, i64 %69
%71 = load i32, i32* %70
%72 = load i32*, i32** %34
%73 = load i32, i32* %37
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i32, i32* %72, i64 %74
%76 = load i32, i32* %75
%77 = icmp eq i32 %71, %76
br i1 %77, label %78, label %79
78: ; preds = %66
store i32 0, i32* %35
br label %83
79: ; preds = %66
br label %80
80: ; preds = %79
%81 = load i32, i32* %37
%82 = add nsw i32 %81, -1
store i32 %82, i32* %37
br label %63
83: ; preds = %78, %63
%84 = load i32, i32* %35
%85 = icmp ne i32 %84, 0
br i1 %85, label %86, label %103
86: ; preds = %83
%87 = load i32, i32* %36
%88 = add nsw i32 %87, 1
store i32 %88, i32* %36
%89 = load i32*, i32** %21
%90 = load i32, i32* %27
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i32, i32* %89, i64 %91
%93 = load i32, i32* %92
%94 = load i32*, i32** %34
%95 = load i32, i32* %36
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i32, i32* %94, i64 %96
store i32 %93, i32* %97
%98 = load i32, i32* %27
%99 = load i32*, i32** %33
%100 = load i32, i32* %36
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i32, i32* %99, i64 %101
store i32 %98, i32* %102
br label %103
103: ; preds = %86, %83
br label %104
104: ; preds = %103, %53
br label %105
105: ; preds = %104
%106 = load i32, i32* %27
%107 = add nsw i32 %106, 1
store i32 %107, i32* %27
br label %49
108: ; preds = %49
%109 = load i32*, i32** %33
%110 = load i32, i32* %36
%111 = load i64*, i64** %26
%112 = call i32 @resample_shuffle(i32* %109, i32 1, i32 %110, i64* %111)
store i32 1, i32* %27
br label %113
113: ; preds = %140, %108
%114 = load i32, i32* %27
%115 = load i32, i32* %14
%116 = icmp sle i32 %114, %115
br i1 %116, label %117, label %143
117: ; preds = %113
%118 = load i32*, i32** %15
%119 = load i32, i32* %27
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds i32, i32* %118, i64 %120
%122 = load i32, i32* %121
%123 = load i32, i32* %31
%124 = icmp eq i32 %122, %123
br i1 %124, label %125, label %139
125: ; preds = %117
%126 = load i32*, i32** %33
%127 = load i32*, i32** %21
%128 = load i32, i32* %27
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i32, i32* %127, i64 %129
%131 = load i32, i32* %130
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds i32, i32* %126, i64 %132
%134 = load i32, i32* %133
%135 = load i32*, i32** %32
%136 = load i32, i32* %27
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds i32, i32* %135, i64 %137
store i32 %134, i32* %138
br label %139
139: ; preds = %125, %117
br label %140
140: ; preds = %139
%141 = load i32, i32* %27
%142 = add nsw i32 %141, 1
store i32 %142, i32* %27
br label %113
143: ; preds = %113
store i32 1, i32* %27
br label %144
144: ; preds = %256, %143
%145 = load i32, i32* %27
%146 = load i32, i32* %14
%147 = icmp sle i32 %145, %146
br i1 %147, label %148, label %259
148: ; preds = %144
%149 = load i32*, i32** %15
%150 = load i32, i32* %27
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds i32, i32* %149, i64 %151
%153 = load i32, i32* %152
%154 = load i32, i32* %31
%155 = icmp eq i32 %153, %154
br i1 %155, label %156, label %255
156: ; preds = %148
%157 = load double**, double*** %20
%158 = getelementptr inbounds double*, double** %157, i64 0
%159 = load double*, double** %158
%160 = getelementptr inbounds double, double* %159, i64 0
%161 = load double, double* %160
%162 = fcmp une double %161, 1.000000e+00
br i1 %162, label %163, label %203
163: ; preds = %156
%164 = load double*, double** %17
%165 = load i32*, i32** %32
%166 = load i32, i32* %27
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds i32, i32* %165, i64 %167
%169 = load i32, i32* %168
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds double, double* %164, i64 %170
%172 = load double, double* %171
%173 = load double*, double** %22
%174 = load i32, i32* %27
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds double, double* %173, i64 %175
store double %172, double* %176
%177 = load double*, double** %18
%178 = load i32*, i32** %32
%179 = load i32, i32* %27
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds i32, i32* %178, i64 %180
%182 = load i32, i32* %181
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds double, double* %177, i64 %183
%185 = load double, double* %184
%186 = load double*, double** %23
%187 = load i32, i32* %27
%188 = sext i32 %187 to i64
%189 = getelementptr inbounds double, double* %186, i64 %188
store double %185, double* %189
%190 = load double*, double** %19
%191 = load i32*, i32** %32
%192 = load i32, i32* %27
%193 = sext i32 %192 to i64
%194 = getelementptr inbounds i32, i32* %191, i64 %193
%195 = load i32, i32* %194
%196 = sext i32 %195 to i64
%197 = getelementptr inbounds double, double* %190, i64 %196
%198 = load double, double* %197
%199 = load double*, double** %24
%200 = load i32, i32* %27
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds double, double* %199, i64 %201
store double %198, double* %202
br label %203
203: ; preds = %163, %156
%204 = load double**, double*** %20
%205 = getelementptr inbounds double*, double** %204, i64 0
%206 = load double*, double** %205
%207 = getelementptr inbounds double, double* %206, i64 0
%208 = load double, double* %207
%209 = fcmp oeq double %208, 1.000000e+00
br i1 %209, label %210, label %254
210: ; preds = %203
store i32 1, i32* %29
br label %211
211: ; preds = %250, %210
%212 = load i32, i32* %29
%213 = load i32, i32* %14
%214 = icmp sle i32 %212, %213
br i1 %214, label %215, label %253
215: ; preds = %211
%216 = load i32*, i32** %15
%217 = load i32, i32* %29
%218 = sext i32 %217 to i64
%219 = getelementptr inbounds i32, i32* %216, i64 %218
%220 = load i32, i32* %219
%221 = load i32, i32* %31
%222 = icmp eq i32 %220, %221
br i1 %222, label %223, label %249
223: ; preds = %215
%224 = load double**, double*** %20
%225 = load i32*, i32** %32
%226 = load i32, i32* %27
%227 = sext i32 %226 to i64
%228 = getelementptr inbounds i32, i32* %225, i64 %227
%229 = load i32, i32* %228
%230 = sext i32 %229 to i64
%231 = getelementptr inbounds double*, double** %224, i64 %230
%232 = load double*, double** %231
%233 = load i32*, i32** %32
%234 = load i32, i32* %29
%235 = sext i32 %234 to i64
%236 = getelementptr inbounds i32, i32* %233, i64 %235
%237 = load i32, i32* %236
%238 = sext i32 %237 to i64
%239 = getelementptr inbounds double, double* %232, i64 %238
%240 = load double, double* %239
%241 = load double**, double*** %25
%242 = load i32, i32* %27
%243 = sext i32 %242 to i64
%244 = getelementptr inbounds double*, double** %241, i64 %243
%245 = load double*, double** %244
%246 = load i32, i32* %29
%247 = sext i32 %246 to i64
%248 = getelementptr inbounds double, double* %245, i64 %247
store double %240, double* %248
br label %249
249: ; preds = %223, %215
br label %250
250: ; preds = %249
%251 = load i32, i32* %29
%252 = add nsw i32 %251, 1
store i32 %252, i32* %29
br label %211
253: ; preds = %211
br label %254
254: ; preds = %253, %203
br label %255
255: ; preds = %254, %148
br label %256
256: ; preds = %255
%257 = load i32, i32* %27
%258 = add nsw i32 %257, 1
store i32 %258, i32* %27
br label %144
259: ; preds = %144
br label %260
260: ; preds = %259
%261 = load i32, i32* %31
%262 = add nsw i32 %261, 1
store i32 %262, i32* %31
br label %44
263: ; preds = %44
%264 = load i32*, i32** %32
%265 = load i32, i32* %14
%266 = call i32 @free_ivector(i32* %264, i32 0, i32 %265)
%267 = load i32*, i32** %33
%268 = load i32, i32* %14
%269 = call i32 @free_ivector(i32* %267, i32 0, i32 %268)
%270 = load i32*, i32** %34
%271 = load i32, i32* %14
%272 = call i32 @free_ivector(i32* %270, i32 0, i32 %271)
ret void
}

LLVM IR (-O2):
define void @permut_locations_of_groups_within_cat(i32 %0, i32* nocapture %1, i32 %2, double* nocapture %3, double* nocapture %4, double* nocapture %5, double** nocapture %6, i32* nocapture %7, double* nocapture writeonly %8, double* nocapture writeonly %9, double* nocapture writeonly %10, double** nocapture %11, i64* %12) {
%14 = tail call i32* @ivector(i32 0, i32 %0)
%15 = tail call i32* @ivector(i32 0, i32 %0)
%16 = tail call i32* @ivector(i32 0, i32 %0)
%17 = icmp slt i32 %2, 1
br i1 %17, label %202, label %18
18: ; preds = %13
%19 = icmp slt i32 %0, 1
%20 = add i32 %0, 1
%21 = zext i32 %20 to i64
%22 = zext i32 %20 to i64
%23 = add nsw i64 %21, -1
%24 = add nsw i64 %21, -2
%25 = and i64 %23, 1
%26 = icmp eq i64 %24, 0
%27 = and i64 %23, -2
%28 = icmp eq i64 %25, 0
%29 = and i64 %23, 1
%30 = icmp eq i64 %24, 0
%31 = and i64 %23, -2
%32 = icmp eq i64 %29, 0
br label %33
33: ; preds = %18, %199
%34 = phi i32 [ 1, %18 ], [ %200, %199 ]
br i1 %19, label %35, label %37
35: ; preds = %33
%36 = tail call i32 @resample_shuffle(i32* %15, i32 1, i32 0, i64* %12)
br label %199
37: ; preds = %33, %62
%38 = phi i64 [ %64, %62 ], [ 1, %33 ]
%39 = phi i32 [ %63, %62 ], [ 0, %33 ]
%40 = getelementptr inbounds i32, i32* %1, i64 %38
%41 = load i32, i32* %40
%42 = icmp eq i32 %41, %34
br i1 %42, label %43, label %62
43: ; preds = %37
%44 = icmp sgt i32 %39, 0
%45 = getelementptr inbounds i32, i32* %7, i64 %38
%46 = load i32, i32* %45
br i1 %44, label %50, label %56
47: ; preds = %50
%48 = add nsw i32 %51, -1
%49 = icmp sgt i32 %51, 1
br i1 %49, label %50, label %56
50: ; preds = %43, %47
%51 = phi i32 [ %48, %47 ], [ %39, %43 ]
%52 = zext i32 %51 to i64
%53 = getelementptr inbounds i32, i32* %16, i64 %52
%54 = load i32, i32* %53
%55 = icmp eq i32 %46, %54
br i1 %55, label %62, label %47
56: ; preds = %47, %43
%57 = add nsw i32 %39, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i32, i32* %16, i64 %58
store i32 %46, i32* %59
%60 = getelementptr inbounds i32, i32* %15, i64 %58
%61 = trunc i64 %38 to i32
store i32 %61, i32* %60
br label %62
62: ; preds = %50, %37, %56
%63 = phi i32 [ %57, %56 ], [ %39, %37 ], [ %39, %50 ]
%64 = add nuw nsw i64 %38, 1
%65 = icmp eq i64 %64, %21
br i1 %65, label %66, label %37
66: ; preds = %62
%67 = tail call i32 @resample_shuffle(i32* %15, i32 1, i32 %63, i64* %12)
br i1 %19, label %199, label %68
68: ; preds = %66
br i1 %26, label %69, label %83
69: ; preds = %108, %68
%70 = phi i64 [ 1, %68 ], [ %109, %108 ]
br i1 %28, label %82, label %71
71: ; preds = %69
%72 = getelementptr inbounds i32, i32* %1, i64 %70
%73 = load i32, i32* %72
%74 = icmp eq i32 %73, %34
br i1 %74, label %75, label %82
75: ; preds = %71
%76 = getelementptr inbounds i32, i32* %7, i64 %70
%77 = load i32, i32* %76
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i32, i32* %15, i64 %78
%80 = load i32, i32* %79
%81 = getelementptr inbounds i32, i32* %14, i64 %70
store i32 %80, i32* %81
br label %82
82: ; preds = %71, %75, %69
br i1 %19, label %199, label %112
83: ; preds = %68, %108
%84 = phi i64 [ %109, %108 ], [ 1, %68 ]
%85 = phi i64 [ %110, %108 ], [ 0, %68 ]
%86 = getelementptr inbounds i32, i32* %1, i64 %84
%87 = load i32, i32* %86
%88 = icmp eq i32 %87, %34
br i1 %88, label %89, label %96
89: ; preds = %83
%90 = getelementptr inbounds i32, i32* %7, i64 %84
%91 = load i32, i32* %90
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i32, i32* %15, i64 %92
%94 = load i32, i32* %93
%95 = getelementptr inbounds i32, i32* %14, i64 %84
store i32 %94, i32* %95
br label %96
96: ; preds = %83, %89
%97 = add nuw nsw i64 %84, 1
%98 = getelementptr inbounds i32, i32* %1, i64 %97
%99 = load i32, i32* %98
%100 = icmp eq i32 %99, %34
br i1 %100, label %101, label %108
101: ; preds = %96
%102 = getelementptr inbounds i32, i32* %7, i64 %97
%103 = load i32, i32* %102
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i32, i32* %15, i64 %104
%106 = load i32, i32* %105
%107 = getelementptr inbounds i32, i32* %14, i64 %97
store i32 %106, i32* %107
br label %108
108: ; preds = %101, %96
%109 = add nuw nsw i64 %84, 2
%110 = add i64 %85, 2
%111 = icmp eq i64 %110, %27
br i1 %111, label %69, label %83
112: ; preds = %82, %196
%113 = phi i64 [ %197, %196 ], [ 1, %82 ]
%114 = getelementptr inbounds i32, i32* %1, i64 %113
%115 = load i32, i32* %114
%116 = icmp eq i32 %115, %34
br i1 %116, label %117, label %196
117: ; preds = %112
%118 = load double*, double** %6
%119 = load double, double* %118
%120 = fcmp une double %119, 1.000000e+00
br i1 %120, label %121, label %136
121: ; preds = %117
%122 = getelementptr inbounds i32, i32* %14, i64 %113
%123 = load i32, i32* %122
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds double, double* %3, i64 %124
%126 = load double, double* %125
%127 = getelementptr inbounds double, double* %8, i64 %113
store double %126, double* %127
%128 = getelementptr inbounds double, double* %4, i64 %124
%129 = load double, double* %128
%130 = getelementptr inbounds double, double* %9, i64 %113
store double %129, double* %130
%131 = getelementptr inbounds double, double* %5, i64 %124
%132 = load double, double* %131
%133 = getelementptr inbounds double, double* %10, i64 %113
store double %132, double* %133
%134 = load double, double* %118
%135 = fcmp une double %134, 1.000000e+00
br i1 %135, label %196, label %136
136: ; preds = %117, %121
%137 = getelementptr inbounds i32, i32* %14, i64 %113
%138 = getelementptr inbounds double*, double** %11, i64 %113
br i1 %30, label %178, label %139
139: ; preds = %136, %174
%140 = phi i64 [ %175, %174 ], [ 1, %136 ]
%141 = phi i64 [ %176, %174 ], [ 0, %136 ]
%142 = getelementptr inbounds i32, i32* %1, i64 %140
%143 = load i32, i32* %142
%144 = icmp eq i32 %143, %34
br i1 %144, label %145, label %157
145: ; preds = %139
%146 = load i32, i32* %137
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds double*, double** %6, i64 %147
%149 = load double*, double** %148
%150 = getelementptr inbounds i32, i32* %14, i64 %140
%151 = load i32, i32* %150
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds double, double* %149, i64 %152
%154 = load double, double* %153
%155 = load double*, double** %138
%156 = getelementptr inbounds double, double* %155, i64 %140
store double %154, double* %156
br label %157
157: ; preds = %139, %145
%158 = add nuw nsw i64 %140, 1
%159 = getelementptr inbounds i32, i32* %1, i64 %158
%160 = load i32, i32* %159
%161 = icmp eq i32 %160, %34
br i1 %161, label %162, label %174
162: ; preds = %157
%163 = load i32, i32* %137
%164 = sext i32 %163 to i64
%165 = getelementptr inbounds double*, double** %6, i64 %164
%166 = load double*, double** %165
%167 = getelementptr inbounds i32, i32* %14, i64 %158
%168 = load i32, i32* %167
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds double, double* %166, i64 %169
%171 = load double, double* %170
%172 = load double*, double** %138
%173 = getelementptr inbounds double, double* %172, i64 %158
store double %171, double* %173
br label %174
174: ; preds = %162, %157
%175 = add nuw nsw i64 %140, 2
%176 = add i64 %141, 2
%177 = icmp eq i64 %176, %31
br i1 %177, label %178, label %139
178: ; preds = %174, %136
%179 = phi i64 [ 1, %136 ], [ %175, %174 ]
br i1 %32, label %196, label %180
180: ; preds = %178
%181 = getelementptr inbounds i32, i32* %1, i64 %179
%182 = load i32, i32* %181
%183 = icmp eq i32 %182, %34
br i1 %183, label %184, label %196
184: ; preds = %180
%185 = load i32, i32* %137
%186 = sext i32 %185 to i64
%187 = getelementptr inbounds double*, double** %6, i64 %186
%188 = load double*, double** %187
%189 = getelementptr inbounds i32, i32* %14, i64 %179
%190 = load i32, i32* %189
%191 = sext i32 %190 to i64
%192 = getelementptr inbounds double, double* %188, i64 %191
%193 = load double, double* %192
%194 = load double*, double** %138
%195 = getelementptr inbounds double, double* %194, i64 %179
store double %193, double* %195
br label %196
196: ; preds = %178, %184, %180, %121, %112
%197 = add nuw nsw i64 %113, 1
%198 = icmp eq i64 %197, %22
br i1 %198, label %199, label %112
199: ; preds = %196, %66, %35, %82
%200 = add nuw i32 %34, 1
%201 = icmp eq i32 %34, %2
br i1 %201, label %202, label %33
202: ; preds = %199, %13
%203 = tail call i32 @free_ivector(i32* %14, i32 0, i32 %0)
%204 = tail call i32 @free_ivector(i32* %15, i32 0, i32 %0)
%205 = tail call i32 @free_ivector(i32* %16, i32 0, i32 %0)
ret void
}