#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 */
typedef int /*<<< orphan*/ types;
typedef int /*<<< orphan*/ sizes;

/* Variables and functions */
int /*<<< orphan*/ blosc_compress(int, int, int, int, char *, char *, int);
int /*<<< orphan*/ blosc_decompress(char *, char *, int);
int /*<<< orphan*/ free(char *);
char *malloc(int);
char rand();
char *test_shuffle() {
  int sizes[] = {7, 64 * 3, 7 * 256, 500, 8000, 100000, 702713};
  int types[] = {1, 2, 3, 4, 5, 6, 7, 8, 16};
  int i, j, k;
  int ok;
  for (i = 0; i < sizeof(sizes) / sizeof(sizes[0]); i++) {
    for (j = 0; j < sizeof(types) / sizeof(types[0]); j++) {
      int n = sizes[i];
      int t = types[j];
      char *d = malloc(t * n);
      char *d2 = malloc(t * n);
      char *o = malloc(t * n + 16);
      for (k = 0; k < n; k++) {
        d[k] = rand();
      }
      blosc_compress(5, 1, t, t * n, d, o, t * n + 16);
      blosc_decompress(o, d2, t * n);
      ok = 1;
      for (k = 0; ok && k < n; k++) {
        ok = (d[k] == d2[k]);
      }
      free(d);
      free(d2);
      free(o);
      do {
        if (!(ok))
          return "ERROR: shuffle test failed";
      } while (0);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_shuffle>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    0xe8e(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe8b(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe88(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe86(%rip),%eax
mov    %eax,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe80(%rip),%rsi
mov    $0x24,%edx
call   1060 <memcpy@plt>
movl   $0x0,-0x64(%rbp)
movslq -0x64(%rbp),%rax
cmp    $0x7,%rax
jae    1381 <test_shuffle+0x221>
movl   $0x0,-0x68(%rbp)
movslq -0x68(%rbp),%rax
cmp    $0x9,%rax
jae    136e <test_shuffle+0x20e>
movslq -0x64(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x74(%rbp)
movslq -0x68(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%eax
mov    %eax,-0x78(%rbp)
mov    -0x78(%rbp),%edi
imul   -0x74(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x80(%rbp)
mov    -0x78(%rbp),%edi
imul   -0x74(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x88(%rbp)
mov    -0x78(%rbp),%edi
imul   -0x74(%rbp),%edi
add    $0x10,%edi
call   1070 <malloc@plt>
mov    %rax,-0x90(%rbp)
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    1258 <test_shuffle+0xf8>
mov    $0x0,%al
call   1080 <rand@plt>
mov    %al,%dl
mov    -0x80(%rbp),%rax
movslq -0x6c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    122a <test_shuffle+0xca>
mov    -0x78(%rbp),%edx
mov    -0x78(%rbp),%ecx
imul   -0x74(%rbp),%ecx
mov    -0x80(%rbp),%r8
mov    -0x90(%rbp),%r9
mov    -0x78(%rbp),%eax
imul   -0x74(%rbp),%eax
add    $0x10,%eax
mov    $0x5,%edi
mov    $0x1,%esi
mov    %eax,(%rsp)
call   1040 <blosc_compress@plt>
mov    -0x90(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    -0x78(%rbp),%edx
imul   -0x74(%rbp),%edx
call   1050 <blosc_decompress@plt>
movl   $0x1,-0x70(%rbp)
movl   $0x0,-0x6c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x70(%rbp)
mov    %al,-0x91(%rbp)
je     12d2 <test_shuffle+0x172>
mov    -0x6c(%rbp),%eax
cmp    -0x74(%rbp),%eax
setl   %al
mov    %al,-0x91(%rbp)
mov    -0x91(%rbp),%al
test   $0x1,%al
jne    12e5 <test_shuffle+0x185>
jmp    131b <test_shuffle+0x1bb>
mov    -0x80(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x88(%rbp),%rcx
movslq -0x6c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x70(%rbp)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    12b1 <test_shuffle+0x151>
mov    -0x80(%rbp),%rdi
call   1030 <free@plt>
mov    -0x88(%rbp),%rdi
call   1030 <free@plt>
mov    -0x90(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x70(%rbp)
jne    1356 <test_shuffle+0x1f6>
lea    0xcf7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1389 <test_shuffle+0x229>
jmp    135b <test_shuffle+0x1fb>
jmp    1360 <test_shuffle+0x200>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    11c6 <test_shuffle+0x66>
jmp    1373 <test_shuffle+0x213>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11b1 <test_shuffle+0x51>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_shuffle>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe9b(%rip),%rax
xor    %ecx,%ecx
mov    %rcx,0x18(%rsp)
movslq (%rax,%rcx,4),%rbp
cmp    $0x2,%ebp
mov    $0x1,%r12d
cmovge %ebp,%r12d
xor    %ecx,%ecx
nop
lea    0xe99(%rip),%rax
mov    %rcx,0x20(%rsp)
mov    (%rax,%rcx,4),%eax
mov    %eax,0xc(%rsp)
mov    %eax,%r13d
imul   %ebp,%r13d
mov    %r13d,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    %r13d,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
lea    0x10(%r13),%edi
mov    %edi,0x8(%rsp)
call   1060 <malloc@plt>
mov    %rax,0x10(%rsp)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1070 <rand@plt>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11d0 <test_shuffle+0x80>
mov    0x8(%rsp),%eax
mov    %eax,(%rsp)
mov    $0x5,%edi
mov    $0x1,%esi
mov    0xc(%rsp),%edx
mov    %r13d,%ecx
mov    %r14,%r8
mov    0x10(%rsp),%rbx
mov    %rbx,%r9
call   1040 <blosc_compress@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r13d,%edx
call   1050 <blosc_decompress@plt>
mov    $0x1,%eax
nop
movzbl -0x1(%r14,%rax,1),%r13d
movzbl -0x1(%r15,%rax,1),%ebx
cmp    %bl,%r13b
jne    123d <test_shuffle+0xed>
lea    0x1(%rax),%rcx
cmp    %rbp,%rax
mov    %rcx,%rax
jl     1220 <test_shuffle+0xd0>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
cmp    %bl,%r13b
jne    128d <test_shuffle+0x13d>
mov    0x20(%rsp),%rcx
add    $0x1,%rcx
cmp    $0x9,%rcx
jne    1180 <test_shuffle+0x30>
mov    0x18(%rsp),%rcx
add    $0x1,%rcx
cmp    $0x7,%rcx
lea    0xd7d(%rip),%rax
jne    1167 <test_shuffle+0x17>
xor    %eax,%eax
jmp    1294 <test_shuffle+0x144>
lea    0xdb0(%rip),%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.test_shuffle.sizes = [7 x i32] [i32 7, i32 192, i32 1792, i32 500, i32 8000, i32 100000, i32 702713]
@__const.test_shuffle.types = [9 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 16]
@.str = [27 x i8] c"ERROR: shuffle test failed\00"
define i8* @test_shuffle() {
%1 = alloca i8*
%2 = alloca [7 x i32]
%3 = alloca [9 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = bitcast [7 x i32]* %2 to i8*
%14 = bitcast [9 x i32]* %3 to i8*
store i32 0, i32* %4
br label %15
15: ; preds = %121, %0
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = icmp ult i64 %17, 7
br i1 %18, label %19, label %124
19: ; preds = %15
store i32 0, i32* %5
br label %20
20: ; preds = %117, %19
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = icmp ult i64 %22, 9
br i1 %23, label %24, label %120
24: ; preds = %20
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [7 x i32], [7 x i32]* %2, i64 0, i64 %26
%28 = load i32, i32* %27
store i32 %28, i32* %8
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 %30
%32 = load i32, i32* %31
store i32 %32, i32* %9
%33 = load i32, i32* %9
%34 = load i32, i32* %8
%35 = mul nsw i32 %33, %34
%36 = call i8* @malloc(i32 %35)
store i8* %36, i8** %10
%37 = load i32, i32* %9
%38 = load i32, i32* %8
%39 = mul nsw i32 %37, %38
%40 = call i8* @malloc(i32 %39)
store i8* %40, i8** %11
%41 = load i32, i32* %9
%42 = load i32, i32* %8
%43 = mul nsw i32 %41, %42
%44 = add nsw i32 %43, 16
%45 = call i8* @malloc(i32 %44)
store i8* %45, i8** %12
store i32 0, i32* %6
br label %46
46: ; preds = %56, %24
%47 = load i32, i32* %6
%48 = load i32, i32* %8
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %59
50: ; preds = %46
%51 = call signext i8 (...) @rand()
%52 = load i8*, i8** %10
%53 = load i32, i32* %6
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
store i8 %51, i8* %55
br label %56
56: ; preds = %50
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
br label %46
59: ; preds = %46
%60 = load i32, i32* %9
%61 = load i32, i32* %9
%62 = load i32, i32* %8
%63 = mul nsw i32 %61, %62
%64 = load i8*, i8** %10
%65 = load i8*, i8** %12
%66 = load i32, i32* %9
%67 = load i32, i32* %8
%68 = mul nsw i32 %66, %67
%69 = add nsw i32 %68, 16
%70 = call i32 @blosc_compress(i32 5, i32 1, i32 %60, i32 %63, i8* %64, i8* %65, i32 %69)
%71 = load i8*, i8** %12
%72 = load i8*, i8** %11
%73 = load i32, i32* %9
%74 = load i32, i32* %8
%75 = mul nsw i32 %73, %74
%76 = call i32 @blosc_decompress(i8* %71, i8* %72, i32 %75)
store i32 1, i32* %7
store i32 0, i32* %6
br label %77
77: ; preds = %101, %59
%78 = load i32, i32* %7
%79 = icmp ne i32 %78, 0
br i1 %79, label %80, label %84
80: ; preds = %77
%81 = load i32, i32* %6
%82 = load i32, i32* %8
%83 = icmp slt i32 %81, %82
br label %84
84: ; preds = %80, %77
%85 = phi i1 [ false, %77 ], [ %83, %80 ]
br i1 %85, label %86, label %104
86: ; preds = %84
%87 = load i8*, i8** %10
%88 = load i32, i32* %6
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8, i8* %87, i64 %89
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = load i8*, i8** %11
%94 = load i32, i32* %6
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8, i8* %93, i64 %95
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp eq i32 %92, %98
%100 = zext i1 %99 to i32
store i32 %100, i32* %7
br label %101
101: ; preds = %86
%102 = load i32, i32* %6
%103 = add nsw i32 %102, 1
store i32 %103, i32* %6
br label %77
104: ; preds = %84
%105 = load i8*, i8** %10
%106 = call i32 @free(i8* %105)
%107 = load i8*, i8** %11
%108 = call i32 @free(i8* %107)
%109 = load i8*, i8** %12
%110 = call i32 @free(i8* %109)
br label %111
111: ; preds = %104
%112 = load i32, i32* %7
%113 = icmp ne i32 %112, 0
br i1 %113, label %115, label %114
114: ; preds = %111
store i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8** %1
br label %125
115: ; preds = %111
br label %116
116: ; preds = %115
br label %117
117: ; preds = %116
%118 = load i32, i32* %5
%119 = add nsw i32 %118, 1
store i32 %119, i32* %5
br label %20
120: ; preds = %20
br label %121
121: ; preds = %120
%122 = load i32, i32* %4
%123 = add nsw i32 %122, 1
store i32 %123, i32* %4
br label %15
124: ; preds = %15
store i8* null, i8** %1
br label %125
125: ; preds = %124, %114
%126 = load i8*, i8** %1
ret i8* %126
}

LLVM IR (-O2):
@__const.test_shuffle.sizes = [7 x i32] [i32 7, i32 192, i32 1792, i32 500, i32 8000, i32 100000, i32 702713]
@__const.test_shuffle.types = [9 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 16]
@.str = [27 x i8] c"ERROR: shuffle test failed\00"
define i8* @test_shuffle() {
br label %1
1: ; preds = %0, %43
%2 = phi i64 [ 0, %0 ], [ %44, %43 ]
%3 = getelementptr inbounds [7 x i32], [7 x i32]* @__const.test_shuffle.sizes, i64 0, i64 %2
%4 = load i32, i32* %3
%5 = call i32 @llvm.smax.i32(i32 %4, i32 1)
%6 = sext i32 %4 to i64
%7 = zext i32 %5 to i64
br label %11
8: ; preds = %39
%9 = add nuw nsw i64 %12, 1
%10 = icmp eq i64 %9, 9
br i1 %10, label %43, label %11
11: ; preds = %8, %1
%12 = phi i64 [ 0, %1 ], [ %9, %8 ]
%13 = getelementptr inbounds [9 x i32], [9 x i32]* @__const.test_shuffle.types, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = mul nsw i32 %14, %4
%16 = tail call i8* @malloc(i32 %15)
%17 = tail call i8* @malloc(i32 %15)
%18 = add nsw i32 %15, 16
%19 = tail call i8* @malloc(i32 %18)
br label %20
20: ; preds = %11, %20
%21 = phi i64 [ 0, %11 ], [ %24, %20 ]
%22 = tail call signext i8 (...) @rand()
%23 = getelementptr inbounds i8, i8* %16, i64 %21
store i8 %22, i8* %23
%24 = add nuw nsw i64 %21, 1
%25 = icmp eq i64 %24, %7
br i1 %25, label %26, label %20
26: ; preds = %20
%27 = tail call i32 @blosc_compress(i32 5, i32 1, i32 %14, i32 %15, i8* %16, i8* %19, i32 %18)
%28 = tail call i32 @blosc_decompress(i8* %19, i8* %17, i32 %15)
br label %29
29: ; preds = %26, %29
%30 = phi i64 [ 0, %26 ], [ %36, %29 ]
%31 = getelementptr inbounds i8, i8* %16, i64 %30
%32 = load i8, i8* %31
%33 = getelementptr inbounds i8, i8* %17, i64 %30
%34 = load i8, i8* %33
%35 = icmp eq i8 %32, %34
%36 = add nuw nsw i64 %30, 1
%37 = icmp slt i64 %36, %6
%38 = select i1 %35, i1 %37, i1 false
br i1 %38, label %29, label %39
39: ; preds = %29
%40 = tail call i32 @free(i8* %16)
%41 = tail call i32 @free(i8* %17)
%42 = tail call i32 @free(i8* %19)
br i1 %35, label %8, label %46
43: ; preds = %8
%44 = add nuw nsw i64 %2, 1
%45 = icmp eq i64 %44, 7
br i1 %45, label %46, label %1
46: ; preds = %43, %39
%47 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), %39 ], [ null, %43 ]
ret i8* %47
}