#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 rotz(double *v1, double ang, double *v2) {
  double m1x, m1y, m1z, m2x, m2y, m2z, m3x, m3y, m3z;
  m1x = cos(ang);
  m1y = -1.0 * sin(ang);
  m1z = 0.0;
  m2x = sin(ang);
  m2y = cos(ang);
  m2z = 0.0;
  m3x = 0.0;
  m3y = 0.0;
  m3z = 1.0;
  v2[0] = m1x * v1[0] + m1y * v1[1] + m1z * v1[2];
  v2[1] = m2x * v1[0] + m2y * v1[1] + m2z * v1[2];
  v2[2] = m3x * v1[0] + m3y * v1[1] + m3z * v1[2];
}


x86 assembly (clang, -O0):
<rotz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  0xeaf(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <cos@plt>
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe58(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x28(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x40(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x50(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x58(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x60,%rsp
pop    %rbp
ret

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

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

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