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


x86 assembly (clang, -O0):
<rotvector>:
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  0x8(%rax),%xmm0
call   1040 <cos@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
call   1040 <cos@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1030 <sin@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
call   1030 <sin@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
cvtsi2sdl -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x18(%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,0x8(%rax)
cvtsi2sdl -0x1c(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x20(%rbp),%eax
imul   -0x24(%rbp),%eax
cvtsi2sd %eax,%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x18(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
xor    %eax,%eax
sub    -0x24(%rbp),%eax
cvtsi2sd %eax,%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x20(%rbp),%eax
imul   -0x1c(%rbp),%eax
cvtsi2sd %eax,%xmm1
mov    -0x10(%rbp),%rax
mulsd  0x18(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x18(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotvector>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r13
mov    %rdi,%rbp
movsd  0x8(%rdi),%xmm0
call   1040 <cos@plt>
mov    %eax,%r15d
movsd  0x10(%rbp),%xmm0
call   1040 <cos@plt>
mov    %eax,%r12d
movsd  0x8(%rbp),%xmm0
call   1030 <sin@plt>
mov    %eax,%ebx
movsd  0x10(%rbp),%xmm0
call   1030 <sin@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x8(%r13),%xmm1
mulsd  0x18(%r13),%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%r14)
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
mov    %ebx,%eax
imul   %r12d,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0x18(%r13),%xmm1
mulsd  0x10(%r13),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%r14)
neg    %ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
imul   %r15d,%r12d
xorps  %xmm1,%xmm1
cvtsi2sd %r12d,%xmm1
mulsd  0x18(%r13),%xmm1
mulsd  0x10(%r13),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @rotvector(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 i32 @cos(double %5)
%7 = getelementptr inbounds double, double* %0, i64 2
%8 = load double, double* %7
%9 = tail call i32 @cos(double %8)
%10 = load double, double* %4
%11 = tail call i32 @sin(double %10)
%12 = load double, double* %7
%13 = tail call i32 @sin(double %12)
%14 = getelementptr inbounds double, double* %1, i64 1
%15 = load double, double* %14
%16 = sitofp i32 %13 to double
%17 = getelementptr inbounds double, double* %1, i64 3
%18 = load double, double* %17
%19 = fneg double %16
%20 = tail call double @llvm.fmuladd.f64(double %19, double %18, double %15)
%21 = getelementptr inbounds double, double* %2, i64 1
store double %20, double* %21
%22 = sitofp i32 %6 to double
%23 = getelementptr inbounds double, double* %1, i64 2
%24 = load double, double* %23
%25 = mul nsw i32 %11, %9
%26 = sitofp i32 %25 to double
%27 = load double, double* %17
%28 = fmul double %27, %26
%29 = tail call double @llvm.fmuladd.f64(double %22, double %24, double %28)
%30 = getelementptr inbounds double, double* %2, i64 2
store double %29, double* %30
%31 = sub nsw i32 0, %11
%32 = sitofp i32 %31 to double
%33 = load double, double* %23
%34 = mul nsw i32 %9, %6
%35 = sitofp i32 %34 to double
%36 = load double, double* %17
%37 = fmul double %36, %35
%38 = tail call double @llvm.fmuladd.f64(double %32, double %33, double %37)
%39 = getelementptr inbounds double, double* %2, i64 3
store double %38, double* %39
ret void
}