#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__ lap_SVD(double *, double *, double *, int, double *, int);
int /*<<< orphan*/ memcpy(double *, double *, int);
int /*<<< orphan*/ mmul(double *, double *, double *, int);
int /*<<< orphan*/ trnm(double *, int);
void singulF(double *F) {
  double S[3], UT[9], V[9], D[9] = {1, 0, 0, 0, 1, 0, 0, 0, 1}, VD[9];
  trnm(F, 3);
  if (lap_SVD(S, F, UT, 3, V, 3) != 0) {
    memcpy(F, D, 9 * sizeof(double));
    return;
  }
  D[0] = S[0];
  D[4] = S[1];
  D[8] = 0;
  mmul(VD, V, D, 3);
  mmul(F, VD, UT, 3);
  trnm(F, 3);
}


x86 assembly (clang, -O0):
<singulF>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1040 <memset@plt>
movsd  0xe86(%rip),%xmm0
movsd  %xmm0,-0x110(%rbp)
ff
movsd  0xe76(%rip),%xmm0
movsd  %xmm0,-0xf0(%rbp)
ff
movsd  0xe66(%rip),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
mov    -0x8(%rbp),%rdi
mov    $0x3,%esi
call   1030 <trnm@plt>
lea    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    -0x70(%rbp),%rdx
lea    -0xc0(%rbp),%r8
mov    $0x3,%r9d
mov    %r9d,%ecx
call   1070 <lap_SVD@plt>
cmp    $0x0,%rax
je     11f5 <singulF+0xa5>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    $0x48,%edx
call   1050 <memcpy@plt>
jmp    1260 <singulF+0x110>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x110(%rbp)
ff
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0xf0(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
lea    -0x160(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
lea    -0x110(%rbp),%rdx
mov    $0x3,%ecx
call   1060 <mmul@plt>
mov    -0x8(%rbp),%rdi
lea    -0x160(%rbp),%rsi
lea    -0x70(%rbp),%rdx
mov    $0x3,%ecx
call   1060 <mmul@plt>
mov    -0x8(%rbp),%rdi
mov    $0x3,%esi
call   1030 <trnm@plt>
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<singulF>:
push   %r14
push   %rbx
sub    $0x158,%rsp
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x10(%rsp)
movabs $0x3ff0000000000000,%rax
mov    %rax,(%rsp)
mov    %rax,0x20(%rsp)
mov    %rax,0x40(%rsp)
mov    $0x3,%esi
call   1030 <trnm@plt>
lea    0x50(%rsp),%rdi
lea    0xc0(%rsp),%rdx
lea    0x70(%rsp),%r8
mov    %rbx,%rsi
mov    $0x3,%ecx
mov    $0x3,%r9d
call   1060 <lap_SVD@plt>
test   %rax,%rax
je     11c1 <singulF+0x81>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x48,%edx
call   1040 <memcpy@plt>
jmp    1223 <singulF+0xe3>
movsd  0x50(%rsp),%xmm0
movsd  0x58(%rsp),%xmm1
movsd  %xmm0,(%rsp)
movsd  %xmm1,0x20(%rsp)
movq   $0x0,0x40(%rsp)
lea    0x110(%rsp),%r14
lea    0x70(%rsp),%rsi
mov    %rsp,%rdx
mov    %r14,%rdi
mov    $0x3,%ecx
call   1050 <mmul@plt>
lea    0xc0(%rsp),%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%ecx
call   1050 <mmul@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <trnm@plt>
add    $0x158,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @singulF(double* %0) {
%2 = alloca double*
%3 = alloca [3 x double]
%4 = alloca [9 x double]
%5 = alloca [9 x double]
%6 = alloca [9 x double]
%7 = alloca [9 x double]
store double* %0, double** %2
%8 = bitcast [9 x double]* %6 to i8*
%9 = bitcast i8* %8 to [9 x double]*
%10 = getelementptr inbounds [9 x double], [9 x double]* %9, i32 0, i32 0
store double 1.000000e+00, double* %10
%11 = getelementptr inbounds [9 x double], [9 x double]* %9, i32 0, i32 4
store double 1.000000e+00, double* %11
%12 = getelementptr inbounds [9 x double], [9 x double]* %9, i32 0, i32 8
store double 1.000000e+00, double* %12
%13 = load double*, double** %2
%14 = call i32 @trnm(double* %13, i32 3)
%15 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%16 = load double*, double** %2
%17 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 0
%18 = getelementptr inbounds [9 x double], [9 x double]* %5, i64 0, i64 0
%19 = call i64 @lap_SVD(double* %15, double* %16, double* %17, i32 3, double* %18, i32 3)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %1
%22 = load double*, double** %2
%23 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 0
%24 = call i32 @memcpy(double* %22, double* %23, i32 72)
br label %43
25: ; preds = %1
%26 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%27 = load double, double* %26
%28 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 0
store double %27, double* %28
%29 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
%30 = load double, double* %29
%31 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 4
store double %30, double* %31
%32 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 8
store double 0.000000e+00, double* %32
%33 = getelementptr inbounds [9 x double], [9 x double]* %7, i64 0, i64 0
%34 = getelementptr inbounds [9 x double], [9 x double]* %5, i64 0, i64 0
%35 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 0
%36 = call i32 @mmul(double* %33, double* %34, double* %35, i32 3)
%37 = load double*, double** %2
%38 = getelementptr inbounds [9 x double], [9 x double]* %7, i64 0, i64 0
%39 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 0
%40 = call i32 @mmul(double* %37, double* %38, double* %39, i32 3)
%41 = load double*, double** %2
%42 = call i32 @trnm(double* %41, i32 3)
br label %43
43: ; preds = %25, %21
ret void
}

LLVM IR (-O2):
define void @singulF(double* %0) {
%2 = alloca [3 x double]
%3 = alloca [9 x double]
%4 = alloca [9 x double]
%5 = alloca [9 x double]
%6 = alloca [9 x double]
%7 = bitcast [3 x double]* %2 to i8*
%8 = bitcast [9 x double]* %3 to i8*
%9 = bitcast [9 x double]* %4 to i8*
%10 = bitcast [9 x double]* %5 to i8*
%11 = getelementptr inbounds [9 x double], [9 x double]* %5, i64 0, i64 0
store double 1.000000e+00, double* %11
%12 = getelementptr inbounds [9 x double], [9 x double]* %5, i64 0, i64 4
store double 1.000000e+00, double* %12
%13 = getelementptr inbounds [9 x double], [9 x double]* %5, i64 0, i64 8
store double 1.000000e+00, double* %13
%14 = bitcast [9 x double]* %6 to i8*
%15 = tail call i32 @trnm(double* %0, i32 3)
%16 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%17 = getelementptr inbounds [9 x double], [9 x double]* %3, i64 0, i64 0
%18 = getelementptr inbounds [9 x double], [9 x double]* %4, i64 0, i64 0
%19 = call i64 @lap_SVD(double* %16, double* %0, double* %17, i32 3, double* %18, i32 3)
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %1
%22 = call i32 @memcpy(double* %0, double* %11, i32 72)
br label %31
23: ; preds = %1
%24 = load double, double* %16
store double %24, double* %11
%25 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 1
%26 = load double, double* %25
store double %26, double* %12
store double 0.000000e+00, double* %13
%27 = getelementptr inbounds [9 x double], [9 x double]* %6, i64 0, i64 0
%28 = call i32 @mmul(double* %27, double* %18, double* %11, i32 3)
%29 = call i32 @mmul(double* %0, double* %27, double* %17, i32 3)
%30 = call i32 @trnm(double* %0, i32 3)
br label %31
31: ; preds = %23, %21
ret void
}