#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__ calloc(int, int);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ memcpy(double *, double *, int);
int /*<<< orphan*/ mtx_mult(double *, double *, double *, int, int, int);
int sqrt(int);
double vect_dot_product(double *, double *, int);
double vect_norm(double *, int);
int /*<<< orphan*/ vect_scalar_multiply(double *, int, int);
int /*<<< orphan*/ vect_sub(double *, double *, int);
void mtx_lanczos_procedure(double *A, double *a, double *b, int n, int m) {
  int i, j, array_index_i;
  double *v_i = (double *)calloc(n, sizeof(double));
  double *a_times_v_i = (double *)calloc(n, sizeof(double));
  double *b_times_v_i_minus_one = (double *)calloc(n, sizeof(double));
  double *v_i_minus_one = (double *)calloc(n, sizeof(double));
  double *w_i = (double *)calloc(n, sizeof(double));
  double *v1 = (double *)calloc(n, sizeof(double));
  double *temp;
  for (i = 0; i < n; i++) {
    v1[i] = 1 / sqrt(n);
  }
  i = 1;
  array_index_i = i - 1;
  mtx_mult(A, v1, w_i, n, n, 1);
  a[array_index_i] = vect_dot_product(w_i, v1, n);
  memcpy(a_times_v_i, v1, n * sizeof(double));
  vect_scalar_multiply(a_times_v_i, a[array_index_i], n);
  vect_sub(w_i, a_times_v_i, n);
  b[array_index_i + 1] = vect_norm(w_i, n);
  memcpy(v_i, v1, n * sizeof(double));
  temp = v_i_minus_one;
  v_i_minus_one = v_i;
  v_i = w_i;
  vect_scalar_multiply(v_i, 1 / b[array_index_i + 1], n);
  w_i = temp;
  for (i = 2; i <= m - 1; i++) {
    array_index_i = i - 1;
    mtx_mult(A, v_i, w_i, n, n, 1);
    a[array_index_i] = vect_dot_product(w_i, v_i, n);
    memcpy(a_times_v_i, v_i, n * sizeof(double));
    vect_scalar_multiply(a_times_v_i, a[array_index_i], n);
    memcpy(b_times_v_i_minus_one, v_i_minus_one, n * sizeof(double));
    vect_scalar_multiply(b_times_v_i_minus_one, b[array_index_i], n);
    vect_sub(w_i, a_times_v_i, n);
    vect_sub(w_i, b_times_v_i_minus_one, n);
    b[array_index_i + 1] = vect_norm(w_i, n);
    temp = v_i_minus_one;
    v_i_minus_one = v_i;
    v_i = w_i;
    vect_scalar_multiply(v_i, 1 / b[array_index_i + 1], n);
    w_i = temp;
  }
  array_index_i = m - 1;
  mtx_mult(A, v_i, w_i, n, n, 1);
  a[array_index_i] = vect_dot_product(w_i, v_i, n);
  for (i = 0; i < (n - 1); i++) {
    b[i] = b[i + 1];
  }
  b[n - 1] = 0;
  free(v1);
  free(v_i);
  free(a_times_v_i);
  free(b_times_v_i_minus_one);
  free(v_i_minus_one);
  free(w_i);
}


