#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*/ fail(char *, int, int);
int vector_product(float *ab, float *a, float *b, int na, int nb) {
  if (na != 3 || nb != 3)
    fail("bad vector product (%d %d)", na, nb);
  ab[0] = a[1] * b[2] - a[2] * b[1];
  ab[1] = a[2] * b[0] - a[0] * b[2];
  ab[2] = a[0] * b[1] - a[1] * b[0];
  return 3;
}


x86 assembly (clang, -O0):
<vector_product>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jne    113f <vector_product+0x2f>
cmpl   $0x3,-0x20(%rbp)
je     1151 <vector_product+0x41>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xeb4(%rip),%rdi
call   1030 <fail@plt>
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  0x8(%rax),%xmm2
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulss  0x4(%rax),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm1
mov    -0x18(%rbp),%rax
mulss  0x8(%rax),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movss  0x4(%rax),%xmm2
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulss  (%rax),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
mov    $0x3,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vector_product>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
cmp    $0x3,%ecx
jne    1129 <vector_product+0x19>
cmp    $0x3,%r8d
je     113a <vector_product+0x2a>
lea    0xed0(%rip),%rdi
mov    %ecx,%esi
mov    %r8d,%edx
call   1030 <fail@plt>
movss  0x4(%rbx),%xmm0
movss  0x4(%r15),%xmm1
mulss  0x8(%rbx),%xmm1
mulss  0x8(%r15),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,(%r14)
movss  0x8(%rbx),%xmm0
movss  0x8(%r15),%xmm1
mulss  (%rbx),%xmm1
mulss  (%r15),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,0x4(%r14)
movss  (%rbx),%xmm0
movss  (%r15),%xmm1
mulss  0x4(%rbx),%xmm1
mulss  0x4(%r15),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,0x8(%r14)
mov    $0x3,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [27 x i8] c"bad vector product (%d %d)\00"
define i32 @vector_product(float* %0, float* %1, float* %2, i32 %3, i32 %4) {
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca i32
%10 = alloca i32
store float* %0, float** %6
store float* %1, float** %7
store float* %2, float** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32, i32* %9
%12 = icmp ne i32 %11, 3
br i1 %12, label %16, label %13
13: ; preds = %5
%14 = load i32, i32* %10
%15 = icmp ne i32 %14, 3
br i1 %15, label %16, label %20
16: ; preds = %13, %5
%17 = load i32, i32* %9
%18 = load i32, i32* %10
%19 = call i32 @fail(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18)
br label %20
20: ; preds = %16, %13
%21 = load float*, float** %7
%22 = getelementptr inbounds float, float* %21, i64 1
%23 = load float, float* %22
%24 = load float*, float** %8
%25 = getelementptr inbounds float, float* %24, i64 2
%26 = load float, float* %25
%27 = load float*, float** %7
%28 = getelementptr inbounds float, float* %27, i64 2
%29 = load float, float* %28
%30 = load float*, float** %8
%31 = getelementptr inbounds float, float* %30, i64 1
%32 = load float, float* %31
%33 = fmul float %29, %32
%34 = fneg float %33
%35 = call float @llvm.fmuladd.f32(float %23, float %26, float %34)
%36 = load float*, float** %6
%37 = getelementptr inbounds float, float* %36, i64 0
store float %35, float* %37
%38 = load float*, float** %7
%39 = getelementptr inbounds float, float* %38, i64 2
%40 = load float, float* %39
%41 = load float*, float** %8
%42 = getelementptr inbounds float, float* %41, i64 0
%43 = load float, float* %42
%44 = load float*, float** %7
%45 = getelementptr inbounds float, float* %44, i64 0
%46 = load float, float* %45
%47 = load float*, float** %8
%48 = getelementptr inbounds float, float* %47, i64 2
%49 = load float, float* %48
%50 = fmul float %46, %49
%51 = fneg float %50
%52 = call float @llvm.fmuladd.f32(float %40, float %43, float %51)
%53 = load float*, float** %6
%54 = getelementptr inbounds float, float* %53, i64 1
store float %52, float* %54
%55 = load float*, float** %7
%56 = getelementptr inbounds float, float* %55, i64 0
%57 = load float, float* %56
%58 = load float*, float** %8
%59 = getelementptr inbounds float, float* %58, i64 1
%60 = load float, float* %59
%61 = load float*, float** %7
%62 = getelementptr inbounds float, float* %61, i64 1
%63 = load float, float* %62
%64 = load float*, float** %8
%65 = getelementptr inbounds float, float* %64, i64 0
%66 = load float, float* %65
%67 = fmul float %63, %66
%68 = fneg float %67
%69 = call float @llvm.fmuladd.f32(float %57, float %60, float %68)
%70 = load float*, float** %6
%71 = getelementptr inbounds float, float* %70, i64 2
store float %69, float* %71
ret i32 3
}

LLVM IR (-O2):
@.str = [27 x i8] c"bad vector product (%d %d)\00"
define i32 @vector_product(float* nocapture writeonly %0, float* nocapture %1, float* nocapture %2, i32 %3, i32 %4) {
%6 = icmp ne i32 %3, 3
%7 = icmp ne i32 %4, 3
%8 = or i1 %6, %7
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call i32 @fail(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
br label %11
11: ; preds = %5, %9
%12 = getelementptr inbounds float, float* %1, i64 1
%13 = load float, float* %12
%14 = getelementptr inbounds float, float* %2, i64 2
%15 = load float, float* %14
%16 = getelementptr inbounds float, float* %1, i64 2
%17 = load float, float* %16
%18 = getelementptr inbounds float, float* %2, i64 1
%19 = load float, float* %18
%20 = fneg float %17
%21 = fmul float %19, %20
%22 = tail call float @llvm.fmuladd.f32(float %13, float %15, float %21)
store float %22, float* %0
%23 = load float, float* %16
%24 = load float, float* %2
%25 = load float, float* %1
%26 = load float, float* %14
%27 = fneg float %25
%28 = fmul float %26, %27
%29 = tail call float @llvm.fmuladd.f32(float %23, float %24, float %28)
%30 = getelementptr inbounds float, float* %0, i64 1
store float %29, float* %30
%31 = load float, float* %1
%32 = load float, float* %18
%33 = load float, float* %12
%34 = load float, float* %2
%35 = fneg float %33
%36 = fmul float %34, %35
%37 = tail call float @llvm.fmuladd.f32(float %31, float %32, float %36)
%38 = getelementptr inbounds float, float* %0, i64 2
store float %37, float* %38
ret i32 3
}