#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*/ lin_solve_PSD(double *, double *, double *, int, int);
int /*<<< orphan*/ lin_solve_triangular_equ(double *, double *, double *, int,
                                            int, int);
int /*<<< orphan*/ printf(char *, ...);
void test_linear_solver(void) {
  int i;
  int dim_i = 3;
  int dim_j = 3;
  double A_1[9] = {0.6790, 0.0000, 0.0000, 0.7580, 0.6550,
                   0.0000, 0.7430, 0.1710, 0.2770};
  double x_1[3] = {0.0460, 0.0970, 0.8230};
  double b_1[3] = {0.031234, 0.098403, 0.278736};
  double A_2[9] = {0.6950, 0.0340, 0.7660, 0.0000, 0.4390,
                   0.7950, 0.0000, 0.0000, 0.1870};
  double x_2[3] = {0.4900, 0.4460, 0.6460};
  double b_2[3] = {0.850550, 0.709364, 0.120802};
  double A_3[9] = {0.7510, 0.1400, 0.1300, 0.1400, 0.2550,
                   0.2140, 0.1300, 0.2140, 0.5060};
  double x_3[3] = {0.8140, 0.2440, 0.9290};
  double b_3[3] = {0.766244, 0.374986, 0.628110};
  printf("Test 1: lower triangular matrix linear equation solver\n");
  printf("Expected: ");
  for (i = 0; i < dim_i; i++) {
    printf("%.4f\t", x_1[i]);
  }
  printf("\n");
  lin_solve_triangular_equ(A_1, x_1, b_1, dim_i, dim_j, 1);
  printf("Obtained: ");
  for (i = 0; i < dim_i; i++) {
    printf("%.4f\t", x_1[i]);
  }
  printf("\n");
  printf("Test 2: upper triangular matrix linear equation solver\n");
  printf("Expected: ");
  for (i = 0; i < dim_i; i++) {
    printf("%.4f\t", x_2[i]);
  }
  printf("\n");
  lin_solve_triangular_equ(A_2, x_2, b_2, dim_i, dim_j, 0);
  printf("Obtained: ");
  for (i = 0; i < dim_i; i++) {
    printf("%.4f\t", x_2[i]);
  }
  printf("\n");
  printf("Test 3: Symmetric matrix linear equation solver\n");
  printf("Expected: ");
  for (i = 0; i < dim_i; i++) {
    printf("%.4f\t", x_3[i]);
  }
  printf("\n");
  lin_solve_PSD(A_3, x_3, b_3, dim_i, dim_j);
  printf("Obtained: ");
  for (i = 0; i < dim_i; i++) {
    printf("%.4f\t", x_3[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<test_linear_solver>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x3,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1040 <memset@plt>
movsd  0xed7(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xec2(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xead(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe98(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe83(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe6e(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0xe92(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xe8f(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xe8c(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xe91(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0xe8b(%rip),%rax
mov    %rax,-0x98(%rbp)
mov    0xe85(%rip),%rax
mov    %rax,-0x90(%rbp)
lea    -0xf0(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1040 <memset@plt>
movsd  0xdfb(%rip),%xmm0
movsd  %xmm0,-0xf0(%rbp)
ff
movsd  0xde3(%rip),%xmm0
movsd  %xmm0,-0xe8(%rbp)
ff
movsd  0xdcb(%rip),%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  0xdb3(%rip),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  0xd9b(%rip),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  0xd83(%rip),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
mov    0xe14(%rip),%rax
mov    %rax,-0x110(%rbp)
mov    0xe0e(%rip),%rax
mov    %rax,-0x108(%rbp)
mov    0xe08(%rip),%rax
mov    %rax,-0x100(%rbp)
mov    0xe0a(%rip),%rax
mov    %rax,-0x130(%rbp)
mov    0xe04(%rip),%rax
mov    %rax,-0x128(%rbp)
mov    0xdfe(%rip),%rax
mov    %rax,-0x120(%rbp)
lea    -0x180(%rbp),%rdi
lea    0xdf9(%rip),%rsi
mov    $0x48,%edx
call   1050 <memcpy@plt>
mov    0xe38(%rip),%rax
mov    %rax,-0x1a0(%rbp)
mov    0xe32(%rip),%rax
mov    %rax,-0x198(%rbp)
mov    0xe2c(%rip),%rax
mov    %rax,-0x190(%rbp)
mov    0xe2e(%rip),%rax
mov    %rax,-0x1c0(%rbp)
mov    0xe28(%rip),%rax
mov    %rax,-0x1b8(%rbp)
mov    0xe22(%rip),%rax
mov    %rax,-0x1b0(%rbp)
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    139a <test_linear_solver+0x24a>
movslq -0x4(%rbp),%rax
movsd  -0x80(%rbp,%rax,8),%xmm0
lea    0xe26(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1368 <test_linear_solver+0x218>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    $0x1,%r9d
call   1060 <lin_solve_triangular_equ@plt>
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1410 <test_linear_solver+0x2c0>
movslq -0x4(%rbp),%rax
movsd  -0x80(%rbp,%rax,8),%xmm0
lea    0xdb0(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    13de <test_linear_solver+0x28e>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1476 <test_linear_solver+0x326>
movslq -0x4(%rbp),%rax
movsd  -0x110(%rbp,%rax,8),%xmm0
ff ff
lea    0xd4a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1441 <test_linear_solver+0x2f1>
lea    0xda6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xf0(%rbp),%rdi
lea    -0x110(%rbp),%rsi
lea    -0x130(%rbp),%rdx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
xor    %r9d,%r9d
call   1060 <lin_solve_triangular_equ@plt>
lea    0xd02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    14f2 <test_linear_solver+0x3a2>
movslq -0x4(%rbp),%rax
movsd  -0x110(%rbp,%rax,8),%xmm0
ff ff
lea    0xcce(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    14bd <test_linear_solver+0x36d>
lea    0xd2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xced(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xc8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1558 <test_linear_solver+0x408>
movslq -0x4(%rbp),%rax
movsd  -0x1a0(%rbp,%rax,8),%xmm0
ff ff
lea    0xc68(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1523 <test_linear_solver+0x3d3>
lea    0xcc4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x180(%rbp),%rdi
lea    -0x1a0(%rbp),%rsi
lea    -0x1c0(%rbp),%rdx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
call   1070 <lin_solve_PSD@plt>
lea    0xc23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    15d1 <test_linear_solver+0x481>
movslq -0x4(%rbp),%rax
movsd  -0x1a0(%rbp,%rax,8),%xmm0
ff ff
lea    0xbef(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    159c <test_linear_solver+0x44c>
lea    0xc4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_linear_solver>:
push   %r15
push   %r14
push   %rbx
sub    $0x1b0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movabs $0x3fe5ba5e353f7cee,%rax
ba e5 3f
mov    %rax,0xc0(%rsp)
movaps 0xe70(%rip),%xmm1
movups %xmm1,0xd8(%rsp)
movaps 0xe71(%rip),%xmm1
movaps %xmm1,0xf0(%rsp)
movabs $0x3fd1ba5e353f7cee,%rax
ba d1 3f
mov    %rax,0x100(%rsp)
mov    0xee0(%rip),%rax
mov    %rax,0x50(%rsp)
movaps 0xec4(%rip),%xmm1
movaps %xmm1,0x40(%rsp)
mov    0xee8(%rip),%rax
mov    %rax,0xb0(%rsp)
movaps 0xec9(%rip),%xmm1
movaps %xmm1,0xa0(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x140(%rsp)
movaps 0xe1a(%rip),%xmm0
movaps %xmm0,0x110(%rsp)
movabs $0x3fe883126e978d50,%rax
83 e8 3f
mov    %rax,0x120(%rsp)
movaps 0xe09(%rip),%xmm0
movaps %xmm0,0x130(%rsp)
movabs $0x3fc7ef9db22d0e56,%rax
ef c7 3f
mov    %rax,0x150(%rsp)
mov    0xe98(%rip),%rax
mov    %rax,0x30(%rsp)
movaps 0xe7c(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    0xea0(%rip),%rax
mov    %rax,0x90(%rsp)
movaps 0xe81(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
mov    0xed2(%rip),%rax
mov    %rax,0x1a0(%rsp)
movaps 0xeb3(%rip),%xmm0
movaps %xmm0,0x190(%rsp)
movaps 0xe94(%rip),%xmm0
movaps %xmm0,0x180(%rsp)
movaps 0xe75(%rip),%xmm0
movaps %xmm0,0x170(%rsp)
movaps 0xe56(%rip),%xmm0
movaps %xmm0,0x160(%rsp)
mov    0xea7(%rip),%rax
mov    %rax,0x10(%rsp)
movaps 0xe8b(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    0xeb0(%rip),%rax
mov    %rax,0x70(%rsp)
movaps 0xe94(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
lea    0xebc(%rip),%rdi
call   1040 <puts@plt>
lea    0xe94(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe8e(%rip),%rbx
movsd  0xd23(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xd19(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xd0f(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xc0(%rsp),%rdi
lea    0x40(%rsp),%rsi
lea    0xa0(%rsp),%rdx
mov    $0x3,%ecx
mov    $0x3,%r8d
mov    $0x1,%r9d
call   1060 <lin_solve_triangular_equ@plt>
lea    0xe22(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  0x40(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x48(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x50(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe19(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  0xc6f(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xc65(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xc5b(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x110(%rsp),%rdi
lea    0x20(%rsp),%rsi
lea    0x80(%rsp),%rdx
mov    $0x3,%ecx
mov    $0x3,%r8d
xor    %r9d,%r9d
call   1060 <lin_solve_triangular_equ@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  0x20(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x28(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x30(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd8e(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  0xbc5(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xbbb(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xbb1(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x160(%rsp),%rdi
mov    %rsp,%rsi
lea    0x60(%rsp),%rdx
mov    $0x3,%ecx
mov    $0x3,%r8d
call   1070 <lin_solve_PSD@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  (%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x10(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1b0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.test_linear_solver.x_1 = [3 x double] [double 4.600000e-02, double 9.700000e-02, double 0x3FEA5604189374BC]
@__const.test_linear_solver.b_1 = [3 x double] [double 3.123400e-02, double 9.840300e-02, double 2.787360e-01]
@__const.test_linear_solver.x_2 = [3 x double] [double 4.900000e-01, double 4.460000e-01, double 6.460000e-01]
@__const.test_linear_solver.b_2 = [3 x double] [double 8.505500e-01, double 7.093640e-01, double 1.208020e-01]
@__const.test_linear_solver.A_3 = [9 x double] [double 7.510000e-01, double 1.400000e-01, double 1.300000e-01, double 1.400000e-01, double 2.550000e-01, double 2.140000e-01, double 1.300000e-01, double 2.140000e-01, double 5.060000e-01]
@__const.test_linear_solver.x_3 = [3 x double] [double 8.140000e-01, double 2.440000e-01, double 9.290000e-01]
@__const.test_linear_solver.b_3 = [3 x double] [double 7.662440e-01, double 3.749860e-01, double 6.281100e-01]
@.str = [56 x i8] c"Test 1: lower triangular matrix linear equation solver\0A\00"
@.str.1 = [11 x i8] c"Expected: \00"
@.str.2 = [6 x i8] c"%.4f\09\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [11 x i8] c"Obtained: \00"
@.str.5 = [56 x i8] c"Test 2: upper triangular matrix linear equation solver\0A\00"
@.str.6 = [49 x i8] c"Test 3: Symmetric matrix linear equation solver\0A\00"
define void @test_linear_solver() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [9 x double]
%5 = alloca [3 x double]
%6 = alloca [3 x double]
%7 = alloca [9 x double]
%8 = alloca [3 x double]
%9 = alloca [3 x double]
%10 = alloca [9 x double]
%11 = alloca [3 x double]
%12 = alloca [3 x double]
store i32 3, i32* %2
store i32 3, i32* %3
%13 = bitcast [9 x double]* %4 to i8*
%14 = bitcast i8* %13 to [9 x double]*
%15 = getelementptr inbounds [9 x double], [9 x double]* %14, i32 0, i32 0
store double 6.790000e-01, double* %15
%16 = getelementptr inbounds [9 x double], [9 x double]* %14, i32 0, i32 3
store double 7.580000e-01, double* %16
%17 = getelementptr inbounds [9 x double], [9 x double]* %14, i32 0, i32 4
store double 6.550000e-01, double* %17
%18 = getelementptr inbounds [9 x double], [9 x double]* %14, i32 0, i32 6
store double 7.430000e-01, double* %18
%19 = getelementptr inbounds [9 x double], [9 x double]* %14, i32 0, i32 7
store double 1.710000e-01, double* %19
%20 = getelementptr inbounds [9 x double], [9 x double]* %14, i32 0, i32 8
store double 2.770000e-01, double* %20
%21 = bitcast [3 x double]* %5 to i8*
%22 = bitcast [3 x double]* %6 to i8*
%23 = bitcast [9 x double]* %7 to i8*
%24 = bitcast i8* %23 to [9 x double]*
%25 = getelementptr inbounds [9 x double], [9 x double]* %24, i32 0, i32 0
store double 6.950000e-01, double* %25
%26 = getelementptr inbounds [9 x double], [9 x double]* %24, i32 0, i32 1
store double 3.400000e-02, double* %26
%27 = getelementptr inbounds [9 x double], [9 x double]* %24, i32 0, i32 2
store double 7.660000e-01, double* %27
%28 = getelementptr inbounds [9 x double], [9 x double]* %24, i32 0, i32 4
store double 4.390000e-01, double* %28
%29 = getelementptr inbounds [9 x double], [9 x double]* %24, i32 0, i32 5
store double 7.950000e-01, double* %29
%30 = getelementptr inbounds [9 x double], [9 x double]* %24, i32 0, i32 8
store double 1.870000e-01, double* %30
%31 = bitcast [3 x double]* %8 to i8*
%32 = bitcast [3 x double]* %9 to i8*
%33 = bitcast [9 x double]* %10 to i8*
%34 = bitcast [3 x double]* %11 to i8*
%35 = bitcast [3 x double]* %12 to i8*
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %38
38: ; preds = %48, %0
%39 = load i32, i32* %1
%40 = load i32, i32* %2
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %51
42: ; preds = %38
%43 = load i32, i32* %1
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 %44
%46 = load double, double* %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %46)
br label %48
48: ; preds = %42
%49 = load i32, i32* %1
%50 = add nsw i32 %49, 1
store i32 %50, i32* %1
br label %38
51: ; preds = %38
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%53 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 0
%54 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%55 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%56 = load i32, i32* %2
%57 = load i32, i32* %3
%58 = call i32 @lin_solve_triangular_equ(double* %53, double* %54, double* %55, i32 %56, i32 %57, i32 1)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %60
60: ; preds = %70, %51
%61 = load i32, i32* %1
%62 = load i32, i32* %2
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %73
64: ; preds = %60
%65 = load i32, i32* %1
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 %66
%68 = load double, double* %67
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %68)
br label %70
70: ; preds = %64
%71 = load i32, i32* %1
%72 = add nsw i32 %71, 1
store i32 %72, i32* %1
br label %60
73: ; preds = %60
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0))
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %77
77: ; preds = %87, %73
%78 = load i32, i32* %1
%79 = load i32, i32* %2
%80 = icmp slt i32 %78, %79
br i1 %80, label %81, label %90
81: ; preds = %77
%82 = load i32, i32* %1
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 %83
%85 = load double, double* %84
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %85)
br label %87
87: ; preds = %81
%88 = load i32, i32* %1
%89 = add nsw i32 %88, 1
store i32 %89, i32* %1
br label %77
90: ; preds = %77
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%92 = getelementptr inbounds [9 x double], [9 x double]* %7, i64 0, i64 0
%93 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%94 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%95 = load i32, i32* %2
%96 = load i32, i32* %3
%97 = call i32 @lin_solve_triangular_equ(double* %92, double* %93, double* %94, i32 %95, i32 %96, i32 0)
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %99
99: ; preds = %109, %90
%100 = load i32, i32* %1
%101 = load i32, i32* %2
%102 = icmp slt i32 %100, %101
br i1 %102, label %103, label %112
103: ; preds = %99
%104 = load i32, i32* %1
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 %105
%107 = load double, double* %106
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %107)
br label %109
109: ; preds = %103
%110 = load i32, i32* %1
%111 = add nsw i32 %110, 1
store i32 %111, i32* %1
br label %99
112: ; preds = %99
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.6, i64 0, i64 0))
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %116
116: ; preds = %126, %112
%117 = load i32, i32* %1
%118 = load i32, i32* %2
%119 = icmp slt i32 %117, %118
br i1 %119, label %120, label %129
120: ; preds = %116
%121 = load i32, i32* %1
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 %122
%124 = load double, double* %123
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %124)
br label %126
126: ; preds = %120
%127 = load i32, i32* %1
%128 = add nsw i32 %127, 1
store i32 %128, i32* %1
br label %116
129: ; preds = %116
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%131 = getelementptr inbounds [9 x double], [9 x double]* %10, i64 0, i64 0
%132 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%133 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%134 = load i32, i32* %2
%135 = load i32, i32* %3
%136 = call i32 @lin_solve_PSD(double* %131, double* %132, double* %133, i32 %134, i32 %135)
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %138
138: ; preds = %148, %129
%139 = load i32, i32* %1
%140 = load i32, i32* %2
%141 = icmp slt i32 %139, %140
br i1 %141, label %142, label %151
142: ; preds = %138
%143 = load i32, i32* %1
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 %144
%146 = load double, double* %145
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %146)
br label %148
148: ; preds = %142
%149 = load i32, i32* %1
%150 = add nsw i32 %149, 1
store i32 %150, i32* %1
br label %138
151: ; preds = %138
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.test_linear_solver.x_1 = [3 x double] [double 4.600000e-02, double 9.700000e-02, double 0x3FEA5604189374BC]
@__const.test_linear_solver.b_1 = [3 x double] [double 3.123400e-02, double 9.840300e-02, double 2.787360e-01]
@__const.test_linear_solver.x_2 = [3 x double] [double 4.900000e-01, double 4.460000e-01, double 6.460000e-01]
@__const.test_linear_solver.b_2 = [3 x double] [double 8.505500e-01, double 7.093640e-01, double 1.208020e-01]
@__const.test_linear_solver.A_3 = [9 x double] [double 7.510000e-01, double 1.400000e-01, double 1.300000e-01, double 1.400000e-01, double 2.550000e-01, double 2.140000e-01, double 1.300000e-01, double 2.140000e-01, double 5.060000e-01]
@__const.test_linear_solver.x_3 = [3 x double] [double 8.140000e-01, double 2.440000e-01, double 9.290000e-01]
@__const.test_linear_solver.b_3 = [3 x double] [double 7.662440e-01, double 3.749860e-01, double 6.281100e-01]
@.str.1 = [11 x i8] c"Expected: \00"
@.str.2 = [6 x i8] c"%.4f\09\00"
@.str.4 = [11 x i8] c"Obtained: \00"
@str = [55 x i8] c"Test 1: lower triangular matrix linear equation solver\00"
@str.7 = [55 x i8] c"Test 2: upper triangular matrix linear equation solver\00"
@str.8 = [48 x i8] c"Test 3: Symmetric matrix linear equation solver\00"
define void @test_linear_solver() {
%1 = alloca [9 x double]
%2 = alloca [3 x double]
%3 = alloca [3 x double]
%4 = alloca [9 x double]
%5 = alloca [3 x double]
%6 = alloca [3 x double]
%7 = alloca [9 x double]
%8 = alloca [3 x double]
%9 = alloca [3 x double]
%10 = bitcast [9 x double]* %1 to i8*
%11 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 0
store double 6.790000e-01, double* %11
%12 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 3
%13 = bitcast double* %12 to <2 x double>*
store <2 x double> <double 7.580000e-01, double 6.550000e-01>, <2 x double>* %13
%14 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 6
%15 = bitcast double* %14 to <2 x double>*
store <2 x double> <double 7.430000e-01, double 1.710000e-01>, <2 x double>* %15
%16 = getelementptr inbounds [9 x double], [9 x double]* %1, i64 0, i64 8
store double 2.770000e-01, double* %16
%17 = bitcast [3 x double]* %2 to i8*
%18 = bitcast [3 x double]* %3 to i8*
%19 = bitcast [9 x double]* %4 to i8*
%20 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 2
%21 = bitcast double* %20 to i8*
%22 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 0
%23 = bitcast [9 x double]* %4 to <2 x double>*
store <2 x double> <double 6.950000e-01, double 3.400000e-02>, <2 x double>* %23
%24 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 2
store double 7.660000e-01, double* %24
%25 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 4
%26 = bitcast double* %25 to <2 x double>*
store <2 x double> <double 4.390000e-01, double 7.950000e-01>, <2 x double>* %26
%27 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 8
store double 1.870000e-01, double* %27
%28 = bitcast [3 x double]* %5 to i8*
%29 = bitcast [3 x double]* %6 to i8*
%30 = bitcast [9 x double]* %7 to i8*
%31 = bitcast [3 x double]* %8 to i8*
%32 = bitcast [3 x double]* %9 to i8*
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%35 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double 4.600000e-02)
%37 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double 9.700000e-02)
%39 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 2
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double 0x3FEA5604189374BC)
%41 = tail call i32 @putchar(i32 10)
%42 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%43 = call i32 @lin_solve_triangular_equ(double* %11, double* %35, double* %42, i32 3, i32 3, i32 1)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%45 = load double, double* %35
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %45)
%47 = load double, double* %37
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %47)
%49 = load double, double* %39
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %49)
%51 = call i32 @putchar(i32 10)
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.7, i64 0, i64 0))
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%54 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double 4.900000e-01)
%56 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double 4.460000e-01)
%58 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double 6.460000e-01)
%60 = call i32 @putchar(i32 10)
%61 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%62 = call i32 @lin_solve_triangular_equ(double* %22, double* %54, double* %61, i32 3, i32 3, i32 0)
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%64 = load double, double* %54
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %64)
%66 = load double, double* %56
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %66)
%68 = load double, double* %58
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %68)
%70 = call i32 @putchar(i32 10)
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.8, i64 0, i64 0))
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%73 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double 8.140000e-01)
%75 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 1
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double 2.440000e-01)
%77 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 2
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double 9.290000e-01)
%79 = call i32 @putchar(i32 10)
%80 = getelementptr inbounds [9 x double], [9 x double]* %7, i64 0, i64 0
%81 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%82 = call i32 @lin_solve_PSD(double* %80, double* %73, double* %81, i32 3, i32 3)
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%84 = load double, double* %73
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %84)
%86 = load double, double* %75
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %86)
%88 = load double, double* %77
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %88)
%90 = call i32 @putchar(i32 10)
ret void
}