#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*/ c_bnd_len(double *, double *, double *);
int /*<<< orphan*/ c_dih_ang(double *, double *, double *, double *, double *);
int /*<<< orphan*/ matmul(double **, double *, double *);
int /*<<< orphan*/ quaternion(double *, double, double *);
int /*<<< orphan*/ rotation_matrix(double *, double **);
void get_rot(double obj_i[3], double obj_f[3], double tor1[3], double tor2[3],
             double tor3[3], double tor4_i[3], double tor4_f[3]) {
  double Us[3][3], p[4];
  double vec_rot[3], mat1[3], mat11[3];
  double angle, ang_i, ang_f, vec_len;
  int i;
  c_dih_ang(tor1, tor2, tor3, tor4_i, &ang_i);
  c_dih_ang(tor1, tor2, tor3, tor4_f, &ang_f);
  angle = (ang_f - ang_i) * 0.25;
  c_bnd_len(tor2, tor3, &vec_len);
  for (i = 0; i < 3; i++)
    vec_rot[i] = (tor3[i] - tor2[i]) / vec_len;
  quaternion(vec_rot, angle, p);
  rotation_matrix(p, Us);
  for (i = 0; i < 3; i++)
    mat11[i] = obj_i[i] - tor3[i];
  matmul(Us, mat11, mat1);
  for (i = 0; i < 3; i++)
    obj_f[i] = mat1[i] + tor3[i];
  return;
}


