#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 sqrt(double);
double x_product(double *a, double *b, double *c) {
  int xp_nd[] = {1, 2, 0, 1};
  double norm = 0;
  int k, l;
  for (k = 0, l = 1; k < 3; k++, l++) {
    c[k] = a[xp_nd[k]] * b[xp_nd[l]] - a[xp_nd[l]] * b[xp_nd[k]];
    norm += c[k] * c[k];
  }
  return sqrt(norm);
}


x86 assembly (clang, -O0):
<x_product>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0xed5(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xed2(%rip),%rax
mov    %rax,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x1,-0x40(%rbp)
cmpl   $0x3,-0x3c(%rbp)
jge    1211 <x_product+0x101>
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movslq -0x30(%rbp,%rcx,4),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x40(%rbp),%rcx
movslq -0x30(%rbp,%rcx,4),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x8(%rbp),%rax
movslq -0x40(%rbp),%rcx
movslq -0x30(%rbp,%rcx,4),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movslq -0x30(%rbp,%rcx,4),%rcx
mulsd  (%rax,%rcx,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1150 <x_product+0x40>
movsd  -0x38(%rbp),%xmm0
call   1030 <sqrt@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<x_product>:
movsd  0x8(%rdi),%xmm0
movsd  0x8(%rsi),%xmm1
mulsd  0x10(%rdi),%xmm1
mulsd  0x10(%rsi),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rdx)
mulsd  %xmm0,%xmm0
xorpd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
movsd  0x10(%rdi),%xmm2
movsd  0x10(%rsi),%xmm3
mulsd  (%rdi),%xmm3
mulsd  (%rsi),%xmm2
subsd  %xmm3,%xmm2
movsd  %xmm2,0x8(%rdx)
mulsd  %xmm2,%xmm2
addsd  %xmm0,%xmm2
movsd  (%rdi),%xmm0
movsd  (%rsi),%xmm3
mulsd  0x8(%rdi),%xmm3
mulsd  0x8(%rsi),%xmm0
subsd  %xmm3,%xmm0
movsd  %xmm0,0x10(%rdx)
mulsd  %xmm0,%xmm0
addsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jb     1189 <x_product+0x79>
sqrtsd %xmm0,%xmm0
ret
jmp    1030 <sqrt@plt>

LLVM IR (-O0):
@__const.x_product.xp_nd = [4 x i32] [i32 1, i32 2, i32 0, i32 1]
define double @x_product(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca [4 x i32]
%8 = alloca double
%9 = alloca i32
%10 = alloca i32
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%11 = bitcast [4 x i32]* %7 to i8*
store double 0.000000e+00, double* %8
store i32 0, i32* %9
store i32 1, i32* %10
br label %12
12: ; preds = %67, %3
%13 = load i32, i32* %9
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %72
15: ; preds = %12
%16 = load double*, double** %4
%17 = load i32, i32* %9
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %16, i64 %21
%23 = load double, double* %22
%24 = load double*, double** %5
%25 = load i32, i32* %10
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %24, i64 %29
%31 = load double, double* %30
%32 = load double*, double** %4
%33 = load i32, i32* %10
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds double, double* %32, i64 %37
%39 = load double, double* %38
%40 = load double*, double** %5
%41 = load i32, i32* %9
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [4 x i32], [4 x i32]* %7, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %40, i64 %45
%47 = load double, double* %46
%48 = fmul double %39, %47
%49 = fneg double %48
%50 = call double @llvm.fmuladd.f64(double %23, double %31, double %49)
%51 = load double*, double** %6
%52 = load i32, i32* %9
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
store double %50, double* %54
%55 = load double*, double** %6
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds double, double* %55, i64 %57
%59 = load double, double* %58
%60 = load double*, double** %6
%61 = load i32, i32* %9
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
%64 = load double, double* %63
%65 = load double, double* %8
%66 = call double @llvm.fmuladd.f64(double %59, double %64, double %65)
store double %66, double* %8
br label %67
67: ; preds = %15
%68 = load i32, i32* %9
%69 = add nsw i32 %68, 1
store i32 %69, i32* %9
%70 = load i32, i32* %10
%71 = add nsw i32 %70, 1
store i32 %71, i32* %10
br label %12
72: ; preds = %12
%73 = load double, double* %8
%74 = call double @sqrt(double %73)
ret double %74
}

LLVM IR (-O2):
define double @x_product(double* nocapture %0, double* nocapture %1, double* nocapture writeonly %2) {
%4 = getelementptr inbounds double, double* %0, i64 1
%5 = load double, double* %4
%6 = getelementptr inbounds double, double* %1, i64 2
%7 = load double, double* %6
%8 = getelementptr inbounds double, double* %0, i64 2
%9 = load double, double* %8
%10 = getelementptr inbounds double, double* %1, i64 1
%11 = load double, double* %10
%12 = fneg double %9
%13 = fmul double %11, %12
%14 = tail call double @llvm.fmuladd.f64(double %5, double %7, double %13)
store double %14, double* %2
%15 = tail call double @llvm.fmuladd.f64(double %14, double %14, double 0.000000e+00)
%16 = load double, double* %8
%17 = load double, double* %1
%18 = load double, double* %0
%19 = load double, double* %6
%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* %2, i64 1
store double %22, double* %23
%24 = tail call double @llvm.fmuladd.f64(double %22, double %22, double %15)
%25 = load double, double* %0
%26 = load double, double* %10
%27 = load double, double* %4
%28 = load double, double* %1
%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* %2, i64 2
store double %31, double* %32
%33 = tail call double @llvm.fmuladd.f64(double %31, double %31, double %24)
%34 = tail call double @sqrt(double %33)
ret double %34
}