#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 arrcopy(double *, double *, int);
double direct_prod(double *, double *, double *, double *, int);
int select_vec(double *, int, double *, int);
int write_vec(double *, int, double *, int);
int floquetsort(double evals_real[], double evals_imag[], double evecs_real[],
                double evecs_imag[], double prev_real[], double prev_imag[],
                double vecs_prev_real[], double vecs_prev_imag[], int size) {
  int i, j, err;
  double dot;
  double vec_prev_real[((2 * 1 + 1) * ((2 * 1 + 1) + 1)) / 2],
      vec_prev_imag[((2 * 1 + 1) * ((2 * 1 + 1) + 1)) / 2];
  double vec_test_real[((2 * 1 + 1) * ((2 * 1 + 1) + 1)) / 2],
      vec_test_imag[((2 * 1 + 1) * ((2 * 1 + 1) + 1)) / 2];
  double evals_temp_real[((2 * 1 + 1) * ((2 * 1 + 1) + 1)) / 2],
      evals_temp_imag[((2 * 1 + 1) * ((2 * 1 + 1) + 1)) / 2];
  double evecs_temp_real[((2 * 1 + 1) * ((2 * 1 + 1) + 1)) / 2 *
                         ((2 * 1 + 1) * ((2 * 1 + 1) + 1)) / 2],
      evecs_temp_imag[((2 * 1 + 1) * ((2 * 1 + 1) + 1)) / 2 *
                      ((2 * 1 + 1) * ((2 * 1 + 1) + 1)) / 2];
  for (i = 0; i < size; i++) {
    err = select_vec(vecs_prev_real, i, vec_prev_real, size);
    err = select_vec(vecs_prev_imag, i, vec_prev_imag, size);
    for (j = 0; j < size; j++) {
      err = select_vec(evecs_real, j, vec_test_real, size);
      err = select_vec(evecs_imag, j, vec_test_imag, size);
      dot = direct_prod(vec_prev_real, vec_prev_imag, vec_test_real,
                        vec_test_imag, size);
      if (dot >= 0.5) {
        err = write_vec(vec_test_real, i, evecs_temp_real, size);
        err = write_vec(vec_test_imag, i, evecs_temp_imag, size);
        evals_temp_real[i] = evals_real[j];
        evals_temp_imag[i] = evals_imag[j];
        break;
      }
    }
  }
  err = arrcopy(evals_temp_real, evals_real, size);
  err = arrcopy(evals_temp_imag, evals_imag, size);
  err = arrcopy(evecs_temp_real, evecs_real, size * size);
  err = arrcopy(evecs_temp_imag, evecs_imag, size * size);
  return (err);
}


