#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 */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ fatalx(char *, int);
int /*<<< orphan*/ free(double **);
void dppermute(double **a, int *ind, int len) {
  int i, k;
  double **rrr;
  if ((rrr = (double **)calloc((len), sizeof(double *))) == NULL)
    fatalx("Unable to allocate %d unit(s) for item \n", len);
  for (i = 0; i < len; i++) {
    rrr[i] = a[i];
  }
  for (i = 0; i < len; i++) {
    k = ind[i];
    a[i] = rrr[k];
  }
  free(rrr);
}


x86 assembly (clang, -O0):
<dppermute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    116d <dppermute+0x3d>
mov    -0x14(%rbp),%esi
lea    0xe98(%rip),%rdi
call   1040 <fatalx@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a6 <dppermute+0x76>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1174 <dppermute+0x44>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ed <dppermute+0xbd>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ad <dppermute+0x7d>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dppermute>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1164 <dppermute+0x34>
lea    0xea4(%rip),%rdi
mov    %r12d,%esi
call   1040 <fatalx@plt>
test   %r12d,%r12d
jle    1355 <dppermute+0x225>
mov    %r12d,%eax
cmp    $0x4,%r12d
jb     1188 <dppermute+0x58>
lea    (%r15,%rax,8),%rcx
cmp    %rcx,%rbx
jae    11f4 <dppermute+0xc4>
lea    (%rbx,%rax,8),%rcx
cmp    %r15,%rcx
jbe    11f4 <dppermute+0xc4>
xor    %ecx,%ecx
mov    %rcx,%rdx
not    %rdx
add    %rax,%rdx
mov    %rax,%rsi
and    $0x3,%rsi
je     11b2 <dppermute+0x82>
nopl   0x0(%rax)
mov    (%r15,%rcx,8),%rdi
mov    %rdi,(%rbx,%rcx,8)
add    $0x1,%rcx
add    $0xffffffffffffffff,%rsi
jne    11a0 <dppermute+0x70>
cmp    $0x3,%rdx
jb     12c4 <dppermute+0x194>
nopl   0x0(%rax)
mov    (%r15,%rcx,8),%rdx
mov    %rdx,(%rbx,%rcx,8)
mov    0x8(%r15,%rcx,8),%rdx
mov    %rdx,0x8(%rbx,%rcx,8)
mov    0x10(%r15,%rcx,8),%rdx
mov    %rdx,0x10(%rbx,%rcx,8)
mov    0x18(%r15,%rcx,8),%rdx
mov    %rdx,0x18(%rbx,%rcx,8)
add    $0x4,%rcx
cmp    %rcx,%rax
jne    11c0 <dppermute+0x90>
jmp    12c4 <dppermute+0x194>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
lea    -0x4(%rcx),%rdi
mov    %rdi,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
mov    %esi,%edx
and    $0x3,%edx
cmp    $0xc,%rdi
jae    1217 <dppermute+0xe7>
xor    %edi,%edi
jmp    1280 <dppermute+0x150>
and    $0xfffffffffffffffc,%rsi
xor    %edi,%edi
nopl   (%rax)
movups (%r15,%rdi,8),%xmm0
movups 0x10(%r15,%rdi,8),%xmm1
movups %xmm0,(%rbx,%rdi,8)
movups %xmm1,0x10(%rbx,%rdi,8)
movups 0x20(%r15,%rdi,8),%xmm0
movups 0x30(%r15,%rdi,8),%xmm1
movups %xmm0,0x20(%rbx,%rdi,8)
movups %xmm1,0x30(%rbx,%rdi,8)
movups 0x40(%r15,%rdi,8),%xmm0
movups 0x50(%r15,%rdi,8),%xmm1
movups %xmm0,0x40(%rbx,%rdi,8)
movups %xmm1,0x50(%rbx,%rdi,8)
movups 0x60(%r15,%rdi,8),%xmm0
movups 0x70(%r15,%rdi,8),%xmm1
movups %xmm0,0x60(%rbx,%rdi,8)
movups %xmm1,0x70(%rbx,%rdi,8)
add    $0x10,%rdi
add    $0xfffffffffffffffc,%rsi
jne    1220 <dppermute+0xf0>
test   %rdx,%rdx
je     12bb <dppermute+0x18b>
lea    (%rbx,%rdi,8),%rsi
add    $0x10,%rsi
lea    (%r15,%rdi,8),%rdi
add    $0x10,%rdi
shl    $0x5,%rdx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movups -0x10(%rdi,%rbp,1),%xmm0
movups (%rdi,%rbp,1),%xmm1
movups %xmm0,-0x10(%rsi,%rbp,1)
movups %xmm1,(%rsi,%rbp,1)
add    $0x20,%rbp
cmp    %rbp,%rdx
jne    12a0 <dppermute+0x170>
cmp    %rax,%rcx
jne    118a <dppermute+0x5a>
test   %r12d,%r12d
jle    1355 <dppermute+0x225>
lea    -0x1(%rax),%rdx
mov    %eax,%ecx
and    $0x3,%ecx
cmp    $0x3,%rdx
jae    12e0 <dppermute+0x1b0>
xor    %edx,%edx
jmp    132f <dppermute+0x1ff>
and    $0xfffffffc,%eax
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nop
movslq (%r14,%rdx,4),%rsi
mov    (%rbx,%rsi,8),%rsi
mov    %rsi,(%r15,%rdx,8)
movslq 0x4(%r14,%rdx,4),%rsi
mov    (%rbx,%rsi,8),%rsi
mov    %rsi,0x8(%r15,%rdx,8)
movslq 0x8(%r14,%rdx,4),%rsi
mov    (%rbx,%rsi,8),%rsi
mov    %rsi,0x10(%r15,%rdx,8)
movslq 0xc(%r14,%rdx,4),%rsi
mov    (%rbx,%rsi,8),%rsi
mov    %rsi,0x18(%r15,%rdx,8)
add    $0x4,%rdx
cmp    %rdx,%rax
jne    12f0 <dppermute+0x1c0>
test   %rcx,%rcx
je     1355 <dppermute+0x225>
lea    (%r15,%rdx,8),%rax
lea    (%r14,%rdx,4),%rdx
xor    %esi,%esi
xchg   %ax,%ax
movslq (%rdx,%rsi,4),%rdi
mov    (%rbx,%rdi,8),%rdi
mov    %rdi,(%rax,%rsi,8)
add    $0x1,%rsi
cmp    %rsi,%rcx
jne    1340 <dppermute+0x210>
mov    %rbx,%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"Unable to allocate %d unit(s) for item \0A\00"
define void @dppermute(double** %0, i32* %1, i32 %2) {
%4 = alloca double**
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca double**
store double** %0, double*** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = call i64 @calloc(i32 %10, i32 8)
%12 = inttoptr i64 %11 to double**
store double** %12, double*** %9
%13 = icmp eq double** %12, null
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load i32, i32* %6
%16 = call i32 @fatalx(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %14, %3
store i32 0, i32* %7
br label %18
18: ; preds = %32, %17
%19 = load i32, i32* %7
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %35
22: ; preds = %18
%23 = load double**, double*** %4
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds double*, double** %23, i64 %25
%27 = load double*, double** %26
%28 = load double**, double*** %9
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double*, double** %28, i64 %30
store double* %27, double** %31
br label %32
32: ; preds = %22
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %18
35: ; preds = %18
store i32 0, i32* %7
br label %36
36: ; preds = %55, %35
%37 = load i32, i32* %7
%38 = load i32, i32* %6
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %58
40: ; preds = %36
%41 = load i32*, i32** %5
%42 = load i32, i32* %7
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* %41, i64 %43
%45 = load i32, i32* %44
store i32 %45, i32* %8
%46 = load double**, double*** %9
%47 = load i32, i32* %8
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double*, double** %46, i64 %48
%50 = load double*, double** %49
%51 = load double**, double*** %4
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double*, double** %51, i64 %53
store double* %50, double** %54
br label %55
55: ; preds = %40
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
br label %36
58: ; preds = %36
%59 = load double**, double*** %9
%60 = call i32 @free(double** %59)
ret void
}

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