#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*/ MatrixPinv(double *, int, int, double, double *);
int /*<<< orphan*/ printf(char *, ...);
void test_MatrixPinv() {
  double a[4][3] = {1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 15};
  double b[4][3];
  double tol = 2.22e-15;
  MatrixPinv((double *)a, 4, 3, tol, (double *)b);
  printf("MatrixPinv(a):\n");
  int i, j;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 3; j++) {
      printf("%lf  ", b[i][j]);
    }
    printf("\n");
  }
  return;
}


x86 assembly (clang, -O0):
<test_MatrixPinv>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
lea    -0x60(%rbp),%rdi
lea    0xeca(%rip),%rsi
mov    $0x60,%edx
call   1040 <memcpy@plt>
movsd  0xea8(%rip),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
lea    -0x60(%rbp),%rdi
movsd  -0xc8(%rbp),%xmm0
ff
lea    -0xc0(%rbp),%rcx
mov    $0x4,%esi
mov    $0x3,%edx
call   1050 <MatrixPinv@plt>
lea    0xee7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xcc(%rbp)
cmpl   $0x4,-0xcc(%rbp)
jge    1223 <test_MatrixPinv+0xf3>
movl   $0x0,-0xd0(%rbp)
cmpl   $0x3,-0xd0(%rbp)
jge    1201 <test_MatrixPinv+0xd1>
movslq -0xcc(%rbp),%rcx
lea    -0xc0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0xd0(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe9a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0xd0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd0(%rbp)
jmp    11b1 <test_MatrixPinv+0x81>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xcc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xcc(%rbp)
jmp    119a <test_MatrixPinv+0x6a>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_MatrixPinv>:
push   %rbx
sub    $0xc0,%rsp
movaps 0xf11(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xef2(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xed3(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe95(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe79(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
lea    0x60(%rsp),%rdi
movsd  0xe57(%rip),%xmm0
mov    %rsp,%rcx
mov    $0x4,%esi
mov    $0x3,%edx
call   1060 <MatrixPinv@plt>
lea    0xeb4(%rip),%rdi
call   1040 <puts@plt>
movsd  (%rsp),%xmm0
lea    0xe9d(%rip),%rbx
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>
movsd  0x18(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
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>
mov    $0xa,%edi
call   1030 <putchar@plt>
movsd  0x30(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x38(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x40(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@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>
movsd  0x58(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xc0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.test_MatrixPinv.a = [4 x [3 x double]] [[3 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00], [3 x double] [double 5.000000e+00, double 6.000000e+00, double 7.000000e+00], [3 x double] [double 9.000000e+00, double 1.000000e+01, double 1.100000e+01], [3 x double] [double 1.300000e+01, double 1.400000e+01, double 1.500000e+01]]
@.str = [16 x i8] c"MatrixPinv(a):\0A\00"
@.str.1 = [6 x i8] c"%lf \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @test_MatrixPinv() {
%1 = alloca [4 x [3 x double]]
%2 = alloca [4 x [3 x double]]
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = bitcast [4 x [3 x double]]* %1 to i8*
store double 2.220000e-15, double* %3
%7 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %1, i64 0, i64 0
%8 = bitcast [3 x double]* %7 to double*
%9 = load double, double* %3
%10 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %2, i64 0, i64 0
%11 = bitcast [3 x double]* %10 to double*
%12 = call i32 @MatrixPinv(double* %8, i32 4, i32 3, double %9, double* %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %14
14: ; preds = %35, %0
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 4
br i1 %16, label %17, label %38
17: ; preds = %14
store i32 0, i32* %5
br label %18
18: ; preds = %30, %17
%19 = load i32, i32* %5
%20 = icmp slt i32 %19, 3
br i1 %20, label %21, label %33
21: ; preds = %18
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %2, i64 0, i64 %23
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [3 x double], [3 x double]* %24, i64 0, i64 %26
%28 = load double, double* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %28)
br label %30
30: ; preds = %21
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %18
33: ; preds = %18
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %33
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %14
38: ; preds = %14
ret void
}

LLVM IR (-O2):
@__const.test_MatrixPinv.a = [4 x [3 x double]] [[3 x double] [double 1.000000e+00, double 2.000000e+00, double 3.000000e+00], [3 x double] [double 5.000000e+00, double 6.000000e+00, double 7.000000e+00], [3 x double] [double 9.000000e+00, double 1.000000e+01, double 1.100000e+01], [3 x double] [double 1.300000e+01, double 1.400000e+01, double 1.500000e+01]]
@.str.1 = [6 x i8] c"%lf \00"
@str = [15 x i8] c"MatrixPinv(a):\00"
define void @test_MatrixPinv() {
%1 = alloca [4 x [3 x double]]
%2 = alloca [4 x [3 x double]]
%3 = bitcast [4 x [3 x double]]* %1 to i8*
%4 = bitcast [4 x [3 x double]]* %2 to i8*
%5 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %1, i64 0, i64 0, i64 0
%6 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %2, i64 0, i64 0, i64 0
%7 = call i32 @MatrixPinv(double* %5, i32 4, i32 3, double 2.220000e-15, double* %6)
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%9 = load double, double* %6
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %9)
%11 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %2, i64 0, i64 0, i64 1
%12 = load double, double* %11
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %12)
%14 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %2, i64 0, i64 0, i64 2
%15 = load double, double* %14
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %15)
%17 = call i32 @putchar(i32 10)
%18 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %2, i64 0, i64 1, i64 0
%19 = load double, double* %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %19)
%21 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %2, i64 0, i64 1, i64 1
%22 = load double, double* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %22)
%24 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %2, i64 0, i64 1, i64 2
%25 = load double, double* %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %25)
%27 = call i32 @putchar(i32 10)
%28 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %2, i64 0, i64 2, i64 0
%29 = load double, double* %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %29)
%31 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %2, i64 0, i64 2, i64 1
%32 = load double, double* %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %32)
%34 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %2, i64 0, i64 2, i64 2
%35 = load double, double* %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %35)
%37 = call i32 @putchar(i32 10)
%38 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %2, i64 0, i64 3, i64 0
%39 = load double, double* %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %39)
%41 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %2, i64 0, i64 3, i64 1
%42 = load double, double* %41
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %42)
%44 = getelementptr inbounds [4 x [3 x double]], [4 x [3 x double]]* %2, i64 0, i64 3, i64 2
%45 = load double, double* %44
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %45)
%47 = call i32 @putchar(i32 10)
ret void
}