#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(float *);
scalar_t__ malloc(int);
int /*<<< orphan*/ sgesvd_(char *, char *, int *, int *, float *, int *,
                           float *, float *, int *, float *, int *, float *,
                           int *, int *);
int /*<<< orphan*/ stderr;
int slevmar_pseudoinverse(float *A, float *B, int m) {
  float *buf = NULL;
  int buf_sz = 0;
  static float eps = -1.0F;
  register int i, j;
  float *a, *u, *s, *vt, *work;
  int a_sz, u_sz, s_sz, vt_sz, tot_sz;
  float thresh, one_over_denom;
  int info, rank, worksz, *iwork, iworksz;
  worksz = 5 * m;
  iworksz = 8 * m;
  a_sz = m * m;
  u_sz = m * m;
  s_sz = m;
  vt_sz = m * m;
  tot_sz = (a_sz + u_sz + s_sz + vt_sz + worksz) * sizeof(float) +
           iworksz * sizeof(int);
  buf_sz = tot_sz;
  buf = (float *)malloc(buf_sz);
  if (!buf) {
    fprintf(stderr, "memory allocation in "
                    "slevmar_pseudoinverse"
                    "() failed!\n");
    return 0;
  }
  a = buf;
  u = a + a_sz;
  s = u + u_sz;
  vt = s + s_sz;
  work = vt + vt_sz;
  iwork = (int *)(work + worksz);
  for (i = 0; i < m; i++)
    for (j = 0; j < m; j++)
      a[i + j * m] = A[i * m + j];
  sgesvd_("A", "A", (int *)&m, (int *)&m, a, (int *)&m, s, u, (int *)&m, vt,
          (int *)&m, work, (int *)&worksz, &info);
  if (info != 0) {
    if (info < 0) {
      fprintf(stderr,
              "LAPACK error: illegal value for argument %d of "
              "sgesvd_"
              "\"/\" sgesdd_"
              " in "
              "slevmar_pseudoinverse"
              "()\n",
              -info);
    } else {
      fprintf(
          stderr,
          "LAPACK error: dgesdd (dbdsdc)/dgesvd (dbdsqr) failed to converge in "
          "slevmar_pseudoinverse"
          "() [info=%d]\n",
          info);
    }
    free(buf);
    return 0;
  }
  if (eps < 0.0) {
    float aux;
    for (eps = 1.0F; aux = eps + 1.0F, aux - 1.0F > 0.0; eps *= 0.5F)
      ;
    eps *= 2.0F;
  }
  for (i = 0; i < a_sz; i++)
    B[i] = 0.0;
  for (rank = 0, thresh = eps * s[0]; rank < m && s[rank] > thresh; rank++) {
    one_over_denom = 1.0F / s[rank];
    for (j = 0; j < m; j++)
      for (i = 0; i < m; i++)
        B[i * m + j] += vt[rank + i * m] * u[j + rank * m] * one_over_denom;
  }
  free(buf);
  return rank;
}


