#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*/ CopyMatrix(double *, double *, int const);
double const DBL_MIN;
int /*<<< orphan*/ TransposeMatrix(double *, double *, int const);
int /*<<< orphan*/ assert(int);
double sqrt(double const);
void MakeFactQ_FromFactSym(double *ev, double *inv_ev, double *v,
                           const double *pi, const int n) {
  int i, j;
  assert(NULL != ev);
  assert(NULL != inv_ev);
  assert(NULL != v);
  assert(NULL != pi);
  assert(n > 0);
  for (i = 0; i < n; i++)
    if (v[i] > 0.) {
      v[i] = 0.;
    }
  TransposeMatrix(ev, inv_ev, n);
  CopyMatrix(inv_ev, ev, n);
  for (i = 0; i < n; i++)
    if (pi[i] > DBL_MIN)
      for (j = 0; j < n; j++) {
        inv_ev[i * n + j] *= sqrt(pi[i]);
        ev[i * n + j] /= sqrt(pi[i]);
      }
}


x86 assembly (clang, -O0):
<MakeFactQ_FromFactSym>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpl   $0x0,-0x24(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1209 <MakeFactQ_FromFactSym+0xc9>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11f6 <MakeFactQ_FromFactSym+0xb6>
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    11fb <MakeFactQ_FromFactSym+0xbb>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11c0 <MakeFactQ_FromFactSym+0x80>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1050 <TransposeMatrix@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <CopyMatrix@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12f4 <MakeFactQ_FromFactSym+0x1b4>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x2d90(%rip),%rax
ucomisd (%rax),%xmm0
jbe    12e1 <MakeFactQ_FromFactSym+0x1a1>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12dc <MakeFactQ_FromFactSym+0x19c>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1060 <sqrt@plt>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x24(%rbp),%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x24(%rbp),%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1261 <MakeFactQ_FromFactSym+0x121>
jmp    12e1 <MakeFactQ_FromFactSym+0x1a1>
jmp    12e6 <MakeFactQ_FromFactSym+0x1a6>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1230 <MakeFactQ_FromFactSym+0xf0>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MakeFactQ_FromFactSym>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%r12d
mov    %rcx,%r15
mov    %rdx,%rbp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %rbp,%rbp
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %r12d,%r12d
setg   %dil
call   1040 <assert@plt>
test   %r12d,%r12d
jle    12e3 <MakeFactQ_FromFactSym+0x1a3>
mov    %r12d,%edx
cmp    $0x1,%r12d
jne    130d <MakeFactQ_FromFactSym+0x1cd>
xor    %eax,%eax
mov    %rdx,0x8(%rsp)
test   $0x1,%dl
je     11de <MakeFactQ_FromFactSym+0x9e>
movsd  0x0(%rbp,%rax,8),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11de <MakeFactQ_FromFactSym+0x9e>
movq   $0x0,0x0(%rbp,%rax,8)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1050 <TransposeMatrix@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
call   1030 <CopyMatrix@plt>
test   %r12d,%r12d
jle    12d4 <MakeFactQ_FromFactSym+0x194>
mov    0x8(%rsp),%rax
lea    0x0(,%rax,8),%rcx
mov    %rcx,0x10(%rsp)
lea    -0x1(%rax),%rbp
xor    %r13d,%r13d
xorpd  %xmm2,%xmm2
jmp    124a <MakeFactQ_FromFactSym+0x10a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r13
mov    0x10(%rsp),%rax
add    %rax,%r14
add    %rax,%rbx
cmp    0x8(%rsp),%r13
je     12d4 <MakeFactQ_FromFactSym+0x194>
movsd  (%r15,%r13,8),%xmm0
ucomisd %xmm2,%xmm0
jbe    1230 <MakeFactQ_FromFactSym+0xf0>
xor    %r12d,%r12d
ucomisd %xmm2,%xmm0
jb     1270 <MakeFactQ_FromFactSym+0x130>
nop
sqrtsd %xmm0,%xmm0
jmp    1279 <MakeFactQ_FromFactSym+0x139>
cs nopw 0x0(%rax,%rax,1)
call   1060 <sqrt@plt>
xorpd  %xmm2,%xmm2
mulsd  (%r14,%r12,8),%xmm0
movsd  %xmm0,(%r14,%r12,8)
movsd  (%r15,%r13,8),%xmm0
ucomisd %xmm2,%xmm0
jb     12a0 <MakeFactQ_FromFactSym+0x160>
sqrtsd %xmm0,%xmm0
jmp    12a9 <MakeFactQ_FromFactSym+0x169>
nopw   0x0(%rax,%rax,1)
call   1060 <sqrt@plt>
xorpd  %xmm2,%xmm2
movsd  (%rbx,%r12,8),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,(%rbx,%r12,8)
cmp    %r12,%rbp
je     1230 <MakeFactQ_FromFactSym+0xf0>
movsd  (%r15,%r13,8),%xmm0
add    $0x1,%r12
ucomisd %xmm2,%xmm0
jb     1270 <MakeFactQ_FromFactSym+0x130>
jmp    1260 <MakeFactQ_FromFactSym+0x120>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
call   1050 <TransposeMatrix@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12d,%edx
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <CopyMatrix@plt>
mov    %edx,%ecx
and    $0xfffffffe,%ecx
xor    %eax,%eax
xorpd  %xmm0,%xmm0
jmp    132d <MakeFactQ_FromFactSym+0x1ed>
nopw   0x0(%rax,%rax,1)
add    $0x2,%rax
cmp    %rax,%rcx
je     11bb <MakeFactQ_FromFactSym+0x7b>
movsd  0x0(%rbp,%rax,8),%xmm1
ucomisd %xmm0,%xmm1
jbe    1342 <MakeFactQ_FromFactSym+0x202>
movq   $0x0,0x0(%rbp,%rax,8)
movsd  0x8(%rbp,%rax,8),%xmm1
ucomisd %xmm0,%xmm1
jbe    1320 <MakeFactQ_FromFactSym+0x1e0>
movq   $0x0,0x8(%rbp,%rax,8)
jmp    1320 <MakeFactQ_FromFactSym+0x1e0>

LLVM IR (-O0):
@DBL_MIN = constant double 0.000000e+00
define void @MakeFactQ_FromFactSym(double* %0, double* %1, double* %2, double* %3, i32 %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store i32 %4, i32* %10
%13 = load double*, double** %6
%14 = icmp ne double* null, %13
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load double*, double** %7
%18 = icmp ne double* null, %17
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load double*, double** %8
%22 = icmp ne double* null, %21
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load double*, double** %9
%26 = icmp ne double* null, %25
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load i32, i32* %10
%30 = icmp sgt i32 %29, 0
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
store i32 0, i32* %11
br label %33
33: ; preds = %50, %5
%34 = load i32, i32* %11
%35 = load i32, i32* %10
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %53
37: ; preds = %33
%38 = load double*, double** %8
%39 = load i32, i32* %11
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = fcmp ogt double %42, 0.000000e+00
br i1 %43, label %44, label %49
44: ; preds = %37
%45 = load double*, double** %8
%46 = load i32, i32* %11
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds double, double* %45, i64 %47
store double 0.000000e+00, double* %48
br label %49
49: ; preds = %44, %37
br label %50
50: ; preds = %49
%51 = load i32, i32* %11
%52 = add nsw i32 %51, 1
store i32 %52, i32* %11
br label %33
53: ; preds = %33
%54 = load double*, double** %6
%55 = load double*, double** %7
%56 = load i32, i32* %10
%57 = call i32 @TransposeMatrix(double* %54, double* %55, i32 %56)
%58 = load double*, double** %7
%59 = load double*, double** %6
%60 = load i32, i32* %10
%61 = call i32 @CopyMatrix(double* %58, double* %59, i32 %60)
store i32 0, i32* %11
br label %62
62: ; preds = %117, %53
%63 = load i32, i32* %11
%64 = load i32, i32* %10
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %120
66: ; preds = %62
%67 = load double*, double** %9
%68 = load i32, i32* %11
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds double, double* %67, i64 %69
%71 = load double, double* %70
%72 = load double, double* @DBL_MIN
%73 = fcmp ogt double %71, %72
br i1 %73, label %74, label %116
74: ; preds = %66
store i32 0, i32* %12
br label %75
75: ; preds = %112, %74
%76 = load i32, i32* %12
%77 = load i32, i32* %10
%78 = icmp slt i32 %76, %77
br i1 %78, label %79, label %115
79: ; preds = %75
%80 = load double*, double** %9
%81 = load i32, i32* %11
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds double, double* %80, i64 %82
%84 = load double, double* %83
%85 = call double @sqrt(double %84)
%86 = load double*, double** %7
%87 = load i32, i32* %11
%88 = load i32, i32* %10
%89 = mul nsw i32 %87, %88
%90 = load i32, i32* %12
%91 = add nsw i32 %89, %90
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds double, double* %86, i64 %92
%94 = load double, double* %93
%95 = fmul double %94, %85
store double %95, double* %93
%96 = load double*, double** %9
%97 = load i32, i32* %11
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds double, double* %96, i64 %98
%100 = load double, double* %99
%101 = call double @sqrt(double %100)
%102 = load double*, double** %6
%103 = load i32, i32* %11
%104 = load i32, i32* %10
%105 = mul nsw i32 %103, %104
%106 = load i32, i32* %12
%107 = add nsw i32 %105, %106
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds double, double* %102, i64 %108
%110 = load double, double* %109
%111 = fdiv double %110, %101
store double %111, double* %109
br label %112
112: ; preds = %79
%113 = load i32, i32* %12
%114 = add nsw i32 %113, 1
store i32 %114, i32* %12
br label %75
115: ; preds = %75
br label %116
116: ; preds = %115, %66
br label %117
117: ; preds = %116
%118 = load i32, i32* %11
%119 = add nsw i32 %118, 1
store i32 %119, i32* %11
br label %62
120: ; preds = %62
ret void
}

LLVM IR (-O2):
@DBL_MIN = constant double 0.000000e+00
define void @MakeFactQ_FromFactSym(double* %0, double* %1, double* %2, double* %3, i32 %4) {
%6 = icmp ne double* %0, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = icmp ne double* %1, null
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = icmp ne double* %2, null
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = icmp ne double* %3, null
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = icmp sgt i32 %4, 0
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
br i1 %18, label %21, label %85
21: ; preds = %5
%22 = zext i32 %4 to i64
%23 = and i64 %22, 1
%24 = icmp eq i32 %4, 1
br i1 %24, label %44, label %25
25: ; preds = %21
%26 = and i64 %22, 4294967294
br label %27
27: ; preds = %40, %25
%28 = phi i64 [ 0, %25 ], [ %41, %40 ]
%29 = phi i64 [ 0, %25 ], [ %42, %40 ]
%30 = getelementptr inbounds double, double* %2, i64 %28
%31 = load double, double* %30
%32 = fcmp ogt double %31, 0.000000e+00
br i1 %32, label %33, label %34
33: ; preds = %27
store double 0.000000e+00, double* %30
br label %34
34: ; preds = %27, %33
%35 = or i64 %28, 1
%36 = getelementptr inbounds double, double* %2, i64 %35
%37 = load double, double* %36
%38 = fcmp ogt double %37, 0.000000e+00
br i1 %38, label %39, label %40
39: ; preds = %34
store double 0.000000e+00, double* %36
br label %40
40: ; preds = %39, %34
%41 = add nuw nsw i64 %28, 2
%42 = add i64 %29, 2
%43 = icmp eq i64 %42, %26
br i1 %43, label %44, label %27
44: ; preds = %40, %21
%45 = phi i64 [ 0, %21 ], [ %41, %40 ]
%46 = icmp eq i64 %23, 0
br i1 %46, label %52, label %47
47: ; preds = %44
%48 = getelementptr inbounds double, double* %2, i64 %45
%49 = load double, double* %48
%50 = fcmp ogt double %49, 0.000000e+00
br i1 %50, label %51, label %52
51: ; preds = %47
store double 0.000000e+00, double* %48
br label %52
52: ; preds = %47, %51, %44
%53 = tail call i32 @TransposeMatrix(double* %0, double* %1, i32 %4)
%54 = tail call i32 @CopyMatrix(double* %1, double* %0, i32 %4)
br i1 %18, label %55, label %88
55: ; preds = %52
%56 = zext i32 %4 to i64
%57 = zext i32 %4 to i64
br label %58
58: ; preds = %55, %82
%59 = phi i64 [ 0, %55 ], [ %83, %82 ]
%60 = getelementptr inbounds double, double* %3, i64 %59
%61 = load double, double* %60
%62 = fcmp ule double %61, 0.000000e+00
br i1 %62, label %82, label %63
63: ; preds = %58
%64 = mul nsw i64 %59, %56
br label %65
65: ; preds = %80, %63
%66 = phi double [ %61, %63 ], [ %81, %80 ]
%67 = phi i64 [ 0, %63 ], [ %78, %80 ]
%68 = tail call double @sqrt(double %66)
%69 = add nuw nsw i64 %67, %64
%70 = getelementptr inbounds double, double* %1, i64 %69
%71 = load double, double* %70
%72 = fmul double %68, %71
store double %72, double* %70
%73 = load double, double* %60
%74 = tail call double @sqrt(double %73)
%75 = getelementptr inbounds double, double* %0, i64 %69
%76 = load double, double* %75
%77 = fdiv double %76, %74
store double %77, double* %75
%78 = add nuw nsw i64 %67, 1
%79 = icmp eq i64 %78, %57
br i1 %79, label %82, label %80
80: ; preds = %65
%81 = load double, double* %60
br label %65
82: ; preds = %65, %58
%83 = add nuw nsw i64 %59, 1
%84 = icmp eq i64 %83, %57
br i1 %84, label %88, label %58
85: ; preds = %5
%86 = tail call i32 @TransposeMatrix(double* %0, double* %1, i32 %4)
%87 = tail call i32 @CopyMatrix(double* %1, double* %0, i32 %4)
br label %88
88: ; preds = %82, %85, %52
ret void
}