#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 /*<<< orphan*/ eig(double *, int, double *, double *);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ getQR_house(double *, int, int, double *, double *,
                               double *);
double house(double *, int, double *);
int /*<<< orphan*/ housemat(double *, int, double, double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ mdisplay(double *, int, int);
int /*<<< orphan*/ mmult(double *, double *, double *, int, int, int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ qr_house(double *, int, int, double *);
int main(int argc, char **argv) {
  int i, j, N, row, col, n, k, q;
  double *P, *bvec, *R, *Q;
  N = 4;
  double b;
  b = 1.;
  row = 3;
  col = 3;
  P = (double *)malloc(sizeof(double) * N * N);
  bvec = (double *)malloc(sizeof(double) * col);
  R = (double *)malloc(sizeof(double) * col * col);
  Q = (double *)malloc(sizeof(double) * row * col);
  double x[4] = {3, 1, 5, 1};
  double v[4] = {0, 0, 0, 0};
  double AA[9] = {12, -51, 4, 6, 167, -68, -4, 24, -41};
  printf("b %lf \n", b);
  b = house(x, N, v);
  printf("beta %lf \n", b);
  for (i = 0; i < N; ++i) {
    printf("v %lf \n", v[i]);
  }
  housemat(v, N, b, P);
  mdisplay(P, N, N);
  mmult(P, x, v, N, N, 1);
  mdisplay(v, N, 1);
  qr_house(AA, row, col, bvec);
  mdisplay(AA, row, col);
  getQR_house(AA, row, col, bvec, Q, R);
  mdisplay(R, col, col);
  mdisplay(Q, row, col);
  mmult(Q, R, AA, row, col, col);
  mdisplay(AA, row, col);
  double A[9] = {1, 5, 7, 3, 0, 6, 4, 3, 1};
  double H[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  double eigre[3] = {0, 0, 0, 0};
  double eigim[3] = {0, 0, 0, 0};
  eig(A, 3, eigre, eigim);
  for (i = 0; i < 3; ++i) {
    printf("e%d %g %g \n", i, eigre[i], eigim[i]);
  }
  free(P);
  free(bvec);
  free(R);
  free(Q);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x4,-0x1c(%rbp)
movsd  0xe18(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x3,-0x20(%rbp)
movl   $0x3,-0x24(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
movslq -0x1c(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x38(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x40(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
movslq -0x24(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x48(%rbp)
movslq -0x20(%rbp),%rax
shl    $0x3,%rax
movslq -0x24(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    0xdaa(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xda7(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xda4(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xda1(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1090 <memset@plt>
lea    -0xf0(%rbp),%rdi
lea    0xd84(%rip),%rsi
mov    $0x48,%edx
call   10a0 <memcpy@plt>
cvttsd2si -0x58(%rbp),%esi
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0xa0(%rbp),%rdx
call   10e0 <house@plt>
movsd  %xmm0,-0x58(%rbp)
cvttsd2si -0x58(%rbp),%esi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1330 <main+0x170>
movslq -0x14(%rbp),%rax
cvttsd2si -0xa0(%rbp,%rax,8),%esi
ff ff
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12fb <main+0x13b>
lea    -0xa0(%rbp),%rdi
mov    -0x1c(%rbp),%esi
movsd  -0x58(%rbp),%xmm0
mov    -0x38(%rbp),%rdx
call   10c0 <housemat@plt>
mov    -0x38(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1080 <mdisplay@plt>
mov    -0x38(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    $0x1,%r9d
call   1050 <mmult@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x1,%edx
call   1080 <mdisplay@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x40(%rbp),%rcx
call   1040 <qr_house@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1080 <mdisplay@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x40(%rbp),%rcx
mov    -0x50(%rbp),%r8
mov    -0x48(%rbp),%r9
call   1060 <getQR_house@plt>
mov    -0x48(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1080 <mdisplay@plt>
mov    -0x50(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1080 <mdisplay@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
lea    -0xf0(%rbp),%rdx
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x24(%rbp),%r9d
call   1050 <mmult@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1080 <mdisplay@plt>
lea    -0x140(%rbp),%rdi
lea    0xc51(%rip),%rsi
mov    $0x48,%edx
call   10a0 <memcpy@plt>
lea    -0x1c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1090 <memset@plt>
lea    -0x1e0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
lea    -0x200(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
lea    -0x140(%rbp),%rdi
lea    -0x1e0(%rbp),%rdx
lea    -0x200(%rbp),%rcx
mov    $0x3,%esi
call   10b0 <eig@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    14db <main+0x31b>
mov    -0x14(%rbp),%esi
movslq -0x14(%rbp),%rax
movsd  -0x1e0(%rbp,%rax,8),%xmm0
ff ff
movslq -0x14(%rbp),%rax
movsd  -0x200(%rbp,%rax,8),%xmm1
ff ff
lea    0xc1d(%rip),%rdi
mov    $0x2,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1498 <main+0x2d8>
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>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    $0x80,%edi
call   10b0 <malloc@plt>
mov    %rax,%r15
mov    $0x18,%edi
call   10b0 <malloc@plt>
mov    %rax,0x48(%rsp)
mov    $0x48,%edi
call   10b0 <malloc@plt>
mov    %rax,%r12
mov    $0x48,%edi
call   10b0 <malloc@plt>
mov    %rax,%r13
movaps 0xe22(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe03(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
mov    0xe4a(%rip),%rax
mov    %rax,0x120(%rsp)
movaps 0xe2b(%rip),%xmm0
movaps %xmm0,0x110(%rsp)
movaps 0xe0c(%rip),%xmm0
movaps %xmm0,0x100(%rsp)
movaps 0xded(%rip),%xmm0
movaps %xmm0,0xf0(%rsp)
movapd 0xdcd(%rip),%xmm0
movapd %xmm0,0xe0(%rsp)
lea    0xe55(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x70(%rsp),%rbp
lea    0x50(%rsp),%rbx
mov    %rbp,%rdi
mov    $0x4,%esi
mov    %rbx,%rdx
call   10c0 <house@plt>
movsd  %xmm0,0x40(%rsp)
cvttsd2si %xmm0,%esi
lea    0xe26(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
cvttsd2si 0x50(%rsp),%esi
lea    0xe1d(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
cvttsd2si 0x58(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
cvttsd2si 0x60(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
cvttsd2si 0x68(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
movsd  0x40(%rsp),%xmm0
mov    %r15,%rdx
call   10a0 <housemat@plt>
mov    %r15,%rdi
mov    $0x4,%esi
mov    $0x4,%edx
call   1080 <mdisplay@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    $0x4,%ecx
mov    $0x4,%r8d
mov    $0x1,%r9d
call   1050 <mmult@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1080 <mdisplay@plt>
lea    0xe0(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
mov    0x48(%rsp),%rbp
mov    %rbp,%rcx
call   1040 <qr_house@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
call   1080 <mdisplay@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
mov    %rbp,%rcx
mov    %r13,%r8
mov    %r12,%r9
call   1060 <getQR_house@plt>
mov    %r12,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
call   1080 <mdisplay@plt>
mov    %r13,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
call   1080 <mdisplay@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    $0x3,%ecx
mov    $0x3,%r8d
mov    $0x3,%r9d
call   1050 <mmult@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x3,%edx
call   1080 <mdisplay@plt>
mov    0xcc4(%rip),%rax
mov    %rax,0xd0(%rsp)
movaps 0xca5(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xc86(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xc67(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xc48(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movq   $0x0,0x30(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x90(%rsp),%rdi
lea    0x20(%rsp),%rdx
mov    %rsp,%rcx
mov    $0x3,%esi
call   1090 <eig@plt>
movsd  0x20(%rsp),%xmm0
movsd  (%rsp),%xmm1
lea    0xc59(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%al
call   1070 <printf@plt>
movsd  0x28(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%al
call   1070 <printf@plt>
movsd  0x30(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x2,%al
call   1070 <printf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.x = [4 x double] [double 3.000000e+00, double 1.000000e+00, double 5.000000e+00, double 1.000000e+00]
@__const.main.AA = [9 x double] [double 1.200000e+01, double -5.100000e+01, double 4.000000e+00, double 6.000000e+00, double 1.670000e+02, double -6.800000e+01, double -4.000000e+00, double 2.400000e+01, double -4.100000e+01]
@.str = [8 x i8] c"b %lf \0A\00"
@.str.1 = [11 x i8] c"beta %lf \0A\00"
@.str.2 = [8 x i8] c"v %lf \0A\00"
@__const.main.A = [9 x double] [double 1.000000e+00, double 5.000000e+00, double 7.000000e+00, double 3.000000e+00, double 0.000000e+00, double 6.000000e+00, double 4.000000e+00, double 3.000000e+00, double 1.000000e+00]
@.str.3 = [12 x i8] c"e%d %g %g \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%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 [4 x double]
%20 = alloca [4 x double]
%21 = alloca [9 x double]
%22 = alloca [9 x double]
%23 = alloca [16 x double]
%24 = alloca [3 x double]
%25 = alloca [3 x double]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 4, i32* %8
store double 1.000000e+00, double* %18
store i32 3, i32* %9
store i32 3, i32* %10
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = mul i64 8, %27
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = mul i64 %28, %30
%32 = trunc i64 %31 to i32
%33 = call i64 @malloc(i32 %32)
%34 = inttoptr i64 %33 to double*
store double* %34, double** %14
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = mul i64 8, %36
%38 = trunc i64 %37 to i32
%39 = call i64 @malloc(i32 %38)
%40 = inttoptr i64 %39 to double*
store double* %40, double** %15
%41 = load i32, i32* %10
%42 = sext i32 %41 to i64
%43 = mul i64 8, %42
%44 = load i32, i32* %10
%45 = sext i32 %44 to i64
%46 = mul i64 %43, %45
%47 = trunc i64 %46 to i32
%48 = call i64 @malloc(i32 %47)
%49 = inttoptr i64 %48 to double*
store double* %49, double** %16
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = mul i64 8, %51
%53 = load i32, i32* %10
%54 = sext i32 %53 to i64
%55 = mul i64 %52, %54
%56 = trunc i64 %55 to i32
%57 = call i64 @malloc(i32 %56)
%58 = inttoptr i64 %57 to double*
store double* %58, double** %17
%59 = bitcast [4 x double]* %19 to i8*
%60 = bitcast [4 x double]* %20 to i8*
%61 = bitcast [9 x double]* %21 to i8*
%62 = load double, double* %18
%63 = fptosi double %62 to i32
%64 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %63)
%65 = getelementptr inbounds [4 x double], [4 x double]* %19, i64 0, i64 0
%66 = load i32, i32* %8
%67 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 0
%68 = call double @house(double* %65, i32 %66, double* %67)
store double %68, double* %18
%69 = load double, double* %18
%70 = fptosi double %69 to i32
%71 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %70)
store i32 0, i32* %6
br label %72
72: ; preds = %83, %2
%73 = load i32, i32* %6
%74 = load i32, i32* %8
%75 = icmp slt i32 %73, %74
br i1 %75, label %76, label %86
76: ; preds = %72
%77 = load i32, i32* %6
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 %78
%80 = load double, double* %79
%81 = fptosi double %80 to i32
%82 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %81)
br label %83
83: ; preds = %76
%84 = load i32, i32* %6
%85 = add nsw i32 %84, 1
store i32 %85, i32* %6
br label %72
86: ; preds = %72
%87 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 0
%88 = load i32, i32* %8
%89 = load double, double* %18
%90 = load double*, double** %14
%91 = call i32 @housemat(double* %87, i32 %88, double %89, double* %90)
%92 = load double*, double** %14
%93 = load i32, i32* %8
%94 = load i32, i32* %8
%95 = call i32 @mdisplay(double* %92, i32 %93, i32 %94)
%96 = load double*, double** %14
%97 = getelementptr inbounds [4 x double], [4 x double]* %19, i64 0, i64 0
%98 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 0
%99 = load i32, i32* %8
%100 = load i32, i32* %8
%101 = call i32 @mmult(double* %96, double* %97, double* %98, i32 %99, i32 %100, i32 1)
%102 = getelementptr inbounds [4 x double], [4 x double]* %20, i64 0, i64 0
%103 = load i32, i32* %8
%104 = call i32 @mdisplay(double* %102, i32 %103, i32 1)
%105 = getelementptr inbounds [9 x double], [9 x double]* %21, i64 0, i64 0
%106 = load i32, i32* %9
%107 = load i32, i32* %10
%108 = load double*, double** %15
%109 = call i32 @qr_house(double* %105, i32 %106, i32 %107, double* %108)
%110 = getelementptr inbounds [9 x double], [9 x double]* %21, i64 0, i64 0
%111 = load i32, i32* %9
%112 = load i32, i32* %10
%113 = call i32 @mdisplay(double* %110, i32 %111, i32 %112)
%114 = getelementptr inbounds [9 x double], [9 x double]* %21, i64 0, i64 0
%115 = load i32, i32* %9
%116 = load i32, i32* %10
%117 = load double*, double** %15
%118 = load double*, double** %17
%119 = load double*, double** %16
%120 = call i32 @getQR_house(double* %114, i32 %115, i32 %116, double* %117, double* %118, double* %119)
%121 = load double*, double** %16
%122 = load i32, i32* %10
%123 = load i32, i32* %10
%124 = call i32 @mdisplay(double* %121, i32 %122, i32 %123)
%125 = load double*, double** %17
%126 = load i32, i32* %9
%127 = load i32, i32* %10
%128 = call i32 @mdisplay(double* %125, i32 %126, i32 %127)
%129 = load double*, double** %17
%130 = load double*, double** %16
%131 = getelementptr inbounds [9 x double], [9 x double]* %21, i64 0, i64 0
%132 = load i32, i32* %9
%133 = load i32, i32* %10
%134 = load i32, i32* %10
%135 = call i32 @mmult(double* %129, double* %130, double* %131, i32 %132, i32 %133, i32 %134)
%136 = getelementptr inbounds [9 x double], [9 x double]* %21, i64 0, i64 0
%137 = load i32, i32* %9
%138 = load i32, i32* %10
%139 = call i32 @mdisplay(double* %136, i32 %137, i32 %138)
%140 = bitcast [9 x double]* %22 to i8*
%141 = bitcast [16 x double]* %23 to i8*
%142 = bitcast [3 x double]* %24 to i8*
%143 = bitcast [3 x double]* %25 to i8*
%144 = getelementptr inbounds [9 x double], [9 x double]* %22, i64 0, i64 0
%145 = getelementptr inbounds [3 x double], [3 x double]* %24, i64 0, i64 0
%146 = getelementptr inbounds [3 x double], [3 x double]* %25, i64 0, i64 0
%147 = call i32 @eig(double* %144, i32 3, double* %145, double* %146)
store i32 0, i32* %6
br label %148
148: ; preds = %162, %86
%149 = load i32, i32* %6
%150 = icmp slt i32 %149, 3
br i1 %150, label %151, label %165
151: ; preds = %148
%152 = load i32, i32* %6
%153 = load i32, i32* %6
%154 = sext i32 %153 to i64
%155 = getelementptr inbounds [3 x double], [3 x double]* %24, i64 0, i64 %154
%156 = load double, double* %155
%157 = load i32, i32* %6
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds [3 x double], [3 x double]* %25, i64 0, i64 %158
%160 = load double, double* %159
%161 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %152, double %156, double %160)
br label %162
162: ; preds = %151
%163 = load i32, i32* %6
%164 = add nsw i32 %163, 1
store i32 %164, i32* %6
br label %148
165: ; preds = %148
%166 = load double*, double** %14
%167 = call i32 @free(double* %166)
%168 = load double*, double** %15
%169 = call i32 @free(double* %168)
%170 = load double*, double** %16
%171 = call i32 @free(double* %170)
%172 = load double*, double** %17
%173 = call i32 @free(double* %172)
ret i32 0
}

LLVM IR (-O2):
@__const.main.x = [4 x double] [double 3.000000e+00, double 1.000000e+00, double 5.000000e+00, double 1.000000e+00]
@__const.main.AA = [9 x double] [double 1.200000e+01, double -5.100000e+01, double 4.000000e+00, double 6.000000e+00, double 1.670000e+02, double -6.800000e+01, double -4.000000e+00, double 2.400000e+01, double -4.100000e+01]
@.str = [8 x i8] c"b %lf \0A\00"
@.str.1 = [11 x i8] c"beta %lf \0A\00"
@.str.2 = [8 x i8] c"v %lf \0A\00"
@__const.main.A = [9 x double] [double 1.000000e+00, double 5.000000e+00, double 7.000000e+00, double 3.000000e+00, double 0.000000e+00, double 6.000000e+00, double 4.000000e+00, double 3.000000e+00, double 1.000000e+00]
@.str.3 = [12 x i8] c"e%d %g %g \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4 x double]
%4 = alloca [4 x double]
%5 = alloca [9 x double]
%6 = alloca [9 x double]
%7 = alloca [3 x double]
%8 = alloca [3 x double]
%9 = tail call i64 @malloc(i32 128)
%10 = tail call i64 @malloc(i32 24)
%11 = tail call i64 @malloc(i32 72)
%12 = tail call i64 @malloc(i32 72)
%13 = bitcast [4 x double]* %3 to i8*
%14 = bitcast [4 x double]* %4 to i8*
%15 = bitcast [9 x double]* %5 to i8*
%16 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 1)
%17 = getelementptr inbounds [4 x double], [4 x double]* %3, i64 0, i64 0
%18 = getelementptr inbounds [4 x double], [4 x double]* %4, i64 0, i64 0
%19 = call double @house(double* %17, i32 4, double* %18)
%20 = fptosi double %19 to i32
%21 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load double, double* %18
%23 = fptosi double %22 to i32
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [4 x double], [4 x double]* %4, i64 0, i64 1
%26 = load double, double* %25
%27 = fptosi double %26 to i32
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds [4 x double], [4 x double]* %4, i64 0, i64 2
%30 = load double, double* %29
%31 = fptosi double %30 to i32
%32 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = getelementptr inbounds [4 x double], [4 x double]* %4, i64 0, i64 3
%34 = load double, double* %33
%35 = fptosi double %34 to i32
%36 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = inttoptr i64 %9 to double*
%38 = inttoptr i64 %10 to double*
%39 = inttoptr i64 %11 to double*
%40 = inttoptr i64 %12 to double*
%41 = call i32 @housemat(double* %18, i32 4, double %19, double* %37)
%42 = call i32 @mdisplay(double* %37, i32 4, i32 4)
%43 = call i32 @mmult(double* %37, double* %17, double* %18, i32 4, i32 4, i32 1)
%44 = call i32 @mdisplay(double* %18, i32 4, i32 1)
%45 = getelementptr inbounds [9 x double], [9 x double]* %5, i64 0, i64 0
%46 = call i32 @qr_house(double* %45, i32 3, i32 3, double* %38)
%47 = call i32 @mdisplay(double* %45, i32 3, i32 3)
%48 = call i32 @getQR_house(double* %45, i32 3, i32 3, double* %38, double* %40, double* %39)
%49 = call i32 @mdisplay(double* %39, i32 3, i32 3)
%50 = call i32 @mdisplay(double* %40, i32 3, i32 3)
%51 = call i32 @mmult(double* %40, double* %39, double* %45, i32 3, i32 3, i32 3)
%52 = call i32 @mdisplay(double* %45, i32 3, i32 3)
%53 = bitcast [9 x double]* %6 to i8*
%54 = bitcast [3 x double]* %7 to i8*
%55 = bitcast [3 x double]* %8 to i8*
%56 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 0
%57 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%58 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%59 = call i32 @eig(double* %56, i32 3, double* %57, double* %58)
%60 = load double, double* %57
%61 = load double, double* %58
%62 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 0, double %60, double %61)
%63 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 1
%64 = load double, double* %63
%65 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 1
%66 = load double, double* %65
%67 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 1, double %64, double %66)
%68 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 2
%69 = load double, double* %68
%70 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 2
%71 = load double, double* %70
%72 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 2, double %69, double %71)
%73 = call i32 @free(double* %37)
%74 = call i32 @free(double* %38)
%75 = call i32 @free(double* %39)
%76 = call i32 @free(double* %40)
ret i32 0
}