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


x86 assembly (clang, -O0):
<get_vec_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  -0x30(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%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,(%rax)
movsd  -0x38(%rbp),%xmm1
mulsd  -0x28(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x30(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x30(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x38(%rbp),%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x10(%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
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_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,0x10(%rsp)
movsd  0x8(%rbx),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x10(%rbx),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rbx),%xmm0
call   1030 <sin@plt>
movsd  0x10(%rsp),%xmm3
movapd %xmm3,%xmm1
mulsd  %xmm0,%xmm1
movapd %xmm3,%xmm2
movsd  0x8(%rsp),%xmm4
mulsd  %xmm4,%xmm2
mulsd  0x10(%r15),%xmm2
mulsd  (%r15),%xmm1
addsd  %xmm2,%xmm1
movsd  0x8(%r15),%xmm2
movsd  0x18(%rsp),%xmm5
mulsd  %xmm5,%xmm2
subsd  %xmm2,%xmm1
movsd  %xmm1,(%r14)
movapd %xmm5,%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm4,%xmm5
movapd %xmm4,%xmm2
mulsd  0x10(%r15),%xmm5
mulsd  (%r15),%xmm1
addsd  %xmm5,%xmm1
mulsd  0x8(%r15),%xmm3
addsd  %xmm1,%xmm3
movsd  %xmm3,0x8(%r14)
mulsd  0x10(%r15),%xmm0
movapd %xmm2,%xmm1
mulsd  (%r15),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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