#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 */
scalar_t__ malloc(int);
double *cross(double a_pos[3], double b_pos[3]) {
  double *product = (double *)malloc(3 * sizeof(double));
  product[0] = b_pos[2] * a_pos[1] - b_pos[1] * a_pos[2];
  product[1] = -1 * (b_pos[2] * a_pos[0] - b_pos[0] * a_pos[2]);
  product[2] = b_pos[1] * a_pos[0] - b_pos[0] * a_pos[1];
  return product;
}


x86 assembly (clang, -O0):
<cross>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x18,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x8(%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,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mulsd  0x10(%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe3e(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x8(%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,0x10(%rax)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cross>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    $0x18,%edi
call   1030 <malloc@plt>
movsd  0x10(%rbx),%xmm0
movsd  0x10(%r14),%xmm1
mulsd  0x8(%rbx),%xmm1
mulsd  0x8(%r14),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
movsd  0x10(%rbx),%xmm0
movsd  0x10(%r14),%xmm1
mulsd  (%rbx),%xmm1
mulsd  (%r14),%xmm0
subsd  %xmm1,%xmm0
xorpd  0xe9e(%rip),%xmm0
movlpd %xmm0,0x8(%rax)
movsd  0x8(%rbx),%xmm0
movsd  0x8(%r14),%xmm1
mulsd  (%rbx),%xmm1
mulsd  (%r14),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double* @cross(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
%5 = alloca double*
store double* %0, double** %3
store double* %1, double** %4
%6 = call i64 @malloc(i32 24)
%7 = inttoptr i64 %6 to double*
store double* %7, double** %5
%8 = load double*, double** %4
%9 = getelementptr inbounds double, double* %8, i64 2
%10 = load double, double* %9
%11 = load double*, double** %3
%12 = getelementptr inbounds double, double* %11, i64 1
%13 = load double, double* %12
%14 = load double*, double** %4
%15 = getelementptr inbounds double, double* %14, i64 1
%16 = load double, double* %15
%17 = load double*, double** %3
%18 = getelementptr inbounds double, double* %17, i64 2
%19 = load double, double* %18
%20 = fmul double %16, %19
%21 = fneg double %20
%22 = call double @llvm.fmuladd.f64(double %10, double %13, double %21)
%23 = load double*, double** %5
%24 = getelementptr inbounds double, double* %23, i64 0
store double %22, double* %24
%25 = load double*, double** %4
%26 = getelementptr inbounds double, double* %25, i64 2
%27 = load double, double* %26
%28 = load double*, double** %3
%29 = getelementptr inbounds double, double* %28, i64 0
%30 = load double, double* %29
%31 = load double*, double** %4
%32 = getelementptr inbounds double, double* %31, i64 0
%33 = load double, double* %32
%34 = load double*, double** %3
%35 = getelementptr inbounds double, double* %34, i64 2
%36 = load double, double* %35
%37 = fmul double %33, %36
%38 = fneg double %37
%39 = call double @llvm.fmuladd.f64(double %27, double %30, double %38)
%40 = fmul double -1.000000e+00, %39
%41 = load double*, double** %5
%42 = getelementptr inbounds double, double* %41, i64 1
store double %40, double* %42
%43 = load double*, double** %4
%44 = getelementptr inbounds double, double* %43, i64 1
%45 = load double, double* %44
%46 = load double*, double** %3
%47 = getelementptr inbounds double, double* %46, i64 0
%48 = load double, double* %47
%49 = load double*, double** %4
%50 = getelementptr inbounds double, double* %49, i64 0
%51 = load double, double* %50
%52 = load double*, double** %3
%53 = getelementptr inbounds double, double* %52, i64 1
%54 = load double, double* %53
%55 = fmul double %51, %54
%56 = fneg double %55
%57 = call double @llvm.fmuladd.f64(double %45, double %48, double %56)
%58 = load double*, double** %5
%59 = getelementptr inbounds double, double* %58, i64 2
store double %57, double* %59
%60 = load double*, double** %5
ret double* %60
}

LLVM IR (-O2):
define double* @cross(double* nocapture %0, double* nocapture %1) {
%3 = tail call i64 @malloc(i32 24)
%4 = inttoptr i64 %3 to double*
%5 = getelementptr inbounds double, double* %1, i64 2
%6 = load double, double* %5
%7 = getelementptr inbounds double, double* %0, i64 1
%8 = load double, double* %7
%9 = getelementptr inbounds double, double* %1, i64 1
%10 = load double, double* %9
%11 = getelementptr inbounds double, double* %0, i64 2
%12 = load double, double* %11
%13 = fneg double %10
%14 = fmul double %12, %13
%15 = tail call double @llvm.fmuladd.f64(double %6, double %8, double %14)
store double %15, double* %4
%16 = load double, double* %5
%17 = load double, double* %0
%18 = load double, double* %1
%19 = load double, double* %11
%20 = fneg double %18
%21 = fmul double %19, %20
%22 = tail call double @llvm.fmuladd.f64(double %16, double %17, double %21)
%23 = fneg double %22
%24 = getelementptr inbounds double, double* %4, i64 1
store double %23, double* %24
%25 = load double, double* %9
%26 = load double, double* %0
%27 = load double, double* %1
%28 = load double, double* %7
%29 = fneg double %27
%30 = fmul double %28, %29
%31 = tail call double @llvm.fmuladd.f64(double %25, double %26, double %30)
%32 = getelementptr inbounds double, double* %4, i64 2
store double %31, double* %32
ret double* %4
}