#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 cos(double const);
double sin(double const);
void get_vec_from_xyz(const double *x, const double *vxyz, double *v) {
  double cp = cos(x[1]);
  double sp = sin(x[1]);
  double ct = cos(x[2]);
  double st = sin(x[2]);
  v[0] = st * cp * vxyz[0] + st * sp * vxyz[1] + ct * vxyz[2];
  v[1] = -sp * vxyz[0] + cp * vxyz[1];
  v[2] = ct * cp * vxyz[0] + ct * sp * vxyz[1] - st * vxyz[2];
}


x86 assembly (clang, -O0):
<get_vec_from_xyz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x38(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x28(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x20(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x30(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_vec_from_xyz>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movsd  0x8(%rdi),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rbx),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rbx),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x10(%rbx),%xmm0
call   1030 <sin@plt>
movsd  0x18(%rsp),%xmm3
movapd %xmm3,%xmm1
mulsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm4
movapd %xmm4,%xmm2
mulsd  %xmm0,%xmm2
mulsd  0x8(%r15),%xmm2
mulsd  (%r15),%xmm1
addsd  %xmm2,%xmm1
movsd  0x10(%r15),%xmm2
movsd  0x10(%rsp),%xmm5
mulsd  %xmm5,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,(%r14)
movsd  0x8(%r15),%xmm1
mulsd  %xmm3,%xmm1
movsd  (%r15),%xmm2
mulsd  %xmm4,%xmm2
subsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%r14)
movapd %xmm4,%xmm1
mulsd  %xmm5,%xmm1
mulsd  0x8(%r15),%xmm1
movapd %xmm1,%xmm2
movapd %xmm3,%xmm1
mulsd  %xmm5,%xmm1
mulsd  (%r15),%xmm1
addsd  %xmm2,%xmm1
mulsd  0x10(%r15),%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @get_vec_from_xyz(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%11 = load double*, double** %4
%12 = getelementptr inbounds double, double* %11, i64 1
%13 = load double, double* %12
%14 = call double @cos(double %13)
store double %14, double* %7
%15 = load double*, double** %4
%16 = getelementptr inbounds double, double* %15, i64 1
%17 = load double, double* %16
%18 = call double @sin(double %17)
store double %18, double* %8
%19 = load double*, double** %4
%20 = getelementptr inbounds double, double* %19, i64 2
%21 = load double, double* %20
%22 = call double @cos(double %21)
store double %22, double* %9
%23 = load double*, double** %4
%24 = getelementptr inbounds double, double* %23, i64 2
%25 = load double, double* %24
%26 = call double @sin(double %25)
store double %26, double* %10
%27 = load double, double* %10
%28 = load double, double* %7
%29 = fmul double %27, %28
%30 = load double*, double** %5
%31 = getelementptr inbounds double, double* %30, i64 0
%32 = load double, double* %31
%33 = load double, double* %10
%34 = load double, double* %8
%35 = fmul double %33, %34
%36 = load double*, double** %5
%37 = getelementptr inbounds double, double* %36, i64 1
%38 = load double, double* %37
%39 = fmul double %35, %38
%40 = call double @llvm.fmuladd.f64(double %29, double %32, double %39)
%41 = load double, double* %9
%42 = load double*, double** %5
%43 = getelementptr inbounds double, double* %42, i64 2
%44 = load double, double* %43
%45 = call double @llvm.fmuladd.f64(double %41, double %44, double %40)
%46 = load double*, double** %6
%47 = getelementptr inbounds double, double* %46, i64 0
store double %45, double* %47
%48 = load double, double* %8
%49 = fneg double %48
%50 = load double*, double** %5
%51 = getelementptr inbounds double, double* %50, i64 0
%52 = load double, double* %51
%53 = load double, double* %7
%54 = load double*, double** %5
%55 = getelementptr inbounds double, double* %54, i64 1
%56 = load double, double* %55
%57 = fmul double %53, %56
%58 = call double @llvm.fmuladd.f64(double %49, double %52, double %57)
%59 = load double*, double** %6
%60 = getelementptr inbounds double, double* %59, i64 1
store double %58, double* %60
%61 = load double, double* %9
%62 = load double, double* %7
%63 = fmul double %61, %62
%64 = load double*, double** %5
%65 = getelementptr inbounds double, double* %64, i64 0
%66 = load double, double* %65
%67 = load double, double* %9
%68 = load double, double* %8
%69 = fmul double %67, %68
%70 = load double*, double** %5
%71 = getelementptr inbounds double, double* %70, i64 1
%72 = load double, double* %71
%73 = fmul double %69, %72
%74 = call double @llvm.fmuladd.f64(double %63, double %66, double %73)
%75 = load double, double* %10
%76 = load double*, double** %5
%77 = getelementptr inbounds double, double* %76, i64 2
%78 = load double, double* %77
%79 = fneg double %75
%80 = call double @llvm.fmuladd.f64(double %79, double %78, double %74)
%81 = load double*, double** %6
%82 = getelementptr inbounds double, double* %81, i64 2
store double %80, double* %82
ret void
}

LLVM IR (-O2):
define void @get_vec_from_xyz(double* nocapture %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = getelementptr inbounds double, double* %0, i64 1
%5 = load double, double* %4
%6 = tail call double @cos(double %5)
%7 = load double, double* %4
%8 = tail call double @sin(double %7)
%9 = getelementptr inbounds double, double* %0, i64 2
%10 = load double, double* %9
%11 = tail call double @cos(double %10)
%12 = load double, double* %9
%13 = tail call double @sin(double %12)
%14 = fmul double %6, %13
%15 = load double, double* %1
%16 = fmul double %8, %13
%17 = getelementptr inbounds double, double* %1, i64 1
%18 = load double, double* %17
%19 = fmul double %16, %18
%20 = tail call double @llvm.fmuladd.f64(double %14, double %15, double %19)
%21 = getelementptr inbounds double, double* %1, i64 2
%22 = load double, double* %21
%23 = tail call double @llvm.fmuladd.f64(double %11, double %22, double %20)
store double %23, double* %2
%24 = fneg double %8
%25 = load double, double* %1
%26 = load double, double* %17
%27 = fmul double %6, %26
%28 = tail call double @llvm.fmuladd.f64(double %24, double %25, double %27)
%29 = getelementptr inbounds double, double* %2, i64 1
store double %28, double* %29
%30 = fmul double %6, %11
%31 = load double, double* %1
%32 = fmul double %8, %11
%33 = load double, double* %17
%34 = fmul double %32, %33
%35 = tail call double @llvm.fmuladd.f64(double %30, double %31, double %34)
%36 = load double, double* %21
%37 = fneg double %13
%38 = tail call double @llvm.fmuladd.f64(double %37, double %36, double %35)
%39 = getelementptr inbounds double, double* %2, i64 2
store double %38, double* %39
ret void
}