#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__ compare_max(double, double, char *, int, double, double *);
int /*<<< orphan*/ dcopy_(int *, double *, int *, double *, int *);
int /*<<< orphan*/ dot_prod_matrix(double *, int, int, double *, double *);
double drand48();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ lapack_inv_(int, double *);
int /*<<< orphan*/ lapack_solve_lin(int, double *, double *, double *);
scalar_t__ malloc(int);
double ptime_ms_d();
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ srand48(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int check_lapack_solve_lin(int n, int verbose, double tiny) {
  if (verbose != 0) {
    fprintf(stdout,
            "==================================================\n"
            "check_lapack_solve_lin (n=%d, tiny=%e): start\n",
            n, tiny);
  }
  int check = 0;
  double max = 0.0;
  double *a = (double *)malloc(sizeof(double) * n * n);
  double *b = (double *)malloc(sizeof(double) * n);
  double *ai = (double *)malloc(sizeof(double) * n * n);
  double *x1 = (double *)malloc(sizeof(double) * n);
  double *x2 = (double *)malloc(sizeof(double) * n);
  if (a == NULL) {
    fprintf(stderr, "check_dgeev_c"
                    " : malloc error for "
                    "a"
                    "\n");
    exit(1);
  };
  if (b == NULL) {
    fprintf(stderr, "check_dgeev_c"
                    " : malloc error for "
                    "b"
                    "\n");
    exit(1);
  };
  if (ai == NULL) {
    fprintf(stderr, "check_dgeev_c"
                    " : malloc error for "
                    "ai"
                    "\n");
    exit(1);
  };
  if (x1 == NULL) {
    fprintf(stderr, "check_dgeev_c"
                    " : malloc error for "
                    "x1"
                    "\n");
    exit(1);
  };
  if (x2 == NULL) {
    fprintf(stderr, "check_dgeev_c"
                    " : malloc error for "
                    "x2"
                    "\n");
    exit(1);
  };
  int i, j;
  srand48(0);
  for (i = 0; i < n; i++) {
    a[i * n + i] = 1.0;
    for (j = 0; j < n; j++) {
      a[i * n + j] = drand48();
    }
  }
  for (i = 0; i < n; i++) {
    b[i] = drand48();
  }
  int i_1 = 1;
  int nn = n * n;
  dcopy_(&nn, a, &i_1, ai, &i_1);
  double t0 = ptime_ms_d();
  lapack_inv_(n, ai);
  dot_prod_matrix(ai, n, n, b, x1);
  double t1 = ptime_ms_d();
  lapack_solve_lin(n, a, b, x2);
  double t2 = ptime_ms_d();
  char label[80];
  for (i = 0; i < n; i++) {
    sprintf(label, "x[%d]", i);
    check += compare_max(x1[i], x2[i], label, verbose, tiny, &max);
  }
  free(a);
  free(b);
  free(ai);
  free(x1);
  free(x2);
  if (verbose != 0) {
    fprintf(stdout,
            " CPU times for lapack_inv_() => dot_prod_matrix(): "
            "%e [msec]\n",
            t1 - t0);
    fprintf(stdout,
            " CPU times for lapack_solve_lin()                : "
            "%e [msec]\n",
            t2 - t1);
    fprintf(stdout, " max error = %e vs tiny = %e\n", max, tiny);
    if (check == 0)
      fprintf(stdout, " => PASSED\n\n");
    else
      fprintf(stdout, " => FAILED\n\n");
  }
  return (check);
}


x86 assembly (clang, -O0):
<check_lapack_solve_lin>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     120f <check_lapack_solve_lin+0x3f>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%edx
movsd  -0x10(%rbp),%xmm0
lea    0xe00(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
movslq -0x4(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
movslq -0x4(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x40(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12b9 <check_lapack_solve_lin+0xe9>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
lea    0xdc2(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
cmpq   $0x0,-0x30(%rbp)
jne    12e5 <check_lapack_solve_lin+0x115>
mov    0x2d15(%rip),%rax
mov    (%rax),%edi
lea    0xdba(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
cmpq   $0x0,-0x38(%rbp)
jne    1311 <check_lapack_solve_lin+0x141>
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
lea    0xdb2(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
cmpq   $0x0,-0x40(%rbp)
jne    133d <check_lapack_solve_lin+0x16d>
mov    0x2cbd(%rip),%rax
mov    (%rax),%edi
lea    0xdab(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
cmpq   $0x0,-0x48(%rbp)
jne    1369 <check_lapack_solve_lin+0x199>
mov    0x2c91(%rip),%rax
mov    (%rax),%edi
lea    0xda4(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
xor    %edi,%edi
call   10b0 <srand48@plt>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    13f2 <check_lapack_solve_lin+0x222>
mov    -0x28(%rbp),%rax
mov    -0x4c(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
movsd  0xc64(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    13df <check_lapack_solve_lin+0x20f>
mov    $0x0,%al
call   10f0 <drand48@plt>
mov    -0x28(%rbp),%rax
mov    -0x4c(%rbp),%ecx
imul   -0x4(%rbp),%ecx
add    -0x50(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    13a8 <check_lapack_solve_lin+0x1d8>
jmp    13e4 <check_lapack_solve_lin+0x214>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1377 <check_lapack_solve_lin+0x1a7>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1427 <check_lapack_solve_lin+0x257>
mov    $0x0,%al
call   10f0 <drand48@plt>
mov    -0x30(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    13f9 <check_lapack_solve_lin+0x229>
movl   $0x1,-0x54(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x4(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x38(%rbp),%rcx
lea    -0x58(%rbp),%rdi
lea    -0x54(%rbp),%r8
mov    %r8,%rdx
call   1040 <dcopy_@plt>
mov    $0x0,%al
call   1080 <ptime_ms_d@plt>
movsd  %xmm0,-0x60(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x38(%rbp),%rsi
call   10c0 <lapack_inv_@plt>
mov    -0x38(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    -0x40(%rbp),%r8
call   1070 <dot_prod_matrix@plt>
mov    $0x0,%al
call   1080 <ptime_ms_d@plt>
movsd  %xmm0,-0x68(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x48(%rbp),%rcx
call   10a0 <lapack_solve_lin@plt>
mov    $0x0,%al
call   1080 <ptime_ms_d@plt>
movsd  %xmm0,-0x70(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1521 <check_lapack_solve_lin+0x351>
lea    -0xc0(%rbp),%rdi
mov    -0x4c(%rbp),%edx
lea    0xc52(%rip),%rsi
call   10d0 <sprintf@plt>
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x48(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
lea    -0xc0(%rbp),%rdi
mov    -0x8(%rbp),%esi
movsd  -0x10(%rbp),%xmm2
lea    -0x20(%rbp),%rdx
call   1060 <compare_max@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    14b2 <check_lapack_solve_lin+0x2e2>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%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>
cmpl   $0x0,-0x8(%rbp)
je     15fd <check_lapack_solve_lin+0x42d>
mov    0x2a79(%rip),%rax
mov    (%rax),%edi
movsd  -0x68(%rbp),%xmm0
subsd  -0x60(%rbp),%xmm0
lea    0xbb5(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    0x2a58(%rip),%rax
mov    (%rax),%edi
movsd  -0x70(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
lea    0xbd2(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    0x2a37(%rip),%rax
mov    (%rax),%edi
movsd  -0x20(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
lea    0xbef(%rip),%rsi
mov    $0x2,%al
call   1050 <fprintf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    15e1 <check_lapack_solve_lin+0x411>
mov    0x2a0c(%rip),%rax
mov    (%rax),%edi
lea    0xbec(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    15f8 <check_lapack_solve_lin+0x428>
mov    0x29f0(%rip),%rax
mov    (%rax),%edi
lea    0xbdd(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    15fd <check_lapack_solve_lin+0x42d>
mov    -0x14(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_lapack_solve_lin>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %esi,%r14d
mov    %edi,%r15d
test   %esi,%esi
movsd  %xmm0,0x10(%rsp)
je     1211 <check_lapack_solve_lin+0x41>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
lea    0xdff(%rip),%rsi
mov    %r15d,%edx
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1050 <fprintf@plt>
movq   $0x0,0x40(%rsp)
lea    0x0(,%r15,8),%ebx
mov    %ebx,%ebp
mov    %r15,(%rsp)
imul   %r15d,%ebp
mov    %ebp,%edi
call   1090 <malloc@plt>
mov    %rax,%r15
mov    %ebx,%edi
call   1090 <malloc@plt>
mov    %rax,%r13
mov    %ebp,%edi
call   1090 <malloc@plt>
mov    %rax,%r12
mov    %ebx,%edi
call   1090 <malloc@plt>
mov    %rax,%rbp
mov    %ebx,%edi
call   1090 <malloc@plt>
mov    %r15,0x8(%rsp)
test   %r15,%r15
je     1501 <check_lapack_solve_lin+0x331>
test   %r13,%r13
je     1513 <check_lapack_solve_lin+0x343>
test   %r12,%r12
mov    (%rsp),%r15
je     1525 <check_lapack_solve_lin+0x355>
test   %rbp,%rbp
je     1537 <check_lapack_solve_lin+0x367>
mov    %rbp,0x18(%rsp)
mov    %r14d,0x24(%rsp)
test   %rax,%rax
je     1549 <check_lapack_solve_lin+0x379>
mov    %rax,0x58(%rsp)
xor    %ebp,%ebp
xor    %edi,%edi
call   10b0 <srand48@plt>
mov    %r15d,%r14d
test   %r15d,%r15d
mov    %r13,0x38(%rsp)
mov    %r12,0x30(%rsp)
jle    1357 <check_lapack_solve_lin+0x187>
lea    0x0(,%r14,8),%r13
mov    0x8(%rsp),%rbx
xor    %r15d,%r15d
nop
mov    %r15d,%eax
imul   (%rsp),%eax
cltq
add    %r15,%rax
mov    0x8(%rsp),%rcx
movabs $0x3ff0000000000000,%rdx
mov    %rdx,(%rcx,%rax,8)
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   10f0 <drand48@plt>
movsd  %xmm0,(%rbx,%r12,8)
add    $0x1,%r12
cmp    %r12,%r14
jne    1300 <check_lapack_solve_lin+0x130>
add    $0x1,%r15
add    %r13,%rbx
cmp    %r14,%r15
jne    12d0 <check_lapack_solve_lin+0x100>
mov    (%rsp),%r15
test   %r15d,%r15d
mov    0x38(%rsp),%r13
mov    0x30(%rsp),%r12
jle    1357 <check_lapack_solve_lin+0x187>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10f0 <drand48@plt>
movsd  %xmm0,0x0(%r13,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1340 <check_lapack_solve_lin+0x170>
movl   $0x1,0x2c(%rsp)
mov    %r15d,%eax
imul   %r15d,%eax
mov    %eax,0x28(%rsp)
lea    0x28(%rsp),%rdi
lea    0x2c(%rsp),%rdx
mov    0x8(%rsp),%rbx
mov    %rbx,%rsi
mov    %r12,%rcx
mov    %rdx,%r8
call   1040 <dcopy_@plt>
xor    %eax,%eax
call   1080 <ptime_ms_d@plt>
movsd  %xmm0,0x50(%rsp)
mov    %r15d,%edi
mov    %r12,%rsi
call   10c0 <lapack_inv_@plt>
mov    %r12,%rdi
mov    %r15d,%esi
mov    %r15d,%edx
mov    %r13,%rcx
mov    0x18(%rsp),%r8
call   1070 <dot_prod_matrix@plt>
xor    %eax,%eax
call   1080 <ptime_ms_d@plt>
movsd  %xmm0,(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    0x58(%rsp),%r12
mov    %r12,%rcx
call   10a0 <lapack_solve_lin@plt>
xor    %eax,%eax
call   1080 <ptime_ms_d@plt>
movsd  %xmm0,0x48(%rsp)
test   %r15d,%r15d
mov    0x24(%rsp),%r15d
jle    1442 <check_lapack_solve_lin+0x272>
xor    %ebx,%ebx
lea    0x60(%rsp),%r13
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
lea    0xd0f(%rip),%rsi
mov    %ebx,%edx
call   10d0 <sprintf@plt>
mov    0x18(%rsp),%rax
movsd  (%rax,%rbx,8),%xmm0
movsd  (%r12,%rbx,8),%xmm1
mov    %r13,%rdi
mov    %r15d,%esi
movsd  0x10(%rsp),%xmm2
lea    0x40(%rsp),%rdx
call   1060 <compare_max@plt>
add    %eax,%ebp
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1400 <check_lapack_solve_lin+0x230>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    0x38(%rsp),%rdi
call   1030 <free@plt>
mov    0x30(%rsp),%rdi
call   1030 <free@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
test   %r15d,%r15d
je     14ed <check_lapack_solve_lin+0x31d>
mov    0x2b5a(%rip),%rbx
mov    (%rbx),%edi
movsd  (%rsp),%xmm0
subsd  0x50(%rsp),%xmm0
lea    0xc8d(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    (%rbx),%edi
movsd  0x48(%rsp),%xmm0
subsd  (%rsp),%xmm0
lea    0xcb0(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    (%rbx),%edi
movsd  0x40(%rsp),%xmm0
lea    0xcd8(%rip),%rsi
movsd  0x10(%rsp),%xmm1
mov    $0x2,%al
call   1050 <fprintf@plt>
test   %ebp,%ebp
mov    (%rbx),%edi
lea    0xcde(%rip),%rax
lea    0xce4(%rip),%rsi
cmove  %rax,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %ebp,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ad8(%rip),%rax
mov    (%rax),%edi
lea    0xb51(%rip),%rsi
jmp    1559 <check_lapack_solve_lin+0x389>
mov    0x2ac6(%rip),%rax
mov    (%rax),%edi
lea    0xb63(%rip),%rsi
jmp    1559 <check_lapack_solve_lin+0x389>
mov    0x2ab4(%rip),%rax
mov    (%rax),%edi
lea    0xb75(%rip),%rsi
jmp    1559 <check_lapack_solve_lin+0x389>
mov    0x2aa2(%rip),%rax
mov    (%rax),%edi
lea    0xb88(%rip),%rsi
jmp    1559 <check_lapack_solve_lin+0x389>
mov    0x2a90(%rip),%rax
mov    (%rax),%edi
lea    0xb9b(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [98 x i8] c"==================================================\0Acheck_lapack_solve_lin (n=%d, tiny=%e): start\0A\00"
@stderr = global i32 0
@.str.1 = [36 x i8] c"check_dgeev_c : malloc error for a\0A\00"
@.str.2 = [36 x i8] c"check_dgeev_c : malloc error for b\0A\00"
@.str.3 = [37 x i8] c"check_dgeev_c : malloc error for ai\0A\00"
@.str.4 = [37 x i8] c"check_dgeev_c : malloc error for x1\0A\00"
@.str.5 = [37 x i8] c"check_dgeev_c : malloc error for x2\0A\00"
@.str.6 = [6 x i8] c"x[%d]\00"
@.str.7 = [62 x i8] c" CPU times for lapack_inv_() => dot_prod_matrix(): %e [msec]\0A\00"
@.str.8 = [62 x i8] c" CPU times for lapack_solve_lin() : %e [msec]\0A\00"
@.str.9 = [30 x i8] c" max error = %e vs tiny = %e\0A\00"
@.str.10 = [13 x i8] c" => PASSED\0A\0A\00"
@.str.11 = [13 x i8] c" => FAILED\0A\0A\00"
define i32 @check_lapack_solve_lin(i32 %0, i32 %1, double %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca [80 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
store double %2, double* %6
%22 = load i32, i32* %5
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %3
%25 = load i32, i32* @stdout
%26 = load i32, i32* %4
%27 = load double, double* %6
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str, i64 0, i64 0), i32 %26, double %27)
br label %29
29: ; preds = %24, %3
store i32 0, i32* %7
store double 0.000000e+00, double* %8
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = mul i64 8, %31
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = mul i64 %32, %34
%36 = trunc i64 %35 to i32
%37 = call i64 @malloc(i32 %36)
%38 = inttoptr i64 %37 to double*
store double* %38, double** %9
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = mul i64 8, %40
%42 = trunc i64 %41 to i32
%43 = call i64 @malloc(i32 %42)
%44 = inttoptr i64 %43 to double*
store double* %44, double** %10
%45 = load i32, i32* %4
%46 = sext i32 %45 to i64
%47 = mul i64 8, %46
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = mul i64 %47, %49
%51 = trunc i64 %50 to i32
%52 = call i64 @malloc(i32 %51)
%53 = inttoptr i64 %52 to double*
store double* %53, double** %11
%54 = load i32, i32* %4
%55 = sext i32 %54 to i64
%56 = mul i64 8, %55
%57 = trunc i64 %56 to i32
%58 = call i64 @malloc(i32 %57)
%59 = inttoptr i64 %58 to double*
store double* %59, double** %12
%60 = load i32, i32* %4
%61 = sext i32 %60 to i64
%62 = mul i64 8, %61
%63 = trunc i64 %62 to i32
%64 = call i64 @malloc(i32 %63)
%65 = inttoptr i64 %64 to double*
store double* %65, double** %13
%66 = load double*, double** %9
%67 = icmp eq double* %66, null
br i1 %67, label %68, label %72
68: ; preds = %29
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %29
%73 = load double*, double** %10
%74 = icmp eq double* %73, null
br i1 %74, label %75, label %79
75: ; preds = %72
%76 = load i32, i32* @stderr
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%78 = call i32 @exit(i32 1)
unreachable
79: ; preds = %72
%80 = load double*, double** %11
%81 = icmp eq double* %80, null
br i1 %81, label %82, label %86
82: ; preds = %79
%83 = load i32, i32* @stderr
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%85 = call i32 @exit(i32 1)
unreachable
86: ; preds = %79
%87 = load double*, double** %12
%88 = icmp eq double* %87, null
br i1 %88, label %89, label %93
89: ; preds = %86
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%92 = call i32 @exit(i32 1)
unreachable
93: ; preds = %86
%94 = load double*, double** %13
%95 = icmp eq double* %94, null
br i1 %95, label %96, label %100
96: ; preds = %93
%97 = load i32, i32* @stderr
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%99 = call i32 @exit(i32 1)
unreachable
100: ; preds = %93
%101 = call i32 @srand48(i32 0)
store i32 0, i32* %14
br label %102
102: ; preds = %133, %100
%103 = load i32, i32* %14
%104 = load i32, i32* %4
%105 = icmp slt i32 %103, %104
br i1 %105, label %106, label %136
106: ; preds = %102
%107 = load double*, double** %9
%108 = load i32, i32* %14
%109 = load i32, i32* %4
%110 = mul nsw i32 %108, %109
%111 = load i32, i32* %14
%112 = add nsw i32 %110, %111
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds double, double* %107, i64 %113
store double 1.000000e+00, double* %114
store i32 0, i32* %15
br label %115
115: ; preds = %129, %106
%116 = load i32, i32* %15
%117 = load i32, i32* %4
%118 = icmp slt i32 %116, %117
br i1 %118, label %119, label %132
119: ; preds = %115
%120 = call double (...) @drand48()
%121 = load double*, double** %9
%122 = load i32, i32* %14
%123 = load i32, i32* %4
%124 = mul nsw i32 %122, %123
%125 = load i32, i32* %15
%126 = add nsw i32 %124, %125
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds double, double* %121, i64 %127
store double %120, double* %128
br label %129
129: ; preds = %119
%130 = load i32, i32* %15
%131 = add nsw i32 %130, 1
store i32 %131, i32* %15
br label %115
132: ; preds = %115
br label %133
133: ; preds = %132
%134 = load i32, i32* %14
%135 = add nsw i32 %134, 1
store i32 %135, i32* %14
br label %102
136: ; preds = %102
store i32 0, i32* %14
br label %137
137: ; preds = %147, %136
%138 = load i32, i32* %14
%139 = load i32, i32* %4
%140 = icmp slt i32 %138, %139
br i1 %140, label %141, label %150
141: ; preds = %137
%142 = call double (...) @drand48()
%143 = load double*, double** %10
%144 = load i32, i32* %14
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds double, double* %143, i64 %145
store double %142, double* %146
br label %147
147: ; preds = %141
%148 = load i32, i32* %14
%149 = add nsw i32 %148, 1
store i32 %149, i32* %14
br label %137
150: ; preds = %137
store i32 1, i32* %16
%151 = load i32, i32* %4
%152 = load i32, i32* %4
%153 = mul nsw i32 %151, %152
store i32 %153, i32* %17
%154 = load double*, double** %9
%155 = load double*, double** %11
%156 = call i32 @dcopy_(i32* %17, double* %154, i32* %16, double* %155, i32* %16)
%157 = call double (...) @ptime_ms_d()
store double %157, double* %18
%158 = load i32, i32* %4
%159 = load double*, double** %11
%160 = call i32 @lapack_inv_(i32 %158, double* %159)
%161 = load double*, double** %11
%162 = load i32, i32* %4
%163 = load i32, i32* %4
%164 = load double*, double** %10
%165 = load double*, double** %12
%166 = call i32 @dot_prod_matrix(double* %161, i32 %162, i32 %163, double* %164, double* %165)
%167 = call double (...) @ptime_ms_d()
store double %167, double* %19
%168 = load i32, i32* %4
%169 = load double*, double** %9
%170 = load double*, double** %10
%171 = load double*, double** %13
%172 = call i32 @lapack_solve_lin(i32 %168, double* %169, double* %170, double* %171)
%173 = call double (...) @ptime_ms_d()
store double %173, double* %20
store i32 0, i32* %14
br label %174
174: ; preds = %200, %150
%175 = load i32, i32* %14
%176 = load i32, i32* %4
%177 = icmp slt i32 %175, %176
br i1 %177, label %178, label %203
178: ; preds = %174
%179 = getelementptr inbounds [80 x i8], [80 x i8]* %21, i64 0, i64 0
%180 = load i32, i32* %14
%181 = call i32 @sprintf(i8* %179, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %180)
%182 = load double*, double** %12
%183 = load i32, i32* %14
%184 = sext i32 %183 to i64
%185 = getelementptr inbounds double, double* %182, i64 %184
%186 = load double, double* %185
%187 = load double*, double** %13
%188 = load i32, i32* %14
%189 = sext i32 %188 to i64
%190 = getelementptr inbounds double, double* %187, i64 %189
%191 = load double, double* %190
%192 = getelementptr inbounds [80 x i8], [80 x i8]* %21, i64 0, i64 0
%193 = load i32, i32* %5
%194 = load double, double* %6
%195 = call i64 @compare_max(double %186, double %191, i8* %192, i32 %193, double %194, double* %8)
%196 = load i32, i32* %7
%197 = sext i32 %196 to i64
%198 = add nsw i64 %197, %195
%199 = trunc i64 %198 to i32
store i32 %199, i32* %7
br label %200
200: ; preds = %178
%201 = load i32, i32* %14
%202 = add nsw i32 %201, 1
store i32 %202, i32* %14
br label %174
203: ; preds = %174
%204 = load double*, double** %9
%205 = call i32 @free(double* %204)
%206 = load double*, double** %10
%207 = call i32 @free(double* %206)
%208 = load double*, double** %11
%209 = call i32 @free(double* %208)
%210 = load double*, double** %12
%211 = call i32 @free(double* %210)
%212 = load double*, double** %13
%213 = call i32 @free(double* %212)
%214 = load i32, i32* %5
%215 = icmp ne i32 %214, 0
br i1 %215, label %216, label %240
216: ; preds = %203
%217 = load i32, i32* @stdout
%218 = load double, double* %19
%219 = load double, double* %18
%220 = fsub double %218, %219
%221 = call i32 (i32, i8*, ...) @fprintf(i32 %217, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.7, i64 0, i64 0), double %220)
%222 = load i32, i32* @stdout
%223 = load double, double* %20
%224 = load double, double* %19
%225 = fsub double %223, %224
%226 = call i32 (i32, i8*, ...) @fprintf(i32 %222, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.8, i64 0, i64 0), double %225)
%227 = load i32, i32* @stdout
%228 = load double, double* %8
%229 = load double, double* %6
%230 = call i32 (i32, i8*, ...) @fprintf(i32 %227, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), double %228, double %229)
%231 = load i32, i32* %7
%232 = icmp eq i32 %231, 0
br i1 %232, label %233, label %236
233: ; preds = %216
%234 = load i32, i32* @stdout
%235 = call i32 (i32, i8*, ...) @fprintf(i32 %234, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
br label %239
236: ; preds = %216
%237 = load i32, i32* @stdout
%238 = call i32 (i32, i8*, ...) @fprintf(i32 %237, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
br label %239
239: ; preds = %236, %233
br label %240
240: ; preds = %239, %203
%241 = load i32, i32* %7
ret i32 %241
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [98 x i8] c"==================================================\0Acheck_lapack_solve_lin (n=%d, tiny=%e): start\0A\00"
@stderr = global i32 0
@.str.1 = [36 x i8] c"check_dgeev_c : malloc error for a\0A\00"
@.str.2 = [36 x i8] c"check_dgeev_c : malloc error for b\0A\00"
@.str.3 = [37 x i8] c"check_dgeev_c : malloc error for ai\0A\00"
@.str.4 = [37 x i8] c"check_dgeev_c : malloc error for x1\0A\00"
@.str.5 = [37 x i8] c"check_dgeev_c : malloc error for x2\0A\00"
@.str.6 = [6 x i8] c"x[%d]\00"
@.str.7 = [62 x i8] c" CPU times for lapack_inv_() => dot_prod_matrix(): %e [msec]\0A\00"
@.str.8 = [62 x i8] c" CPU times for lapack_solve_lin() : %e [msec]\0A\00"
@.str.9 = [30 x i8] c" max error = %e vs tiny = %e\0A\00"
@.str.10 = [13 x i8] c" => PASSED\0A\0A\00"
@.str.11 = [13 x i8] c" => FAILED\0A\0A\00"
define i32 @check_lapack_solve_lin(i32 %0, i32 %1, double %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca [80 x i8]
%8 = icmp eq i32 %1, 0
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = load i32, i32* @stdout
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str, i64 0, i64 0), i32 %0, double %2)
br label %12
12: ; preds = %9, %3
%13 = bitcast double* %4 to i8*
store double 0.000000e+00, double* %4
%14 = shl i32 %0, 3
%15 = mul i32 %14, %0
%16 = tail call i64 @malloc(i32 %15)
%17 = inttoptr i64 %16 to double*
%18 = tail call i64 @malloc(i32 %14)
%19 = inttoptr i64 %18 to double*
%20 = tail call i64 @malloc(i32 %15)
%21 = inttoptr i64 %20 to double*
%22 = tail call i64 @malloc(i32 %14)
%23 = inttoptr i64 %22 to double*
%24 = tail call i64 @malloc(i32 %14)
%25 = inttoptr i64 %24 to double*
%26 = icmp eq i64 %16, 0
br i1 %26, label %27, label %31
27: ; preds = %12
%28 = load i32, i32* @stderr
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %12
%32 = icmp eq i64 %18, 0
br i1 %32, label %33, label %37
33: ; preds = %31
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0))
%36 = tail call i32 @exit(i32 1)
unreachable
37: ; preds = %31
%38 = icmp eq i64 %20, 0
br i1 %38, label %39, label %43
39: ; preds = %37
%40 = load i32, i32* @stderr
%41 = tail call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%42 = tail call i32 @exit(i32 1)
unreachable
43: ; preds = %37
%44 = icmp eq i64 %22, 0
br i1 %44, label %45, label %49
45: ; preds = %43
%46 = load i32, i32* @stderr
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%48 = tail call i32 @exit(i32 1)
unreachable
49: ; preds = %43
%50 = icmp eq i64 %24, 0
br i1 %50, label %51, label %55
51: ; preds = %49
%52 = load i32, i32* @stderr
%53 = tail call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%54 = tail call i32 @exit(i32 1)
unreachable
55: ; preds = %49
%56 = tail call i32 @srand48(i32 0)
%57 = icmp sgt i32 %0, 0
br i1 %57, label %58, label %88
58: ; preds = %55
%59 = zext i32 %0 to i64
%60 = zext i32 %0 to i64
br label %64
61: ; preds = %79
br i1 %57, label %62, label %88
62: ; preds = %61
%63 = zext i32 %0 to i64
br label %82
64: ; preds = %79, %58
%65 = phi i64 [ 0, %58 ], [ %80, %79 ]
%66 = trunc i64 %65 to i32
%67 = mul nsw i64 %65, %59
%68 = mul nsw i32 %66, %0
%69 = sext i32 %68 to i64
%70 = add nsw i64 %65, %69
%71 = getelementptr inbounds double, double* %17, i64 %70
store double 1.000000e+00, double* %71
br label %72
72: ; preds = %64, %72
%73 = phi i64 [ 0, %64 ], [ %77, %72 ]
%74 = tail call double (...) @drand48()
%75 = add nuw nsw i64 %73, %67
%76 = getelementptr inbounds double, double* %17, i64 %75
store double %74, double* %76
%77 = add nuw nsw i64 %73, 1
%78 = icmp eq i64 %77, %60
br i1 %78, label %79, label %72
79: ; preds = %72
%80 = add nuw nsw i64 %65, 1
%81 = icmp eq i64 %80, %60
br i1 %81, label %61, label %64
82: ; preds = %62, %82
%83 = phi i64 [ 0, %62 ], [ %86, %82 ]
%84 = tail call double (...) @drand48()
%85 = getelementptr inbounds double, double* %19, i64 %83
store double %84, double* %85
%86 = add nuw nsw i64 %83, 1
%87 = icmp eq i64 %86, %63
br i1 %87, label %88, label %82
88: ; preds = %82, %55, %61
%89 = bitcast i32* %5 to i8*
store i32 1, i32* %5
%90 = bitcast i32* %6 to i8*
%91 = mul nsw i32 %0, %0
store i32 %91, i32* %6
%92 = call i32 @dcopy_(i32* %6, double* %17, i32* %5, double* %21, i32* %5)
%93 = call double (...) @ptime_ms_d()
%94 = call i32 @lapack_inv_(i32 %0, double* %21)
%95 = call i32 @dot_prod_matrix(double* %21, i32 %0, i32 %0, double* %19, double* %23)
%96 = call double (...) @ptime_ms_d()
%97 = call i32 @lapack_solve_lin(i32 %0, double* %17, double* %19, double* %25)
%98 = call double (...) @ptime_ms_d()
%99 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
br i1 %57, label %100, label %116
100: ; preds = %88
%101 = zext i32 %0 to i64
br label %102
102: ; preds = %100, %102
%103 = phi i64 [ 0, %100 ], [ %114, %102 ]
%104 = phi i32 [ 0, %100 ], [ %113, %102 ]
%105 = trunc i64 %103 to i32
%106 = call i32 @sprintf(i8* %99, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 %105)
%107 = getelementptr inbounds double, double* %23, i64 %103
%108 = load double, double* %107
%109 = getelementptr inbounds double, double* %25, i64 %103
%110 = load double, double* %109
%111 = call i64 @compare_max(double %108, double %110, i8* %99, i32 %1, double %2, double* %4)
%112 = trunc i64 %111 to i32
%113 = add i32 %104, %112
%114 = add nuw nsw i64 %103, 1
%115 = icmp eq i64 %114, %101
br i1 %115, label %116, label %102
116: ; preds = %102, %88
%117 = phi i32 [ 0, %88 ], [ %113, %102 ]
%118 = call i32 @free(double* %17)
%119 = call i32 @free(double* %19)
%120 = call i32 @free(double* %21)
%121 = call i32 @free(double* %23)
%122 = call i32 @free(double* %25)
br i1 %8, label %137, label %123
123: ; preds = %116
%124 = load i32, i32* @stdout
%125 = fsub double %96, %93
%126 = call i32 (i32, i8*, ...) @fprintf(i32 %124, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.7, i64 0, i64 0), double %125)
%127 = load i32, i32* @stdout
%128 = fsub double %98, %96
%129 = call i32 (i32, i8*, ...) @fprintf(i32 %127, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.8, i64 0, i64 0), double %128)
%130 = load i32, i32* @stdout
%131 = load double, double* %4
%132 = call i32 (i32, i8*, ...) @fprintf(i32 %130, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.9, i64 0, i64 0), double %131, double %2)
%133 = icmp eq i32 %117, 0
%134 = load i32, i32* @stdout
%135 = select i1 %133, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0)
%136 = call i32 (i32, i8*, ...) @fprintf(i32 %134, i8* %135)
br label %137
137: ; preds = %123, %116
ret i32 %117
}