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


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

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

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

LLVM IR (-O2):
define void @get_vec_rpz(double* nocapture %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = getelementptr inbounds double, double* %0, i64 2
%5 = load double, double* %4
%6 = tail call double @sin(double %5)
%7 = load double, double* %4
%8 = tail call double @cos(double %7)
%9 = getelementptr inbounds double, double* %1, i64 2
%10 = load double, double* %9
%11 = load double, double* %1
%12 = fmul double %6, %11
%13 = tail call double @llvm.fmuladd.f64(double %8, double %10, double %12)
store double %13, double* %2
%14 = getelementptr inbounds double, double* %1, i64 1
%15 = load double, double* %14
%16 = getelementptr inbounds double, double* %2, i64 1
store double %15, double* %16
%17 = fneg double %6
%18 = load double, double* %9
%19 = load double, double* %1
%20 = fmul double %8, %19
%21 = tail call double @llvm.fmuladd.f64(double %17, double %18, double %20)
%22 = getelementptr inbounds double, double* %2, i64 2
store double %21, double* %22
ret void
}