#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*/ get_rot_matrix(double **, double, double, double);
char similar_eulers(double a1, double a2, double a3, double b1, double b2,
                    double b3) {
  double deviation_cosine;
  double trace;
  double matrix1[3][3], matrix2[3][3];
  int i, j;
  get_rot_matrix(matrix2, a1, a2, a3);
  get_rot_matrix(matrix1, b1, b2, b3);
  trace = 0;
  for (i = 0; i < 3; ++i)
    for (j = 0; j < 3; ++j)
      trace += matrix2[i][j] * matrix1[i][j];
  deviation_cosine = (trace - 1.0) / 2.0;
  if (deviation_cosine <= 0.9998477)
    return 0;
  else
    return 1;
}


x86 assembly (clang, -O0):
<similar_eulers>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
movsd  %xmm4,-0x30(%rbp)
movsd  %xmm5,-0x38(%rbp)
lea    -0xe0(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1030 <get_rot_matrix@plt>
lea    -0x90(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
call   1030 <get_rot_matrix@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0xe4(%rbp)
cmpl   $0x3,-0xe4(%rbp)
jge    1226 <similar_eulers+0x116>
movl   $0x0,-0xe8(%rbp)
cmpl   $0x3,-0xe8(%rbp)
jge    120d <similar_eulers+0xfd>
movslq -0xe4(%rbp),%rcx
lea    -0xe0(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0xe8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0xe4(%rbp),%rcx
lea    -0x90(%rbp),%rax
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0xe8(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    1198 <similar_eulers+0x88>
jmp    1212 <similar_eulers+0x102>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1181 <similar_eulers+0x71>
movsd  -0x48(%rbp),%xmm0
movsd  0xddd(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xdc9(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xdb0(%rip),%xmm0
ucomisd -0x40(%rbp),%xmm0
jb     1264 <similar_eulers+0x154>
movb   $0x0,-0x1(%rbp)
jmp    1268 <similar_eulers+0x158>
movb   $0x1,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<similar_eulers>:
sub    $0xb8,%rsp
movsd  %xmm5,0x18(%rsp)
movsd  %xmm4,0x10(%rsp)
movsd  %xmm3,0x8(%rsp)
lea    0x20(%rsp),%rdi
call   1030 <get_rot_matrix@plt>
lea    0x70(%rsp),%rdi
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
call   1030 <get_rot_matrix@plt>
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
mulsd  0x70(%rsp),%xmm0
xorpd  %xmm2,%xmm2
addsd  %xmm0,%xmm2
mulsd  0x78(%rsp),%xmm1
addsd  %xmm2,%xmm1
movsd  0x30(%rsp),%xmm0
mulsd  0x80(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  0x38(%rsp),%xmm1
mulsd  0x88(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  0x40(%rsp),%xmm0
mulsd  0x90(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  0x48(%rsp),%xmm1
mulsd  0x98(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  0x50(%rsp),%xmm0
mulsd  0xa0(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  0x58(%rsp),%xmm1
mulsd  0xa8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  0x60(%rsp),%xmm0
mulsd  0xb0(%rsp),%xmm0
addsd  %xmm1,%xmm0
addsd  0xe00(%rip),%xmm0
mulsd  0xe00(%rip),%xmm0
movsd  0xe00(%rip),%xmm1
ucomisd %xmm0,%xmm1
setb   %al
add    $0xb8,%rsp
ret

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

LLVM IR (-O2):
define signext i8 @similar_eulers(double %0, double %1, double %2, double %3, double %4, double %5) {
%7 = alloca [3 x [3 x double]]
%8 = alloca [3 x [3 x double]]
%9 = bitcast [3 x [3 x double]]* %7 to i8*
%10 = bitcast [3 x [3 x double]]* %8 to i8*
%11 = bitcast [3 x [3 x double]]* %8 to double**
%12 = call i32 @get_rot_matrix(double** %11, double %0, double %1, double %2)
%13 = bitcast [3 x [3 x double]]* %7 to double**
%14 = call i32 @get_rot_matrix(double** %13, double %3, double %4, double %5)
%15 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 0, i64 0
%16 = load double, double* %15
%17 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 0, i64 0
%18 = load double, double* %17
%19 = call double @llvm.fmuladd.f64(double %16, double %18, double 0.000000e+00)
%20 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 0, i64 1
%21 = load double, double* %20
%22 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 0, i64 1
%23 = load double, double* %22
%24 = call double @llvm.fmuladd.f64(double %21, double %23, double %19)
%25 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 0, i64 2
%26 = load double, double* %25
%27 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 0, i64 2
%28 = load double, double* %27
%29 = call double @llvm.fmuladd.f64(double %26, double %28, double %24)
%30 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 1, i64 0
%31 = load double, double* %30
%32 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 1, i64 0
%33 = load double, double* %32
%34 = call double @llvm.fmuladd.f64(double %31, double %33, double %29)
%35 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 1, i64 1
%36 = load double, double* %35
%37 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 1, i64 1
%38 = load double, double* %37
%39 = call double @llvm.fmuladd.f64(double %36, double %38, double %34)
%40 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 1, i64 2
%41 = load double, double* %40
%42 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 1, i64 2
%43 = load double, double* %42
%44 = call double @llvm.fmuladd.f64(double %41, double %43, double %39)
%45 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 2, i64 0
%46 = load double, double* %45
%47 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 2, i64 0
%48 = load double, double* %47
%49 = call double @llvm.fmuladd.f64(double %46, double %48, double %44)
%50 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 2, i64 1
%51 = load double, double* %50
%52 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 2, i64 1
%53 = load double, double* %52
%54 = call double @llvm.fmuladd.f64(double %51, double %53, double %49)
%55 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %8, i64 0, i64 2, i64 2
%56 = load double, double* %55
%57 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %7, i64 0, i64 2, i64 2
%58 = load double, double* %57
%59 = call double @llvm.fmuladd.f64(double %56, double %58, double %54)
%60 = fadd double %59, -1.000000e+00
%61 = fmul double %60, 5.000000e-01
%62 = fcmp ugt double %61, 0x3FEFFEC09A8F62DF
%63 = zext i1 %62 to i8
ret i8 %63
}