#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*/ chol3(double *, double **);
void makeChol3(double dest[], const double *src) {
  int i, j;
  unsigned cnt = 0;
  double tmp_corr[3][3] = {0};
  for (i = 0; i < 3; i++) {
    for (j = 0; j <= i; j++) {
      if (i == j) {
        tmp_corr[j][i] = 1.0;
      } else {
        tmp_corr[j][i] = src[cnt++];
        tmp_corr[i][j] = tmp_corr[j][i];
      }
    }
  }
  chol3(dest, tmp_corr);
}


x86 assembly (clang, -O0):
<makeChol3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x48,%edx
call   1030 <memset@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1220 <makeChol3+0x100>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     120d <makeChol3+0xed>
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    119c <makeChol3+0x7c>
movslq -0x18(%rbp),%rcx
lea    -0x70(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movsd  0xe6e(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    11fa <makeChol3+0xda>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
mov    %ecx,%ecx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x18(%rbp),%rcx
lea    -0x70(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movslq -0x18(%rbp),%rcx
lea    -0x70(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x14(%rbp),%rcx
lea    -0x70(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    11ff <makeChol3+0xdf>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115f <makeChol3+0x3f>
jmp    1212 <makeChol3+0xf2>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114e <makeChol3+0x2e>
mov    -0x8(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1040 <chol3@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeChol3>:
sub    $0x48,%rsp
movabs $0x3ff0000000000000,%rax
mov    %rax,(%rsp)
movups (%rsi),%xmm0
movlps %xmm0,0x18(%rsp)
mov    %rax,0x20(%rsp)
movhps %xmm0,0x30(%rsp)
movups %xmm0,0x8(%rsp)
movsd  0x10(%rsi),%xmm0
movsd  %xmm0,0x38(%rsp)
movsd  %xmm0,0x28(%rsp)
mov    %rax,0x40(%rsp)
mov    %rsp,%rsi
call   1030 <chol3@plt>
add    $0x48,%rsp
ret

LLVM IR (-O0):
define void @makeChol3(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [3 x [3 x double]]
store double* %0, double** %3
store double* %1, double** %4
store i32 0, i32* %7
%9 = bitcast [3 x [3 x double]]* %8 to i8*
store i32 0, i32* %5
br label %10
10: ; preds = %60, %2
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %63
13: ; preds = %10
store i32 0, i32* %6
br label %14
14: ; preds = %56, %13
%15 = load i32, i32* %6
%16 = load i32, i32* %5
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %59
18: ; preds = %14
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %29
22: ; preds = %18
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 %24
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [3 x double], [3 x double]* %25, i64 0, i64 %27
store double 1.000000e+00, double* %28
br label %55
29: ; preds = %18
%30 = load double*, double** %4
%31 = load i32, i32* %7
%32 = add i32 %31, 1
store i32 %32, i32* %7
%33 = zext i32 %31 to i64
%34 = getelementptr inbounds double, double* %30, i64 %33
%35 = load double, double* %34
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 %37
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [3 x double], [3 x double]* %38, i64 0, i64 %40
store double %35, double* %41
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 %43
%45 = load i32, i32* %5
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [3 x double], [3 x double]* %44, i64 0, i64 %46
%48 = load double, double* %47
%49 = load i32, i32* %5
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 %50
%52 = load i32, i32* %6
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [3 x double], [3 x double]* %51, i64 0, i64 %53
store double %48, double* %54
br label %55
55: ; preds = %29, %22
br label %56
56: ; preds = %55
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
br label %14
59: ; preds = %14
br label %60
60: ; preds = %59
%61 = load i32, i32* %5
%62 = add nsw i32 %61, 1
store i32 %62, i32* %5
br label %10
63: ; preds = %10
%64 = load double*, double** %3
%65 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 0
%66 = bitcast [3 x double]* %65 to double**
%67 = call i32 @chol3(double* %64, double** %66)
ret void
}

LLVM IR (-O2):
define void @makeChol3(double* %0, double* nocapture %1) {
%3 = alloca [3 x [3 x double]]
%4 = bitcast [3 x [3 x double]]* %3 to i8*
%5 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %3, i64 0, i64 0, i64 0
store double 1.000000e+00, double* %5
%6 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %3, i64 0, i64 1, i64 0
%7 = bitcast double* %1 to <2 x double>*
%8 = load <2 x double>, <2 x double>* %7
%9 = extractelement <2 x double> %8, i64 0
store double %9, double* %6
%10 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %3, i64 0, i64 0, i64 1
%11 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %3, i64 0, i64 1, i64 1
store double 1.000000e+00, double* %11
%12 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %3, i64 0, i64 2, i64 0
%13 = extractelement <2 x double> %8, i64 1
store double %13, double* %12
%14 = bitcast double* %10 to <2 x double>*
store <2 x double> %8, <2 x double>* %14
%15 = getelementptr inbounds double, double* %1, i64 2
%16 = load double, double* %15
%17 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %3, i64 0, i64 2, i64 1
store double %16, double* %17
%18 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %3, i64 0, i64 1, i64 2
store double %16, double* %18
%19 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %3, i64 0, i64 2, i64 2
store double 1.000000e+00, double* %19
%20 = bitcast [3 x [3 x double]]* %3 to double**
%21 = call i32 @chol3(double* %0, double** %20)
ret void
}