#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);
double sin(double);
void rotvector(double theta[3], double Vin[3], double Vout[3]) {
  double cphi, ctet;
  double sphi, stet;
  cphi = cos(theta[0]);
  ctet = cos(theta[1]);
  sphi = sin(theta[0]);
  stet = sin(theta[1]);
  Vout[0] = Vin[0] - stet * Vin[2];
  Vout[1] = cphi * Vin[1] + ctet * sphi * Vin[2];
  Vout[2] = -sphi * Vin[1] + ctet * cphi * Vin[2];
}


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

LLVM IR (-O0):
define void @rotvector(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 0
%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 @cos(double %17)
store double %18, double* %8
%19 = load double*, double** %4
%20 = getelementptr inbounds double, double* %19, i64 0
%21 = load double, double* %20
%22 = call double @sin(double %21)
store double %22, double* %9
%23 = load double*, double** %4
%24 = getelementptr inbounds double, double* %23, i64 1
%25 = load double, double* %24
%26 = call double @sin(double %25)
store double %26, double* %10
%27 = load double*, double** %5
%28 = getelementptr inbounds double, double* %27, i64 0
%29 = load double, double* %28
%30 = load double, double* %10
%31 = load double*, double** %5
%32 = getelementptr inbounds double, double* %31, i64 2
%33 = load double, double* %32
%34 = fneg double %30
%35 = call double @llvm.fmuladd.f64(double %34, double %33, double %29)
%36 = load double*, double** %6
%37 = getelementptr inbounds double, double* %36, i64 0
store double %35, double* %37
%38 = load double, double* %7
%39 = load double*, double** %5
%40 = getelementptr inbounds double, double* %39, i64 1
%41 = load double, double* %40
%42 = load double, double* %8
%43 = load double, double* %9
%44 = fmul double %42, %43
%45 = load double*, double** %5
%46 = getelementptr inbounds double, double* %45, i64 2
%47 = load double, double* %46
%48 = fmul double %44, %47
%49 = call double @llvm.fmuladd.f64(double %38, double %41, double %48)
%50 = load double*, double** %6
%51 = getelementptr inbounds double, double* %50, i64 1
store double %49, double* %51
%52 = load double, double* %9
%53 = fneg double %52
%54 = load double*, double** %5
%55 = getelementptr inbounds double, double* %54, i64 1
%56 = load double, double* %55
%57 = load double, double* %8
%58 = load double, double* %7
%59 = fmul double %57, %58
%60 = load double*, double** %5
%61 = getelementptr inbounds double, double* %60, i64 2
%62 = load double, double* %61
%63 = fmul double %59, %62
%64 = call double @llvm.fmuladd.f64(double %53, double %56, double %63)
%65 = load double*, double** %6
%66 = getelementptr inbounds double, double* %65, i64 2
store double %64, double* %66
ret void
}

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