#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 meshRotateVector(double theta, double v[2], double vRot[2]) {
  double cosTheta = cos(theta);
  double sinTheta = sin(theta);
  double vRot0 = cosTheta * v[0] - sinTheta * v[1];
  vRot[1] = sinTheta * v[0] + cosTheta * v[1];
  vRot[0] = vRot0;
}


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

x86 assembly (clang, -O2):
<meshRotateVector>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  %xmm0,0x8(%rsp)
call   1040 <cos@plt>
movaps %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1030 <sin@plt>
movapd 0xeb0(%rip),%xmm1
xorpd  %xmm0,%xmm1
movsd  (%rbx),%xmm2
movsd  0x8(%rbx),%xmm3
unpcklpd %xmm3,%xmm3
movapd 0x10(%rsp),%xmm4
unpcklpd %xmm4,%xmm1
mulpd  %xmm3,%xmm1
unpcklpd %xmm0,%xmm4
unpcklpd %xmm2,%xmm2
mulpd  %xmm4,%xmm2
addpd  %xmm1,%xmm2
movupd %xmm2,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @meshRotateVector(double %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = tail call double @cos(double %0)
%5 = tail call double @sin(double %0)
%6 = load double, double* %1
%7 = getelementptr inbounds double, double* %1, i64 1
%8 = load double, double* %7
%9 = fneg double %5
%10 = insertelement <2 x double> poison, double %8, i64 0
%11 = shufflevector <2 x double> %10, <2 x double> poison, <2 x i32> zeroinitializer
%12 = insertelement <2 x double> poison, double %9, i64 0
%13 = insertelement <2 x double> %12, double %4, i64 1
%14 = fmul <2 x double> %11, %13
%15 = insertelement <2 x double> poison, double %4, i64 0
%16 = insertelement <2 x double> %15, double %5, i64 1
%17 = insertelement <2 x double> poison, double %6, i64 0
%18 = shufflevector <2 x double> %17, <2 x double> poison, <2 x i32> zeroinitializer
%19 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %16, <2 x double> %18, <2 x double> %14)
%20 = bitcast double* %2 to <2 x double>*
store <2 x double> %19, <2 x double>* %20
ret void
}