x86 assembly (clang, -O0):
<mtx_lanczos_procedure>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x58(%rbp)
mov    -0x1c(%rbp),%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,-0x60(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1255 <mtx_lanczos_procedure+0xc5>
mov    -0x1c(%rbp),%edi
call   10a0 <sqrt@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
mov    -0x60(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1218 <mtx_lanczos_procedure+0x88>
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    $0x1,%r9d
call   1040 <mtx_mult@plt>
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <vect_dot_product@plt>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%rdi
mov    -0x60(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1070 <memcpy@plt>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cvttsd2si (%rax,%rcx,8),%esi
mov    -0x1c(%rbp),%edx
call   10b0 <vect_scalar_multiply@plt>
mov    -0x58(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1090 <vect_sub@plt>
mov    -0x58(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1080 <vect_norm@plt>
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%rdi
mov    -0x60(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1070 <memcpy@plt>
mov    -0x50(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xcba(%rip),%xmm0
divsd  (%rax,%rcx,8),%xmm0
cvttsd2si %xmm0,%esi
mov    -0x1c(%rbp),%edx
call   10b0 <vect_scalar_multiply@plt>
mov    -0x68(%rbp),%rax
mov    %rax,-0x58(%rbp)
movl   $0x2,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     14b1 <mtx_lanczos_procedure+0x321>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    $0x1,%r9d
call   1040 <mtx_mult@plt>
mov    -0x58(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <vect_dot_product@plt>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1070 <memcpy@plt>
mov    -0x40(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cvttsd2si (%rax,%rcx,8),%esi
mov    -0x1c(%rbp),%edx
call   10b0 <vect_scalar_multiply@plt>
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edx
call   1070 <memcpy@plt>
mov    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cvttsd2si (%rax,%rcx,8),%esi
mov    -0x1c(%rbp),%edx
call   10b0 <vect_scalar_multiply@plt>
mov    -0x58(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1090 <vect_sub@plt>
mov    -0x58(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1090 <vect_sub@plt>
mov    -0x58(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1080 <vect_norm@plt>
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x50(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xb76(%rip),%xmm0
divsd  (%rax,%rcx,8),%xmm0
cvttsd2si %xmm0,%esi
mov    -0x1c(%rbp),%edx
call   10b0 <vect_scalar_multiply@plt>
mov    -0x68(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1366 <mtx_lanczos_procedure+0x1d6>
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    $0x1,%r9d
call   1040 <mtx_mult@plt>
mov    -0x58(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <vect_dot_product@plt>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    153a <mtx_lanczos_procedure+0x3aa>
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    14fc <mtx_lanczos_procedure+0x36c>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mtx_lanczos_procedure>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r8d,0xc(%rsp)
mov    %ecx,%r12d
mov    %rdx,%r15
mov    %rsi,0x28(%rsp)
mov    %rdi,%r13
mov    %ecx,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,0x38(%rsp)
mov    %r12d,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,0x30(%rsp)
mov    %r12d,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,0x58(%rsp)
mov    %r12d,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,0x20(%rsp)
mov    %r12d,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,%rbp
mov    %r12d,%edi
mov    $0x8,%esi
call   1060 <calloc@plt>
mov    %rax,%rsi
test   %r12d,%r12d
mov    %rax,0x50(%rsp)
mov    %r15,0x18(%rsp)
jle    127d <mtx_lanczos_procedure+0xdd>
mov    %rbp,0x10(%rsp)
mov    %r12d,%r15d
cmp    $0x1,%r12d
jne    1535 <mtx_lanczos_procedure+0x395>
mov    %r15,%r14
xor    %ebx,%ebx
test   $0x1,%r14b
mov    0x10(%rsp),%rbp
je     127d <mtx_lanczos_procedure+0xdd>
mov    %r12d,%edi
call   10b0 <sqrt@plt>
mov    0x50(%rsp),%rsi
lea    0x1(%rax),%ecx
xor    %edx,%edx
cmp    $0x3,%ecx
cmovb  %eax,%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
movsd  %xmm0,(%rsi,%rbx,8)
mov    %r13,0x10(%rsp)
mov    %r13,%rdi
mov    %rsi,%r14
mov    %rbp,%rdx
mov    %r12d,%ecx
mov    %r12d,%r8d
mov    $0x1,%r9d
call   1040 <mtx_mult@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1050 <vect_dot_product@plt>
mov    0x28(%rsp),%r13
movsd  %xmm0,0x0(%r13)
lea    0x0(,%r12,8),%r15d
mov    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1070 <memcpy@plt>
cvttsd2si 0x0(%r13),%esi
mov    %rbx,%rdi
mov    %r12d,%edx
call   10c0 <vect_scalar_multiply@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   10a0 <vect_sub@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
call   1080 <vect_norm@plt>
mov    0x18(%rsp),%rax
movsd  %xmm0,0x8(%rax)
mov    0x38(%rsp),%r13
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r15d,%r14d
mov    0x18(%rsp),%r15
mov    %r14d,%edx
call   1070 <memcpy@plt>
movsd  0xcd9(%rip),%xmm0
divsd  0x8(%r15),%xmm0
cvttsd2si %xmm0,%esi
mov    %rbp,%rdi
mov    %r12d,%edx
call   10c0 <vect_scalar_multiply@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
jl     147d <mtx_lanczos_procedure+0x2dd>
mov    %eax,%eax
add    $0xfffffffffffffffe,%rax
mov    %rax,0x60(%rsp)
xor    %r15d,%r15d
mov    0x20(%rsp),%rax
mov    %r14d,0x4c(%rsp)
mov    %r12,0x40(%rsp)
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,0x38(%rsp)
mov    %r13,0x20(%rsp)
mov    %rax,%r14
mov    0x10(%rsp),%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
mov    %r12d,%ecx
mov    %r12d,%r8d
mov    $0x1,%r9d
call   1040 <mtx_mult@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1050 <vect_dot_product@plt>
mov    0x28(%rsp),%rbx
movsd  %xmm0,0x8(%rbx,%r15,8)
mov    0x30(%rsp),%r12
mov    %r12,%rdi
mov    %rbp,%rsi
mov    0x4c(%rsp),%r13d
mov    %r13d,%edx
call   1070 <memcpy@plt>
cvttsd2si 0x8(%rbx,%r15,8),%esi
mov    %r12,%rdi
mov    0x40(%rsp),%rdx
call   10c0 <vect_scalar_multiply@plt>
mov    0x58(%rsp),%rbp
mov    %rbp,%rdi
mov    0x20(%rsp),%rbx
mov    %rbx,%rsi
mov    %r13d,%edx
call   1070 <memcpy@plt>
mov    0x18(%rsp),%r13
cvttsd2si 0x8(%r13,%r15,8),%esi
mov    %rbp,%rdi
mov    0x40(%rsp),%rdx
call   10c0 <vect_scalar_multiply@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    0x40(%rsp),%r12
mov    %r12d,%edx
call   10a0 <vect_sub@plt>
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %r14,%rbp
mov    %r12d,%edx
call   10a0 <vect_sub@plt>
mov    %r14,%rdi
mov    %r12d,%esi
call   1080 <vect_norm@plt>
movsd  %xmm0,0x10(%r13,%r15,8)
movsd  0xbb2(%rip),%xmm1
divsd  %xmm0,%xmm1
cvttsd2si %xmm1,%esi
mov    %r14,%rdi
mov    %r12d,%edx
call   10c0 <vect_scalar_multiply@plt>
mov    0x38(%rsp),%r14
add    $0x1,%r15
mov    %rbx,%rax
mov    %r14,%r13
cmp    %r15,0x60(%rsp)
jne    1370 <mtx_lanczos_procedure+0x1d0>
jmp    1485 <mtx_lanczos_procedure+0x2e5>
mov    0x20(%rsp),%rbx
mov    %r13,%r14
mov    0x10(%rsp),%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r12d,%ecx
mov    %r12d,%r8d
mov    $0x1,%r9d
call   1040 <mtx_mult@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1050 <vect_dot_product@plt>
movslq 0xc(%rsp),%rax
mov    0x28(%rsp),%rcx
movsd  %xmm0,-0x8(%rcx,%rax,8)
lea    -0x1(%r12),%r15d
cmp    $0x2,%r12d
mov    %rbp,%r12
mov    0x18(%rsp),%rbp
jl     14e5 <mtx_lanczos_procedure+0x345>
lea    0x8(%rbp),%rsi
mov    %r15d,%edx
shl    $0x3,%rdx
mov    %rbp,%rdi
call   1090 <memmove@plt>
movslq %r15d,%rax
movq   $0x0,0x0(%rbp,%rax,8)
mov    0x50(%rsp),%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    0x30(%rsp),%rdi
call   1030 <free@plt>
mov    0x58(%rsp),%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
mov    %r15,%r14
and    $0xfffffffe,%r15d
xor    %ebx,%ebx
jmp    155d <mtx_lanczos_procedure+0x3bd>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rbp,%rbx,8)
add    $0x2,%rbx
cmp    %rbx,%r15
mov    %rbp,%rsi
je     124e <mtx_lanczos_procedure+0xae>
mov    %r12d,%edi
mov    %rsi,%rbp
call   10b0 <sqrt@plt>
lea    0x1(%rax),%ecx
cmp    $0x3,%ecx
mov    $0x0,%ecx
cmovae %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x0(%rbp,%rbx,8)
mov    %r12d,%edi
call   10b0 <sqrt@plt>
lea    0x1(%rax),%ecx
cmp    $0x3,%ecx
jb     1540 <mtx_lanczos_procedure+0x3a0>
xor    %eax,%eax
jmp    1540 <mtx_lanczos_procedure+0x3a0>

LLVM IR (-O0):
define void @mtx_lanczos_procedure(double* %0, double* %1, double* %2, i32 %3, i32 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double*
%15 = alloca double*
%16 = alloca double*
%17 = alloca double*
%18 = alloca double*
%19 = alloca double*
%20 = alloca double*
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%21 = load i32, i32* %9
%22 = call i64 @calloc(i32 %21, i32 8)
%23 = inttoptr i64 %22 to double*
store double* %23, double** %14
%24 = load i32, i32* %9
%25 = call i64 @calloc(i32 %24, i32 8)
%26 = inttoptr i64 %25 to double*
store double* %26, double** %15
%27 = load i32, i32* %9
%28 = call i64 @calloc(i32 %27, i32 8)
%29 = inttoptr i64 %28 to double*
store double* %29, double** %16
%30 = load i32, i32* %9
%31 = call i64 @calloc(i32 %30, i32 8)
%32 = inttoptr i64 %31 to double*
store double* %32, double** %17
%33 = load i32, i32* %9
%34 = call i64 @calloc(i32 %33, i32 8)
%35 = inttoptr i64 %34 to double*
store double* %35, double** %18
%36 = load i32, i32* %9
%37 = call i64 @calloc(i32 %36, i32 8)
%38 = inttoptr i64 %37 to double*
store double* %38, double** %19
store i32 0, i32* %11
br label %39
39: ; preds = %52, %5
%40 = load i32, i32* %11
%41 = load i32, i32* %9
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %55
43: ; preds = %39
%44 = load i32, i32* %9
%45 = call i32 @sqrt(i32 %44)
%46 = sdiv i32 1, %45
%47 = sitofp i32 %46 to double
%48 = load double*, double** %19
%49 = load i32, i32* %11
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
store double %47, double* %51
br label %52
52: ; preds = %43
%53 = load i32, i32* %11
%54 = add nsw i32 %53, 1
store i32 %54, i32* %11
br label %39
55: ; preds = %39
store i32 1, i32* %11
%56 = load i32, i32* %11
%57 = sub nsw i32 %56, 1
store i32 %57, i32* %13
%58 = load double*, double** %6
%59 = load double*, double** %19
%60 = load double*, double** %18
%61 = load i32, i32* %9
%62 = load i32, i32* %9
%63 = call i32 @mtx_mult(double* %58, double* %59, double* %60, i32 %61, i32 %62, i32 1)
%64 = load double*, double** %18
%65 = load double*, double** %19
%66 = load i32, i32* %9
%67 = call double @vect_dot_product(double* %64, double* %65, i32 %66)
%68 = load double*, double** %7
%69 = load i32, i32* %13
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
store double %67, double* %71
%72 = load double*, double** %15
%73 = load double*, double** %19
%74 = load i32, i32* %9
%75 = sext i32 %74 to i64
%76 = mul i64 %75, 8
%77 = trunc i64 %76 to i32
%78 = call i32 @memcpy(double* %72, double* %73, i32 %77)
%79 = load double*, double** %15
%80 = load double*, double** %7
%81 = load i32, i32* %13
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds double, double* %80, i64 %82
%84 = load double, double* %83
%85 = fptosi double %84 to i32
%86 = load i32, i32* %9
%87 = call i32 @vect_scalar_multiply(double* %79, i32 %85, i32 %86)
%88 = load double*, double** %18
%89 = load double*, double** %15
%90 = load i32, i32* %9
%91 = call i32 @vect_sub(double* %88, double* %89, i32 %90)
%92 = load double*, double** %18
%93 = load i32, i32* %9
%94 = call double @vect_norm(double* %92, i32 %93)
%95 = load double*, double** %8
%96 = load i32, i32* %13
%97 = add nsw i32 %96, 1
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds double, double* %95, i64 %98
store double %94, double* %99
%100 = load double*, double** %14
%101 = load double*, double** %19
%102 = load i32, i32* %9
%103 = sext i32 %102 to i64
%104 = mul i64 %103, 8
%105 = trunc i64 %104 to i32
%106 = call i32 @memcpy(double* %100, double* %101, i32 %105)
%107 = load double*, double** %17
store double* %107, double** %20
%108 = load double*, double** %14
store double* %108, double** %17
%109 = load double*, double** %18
store double* %109, double** %14
%110 = load double*, double** %14
%111 = load double*, double** %8
%112 = load i32, i32* %13
%113 = add nsw i32 %112, 1
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds double, double* %111, i64 %114
%116 = load double, double* %115
%117 = fdiv double 1.000000e+00, %116
%118 = fptosi double %117 to i32
%119 = load i32, i32* %9
%120 = call i32 @vect_scalar_multiply(double* %110, i32 %118, i32 %119)
%121 = load double*, double** %20
store double* %121, double** %18
store i32 2, i32* %11
br label %122
122: ; preds = %207, %55
%123 = load i32, i32* %11
%124 = load i32, i32* %10
%125 = sub nsw i32 %124, 1
%126 = icmp sle i32 %123, %125
br i1 %126, label %127, label %210
127: ; preds = %122
%128 = load i32, i32* %11
%129 = sub nsw i32 %128, 1
store i32 %129, i32* %13
%130 = load double*, double** %6
%131 = load double*, double** %14
%132 = load double*, double** %18
%133 = load i32, i32* %9
%134 = load i32, i32* %9
%135 = call i32 @mtx_mult(double* %130, double* %131, double* %132, i32 %133, i32 %134, i32 1)
%136 = load double*, double** %18
%137 = load double*, double** %14
%138 = load i32, i32* %9
%139 = call double @vect_dot_product(double* %136, double* %137, i32 %138)
%140 = load double*, double** %7
%141 = load i32, i32* %13
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds double, double* %140, i64 %142
store double %139, double* %143
%144 = load double*, double** %15
%145 = load double*, double** %14
%146 = load i32, i32* %9
%147 = sext i32 %146 to i64
%148 = mul i64 %147, 8
%149 = trunc i64 %148 to i32
%150 = call i32 @memcpy(double* %144, double* %145, i32 %149)
%151 = load double*, double** %15
%152 = load double*, double** %7
%153 = load i32, i32* %13
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds double, double* %152, i64 %154
%156 = load double, double* %155
%157 = fptosi double %156 to i32
%158 = load i32, i32* %9
%159 = call i32 @vect_scalar_multiply(double* %151, i32 %157, i32 %158)
%160 = load double*, double** %16
%161 = load double*, double** %17
%162 = load i32, i32* %9
%163 = sext i32 %162 to i64
%164 = mul i64 %163, 8
%165 = trunc i64 %164 to i32
%166 = call i32 @memcpy(double* %160, double* %161, i32 %165)
%167 = load double*, double** %16
%168 = load double*, double** %8
%169 = load i32, i32* %13
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds double, double* %168, i64 %170
%172 = load double, double* %171
%173 = fptosi double %172 to i32
%174 = load i32, i32* %9
%175 = call i32 @vect_scalar_multiply(double* %167, i32 %173, i32 %174)
%176 = load double*, double** %18
%177 = load double*, double** %15
%178 = load i32, i32* %9
%179 = call i32 @vect_sub(double* %176, double* %177, i32 %178)
%180 = load double*, double** %18
%181 = load double*, double** %16
%182 = load i32, i32* %9
%183 = call i32 @vect_sub(double* %180, double* %181, i32 %182)
%184 = load double*, double** %18
%185 = load i32, i32* %9
%186 = call double @vect_norm(double* %184, i32 %185)
%187 = load double*, double** %8
%188 = load i32, i32* %13
%189 = add nsw i32 %188, 1
%190 = sext i32 %189 to i64
%191 = getelementptr inbounds double, double* %187, i64 %190
store double %186, double* %191
%192 = load double*, double** %17
store double* %192, double** %20
%193 = load double*, double** %14
store double* %193, double** %17
%194 = load double*, double** %18
store double* %194, double** %14
%195 = load double*, double** %14
%196 = load double*, double** %8
%197 = load i32, i32* %13
%198 = add nsw i32 %197, 1
%199 = sext i32 %198 to i64
%200 = getelementptr inbounds double, double* %196, i64 %199
%201 = load double, double* %200
%202 = fdiv double 1.000000e+00, %201
%203 = fptosi double %202 to i32
%204 = load i32, i32* %9
%205 = call i32 @vect_scalar_multiply(double* %195, i32 %203, i32 %204)
%206 = load double*, double** %20
store double* %206, double** %18
br label %207
207: ; preds = %127
%208 = load i32, i32* %11
%209 = add nsw i32 %208, 1
store i32 %209, i32* %11
br label %122
210: ; preds = %122
%211 = load i32, i32* %10
%212 = sub nsw i32 %211, 1
store i32 %212, i32* %13
%213 = load double*, double** %6
%214 = load double*, double** %14
%215 = load double*, double** %18
%216 = load i32, i32* %9
%217 = load i32, i32* %9
%218 = call i32 @mtx_mult(double* %213, double* %214, double* %215, i32 %216, i32 %217, i32 1)
%219 = load double*, double** %18
%220 = load double*, double** %14
%221 = load i32, i32* %9
%222 = call double @vect_dot_product(double* %219, double* %220, i32 %221)
%223 = load double*, double** %7
%224 = load i32, i32* %13
%225 = sext i32 %224 to i64
%226 = getelementptr inbounds double, double* %223, i64 %225
store double %222, double* %226
store i32 0, i32* %11
br label %227
227: ; preds = %243, %210
%228 = load i32, i32* %11
%229 = load i32, i32* %9
%230 = sub nsw i32 %229, 1
%231 = icmp slt i32 %228, %230
br i1 %231, label %232, label %246
232: ; preds = %227
%233 = load double*, double** %8
%234 = load i32, i32* %11
%235 = add nsw i32 %234, 1
%236 = sext i32 %235 to i64
%237 = getelementptr inbounds double, double* %233, i64 %236
%238 = load double, double* %237
%239 = load double*, double** %8
%240 = load i32, i32* %11
%241 = sext i32 %240 to i64
%242 = getelementptr inbounds double, double* %239, i64 %241
store double %238, double* %242
br label %243
243: ; preds = %232
%244 = load i32, i32* %11
%245 = add nsw i32 %244, 1
store i32 %245, i32* %11
br label %227
246: ; preds = %227
%247 = load double*, double** %8
%248 = load i32, i32* %9
%249 = sub nsw i32 %248, 1
%250 = sext i32 %249 to i64
%251 = getelementptr inbounds double, double* %247, i64 %250
store double 0.000000e+00, double* %251
%252 = load double*, double** %19
%253 = call i32 @free(double* %252)
%254 = load double*, double** %14
%255 = call i32 @free(double* %254)
%256 = load double*, double** %15
%257 = call i32 @free(double* %256)
%258 = load double*, double** %16
%259 = call i32 @free(double* %258)
%260 = load double*, double** %17
%261 = call i32 @free(double* %260)
%262 = load double*, double** %18
%263 = call i32 @free(double* %262)
ret void
}

LLVM IR (-O2):
define void @mtx_lanczos_procedure(double* %0, double* nocapture %1, double* nocapture %2, i32 %3, i32 %4) {
%6 = bitcast double* %2 to i8*
%7 = tail call i64 @calloc(i32 %3, i32 8)
%8 = inttoptr i64 %7 to double*
%9 = tail call i64 @calloc(i32 %3, i32 8)
%10 = inttoptr i64 %9 to double*
%11 = tail call i64 @calloc(i32 %3, i32 8)
%12 = inttoptr i64 %11 to double*
%13 = tail call i64 @calloc(i32 %3, i32 8)
%14 = inttoptr i64 %13 to double*
%15 = tail call i64 @calloc(i32 %3, i32 8)
%16 = inttoptr i64 %15 to double*
%17 = tail call i64 @calloc(i32 %3, i32 8)
%18 = inttoptr i64 %17 to double*
%19 = icmp sgt i32 %3, 0
br i1 %19, label %20, label %55
20: ; preds = %5
%21 = zext i32 %3 to i64
%22 = and i64 %21, 1
%23 = icmp eq i32 %3, 1
br i1 %23, label %45, label %24
24: ; preds = %20
%25 = and i64 %21, 4294967294
br label %26
26: ; preds = %26, %24
%27 = phi i64 [ 0, %24 ], [ %42, %26 ]
%28 = phi i64 [ 0, %24 ], [ %43, %26 ]
%29 = tail call i32 @sqrt(i32 %3)
%30 = add i32 %29, 1
%31 = icmp ult i32 %30, 3
%32 = select i1 %31, i32 %29, i32 0
%33 = sitofp i32 %32 to double
%34 = getelementptr inbounds double, double* %18, i64 %27
store double %33, double* %34
%35 = or i64 %27, 1
%36 = tail call i32 @sqrt(i32 %3)
%37 = add i32 %36, 1
%38 = icmp ult i32 %37, 3
%39 = select i1 %38, i32 %36, i32 0
%40 = sitofp i32 %39 to double
%41 = getelementptr inbounds double, double* %18, i64 %35
store double %40, double* %41
%42 = add nuw nsw i64 %27, 2
%43 = add i64 %28, 2
%44 = icmp eq i64 %43, %25
br i1 %44, label %45, label %26
45: ; preds = %26, %20
%46 = phi i64 [ 0, %20 ], [ %42, %26 ]
%47 = icmp eq i64 %22, 0
br i1 %47, label %55, label %48
48: ; preds = %45
%49 = tail call i32 @sqrt(i32 %3)
%50 = add i32 %49, 1
%51 = icmp ult i32 %50, 3
%52 = select i1 %51, i32 %49, i32 0
%53 = sitofp i32 %52 to double
%54 = getelementptr inbounds double, double* %18, i64 %46
store double %53, double* %54
br label %55
55: ; preds = %48, %45, %5
%56 = tail call i32 @mtx_mult(double* %0, double* %18, double* %16, i32 %3, i32 %3, i32 1)
%57 = tail call double @vect_dot_product(double* %16, double* %18, i32 %3)
store double %57, double* %1
%58 = shl i32 %3, 3
%59 = tail call i32 @memcpy(double* %10, double* %18, i32 %58)
%60 = load double, double* %1
%61 = fptosi double %60 to i32
%62 = tail call i32 @vect_scalar_multiply(double* %10, i32 %61, i32 %3)
%63 = tail call i32 @vect_sub(double* %16, double* %10, i32 %3)
%64 = tail call double @vect_norm(double* %16, i32 %3)
%65 = getelementptr double, double* %2, i64 1
store double %64, double* %65
%66 = tail call i32 @memcpy(double* %8, double* %18, i32 %58)
%67 = load double, double* %65
%68 = fdiv double 1.000000e+00, %67
%69 = fptosi double %68 to i32
%70 = tail call i32 @vect_scalar_multiply(double* %16, i32 %69, i32 %3)
%71 = icmp sgt i32 %4, 2
br i1 %71, label %72, label %101
72: ; preds = %55
%73 = zext i32 %4 to i64
br label %74
74: ; preds = %72, %74
%75 = phi i64 [ 2, %72 ], [ %99, %74 ]
%76 = phi double* [ %14, %72 ], [ %77, %74 ]
%77 = phi double* [ %8, %72 ], [ %78, %74 ]
%78 = phi double* [ %16, %72 ], [ %76, %74 ]
%79 = add nsw i64 %75, -1
%80 = tail call i32 @mtx_mult(double* %0, double* %78, double* %76, i32 %3, i32 %3, i32 1)
%81 = tail call double @vect_dot_product(double* %76, double* %78, i32 %3)
%82 = getelementptr inbounds double, double* %1, i64 %79
store double %81, double* %82
%83 = tail call i32 @memcpy(double* %10, double* %78, i32 %58)
%84 = load double, double* %82
%85 = fptosi double %84 to i32
%86 = tail call i32 @vect_scalar_multiply(double* %10, i32 %85, i32 %3)
%87 = tail call i32 @memcpy(double* %12, double* %77, i32 %58)
%88 = getelementptr inbounds double, double* %2, i64 %79
%89 = load double, double* %88
%90 = fptosi double %89 to i32
%91 = tail call i32 @vect_scalar_multiply(double* %12, i32 %90, i32 %3)
%92 = tail call i32 @vect_sub(double* %76, double* %10, i32 %3)
%93 = tail call i32 @vect_sub(double* %76, double* %12, i32 %3)
%94 = tail call double @vect_norm(double* %76, i32 %3)
%95 = getelementptr inbounds double, double* %2, i64 %75
store double %94, double* %95
%96 = fdiv double 1.000000e+00, %94
%97 = fptosi double %96 to i32
%98 = tail call i32 @vect_scalar_multiply(double* %76, i32 %97, i32 %3)
%99 = add nuw nsw i64 %75, 1
%100 = icmp eq i64 %99, %73
br i1 %100, label %101, label %74
101: ; preds = %74, %55
%102 = phi double* [ %16, %55 ], [ %76, %74 ]
%103 = phi double* [ %8, %55 ], [ %78, %74 ]
%104 = phi double* [ %14, %55 ], [ %77, %74 ]
%105 = add nsw i32 %4, -1
%106 = tail call i32 @mtx_mult(double* %0, double* %102, double* %104, i32 %3, i32 %3, i32 1)
%107 = tail call double @vect_dot_product(double* %104, double* %102, i32 %3)
%108 = sext i32 %105 to i64
%109 = getelementptr inbounds double, double* %1, i64 %108
store double %107, double* %109
%110 = add i32 %3, -1
%111 = icmp sgt i32 %3, 1
br i1 %111, label %112, label %116
112: ; preds = %101
%113 = bitcast double* %65 to i8*
%114 = zext i32 %110 to i64
%115 = shl nuw nsw i64 %114, 3
br label %116
116: ; preds = %112, %101
%117 = sext i32 %110 to i64
%118 = getelementptr inbounds double, double* %2, i64 %117
store double 0.000000e+00, double* %118
%119 = tail call i32 @free(double* %18)
%120 = tail call i32 @free(double* %102)
%121 = tail call i32 @free(double* %10)
%122 = tail call i32 @free(double* %12)
%123 = tail call i32 @free(double* %103)
%124 = tail call i32 @free(double* %104)
ret void
}