#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 */
double acos(double);
double sqrt(double);
double get_angle(double metric[3][3], const int i, const int j) {
  double length_i, length_j;
  length_i = sqrt(metric[i][i]);
  length_j = sqrt(metric[j][j]);
  return acos(metric[i][j] / length_i / length_j) / 3.14159265358979323846 *
         180;
}


x86 assembly (clang, -O0):
<get_angle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0xc(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
divsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
call   1030 <acos@plt>
movsd  0xe63(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe4f(%rip),%xmm1
mulsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_angle>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rdi,%rbx
movslq %esi,%rax
lea    (%rax,%rax,2),%rcx
lea    (%rdi,%rcx,8),%r15
movsd  (%r15,%rax,8),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     114e <get_angle+0x2e>
sqrtsd %xmm0,%xmm2
jmp    115b <get_angle+0x3b>
call   1040 <sqrt@plt>
xorpd  %xmm1,%xmm1
movapd %xmm0,%xmm2
movslq %r14d,%rbp
lea    0x0(,%rbp,2),%rax
add    %rbp,%rax
lea    (%rbx,%rax,8),%rax
movsd  (%rax,%rbp,8),%xmm0
ucomisd %xmm1,%xmm0
jb     117e <get_angle+0x5e>
sqrtsd %xmm0,%xmm0
jmp    118d <get_angle+0x6d>
movsd  %xmm2,(%rsp)
call   1040 <sqrt@plt>
movsd  (%rsp),%xmm2
movsd  (%r15,%rbp,8),%xmm1
divsd  %xmm2,%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
call   1030 <acos@plt>
divsd  0xe54(%rip),%xmm0
mulsd  0xe54(%rip),%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @get_angle([3 x double]* %0, i32 %1, i32 %2) {
%4 = alloca [3 x double]*
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
store [3 x double]* %0, [3 x double]** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load [3 x double]*, [3 x double]** %4
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 %11
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 %14
%16 = load double, double* %15
%17 = call double @sqrt(double %16)
store double %17, double* %7
%18 = load [3 x double]*, [3 x double]** %4
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [3 x double], [3 x double]* %18, i64 %20
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [3 x double], [3 x double]* %21, i64 0, i64 %23
%25 = load double, double* %24
%26 = call double @sqrt(double %25)
store double %26, double* %8
%27 = load [3 x double]*, [3 x double]** %4
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [3 x double], [3 x double]* %27, i64 %29
%31 = load i32, i32* %6
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [3 x double], [3 x double]* %30, i64 0, i64 %32
%34 = load double, double* %33
%35 = load double, double* %7
%36 = fdiv double %34, %35
%37 = load double, double* %8
%38 = fdiv double %36, %37
%39 = call double @acos(double %38)
%40 = fdiv double %39, 0x400921FB54442D18
%41 = fmul double %40, 1.800000e+02
ret double %41
}

LLVM IR (-O2):
define double @get_angle([3 x double]* nocapture %0, i32 %1, i32 %2) {
%4 = sext i32 %1 to i64
%5 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %4, i64 %4
%6 = load double, double* %5
%7 = tail call double @sqrt(double %6)
%8 = sext i32 %2 to i64
%9 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %8, i64 %8
%10 = load double, double* %9
%11 = tail call double @sqrt(double %10)
%12 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %4, i64 %8
%13 = load double, double* %12
%14 = fdiv double %13, %7
%15 = fdiv double %14, %11
%16 = tail call double @acos(double %15)
%17 = fdiv double %16, 0x400921FB54442D18
%18 = fmul double %17, 1.800000e+02
ret double %18
}