#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_product(double *v1, double *v2) {
  double *output;
  output = (double *)malloc(sizeof(double) * 3);
  output[0] = v1[1] * v2[2] - v1[2] * v2[1];
  output[1] = v1[2] * v2[0] - v1[0] * v2[2];
  output[2] = v1[0] * v2[1] - v1[1] * v2[0];
  return output;
}


x86 assembly (clang, -O0):
<cross_product>:
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    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%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
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%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,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x10(%rbp),%rax
mulsd  (%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_product>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x18,%edi
call   1030 <malloc@plt>
movsd  0x8(%rbx),%xmm0
movsd  0x8(%r14),%xmm1
mulsd  0x10(%rbx),%xmm1
mulsd  0x10(%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
movsd  %xmm0,0x8(%rax)
movsd  (%rbx),%xmm0
movsd  (%r14),%xmm1
mulsd  0x8(%rbx),%xmm1
mulsd  0x8(%r14),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double* @cross_product(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** %3
%9 = getelementptr inbounds double, double* %8, i64 1
%10 = load double, double* %9
%11 = load double*, double** %4
%12 = getelementptr inbounds double, double* %11, i64 2
%13 = load double, double* %12
%14 = load double*, double** %3
%15 = getelementptr inbounds double, double* %14, i64 2
%16 = load double, double* %15
%17 = load double*, double** %4
%18 = getelementptr inbounds double, double* %17, i64 1
%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** %3
%26 = getelementptr inbounds double, double* %25, i64 2
%27 = load double, double* %26
%28 = load double*, double** %4
%29 = getelementptr inbounds double, double* %28, i64 0
%30 = load double, double* %29
%31 = load double*, double** %3
%32 = getelementptr inbounds double, double* %31, i64 0
%33 = load double, double* %32
%34 = load double*, double** %4
%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 = load double*, double** %5
%41 = getelementptr inbounds double, double* %40, i64 1
store double %39, double* %41
%42 = load double*, double** %3
%43 = getelementptr inbounds double, double* %42, i64 0
%44 = load double, double* %43
%45 = load double*, double** %4
%46 = getelementptr inbounds double, double* %45, i64 1
%47 = load double, double* %46
%48 = load double*, double** %3
%49 = getelementptr inbounds double, double* %48, i64 1
%50 = load double, double* %49
%51 = load double*, double** %4
%52 = getelementptr inbounds double, double* %51, i64 0
%53 = load double, double* %52
%54 = fmul double %50, %53
%55 = fneg double %54
%56 = call double @llvm.fmuladd.f64(double %44, double %47, double %55)
%57 = load double*, double** %5
%58 = getelementptr inbounds double, double* %57, i64 2
store double %56, double* %58
%59 = load double*, double** %5
ret double* %59
}

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