#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 /*<<< orphan*/ assert(double const *);
double cos(double const);
double sin(double const);
void efp_torque_to_derivative(const double *euler, const double *torque,
                              double *deriv) {
  assert(euler);
  assert(torque);
  assert(deriv);
  double tx = torque[0];
  double ty = torque[1];
  double tz = torque[2];
  double sina = sin(euler[0]);
  double cosa = cos(euler[0]);
  double sinb = sin(euler[1]);
  double cosb = cos(euler[1]);
  deriv[0] = tz;
  deriv[1] = cosa * tx + sina * ty;
  deriv[2] = sinb * sina * tx - sinb * cosa * ty + cosb * tz;
}


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

x86 assembly (clang, -O2):
<efp_torque_to_derivative>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
call   1030 <assert@plt>
mov    %rbx,%rdi
call   1030 <assert@plt>
mov    %r14,%rdi
call   1030 <assert@plt>
movsd  (%rbx),%xmm0
movaps %xmm0,0x40(%rsp)
movsd  0x8(%rbx),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rbx),%xmm0
movaps %xmm0,0x30(%rsp)
movsd  (%r15),%xmm0
call   1040 <sin@plt>
movaps %xmm0,0x20(%rsp)
movsd  (%r15),%xmm0
call   1050 <cos@plt>
movaps %xmm0,0x10(%rsp)
movsd  0x8(%r15),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,(%rsp)
movsd  0x8(%r15),%xmm0
call   1050 <cos@plt>
movapd 0x30(%rsp),%xmm3
movsd  %xmm3,(%r14)
movsd  0x8(%rsp),%xmm2
movapd %xmm2,%xmm1
movapd 0x20(%rsp),%xmm4
mulsd  %xmm4,%xmm1
movsd  (%rsp),%xmm6
mulsd  %xmm6,%xmm4
movapd 0x10(%rsp),%xmm5
mulsd  %xmm5,%xmm6
mulsd  %xmm2,%xmm6
movapd 0x40(%rsp),%xmm2
mulsd  %xmm2,%xmm4
subsd  %xmm6,%xmm4
unpcklpd %xmm4,%xmm1
unpcklpd %xmm0,%xmm5
unpcklpd %xmm3,%xmm2
mulpd  %xmm5,%xmm2
addpd  %xmm1,%xmm2
movupd %xmm2,0x8(%r14)
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @efp_torque_to_derivative(double* %0, double* %1, double* %2) {
%4 = tail call i32 @assert(double* %0)
%5 = tail call i32 @assert(double* %1)
%6 = tail call i32 @assert(double* %2)
%7 = load double, double* %1
%8 = getelementptr inbounds double, double* %1, i64 1
%9 = load double, double* %8
%10 = getelementptr inbounds double, double* %1, i64 2
%11 = load double, double* %10
%12 = load double, double* %0
%13 = tail call double @sin(double %12)
%14 = load double, double* %0
%15 = tail call double @cos(double %14)
%16 = getelementptr inbounds double, double* %0, i64 1
%17 = load double, double* %16
%18 = tail call double @sin(double %17)
%19 = load double, double* %16
%20 = tail call double @cos(double %19)
store double %11, double* %2
%21 = fmul double %9, %13
%22 = getelementptr inbounds double, double* %2, i64 1
%23 = fmul double %13, %18
%24 = fneg double %18
%25 = fmul double %15, %24
%26 = fmul double %9, %25
%27 = tail call double @llvm.fmuladd.f64(double %23, double %7, double %26)
%28 = insertelement <2 x double> poison, double %15, i64 0
%29 = insertelement <2 x double> %28, double %20, i64 1
%30 = insertelement <2 x double> poison, double %7, i64 0
%31 = insertelement <2 x double> %30, double %11, i64 1
%32 = insertelement <2 x double> poison, double %21, i64 0
%33 = insertelement <2 x double> %32, double %27, i64 1
%34 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %29, <2 x double> %31, <2 x double> %33)
%35 = bitcast double* %22 to <2 x double>*
store <2 x double> %34, <2 x double>* %35
ret void
}