#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 log10(double);
int /*<<< orphan*/ printf(char *);
int get_ritzvals(double *alpha, double *beta, int j, double Anorm,
                 double *workj, double *ritz, int d, int left_goodlim,
                 int right_goodlim, double eigtol, double bis_safety) {
  extern int DEBUG_EVECS;
  extern int WARNING_EVECS;
  int nvals_left;
  int nvals_right;
  double bisection_tol;
  int pred_steps;
  int tot_pred_steps;
  double *ritz_sav = NULL;
  int bisect_flag;
  int ql_flag;
  int local_debug;
  int bisect();
  int ql();
  void shell_sort();
  double *mkvec();
  void frvec();
  void cpvec();
  void bail();
  void strout();
  nvals_left = ((d) > (left_goodlim) ? (d) : (left_goodlim));
  nvals_right =
      ((j - nvals_left) < (right_goodlim) ? (j - nvals_left) : (right_goodlim));
  bisection_tol = eigtol * eigtol / bis_safety;
  pred_steps = (log10(Anorm / bisection_tol) / log10(2.0)) + 1;
  tot_pred_steps = (nvals_left + nvals_right) * pred_steps;
  bisect_flag = ql_flag = 0;
  if (5 * tot_pred_steps < 30 * j) {
    if (DEBUG_EVECS > 2) {
      printf("  tridiagonal solver: bisection\n");
    }
    local_debug = 0;
    if (local_debug) {
      ritz_sav = mkvec(1, j);
      cpvec(ritz_sav, 1, j, alpha);
      cpvec(workj, 0, j, beta);
      ql_flag = ql(ritz_sav, workj, j);
      if (ql_flag != 0) {
        bail("Aborting debugging procedure in get_ritzvals().\n", 1);
      }
      shell_sort(j, &ritz_sav[1]);
    }
    bisect_flag = bisect(alpha, beta, j, Anorm, workj, ritz, nvals_left,
                         nvals_right, bisection_tol, ritz_sav, pred_steps + 10);
    if (local_debug) {
      frvec(ritz_sav, 1);
    }
  } else {
    if (DEBUG_EVECS > 2) {
      printf("  tridiagonal solver: ql\n");
    }
    cpvec(ritz, 1, j, alpha);
    cpvec(workj, 0, j, beta);
    ql_flag = ql(ritz, workj, j);
    shell_sort(j, &ritz[1]);
  }
  if (bisect_flag != 0 && ql_flag == 0) {
    if (DEBUG_EVECS > 0 || WARNING_EVECS > 0) {
      strout("WARNING: Sturm bisection of T failed; switching to QL.\n");
    }
    if (DEBUG_EVECS > 1 || WARNING_EVECS > 1) {
      if (bisect_flag == 1) {
        strout("         - failure detected in sturmcnt().\n");
      }
      if (bisect_flag == 2) {
        strout("         - maximum number of bisection steps reached.\n");
      }
    }
    cpvec(ritz, 1, j, alpha);
    cpvec(workj, 0, j, beta);
    ql_flag = ql(ritz, workj, j);
    shell_sort(j, &ritz[1]);
  }
  if (ql_flag != 0 && bisect_flag == 0) {
    if (DEBUG_EVECS > 0 || WARNING_EVECS > 0) {
      strout("WARNING: QL failed for T; switching to Sturm bisection.\n");
    }
    bisect_flag = bisect(alpha, beta, j, Anorm, workj, ritz, nvals_left,
                         nvals_right, bisection_tol, ritz_sav, pred_steps + 3);
  }
  if (bisect_flag != 0 && ql_flag != 0) {
    if (DEBUG_EVECS > 0 || WARNING_EVECS > 0) {
      return (1);
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<get_ritzvals>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
mov    %r9d,-0x3c(%rbp)
movsd  %xmm1,-0x48(%rbp)
movsd  %xmm2,-0x50(%rbp)
movq   $0x0,-0x70(%rbp)
mov    -0x3c(%rbp),%eax
cmp    0x10(%rbp),%eax
jle    11f6 <get_ritzvals+0x56>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x80(%rbp)
jmp    11fc <get_ritzvals+0x5c>
mov    0x10(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    -0x80(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0x54(%rbp),%eax
cmp    0x18(%rbp),%eax
jge    1222 <get_ritzvals+0x82>
mov    -0x1c(%rbp),%eax
sub    -0x54(%rbp),%eax
mov    %eax,-0x84(%rbp)
jmp    122b <get_ritzvals+0x8b>
mov    0x18(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x28(%rbp),%xmm0
divsd  -0x60(%rbp),%xmm0
call   1090 <log10@plt>
mov    %eax,-0x88(%rbp)
movsd  0xd9b(%rip),%xmm0
call   1090 <log10@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%eax
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
mov    -0x54(%rbp),%eax
add    -0x58(%rbp),%eax
imul   -0x64(%rbp),%eax
mov    %eax,-0x68(%rbp)
movl   $0x0,-0x78(%rbp)
movl   $0x0,-0x74(%rbp)
imul   $0x5,-0x68(%rbp),%eax
imul   $0x1e,-0x1c(%rbp),%ecx
cmp    %ecx,%eax
jge    13ba <get_ritzvals+0x21a>
mov    0x2d3b(%rip),%rax
cmpl   $0x2,(%rax)
jle    12c2 <get_ritzvals+0x122>
lea    0xd4b(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
je     1355 <get_ritzvals+0x1b5>
mov    -0x1c(%rbp),%esi
mov    $0x1,%edi
mov    $0x0,%al
call   1040 <mkvec@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x0,%al
call   1060 <cpvec@plt>
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rcx
xor    %esi,%esi
mov    $0x0,%al
call   1060 <cpvec@plt>
mov    -0x70(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    $0x0,%al
call   10c0 <ql@plt>
mov    %eax,-0x78(%rbp)
cmpl   $0x0,-0x78(%rbp)
je     1343 <get_ritzvals+0x1a3>
lea    0xcf2(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1070 <bail@plt>
mov    -0x1c(%rbp),%edi
mov    -0x70(%rbp),%rsi
add    $0x8,%rsi
mov    $0x0,%al
call   1080 <shell_sort@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
movsd  -0x28(%rbp),%xmm0
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x54(%rbp),%r9d
mov    -0x58(%rbp),%r11d
movsd  -0x60(%rbp),%xmm1
mov    -0x70(%rbp),%r10
mov    -0x64(%rbp),%eax
add    $0xa,%eax
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x2,%al
call   10b0 <bisect@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x7c(%rbp)
je     13b5 <get_ritzvals+0x215>
mov    -0x70(%rbp),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <frvec@plt>
jmp    1428 <get_ritzvals+0x288>
mov    0x2c27(%rip),%rax
cmpl   $0x2,(%rax)
jle    13d6 <get_ritzvals+0x236>
lea    0xc89(%rip),%rdi
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x0,%al
call   1060 <cpvec@plt>
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rcx
xor    %esi,%esi
mov    $0x0,%al
call   1060 <cpvec@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    $0x0,%al
call   10c0 <ql@plt>
mov    %eax,-0x78(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x38(%rbp),%rsi
add    $0x8,%rsi
mov    $0x0,%al
call   1080 <shell_sort@plt>
cmpl   $0x0,-0x74(%rbp)
je     1511 <get_ritzvals+0x371>
cmpl   $0x0,-0x78(%rbp)
jne    1511 <get_ritzvals+0x371>
mov    0x2ba5(%rip),%rax
cmpl   $0x0,(%rax)
jg     145c <get_ritzvals+0x2bc>
mov    0x2b85(%rip),%rax
cmpl   $0x0,(%rax)
jle    146a <get_ritzvals+0x2ca>
lea    0xc11(%rip),%rdi
mov    $0x0,%al
call   10a0 <strout@plt>
mov    0x2b77(%rip),%rax
cmpl   $0x1,(%rax)
jg     148a <get_ritzvals+0x2ea>
mov    0x2b57(%rip),%rax
cmpl   $0x1,(%rax)
jle    14bf <get_ritzvals+0x31f>
cmpl   $0x1,-0x74(%rbp)
jne    14a2 <get_ritzvals+0x302>
lea    0xc11(%rip),%rdi
mov    $0x0,%al
call   10a0 <strout@plt>
cmpl   $0x2,-0x74(%rbp)
jne    14ba <get_ritzvals+0x31a>
lea    0xc25(%rip),%rdi
mov    $0x0,%al
call   10a0 <strout@plt>
jmp    14bf <get_ritzvals+0x31f>
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x0,%al
call   1060 <cpvec@plt>
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rcx
xor    %esi,%esi
mov    $0x0,%al
call   1060 <cpvec@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    $0x0,%al
call   10c0 <ql@plt>
mov    %eax,-0x78(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x38(%rbp),%rsi
add    $0x8,%rsi
mov    $0x0,%al
call   1080 <shell_sort@plt>
cmpl   $0x0,-0x78(%rbp)
je     1599 <get_ritzvals+0x3f9>
cmpl   $0x0,-0x74(%rbp)
jne    1599 <get_ritzvals+0x3f9>
mov    0x2abc(%rip),%rax
cmpl   $0x0,(%rax)
jg     1545 <get_ritzvals+0x3a5>
mov    0x2a9c(%rip),%rax
cmpl   $0x0,(%rax)
jle    1553 <get_ritzvals+0x3b3>
lea    0xbc3(%rip),%rdi
mov    $0x0,%al
call   10a0 <strout@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
movsd  -0x28(%rbp),%xmm0
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
mov    -0x54(%rbp),%r9d
mov    -0x58(%rbp),%r11d
movsd  -0x60(%rbp),%xmm1
mov    -0x70(%rbp),%r10
mov    -0x64(%rbp),%eax
add    $0x3,%eax
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x2,%al
call   10b0 <bisect@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
je     15de <get_ritzvals+0x43e>
cmpl   $0x0,-0x78(%rbp)
je     15de <get_ritzvals+0x43e>
mov    0x2a34(%rip),%rax
cmpl   $0x0,(%rax)
jg     15cd <get_ritzvals+0x42d>
mov    0x2a14(%rip),%rax
cmpl   $0x0,(%rax)
jle    15d9 <get_ritzvals+0x439>
movl   $0x1,-0x4(%rbp)
jmp    15e5 <get_ritzvals+0x445>
jmp    15de <get_ritzvals+0x43e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_ritzvals>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,%r13d
mov    0x68(%rsp),%eax
mov    0x60(%rsp),%ebp
cmp    %ebp,%r9d
cmovg  %r9d,%ebp
mov    %edx,%r15d
sub    %ebp,%r15d
cmp    %eax,%r15d
cmovge %eax,%r15d
mov    %r8,%r14
mov    %rcx,0x10(%rsp)
mov    %rsi,0x8(%rsp)
mov    %rdi,(%rsp)
mulsd  %xmm1,%xmm1
divsd  %xmm2,%xmm1
movsd  %xmm0,0x18(%rsp)
movsd  %xmm1,0x20(%rsp)
divsd  %xmm1,%xmm0
call   1060 <log10@plt>
mov    %eax,%ebx
movsd  0xe2b(%rip),%xmm0
call   1060 <log10@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
mov    %eax,%r12d
lea    0x1(%r12),%eax
lea    (%r15,%rbp,1),%ecx
imul   %eax,%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %r13d,%edx
shl    $0x5,%edx
sub    %r13d,%edx
sub    %r13d,%edx
mov    0x2de2(%rip),%rbx
mov    (%rbx),%eax
cmp    %edx,%ecx
jge    12bd <get_ritzvals+0x14d>
cmp    $0x3,%eax
jl     1221 <get_ritzvals+0xb1>
lea    0xed9(%rip),%rdi
call   1030 <puts@plt>
add    $0xb,%r12d
sub    $0x8,%rsp
mov    0x8(%rsp),%rdi
mov    0x10(%rsp),%rsi
mov    %r13d,%edx
movsd  0x20(%rsp),%xmm0
mov    0x18(%rsp),%rcx
mov    %r14,%r8
mov    %ebp,%r9d
movsd  0x28(%rsp),%xmm1
mov    $0x2,%al
push   %r12
push   $0x0
push   %r15
call   1080 <bisect@plt>
add    $0x20,%rsp
test   %eax,%eax
je     140b <get_ritzvals+0x29b>
mov    %eax,%ebp
mov    %rbx,%r15
mov    (%rbx),%eax
mov    0x2d64(%rip),%rbx
test   %eax,%eax
jg     127e <get_ritzvals+0x10e>
mov    (%rbx),%ecx
test   %ecx,%ecx
jle    1291 <get_ritzvals+0x121>
lea    0xd83(%rip),%rdi
xor    %eax,%eax
call   1070 <strout@plt>
mov    (%r15),%eax
mov    (%rbx),%ecx
cmp    $0x1,%eax
jg     129f <get_ritzvals+0x12f>
cmp    $0x2,%ecx
jl     139c <get_ritzvals+0x22c>
cmp    $0x1,%ebp
je     138e <get_ritzvals+0x21e>
cmp    $0x2,%ebp
jne    139c <get_ritzvals+0x22c>
lea    0xdb4(%rip),%rdi
jmp    1395 <get_ritzvals+0x225>
cmp    $0x3,%eax
jl     12ce <get_ritzvals+0x15e>
lea    0xe13(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %r13d,%edx
mov    (%rsp),%rcx
xor    %eax,%eax
call   1040 <cpvec@plt>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r13d,%edx
mov    0x8(%rsp),%rcx
xor    %eax,%eax
call   1040 <cpvec@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1090 <ql@plt>
mov    %eax,%ebx
lea    0x8(%r14),%rsi
mov    %r13d,%edi
xor    %eax,%eax
call   1050 <shell_sort@plt>
test   %ebx,%ebx
mov    0x2cc2(%rip),%rbx
je     140b <get_ritzvals+0x29b>
cmpl   $0x0,(%rbx)
jg     133d <get_ritzvals+0x1cd>
mov    0x2ca0(%rip),%rax
cmpl   $0x0,(%rax)
jle    134b <get_ritzvals+0x1db>
lea    0xd5f(%rip),%rdi
xor    %eax,%eax
call   1070 <strout@plt>
add    $0x4,%r12d
sub    $0x8,%rsp
mov    0x8(%rsp),%rdi
mov    0x10(%rsp),%rsi
mov    %r13d,%edx
movsd  0x20(%rsp),%xmm0
mov    0x18(%rsp),%rcx
mov    %r14,%r8
mov    %ebp,%r9d
movsd  0x28(%rsp),%xmm1
mov    $0x2,%al
push   %r12
push   $0x0
push   %r15
call   1080 <bisect@plt>
add    $0x20,%rsp
test   %eax,%eax
jne    13f5 <get_ritzvals+0x285>
jmp    140b <get_ritzvals+0x29b>
lea    0xcab(%rip),%rdi
xor    %eax,%eax
call   1070 <strout@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %r13d,%edx
mov    (%rsp),%rcx
xor    %eax,%eax
call   1040 <cpvec@plt>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    %r13d,%edx
mov    0x8(%rsp),%rcx
xor    %eax,%eax
call   1040 <cpvec@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   1090 <ql@plt>
mov    %eax,%ebx
add    $0x8,%r14
mov    %r13d,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <shell_sort@plt>
test   %ebx,%ebx
mov    %r15,%rbx
je     140b <get_ritzvals+0x29b>
cmpl   $0x0,(%rbx)
mov    $0x1,%eax
jg     140d <get_ritzvals+0x29d>
mov    0x2bd2(%rip),%rcx
cmpl   $0x0,(%rcx)
jg     140d <get_ritzvals+0x29d>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@DEBUG_EVECS = external global i32
@.str = [33 x i8] c" tridiagonal solver: bisection\0A\00"
@.str.1 = [49 x i8] c"Aborting debugging procedure in get_ritzvals().\0A\00"
@.str.2 = [26 x i8] c" tridiagonal solver: ql\0A\00"
@WARNING_EVECS = external global i32
@.str.3 = [56 x i8] c"WARNING: Sturm bisection of T failed; switching to QL.\0A\00"
@.str.4 = [44 x i8] c" - failure detected in sturmcnt().\0A\00"
@.str.5 = [55 x i8] c" - maximum number of bisection steps reached.\0A\00"
@.str.6 = [57 x i8] c"WARNING: QL failed for T; switching to Sturm bisection.\0A\00"
define i32 @get_ritzvals(double* %0, double* %1, i32 %2, double %3, double* %4, double* %5, i32 %6, i32 %7, i32 %8, double %9, double %10) {
%12 = alloca i32
%13 = alloca double*
%14 = alloca double*
%15 = alloca i32
%16 = alloca double
%17 = alloca double*
%18 = alloca double*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca double
%23 = alloca double
%24 = alloca i32
%25 = alloca i32
%26 = alloca double
%27 = alloca i32
%28 = alloca i32
%29 = alloca double*
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
store double* %0, double** %13
store double* %1, double** %14
store i32 %2, i32* %15
store double %3, double* %16
store double* %4, double** %17
store double* %5, double** %18
store i32 %6, i32* %19
store i32 %7, i32* %20
store i32 %8, i32* %21
store double %9, double* %22
store double %10, double* %23
store double* null, double** %29
%33 = load i32, i32* %19
%34 = load i32, i32* %20
%35 = icmp sgt i32 %33, %34
br i1 %35, label %36, label %38
36: ; preds = %11
%37 = load i32, i32* %19
br label %40
38: ; preds = %11
%39 = load i32, i32* %20
br label %40
40: ; preds = %38, %36
%41 = phi i32 [ %37, %36 ], [ %39, %38 ]
store i32 %41, i32* %24
%42 = load i32, i32* %15
%43 = load i32, i32* %24
%44 = sub nsw i32 %42, %43
%45 = load i32, i32* %21
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %51
47: ; preds = %40
%48 = load i32, i32* %15
%49 = load i32, i32* %24
%50 = sub nsw i32 %48, %49
br label %53
51: ; preds = %40
%52 = load i32, i32* %21
br label %53
53: ; preds = %51, %47
%54 = phi i32 [ %50, %47 ], [ %52, %51 ]
store i32 %54, i32* %25
%55 = load double, double* %22
%56 = load double, double* %22
%57 = fmul double %55, %56
%58 = load double, double* %23
%59 = fdiv double %57, %58
store double %59, double* %26
%60 = load double, double* %16
%61 = load double, double* %26
%62 = fdiv double %60, %61
%63 = call i32 @log10(double %62)
%64 = call i32 @log10(double 2.000000e+00)
%65 = sdiv i32 %63, %64
%66 = add nsw i32 %65, 1
store i32 %66, i32* %27
%67 = load i32, i32* %24
%68 = load i32, i32* %25
%69 = add nsw i32 %67, %68
%70 = load i32, i32* %27
%71 = mul nsw i32 %69, %70
store i32 %71, i32* %28
store i32 0, i32* %31
store i32 0, i32* %30
%72 = load i32, i32* %28
%73 = mul nsw i32 5, %72
%74 = load i32, i32* %15
%75 = mul nsw i32 30, %74
%76 = icmp slt i32 %73, %75
br i1 %76, label %77, label %124
77: ; preds = %53
%78 = load i32, i32* @DEBUG_EVECS
%79 = icmp sgt i32 %78, 2
br i1 %79, label %80, label %82
80: ; preds = %77
%81 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %82
82: ; preds = %80, %77
store i32 0, i32* %32
%83 = load i32, i32* %32
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %105
85: ; preds = %82
%86 = load i32, i32* %15
%87 = call double* (i32, i32, ...) bitcast (double* (...)* @mkvec to double* (i32, i32, ...)*)(i32 1, i32 %86)
store double* %87, double** %29
%88 = load double*, double** %29
%89 = load i32, i32* %15
%90 = load double*, double** %13
%91 = load double*, double** %17
%92 = load i32, i32* %15
%93 = load double*, double** %14
%94 = load double*, double** %29
%95 = load double*, double** %17
%96 = load i32, i32* %15
%97 = call i32 (double*, double*, i32, ...) bitcast (i32 (...)* @ql to i32 (double*, double*, i32, ...)*)(double* %94, double* %95, i32 %96)
store i32 %97, i32* %31
%98 = load i32, i32* %31
%99 = icmp ne i32 %98, 0
br i1 %99, label %100, label %101
100: ; preds = %85
br label %101
101: ; preds = %100, %85
%102 = load i32, i32* %15
%103 = load double*, double** %29
%104 = getelementptr inbounds double, double* %103, i64 1
br label %105
105: ; preds = %101, %82
%106 = load double*, double** %13
%107 = load double*, double** %14
%108 = load i32, i32* %15
%109 = load double, double* %16
%110 = load double*, double** %17
%111 = load double*, double** %18
%112 = load i32, i32* %24
%113 = load i32, i32* %25
%114 = load double, double* %26
%115 = load double*, double** %29
%116 = load i32, i32* %27
%117 = add nsw i32 %116, 10
%118 = call i32 (double*, double*, i32, double, double*, double*, i32, i32, double, double*, i32, ...) bitcast (i32 (...)* @bisect to i32 (double*, double*, i32, double, double*, double*, i32, i32, double, double*, i32, ...)*)(double* %106, double* %107, i32 %108, double %109, double* %110, double* %111, i32 %112, i32 %113, double %114, double* %115, i32 %117)
store i32 %118, i32* %30
%119 = load i32, i32* %32
%120 = icmp ne i32 %119, 0
br i1 %120, label %121, label %123
121: ; preds = %105
%122 = load double*, double** %29
br label %123
123: ; preds = %121, %105
br label %143
124: ; preds = %53
%125 = load i32, i32* @DEBUG_EVECS
%126 = icmp sgt i32 %125, 2
br i1 %126, label %127, label %129
127: ; preds = %124
%128 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %129
129: ; preds = %127, %124
%130 = load double*, double** %18
%131 = load i32, i32* %15
%132 = load double*, double** %13
%133 = load double*, double** %17
%134 = load i32, i32* %15
%135 = load double*, double** %14
%136 = load double*, double** %18
%137 = load double*, double** %17
%138 = load i32, i32* %15
%139 = call i32 (double*, double*, i32, ...) bitcast (i32 (...)* @ql to i32 (double*, double*, i32, ...)*)(double* %136, double* %137, i32 %138)
store i32 %139, i32* %31
%140 = load i32, i32* %15
%141 = load double*, double** %18
%142 = getelementptr inbounds double, double* %141, i64 1
br label %143
143: ; preds = %129, %123
%144 = load i32, i32* %30
%145 = icmp ne i32 %144, 0
br i1 %145, label %146, label %185
146: ; preds = %143
%147 = load i32, i32* %31
%148 = icmp eq i32 %147, 0
br i1 %148, label %149, label %185
149: ; preds = %146
%150 = load i32, i32* @DEBUG_EVECS
%151 = icmp sgt i32 %150, 0
br i1 %151, label %155, label %152
152: ; preds = %149
%153 = load i32, i32* @WARNING_EVECS
%154 = icmp sgt i32 %153, 0
br i1 %154, label %155, label %156
155: ; preds = %152, %149
br label %156
156: ; preds = %155, %152
%157 = load i32, i32* @DEBUG_EVECS
%158 = icmp sgt i32 %157, 1
br i1 %158, label %162, label %159
159: ; preds = %156
%160 = load i32, i32* @WARNING_EVECS
%161 = icmp sgt i32 %160, 1
br i1 %161, label %162, label %171
162: ; preds = %159, %156
%163 = load i32, i32* %30
%164 = icmp eq i32 %163, 1
br i1 %164, label %165, label %166
165: ; preds = %162
br label %166
166: ; preds = %165, %162
%167 = load i32, i32* %30
%168 = icmp eq i32 %167, 2
br i1 %168, label %169, label %170
169: ; preds = %166
br label %170
170: ; preds = %169, %166
br label %171
171: ; preds = %170, %159
%172 = load double*, double** %18
%173 = load i32, i32* %15
%174 = load double*, double** %13
%175 = load double*, double** %17
%176 = load i32, i32* %15
%177 = load double*, double** %14
%178 = load double*, double** %18
%179 = load double*, double** %17
%180 = load i32, i32* %15
%181 = call i32 (double*, double*, i32, ...) bitcast (i32 (...)* @ql to i32 (double*, double*, i32, ...)*)(double* %178, double* %179, i32 %180)
store i32 %181, i32* %31
%182 = load i32, i32* %15
%183 = load double*, double** %18
%184 = getelementptr inbounds double, double* %183, i64 1
br label %185
185: ; preds = %171, %146, %143
%186 = load i32, i32* %31
%187 = icmp ne i32 %186, 0
br i1 %187, label %188, label %212
188: ; preds = %185
%189 = load i32, i32* %30
%190 = icmp eq i32 %189, 0
br i1 %190, label %191, label %212
191: ; preds = %188
%192 = load i32, i32* @DEBUG_EVECS
%193 = icmp sgt i32 %192, 0
br i1 %193, label %197, label %194
194: ; preds = %191
%195 = load i32, i32* @WARNING_EVECS
%196 = icmp sgt i32 %195, 0
br i1 %196, label %197, label %198
197: ; preds = %194, %191
br label %198
198: ; preds = %197, %194
%199 = load double*, double** %13
%200 = load double*, double** %14
%201 = load i32, i32* %15
%202 = load double, double* %16
%203 = load double*, double** %17
%204 = load double*, double** %18
%205 = load i32, i32* %24
%206 = load i32, i32* %25
%207 = load double, double* %26
%208 = load double*, double** %29
%209 = load i32, i32* %27
%210 = add nsw i32 %209, 3
%211 = call i32 (double*, double*, i32, double, double*, double*, i32, i32, double, double*, i32, ...) bitcast (i32 (...)* @bisect to i32 (double*, double*, i32, double, double*, double*, i32, i32, double, double*, i32, ...)*)(double* %199, double* %200, i32 %201, double %202, double* %203, double* %204, i32 %205, i32 %206, double %207, double* %208, i32 %210)
store i32 %211, i32* %30
br label %212
212: ; preds = %198, %188, %185
%213 = load i32, i32* %30
%214 = icmp ne i32 %213, 0
br i1 %214, label %215, label %226
215: ; preds = %212
%216 = load i32, i32* %31
%217 = icmp ne i32 %216, 0
br i1 %217, label %218, label %226
218: ; preds = %215
%219 = load i32, i32* @DEBUG_EVECS
%220 = icmp sgt i32 %219, 0
br i1 %220, label %224, label %221
221: ; preds = %218
%222 = load i32, i32* @WARNING_EVECS
%223 = icmp sgt i32 %222, 0
br i1 %223, label %224, label %225
224: ; preds = %221, %218
store i32 1, i32* %12
br label %227
225: ; preds = %221
br label %226
226: ; preds = %225, %215, %212
store i32 0, i32* %12
br label %227
227: ; preds = %226, %224
%228 = load i32, i32* %12
ret i32 %228
}

LLVM IR (-O2):
@DEBUG_EVECS = external global i32
@WARNING_EVECS = external global i32
@.str.3 = [56 x i8] c"WARNING: Sturm bisection of T failed; switching to QL.\0A\00"
@.str.4 = [44 x i8] c" - failure detected in sturmcnt().\0A\00"
@.str.5 = [55 x i8] c" - maximum number of bisection steps reached.\0A\00"
@.str.6 = [57 x i8] c"WARNING: QL failed for T; switching to Sturm bisection.\0A\00"
@str = [25 x i8] c" tridiagonal solver: ql\00"
@str.7 = [32 x i8] c" tridiagonal solver: bisection\00"
define i32 @get_ritzvals(double* %0, double* %1, i32 %2, double %3, double* %4, double* %5, i32 %6, i32 %7, i32 %8, double %9, double %10) {
%12 = icmp sgt i32 %6, %7
%13 = select i1 %12, i32 %6, i32 %7
%14 = sub nsw i32 %2, %13
%15 = icmp slt i32 %14, %8
%16 = select i1 %15, i32 %14, i32 %8
%17 = fmul double %9, %9
%18 = fdiv double %17, %10
%19 = fdiv double %3, %18
%20 = tail call i32 @log10(double %19)
%21 = tail call i32 @log10(double 2.000000e+00)
%22 = sdiv i32 %20, %21
%23 = add nsw i32 %22, 1
%24 = add nsw i32 %16, %13
%25 = mul i32 %24, 5
%26 = mul i32 %25, %23
%27 = mul nsw i32 %2, 30
%28 = icmp slt i32 %26, %27
%29 = load i32, i32* @DEBUG_EVECS
%30 = icmp sgt i32 %29, 2
br i1 %28, label %31, label %34
31: ; preds = %11
br i1 %30, label %32, label %37
32: ; preds = %31
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.7, i64 0, i64 0))
br label %37
34: ; preds = %11
br i1 %30, label %35, label %58
35: ; preds = %34
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %58
37: ; preds = %32, %31
%38 = add nsw i32 %22, 11
%39 = tail call i32 (double*, double*, i32, double, double*, double*, i32, i32, double, double*, i32, ...) bitcast (i32 (...)* @bisect to i32 (double*, double*, i32, double, double*, double*, i32, i32, double, double*, i32, ...)*)(double* %0, double* %1, i32 %2, double %3, double* %4, double* %5, i32 %13, i32 %16, double %18, double* null, i32 %38)
%40 = icmp eq i32 %39, 0
br i1 %40, label %85, label %41
41: ; preds = %37
%42 = load i32, i32* @DEBUG_EVECS
%43 = icmp sgt i32 %42, 0
%44 = load i32, i32* @WARNING_EVECS
%45 = icmp sgt i32 %44, 0
%46 = select i1 %43, i1 true, i1 %45
br i1 %46, label %47, label %50
47: ; preds = %41
tail call void (i8*, ...) bitcast (void (...)* @strout to void (i8*, ...)*)(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
%48 = load i32, i32* @DEBUG_EVECS
%49 = load i32, i32* @WARNING_EVECS
br label %50
50: ; preds = %41, %47
%51 = phi i32 [ %44, %41 ], [ %49, %47 ]
%52 = phi i32 [ %42, %41 ], [ %48, %47 ]
%53 = icmp sgt i32 %52, 1
%54 = icmp sgt i32 %51, 1
%55 = select i1 %53, i1 true, i1 %54
br i1 %55, label %56, label %75
56: ; preds = %50
switch i32 %39, label %75 [
i32 1, label %73
i32 2, label %57
]
57: ; preds = %56
br label %73
58: ; preds = %34, %35
tail call void (double*, i32, i32, double*, ...) bitcast (void (...)* @cpvec to void (double*, i32, i32, double*, ...)*)(double* %5, i32 1, i32 %2, double* %0)
tail call void (double*, i32, i32, double*, ...) bitcast (void (...)* @cpvec to void (double*, i32, i32, double*, ...)*)(double* %4, i32 0, i32 %2, double* %1)
%59 = tail call i32 (double*, double*, i32, ...) bitcast (i32 (...)* @ql to i32 (double*, double*, i32, ...)*)(double* %5, double* %4, i32 %2)
%60 = getelementptr inbounds double, double* %5, i64 1
tail call void (i32, double*, ...) bitcast (void (...)* @shell_sort to void (i32, double*, ...)*)(i32 %2, double* %60)
%61 = icmp eq i32 %59, 0
br i1 %61, label %85, label %62
62: ; preds = %58
%63 = load i32, i32* @DEBUG_EVECS
%64 = icmp sgt i32 %63, 0
%65 = load i32, i32* @WARNING_EVECS
%66 = icmp sgt i32 %65, 0
%67 = select i1 %64, i1 true, i1 %66
br i1 %67, label %68, label %69
68: ; preds = %62
tail call void (i8*, ...) bitcast (void (...)* @strout to void (i8*, ...)*)(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.6, i64 0, i64 0))
br label %69
69: ; preds = %62, %68
%70 = add nsw i32 %22, 4
%71 = tail call i32 (double*, double*, i32, double, double*, double*, i32, i32, double, double*, i32, ...) bitcast (i32 (...)* @bisect to i32 (double*, double*, i32, double, double*, double*, i32, i32, double, double*, i32, ...)*)(double* %0, double* %1, i32 %2, double %3, double* %4, double* %5, i32 %13, i32 %16, double %18, double* null, i32 %70)
%72 = icmp eq i32 %71, 0
br i1 %72, label %85, label %79
73: ; preds = %56, %57
%74 = phi i8* [ getelementptr inbounds ([55 x i8], [55 x i8]* @.str.5, i64 0, i64 0), %57 ], [ getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), %56 ]
tail call void (i8*, ...) bitcast (void (...)* @strout to void (i8*, ...)*)(i8* %74)
br label %75
75: ; preds = %73, %50, %56
tail call void (double*, i32, i32, double*, ...) bitcast (void (...)* @cpvec to void (double*, i32, i32, double*, ...)*)(double* %5, i32 1, i32 %2, double* %0)
tail call void (double*, i32, i32, double*, ...) bitcast (void (...)* @cpvec to void (double*, i32, i32, double*, ...)*)(double* %4, i32 0, i32 %2, double* %1)
%76 = tail call i32 (double*, double*, i32, ...) bitcast (i32 (...)* @ql to i32 (double*, double*, i32, ...)*)(double* %5, double* %4, i32 %2)
%77 = getelementptr inbounds double, double* %5, i64 1
tail call void (i32, double*, ...) bitcast (void (...)* @shell_sort to void (i32, double*, ...)*)(i32 %2, double* %77)
%78 = icmp eq i32 %76, 0
br i1 %78, label %85, label %79
79: ; preds = %69, %75
%80 = load i32, i32* @DEBUG_EVECS
%81 = icmp sgt i32 %80, 0
%82 = load i32, i32* @WARNING_EVECS
%83 = icmp sgt i32 %82, 0
%84 = select i1 %81, i1 true, i1 %83
br i1 %84, label %86, label %85
85: ; preds = %37, %69, %58, %79, %75
br label %86
86: ; preds = %79, %85
%87 = phi i32 [ 0, %85 ], [ 1, %79 ]
ret i32 %87
}