#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, double, double, double);
int /*<<< orphan*/ stderr;
scalar_t__ vec3_cmp(double *, double *);
int /*<<< orphan*/ vec3_cross(double *, double *, double *);
int test_vector(void) {
  double v0[3] = {3., -3., 1.};
  double v1[3] = {4., 9., 2.};
  double v2[3] = {-12., 12., -4.};
  double u[3];
  double u01[3] = {-15., -2., 39.};
  double u02[3] = {0., 0., 0.};
  vec3_cross(u, v0, v1);
  if (vec3_cmp(u, u01)) {
    fprintf(stderr, "Error with cross product!\n");
    printf("Got: %0.3f, %0.3f, %0.3f", u[0], u[1], u[2]);
    printf("Expected: %0.3f, %0.3f, %0.3f", u01[0], u01[1], u01[2]);
    return -1;
  }
  vec3_cross(u, v0, v2);
  if (vec3_cmp(u, u02)) {
    fprintf(stderr, "Error with cross product!\n");
    printf("Got: %0.3f, %0.3f, %0.3f", u[0], u[1], u[2]);
    printf("Expected: %0.3f, %0.3f, %0.3f", u02[0], u02[1], u02[2]);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_vector>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    0xe9e(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe9b(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe98(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xe9d(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe9c(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xe99(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0xe96(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe9b(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    0xe95(%rip),%rax
mov    %rax,-0x98(%rbp)
mov    0xe8f(%rip),%rax
mov    %rax,-0x90(%rbp)
lea    -0xc0(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
lea    -0x80(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1040 <vec3_cross@plt>
lea    -0x80(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1070 <vec3_cmp@plt>
cmp    $0x0,%rax
je     1286 <test_vector+0x136>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
lea    0xe42(%rip),%rsi
call   1060 <fprintf@plt>
movsd  -0x80(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm2
lea    0xe42(%rip),%rdi
call   1030 <printf@plt>
movsd  -0xa0(%rbp),%xmm0
ff
movsd  -0x98(%rbp),%xmm1
ff
movsd  -0x90(%rbp),%xmm2
ff
lea    0xe37(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1318 <test_vector+0x1c8>
lea    -0x80(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1040 <vec3_cross@plt>
lea    -0x80(%rbp),%rdi
lea    -0xc0(%rbp),%rsi
call   1070 <vec3_cmp@plt>
cmp    $0x0,%rax
je     1311 <test_vector+0x1c1>
mov    0x2d28(%rip),%rax
mov    (%rax),%edi
lea    0xdb7(%rip),%rsi
call   1060 <fprintf@plt>
movsd  -0x80(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm1
movsd  -0x70(%rbp),%xmm2
lea    0xdb7(%rip),%rdi
call   1030 <printf@plt>
movsd  -0xc0(%rbp),%xmm0
ff
movsd  -0xb8(%rbp),%xmm1
ff
movsd  -0xb0(%rbp),%xmm2
ff
lea    0xdac(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1318 <test_vector+0x1c8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_vector>:
push   %r14
push   %rbx
sub    $0xb8,%rsp
mov    0xebf(%rip),%rax
mov    %rax,0x70(%rsp)
movaps 0xea3(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
mov    0xec7(%rip),%rax
mov    %rax,0xb0(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
mov    0xec9(%rip),%rax
mov    %rax,0x90(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
mov    0xecb(%rip),%rax
mov    %rax,0x50(%rsp)
movaps 0xeaf(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movq   $0x0,0x30(%rsp)
mov    %rsp,%r14
lea    0x60(%rsp),%rsi
lea    0xa0(%rsp),%rdx
mov    %r14,%rdi
call   1040 <vec3_cross@plt>
lea    0x40(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <vec3_cmp@plt>
test   %rax,%rax
je     122e <test_vector+0xee>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
call   1050 <fprintf@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
movsd  0x40(%rsp),%xmm0
jmp    1293 <test_vector+0x153>
mov    %rsp,%r14
lea    0x60(%rsp),%rsi
lea    0x80(%rsp),%rdx
mov    %r14,%rdi
call   1040 <vec3_cross@plt>
lea    0x20(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <vec3_cmp@plt>
test   %rax,%rax
je     12b9 <test_vector+0x179>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
lea    0xe0d(%rip),%rsi
call   1050 <fprintf@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
lea    0xe0b(%rip),%rdi
call   1030 <printf@plt>
movsd  0x20(%rsp),%xmm0
movsd  0x8(%rbx),%xmm1
movsd  0x10(%rbx),%xmm2
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
jmp    12ae <test_vector+0x16e>

LLVM IR (-O0):
@__const.test_vector.v0 = [3 x double] [double 3.000000e+00, double -3.000000e+00, double 1.000000e+00]
@__const.test_vector.v1 = [3 x double] [double 4.000000e+00, double 9.000000e+00, double 2.000000e+00]
@__const.test_vector.v2 = [3 x double] [double -1.200000e+01, double 1.200000e+01, double -4.000000e+00]
@__const.test_vector.u01 = [3 x double] [double -1.500000e+01, double -2.000000e+00, double 3.900000e+01]
@stderr = global i32 0
@.str = [27 x i8] c"Error with cross product!\0A\00"
@.str.1 = [25 x i8] c"Got: %0.3f, %0.3f, %0.3f\00"
@.str.2 = [30 x i8] c"Expected: %0.3f, %0.3f, %0.3f\00"
define i32 @test_vector() {
%1 = alloca i32
%2 = alloca [3 x double]
%3 = alloca [3 x double]
%4 = alloca [3 x double]
%5 = alloca [3 x double]
%6 = alloca [3 x double]
%7 = alloca [3 x double]
%8 = bitcast [3 x double]* %2 to i8*
%9 = bitcast [3 x double]* %3 to i8*
%10 = bitcast [3 x double]* %4 to i8*
%11 = bitcast [3 x double]* %6 to i8*
%12 = bitcast [3 x double]* %7 to i8*
%13 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%14 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%15 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%16 = call i32 @vec3_cross(double* %13, double* %14, double* %15)
%17 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%18 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%19 = call i64 @vec3_cmp(double* %17, double* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %38
21: ; preds = %0
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%24 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%25 = load double, double* %24
%26 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
%27 = load double, double* %26
%28 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%29 = load double, double* %28
%30 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double %25, double %27, double %29)
%31 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%32 = load double, double* %31
%33 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 1
%34 = load double, double* %33
%35 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
%36 = load double, double* %35
%37 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), double %32, double %34, double %36)
store i32 -1, i32* %1
br label %65
38: ; preds = %0
%39 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%40 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%41 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%42 = call i32 @vec3_cross(double* %39, double* %40, double* %41)
%43 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%44 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%45 = call i64 @vec3_cmp(double* %43, double* %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %64
47: ; preds = %38
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%50 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%51 = load double, double* %50
%52 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
%53 = load double, double* %52
%54 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%55 = load double, double* %54
%56 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double %51, double %53, double %55)
%57 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%58 = load double, double* %57
%59 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 1
%60 = load double, double* %59
%61 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 2
%62 = load double, double* %61
%63 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), double %58, double %60, double %62)
store i32 -1, i32* %1
br label %65
64: ; preds = %38
store i32 0, i32* %1
br label %65
65: ; preds = %64, %47, %21
%66 = load i32, i32* %1
ret i32 %66
}

LLVM IR (-O2):
@__const.test_vector.v0 = [3 x double] [double 3.000000e+00, double -3.000000e+00, double 1.000000e+00]
@__const.test_vector.v1 = [3 x double] [double 4.000000e+00, double 9.000000e+00, double 2.000000e+00]
@__const.test_vector.v2 = [3 x double] [double -1.200000e+01, double 1.200000e+01, double -4.000000e+00]
@__const.test_vector.u01 = [3 x double] [double -1.500000e+01, double -2.000000e+00, double 3.900000e+01]
@stderr = global i32 0
@.str = [27 x i8] c"Error with cross product!\0A\00"
@.str.1 = [25 x i8] c"Got: %0.3f, %0.3f, %0.3f\00"
@.str.2 = [30 x i8] c"Expected: %0.3f, %0.3f, %0.3f\00"
define i32 @test_vector() {
%1 = alloca [3 x double]
%2 = alloca [3 x double]
%3 = alloca [3 x double]
%4 = alloca [3 x double]
%5 = alloca [3 x double]
%6 = alloca [3 x double]
%7 = bitcast [3 x double]* %1 to i8*
%8 = bitcast [3 x double]* %2 to i8*
%9 = bitcast [3 x double]* %3 to i8*
%10 = bitcast [3 x double]* %4 to i8*
%11 = bitcast [3 x double]* %5 to i8*
%12 = bitcast [3 x double]* %6 to i8*
%13 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%14 = getelementptr inbounds [3 x double], [3 x double]* %1, i64 0, i64 0
%15 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
%16 = call i32 @vec3_cross(double* %13, double* %14, double* %15)
%17 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%18 = call i64 @vec3_cmp(double* %13, double* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %30, label %20
20: ; preds = %0
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%23 = load double, double* %13
%24 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
%25 = load double, double* %24
%26 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
%27 = load double, double* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double %23, double %25, double %27)
%29 = load double, double* %17
br label %46
30: ; preds = %0
%31 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%32 = call i32 @vec3_cross(double* %13, double* %14, double* %31)
%33 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%34 = call i64 @vec3_cmp(double* %13, double* %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %54, label %36
36: ; preds = %30
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%39 = load double, double* %13
%40 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
%41 = load double, double* %40
%42 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
%43 = load double, double* %42
%44 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), double %39, double %41, double %43)
%45 = load double, double* %33
br label %46
46: ; preds = %20, %36
%47 = phi [3 x double]* [ %6, %36 ], [ %5, %20 ]
%48 = phi double [ %45, %36 ], [ %29, %20 ]
%49 = getelementptr inbounds [3 x double], [3 x double]* %47, i64 0, i64 1
%50 = load double, double* %49
%51 = getelementptr inbounds [3 x double], [3 x double]* %47, i64 0, i64 2
%52 = load double, double* %51
%53 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), double %48, double %50, double %52)
br label %54
54: ; preds = %46, %30
%55 = phi i32 [ 0, %30 ], [ -1, %46 ]
ret i32 %55
}