#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__ fabs(double);
void dsyev_sort(double *E, double **Evecs, int N) {
  double temp;
  int i, j, k;
  for (j = 0; j < N; j++)
    for (i = 0; i < N - 1; i++)
      if (fabs(E[i]) > fabs(E[i + 1])) {
        temp = E[i];
        E[i] = E[i + 1];
        E[i + 1] = temp;
        for (k = 0; k < N; k++) {
          temp = Evecs[k][i];
          Evecs[k][i] = Evecs[k][i + 1];
          Evecs[k][i + 1] = temp;
        }
      }
}


x86 assembly (clang, -O0):
<dsyev_sort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1287 <dsyev_sort+0x177>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1274 <dsyev_sort+0x164>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
jle    1261 <dsyev_sort+0x151>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x20(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    125c <dsyev_sort+0x14c>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11da <dsyev_sort+0xca>
jmp    1261 <dsyev_sort+0x151>
jmp    1266 <dsyev_sort+0x156>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113d <dsyev_sort+0x2d>
jmp    1279 <dsyev_sort+0x169>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    112a <dsyev_sort+0x1a>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dsyev_sort>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdi,0x8(%rsp)
test   %edx,%edx
jle    1290 <dsyev_sort+0x180>
mov    %rsi,%rbx
lea    -0x1(%rdx),%eax
mov    %rax,0x28(%rsp)
mov    %edx,%r14d
lea    -0x1(%r14),%rax
mov    %rax,0x20(%rsp)
mov    %r14d,%ebp
and    $0x3,%ebp
and    $0xfffffffc,%r14d
xor    %eax,%eax
mov    %rdx,0x10(%rsp)
mov    0x8(%rsp),%r15
jmp    1175 <dsyev_sort+0x65>
nopw   0x0(%rax,%rax,1)
mov    0x18(%rsp),%rax
add    $0x1,%eax
mov    0x10(%rsp),%rdx
cmp    %edx,%eax
je     1290 <dsyev_sort+0x180>
mov    %rax,0x18(%rsp)
cmp    $0x1,%edx
je     1160 <dsyev_sort+0x50>
xor    %r13d,%r13d
jmp    119c <dsyev_sort+0x8c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x30(%rsp),%r13
cmp    0x28(%rsp),%r13
je     1160 <dsyev_sort+0x50>
movsd  (%r15,%r13,8),%xmm0
call   1030 <fabs@plt>
mov    %rax,%r12
lea    0x1(%r13),%rax
mov    %rax,0x30(%rsp)
movsd  0x8(%r15,%r13,8),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%r12
jle    1190 <dsyev_sort+0x80>
mov    0x8(%rsp),%rax
movups (%rax,%r13,8),%xmm0
shufps $0x4e,%xmm0,%xmm0
movups %xmm0,(%rax,%r13,8)
cmpq   $0x3,0x20(%rsp)
jae    11f0 <dsyev_sort+0xe0>
xor    %eax,%eax
jmp    1254 <dsyev_sort+0x144>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rbx,%rax,8),%rcx
movups (%rcx,%r13,8),%xmm0
shufps $0x4e,%xmm0,%xmm0
movups %xmm0,(%rcx,%r13,8)
mov    0x8(%rbx,%rax,8),%rcx
movups (%rcx,%r13,8),%xmm0
shufps $0x4e,%xmm0,%xmm0
movups %xmm0,(%rcx,%r13,8)
mov    0x10(%rbx,%rax,8),%rcx
movups (%rcx,%r13,8),%xmm0
shufps $0x4e,%xmm0,%xmm0
movups %xmm0,(%rcx,%r13,8)
mov    0x18(%rbx,%rax,8),%rcx
movups (%rcx,%r13,8),%xmm0
shufps $0x4e,%xmm0,%xmm0
movups %xmm0,(%rcx,%r13,8)
add    $0x4,%rax
cmp    %rax,%r14
jne    1200 <dsyev_sort+0xf0>
test   %rbp,%rbp
je     1190 <dsyev_sort+0x80>
lea    (%rbx,%rax,8),%rax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rax,%rcx,8),%rdx
movups (%rdx,%r13,8),%xmm0
shufps $0x4e,%xmm0,%xmm0
movups %xmm0,(%rdx,%r13,8)
add    $0x1,%rcx
cmp    %rcx,%rbp
jne    1270 <dsyev_sort+0x160>
jmp    1190 <dsyev_sort+0x80>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @dsyev_sort(double* nocapture %0, double** nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %89
5: ; preds = %3
%6 = add nsw i32 %2, -1
%7 = icmp eq i32 %2, 1
%8 = zext i32 %6 to i64
%9 = zext i32 %2 to i64
%10 = add nsw i64 %9, -1
%11 = and i64 %9, 3
%12 = icmp ult i64 %10, 3
%13 = and i64 %9, 4294967292
%14 = icmp eq i64 %11, 0
br label %15
15: ; preds = %5, %86
%16 = phi i32 [ 0, %5 ], [ %87, %86 ]
br i1 %7, label %86, label %17
17: ; preds = %15, %84
%18 = phi i64 [ %22, %84 ], [ 0, %15 ]
%19 = getelementptr inbounds double, double* %0, i64 %18
%20 = load double, double* %19
%21 = tail call i64 @fabs(double %20)
%22 = add nuw nsw i64 %18, 1
%23 = getelementptr inbounds double, double* %0, i64 %22
%24 = load double, double* %23
%25 = tail call i64 @fabs(double %24)
%26 = icmp sgt i64 %21, %25
br i1 %26, label %27, label %84
27: ; preds = %17
%28 = bitcast double* %19 to <2 x double>*
%29 = load <2 x double>, <2 x double>* %28
%30 = shufflevector <2 x double> %29, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%31 = bitcast double* %19 to <2 x double>*
store <2 x double> %30, <2 x double>* %31
br i1 %12, label %69, label %32
32: ; preds = %27, %32
%33 = phi i64 [ %66, %32 ], [ 0, %27 ]
%34 = phi i64 [ %67, %32 ], [ 0, %27 ]
%35 = getelementptr inbounds double*, double** %1, i64 %33
%36 = load double*, double** %35
%37 = getelementptr inbounds double, double* %36, i64 %18
%38 = bitcast double* %37 to <2 x double>*
%39 = load <2 x double>, <2 x double>* %38
%40 = shufflevector <2 x double> %39, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%41 = bitcast double* %37 to <2 x double>*
store <2 x double> %40, <2 x double>* %41
%42 = or i64 %33, 1
%43 = getelementptr inbounds double*, double** %1, i64 %42
%44 = load double*, double** %43
%45 = getelementptr inbounds double, double* %44, i64 %18
%46 = bitcast double* %45 to <2 x double>*
%47 = load <2 x double>, <2 x double>* %46
%48 = shufflevector <2 x double> %47, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%49 = bitcast double* %45 to <2 x double>*
store <2 x double> %48, <2 x double>* %49
%50 = or i64 %33, 2
%51 = getelementptr inbounds double*, double** %1, i64 %50
%52 = load double*, double** %51
%53 = getelementptr inbounds double, double* %52, i64 %18
%54 = bitcast double* %53 to <2 x double>*
%55 = load <2 x double>, <2 x double>* %54
%56 = shufflevector <2 x double> %55, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%57 = bitcast double* %53 to <2 x double>*
store <2 x double> %56, <2 x double>* %57
%58 = or i64 %33, 3
%59 = getelementptr inbounds double*, double** %1, i64 %58
%60 = load double*, double** %59
%61 = getelementptr inbounds double, double* %60, i64 %18
%62 = bitcast double* %61 to <2 x double>*
%63 = load <2 x double>, <2 x double>* %62
%64 = shufflevector <2 x double> %63, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%65 = bitcast double* %61 to <2 x double>*
store <2 x double> %64, <2 x double>* %65
%66 = add nuw nsw i64 %33, 4
%67 = add i64 %34, 4
%68 = icmp eq i64 %67, %13
br i1 %68, label %69, label %32
69: ; preds = %32, %27
%70 = phi i64 [ 0, %27 ], [ %66, %32 ]
br i1 %14, label %84, label %71
71: ; preds = %69, %71
%72 = phi i64 [ %81, %71 ], [ %70, %69 ]
%73 = phi i64 [ %82, %71 ], [ 0, %69 ]
%74 = getelementptr inbounds double*, double** %1, i64 %72
%75 = load double*, double** %74
%76 = getelementptr inbounds double, double* %75, i64 %18
%77 = bitcast double* %76 to <2 x double>*
%78 = load <2 x double>, <2 x double>* %77
%79 = shufflevector <2 x double> %78, <2 x double> poison, <2 x i32> <i32 1, i32 0>
%80 = bitcast double* %76 to <2 x double>*
store <2 x double> %79, <2 x double>* %80
%81 = add nuw nsw i64 %72, 1
%82 = add i64 %73, 1
%83 = icmp eq i64 %82, %11
br i1 %83, label %84, label %71
84: ; preds = %69, %71, %17
%85 = icmp eq i64 %22, %8
br i1 %85, label %86, label %17
86: ; preds = %84, %15
%87 = add nuw nsw i32 %16, 1
%88 = icmp eq i32 %87, %2
br i1 %88, label %89, label %15
89: ; preds = %86, %3
ret void
}