#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*/ getRotationMatrixFromQuartenion(float *, float **);
int /*<<< orphan*/ normalizeVector(float *, int);
float sqrt(float);
void getRotationMatrixFromVectors(float vin[3], float vout[3],
                                  float matrix[4][4]) {
  normalizeVector(vout, 3);
  float q[4] = {0, 0, 0, 0};
  float vin_length = 0;
  float vout_length = 0;
  float dotprod = 0;
  int i;
  for (i = 0; i < 3; i++) {
    vin_length += vin[i] * vin[i];
    vout_length += vout[i] * vout[i];
    dotprod += vin[i] * vout[i];
  }
  q[0] = sqrt(vin_length * vout_length) + dotprod;
  q[1] = -1 * (vin[1] * vout[2] - vin[2] * vout[1]);
  q[2] = -1 * (vin[2] * vout[0] - vin[0] * vout[2]);
  q[3] = -1 * (vin[0] * vout[1] - vin[1] * vout[0]);
  normalizeVector(q, 4);
  getRotationMatrixFromQuartenion(q, matrix);
}


x86 assembly (clang, -O0):
<getRotationMatrixFromVectors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3,%esi
call   1030 <normalizeVector@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
cmpl   $0x3,-0x40(%rbp)
jge    122d <getRotationMatrixFromVectors+0xed>
mov    -0x8(%rbp),%rax
movslq -0x40(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x40(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm2
movss  -0x34(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x40(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x40(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm2
movss  -0x38(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x40(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x40(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm2
movss  -0x3c(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1191 <getRotationMatrixFromVectors+0x51>
movss  -0x34(%rbp),%xmm0
mulss  -0x38(%rbp),%xmm0
call   1050 <sqrt@plt>
addss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm1
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulss  0x4(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  0xd79(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x10(%rbp),%rax
mulss  0x8(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  0xd31(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm2
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x10(%rbp),%rax
mulss  (%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  0xce9(%rip),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x4,%esi
call   1030 <normalizeVector@plt>
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <getRotationMatrixFromQuartenion@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRotationMatrixFromVectors>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsi,%rdi
mov    $0x3,%esi
call   1030 <normalizeVector@plt>
movss  (%r15),%xmm0
movss  0x4(%r15),%xmm1
movaps %xmm0,%xmm4
mulss  %xmm0,%xmm4
xorps  %xmm2,%xmm2
addss  %xmm2,%xmm4
movss  (%rbx),%xmm5
movss  0x4(%rbx),%xmm3
mulss  %xmm5,%xmm0
mulss  %xmm5,%xmm5
addss  %xmm2,%xmm5
addss  %xmm2,%xmm0
movaps %xmm1,%xmm6
mulss  %xmm1,%xmm6
addss  %xmm4,%xmm6
mulss  %xmm3,%xmm1
mulss  %xmm3,%xmm3
addss  %xmm5,%xmm3
addss  %xmm0,%xmm1
movss  0x8(%r15),%xmm5
movaps %xmm5,%xmm4
mulss  %xmm5,%xmm4
addss  %xmm6,%xmm4
movss  0x8(%rbx),%xmm0
mulss  %xmm0,%xmm5
mulss  %xmm0,%xmm0
addss  %xmm3,%xmm0
mulss  %xmm4,%xmm0
addss  %xmm1,%xmm5
ucomiss %xmm2,%xmm0
jb     11d1 <getRotationMatrixFromVectors+0xa1>
sqrtss %xmm0,%xmm0
jmp    11e2 <getRotationMatrixFromVectors+0xb2>
movss  %xmm5,0xc(%rsp)
call   1040 <sqrt@plt>
movss  0xc(%rsp),%xmm5
addss  %xmm0,%xmm5
movss  %xmm5,0x10(%rsp)
movss  0x4(%rbx),%xmm0
movss  0x8(%rbx),%xmm1
movss  0x4(%r15),%xmm2
movss  0x8(%r15),%xmm3
movaps %xmm0,%xmm4
mulss  %xmm3,%xmm4
movaps %xmm2,%xmm5
mulss  %xmm1,%xmm5
subss  %xmm4,%xmm5
movaps 0xde5(%rip),%xmm4
xorps  %xmm4,%xmm5
movss  %xmm5,0x14(%rsp)
movss  (%rbx),%xmm5
movss  (%r15),%xmm6
mulss  %xmm6,%xmm1
mulss  %xmm5,%xmm3
subss  %xmm1,%xmm3
xorps  %xmm4,%xmm3
movss  %xmm3,0x18(%rsp)
mulss  %xmm2,%xmm5
mulss  %xmm0,%xmm6
subss  %xmm5,%xmm6
xorps  %xmm4,%xmm6
movss  %xmm6,0x1c(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <normalizeVector@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <getRotationMatrixFromQuartenion@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @getRotationMatrixFromVectors(float* nocapture %0, float* %1, [4 x float]* %2) {
%4 = alloca [4 x float]
%5 = tail call i32 @normalizeVector(float* %1, i32 3)
%6 = bitcast [4 x float]* %4 to i8*
%7 = load float, float* %0
%8 = tail call float @llvm.fmuladd.f32(float %7, float %7, float 0.000000e+00)
%9 = load float, float* %1
%10 = tail call float @llvm.fmuladd.f32(float %9, float %9, float 0.000000e+00)
%11 = tail call float @llvm.fmuladd.f32(float %7, float %9, float 0.000000e+00)
%12 = getelementptr inbounds float, float* %0, i64 1
%13 = load float, float* %12
%14 = tail call float @llvm.fmuladd.f32(float %13, float %13, float %8)
%15 = getelementptr inbounds float, float* %1, i64 1
%16 = load float, float* %15
%17 = tail call float @llvm.fmuladd.f32(float %16, float %16, float %10)
%18 = tail call float @llvm.fmuladd.f32(float %13, float %16, float %11)
%19 = getelementptr inbounds float, float* %0, i64 2
%20 = load float, float* %19
%21 = tail call float @llvm.fmuladd.f32(float %20, float %20, float %14)
%22 = getelementptr inbounds float, float* %1, i64 2
%23 = load float, float* %22
%24 = tail call float @llvm.fmuladd.f32(float %23, float %23, float %17)
%25 = tail call float @llvm.fmuladd.f32(float %20, float %23, float %18)
%26 = fmul float %21, %24
%27 = tail call float @sqrt(float %26)
%28 = fadd float %25, %27
%29 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 0
store float %28, float* %29
%30 = load float, float* %12
%31 = load float, float* %22
%32 = load float, float* %19
%33 = load float, float* %15
%34 = fneg float %32
%35 = fmul float %33, %34
%36 = tail call float @llvm.fmuladd.f32(float %30, float %31, float %35)
%37 = fneg float %36
%38 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 1
store float %37, float* %38
%39 = load float, float* %1
%40 = load float, float* %0
%41 = fneg float %40
%42 = fmul float %31, %41
%43 = tail call float @llvm.fmuladd.f32(float %32, float %39, float %42)
%44 = fneg float %43
%45 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 2
store float %44, float* %45
%46 = fneg float %30
%47 = fmul float %39, %46
%48 = tail call float @llvm.fmuladd.f32(float %40, float %33, float %47)
%49 = fneg float %48
%50 = getelementptr inbounds [4 x float], [4 x float]* %4, i64 0, i64 3
store float %49, float* %50
%51 = call i32 @normalizeVector(float* %29, i32 4)
%52 = bitcast [4 x float]* %2 to float**
%53 = call i32 @getRotationMatrixFromQuartenion(float* %29, float** %52)
ret void
}