#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*/ free(double *);
double *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ relax_pinvb(double *, int, int, int, double *, int, double *,
                               double *, double *, double *);
int /*<<< orphan*/ relax_pinvtb(double *, int, int, int, double *, int,
                                double *, double *, double *, double *);
int relax_svd(double *, int, int, int, double *, int, double *, double *);
int direct_svd(double *A, int m, int n, int stride, double *b, double *x0) {
  double *U, *V, *w, *tmpvec;
  int ustride, vstride;
  int err;
  if (m >= n) {
    int i, j;
    ustride = n;
    vstride = n;
    U = malloc(m * ustride * sizeof U[0]);
    V = malloc(n * vstride * sizeof V[0]);
    w = malloc(n * sizeof w[0]);
    tmpvec = malloc(m * sizeof tmpvec[0]);
    for (i = 0; i < m; i++) {
      for (j = 0; j < n; j++)
        U[i * ustride + j] = A[i * stride + j];
      for (; j < ustride; j++)
        U[i * ustride + j] = 0.0;
    }
    err = relax_svd(U, m, n, ustride, V, vstride, w, tmpvec);
    relax_pinvb(U, m, n, ustride, V, vstride, w, b, x0, tmpvec);
    free(U);
    free(V);
    free(w);
    free(tmpvec);
  } else {
    int i, j;
    i = m;
    m = n;
    n = i;
    ustride = n;
    vstride = n;
    U = malloc(m * ustride * sizeof U[0]);
    V = malloc(n * vstride * sizeof V[0]);
    w = malloc(n * sizeof w[0]);
    tmpvec = malloc(m * sizeof tmpvec[0]);
    for (i = 0; i < m; i++) {
      for (j = 0; j < n; j++)
        U[i * ustride + j] = A[j * stride + i];
      for (; j < ustride; j++)
        U[i * ustride + j] = 0.0;
    }
    err = relax_svd(U, m, n, ustride, V, vstride, w, tmpvec);
    relax_pinvtb(U, m, n, ustride, V, vstride, w, b, x0, tmpvec);
    free(U);
    free(V);
    free(w);
    free(tmpvec);
  }
  printf(" iter %7d", -1);
  return err;
}


