int eigsrt(double *d, double **v) {
  const unsigned int n = 3;
  int i, j, k;
  double p;
  for (i = 1; i < n; i++) {
    k = i;
    p = d[i];
    for (j = i + 1; j <= n; j++) {
      if (d[j] >= p) {
        k = j;
        p = d[j];
      }
    }
    if (k != i) {
      d[k] = d[i];
      d[i] = p;
      for (j = 1; j <= n; j++) {
        p = v[j][i];
        v[j][i] = v[j][k];
        v[j][k] = p;
      }
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<eigsrt>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jae    125f <eigsrt+0x15f>
mov    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
ja     1192 <eigsrt+0x92>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
ucomisd -0x28(%rbp),%xmm0
jb     117f <eigsrt+0x7f>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1184 <eigsrt+0x84>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1145 <eigsrt+0x45>
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     124c <eigsrt+0x14c>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
ja     1247 <eigsrt+0x147>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d1 <eigsrt+0xd1>
jmp    124c <eigsrt+0x14c>
jmp    1251 <eigsrt+0x151>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    111a <eigsrt+0x1a>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<eigsrt>:
movsd  0x8(%rdi),%xmm0
movsd  0x10(%rdi),%xmm2
ucomisd %xmm0,%xmm2
movapd %xmm0,%xmm1
jb     1118 <eigsrt+0x18>
movapd %xmm2,%xmm1
movsd  0x18(%rdi),%xmm2
mov    $0x2,%ecx
sbb    $0x0,%rcx
ucomisd %xmm1,%xmm2
mov    $0x3,%eax
cmovae %rax,%rcx
cmp    $0x1,%rcx
je     11a0 <eigsrt+0xa0>
movapd %xmm1,%xmm3
cmpnlesd %xmm2,%xmm3
andpd  %xmm3,%xmm1
andnpd %xmm2,%xmm3
orpd   %xmm1,%xmm3
movsd  %xmm0,(%rdi,%rcx,8)
movlpd %xmm3,0x8(%rdi)
mov    0x8(%rsi),%rdx
movsd  0x8(%rdx),%xmm0
movsd  (%rdx,%rcx,8),%xmm1
movsd  %xmm1,0x8(%rdx)
movsd  %xmm0,(%rdx,%rcx,8)
mov    0x10(%rsi),%rdx
movsd  0x8(%rdx),%xmm0
movsd  (%rdx,%rcx,8),%xmm1
movsd  %xmm1,0x8(%rdx)
movsd  %xmm0,(%rdx,%rcx,8)
mov    0x18(%rsi),%rdx
movsd  0x8(%rdx),%xmm0
movsd  (%rdx,%rcx,8),%xmm1
movsd  %xmm1,0x8(%rdx)
movsd  %xmm0,(%rdx,%rcx,8)
movsd  0x10(%rdi),%xmm0
movsd  0x18(%rdi),%xmm1
ucomisd %xmm0,%xmm1
sbb    $0x0,%rax
ucomisd %xmm0,%xmm1
jb     120a <eigsrt+0x10a>
movsd  %xmm0,(%rdi,%rax,8)
movsd  %xmm1,0x10(%rdi)
mov    0x8(%rsi),%rcx
movsd  0x10(%rcx),%xmm0
movsd  (%rcx,%rax,8),%xmm1
movsd  %xmm1,0x10(%rcx)
movsd  %xmm0,(%rcx,%rax,8)
mov    0x10(%rsi),%rcx
movsd  0x10(%rcx),%xmm0
movsd  (%rcx,%rax,8),%xmm1
movsd  %xmm1,0x10(%rcx)
movsd  %xmm0,(%rcx,%rax,8)
mov    0x18(%rsi),%rcx
movsd  0x10(%rcx),%xmm0
movsd  (%rcx,%rax,8),%xmm1
movsd  %xmm1,0x10(%rcx)
movsd  %xmm0,(%rcx,%rax,8)
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @eigsrt(double* nocapture %0, double** nocapture %1) {
%3 = getelementptr inbounds double, double* %0, i64 1
%4 = load double, double* %3
%5 = getelementptr inbounds double, double* %0, i64 2
%6 = load double, double* %5
%7 = fcmp ult double %6, %4
%8 = select i1 %7, double %4, double %6
%9 = getelementptr inbounds double, double* %0, i64 3
%10 = load double, double* %9
%11 = fcmp ult double %10, %8
%12 = select i1 %7, i64 1, i64 2
%13 = select i1 %11, i64 %12, i64 3
%14 = icmp eq i64 %13, 1
br i1 %14, label %36, label %15
15: ; preds = %2
%16 = select i1 %11, double %8, double %10
%17 = getelementptr inbounds double, double* %0, i64 %13
store double %4, double* %17
store double %16, double* %3
%18 = getelementptr inbounds double*, double** %1, i64 1
%19 = load double*, double** %18
%20 = getelementptr inbounds double, double* %19, i64 1
%21 = load double, double* %20
%22 = getelementptr inbounds double, double* %19, i64 %13
%23 = load double, double* %22
store double %23, double* %20
store double %21, double* %22
%24 = getelementptr inbounds double*, double** %1, i64 2
%25 = load double*, double** %24
%26 = getelementptr inbounds double, double* %25, i64 1
%27 = load double, double* %26
%28 = getelementptr inbounds double, double* %25, i64 %13
%29 = load double, double* %28
store double %29, double* %26
store double %27, double* %28
%30 = getelementptr inbounds double*, double** %1, i64 3
%31 = load double*, double** %30
%32 = getelementptr inbounds double, double* %31, i64 1
%33 = load double, double* %32
%34 = getelementptr inbounds double, double* %31, i64 %13
%35 = load double, double* %34
store double %35, double* %32
store double %33, double* %34
br label %36
36: ; preds = %15, %2
%37 = getelementptr inbounds double, double* %0, i64 2
%38 = load double, double* %37
%39 = getelementptr inbounds double, double* %0, i64 3
%40 = load double, double* %39
%41 = fcmp ult double %40, %38
%42 = select i1 %41, i64 2, i64 3
br i1 %41, label %63, label %43
43: ; preds = %36
%44 = getelementptr inbounds double, double* %0, i64 %42
store double %38, double* %44
store double %40, double* %37
%45 = getelementptr inbounds double*, double** %1, i64 1
%46 = load double*, double** %45
%47 = getelementptr inbounds double, double* %46, i64 2
%48 = load double, double* %47
%49 = getelementptr inbounds double, double* %46, i64 %42
%50 = load double, double* %49
store double %50, double* %47
store double %48, double* %49
%51 = getelementptr inbounds double*, double** %1, i64 2
%52 = load double*, double** %51
%53 = getelementptr inbounds double, double* %52, i64 2
%54 = load double, double* %53
%55 = getelementptr inbounds double, double* %52, i64 %42
%56 = load double, double* %55
store double %56, double* %53
store double %54, double* %55
%57 = getelementptr inbounds double*, double** %1, i64 3
%58 = load double*, double** %57
%59 = getelementptr inbounds double, double* %58, i64 2
%60 = load double, double* %59
%61 = getelementptr inbounds double, double* %58, i64 %42
%62 = load double, double* %61
store double %62, double* %59
store double %60, double* %61
br label %63
63: ; preds = %43, %36
ret i32 0
}