#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*/ dgemm_(char *, char *, int *, int *, int *, double *,
                          double *, int *, double *, int *, double *, double *,
                          int *);
double *fgls_malloc_impl(char *, int, int);
int /*<<< orphan*/ free(double *);
void build_SPD_Phi(int n, double *eigVecs, double *eigVals, double *Phi) {
  double ONE = 1.0, ZERO = 0.0, *tmp;
  int i, j;
  tmp =
      fgls_malloc_impl("/scratch/repos/new/home/jordi_armengol_estape/"
                       "c-scraper/outputs/2022-01-22/02-19-57/repos/"
                       "lucasb-eyer/OmicABEL/refs/heads/master/src/fgls_chol.c",
                       427, n * n * sizeof(double));
  for (j = 0; j < n; j++)
    for (i = 0; i < n; i++)
      tmp[j * n + i] = eigVecs[j * n + i] * eigVals[j];
  dgemm_("N", "T", &n, &n, &n, &ONE, tmp, &n, eigVecs, &n, &ZERO, Phi, &n);
  free(tmp);
}


x86 assembly (clang, -O0):
<build_SPD_Phi>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %edi,-0x14(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
movsd  0xeab(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edx
lea    0xe90(%rip),%rdi
mov    $0x1ab,%esi
call   1050 <fgls_malloc_impl@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1206 <build_SPD_Phi+0xd6>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f3 <build_SPD_Phi+0xc3>
mov    -0x20(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0x14(%rbp),%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x50(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm0
mov    -0x48(%rbp),%rax
mov    -0x50(%rbp),%ecx
imul   -0x14(%rbp),%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11a0 <build_SPD_Phi+0x70>
jmp    11f8 <build_SPD_Phi+0xc8>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    118d <build_SPD_Phi+0x5d>
mov    -0x48(%rbp),%r14
mov    -0x20(%rbp),%rbx
mov    -0x30(%rbp),%r10
lea    0xe80(%rip),%rdi
lea    0xe7b(%rip),%rsi
lea    -0x14(%rbp),%rax
lea    -0x38(%rbp),%r9
lea    -0x40(%rbp),%r11
mov    %rax,%rdx
mov    %rax,%rcx
mov    %rax,%r8
mov    %r14,(%rsp)
mov    %rax,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %rax,0x18(%rsp)
mov    %r11,0x20(%rsp)
mov    %r10,0x28(%rsp)
mov    %rax,0x30(%rsp)
call   1040 <dgemm_@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_SPD_Phi>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rcx,0x18(%rsp)
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %edi,%r13d
mov    %edi,0x4(%rsp)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x50(%rsp)
movq   $0x0,0x48(%rsp)
mov    %edi,%edx
imul   %edi,%edx
shl    $0x3,%edx
lea    0xe89(%rip),%rdi
mov    $0x1ab,%esi
call   1050 <fgls_malloc_impl@plt>
mov    %rax,%r15
test   %r13d,%r13d
jle    13f0 <build_SPD_Phi+0x2c0>
mov    %r13d,%eax
mov    %eax,%ecx
and    $0xfffffffc,%ecx
mov    %rcx,0x38(%rsp)
add    $0xfffffffffffffffc,%rcx
mov    %rcx,0x30(%rsp)
mov    %rcx,%rdx
shr    $0x2,%rdx
add    $0x1,%rdx
mov    %rdx,%rcx
mov    %rdx,0x28(%rsp)
and    $0xfffffffffffffffe,%rdx
mov    %rdx,0x20(%rsp)
mov    %rax,%rcx
neg    %rcx
mov    %rcx,0x40(%rsp)
lea    0x30(%r15),%rdx
lea    0x0(,%rax,8),%r11
lea    0x30(%r12),%rcx
lea    0x8(%r12),%rdi
lea    0x8(%r15),%r14
xor    %r8d,%r8d
mov    %r15,0x10(%rsp)
mov    %r13d,(%rsp)
mov    %r11,0x8(%rsp)
jmp    1219 <build_SPD_Phi+0xe9>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r8
add    %r11,%rdx
add    %r11,%rcx
add    %r11,%rdi
add    %r11,%r14
cmp    %rax,%r8
je     13f0 <build_SPD_Phi+0x2c0>
mov    %r8,%r9
imul   %rax,%r9
cmp    $0x4,%r13d
jae    12a0 <build_SPD_Phi+0x170>
xor    %esi,%esi
mov    %rsi,%rbp
test   $0x1,%al
je     124b <build_SPD_Phi+0x11b>
add    %rsi,%r9
movsd  (%r12,%r9,8),%xmm0
mulsd  (%rbx,%r8,8),%xmm0
movsd  %xmm0,(%r15,%r9,8)
mov    %rsi,%rbp
or     $0x1,%rbp
not    %rsi
cmp    0x40(%rsp),%rsi
je     1200 <build_SPD_Phi+0xd0>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  -0x8(%rdi,%rbp,8),%xmm0
mulsd  (%rbx,%r8,8),%xmm0
movsd  %xmm0,-0x8(%r14,%rbp,8)
movsd  (%rdi,%rbp,8),%xmm0
mulsd  (%rbx,%r8,8),%xmm0
movsd  %xmm0,(%r14,%rbp,8)
add    $0x2,%rbp
cmp    %rbp,%rax
jne    1260 <build_SPD_Phi+0x130>
jmp    1200 <build_SPD_Phi+0xd0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%r9,%rax,1),%rsi
lea    (%r15,%r9,8),%rbp
lea    (%r15,%rsi,8),%r13
lea    (%rbx,%r8,8),%r10
add    $0x8,%r10
lea    (%rbx,%r8,8),%r15
lea    (%r12,%rsi,8),%rsi
mov    %r12,%r11
lea    (%r12,%r9,8),%r12
cmp    %rsi,%rbp
setb   %sil
cmp    %r13,%r12
setb   %r12b
cmp    %r10,%rbp
setb   %r10b
cmp    %r13,%r15
setb   %bpl
test   %r12b,%sil
jne    13cc <build_SPD_Phi+0x29c>
mov    $0x0,%esi
and    %bpl,%r10b
mov    %r11,%r12
mov    0x10(%rsp),%r15
mov    (%rsp),%r13d
mov    0x8(%rsp),%r11
jne    1228 <build_SPD_Phi+0xf8>
cmpq   $0x0,0x30(%rsp)
je     13e4 <build_SPD_Phi+0x2b4>
movsd  (%rbx,%r8,8),%xmm0
unpcklpd %xmm0,%xmm0
mov    0x20(%rsp),%rsi
xor    %r10d,%r10d
cs nopw 0x0(%rax,%rax,1)
nop
movupd -0x30(%rcx,%r10,8),%xmm1
movupd -0x20(%rcx,%r10,8),%xmm2
mulpd  %xmm0,%xmm1
mulpd  %xmm0,%xmm2
movupd %xmm1,-0x30(%rdx,%r10,8)
movupd %xmm2,-0x20(%rdx,%r10,8)
movupd -0x10(%rcx,%r10,8),%xmm1
movupd (%rcx,%r10,8),%xmm2
mulpd  %xmm0,%xmm1
mulpd  %xmm0,%xmm2
movupd %xmm1,-0x10(%rdx,%r10,8)
movupd %xmm2,(%rdx,%r10,8)
add    $0x8,%r10
add    $0xfffffffffffffffe,%rsi
jne    1330 <build_SPD_Phi+0x200>
testb  $0x1,0x28(%rsp)
je     13b6 <build_SPD_Phi+0x286>
add    %r9,%r10
movupd (%r12,%r10,8),%xmm0
movupd 0x10(%r12,%r10,8),%xmm1
movsd  (%rbx,%r8,8),%xmm2
unpcklpd %xmm2,%xmm2
mulpd  %xmm2,%xmm0
mulpd  %xmm1,%xmm2
movupd %xmm0,(%r15,%r10,8)
movupd %xmm2,0x10(%r15,%r10,8)
mov    0x38(%rsp),%rbp
mov    %rbp,%rsi
cmp    %rax,%rbp
je     1200 <build_SPD_Phi+0xd0>
jmp    1228 <build_SPD_Phi+0xf8>
xor    %esi,%esi
mov    %r11,%r12
mov    0x10(%rsp),%r15
mov    (%rsp),%r13d
mov    0x8(%rsp),%r11
jmp    1228 <build_SPD_Phi+0xf8>
xor    %r10d,%r10d
testb  $0x1,0x28(%rsp)
jne    1387 <build_SPD_Phi+0x257>
jmp    13b6 <build_SPD_Phi+0x286>
sub    $0x8,%rsp
lea    0xc(%rsp),%rcx
lea    0x50(%rsp),%rax
lea    0xc8c(%rip),%rdi
lea    0xc87(%rip),%rsi
lea    0x58(%rsp),%r9
mov    %rcx,%rdx
mov    %rcx,%r8
push   %rcx
push   0x28(%rsp)
push   %rax
push   %rcx
push   %r12
push   %rcx
push   %r15
call   1040 <dgemm_@plt>
add    $0x40,%rsp
mov    %r15,%rdi
call   1030 <free@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lucasb-eyer/OmicABEL/refs/heads/master/src/fgls_chol.c\00"
@.str.1 = [2 x i8] c"N\00"
@.str.2 = [2 x i8] c"T\00"
define void @build_SPD_Phi(i32 %0, double* %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double
%10 = alloca double
%11 = alloca double*
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
store double 1.000000e+00, double* %9
store double 0.000000e+00, double* %10
%14 = load i32, i32* %5
%15 = load i32, i32* %5
%16 = mul nsw i32 %14, %15
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 8
%19 = trunc i64 %18 to i32
%20 = call double* @fgls_malloc_impl(i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str, i64 0, i64 0), i32 427, i32 %19)
store double* %20, double** %11
store i32 0, i32* %13
br label %21
21: ; preds = %58, %4
%22 = load i32, i32* %13
%23 = load i32, i32* %5
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %61
25: ; preds = %21
store i32 0, i32* %12
br label %26
26: ; preds = %54, %25
%27 = load i32, i32* %12
%28 = load i32, i32* %5
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %57
30: ; preds = %26
%31 = load double*, double** %6
%32 = load i32, i32* %13
%33 = load i32, i32* %5
%34 = mul nsw i32 %32, %33
%35 = load i32, i32* %12
%36 = add nsw i32 %34, %35
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %31, i64 %37
%39 = load double, double* %38
%40 = load double*, double** %7
%41 = load i32, i32* %13
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds double, double* %40, i64 %42
%44 = load double, double* %43
%45 = fmul double %39, %44
%46 = load double*, double** %11
%47 = load i32, i32* %13
%48 = load i32, i32* %5
%49 = mul nsw i32 %47, %48
%50 = load i32, i32* %12
%51 = add nsw i32 %49, %50
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds double, double* %46, i64 %52
store double %45, double* %53
br label %54
54: ; preds = %30
%55 = load i32, i32* %12
%56 = add nsw i32 %55, 1
store i32 %56, i32* %12
br label %26
57: ; preds = %26
br label %58
58: ; preds = %57
%59 = load i32, i32* %13
%60 = add nsw i32 %59, 1
store i32 %60, i32* %13
br label %21
61: ; preds = %21
%62 = load double*, double** %11
%63 = load double*, double** %6
%64 = load double*, double** %8
%65 = call i32 @dgemm_(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.2, i64 0, i64 0), i32* %5, i32* %5, i32* %5, double* %9, double* %62, i32* %5, double* %63, i32* %5, double* %10, double* %64, i32* %5)
%66 = load double*, double** %11
%67 = call i32 @free(double* %66)
ret void
}

LLVM IR (-O2):
@.str = [145 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/lucasb-eyer/OmicABEL/refs/heads/master/src/fgls_chol.c\00"
@.str.1 = [2 x i8] c"N\00"
@.str.2 = [2 x i8] c"T\00"
define void @build_SPD_Phi(i32 %0, double* %1, double* nocapture %2, double* %3) {
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store i32 %0, i32* %5
%8 = bitcast double* %6 to i8*
store double 1.000000e+00, double* %6
%9 = bitcast double* %7 to i8*
store double 0.000000e+00, double* %7
%10 = shl i32 %0, 3
%11 = mul i32 %10, %0
%12 = tail call double* @fgls_malloc_impl(i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str, i64 0, i64 0), i32 427, i32 %11)
%13 = icmp sgt i32 %0, 0
br i1 %13, label %14, label %153
14: ; preds = %4
%15 = zext i32 %0 to i64
%16 = zext i32 %0 to i64
%17 = and i64 %16, 4294967292
%18 = add nsw i64 %17, -4
%19 = lshr exact i64 %18, 2
%20 = add nuw nsw i64 %19, 1
%21 = icmp ult i32 %0, 4
%22 = and i64 %16, 4294967292
%23 = and i64 %20, 1
%24 = icmp eq i64 %18, 0
%25 = and i64 %20, 9223372036854775806
%26 = icmp eq i64 %23, 0
%27 = icmp eq i64 %22, %16
%28 = and i64 %16, 1
%29 = icmp eq i64 %28, 0
%30 = sub nsw i64 0, %16
br label %31
31: ; preds = %150, %14
%32 = phi i64 [ 0, %14 ], [ %151, %150 ]
%33 = mul i64 %32, %16
%34 = getelementptr double, double* %12, i64 %33
%35 = add i64 %33, %16
%36 = getelementptr double, double* %12, i64 %35
%37 = mul nsw i64 %32, %15
%38 = getelementptr inbounds double, double* %2, i64 %32
br i1 %21, label %119, label %39
39: ; preds = %31
%40 = add nuw i64 %32, 1
%41 = getelementptr double, double* %2, i64 %40
%42 = getelementptr double, double* %2, i64 %32
%43 = getelementptr double, double* %1, i64 %35
%44 = getelementptr double, double* %1, i64 %33
%45 = icmp ult double* %34, %43
%46 = icmp ult double* %44, %36
%47 = and i1 %45, %46
%48 = icmp ult double* %34, %41
%49 = icmp ult double* %42, %36
%50 = and i1 %48, %49
%51 = or i1 %47, %50
br i1 %51, label %119, label %52
52: ; preds = %39
br i1 %24, label %97, label %53
53: ; preds = %52
%54 = load double, double* %38
%55 = insertelement <2 x double> poison, double %54, i64 0
%56 = shufflevector <2 x double> %55, <2 x double> poison, <2 x i32> zeroinitializer
%57 = insertelement <2 x double> poison, double %54, i64 0
%58 = shufflevector <2 x double> %57, <2 x double> poison, <2 x i32> zeroinitializer
%59 = load double, double* %38
%60 = insertelement <2 x double> poison, double %59, i64 0
%61 = shufflevector <2 x double> %60, <2 x double> poison, <2 x i32> zeroinitializer
%62 = insertelement <2 x double> poison, double %59, i64 0
%63 = shufflevector <2 x double> %62, <2 x double> poison, <2 x i32> zeroinitializer
br label %64
64: ; preds = %64, %53
%65 = phi i64 [ 0, %53 ], [ %94, %64 ]
%66 = phi i64 [ 0, %53 ], [ %95, %64 ]
%67 = add nuw nsw i64 %65, %37
%68 = getelementptr inbounds double, double* %1, i64 %67
%69 = bitcast double* %68 to <2 x double>*
%70 = load <2 x double>, <2 x double>* %69
%71 = getelementptr inbounds double, double* %68, i64 2
%72 = bitcast double* %71 to <2 x double>*
%73 = load <2 x double>, <2 x double>* %72
%74 = fmul <2 x double> %70, %56
%75 = fmul <2 x double> %73, %58
%76 = getelementptr inbounds double, double* %12, i64 %67
%77 = bitcast double* %76 to <2 x double>*
store <2 x double> %74, <2 x double>* %77
%78 = getelementptr inbounds double, double* %76, i64 2
%79 = bitcast double* %78 to <2 x double>*
store <2 x double> %75, <2 x double>* %79
%80 = or i64 %65, 4
%81 = add nuw nsw i64 %80, %37
%82 = getelementptr inbounds double, double* %1, i64 %81
%83 = bitcast double* %82 to <2 x double>*
%84 = load <2 x double>, <2 x double>* %83
%85 = getelementptr inbounds double, double* %82, i64 2
%86 = bitcast double* %85 to <2 x double>*
%87 = load <2 x double>, <2 x double>* %86
%88 = fmul <2 x double> %84, %61
%89 = fmul <2 x double> %87, %63
%90 = getelementptr inbounds double, double* %12, i64 %81
%91 = bitcast double* %90 to <2 x double>*
store <2 x double> %88, <2 x double>* %91
%92 = getelementptr inbounds double, double* %90, i64 2
%93 = bitcast double* %92 to <2 x double>*
store <2 x double> %89, <2 x double>* %93
%94 = add nuw i64 %65, 8
%95 = add i64 %66, 2
%96 = icmp eq i64 %95, %25
br i1 %96, label %97, label %64
97: ; preds = %64, %52
%98 = phi i64 [ 0, %52 ], [ %94, %64 ]
br i1 %26, label %118, label %99
99: ; preds = %97
%100 = add nuw nsw i64 %98, %37
%101 = getelementptr inbounds double, double* %1, i64 %100
%102 = bitcast double* %101 to <2 x double>*
%103 = load <2 x double>, <2 x double>* %102
%104 = getelementptr inbounds double, double* %101, i64 2
%105 = bitcast double* %104 to <2 x double>*
%106 = load <2 x double>, <2 x double>* %105
%107 = load double, double* %38
%108 = insertelement <2 x double> poison, double %107, i64 0
%109 = shufflevector <2 x double> %108, <2 x double> poison, <2 x i32> zeroinitializer
%110 = insertelement <2 x double> poison, double %107, i64 0
%111 = shufflevector <2 x double> %110, <2 x double> poison, <2 x i32> zeroinitializer
%112 = fmul <2 x double> %103, %109
%113 = fmul <2 x double> %106, %111
%114 = getelementptr inbounds double, double* %12, i64 %100
%115 = bitcast double* %114 to <2 x double>*
store <2 x double> %112, <2 x double>* %115
%116 = getelementptr inbounds double, double* %114, i64 2
%117 = bitcast double* %116 to <2 x double>*
store <2 x double> %113, <2 x double>* %117
br label %118
118: ; preds = %97, %99
br i1 %27, label %150, label %119
119: ; preds = %39, %31, %118
%120 = phi i64 [ 0, %39 ], [ 0, %31 ], [ %22, %118 ]
%121 = xor i64 %120, -1
br i1 %29, label %130, label %122
122: ; preds = %119
%123 = add nuw nsw i64 %120, %37
%124 = getelementptr inbounds double, double* %1, i64 %123
%125 = load double, double* %124
%126 = load double, double* %38
%127 = fmul double %125, %126
%128 = getelementptr inbounds double, double* %12, i64 %123
store double %127, double* %128
%129 = or i64 %120, 1
br label %130
130: ; preds = %122, %119
%131 = phi i64 [ %120, %119 ], [ %129, %122 ]
%132 = icmp eq i64 %121, %30
br i1 %132, label %150, label %133
133: ; preds = %130, %133
%134 = phi i64 [ %148, %133 ], [ %131, %130 ]
%135 = add nuw nsw i64 %134, %37
%136 = getelementptr inbounds double, double* %1, i64 %135
%137 = load double, double* %136
%138 = load double, double* %38
%139 = fmul double %137, %138
%140 = getelementptr inbounds double, double* %12, i64 %135
store double %139, double* %140
%141 = add nuw nsw i64 %134, 1
%142 = add nuw nsw i64 %141, %37
%143 = getelementptr inbounds double, double* %1, i64 %142
%144 = load double, double* %143
%145 = load double, double* %38
%146 = fmul double %144, %145
%147 = getelementptr inbounds double, double* %12, i64 %142
store double %146, double* %147
%148 = add nuw nsw i64 %134, 2
%149 = icmp eq i64 %148, %16
br i1 %149, label %150, label %133
150: ; preds = %130, %133, %118
%151 = add nuw nsw i64 %32, 1
%152 = icmp eq i64 %151, %16
br i1 %152, label %153, label %31
153: ; preds = %150, %4
%154 = call i32 @dgemm_(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.2, i64 0, i64 0), i32* %5, i32* %5, i32* %5, double* %6, double* %12, i32* %5, double* %1, i32* %5, double* %7, double* %3, i32* %5)
%155 = call i32 @free(double* %12)
ret void
}