#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 *ej1(int);
int /*<<< orphan*/ printf(char *);
double *ej2(double *u, double *v, int num) {
  if (num == 3) {
    int i;
    double *w = ej1(num);
    w[0] = u[1] * v[2] - u[2] * v[1];
    w[1] = u[2] * v[0] - u[0] * v[2];
    w[2] = u[0] * v[1] - u[1] * v[0];
    return w;
  } else {
    printf("ERROR: Producto vectorial definido solo para 3 dimensiones.\n");
    return 0;
  }
}


x86 assembly (clang, -O0):
<ej2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jne    1235 <ej2+0x115>
mov    -0x1c(%rbp),%edi
call   1040 <ej1@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm1
mov    -0x18(%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    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x18(%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    -0x28(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
mulsd  (%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,0x10(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1249 <ej2+0x129>
lea    0xdc4(%rip),%rdi
call   1030 <printf@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ej2>:
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edx
jne    1193 <ej2+0x73>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x3,%edi
call   1040 <ej1@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)
jmp    11a1 <ej2+0x81>
lea    0xe66(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@str = [60 x i8] c"ERROR: Producto vectorial definido solo para 3 dimensiones.\00"
define double* @ej2(double* nocapture %0, double* nocapture %1, i32 %2) {
%4 = icmp eq i32 %2, 3
br i1 %4, label %5, label %34
5: ; preds = %3
%6 = tail call double* @ej1(i32 3)
%7 = getelementptr inbounds double, double* %0, i64 1
%8 = load double, double* %7
%9 = getelementptr inbounds double, double* %1, i64 2
%10 = load double, double* %9
%11 = getelementptr inbounds double, double* %0, i64 2
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %1, i64 1
%14 = load double, double* %13
%15 = fneg double %12
%16 = fmul double %14, %15
%17 = tail call double @llvm.fmuladd.f64(double %8, double %10, double %16)
store double %17, double* %6
%18 = load double, double* %11
%19 = load double, double* %1
%20 = load double, double* %0
%21 = load double, double* %9
%22 = fneg double %20
%23 = fmul double %21, %22
%24 = tail call double @llvm.fmuladd.f64(double %18, double %19, double %23)
%25 = getelementptr inbounds double, double* %6, i64 1
store double %24, double* %25
%26 = load double, double* %0
%27 = load double, double* %13
%28 = load double, double* %7
%29 = load double, double* %1
%30 = fneg double %28
%31 = fmul double %29, %30
%32 = tail call double @llvm.fmuladd.f64(double %26, double %27, double %31)
%33 = getelementptr inbounds double, double* %6, i64 2
store double %32, double* %33
br label %36
34: ; preds = %3
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str, i64 0, i64 0))
br label %36
36: ; preds = %34, %5
%37 = phi double* [ %6, %5 ], [ null, %34 ]
ret double* %37
}