#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 latero_forward_kinematics(double angle[3], double *px, double *py,
                               double *ptheta) {
  *px = 222.3 * cos(angle[0]);
  *px += 245.6 * cos(angle[0] + angle[1]);
  *px += 62.7 * cos(angle[0] + angle[1] + angle[2]);
  *py = 222.3 * sin(angle[0]);
  *py += 245.6 * sin(angle[0] + angle[1]);
  *py += 62.7 * sin(angle[0] + angle[1] + angle[2]);
  *ptheta = angle[0] + angle[1] + angle[2];
}


x86 assembly (clang, -O0):
<latero_forward_kinematics>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1040 <cos@plt>
movaps %xmm0,%xmm1
movsd  0xec0(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x8(%rax),%xmm0
call   1040 <cos@plt>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
movsd  0xe86(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x10(%rax),%xmm0
call   1040 <cos@plt>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
movsd  0xe43(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <sin@plt>
movaps %xmm0,%xmm1
movsd  0xe2f(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x8(%rax),%xmm0
call   1030 <sin@plt>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
movsd  0xdf5(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x10(%rax),%xmm0
call   1030 <sin@plt>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
movsd  0xdb2(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
addsd  0x10(%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<latero_forward_kinematics>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
movsd  (%rdi),%xmm0
call   1040 <cos@plt>
mulsd  0xebb(%rip),%xmm0
movsd  %xmm0,(%r12)
movsd  (%rbx),%xmm0
addsd  0x8(%rbx),%xmm0
call   1040 <cos@plt>
mulsd  0xea7(%rip),%xmm0
addsd  (%r12),%xmm0
movsd  %xmm0,(%r12)
movsd  (%rbx),%xmm0
addsd  0x8(%rbx),%xmm0
addsd  0x10(%rbx),%xmm0
call   1040 <cos@plt>
mulsd  0xe88(%rip),%xmm0
addsd  (%r12),%xmm0
movsd  %xmm0,(%r12)
movsd  (%rbx),%xmm0
call   1030 <sin@plt>
mulsd  0xe5b(%rip),%xmm0
movsd  %xmm0,(%r15)
movsd  (%rbx),%xmm0
addsd  0x8(%rbx),%xmm0
call   1030 <sin@plt>
mulsd  0xe48(%rip),%xmm0
addsd  (%r15),%xmm0
movsd  %xmm0,(%r15)
movsd  (%rbx),%xmm0
addsd  0x8(%rbx),%xmm0
addsd  0x10(%rbx),%xmm0
call   1030 <sin@plt>
mulsd  0xe2b(%rip),%xmm0
addsd  (%r15),%xmm0
movsd  %xmm0,(%r15)
movsd  (%rbx),%xmm0
addsd  0x8(%rbx),%xmm0
addsd  0x10(%rbx),%xmm0
movsd  %xmm0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @latero_forward_kinematics(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%9 = load double*, double** %5
%10 = getelementptr inbounds double, double* %9, i64 0
%11 = load double, double* %10
%12 = call double @cos(double %11)
%13 = fmul double 2.223000e+02, %12
%14 = load double*, double** %6
store double %13, double* %14
%15 = load double*, double** %5
%16 = getelementptr inbounds double, double* %15, i64 0
%17 = load double, double* %16
%18 = load double*, double** %5
%19 = getelementptr inbounds double, double* %18, i64 1
%20 = load double, double* %19
%21 = fadd double %17, %20
%22 = call double @cos(double %21)
%23 = load double*, double** %6
%24 = load double, double* %23
%25 = call double @llvm.fmuladd.f64(double 2.456000e+02, double %22, double %24)
store double %25, double* %23
%26 = load double*, double** %5
%27 = getelementptr inbounds double, double* %26, i64 0
%28 = load double, double* %27
%29 = load double*, double** %5
%30 = getelementptr inbounds double, double* %29, i64 1
%31 = load double, double* %30
%32 = fadd double %28, %31
%33 = load double*, double** %5
%34 = getelementptr inbounds double, double* %33, i64 2
%35 = load double, double* %34
%36 = fadd double %32, %35
%37 = call double @cos(double %36)
%38 = load double*, double** %6
%39 = load double, double* %38
%40 = call double @llvm.fmuladd.f64(double 6.270000e+01, double %37, double %39)
store double %40, double* %38
%41 = load double*, double** %5
%42 = getelementptr inbounds double, double* %41, i64 0
%43 = load double, double* %42
%44 = call double @sin(double %43)
%45 = fmul double 2.223000e+02, %44
%46 = load double*, double** %7
store double %45, double* %46
%47 = load double*, double** %5
%48 = getelementptr inbounds double, double* %47, i64 0
%49 = load double, double* %48
%50 = load double*, double** %5
%51 = getelementptr inbounds double, double* %50, i64 1
%52 = load double, double* %51
%53 = fadd double %49, %52
%54 = call double @sin(double %53)
%55 = load double*, double** %7
%56 = load double, double* %55
%57 = call double @llvm.fmuladd.f64(double 2.456000e+02, double %54, double %56)
store double %57, double* %55
%58 = load double*, double** %5
%59 = getelementptr inbounds double, double* %58, i64 0
%60 = load double, double* %59
%61 = load double*, double** %5
%62 = getelementptr inbounds double, double* %61, i64 1
%63 = load double, double* %62
%64 = fadd double %60, %63
%65 = load double*, double** %5
%66 = getelementptr inbounds double, double* %65, i64 2
%67 = load double, double* %66
%68 = fadd double %64, %67
%69 = call double @sin(double %68)
%70 = load double*, double** %7
%71 = load double, double* %70
%72 = call double @llvm.fmuladd.f64(double 6.270000e+01, double %69, double %71)
store double %72, double* %70
%73 = load double*, double** %5
%74 = getelementptr inbounds double, double* %73, i64 0
%75 = load double, double* %74
%76 = load double*, double** %5
%77 = getelementptr inbounds double, double* %76, i64 1
%78 = load double, double* %77
%79 = fadd double %75, %78
%80 = load double*, double** %5
%81 = getelementptr inbounds double, double* %80, i64 2
%82 = load double, double* %81
%83 = fadd double %79, %82
%84 = load double*, double** %8
store double %83, double* %84
ret void
}

LLVM IR (-O2):
define void @latero_forward_kinematics(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture writeonly %3) {
%5 = load double, double* %0
%6 = tail call double @cos(double %5)
%7 = fmul double %6, 2.223000e+02
store double %7, double* %1
%8 = load double, double* %0
%9 = getelementptr inbounds double, double* %0, i64 1
%10 = load double, double* %9
%11 = fadd double %8, %10
%12 = tail call double @cos(double %11)
%13 = load double, double* %1
%14 = tail call double @llvm.fmuladd.f64(double %12, double 2.456000e+02, double %13)
store double %14, double* %1
%15 = load double, double* %0
%16 = load double, double* %9
%17 = fadd double %15, %16
%18 = getelementptr inbounds double, double* %0, i64 2
%19 = load double, double* %18
%20 = fadd double %17, %19
%21 = tail call double @cos(double %20)
%22 = load double, double* %1
%23 = tail call double @llvm.fmuladd.f64(double %21, double 6.270000e+01, double %22)
store double %23, double* %1
%24 = load double, double* %0
%25 = tail call double @sin(double %24)
%26 = fmul double %25, 2.223000e+02
store double %26, double* %2
%27 = load double, double* %0
%28 = load double, double* %9
%29 = fadd double %27, %28
%30 = tail call double @sin(double %29)
%31 = load double, double* %2
%32 = tail call double @llvm.fmuladd.f64(double %30, double 2.456000e+02, double %31)
store double %32, double* %2
%33 = load double, double* %0
%34 = load double, double* %9
%35 = fadd double %33, %34
%36 = load double, double* %18
%37 = fadd double %35, %36
%38 = tail call double @sin(double %37)
%39 = load double, double* %2
%40 = tail call double @llvm.fmuladd.f64(double %38, double 6.270000e+01, double %39)
store double %40, double* %2
%41 = load double, double* %0
%42 = load double, double* %9
%43 = fadd double %41, %42
%44 = load double, double* %18
%45 = fadd double %43, %44
store double %45, double* %3
ret void
}