#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*/ arb_rotation(double *, double, double **);
double **dmatrix(int, int, int, int);
double dot(double *, double *);
int /*<<< orphan*/ free_dmatrix(double **, int, int, int, int);
int /*<<< orphan*/ nrerror(char *);
int /*<<< orphan*/ vec_norm(double *);
void get_vector(double *va, double *vref, double deg_ang, double *vo) {
  double **temp;
  long i;
  if (dot(va, vref) > 1.0e-7)
    nrerror("va and vref should be perpendicular");
  temp = dmatrix(1, 3, 1, 3);
  arb_rotation(vref, deg_ang, temp);
  for (i = 1; i <= 3; i++)
    vo[i] = dot(temp[i], va);
  vec_norm(vo);
  free_dmatrix(temp, 1, 3, 1, 3);
}


x86 assembly (clang, -O0):
<get_vector>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <dot@plt>
movsd  0xe72(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a4 <get_vector+0x44>
lea    0xe69(%rip),%rdi
call   1050 <nrerror@plt>
mov    $0x1,%edx
mov    $0x3,%ecx
mov    %edx,%edi
mov    %ecx,%esi
call   1070 <dmatrix@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
mov    -0x28(%rbp),%rsi
call   1040 <arb_rotation@plt>
movq   $0x1,-0x30(%rbp)
cmpq   $0x3,-0x30(%rbp)
jg     1213 <get_vector+0xb3>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <dot@plt>
mov    -0x20(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11d5 <get_vector+0x75>
mov    -0x20(%rbp),%rdi
call   1060 <vec_norm@plt>
mov    -0x28(%rbp),%rdi
mov    $0x1,%ecx
mov    $0x3,%r8d
mov    %ecx,%esi
mov    %r8d,%edx
call   1080 <free_dmatrix@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_vector>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
movsd  %xmm0,(%rsp)
mov    %rsi,%r12
mov    %rdi,%r15
call   1030 <dot@plt>
ucomisd 0xe7d(%rip),%xmm0
jbe    1191 <get_vector+0x31>
lea    0xe7c(%rip),%rdi
call   1050 <nrerror@plt>
mov    $0x1,%edi
mov    $0x3,%esi
mov    $0x1,%edx
mov    $0x3,%ecx
call   1070 <dmatrix@plt>
mov    %rax,%rbx
mov    %r12,%rdi
movsd  (%rsp),%xmm0
mov    %rax,%rsi
call   1040 <arb_rotation@plt>
mov    0x8(%rbx),%rdi
mov    %r15,%rsi
call   1030 <dot@plt>
movsd  %xmm0,0x8(%r14)
mov    0x10(%rbx),%rdi
mov    %r15,%rsi
call   1030 <dot@plt>
movsd  %xmm0,0x10(%r14)
mov    0x18(%rbx),%rdi
mov    %r15,%rsi
call   1030 <dot@plt>
movsd  %xmm0,0x18(%r14)
mov    %r14,%rdi
call   1060 <vec_norm@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x3,%edx
mov    $0x1,%ecx
mov    $0x3,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1080 <free_dmatrix@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"va and vref should be perpendicular\00"
define void @get_vector(double* %0, double* %1, double %2, double* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double*
%9 = alloca double**
%10 = alloca i64
store double* %0, double** %5
store double* %1, double** %6
store double %2, double* %7
store double* %3, double** %8
%11 = load double*, double** %5
%12 = load double*, double** %6
%13 = call double @dot(double* %11, double* %12)
%14 = fcmp ogt double %13, 0x3E7AD7F29ABCAF48
br i1 %14, label %15, label %17
15: ; preds = %4
%16 = call i32 @nrerror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %4
%18 = call double** @dmatrix(i32 1, i32 3, i32 1, i32 3)
store double** %18, double*** %9
%19 = load double*, double** %6
%20 = load double, double* %7
%21 = load double**, double*** %9
%22 = call i32 @arb_rotation(double* %19, double %20, double** %21)
store i64 1, i64* %10
br label %23
23: ; preds = %36, %17
%24 = load i64, i64* %10
%25 = icmp sle i64 %24, 3
br i1 %25, label %26, label %39
26: ; preds = %23
%27 = load double**, double*** %9
%28 = load i64, i64* %10
%29 = getelementptr inbounds double*, double** %27, i64 %28
%30 = load double*, double** %29
%31 = load double*, double** %5
%32 = call double @dot(double* %30, double* %31)
%33 = load double*, double** %8
%34 = load i64, i64* %10
%35 = getelementptr inbounds double, double* %33, i64 %34
store double %32, double* %35
br label %36
36: ; preds = %26
%37 = load i64, i64* %10
%38 = add nsw i64 %37, 1
store i64 %38, i64* %10
br label %23
39: ; preds = %23
%40 = load double*, double** %8
%41 = call i32 @vec_norm(double* %40)
%42 = load double**, double*** %9
%43 = call i32 @free_dmatrix(double** %42, i32 1, i32 3, i32 1, i32 3)
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"va and vref should be perpendicular\00"
define void @get_vector(double* %0, double* %1, double %2, double* %3) {
%5 = tail call double @dot(double* %0, double* %1)
%6 = fcmp ogt double %5, 0x3E7AD7F29ABCAF48
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @nrerror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %4
%10 = tail call double** @dmatrix(i32 1, i32 3, i32 1, i32 3)
%11 = tail call i32 @arb_rotation(double* %1, double %2, double** %10)
%12 = getelementptr inbounds double*, double** %10, i64 1
%13 = load double*, double** %12
%14 = tail call double @dot(double* %13, double* %0)
%15 = getelementptr inbounds double, double* %3, i64 1
store double %14, double* %15
%16 = getelementptr inbounds double*, double** %10, i64 2
%17 = load double*, double** %16
%18 = tail call double @dot(double* %17, double* %0)
%19 = getelementptr inbounds double, double* %3, i64 2
store double %18, double* %19
%20 = getelementptr inbounds double*, double** %10, i64 3
%21 = load double*, double** %20
%22 = tail call double @dot(double* %21, double* %0)
%23 = getelementptr inbounds double, double* %3, i64 3
store double %22, double* %23
%24 = tail call i32 @vec_norm(double* %3)
%25 = tail call i32 @free_dmatrix(double** %10, i32 1, i32 3, i32 1, i32 3)
ret void
}