#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);
double sin(double);
double tan(double);
void rotvector_inv(double theta[3], double Vin[3], double Vout[3]) {
  double cphi, sphi;
  double ttet, sectet;
  cphi = cos(theta[0]);
  ttet = tan(theta[1]);
  sphi = sin(theta[0]);
  sectet = 1. / cos(theta[1]);
  Vout[0] = Vin[0] + sphi * ttet * Vin[1] + cphi * ttet * Vin[2];
  Vout[1] = cphi * Vin[1] - sphi * Vin[2];
  Vout[2] = sphi * sectet * Vin[1] + sectet * cphi * Vin[2];
}


x86 assembly (clang, -O0):
<rotvector_inv>:
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   1050 <cos@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1040 <tan@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
call   1050 <cos@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe67(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x28(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
mulsd  -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  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
movsd  -0x28(%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,0x8(%rax)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
movsd  -0x38(%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_inv>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
call   1050 <cos@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rbx),%xmm0
call   1040 <tan@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rbx),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rbx),%xmm0
call   1050 <cos@plt>
cvtsi2sd %eax,%xmm1
movsd  0xe73(%rip),%xmm0
movsd  0x10(%rsp),%xmm5
movapd %xmm5,%xmm2
movsd  0x8(%rsp),%xmm4
mulsd  %xmm4,%xmm2
mulsd  0x8(%r15),%xmm2
addsd  (%r15),%xmm2
divsd  %xmm1,%xmm0
movsd  0x18(%rsp),%xmm3
mulsd  %xmm3,%xmm5
mulsd  0x10(%r15),%xmm5
addsd  %xmm2,%xmm5
movsd  %xmm5,(%r14)
movsd  0x10(%r15),%xmm1
mulsd  %xmm4,%xmm1
movsd  0x8(%r15),%xmm2
mulsd  %xmm3,%xmm2
subsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%r14)
movapd %xmm4,%xmm1
mulsd  %xmm0,%xmm1
mulsd  %xmm3,%xmm0
mulsd  0x10(%r15),%xmm0
mulsd  0x8(%r15),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%r14)
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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