x86 assembly (clang, -O0):
<get_rot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
lea    -0x110(%rbp),%r8
call   1060 <c_dih_ang@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    0x10(%rbp),%rcx
lea    -0x118(%rbp),%r8
call   1060 <c_dih_ang@plt>
movsd  -0x118(%rbp),%xmm0
ff
subsd  -0x110(%rbp),%xmm0
ff
movsd  0xe39(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x108(%rbp)
ff
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x120(%rbp),%rdx
call   1070 <c_bnd_len@plt>
movl   $0x0,-0x124(%rbp)
cmpl   $0x3,-0x124(%rbp)
jge    124a <get_rot+0xfa>
mov    -0x28(%rbp),%rax
movslq -0x124(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x124(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
divsd  -0x120(%rbp),%xmm0
ff
movslq -0x124(%rbp),%rax
movsd  %xmm0,-0xc0(%rbp,%rax,8)
ff ff
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    11f1 <get_rot+0xa1>
lea    -0xc0(%rbp),%rdi
movsd  -0x108(%rbp),%xmm0
ff
lea    -0xa0(%rbp),%rsi
call   1040 <quaternion@plt>
lea    -0xa0(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1030 <rotation_matrix@plt>
movl   $0x0,-0x124(%rbp)
cmpl   $0x3,-0x124(%rbp)
jge    12d0 <get_rot+0x180>
mov    -0x8(%rbp),%rax
movslq -0x124(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
movslq -0x124(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movslq -0x124(%rbp),%rax
movsd  %xmm0,-0x100(%rbp,%rax,8)
ff ff
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    127f <get_rot+0x12f>
lea    -0x80(%rbp),%rdi
lea    -0x100(%rbp),%rsi
lea    -0xe0(%rbp),%rdx
call   1050 <matmul@plt>
movl   $0x0,-0x124(%rbp)
cmpl   $0x3,-0x124(%rbp)
jge    1342 <get_rot+0x1f2>
movslq -0x124(%rbp),%rax
movsd  -0xe0(%rbp,%rax,8),%xmm0
ff ff
mov    -0x28(%rbp),%rax
movslq -0x124(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x124(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    12f1 <get_rot+0x1a1>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rot>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %r8,%rbx
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x120(%rsp),%rbp
lea    0x18(%rsp),%r8
mov    %rdx,%rdi
mov    %rcx,%rsi
mov    %rbx,%rdx
mov    %r9,%rcx
call   1060 <c_dih_ang@plt>
lea    0x10(%rsp),%r8
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
call   1060 <c_dih_ang@plt>
movsd  0x10(%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%rsp)
lea    0x8(%rsp),%rdx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <c_bnd_len@plt>
movsd  0x8(%rsp),%xmm0
movupd (%rbx),%xmm1
movupd (%r12),%xmm2
subpd  %xmm2,%xmm1
movapd %xmm0,%xmm2
unpcklpd %xmm0,%xmm2
divpd  %xmm2,%xmm1
movapd %xmm1,0x60(%rsp)
movsd  0x10(%rbx),%xmm1
subsd  0x10(%r12),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x70(%rsp)
movsd  (%rsp),%xmm0
mulsd  0xdf2(%rip),%xmm0
lea    0x60(%rsp),%rdi
lea    0x80(%rsp),%rbp
mov    %rbp,%rsi
call   1040 <quaternion@plt>
lea    0xa0(%rsp),%r12
mov    %rbp,%rdi
mov    %r12,%rsi
call   1030 <rotation_matrix@plt>
movupd (%r15),%xmm0
movupd (%rbx),%xmm1
subpd  %xmm1,%xmm0
movapd %xmm0,0x40(%rsp)
movsd  0x10(%r15),%xmm0
subsd  0x10(%rbx),%xmm0
movsd  %xmm0,0x50(%rsp)
lea    0x40(%rsp),%rsi
lea    0x20(%rsp),%rdx
mov    %r12,%rdi
call   1050 <matmul@plt>
movsd  0x20(%rsp),%xmm0
addsd  (%rbx),%xmm0
movsd  %xmm0,(%r14)
movsd  0x28(%rsp),%xmm0
addsd  0x8(%rbx),%xmm0
movsd  %xmm0,0x8(%r14)
movsd  0x30(%rsp),%xmm0
addsd  0x10(%rbx),%xmm0
movsd  %xmm0,0x10(%r14)
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @get_rot(double* nocapture %0, double* nocapture writeonly %1, double* %2, double* %3, double* %4, double* %5, double* %6) {
%8 = alloca [3 x [3 x double]]
%9 = alloca [4 x double]
%10 = alloca [3 x double]
%11 = alloca [3 x double]
%12 = alloca [3 x double]
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = bitcast [3 x [3 x double]]* %8 to i8*
%17 = bitcast [4 x double]* %9 to i8*
%18 = bitcast [3 x double]* %10 to i8*
%19 = bitcast [3 x double]* %11 to i8*
%20 = bitcast [3 x double]* %12 to i8*
%21 = bitcast double* %13 to i8*
%22 = bitcast double* %14 to i8*
%23 = bitcast double* %15 to i8*
%24 = call i32 @c_dih_ang(double* %2, double* %3, double* %4, double* %5, double* %13)
%25 = call i32 @c_dih_ang(double* %2, double* %3, double* %4, double* %6, double* %14)
%26 = load double, double* %14
%27 = load double, double* %13
%28 = fsub double %26, %27
%29 = call i32 @c_bnd_len(double* %3, double* %4, double* %15)
%30 = load double, double* %15
%31 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%32 = getelementptr inbounds double, double* %4, i64 1
%33 = bitcast double* %4 to <2 x double>*
%34 = load <2 x double>, <2 x double>* %33
%35 = bitcast double* %3 to <2 x double>*
%36 = load <2 x double>, <2 x double>* %35
%37 = fsub <2 x double> %34, %36
%38 = insertelement <2 x double> poison, double %30, i64 0
%39 = shufflevector <2 x double> %38, <2 x double> poison, <2 x i32> zeroinitializer
%40 = fdiv <2 x double> %37, %39
%41 = bitcast [3 x double]* %10 to <2 x double>*
store <2 x double> %40, <2 x double>* %41
%42 = getelementptr inbounds double, double* %4, i64 2
%43 = load double, double* %42
%44 = getelementptr inbounds double, double* %3, i64 2
%45 = load double, double* %44
%46 = fsub double %43, %45
%47 = fdiv double %46, %30
%48 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 2
store double %47, double* %48
%49 = fmul double %28, 2.500000e-01
%50 = getelementptr inbounds [4 x double], [4 x double]* %9, i64 0, i64 0
%51 = call i32 @quaternion(double* %31, double %49, double* %50)
%52 = bitcast [3 x [3 x double]]* %8 to double**
%53 = call i32 @rotation_matrix(double* %50, double** %52)
%54 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%55 = bitcast double* %0 to <2 x double>*
%56 = load <2 x double>, <2 x double>* %55
%57 = bitcast double* %4 to <2 x double>*
%58 = load <2 x double>, <2 x double>* %57
%59 = fsub <2 x double> %56, %58
%60 = bitcast [3 x double]* %12 to <2 x double>*
store <2 x double> %59, <2 x double>* %60
%61 = getelementptr inbounds double, double* %0, i64 2
%62 = load double, double* %61
%63 = load double, double* %42
%64 = fsub double %62, %63
%65 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 2
store double %64, double* %65
%66 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%67 = call i32 @matmul(double** %52, double* %54, double* %66)
%68 = load double, double* %66
%69 = load double, double* %4
%70 = fadd double %68, %69
store double %70, double* %1
%71 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
%72 = load double, double* %71
%73 = load double, double* %32
%74 = fadd double %72, %73
%75 = getelementptr inbounds double, double* %1, i64 1
store double %74, double* %75
%76 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
%77 = load double, double* %76
%78 = load double, double* %42
%79 = fadd double %77, %78
%80 = getelementptr inbounds double, double* %1, i64 2
store double %79, double* %80
ret void
}