#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*/ jacobi_decompose(double **, double *, double **);
double sqrt(double);
void set_eig(double input[][3], double *res) {
  double output[3][3];
  double eigs[3];
  jacobi_decompose(input, eigs, output);
  *res = eigs[0];
  if (eigs[1] < *res)
    *res = eigs[1];
  if (eigs[2] < *res)
    *res = eigs[2];
  if (*res <= 0)
    *res = sqrt(input[0][0] + input[1][1] + input[2][2]);
  else {
    *res = sqrt(*res);
  }
}


x86 assembly (clang, -O0):
<set_eig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x80(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1030 <jacobi_decompose@plt>
movsd  -0x80(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x78(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    1175 <set_eig+0x55>
movsd  -0x78(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x70(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    1199 <set_eig+0x79>
movsd  -0x70(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jb     11d6 <set_eig+0xb6>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x20(%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x40(%rax),%xmm0
call   1040 <sqrt@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11eb <set_eig+0xcb>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <sqrt@plt>
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_eig>:
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rsi
lea    0x20(%rsp),%rdx
call   1030 <jacobi_decompose@plt>
movsd  (%rsp),%xmm0
movsd  %xmm0,(%r14)
movsd  0x8(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jbe    1159 <set_eig+0x39>
movsd  %xmm1,(%r14)
movapd %xmm1,%xmm0
movsd  0x10(%rsp),%xmm1
ucomisd %xmm1,%xmm0
jbe    116e <set_eig+0x4e>
movsd  %xmm1,(%r14)
movapd %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jb     1186 <set_eig+0x66>
movsd  (%rbx),%xmm0
addsd  0x20(%rbx),%xmm0
addsd  0x40(%rbx),%xmm0
ucomisd %xmm1,%xmm0
jb     1192 <set_eig+0x72>
sqrtsd %xmm0,%xmm0
jmp    1197 <set_eig+0x77>
call   1040 <sqrt@plt>
movsd  %xmm0,(%r14)
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @set_eig([3 x double]* %0, double* %1) {
%3 = alloca [3 x double]*
%4 = alloca double*
%5 = alloca [3 x [3 x double]]
%6 = alloca [3 x double]
store [3 x double]* %0, [3 x double]** %3
store double* %1, double** %4
%7 = load [3 x double]*, [3 x double]** %3
%8 = bitcast [3 x double]* %7 to double**
%9 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%10 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %5, i64 0, i64 0
%11 = bitcast [3 x double]* %10 to double**
%12 = call i32 @jacobi_decompose(double** %8, double* %9, double** %11)
%13 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%14 = load double, double* %13
%15 = load double*, double** %4
store double %14, double* %15
%16 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 1
%17 = load double, double* %16
%18 = load double*, double** %4
%19 = load double, double* %18
%20 = fcmp olt double %17, %19
br i1 %20, label %21, label %25
21: ; preds = %2
%22 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 1
%23 = load double, double* %22
%24 = load double*, double** %4
store double %23, double* %24
br label %25
25: ; preds = %21, %2
%26 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
%27 = load double, double* %26
%28 = load double*, double** %4
%29 = load double, double* %28
%30 = fcmp olt double %27, %29
br i1 %30, label %31, label %35
31: ; preds = %25
%32 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
%33 = load double, double* %32
%34 = load double*, double** %4
store double %33, double* %34
br label %35
35: ; preds = %31, %25
%36 = load double*, double** %4
%37 = load double, double* %36
%38 = fcmp ole double %37, 0.000000e+00
br i1 %38, label %39, label %56
39: ; preds = %35
%40 = load [3 x double]*, [3 x double]** %3
%41 = getelementptr inbounds [3 x double], [3 x double]* %40, i64 0
%42 = getelementptr inbounds [3 x double], [3 x double]* %41, i64 0, i64 0
%43 = load double, double* %42
%44 = load [3 x double]*, [3 x double]** %3
%45 = getelementptr inbounds [3 x double], [3 x double]* %44, i64 1
%46 = getelementptr inbounds [3 x double], [3 x double]* %45, i64 0, i64 1
%47 = load double, double* %46
%48 = fadd double %43, %47
%49 = load [3 x double]*, [3 x double]** %3
%50 = getelementptr inbounds [3 x double], [3 x double]* %49, i64 2
%51 = getelementptr inbounds [3 x double], [3 x double]* %50, i64 0, i64 2
%52 = load double, double* %51
%53 = fadd double %48, %52
%54 = call double @sqrt(double %53)
%55 = load double*, double** %4
store double %54, double* %55
br label %61
56: ; preds = %35
%57 = load double*, double** %4
%58 = load double, double* %57
%59 = call double @sqrt(double %58)
%60 = load double*, double** %4
store double %59, double* %60
br label %61
61: ; preds = %56, %39
ret void
}

LLVM IR (-O2):
define void @set_eig([3 x double]* %0, double* nocapture %1) {
%3 = alloca [3 x [3 x double]]
%4 = alloca [3 x double]
%5 = bitcast [3 x [3 x double]]* %3 to i8*
%6 = bitcast [3 x double]* %4 to i8*
%7 = bitcast [3 x double]* %0 to double**
%8 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%9 = bitcast [3 x [3 x double]]* %3 to double**
%10 = call i32 @jacobi_decompose(double** %7, double* %8, double** %9)
%11 = load double, double* %8
store double %11, double* %1
%12 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
%13 = load double, double* %12
%14 = fcmp olt double %13, %11
br i1 %14, label %15, label %16
15: ; preds = %2
store double %13, double* %1
br label %16
16: ; preds = %15, %2
%17 = phi double [ %13, %15 ], [ %11, %2 ]
%18 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
%19 = load double, double* %18
%20 = fcmp olt double %19, %17
br i1 %20, label %21, label %22
21: ; preds = %16
store double %19, double* %1
br label %22
22: ; preds = %21, %16
%23 = phi double [ %19, %21 ], [ %17, %16 ]
%24 = fcmp ugt double %23, 0.000000e+00
br i1 %24, label %34, label %25
25: ; preds = %22
%26 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 0, i64 0
%27 = load double, double* %26
%28 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 1, i64 1
%29 = load double, double* %28
%30 = fadd double %27, %29
%31 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 2, i64 2
%32 = load double, double* %31
%33 = fadd double %30, %32
br label %34
34: ; preds = %22, %25
%35 = phi double [ %33, %25 ], [ %23, %22 ]
%36 = call double @sqrt(double %35)
store double %36, double* %1
ret void
}