x86 assembly (clang, -O0):
<slevmar_pseudoinverse>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xe0,%rsp
mov    %rdi,-0x30(%rbp)
mov    %rsi,-0x38(%rbp)
mov    %edx,-0x3c(%rbp)
movq   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
imul   $0x5,-0x3c(%rbp),%eax
mov    %eax,-0xa8(%rbp)
mov    -0x3c(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0xb4(%rbp)
mov    -0x3c(%rbp),%eax
imul   -0x3c(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x3c(%rbp),%eax
imul   -0x3c(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x3c(%rbp),%eax
imul   -0x3c(%rbp),%eax
mov    %eax,-0x90(%rbp)
mov    -0x84(%rbp),%eax
add    -0x88(%rbp),%eax
add    -0x8c(%rbp),%eax
add    -0x90(%rbp),%eax
add    -0xa8(%rbp),%eax
cltq
shl    $0x2,%rax
movslq -0xb4(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %eax,-0x94(%rbp)
mov    -0x94(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%edi
call   1060 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    122d <slevmar_pseudoinverse+0xed>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
lea    0xdf2(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x24(%rbp)
jmp    1623 <slevmar_pseudoinverse+0x4e3>
mov    -0x48(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
movslq -0x84(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
movslq -0x88(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
movslq -0x8c(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
movslq -0x90(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rax
movslq -0xa8(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0xb0(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    131b <slevmar_pseudoinverse+0x1db>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1308 <slevmar_pseudoinverse+0x1c8>
mov    -0x30(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x60(%rbp),%rax
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%edx
imul   -0x3c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    12c0 <slevmar_pseudoinverse+0x180>
jmp    130d <slevmar_pseudoinverse+0x1cd>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    12ad <slevmar_pseudoinverse+0x16d>
mov    -0x60(%rbp),%r8
mov    -0x70(%rbp),%r12
mov    -0x68(%rbp),%r15
mov    -0x78(%rbp),%r14
mov    -0x80(%rbp),%r11
lea    0xd0c(%rip),%rsi
lea    -0x3c(%rbp),%rbx
lea    -0xa8(%rbp),%r10
lea    -0xa0(%rbp),%rax
mov    %rsi,%rdi
mov    %rbx,%rdx
mov    %rbx,%rcx
mov    %rbx,%r9
mov    %r12,(%rsp)
mov    %r15,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %r11,0x28(%rsp)
mov    %r10,0x30(%rsp)
mov    %rax,0x38(%rsp)
call   1050 <sgesvd_@plt>
cmpl   $0x0,-0xa0(%rbp)
je     13f0 <slevmar_pseudoinverse+0x2b0>
cmpl   $0x0,-0xa0(%rbp)
jge    13be <slevmar_pseudoinverse+0x27e>
mov    0x2c3f(%rip),%rax
mov    (%rax),%edi
xor    %edx,%edx
sub    -0xa0(%rbp),%edx
lea    0xc92(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    13db <slevmar_pseudoinverse+0x29b>
mov    0x2c1b(%rip),%rax
mov    (%rax),%edi
mov    -0xa0(%rbp),%edx
lea    0xcce(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x24(%rbp)
jmp    1623 <slevmar_pseudoinverse+0x4e3>
movss  0x2c48(%rip),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1490 <slevmar_pseudoinverse+0x350>
movss  0xbef(%rip),%xmm0
movss  %xmm0,0x2c27(%rip)
movss  0xbdf(%rip),%xmm0
addss  0x2c17(%rip),%xmm0
movss  %xmm0,-0xb8(%rbp)
ff
movss  -0xb8(%rbp),%xmm0
ff
movss  0xbbf(%rip),%xmm1
subss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1478 <slevmar_pseudoinverse+0x338>
jmp    145b <slevmar_pseudoinverse+0x31b>
movss  0xba5(%rip),%xmm0
mulss  0x2bd5(%rip),%xmm0
movss  %xmm0,0x2bcd(%rip)
jmp    1419 <slevmar_pseudoinverse+0x2d9>
movss  0xb84(%rip),%xmm0
mulss  0x2bb8(%rip),%xmm0
movss  %xmm0,0x2bb0(%rip)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x84(%rbp),%eax
jge    14c4 <slevmar_pseudoinverse+0x384>
mov    -0x38(%rbp),%rax
movslq -0x50(%rbp),%rcx
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1497 <slevmar_pseudoinverse+0x357>
movl   $0x0,-0xa4(%rbp)
movss  0x2b6a(%rip),%xmm0
mov    -0x70(%rbp),%rax
mulss  (%rax),%xmm0
movss  %xmm0,-0x98(%rbp)
ff
mov    -0xa4(%rbp),%ecx
xor    %eax,%eax
cmp    -0x3c(%rbp),%ecx
mov    %al,-0xb9(%rbp)
jge    151d <slevmar_pseudoinverse+0x3dd>
mov    -0x70(%rbp),%rax
movslq -0xa4(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
ucomiss -0x98(%rbp),%xmm0
seta   %al
mov    %al,-0xb9(%rbp)
mov    -0xb9(%rbp),%al
test   $0x1,%al
jne    1530 <slevmar_pseudoinverse+0x3f0>
jmp    1611 <slevmar_pseudoinverse+0x4d1>
mov    -0x70(%rbp),%rax
movslq -0xa4(%rbp),%rcx
movss  0xabd(%rip),%xmm0
divss  (%rax,%rcx,4),%xmm0
movss  %xmm0,-0x9c(%rbp)
ff
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    15f8 <slevmar_pseudoinverse+0x4b8>
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    15e5 <slevmar_pseudoinverse+0x4a5>
mov    -0x78(%rbp),%rax
mov    -0xa4(%rbp),%ecx
mov    -0x50(%rbp),%edx
imul   -0x3c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x68(%rbp),%rax
mov    -0x54(%rbp),%ecx
mov    -0xa4(%rbp),%edx
imul   -0x3c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
mulss  (%rax,%rcx,4),%xmm0
movss  -0x9c(%rbp),%xmm2
ff
mov    -0x38(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x54(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    156a <slevmar_pseudoinverse+0x42a>
jmp    15ea <slevmar_pseudoinverse+0x4aa>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1557 <slevmar_pseudoinverse+0x417>
jmp    15fd <slevmar_pseudoinverse+0x4bd>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    14e6 <slevmar_pseudoinverse+0x3a6>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0xa4(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<slevmar_pseudoinverse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %edx,%r13d
mov    %rsi,0x28(%rsp)
mov    %rdi,%r12
mov    %edx,0x1c(%rsp)
lea    0x0(%r13,%r13,4),%eax
mov    %eax,0x30(%rsp)
mov    %edx,%ebx
imul   %ebx,%ebx
lea    (%rbx,%r13,1),%ecx
add    %eax,%ecx
lea    (%rcx,%r13,8),%eax
lea    (%rax,%rbx,2),%edi
shl    $0x2,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     12e8 <slevmar_pseudoinverse+0x198>
mov    %rax,%r15
mov    %rbx,0x10(%rsp)
mov    %ebx,%ecx
lea    (%rax,%rcx,4),%r14
lea    (%r14,%rcx,4),%r11
movslq %r13d,%rax
mov    %rax,0x8(%rsp)
lea    (%r11,%rax,4),%rax
mov    %rax,0x40(%rsp)
mov    %rcx,0x38(%rsp)
lea    (%rax,%rcx,4),%rax
mov    %rax,0x20(%rsp)
test   %r13d,%r13d
jle    1285 <slevmar_pseudoinverse+0x135>
mov    %r13d,%r8d
mov    %r8d,%edx
and    $0xfffffffe,%edx
lea    0x4(%r12),%rsi
mov    0x8(%rsp),%rax
lea    0x0(,%rax,4),%rdi
lea    0x0(,%rax,8),%rbp
xor    %eax,%eax
mov    %r15,%r9
mov    0x8(%rsp),%r10
jmp    1220 <slevmar_pseudoinverse+0xd0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rax
add    %rdi,%rsi
add    $0x4,%r9
cmp    %r8,%rax
je     1285 <slevmar_pseudoinverse+0x135>
cmp    $0x1,%r13d
jne    1230 <slevmar_pseudoinverse+0xe0>
xor    %ebx,%ebx
jmp    1260 <slevmar_pseudoinverse+0x110>
nopw   0x0(%rax,%rax,1)
mov    %r9,%rcx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
movss  -0x4(%rsi,%rbx,4),%xmm0
movss  %xmm0,(%rcx)
movss  (%rsi,%rbx,4),%xmm0
movss  %xmm0,(%rcx,%rdi,1)
add    $0x2,%rbx
add    %rbp,%rcx
cmp    %rbx,%rdx
jne    1240 <slevmar_pseudoinverse+0xf0>
test   $0x1,%r8b
je     1210 <slevmar_pseudoinverse+0xc0>
mov    %rax,%rcx
imul   %r10,%rcx
add    %rbx,%rcx
movss  (%r12,%rcx,4),%xmm0
imul   %r10,%rbx
add    %rax,%rbx
movss  %xmm0,(%r15,%rbx,4)
jmp    1210 <slevmar_pseudoinverse+0xc0>
lea    0x34(%rsp),%rax
lea    0x30(%rsp),%rbp
lea    0x1c(%rsp),%rcx
lea    0xda3(%rip),%rdi
mov    %rdi,%rsi
mov    %rcx,%rdx
mov    %r15,%r8
mov    %rcx,%r9
push   %rax
push   %rbp
push   0x30(%rsp)
push   %rcx
mov    0x60(%rsp),%rbp
push   %rbp
push   %rcx
push   %r14
push   %r11
mov    %r11,%rbx
call   1060 <sgesvd_@plt>
add    $0x40,%rsp
mov    0x34(%rsp),%edx
test   %edx,%edx
je     1306 <slevmar_pseudoinverse+0x1b6>
mov    0x2d0c(%rip),%rax
mov    (%rax),%edi
js     14e6 <slevmar_pseudoinverse+0x396>
lea    0xdbb(%rip),%rsi
jmp    14ef <slevmar_pseudoinverse+0x39f>
mov    0x2cf1(%rip),%rax
mov    (%rax),%edi
lea    0xd10(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %eax,%eax
jmp    1518 <slevmar_pseudoinverse+0x3c8>
mov    %rbx,0x20(%rsp)
movss  0x2d35(%rip),%xmm3
xorps  %xmm0,%xmm0
ucomiss %xmm3,%xmm0
jbe    132d <slevmar_pseudoinverse+0x1dd>
movl   $0x34000000,0x2d23(%rip)
movss  0xcd3(%rip),%xmm3
cmpl   $0x0,0x10(%rsp)
je     1359 <slevmar_pseudoinverse+0x209>
mov    0x38(%rsp),%rax
lea    0x0(,%rax,4),%rdx
mov    0x28(%rsp),%rdi
xor    %esi,%esi
movss  %xmm3,0x10(%rsp)
call   1040 <memset@plt>
movss  0x10(%rsp),%xmm3
mov    0x1c(%rsp),%r10d
xor    %esi,%esi
test   %r10d,%r10d
jle    150a <slevmar_pseudoinverse+0x3ba>
mov    0x20(%rsp),%rax
movss  (%rax),%xmm2
mulss  %xmm2,%xmm3
ucomiss %xmm3,%xmm2
jbe    150a <slevmar_pseudoinverse+0x3ba>
mov    %r10d,%r13d
and    $0xfffffffe,%r13d
mov    0x28(%rsp),%rax
lea    (%rax,%r10,4),%rax
mov    %rax,0x10(%rsp)
mov    %r15,%rcx
lea    0x0(,%r10,8),%r15
mov    0x38(%rsp),%rax
mov    0x8(%rsp),%rdx
lea    (%rdx,%rax,2),%rax
add    %r10,%rax
mov    %rcx,0x8(%rsp)
lea    (%rcx,%rax,4),%r12
xor    %esi,%esi
movss  0xc41(%rip),%xmm0
mov    0x40(%rsp),%rdi
nopl   0x0(%rax,%rax,1)
movaps %xmm0,%xmm1
divss  %xmm2,%xmm1
mov    %rsi,%r9
imul   %r10,%r9
mov    0x28(%rsp),%rdx
mov    0x10(%rsp),%rax
xor    %r11d,%r11d
jmp    1405 <slevmar_pseudoinverse+0x2b5>
nopl   (%rax)
add    $0x1,%r11
add    $0x4,%rax
add    $0x4,%rdx
cmp    %r10,%r11
je     14c0 <slevmar_pseudoinverse+0x370>
lea    (%r11,%r9,1),%rbx
cmp    $0x1,%r10d
jne    1420 <slevmar_pseudoinverse+0x2d0>
xor    %ecx,%ecx
jmp    1475 <slevmar_pseudoinverse+0x325>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %r8d,%r8d
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
movss  0x0(%rbp,%r8,1),%xmm2
mulss  (%r14,%rbx,4),%xmm2
mulss  %xmm1,%xmm2
addss  (%rdx,%r8,1),%xmm2
movss  %xmm2,(%rdx,%r8,1)
movss  (%r12,%r8,1),%xmm2
mulss  (%r14,%rbx,4),%xmm2
mulss  %xmm1,%xmm2
addss  (%rax,%r8,1),%xmm2
movss  %xmm2,(%rax,%r8,1)
add    $0x2,%rcx
add    %r15,%r8
cmp    %rcx,%r13
jne    1430 <slevmar_pseudoinverse+0x2e0>
test   $0x1,%r10b
je     13f0 <slevmar_pseudoinverse+0x2a0>
imul   %r10,%rcx
mov    %rsi,%r8
add    %rcx,%rsi
movss  (%rdi,%rsi,4),%xmm2
mulss  (%r14,%rbx,4),%xmm2
add    %r11,%rcx
mulss  %xmm1,%xmm2
mov    0x28(%rsp),%rsi
addss  (%rsi,%rcx,4),%xmm2
movss  %xmm2,(%rsi,%rcx,4)
mov    %r8,%rsi
jmp    13f0 <slevmar_pseudoinverse+0x2a0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rsi
cmp    %r10,%rsi
je     1502 <slevmar_pseudoinverse+0x3b2>
mov    0x20(%rsp),%rax
movss  (%rax,%rsi,4),%xmm2
add    $0x4,%r12
add    $0x4,%rbp
ucomiss %xmm3,%xmm2
ja     13d0 <slevmar_pseudoinverse+0x280>
jmp    1505 <slevmar_pseudoinverse+0x3b5>
neg    %edx
lea    0xb51(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    1518 <slevmar_pseudoinverse+0x3c8>
mov    %r10d,%esi
mov    0x8(%rsp),%r15
mov    %r15,%rdi
mov    %rsi,%rbx
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@slevmar_pseudoinverse.eps = internal global float -1.000000e+00
@stderr = global i32 0
@.str = [54 x i8] c"memory allocation in slevmar_pseudoinverse() failed!\0A\00"
@.str.1 = [2 x i8] c"A\00"
@.str.2 = [94 x i8] c"LAPACK error: illegal value for argument %d of sgesvd_\22/\22 sgesdd_ in slevmar_pseudoinverse()\0A\00"
@.str.3 = [103 x i8] c"LAPACK error: dgesdd (dbdsdc)/dgesvd (dbdsqr) failed to converge in slevmar_pseudoinverse() [info=%d]\0A\00"
define i32 @slevmar_pseudoinverse(float* %0, float* %1, i32 %2) {
%4 = alloca i32
%5 = alloca float*
%6 = alloca float*
%7 = alloca i32
%8 = alloca float*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca float*
%13 = alloca float*
%14 = alloca float*
%15 = alloca float*
%16 = alloca float*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca float
%23 = alloca float
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32*
%28 = alloca i32
%29 = alloca float
store float* %0, float** %5
store float* %1, float** %6
store i32 %2, i32* %7
store float* null, float** %8
store i32 0, i32* %9
%30 = load i32, i32* %7
%31 = mul nsw i32 5, %30
store i32 %31, i32* %26
%32 = load i32, i32* %7
%33 = mul nsw i32 8, %32
store i32 %33, i32* %28
%34 = load i32, i32* %7
%35 = load i32, i32* %7
%36 = mul nsw i32 %34, %35
store i32 %36, i32* %17
%37 = load i32, i32* %7
%38 = load i32, i32* %7
%39 = mul nsw i32 %37, %38
store i32 %39, i32* %18
%40 = load i32, i32* %7
store i32 %40, i32* %19
%41 = load i32, i32* %7
%42 = load i32, i32* %7
%43 = mul nsw i32 %41, %42
store i32 %43, i32* %20
%44 = load i32, i32* %17
%45 = load i32, i32* %18
%46 = add nsw i32 %44, %45
%47 = load i32, i32* %19
%48 = add nsw i32 %46, %47
%49 = load i32, i32* %20
%50 = add nsw i32 %48, %49
%51 = load i32, i32* %26
%52 = add nsw i32 %50, %51
%53 = sext i32 %52 to i64
%54 = mul i64 %53, 4
%55 = load i32, i32* %28
%56 = sext i32 %55 to i64
%57 = mul i64 %56, 4
%58 = add i64 %54, %57
%59 = trunc i64 %58 to i32
store i32 %59, i32* %21
%60 = load i32, i32* %21
store i32 %60, i32* %9
%61 = load i32, i32* %9
%62 = call i64 @malloc(i32 %61)
%63 = inttoptr i64 %62 to float*
store float* %63, float** %8
%64 = load float*, float** %8
%65 = icmp ne float* %64, null
br i1 %65, label %69, label %66
66: ; preds = %3
%67 = load i32, i32* @stderr
%68 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %264
69: ; preds = %3
%70 = load float*, float** %8
store float* %70, float** %12
%71 = load float*, float** %12
%72 = load i32, i32* %17
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds float, float* %71, i64 %73
store float* %74, float** %13
%75 = load float*, float** %13
%76 = load i32, i32* %18
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds float, float* %75, i64 %77
store float* %78, float** %14
%79 = load float*, float** %14
%80 = load i32, i32* %19
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds float, float* %79, i64 %81
store float* %82, float** %15
%83 = load float*, float** %15
%84 = load i32, i32* %20
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds float, float* %83, i64 %85
store float* %86, float** %16
%87 = load float*, float** %16
%88 = load i32, i32* %26
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds float, float* %87, i64 %89
%91 = bitcast float* %90 to i32*
store i32* %91, i32** %27
store i32 0, i32* %10
br label %92
92: ; preds = %123, %69
%93 = load i32, i32* %10
%94 = load i32, i32* %7
%95 = icmp slt i32 %93, %94
br i1 %95, label %96, label %126
96: ; preds = %92
store i32 0, i32* %11
br label %97
97: ; preds = %119, %96
%98 = load i32, i32* %11
%99 = load i32, i32* %7
%100 = icmp slt i32 %98, %99
br i1 %100, label %101, label %122
101: ; preds = %97
%102 = load float*, float** %5
%103 = load i32, i32* %10
%104 = load i32, i32* %7
%105 = mul nsw i32 %103, %104
%106 = load i32, i32* %11
%107 = add nsw i32 %105, %106
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds float, float* %102, i64 %108
%110 = load float, float* %109
%111 = load float*, float** %12
%112 = load i32, i32* %10
%113 = load i32, i32* %11
%114 = load i32, i32* %7
%115 = mul nsw i32 %113, %114
%116 = add nsw i32 %112, %115
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds float, float* %111, i64 %117
store float %110, float* %118
br label %119
119: ; preds = %101
%120 = load i32, i32* %11
%121 = add nsw i32 %120, 1
store i32 %121, i32* %11
br label %97
122: ; preds = %97
br label %123
123: ; preds = %122
%124 = load i32, i32* %10
%125 = add nsw i32 %124, 1
store i32 %125, i32* %10
br label %92
126: ; preds = %92
%127 = load float*, float** %12
%128 = load float*, float** %14
%129 = load float*, float** %13
%130 = load float*, float** %15
%131 = load float*, float** %16
%132 = call i32 @sgesvd_(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %7, i32* %7, float* %127, i32* %7, float* %128, float* %129, i32* %7, float* %130, i32* %7, float* %131, i32* %26, i32* %24)
%133 = load i32, i32* %24
%134 = icmp ne i32 %133, 0
br i1 %134, label %135, label %150
135: ; preds = %126
%136 = load i32, i32* %24
%137 = icmp slt i32 %136, 0
br i1 %137, label %138, label %143
138: ; preds = %135
%139 = load i32, i32* @stderr
%140 = load i32, i32* %24
%141 = sub nsw i32 0, %140
%142 = call i32 (i32, i8*, ...) @fprintf(i32 %139, i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.2, i64 0, i64 0), i32 %141)
br label %147
143: ; preds = %135
%144 = load i32, i32* @stderr
%145 = load i32, i32* %24
%146 = call i32 (i32, i8*, ...) @fprintf(i32 %144, i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.3, i64 0, i64 0), i32 %145)
br label %147
147: ; preds = %143, %138
%148 = load float*, float** %8
%149 = call i32 @free(float* %148)
store i32 0, i32* %4
br label %264
150: ; preds = %126
%151 = load float, float* @slevmar_pseudoinverse.eps
%152 = fpext float %151 to double
%153 = fcmp olt double %152, 0.000000e+00
br i1 %153, label %154, label %169
154: ; preds = %150
store float 1.000000e+00, float* @slevmar_pseudoinverse.eps
br label %155
155: ; preds = %163, %154
%156 = load float, float* @slevmar_pseudoinverse.eps
%157 = fadd float %156, 1.000000e+00
store float %157, float* %29
%158 = load float, float* %29
%159 = fsub float %158, 1.000000e+00
%160 = fpext float %159 to double
%161 = fcmp ogt double %160, 0.000000e+00
br i1 %161, label %162, label %166
162: ; preds = %155
br label %163
163: ; preds = %162
%164 = load float, float* @slevmar_pseudoinverse.eps
%165 = fmul float %164, 5.000000e-01
store float %165, float* @slevmar_pseudoinverse.eps
br label %155
166: ; preds = %155
%167 = load float, float* @slevmar_pseudoinverse.eps
%168 = fmul float %167, 2.000000e+00
store float %168, float* @slevmar_pseudoinverse.eps
br label %169
169: ; preds = %166, %150
store i32 0, i32* %10
br label %170
170: ; preds = %179, %169
%171 = load i32, i32* %10
%172 = load i32, i32* %17
%173 = icmp slt i32 %171, %172
br i1 %173, label %174, label %182
174: ; preds = %170
%175 = load float*, float** %6
%176 = load i32, i32* %10
%177 = sext i32 %176 to i64
%178 = getelementptr inbounds float, float* %175, i64 %177
store float 0.000000e+00, float* %178
br label %179
179: ; preds = %174
%180 = load i32, i32* %10
%181 = add nsw i32 %180, 1
store i32 %181, i32* %10
br label %170
182: ; preds = %170
store i32 0, i32* %25
%183 = load float, float* @slevmar_pseudoinverse.eps
%184 = load float*, float** %14
%185 = getelementptr inbounds float, float* %184, i64 0
%186 = load float, float* %185
%187 = fmul float %183, %186
store float %187, float* %22
br label %188
188: ; preds = %257, %182
%189 = load i32, i32* %25
%190 = load i32, i32* %7
%191 = icmp slt i32 %189, %190
br i1 %191, label %192, label %200
192: ; preds = %188
%193 = load float*, float** %14
%194 = load i32, i32* %25
%195 = sext i32 %194 to i64
%196 = getelementptr inbounds float, float* %193, i64 %195
%197 = load float, float* %196
%198 = load float, float* %22
%199 = fcmp ogt float %197, %198
br label %200
200: ; preds = %192, %188
%201 = phi i1 [ false, %188 ], [ %199, %192 ]
br i1 %201, label %202, label %260
202: ; preds = %200
%203 = load float*, float** %14
%204 = load i32, i32* %25
%205 = sext i32 %204 to i64
%206 = getelementptr inbounds float, float* %203, i64 %205
%207 = load float, float* %206
%208 = fdiv float 1.000000e+00, %207
store float %208, float* %23
store i32 0, i32* %11
br label %209
209: ; preds = %253, %202
%210 = load i32, i32* %11
%211 = load i32, i32* %7
%212 = icmp slt i32 %210, %211
br i1 %212, label %213, label %256
213: ; preds = %209
store i32 0, i32* %10
br label %214
214: ; preds = %249, %213
%215 = load i32, i32* %10
%216 = load i32, i32* %7
%217 = icmp slt i32 %215, %216
br i1 %217, label %218, label %252
218: ; preds = %214
%219 = load float*, float** %15
%220 = load i32, i32* %25
%221 = load i32, i32* %10
%222 = load i32, i32* %7
%223 = mul nsw i32 %221, %222
%224 = add nsw i32 %220, %223
%225 = sext i32 %224 to i64
%226 = getelementptr inbounds float, float* %219, i64 %225
%227 = load float, float* %226
%228 = load float*, float** %13
%229 = load i32, i32* %11
%230 = load i32, i32* %25
%231 = load i32, i32* %7
%232 = mul nsw i32 %230, %231
%233 = add nsw i32 %229, %232
%234 = sext i32 %233 to i64
%235 = getelementptr inbounds float, float* %228, i64 %234
%236 = load float, float* %235
%237 = fmul float %227, %236
%238 = load float, float* %23
%239 = load float*, float** %6
%240 = load i32, i32* %10
%241 = load i32, i32* %7
%242 = mul nsw i32 %240, %241
%243 = load i32, i32* %11
%244 = add nsw i32 %242, %243
%245 = sext i32 %244 to i64
%246 = getelementptr inbounds float, float* %239, i64 %245
%247 = load float, float* %246
%248 = call float @llvm.fmuladd.f32(float %237, float %238, float %247)
store float %248, float* %246
br label %249
249: ; preds = %218
%250 = load i32, i32* %10
%251 = add nsw i32 %250, 1
store i32 %251, i32* %10
br label %214
252: ; preds = %214
br label %253
253: ; preds = %252
%254 = load i32, i32* %11
%255 = add nsw i32 %254, 1
store i32 %255, i32* %11
br label %209
256: ; preds = %209
br label %257
257: ; preds = %256
%258 = load i32, i32* %25
%259 = add nsw i32 %258, 1
store i32 %259, i32* %25
br label %188
260: ; preds = %200
%261 = load float*, float** %8
%262 = call i32 @free(float* %261)
%263 = load i32, i32* %25
store i32 %263, i32* %4
br label %264
264: ; preds = %260, %147, %66
%265 = load i32, i32* %4
ret i32 %265
}

LLVM IR (-O2):
@slevmar_pseudoinverse.eps = internal unnamed_addr global float -1.000000e+00
@stderr = global i32 0
@.str = [54 x i8] c"memory allocation in slevmar_pseudoinverse() failed!\0A\00"
@.str.1 = [2 x i8] c"A\00"
@.str.2 = [94 x i8] c"LAPACK error: illegal value for argument %d of sgesvd_\22/\22 sgesdd_ in slevmar_pseudoinverse()\0A\00"
@.str.3 = [103 x i8] c"LAPACK error: dgesdd (dbdsdc)/dgesvd (dbdsqr) failed to converge in slevmar_pseudoinverse() [info=%d]\0A\00"
define i32 @slevmar_pseudoinverse(float* nocapture %0, float* nocapture %1, i32 %2) {
%4 = bitcast float* %1 to i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %2, i32* %5
%8 = bitcast i32* %6 to i8*
%9 = bitcast i32* %7 to i8*
%10 = mul nsw i32 %2, 5
store i32 %10, i32* %7
%11 = shl nsw i32 %2, 3
%12 = mul nsw i32 %2, %2
%13 = shl nuw nsw i32 %12, 1
%14 = add i32 %12, %2
%15 = add i32 %14, %10
%16 = add i32 %15, %11
%17 = add i32 %16, %13
%18 = shl i32 %17, 2
%19 = tail call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to float*
%21 = icmp eq i64 %19, 0
br i1 %21, label %22, label %25
22: ; preds = %3
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
br label %174
25: ; preds = %3
%26 = zext i32 %12 to i64
%27 = getelementptr inbounds float, float* %20, i64 %26
%28 = getelementptr inbounds float, float* %27, i64 %26
%29 = sext i32 %2 to i64
%30 = getelementptr inbounds float, float* %28, i64 %29
%31 = getelementptr inbounds float, float* %30, i64 %26
%32 = icmp sgt i32 %2, 0
br i1 %32, label %33, label %73
33: ; preds = %25
%34 = zext i32 %2 to i64
%35 = and i64 %34, 1
%36 = icmp eq i32 %2, 1
%37 = and i64 %34, 4294967294
%38 = icmp eq i64 %35, 0
br label %39
39: ; preds = %70, %33
%40 = phi i64 [ 0, %33 ], [ %71, %70 ]
%41 = mul nsw i64 %40, %29
br i1 %36, label %61, label %42
42: ; preds = %39, %42
%43 = phi i64 [ %58, %42 ], [ 0, %39 ]
%44 = phi i64 [ %59, %42 ], [ 0, %39 ]
%45 = add nsw i64 %43, %41
%46 = getelementptr inbounds float, float* %0, i64 %45
%47 = load float, float* %46
%48 = mul nsw i64 %43, %29
%49 = add nsw i64 %48, %40
%50 = getelementptr inbounds float, float* %20, i64 %49
store float %47, float* %50
%51 = or i64 %43, 1
%52 = add nsw i64 %51, %41
%53 = getelementptr inbounds float, float* %0, i64 %52
%54 = load float, float* %53
%55 = mul nsw i64 %51, %29
%56 = add nsw i64 %55, %40
%57 = getelementptr inbounds float, float* %20, i64 %56
store float %54, float* %57
%58 = add nuw nsw i64 %43, 2
%59 = add i64 %44, 2
%60 = icmp eq i64 %59, %37
br i1 %60, label %61, label %42
61: ; preds = %42, %39
%62 = phi i64 [ 0, %39 ], [ %58, %42 ]
br i1 %38, label %70, label %63
63: ; preds = %61
%64 = add nsw i64 %62, %41
%65 = getelementptr inbounds float, float* %0, i64 %64
%66 = load float, float* %65
%67 = mul nsw i64 %62, %29
%68 = add nsw i64 %67, %40
%69 = getelementptr inbounds float, float* %20, i64 %68
store float %66, float* %69
br label %70
70: ; preds = %61, %63
%71 = add nuw nsw i64 %40, 1
%72 = icmp eq i64 %71, %34
br i1 %72, label %73, label %39
73: ; preds = %70, %25
%74 = call i32 @sgesvd_(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32* %5, i32* %5, float* %20, i32* %5, float* %28, float* %27, i32* %5, float* %30, i32* %5, float* %31, i32* %7, i32* %6)
%75 = load i32, i32* %6
%76 = icmp eq i32 %75, 0
br i1 %76, label %87, label %77
77: ; preds = %73
%78 = icmp slt i32 %75, 0
%79 = load i32, i32* @stderr
br i1 %78, label %80, label %83
80: ; preds = %77
%81 = sub nsw i32 0, %75
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.2, i64 0, i64 0), i32 %81)
br label %85
83: ; preds = %77
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.3, i64 0, i64 0), i32 %75)
br label %85
85: ; preds = %83, %80
%86 = call i32 @free(float* %20)
br label %174
87: ; preds = %73
%88 = load float, float* @slevmar_pseudoinverse.eps
%89 = fcmp olt float %88, 0.000000e+00
br i1 %89, label %90, label %91
90: ; preds = %87
store float 0x3E80000000000000, float* @slevmar_pseudoinverse.eps
br label %91
91: ; preds = %90, %87
%92 = phi float [ 0x3E80000000000000, %90 ], [ %88, %87 ]
%93 = icmp eq i32 %12, 0
br i1 %93, label %96, label %94
94: ; preds = %91
%95 = shl nuw nsw i64 %26, 2
br label %96
96: ; preds = %94, %91
%97 = load float, float* %28
%98 = fmul float %92, %97
%99 = load i32, i32* %5
%100 = icmp sgt i32 %99, 0
br i1 %100, label %101, label %171
101: ; preds = %96
%102 = zext i32 %99 to i64
%103 = zext i32 %99 to i64
%104 = fcmp ogt float %97, %98
br i1 %104, label %105, label %171
105: ; preds = %101
%106 = and i64 %103, 1
%107 = icmp eq i32 %99, 1
%108 = and i64 %103, 4294967294
%109 = icmp eq i64 %106, 0
br label %110
110: ; preds = %105, %165
%111 = phi i64 [ %163, %165 ], [ 0, %105 ]
%112 = phi float [ %167, %165 ], [ %97, %105 ]
%113 = fdiv float 1.000000e+00, %112
%114 = mul nsw i64 %111, %102
br label %115
115: ; preds = %159, %110
%116 = phi i64 [ 0, %110 ], [ %160, %159 ]
%117 = add nuw nsw i64 %116, %114
%118 = getelementptr inbounds float, float* %27, i64 %117
br i1 %107, label %146, label %119
119: ; preds = %115, %119
%120 = phi i64 [ %143, %119 ], [ 0, %115 ]
%121 = phi i64 [ %144, %119 ], [ 0, %115 ]
%122 = mul nsw i64 %120, %102
%123 = add nuw nsw i64 %122, %111
%124 = getelementptr inbounds float, float* %30, i64 %123
%125 = load float, float* %124
%126 = load float, float* %118
%127 = fmul float %125, %126
%128 = add nuw nsw i64 %122, %116
%129 = getelementptr inbounds float, float* %1, i64 %128
%130 = load float, float* %129
%131 = call float @llvm.fmuladd.f32(float %127, float %113, float %130)
store float %131, float* %129
%132 = or i64 %120, 1
%133 = mul nsw i64 %132, %102
%134 = add nuw nsw i64 %133, %111
%135 = getelementptr inbounds float, float* %30, i64 %134
%136 = load float, float* %135
%137 = load float, float* %118
%138 = fmul float %136, %137
%139 = add nuw nsw i64 %133, %116
%140 = getelementptr inbounds float, float* %1, i64 %139
%141 = load float, float* %140
%142 = call float @llvm.fmuladd.f32(float %138, float %113, float %141)
store float %142, float* %140
%143 = add nuw nsw i64 %120, 2
%144 = add i64 %121, 2
%145 = icmp eq i64 %144, %108
br i1 %145, label %146, label %119
146: ; preds = %119, %115
%147 = phi i64 [ 0, %115 ], [ %143, %119 ]
br i1 %109, label %159, label %148
148: ; preds = %146
%149 = mul nsw i64 %147, %102
%150 = add nuw nsw i64 %149, %111
%151 = getelementptr inbounds float, float* %30, i64 %150
%152 = load float, float* %151
%153 = load float, float* %118
%154 = fmul float %152, %153
%155 = add nuw nsw i64 %149, %116
%156 = getelementptr inbounds float, float* %1, i64 %155
%157 = load float, float* %156
%158 = call float @llvm.fmuladd.f32(float %154, float %113, float %157)
store float %158, float* %156
br label %159
159: ; preds = %146, %148
%160 = add nuw nsw i64 %116, 1
%161 = icmp eq i64 %160, %103
br i1 %161, label %162, label %115
162: ; preds = %159
%163 = add nuw nsw i64 %111, 1
%164 = icmp eq i64 %163, %103
br i1 %164, label %171, label %165
165: ; preds = %162
%166 = getelementptr inbounds float, float* %28, i64 %163
%167 = load float, float* %166
%168 = fcmp ogt float %167, %98
br i1 %168, label %110, label %169
169: ; preds = %165
%170 = trunc i64 %163 to i32
br label %171
171: ; preds = %162, %101, %169, %96
%172 = phi i32 [ 0, %96 ], [ %170, %169 ], [ 0, %101 ], [ %99, %162 ]
%173 = call i32 @free(float* %20)
br label %174
174: ; preds = %171, %85, %22
%175 = phi i32 [ 0, %85 ], [ %172, %171 ], [ 0, %22 ]
ret i32 %175
}