#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*/ crossVectors(float *, float *, float *);
scalar_t__ dotVectors(float *, float *);
int /*<<< orphan*/ normalizeVector(float *);
void computeNormal2EdgeOfTriangle(const float *v0, const float *v1,
                                  const float *v2, float *norm2edge) {
  float v0v1[3], v0v2[3], norm2triangle[3];
  v0v1[0] = v1[0] - v0[0];
  v0v1[1] = v1[1] - v0[1];
  v0v1[2] = v1[2] - v0[2];
  normalizeVector(v0v1);
  v0v2[0] = v2[0] - v0[0];
  v0v2[1] = v2[1] - v0[1];
  v0v2[2] = v2[2] - v0[2];
  normalizeVector(v0v2);
  crossVectors(v0v1, v0v2, norm2triangle);
  normalizeVector(norm2triangle);
  crossVectors(v0v1, norm2triangle, norm2edge);
  normalizeVector(norm2edge);
  if (dotVectors(v0v2, norm2edge) < 0) {
    norm2edge[0] = -norm2edge[0];
    norm2edge[1] = -norm2edge[1];
    norm2edge[2] = -norm2edge[2];
  }
}


x86 assembly (clang, -O0):
<computeNormal2EdgeOfTriangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subss  (%rax),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x8(%rbp),%rax
subss  0x4(%rax),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
subss  0x8(%rax),%xmm0
movss  %xmm0,-0x24(%rbp)
lea    -0x2c(%rbp),%rdi
call   1040 <normalizeVector@plt>
mov    -0x18(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subss  (%rax),%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
movss  0x4(%rax),%xmm0
mov    -0x8(%rbp),%rax
subss  0x4(%rax),%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x18(%rbp),%rax
movss  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
subss  0x8(%rax),%xmm0
movss  %xmm0,-0x30(%rbp)
lea    -0x38(%rbp),%rdi
call   1040 <normalizeVector@plt>
lea    -0x2c(%rbp),%rdi
lea    -0x38(%rbp),%rsi
lea    -0x44(%rbp),%rdx
call   1050 <crossVectors@plt>
lea    -0x44(%rbp),%rdi
call   1040 <normalizeVector@plt>
lea    -0x2c(%rbp),%rdi
lea    -0x44(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <crossVectors@plt>
mov    -0x20(%rbp),%rdi
call   1040 <normalizeVector@plt>
lea    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <dotVectors@plt>
cmp    $0x0,%rax
jge    1286 <computeNormal2EdgeOfTriangle+0x156>
mov    -0x20(%rbp),%rax
movss  (%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movss  0x4(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,0x4(%rax)
mov    -0x20(%rbp),%rax
movss  0x8(%rax),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mov    -0x20(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<computeNormal2EdgeOfTriangle>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rdi,%rbx
movss  (%rsi),%xmm0
subss  (%rdi),%xmm0
movss  %xmm0,0x10(%rsp)
movss  0x4(%rsi),%xmm0
subss  0x4(%rdi),%xmm0
movss  %xmm0,0x14(%rsp)
movss  0x8(%rsi),%xmm0
subss  0x8(%rdi),%xmm0
movss  %xmm0,0x18(%rsp)
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1040 <normalizeVector@plt>
movss  (%r12),%xmm0
subss  (%rbx),%xmm0
movss  %xmm0,0x4(%rsp)
movss  0x4(%r12),%xmm0
subss  0x4(%rbx),%xmm0
movss  %xmm0,0x8(%rsp)
movss  0x8(%r12),%xmm0
subss  0x8(%rbx),%xmm0
movss  %xmm0,0xc(%rsp)
lea    0x4(%rsp),%r12
mov    %r12,%rdi
call   1040 <normalizeVector@plt>
lea    0x1c(%rsp),%rbx
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1050 <crossVectors@plt>
mov    %rbx,%rdi
call   1040 <normalizeVector@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1050 <crossVectors@plt>
mov    %r15,%rdi
call   1040 <normalizeVector@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <dotVectors@plt>
test   %rax,%rax
jns    1233 <computeNormal2EdgeOfTriangle+0x103>
movaps 0xdf8(%rip),%xmm0
movss  (%r15),%xmm1
movss  0x4(%r15),%xmm2
movss  0x8(%r15),%xmm3
xorps  %xmm0,%xmm1
movss  %xmm1,(%r15)
xorps  %xmm0,%xmm2
movss  %xmm2,0x4(%r15)
xorps  %xmm0,%xmm3
movss  %xmm3,0x8(%r15)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @computeNormal2EdgeOfTriangle(float* %0, float* %1, float* %2, float* %3) {
%5 = alloca float*
%6 = alloca float*
%7 = alloca float*
%8 = alloca float*
%9 = alloca [3 x float]
%10 = alloca [3 x float]
%11 = alloca [3 x float]
store float* %0, float** %5
store float* %1, float** %6
store float* %2, float** %7
store float* %3, float** %8
%12 = load float*, float** %6
%13 = getelementptr inbounds float, float* %12, i64 0
%14 = load float, float* %13
%15 = load float*, float** %5
%16 = getelementptr inbounds float, float* %15, i64 0
%17 = load float, float* %16
%18 = fsub float %14, %17
%19 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
store float %18, float* %19
%20 = load float*, float** %6
%21 = getelementptr inbounds float, float* %20, i64 1
%22 = load float, float* %21
%23 = load float*, float** %5
%24 = getelementptr inbounds float, float* %23, i64 1
%25 = load float, float* %24
%26 = fsub float %22, %25
%27 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 1
store float %26, float* %27
%28 = load float*, float** %6
%29 = getelementptr inbounds float, float* %28, i64 2
%30 = load float, float* %29
%31 = load float*, float** %5
%32 = getelementptr inbounds float, float* %31, i64 2
%33 = load float, float* %32
%34 = fsub float %30, %33
%35 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 2
store float %34, float* %35
%36 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%37 = call i32 @normalizeVector(float* %36)
%38 = load float*, float** %7
%39 = getelementptr inbounds float, float* %38, i64 0
%40 = load float, float* %39
%41 = load float*, float** %5
%42 = getelementptr inbounds float, float* %41, i64 0
%43 = load float, float* %42
%44 = fsub float %40, %43
%45 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
store float %44, float* %45
%46 = load float*, float** %7
%47 = getelementptr inbounds float, float* %46, i64 1
%48 = load float, float* %47
%49 = load float*, float** %5
%50 = getelementptr inbounds float, float* %49, i64 1
%51 = load float, float* %50
%52 = fsub float %48, %51
%53 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 1
store float %52, float* %53
%54 = load float*, float** %7
%55 = getelementptr inbounds float, float* %54, i64 2
%56 = load float, float* %55
%57 = load float*, float** %5
%58 = getelementptr inbounds float, float* %57, i64 2
%59 = load float, float* %58
%60 = fsub float %56, %59
%61 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 2
store float %60, float* %61
%62 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%63 = call i32 @normalizeVector(float* %62)
%64 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%65 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%66 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 0
%67 = call i32 @crossVectors(float* %64, float* %65, float* %66)
%68 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 0
%69 = call i32 @normalizeVector(float* %68)
%70 = getelementptr inbounds [3 x float], [3 x float]* %9, i64 0, i64 0
%71 = getelementptr inbounds [3 x float], [3 x float]* %11, i64 0, i64 0
%72 = load float*, float** %8
%73 = call i32 @crossVectors(float* %70, float* %71, float* %72)
%74 = load float*, float** %8
%75 = call i32 @normalizeVector(float* %74)
%76 = getelementptr inbounds [3 x float], [3 x float]* %10, i64 0, i64 0
%77 = load float*, float** %8
%78 = call i64 @dotVectors(float* %76, float* %77)
%79 = icmp slt i64 %78, 0
br i1 %79, label %80, label %99
80: ; preds = %4
%81 = load float*, float** %8
%82 = getelementptr inbounds float, float* %81, i64 0
%83 = load float, float* %82
%84 = fneg float %83
%85 = load float*, float** %8
%86 = getelementptr inbounds float, float* %85, i64 0
store float %84, float* %86
%87 = load float*, float** %8
%88 = getelementptr inbounds float, float* %87, i64 1
%89 = load float, float* %88
%90 = fneg float %89
%91 = load float*, float** %8
%92 = getelementptr inbounds float, float* %91, i64 1
store float %90, float* %92
%93 = load float*, float** %8
%94 = getelementptr inbounds float, float* %93, i64 2
%95 = load float, float* %94
%96 = fneg float %95
%97 = load float*, float** %8
%98 = getelementptr inbounds float, float* %97, i64 2
store float %96, float* %98
br label %99
99: ; preds = %80, %4
ret void
}

LLVM IR (-O2):
define void @computeNormal2EdgeOfTriangle(float* nocapture %0, float* nocapture %1, float* nocapture %2, float* %3) {
%5 = alloca [3 x float]
%6 = alloca [3 x float]
%7 = alloca [3 x float]
%8 = bitcast [3 x float]* %5 to i8*
%9 = bitcast [3 x float]* %6 to i8*
%10 = bitcast [3 x float]* %7 to i8*
%11 = load float, float* %1
%12 = load float, float* %0
%13 = fsub float %11, %12
%14 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 0
store float %13, float* %14
%15 = getelementptr inbounds float, float* %1, i64 1
%16 = load float, float* %15
%17 = getelementptr inbounds float, float* %0, i64 1
%18 = load float, float* %17
%19 = fsub float %16, %18
%20 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 1
store float %19, float* %20
%21 = getelementptr inbounds float, float* %1, i64 2
%22 = load float, float* %21
%23 = getelementptr inbounds float, float* %0, i64 2
%24 = load float, float* %23
%25 = fsub float %22, %24
%26 = getelementptr inbounds [3 x float], [3 x float]* %5, i64 0, i64 2
store float %25, float* %26
%27 = call i32 @normalizeVector(float* %14)
%28 = load float, float* %2
%29 = load float, float* %0
%30 = fsub float %28, %29
%31 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 0
store float %30, float* %31
%32 = getelementptr inbounds float, float* %2, i64 1
%33 = load float, float* %32
%34 = load float, float* %17
%35 = fsub float %33, %34
%36 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 1
store float %35, float* %36
%37 = getelementptr inbounds float, float* %2, i64 2
%38 = load float, float* %37
%39 = load float, float* %23
%40 = fsub float %38, %39
%41 = getelementptr inbounds [3 x float], [3 x float]* %6, i64 0, i64 2
store float %40, float* %41
%42 = call i32 @normalizeVector(float* %31)
%43 = getelementptr inbounds [3 x float], [3 x float]* %7, i64 0, i64 0
%44 = call i32 @crossVectors(float* %14, float* %31, float* %43)
%45 = call i32 @normalizeVector(float* %43)
%46 = call i32 @crossVectors(float* %14, float* %43, float* %3)
%47 = call i32 @normalizeVector(float* %3)
%48 = call i64 @dotVectors(float* %31, float* %3)
%49 = icmp slt i64 %48, 0
br i1 %49, label %50, label %59
50: ; preds = %4
%51 = load float, float* %3
%52 = fneg float %51
store float %52, float* %3
%53 = getelementptr inbounds float, float* %3, i64 1
%54 = load float, float* %53
%55 = fneg float %54
store float %55, float* %53
%56 = getelementptr inbounds float, float* %3, i64 2
%57 = load float, float* %56
%58 = fneg float %57
store float %58, float* %56
br label %59
59: ; preds = %50, %4
ret void
}