x86 assembly (clang, -O0):
<floquetsort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3b0,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    0x20(%rbp),%eax
jge    12ca <floquetsort+0x18a>
mov    0x10(%rbp),%rdi
mov    -0x34(%rbp),%esi
lea    -0x80(%rbp),%rdx
mov    0x20(%rbp),%ecx
call   1030 <select_vec@plt>
mov    %eax,-0x3c(%rbp)
mov    0x18(%rbp),%rdi
mov    -0x34(%rbp),%esi
lea    -0xb0(%rbp),%rdx
mov    0x20(%rbp),%ecx
call   1030 <select_vec@plt>
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    0x20(%rbp),%eax
jge    12b7 <floquetsort+0x177>
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%esi
lea    -0xe0(%rbp),%rdx
mov    0x20(%rbp),%ecx
call   1030 <select_vec@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%esi
lea    -0x110(%rbp),%rdx
mov    0x20(%rbp),%ecx
call   1030 <select_vec@plt>
mov    %eax,-0x3c(%rbp)
lea    -0x80(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
lea    -0xe0(%rbp),%rdx
lea    -0x110(%rbp),%rcx
mov    0x20(%rbp),%r8d
call   1040 <direct_prod@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  0xdd7(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     12a4 <floquetsort+0x164>
lea    -0xe0(%rbp),%rdi
mov    -0x34(%rbp),%esi
lea    -0x290(%rbp),%rdx
mov    0x20(%rbp),%ecx
call   1060 <write_vec@plt>
mov    %eax,-0x3c(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x34(%rbp),%esi
lea    -0x3b0(%rbp),%rdx
mov    0x20(%rbp),%ecx
call   1060 <write_vec@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x34(%rbp),%rax
movsd  %xmm0,-0x140(%rbp,%rax,8)
ff ff
mov    -0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x34(%rbp),%rax
movsd  %xmm0,-0x170(%rbp,%rax,8)
ff ff
jmp    12b7 <floquetsort+0x177>
jmp    12a9 <floquetsort+0x169>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11b7 <floquetsort+0x77>
jmp    12bc <floquetsort+0x17c>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1175 <floquetsort+0x35>
lea    -0x140(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    0x20(%rbp),%edx
call   1050 <arrcopy@plt>
mov    %eax,-0x3c(%rbp)
lea    -0x170(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x20(%rbp),%edx
call   1050 <arrcopy@plt>
mov    %eax,-0x3c(%rbp)
lea    -0x290(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x20(%rbp),%edx
imul   0x20(%rbp),%edx
call   1050 <arrcopy@plt>
mov    %eax,-0x3c(%rbp)
lea    -0x3b0(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x20(%rbp),%edx
imul   0x20(%rbp),%edx
call   1050 <arrcopy@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x3b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<floquetsort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x388,%rsp
mov    %rcx,0x18(%rsp)
mov    %rdx,%r15
mov    %rsi,0x10(%rsp)
mov    %rdi,0x8(%rsp)
mov    0x3d0(%rsp),%ebx
test   %ebx,%ebx
jle    128a <floquetsort+0x14a>
mov    %ebx,%r14d
xor    %ebp,%ebp
lea    0x110(%rsp),%r12
lea    0xe0(%rsp),%r13
jmp    11f1 <floquetsort+0xb1>
nopl   0x0(%rax)
mov    %r12,%rdi
mov    (%rsp),%rsi
lea    0x260(%rsp),%rdx
mov    %ebx,%ecx
call   1060 <write_vec@plt>
mov    %r13,%rdi
mov    (%rsp),%rsi
lea    0x140(%rsp),%rdx
mov    %ebx,%ecx
call   1060 <write_vec@plt>
mov    0x8(%rsp),%rax
movsd  (%rax,%rbp,8),%xmm0
mov    (%rsp),%rcx
movsd  %xmm0,0x50(%rsp,%rcx,8)
mov    0x10(%rsp),%rax
movsd  (%rax,%rbp,8),%xmm0
movsd  %xmm0,0x20(%rsp,%rcx,8)
mov    (%rsp),%rbp
add    $0x1,%rbp
cmp    %r14,%rbp
je     128a <floquetsort+0x14a>
mov    0x3c0(%rsp),%rdi
mov    %ebp,%esi
lea    0xb0(%rsp),%rdx
mov    %ebx,%ecx
call   1030 <select_vec@plt>
mov    0x3c8(%rsp),%rdi
mov    %rbp,(%rsp)
mov    %ebp,%esi
lea    0x80(%rsp),%rdx
mov    %ebx,%ecx
call   1030 <select_vec@plt>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %ebp,%esi
mov    %r12,%rdx
mov    %ebx,%ecx
call   1030 <select_vec@plt>
mov    0x18(%rsp),%rdi
mov    %ebp,%esi
mov    %r13,%rdx
mov    %ebx,%ecx
call   1030 <select_vec@plt>
lea    0xb0(%rsp),%rdi
lea    0x80(%rsp),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
mov    %ebx,%r8d
call   1040 <direct_prod@plt>
ucomisd 0xd8a(%rip),%xmm0
jae    1190 <floquetsort+0x50>
add    $0x1,%rbp
cmp    %ebp,%r14d
jne    1230 <floquetsort+0xf0>
jmp    11e0 <floquetsort+0xa0>
lea    0x50(%rsp),%rdi
mov    0x8(%rsp),%rsi
mov    %ebx,%edx
call   1050 <arrcopy@plt>
lea    0x20(%rsp),%rdi
mov    0x10(%rsp),%rsi
mov    %ebx,%edx
call   1050 <arrcopy@plt>
imul   %ebx,%ebx
lea    0x260(%rsp),%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1050 <arrcopy@plt>
lea    0x140(%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    %ebx,%edx
call   1050 <arrcopy@plt>
add    $0x388,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @floquetsort(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double* %6, double* %7, i32 %8) {
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double*
%17 = alloca double*
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca double
%23 = alloca [6 x double]
%24 = alloca [6 x double]
%25 = alloca [6 x double]
%26 = alloca [6 x double]
%27 = alloca [6 x double]
%28 = alloca [6 x double]
%29 = alloca [36 x double]
%30 = alloca [36 x double]
store double* %0, double** %10
store double* %1, double** %11
store double* %2, double** %12
store double* %3, double** %13
store double* %4, double** %14
store double* %5, double** %15
store double* %6, double** %16
store double* %7, double** %17
store i32 %8, i32* %18
store i32 0, i32* %19
br label %31
31: ; preds = %101, %9
%32 = load i32, i32* %19
%33 = load i32, i32* %18
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %104
35: ; preds = %31
%36 = load double*, double** %16
%37 = load i32, i32* %19
%38 = getelementptr inbounds [6 x double], [6 x double]* %23, i64 0, i64 0
%39 = load i32, i32* %18
%40 = call i32 @select_vec(double* %36, i32 %37, double* %38, i32 %39)
store i32 %40, i32* %21
%41 = load double*, double** %17
%42 = load i32, i32* %19
%43 = getelementptr inbounds [6 x double], [6 x double]* %24, i64 0, i64 0
%44 = load i32, i32* %18
%45 = call i32 @select_vec(double* %41, i32 %42, double* %43, i32 %44)
store i32 %45, i32* %21
store i32 0, i32* %20
br label %46
46: ; preds = %97, %35
%47 = load i32, i32* %20
%48 = load i32, i32* %18
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %100
50: ; preds = %46
%51 = load double*, double** %12
%52 = load i32, i32* %20
%53 = getelementptr inbounds [6 x double], [6 x double]* %25, i64 0, i64 0
%54 = load i32, i32* %18
%55 = call i32 @select_vec(double* %51, i32 %52, double* %53, i32 %54)
store i32 %55, i32* %21
%56 = load double*, double** %13
%57 = load i32, i32* %20
%58 = getelementptr inbounds [6 x double], [6 x double]* %26, i64 0, i64 0
%59 = load i32, i32* %18
%60 = call i32 @select_vec(double* %56, i32 %57, double* %58, i32 %59)
store i32 %60, i32* %21
%61 = getelementptr inbounds [6 x double], [6 x double]* %23, i64 0, i64 0
%62 = getelementptr inbounds [6 x double], [6 x double]* %24, i64 0, i64 0
%63 = getelementptr inbounds [6 x double], [6 x double]* %25, i64 0, i64 0
%64 = getelementptr inbounds [6 x double], [6 x double]* %26, i64 0, i64 0
%65 = load i32, i32* %18
%66 = call double @direct_prod(double* %61, double* %62, double* %63, double* %64, i32 %65)
store double %66, double* %22
%67 = load double, double* %22
%68 = fcmp oge double %67, 5.000000e-01
br i1 %68, label %69, label %96
69: ; preds = %50
%70 = getelementptr inbounds [6 x double], [6 x double]* %25, i64 0, i64 0
%71 = load i32, i32* %19
%72 = getelementptr inbounds [36 x double], [36 x double]* %29, i64 0, i64 0
%73 = load i32, i32* %18
%74 = call i32 @write_vec(double* %70, i32 %71, double* %72, i32 %73)
store i32 %74, i32* %21
%75 = getelementptr inbounds [6 x double], [6 x double]* %26, i64 0, i64 0
%76 = load i32, i32* %19
%77 = getelementptr inbounds [36 x double], [36 x double]* %30, i64 0, i64 0
%78 = load i32, i32* %18
%79 = call i32 @write_vec(double* %75, i32 %76, double* %77, i32 %78)
store i32 %79, i32* %21
%80 = load double*, double** %10
%81 = load i32, i32* %20
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds double, double* %80, i64 %82
%84 = load double, double* %83
%85 = load i32, i32* %19
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [6 x double], [6 x double]* %27, i64 0, i64 %86
store double %84, double* %87
%88 = load double*, double** %11
%89 = load i32, i32* %20
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %88, i64 %90
%92 = load double, double* %91
%93 = load i32, i32* %19
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds [6 x double], [6 x double]* %28, i64 0, i64 %94
store double %92, double* %95
br label %100
96: ; preds = %50
br label %97
97: ; preds = %96
%98 = load i32, i32* %20
%99 = add nsw i32 %98, 1
store i32 %99, i32* %20
br label %46
100: ; preds = %69, %46
br label %101
101: ; preds = %100
%102 = load i32, i32* %19
%103 = add nsw i32 %102, 1
store i32 %103, i32* %19
br label %31
104: ; preds = %31
%105 = getelementptr inbounds [6 x double], [6 x double]* %27, i64 0, i64 0
%106 = load double*, double** %10
%107 = load i32, i32* %18
%108 = call i32 @arrcopy(double* %105, double* %106, i32 %107)
store i32 %108, i32* %21
%109 = getelementptr inbounds [6 x double], [6 x double]* %28, i64 0, i64 0
%110 = load double*, double** %11
%111 = load i32, i32* %18
%112 = call i32 @arrcopy(double* %109, double* %110, i32 %111)
store i32 %112, i32* %21
%113 = getelementptr inbounds [36 x double], [36 x double]* %29, i64 0, i64 0
%114 = load double*, double** %12
%115 = load i32, i32* %18
%116 = load i32, i32* %18
%117 = mul nsw i32 %115, %116
%118 = call i32 @arrcopy(double* %113, double* %114, i32 %117)
store i32 %118, i32* %21
%119 = getelementptr inbounds [36 x double], [36 x double]* %30, i64 0, i64 0
%120 = load double*, double** %13
%121 = load i32, i32* %18
%122 = load i32, i32* %18
%123 = mul nsw i32 %121, %122
%124 = call i32 @arrcopy(double* %119, double* %120, i32 %123)
store i32 %124, i32* %21
%125 = load i32, i32* %21
ret i32 %125
}

LLVM IR (-O2):
define i32 @floquetsort(double* %0, double* %1, double* %2, double* %3, double* nocapture readnone %4, double* nocapture readnone %5, double* %6, double* %7, i32 %8) {
%10 = alloca [6 x double]
%11 = alloca [6 x double]
%12 = alloca [6 x double]
%13 = alloca [6 x double]
%14 = alloca [6 x double]
%15 = alloca [6 x double]
%16 = alloca [36 x double]
%17 = alloca [36 x double]
%18 = bitcast [6 x double]* %10 to i8*
%19 = bitcast [6 x double]* %11 to i8*
%20 = bitcast [6 x double]* %12 to i8*
%21 = bitcast [6 x double]* %13 to i8*
%22 = bitcast [6 x double]* %14 to i8*
%23 = bitcast [6 x double]* %15 to i8*
%24 = bitcast [36 x double]* %16 to i8*
%25 = bitcast [36 x double]* %17 to i8*
%26 = icmp sgt i32 %8, 0
br i1 %26, label %27, label %62
27: ; preds = %9
%28 = getelementptr inbounds [6 x double], [6 x double]* %10, i64 0, i64 0
%29 = getelementptr inbounds [6 x double], [6 x double]* %11, i64 0, i64 0
%30 = getelementptr inbounds [6 x double], [6 x double]* %12, i64 0, i64 0
%31 = getelementptr inbounds [6 x double], [6 x double]* %13, i64 0, i64 0
%32 = getelementptr inbounds [36 x double], [36 x double]* %16, i64 0, i64 0
%33 = getelementptr inbounds [36 x double], [36 x double]* %17, i64 0, i64 0
%34 = zext i32 %8 to i64
br label %35
35: ; preds = %59, %27
%36 = phi i64 [ 0, %27 ], [ %60, %59 ]
%37 = trunc i64 %36 to i32
%38 = call i32 @select_vec(double* %6, i32 %37, double* %28, i32 %8)
%39 = call i32 @select_vec(double* %7, i32 %37, double* %29, i32 %8)
br label %40
40: ; preds = %35, %56
%41 = phi i32 [ %57, %56 ], [ 0, %35 ]
%42 = call i32 @select_vec(double* %2, i32 %41, double* %30, i32 %8)
%43 = call i32 @select_vec(double* %3, i32 %41, double* %31, i32 %8)
%44 = call double @direct_prod(double* %28, double* %29, double* %30, double* %31, i32 %8)
%45 = fcmp ult double %44, 5.000000e-01
br i1 %45, label %56, label %46
46: ; preds = %40
%47 = call i32 @write_vec(double* %30, i32 %37, double* %32, i32 %8)
%48 = call i32 @write_vec(double* %31, i32 %37, double* %33, i32 %8)
%49 = zext i32 %41 to i64
%50 = getelementptr inbounds double, double* %0, i64 %49
%51 = load double, double* %50
%52 = getelementptr inbounds [6 x double], [6 x double]* %14, i64 0, i64 %36
store double %51, double* %52
%53 = getelementptr inbounds double, double* %1, i64 %49
%54 = load double, double* %53
%55 = getelementptr inbounds [6 x double], [6 x double]* %15, i64 0, i64 %36
store double %54, double* %55
br label %59
56: ; preds = %40
%57 = add nuw nsw i32 %41, 1
%58 = icmp eq i32 %57, %8
br i1 %58, label %59, label %40
59: ; preds = %56, %46
%60 = add nuw nsw i64 %36, 1
%61 = icmp eq i64 %60, %34
br i1 %61, label %62, label %35
62: ; preds = %59, %9
%63 = getelementptr inbounds [6 x double], [6 x double]* %14, i64 0, i64 0
%64 = call i32 @arrcopy(double* %63, double* %0, i32 %8)
%65 = getelementptr inbounds [6 x double], [6 x double]* %15, i64 0, i64 0
%66 = call i32 @arrcopy(double* %65, double* %1, i32 %8)
%67 = getelementptr inbounds [36 x double], [36 x double]* %16, i64 0, i64 0
%68 = mul nsw i32 %8, %8
%69 = call i32 @arrcopy(double* %67, double* %2, i32 %68)
%70 = getelementptr inbounds [36 x double], [36 x double]* %17, i64 0, i64 0
%71 = call i32 @arrcopy(double* %70, double* %3, i32 %68)
ret i32 %71
}