#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 */
typedef int int64_t;

/* Variables and functions */
int /*<<< orphan*/ set_eig(double **, double *);
void calc_deviations(double corr[][6], double *sig_x, double *sig_v) {
  double input[3][3];
  int64_t i, j;
  for (i = 0; i < 6; i++)
    for (j = 0; j < i; j++)
      corr[i][j] = corr[j][i];
  for (i = 0; i < 3; i++)
    for (j = 0; j < 3; j++)
      input[i][j] = corr[i][j];
  set_eig(input, sig_x);
  for (i = 3; i < 6; i++)
    for (j = 3; j < 6; j++)
      input[i - 3][j - 3] = corr[i][j];
  set_eig(input, sig_v);
}


x86 assembly (clang, -O0):
<calc_deviations>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x64(%rbp)
cmpl   $0x6,-0x64(%rbp)
jge    1199 <calc_deviations+0x89>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    1186 <calc_deviations+0x76>
mov    -0x8(%rbp),%rax
movslq -0x68(%rbp),%rcx
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movslq -0x64(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x64(%rbp),%rcx
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movslq -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    113c <calc_deviations+0x2c>
jmp    118b <calc_deviations+0x7b>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    112b <calc_deviations+0x1b>
movl   $0x0,-0x64(%rbp)
cmpl   $0x3,-0x64(%rbp)
jge    120c <calc_deviations+0xfc>
movl   $0x0,-0x68(%rbp)
cmpl   $0x3,-0x68(%rbp)
jge    11f9 <calc_deviations+0xe9>
mov    -0x8(%rbp),%rax
movslq -0x64(%rbp),%rcx
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x64(%rbp),%rcx
lea    -0x60(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    11b1 <calc_deviations+0xa1>
jmp    11fe <calc_deviations+0xee>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11a0 <calc_deviations+0x90>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <set_eig@plt>
movl   $0x3,-0x64(%rbp)
cmpl   $0x6,-0x64(%rbp)
jge    1296 <calc_deviations+0x186>
movl   $0x3,-0x68(%rbp)
cmpl   $0x6,-0x68(%rbp)
jge    1283 <calc_deviations+0x173>
mov    -0x8(%rbp),%rax
movslq -0x64(%rbp),%rcx
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x64(%rbp),%eax
sub    $0x3,%eax
movslq %eax,%rcx
lea    -0x60(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
mov    -0x68(%rbp),%ecx
sub    $0x3,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1231 <calc_deviations+0x121>
jmp    1288 <calc_deviations+0x178>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1220 <calc_deviations+0x110>
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <set_eig@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_deviations>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rdx,%r14
mov    %rdi,%rbx
movsd  0x8(%rdi),%xmm0
movsd  0x10(%rdi),%xmm1
movsd  %xmm0,0x30(%rdi)
movsd  %xmm1,0x60(%rdi)
movsd  0x40(%rdi),%xmm0
movsd  %xmm0,0x68(%rdi)
movsd  0x18(%rdi),%xmm0
movsd  %xmm0,0x90(%rdi)
movsd  0x48(%rdi),%xmm0
movsd  %xmm0,0x98(%rdi)
movsd  0x78(%rdi),%xmm0
movsd  %xmm0,0xa0(%rdi)
movsd  0x20(%rdi),%xmm0
movsd  %xmm0,0xc0(%rdi)
movsd  0x50(%rdi),%xmm0
movsd  %xmm0,0xc8(%rdi)
movsd  0x80(%rdi),%xmm0
movsd  %xmm0,0xd0(%rdi)
movsd  0xb0(%rdi),%xmm0
movsd  %xmm0,0xd8(%rdi)
movsd  0x28(%rdi),%xmm0
movsd  %xmm0,0xf0(%rdi)
movsd  0x58(%rdi),%xmm0
movsd  %xmm0,0xf8(%rdi)
movsd  0x88(%rdi),%xmm0
movsd  %xmm0,0x100(%rdi)
movsd  0xb8(%rdi),%xmm0
movsd  %xmm0,0x108(%rdi)
movsd  0xe8(%rdi),%xmm0
movsd  %xmm0,0x110(%rdi)
mov    0x10(%rdi),%rax
mov    %rax,0x10(%rsp)
movups (%rdi),%xmm0
movaps %xmm0,(%rsp)
movups 0x30(%rdi),%xmm0
movups %xmm0,0x18(%rsp)
mov    0x40(%rdi),%rax
mov    %rax,0x28(%rsp)
movups 0x60(%rdi),%xmm0
movaps %xmm0,0x30(%rsp)
mov    0x70(%rdi),%rax
mov    %rax,0x40(%rsp)
mov    %rsp,%r15
mov    %r15,%rdi
call   1030 <set_eig@plt>
mov    0xb8(%rbx),%rax
mov    %rax,0x10(%rsp)
movups 0xa8(%rbx),%xmm0
movaps %xmm0,(%rsp)
mov    0xe8(%rbx),%rax
mov    %rax,0x28(%rsp)
movups 0xd8(%rbx),%xmm0
movups %xmm0,0x18(%rsp)
mov    0x118(%rbx),%rax
mov    %rax,0x40(%rsp)
movups 0x108(%rbx),%xmm0
movaps %xmm0,0x30(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <set_eig@plt>
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @calc_deviations([6 x double]* nocapture %0, double* %1, double* %2) {
%4 = alloca [3 x [3 x double]]
%5 = bitcast [3 x [3 x double]]* %4 to i8*
%6 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 0, i64 1
%7 = load double, double* %6
%8 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 1, i64 0
store double %7, double* %8
%9 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 0, i64 2
%10 = load double, double* %9
%11 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 2, i64 0
store double %10, double* %11
%12 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 1, i64 2
%13 = load double, double* %12
%14 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 2, i64 1
store double %13, double* %14
%15 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 0, i64 3
%16 = load double, double* %15
%17 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 3, i64 0
store double %16, double* %17
%18 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 1, i64 3
%19 = load double, double* %18
%20 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 3, i64 1
store double %19, double* %20
%21 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 2, i64 3
%22 = load double, double* %21
%23 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 3, i64 2
store double %22, double* %23
%24 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 0, i64 4
%25 = load double, double* %24
%26 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 4, i64 0
store double %25, double* %26
%27 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 1, i64 4
%28 = load double, double* %27
%29 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 4, i64 1
store double %28, double* %29
%30 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 2, i64 4
%31 = load double, double* %30
%32 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 4, i64 2
store double %31, double* %32
%33 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 3, i64 4
%34 = load double, double* %33
%35 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 4, i64 3
store double %34, double* %35
%36 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 0, i64 5
%37 = load double, double* %36
%38 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 5, i64 0
store double %37, double* %38
%39 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 1, i64 5
%40 = load double, double* %39
%41 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 5, i64 1
store double %40, double* %41
%42 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 2, i64 5
%43 = load double, double* %42
%44 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 5, i64 2
store double %43, double* %44
%45 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 3, i64 5
%46 = load double, double* %45
%47 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 5, i64 3
store double %46, double* %47
%48 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 4, i64 5
%49 = load double, double* %48
%50 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 5, i64 4
store double %49, double* %50
%51 = bitcast [3 x [3 x double]]* %4 to i8*
%52 = bitcast [6 x double]* %0 to i8*
%53 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %4, i64 0, i64 1, i64 0
%54 = bitcast double* %53 to i8*
%55 = getelementptr [6 x double], [6 x double]* %0, i64 1, i64 0
%56 = bitcast double* %55 to i8*
%57 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %4, i64 0, i64 2, i64 0
%58 = bitcast double* %57 to i8*
%59 = getelementptr [6 x double], [6 x double]* %0, i64 2, i64 0
%60 = bitcast double* %59 to i8*
%61 = bitcast [3 x [3 x double]]* %4 to double**
%62 = call i32 @set_eig(double** %61, double* %1)
%63 = getelementptr [6 x double], [6 x double]* %0, i64 3, i64 3
%64 = bitcast double* %63 to i8*
%65 = getelementptr [6 x double], [6 x double]* %0, i64 4, i64 3
%66 = bitcast double* %65 to i8*
%67 = getelementptr [6 x double], [6 x double]* %0, i64 5, i64 3
%68 = bitcast double* %67 to i8*
%69 = call i32 @set_eig(double** %61, double* %2)
ret void
}