x86 assembly (clang, -O0):
<direct_svd>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x88,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jl     132e <direct_svd+0x1ce>
mov    -0x18(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x54(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x58(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x48(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    129a <direct_svd+0x13a>
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    124f <direct_svd+0xef>
mov    -0x10(%rbp),%rax
mov    -0x60(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
add    -0x64(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
mov    -0x60(%rbp),%ecx
imul   -0x54(%rbp),%ecx
add    -0x64(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1209 <direct_svd+0xa9>
jmp    1254 <direct_svd+0xf4>
mov    -0x64(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    1287 <direct_svd+0x127>
mov    -0x38(%rbp),%rax
mov    -0x60(%rbp),%ecx
imul   -0x54(%rbp),%ecx
add    -0x64(%rbp),%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1254 <direct_svd+0xf4>
jmp    128c <direct_svd+0x12c>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    11f6 <direct_svd+0x96>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x54(%rbp),%ecx
mov    -0x40(%rbp),%r8
mov    -0x58(%rbp),%r9d
mov    -0x48(%rbp),%r10
mov    -0x50(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1060 <relax_svd@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x54(%rbp),%ecx
mov    -0x40(%rbp),%r8
mov    -0x58(%rbp),%r9d
mov    -0x48(%rbp),%rbx
mov    -0x28(%rbp),%r11
mov    -0x30(%rbp),%r10
mov    -0x50(%rbp),%rax
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1050 <relax_pinvb@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
jmp    14dc <direct_svd+0x37c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x68(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x54(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x58(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x48(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    144d <direct_svd+0x2ed>
movl   $0x0,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1402 <direct_svd+0x2a2>
mov    -0x10(%rbp),%rax
mov    -0x6c(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
add    -0x68(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
mov    -0x68(%rbp),%ecx
imul   -0x54(%rbp),%ecx
add    -0x6c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    13bc <direct_svd+0x25c>
jmp    1407 <direct_svd+0x2a7>
mov    -0x6c(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    143a <direct_svd+0x2da>
mov    -0x38(%rbp),%rax
mov    -0x68(%rbp),%ecx
imul   -0x54(%rbp),%ecx
add    -0x6c(%rbp),%ecx
movslq %ecx,%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    1407 <direct_svd+0x2a7>
jmp    143f <direct_svd+0x2df>
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    13a9 <direct_svd+0x249>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x54(%rbp),%ecx
mov    -0x40(%rbp),%r8
mov    -0x58(%rbp),%r9d
mov    -0x48(%rbp),%r10
mov    -0x50(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1060 <relax_svd@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x54(%rbp),%ecx
mov    -0x40(%rbp),%r8
mov    -0x58(%rbp),%r9d
mov    -0x48(%rbp),%rbx
mov    -0x28(%rbp),%r11
mov    -0x30(%rbp),%r10
mov    -0x50(%rbp),%rax
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1080 <relax_pinvtb@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
lea    0xb1d(%rip),%rdi
mov    $0xffffffff,%esi
call   1040 <printf@plt>
mov    -0x5c(%rbp),%eax
add    $0x88,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<direct_svd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r9,%r15
mov    %r8,%r14
mov    %rcx,0x8(%rsp)
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,0x18(%rsp)
mov    %edx,%edi
imul   %esi,%edi
shl    $0x3,%edi
call   1080 <malloc@plt>
mov    %rbx,%rcx
cmp    %ecx,%ebp
mov    %rax,(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r14,0x58(%rsp)
mov    %r15,0x50(%rsp)
jge    1419 <direct_svd+0x2a9>
lea    0x0(,%rbp,8),%ebx
mov    %ebx,%edi
mov    %rbp,0x28(%rsp)
imul   %ebp,%edi
mov    %rcx,%rbp
call   1080 <malloc@plt>
mov    %rax,0x30(%rsp)
mov    %ebx,%edi
call   1080 <malloc@plt>
mov    %rax,0x40(%rsp)
lea    0x0(,%rbp,8),%edi
call   1080 <malloc@plt>
mov    %rax,0x38(%rsp)
test   %ebp,%ebp
jle    152c <direct_svd+0x3bc>
mov    0x8(%rsp),%rcx
movslq %ecx,%r10
mov    0x28(%rsp),%rax
movslq %eax,%rdx
mov    0x10(%rsp),%esi
mov    %rsi,0x20(%rsp)
mov    %eax,%esi
mov    %esi,%edi
and    $0xfffffffc,%edi
mov    %rdi,0x78(%rsp)
add    $0xfffffffffffffffc,%rdi
mov    %rdi,0x70(%rsp)
shr    $0x2,%rdi
add    $0x1,%rdi
cmp    $0x4,%eax
setae  %al
cmp    $0x1,%ecx
sete   %cl
and    %al,%cl
mov    %cl,0x8(%rsp)
mov    %rdi,%rax
mov    %rdi,0x68(%rsp)
and    $0xfffffffffffffffe,%rdi
mov    %rdi,0x60(%rsp)
mov    %rsi,%rax
neg    %rax
mov    %rax,0x80(%rsp)
mov    %r10,%rax
shl    $0x5,%rax
mov    0x18(%rsp),%rdi
lea    0x10(%rdi),%r9
mov    %r10,%r14
shl    $0x6,%r14
mov    %r10,%r8
shl    $0x4,%r8
mov    (%rsp),%rcx
mov    %rcx,%r13
add    $0x8,%r13
lea    0x30(%rcx),%r11
mov    %rdx,0x48(%rsp)
lea    0x0(,%rdx,8),%r15
xor    %r12d,%r12d
jmp    12cd <direct_svd+0x15d>
nopl   0x0(%rax)
add    $0x1,%r12
add    $0x8,%r9
add    %r15,%r11
add    $0x8,%rdi
add    %r15,%r13
cmp    0x20(%rsp),%r12
je     152c <direct_svd+0x3bc>
cmpl   $0x0,0x28(%rsp)
jle    12b0 <direct_svd+0x140>
mov    %r12,%rbx
imul   0x48(%rsp),%rbx
cmpb   $0x0,0x8(%rsp)
je     1340 <direct_svd+0x1d0>
mov    %r10,%rcx
cmpq   $0x0,0x70(%rsp)
je     1344 <direct_svd+0x1d4>
mov    0x60(%rsp),%rdx
mov    %r9,%r10
xor    %ebp,%ebp
nopl   0x0(%rax)
movups -0x10(%r10),%xmm0
movups (%r10),%xmm1
movups %xmm0,-0x30(%r11,%rbp,8)
movups %xmm1,-0x20(%r11,%rbp,8)
movups -0x10(%r10,%rax,1),%xmm0
movups (%r10,%rax,1),%xmm1
movups %xmm0,-0x10(%r11,%rbp,8)
movups %xmm1,(%r11,%rbp,8)
add    $0x8,%rbp
add    %r14,%r10
add    $0xfffffffffffffffe,%rdx
jne    1300 <direct_svd+0x190>
jmp    1346 <direct_svd+0x1d6>
nopw   0x0(%rax,%rax,1)
xor    %edx,%edx
jmp    1389 <direct_svd+0x219>
xor    %ebp,%ebp
testb  $0x1,0x68(%rsp)
mov    %rcx,%r10
je     1378 <direct_svd+0x208>
mov    %rbp,%rcx
imul   %r10,%rcx
add    %r12,%rcx
mov    0x18(%rsp),%rdx
movups (%rdx,%rcx,8),%xmm0
movups 0x10(%rdx,%rcx,8),%xmm1
add    %rbx,%rbp
mov    (%rsp),%rcx
movups %xmm0,(%rcx,%rbp,8)
movups %xmm1,0x10(%rcx,%rbp,8)
mov    0x78(%rsp),%rcx
mov    %rcx,%rdx
cmp    %rsi,%rcx
je     12b0 <direct_svd+0x140>
mov    %rdx,%rbp
test   $0x1,%sil
je     13ba <direct_svd+0x24a>
mov    %rdx,%rcx
imul   %r10,%rcx
add    %r12,%rcx
mov    0x18(%rsp),%rbp
movsd  0x0(%rbp,%rcx,8),%xmm0
add    %rdx,%rbx
mov    (%rsp),%rcx
movsd  %xmm0,(%rcx,%rbx,8)
mov    %rdx,%rbp
or     $0x1,%rbp
not    %rdx
cmp    0x80(%rsp),%rdx
je     12b0 <direct_svd+0x140>
lea    0x1(%rbp),%rcx
imul   %r10,%rcx
lea    (%rdi,%rcx,8),%rdx
mov    %r10,%rcx
imul   %rbp,%rcx
lea    (%rdi,%rcx,8),%rbx
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%rbx,%rcx,1),%xmm0
movsd  %xmm0,-0x8(%r13,%rbp,8)
movsd  (%rdx,%rcx,1),%xmm0
movsd  %xmm0,0x0(%r13,%rbp,8)
add    $0x2,%rbp
add    %r8,%rcx
cmp    %rbp,%rsi
jne    13f0 <direct_svd+0x280>
jmp    12b0 <direct_svd+0x140>
mov    %rax,%r12
lea    0x0(,%rcx,8),%ebx
mov    %ebx,%edi
imul   %ecx,%edi
call   1080 <malloc@plt>
mov    %rax,%r13
mov    %ebx,%edi
call   1080 <malloc@plt>
mov    %rax,0x40(%rsp)
lea    0x0(,%rbp,8),%edi
call   1080 <malloc@plt>
mov    0x10(%rsp),%rcx
mov    %rax,0x38(%rsp)
test   %ebp,%ebp
jle    15d3 <direct_svd+0x463>
mov    %ecx,%eax
shl    $0x3,%rax
mov    %rax,0x20(%rsp)
mov    %ebp,%edx
xor    %ebx,%ebx
cmp    $0x1,%ebp
je     159c <direct_svd+0x42c>
mov    %rbp,0x28(%rsp)
mov    %r13,0x30(%rsp)
lea    (%rcx,%rcx,1),%eax
mov    %eax,0x48(%rsp)
mov    0x8(%rsp),%rax
lea    (%rax,%rax,1),%ebp
mov    %edx,%r12d
and    $0xfffffffe,%r12d
neg    %r12
xor    %ebx,%ebx
xor    %r14d,%r14d
xor    %r15d,%r15d
mov    %rdx,%r13
jmp    14c5 <direct_svd+0x355>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    0x48(%rsp),%r15d
add    %ebp,%r14d
add    $0xfffffffffffffffe,%rbx
cmp    %rbx,%r12
je     158c <direct_svd+0x41c>
test   %ecx,%ecx
jle    14f2 <direct_svd+0x382>
movslq %r14d,%rax
mov    0x18(%rsp),%rcx
lea    (%rcx,%rax,8),%rsi
movslq %r15d,%rax
mov    (%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    0x20(%rsp),%rdx
call   1060 <memcpy@plt>
mov    %r13,%rdx
mov    0x10(%rsp),%rcx
test   %ecx,%ecx
jle    14b0 <direct_svd+0x340>
lea    (%rcx,%r15,1),%eax
mov    0x8(%rsp),%rcx
add    %r14d,%ecx
movslq %ecx,%rcx
mov    0x18(%rsp),%rdx
lea    (%rdx,%rcx,8),%rsi
cltq
mov    (%rsp),%rcx
lea    (%rcx,%rax,8),%rdi
mov    0x20(%rsp),%rdx
call   1060 <memcpy@plt>
mov    %r13,%rdx
mov    0x10(%rsp),%rcx
jmp    14b0 <direct_svd+0x340>
mov    (%rsp),%r12
mov    %r12,%rdi
mov    0x10(%rsp),%r14
mov    %r14d,%esi
mov    0x28(%rsp),%rbp
mov    %ebp,%edx
mov    %ebp,%ecx
mov    0x30(%rsp),%r13
mov    %r13,%r8
mov    %ebp,%r9d
mov    0x38(%rsp),%r15
push   %r15
mov    0x48(%rsp),%rbx
push   %rbx
call   1070 <relax_svd@plt>
add    $0x10,%rsp
mov    %r12,%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %ebp,%ecx
mov    %r13,%r8
mov    %ebp,%r9d
mov    %eax,%ebp
push   %r15
push   0x58(%rsp)
push   0x68(%rsp)
push   %rbx
call   1090 <relax_pinvtb@plt>
jmp    161d <direct_svd+0x4ad>
neg    %ebx
mov    (%rsp),%r12
mov    0x30(%rsp),%r13
mov    0x28(%rsp),%rbp
test   $0x1,%dl
je     15d3 <direct_svd+0x463>
test   %ecx,%ecx
jle    15d3 <direct_svd+0x463>
mov    %ebx,%eax
imul   %ecx,%eax
mov    0x8(%rsp),%rcx
imul   %ebx,%ecx
movslq %ecx,%rcx
mov    0x18(%rsp),%rdx
lea    (%rdx,%rcx,8),%rsi
cltq
lea    (%r12,%rax,8),%rdi
mov    0x20(%rsp),%rdx
call   1060 <memcpy@plt>
mov    0x10(%rsp),%rcx
mov    %r12,%rdi
mov    %ebp,%esi
mov    %rcx,%r14
mov    %r14d,%edx
mov    %r13,%r8
mov    %r14d,%r9d
mov    0x38(%rsp),%r15
push   %r15
mov    0x48(%rsp),%rbx
push   %rbx
call   1070 <relax_svd@plt>
add    $0x10,%rsp
mov    %r12,%rdi
mov    %ebp,%esi
mov    %eax,%ebp
mov    %r14d,%edx
mov    %r14d,%ecx
mov    %r13,%r8
mov    %r14d,%r9d
push   %r15
push   0x58(%rsp)
push   0x68(%rsp)
push   %rbx
call   1050 <relax_pinvb@plt>
add    $0x20,%rsp
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
lea    0x9b8(%rip),%rdi
mov    $0xffffffff,%esi
call   1040 <printf@plt>
mov    %ebp,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c" iter %7d\00"
define i32 @direct_svd(double* nocapture %0, i32 %1, i32 %2, i32 %3, double* %4, double* %5) {
%7 = icmp slt i32 %1, %2
%8 = mul nsw i32 %2, %1
%9 = shl i32 %8, 3
%10 = tail call double* @malloc(i32 %9)
br i1 %7, label %76, label %11
11: ; preds = %6
%12 = shl i32 %2, 3
%13 = mul i32 %12, %2
%14 = tail call double* @malloc(i32 %13)
%15 = tail call double* @malloc(i32 %12)
%16 = shl i32 %1, 3
%17 = tail call double* @malloc(i32 %16)
%18 = icmp sgt i32 %1, 0
br i1 %18, label %19, label %73
19: ; preds = %11
%20 = icmp sgt i32 %2, 0
%21 = zext i32 %2 to i64
%22 = shl nuw nsw i64 %21, 3
%23 = zext i32 %1 to i64
%24 = and i64 %23, 1
%25 = icmp eq i32 %1, 1
br i1 %25, label %59, label %26
26: ; preds = %19
%27 = and i64 %23, 4294967294
br label %28
28: ; preds = %53, %26
%29 = phi i64 [ 0, %26 ], [ %54, %53 ]
%30 = phi i64 [ 0, %26 ], [ %55, %53 ]
%31 = trunc i64 %29 to i32
br i1 %20, label %32, label %41
32: ; preds = %28
%33 = mul i32 %31, %2
%34 = mul i32 %31, %3
%35 = sext i32 %34 to i64
%36 = getelementptr double, double* %0, i64 %35
%37 = bitcast double* %36 to i8*
%38 = sext i32 %33 to i64
%39 = getelementptr double, double* %10, i64 %38
%40 = bitcast double* %39 to i8*
br label %41
41: ; preds = %28, %32
%42 = trunc i64 %29 to i32
%43 = or i32 %42, 1
br i1 %20, label %44, label %53
44: ; preds = %41
%45 = mul i32 %43, %2
%46 = mul i32 %43, %3
%47 = sext i32 %46 to i64
%48 = getelementptr double, double* %0, i64 %47
%49 = bitcast double* %48 to i8*
%50 = sext i32 %45 to i64
%51 = getelementptr double, double* %10, i64 %50
%52 = bitcast double* %51 to i8*
br label %53
53: ; preds = %44, %41
%54 = add nuw nsw i64 %29, 2
%55 = add i64 %30, 2
%56 = icmp eq i64 %55, %27
br i1 %56, label %57, label %28
57: ; preds = %53
%58 = trunc i64 %54 to i32
br label %59
59: ; preds = %57, %19
%60 = phi i32 [ 0, %19 ], [ %58, %57 ]
%61 = icmp eq i64 %24, 0
%62 = xor i1 %20, true
%63 = or i1 %61, %62
br i1 %63, label %73, label %64
64: ; preds = %59
%65 = mul i32 %60, %2
%66 = mul i32 %60, %3
%67 = sext i32 %66 to i64
%68 = getelementptr double, double* %0, i64 %67
%69 = bitcast double* %68 to i8*
%70 = sext i32 %65 to i64
%71 = getelementptr double, double* %10, i64 %70
%72 = bitcast double* %71 to i8*
br label %73
73: ; preds = %59, %64, %11
%74 = tail call i32 @relax_svd(double* %10, i32 %1, i32 %2, i32 %2, double* %14, i32 %2, double* %15, double* %17)
%75 = tail call i32 @relax_pinvb(double* %10, i32 %1, i32 %2, i32 %2, double* %14, i32 %2, double* %15, double* %4, double* %5, double* %17)
br label %198
76: ; preds = %6
%77 = shl i32 %1, 3
%78 = mul i32 %77, %1
%79 = tail call double* @malloc(i32 %78)
%80 = tail call double* @malloc(i32 %77)
%81 = shl i32 %2, 3
%82 = tail call double* @malloc(i32 %81)
%83 = icmp sgt i32 %2, 0
br i1 %83, label %84, label %195
84: ; preds = %76
%85 = icmp sgt i32 %1, 0
%86 = sext i32 %3 to i64
%87 = sext i32 %1 to i64
%88 = zext i32 %2 to i64
%89 = zext i32 %1 to i64
%90 = and i64 %89, 4294967292
%91 = add nsw i64 %90, -4
%92 = lshr exact i64 %91, 2
%93 = add nuw nsw i64 %92, 1
%94 = icmp ugt i32 %1, 3
%95 = icmp eq i32 %3, 1
%96 = and i1 %94, %95
%97 = and i64 %89, 4294967292
%98 = and i64 %93, 1
%99 = icmp eq i64 %91, 0
%100 = and i64 %93, 9223372036854775806
%101 = icmp eq i64 %98, 0
%102 = icmp eq i64 %97, %89
%103 = and i64 %89, 1
%104 = icmp eq i64 %103, 0
%105 = sub nsw i64 0, %89
br label %106
106: ; preds = %84, %192
%107 = phi i64 [ 0, %84 ], [ %193, %192 ]
br i1 %85, label %108, label %192
108: ; preds = %106
%109 = mul nsw i64 %107, %87
br i1 %96, label %110, label %161
110: ; preds = %108
br i1 %99, label %144, label %111
111: ; preds = %110, %111
%112 = phi i64 [ %141, %111 ], [ 0, %110 ]
%113 = phi i64 [ %142, %111 ], [ 0, %110 ]
%114 = mul nsw i64 %112, %86
%115 = add nsw i64 %114, %107
%116 = getelementptr inbounds double, double* %0, i64 %115
%117 = bitcast double* %116 to <2 x double>*
%118 = load <2 x double>, <2 x double>* %117
%119 = getelementptr inbounds double, double* %116, i64 2
%120 = bitcast double* %119 to <2 x double>*
%121 = load <2 x double>, <2 x double>* %120
%122 = add nsw i64 %112, %109
%123 = getelementptr inbounds double, double* %10, i64 %122
%124 = bitcast double* %123 to <2 x double>*
store <2 x double> %118, <2 x double>* %124
%125 = getelementptr inbounds double, double* %123, i64 2
%126 = bitcast double* %125 to <2 x double>*
store <2 x double> %121, <2 x double>* %126
%127 = or i64 %112, 4
%128 = mul nsw i64 %127, %86
%129 = add nsw i64 %128, %107
%130 = getelementptr inbounds double, double* %0, i64 %129
%131 = bitcast double* %130 to <2 x double>*
%132 = load <2 x double>, <2 x double>* %131
%133 = getelementptr inbounds double, double* %130, i64 2
%134 = bitcast double* %133 to <2 x double>*
%135 = load <2 x double>, <2 x double>* %134
%136 = add nsw i64 %127, %109
%137 = getelementptr inbounds double, double* %10, i64 %136
%138 = bitcast double* %137 to <2 x double>*
store <2 x double> %132, <2 x double>* %138
%139 = getelementptr inbounds double, double* %137, i64 2
%140 = bitcast double* %139 to <2 x double>*
store <2 x double> %135, <2 x double>* %140
%141 = add nuw i64 %112, 8
%142 = add i64 %113, 2
%143 = icmp eq i64 %142, %100
br i1 %143, label %144, label %111
144: ; preds = %111, %110
%145 = phi i64 [ 0, %110 ], [ %141, %111 ]
br i1 %101, label %160, label %146
146: ; preds = %144
%147 = mul nsw i64 %145, %86
%148 = add nsw i64 %147, %107
%149 = getelementptr inbounds double, double* %0, i64 %148
%150 = bitcast double* %149 to <2 x double>*
%151 = load <2 x double>, <2 x double>* %150
%152 = getelementptr inbounds double, double* %149, i64 2
%153 = bitcast double* %152 to <2 x double>*
%154 = load <2 x double>, <2 x double>* %153
%155 = add nsw i64 %145, %109
%156 = getelementptr inbounds double, double* %10, i64 %155
%157 = bitcast double* %156 to <2 x double>*
store <2 x double> %151, <2 x double>* %157
%158 = getelementptr inbounds double, double* %156, i64 2
%159 = bitcast double* %158 to <2 x double>*
store <2 x double> %154, <2 x double>* %159
br label %160
160: ; preds = %144, %146
br i1 %102, label %192, label %161
161: ; preds = %108, %160
%162 = phi i64 [ 0, %108 ], [ %97, %160 ]
%163 = xor i64 %162, -1
br i1 %104, label %172, label %164
164: ; preds = %161
%165 = mul nsw i64 %162, %86
%166 = add nsw i64 %165, %107
%167 = getelementptr inbounds double, double* %0, i64 %166
%168 = load double, double* %167
%169 = add nsw i64 %162, %109
%170 = getelementptr inbounds double, double* %10, i64 %169
store double %168, double* %170
%171 = or i64 %162, 1
br label %172
172: ; preds = %164, %161
%173 = phi i64 [ %162, %161 ], [ %171, %164 ]
%174 = icmp eq i64 %163, %105
br i1 %174, label %192, label %175
175: ; preds = %172, %175
%176 = phi i64 [ %190, %175 ], [ %173, %172 ]
%177 = mul nsw i64 %176, %86
%178 = add nsw i64 %177, %107
%179 = getelementptr inbounds double, double* %0, i64 %178
%180 = load double, double* %179
%181 = add nsw i64 %176, %109
%182 = getelementptr inbounds double, double* %10, i64 %181
store double %180, double* %182
%183 = add nuw nsw i64 %176, 1
%184 = mul nsw i64 %183, %86
%185 = add nsw i64 %184, %107
%186 = getelementptr inbounds double, double* %0, i64 %185
%187 = load double, double* %186
%188 = add nsw i64 %183, %109
%189 = getelementptr inbounds double, double* %10, i64 %188
store double %187, double* %189
%190 = add nuw nsw i64 %176, 2
%191 = icmp eq i64 %190, %89
br i1 %191, label %192, label %175
192: ; preds = %172, %175, %160, %106
%193 = add nuw nsw i64 %107, 1
%194 = icmp eq i64 %193, %88
br i1 %194, label %195, label %106
195: ; preds = %192, %76
%196 = tail call i32 @relax_svd(double* %10, i32 %2, i32 %1, i32 %1, double* %79, i32 %1, double* %80, double* %82)
%197 = tail call i32 @relax_pinvtb(double* %10, i32 %2, i32 %1, i32 %1, double* %79, i32 %1, double* %80, double* %4, double* %5, double* %82)
br label %198
198: ; preds = %195, %73
%199 = phi double* [ %79, %195 ], [ %14, %73 ]
%200 = phi double* [ %80, %195 ], [ %15, %73 ]
%201 = phi double* [ %82, %195 ], [ %17, %73 ]
%202 = phi i32 [ %196, %195 ], [ %74, %73 ]
%203 = tail call i32 @free(double* %10)
%204 = tail call i32 @free(double* %199)
%205 = tail call i32 @free(double* %200)
%206 = tail call i32 @free(double* %201)
%207 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 -1)
ret i32 %202
}