#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 */
typedef float GLfloat;

/* Variables and functions */
float sqrt(float);
int calculate_normal(GLfloat xv, GLfloat yv, GLfloat zv, GLfloat x1, GLfloat y1,
                     GLfloat z1, GLfloat x2, GLfloat y2, GLfloat z2,
                     GLfloat *result_x, GLfloat *result_y, GLfloat *result_z) {
  float vx, vy, vz, wx, wy, wz;
  float rx, ry, rz, length;
  vx = x1 - xv;
  vy = y1 - yv;
  vz = z1 - zv;
  wx = x2 - xv;
  wy = y2 - yv;
  wz = z2 - zv;
  rx = (vy * wz) - (wy * wz);
  ry = (wx * vz) - (vx * wz);
  rz = (vx * wy) - (wx * vy);
  length = sqrt((rx * rx) + (ry * ry) + (rz * rz));
  *result_x = rx / length;
  *result_y = ry / length;
  *result_z = rz / length;
  return 0;
}


x86 assembly (clang, -O0):
<calculate_normal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movss  0x10(%rbp),%xmm8
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  %xmm4,-0x14(%rbp)
movss  %xmm5,-0x18(%rbp)
movss  %xmm6,-0x1c(%rbp)
movss  %xmm7,-0x20(%rbp)
mov    %rdi,-0x28(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
movss  -0x10(%rbp),%xmm0
subss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x14(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x18(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x1c(%rbp),%xmm0
subss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
movss  -0x20(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
movss  0x10(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x50(%rbp)
movss  -0x40(%rbp),%xmm0
movss  -0x50(%rbp),%xmm2
movss  -0x4c(%rbp),%xmm1
mulss  -0x50(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x54(%rbp)
movss  -0x48(%rbp),%xmm0
movss  -0x44(%rbp),%xmm2
movss  -0x3c(%rbp),%xmm1
mulss  -0x50(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x58(%rbp)
movss  -0x3c(%rbp),%xmm0
movss  -0x4c(%rbp),%xmm2
movss  -0x48(%rbp),%xmm1
mulss  -0x40(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x5c(%rbp)
movss  -0x54(%rbp),%xmm1
movss  -0x54(%rbp),%xmm2
movss  -0x58(%rbp),%xmm0
mulss  -0x58(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x5c(%rbp),%xmm0
movss  -0x5c(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <sqrt@plt>
movss  %xmm0,-0x60(%rbp)
movss  -0x54(%rbp),%xmm0
divss  -0x60(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x58(%rbp),%xmm0
divss  -0x60(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x5c(%rbp),%xmm0
divss  -0x60(%rbp),%xmm0
mov    -0x38(%rbp),%rax
movss  %xmm0,(%rax)
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_normal>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movss  0x30(%rsp),%xmm8
subss  %xmm0,%xmm3
subss  %xmm1,%xmm4
subss  %xmm2,%xmm5
subss  %xmm0,%xmm6
subss  %xmm1,%xmm7
subss  %xmm2,%xmm8
movaps %xmm8,%xmm0
mulss  %xmm7,%xmm0
mulss  %xmm6,%xmm5
mulss  %xmm4,%xmm6
mulss  %xmm8,%xmm4
subss  %xmm0,%xmm4
mulss  %xmm3,%xmm8
subss  %xmm8,%xmm5
mulss  %xmm3,%xmm7
subss  %xmm6,%xmm7
movaps %xmm5,%xmm0
mulss  %xmm5,%xmm0
movaps %xmm4,%xmm1
mulss  %xmm4,%xmm1
addss  %xmm0,%xmm1
movaps %xmm7,%xmm0
mulss  %xmm7,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     1198 <calculate_normal+0x88>
sqrtss %xmm0,%xmm0
jmp    11c1 <calculate_normal+0xb1>
movss  %xmm7,0xc(%rsp)
movss  %xmm5,0x8(%rsp)
movss  %xmm4,0x4(%rsp)
call   1030 <sqrt@plt>
movss  0x4(%rsp),%xmm4
movss  0x8(%rsp),%xmm5
movss  0xc(%rsp),%xmm7
divss  %xmm0,%xmm4
movss  %xmm4,(%rbx)
divss  %xmm0,%xmm5
movss  %xmm5,(%r15)
divss  %xmm0,%xmm7
movss  %xmm7,(%r14)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @calculate_normal(float %0, float %1, float %2, float %3, float %4, float %5, float %6, float %7, float %8, float* %9, float* %10, float* %11) {
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca float
%22 = alloca float*
%23 = alloca float*
%24 = alloca float*
%25 = alloca float
%26 = alloca float
%27 = alloca float
%28 = alloca float
%29 = alloca float
%30 = alloca float
%31 = alloca float
%32 = alloca float
%33 = alloca float
%34 = alloca float
store float %0, float* %13
store float %1, float* %14
store float %2, float* %15
store float %3, float* %16
store float %4, float* %17
store float %5, float* %18
store float %6, float* %19
store float %7, float* %20
store float %8, float* %21
store float* %9, float** %22
store float* %10, float** %23
store float* %11, float** %24
%35 = load float, float* %16
%36 = load float, float* %13
%37 = fsub float %35, %36
store float %37, float* %25
%38 = load float, float* %17
%39 = load float, float* %14
%40 = fsub float %38, %39
store float %40, float* %26
%41 = load float, float* %18
%42 = load float, float* %15
%43 = fsub float %41, %42
store float %43, float* %27
%44 = load float, float* %19
%45 = load float, float* %13
%46 = fsub float %44, %45
store float %46, float* %28
%47 = load float, float* %20
%48 = load float, float* %14
%49 = fsub float %47, %48
store float %49, float* %29
%50 = load float, float* %21
%51 = load float, float* %15
%52 = fsub float %50, %51
store float %52, float* %30
%53 = load float, float* %26
%54 = load float, float* %30
%55 = load float, float* %29
%56 = load float, float* %30
%57 = fmul float %55, %56
%58 = fneg float %57
%59 = call float @llvm.fmuladd.f32(float %53, float %54, float %58)
store float %59, float* %31
%60 = load float, float* %28
%61 = load float, float* %27
%62 = load float, float* %25
%63 = load float, float* %30
%64 = fmul float %62, %63
%65 = fneg float %64
%66 = call float @llvm.fmuladd.f32(float %60, float %61, float %65)
store float %66, float* %32
%67 = load float, float* %25
%68 = load float, float* %29
%69 = load float, float* %28
%70 = load float, float* %26
%71 = fmul float %69, %70
%72 = fneg float %71
%73 = call float @llvm.fmuladd.f32(float %67, float %68, float %72)
store float %73, float* %33
%74 = load float, float* %31
%75 = load float, float* %31
%76 = load float, float* %32
%77 = load float, float* %32
%78 = fmul float %76, %77
%79 = call float @llvm.fmuladd.f32(float %74, float %75, float %78)
%80 = load float, float* %33
%81 = load float, float* %33
%82 = call float @llvm.fmuladd.f32(float %80, float %81, float %79)
%83 = call float @sqrt(float %82)
store float %83, float* %34
%84 = load float, float* %31
%85 = load float, float* %34
%86 = fdiv float %84, %85
%87 = load float*, float** %22
store float %86, float* %87
%88 = load float, float* %32
%89 = load float, float* %34
%90 = fdiv float %88, %89
%91 = load float*, float** %23
store float %90, float* %91
%92 = load float, float* %33
%93 = load float, float* %34
%94 = fdiv float %92, %93
%95 = load float*, float** %24
store float %94, float* %95
ret i32 0
}

LLVM IR (-O2):
define i32 @calculate_normal(float %0, float %1, float %2, float %3, float %4, float %5, float %6, float %7, float %8, float* nocapture writeonly %9, float* nocapture writeonly %10, float* nocapture writeonly %11) {
%13 = fsub float %3, %0
%14 = fsub float %4, %1
%15 = fsub float %5, %2
%16 = fsub float %6, %0
%17 = fsub float %7, %1
%18 = fsub float %8, %2
%19 = fneg float %17
%20 = fmul float %18, %19
%21 = tail call float @llvm.fmuladd.f32(float %14, float %18, float %20)
%22 = fneg float %13
%23 = fmul float %18, %22
%24 = tail call float @llvm.fmuladd.f32(float %16, float %15, float %23)
%25 = fneg float %16
%26 = fmul float %14, %25
%27 = tail call float @llvm.fmuladd.f32(float %13, float %17, float %26)
%28 = fmul float %24, %24
%29 = tail call float @llvm.fmuladd.f32(float %21, float %21, float %28)
%30 = tail call float @llvm.fmuladd.f32(float %27, float %27, float %29)
%31 = tail call float @sqrt(float %30)
%32 = fdiv float %21, %31
store float %32, float* %9
%33 = fdiv float %24, %31
store float %33, float* %10
%34 = fdiv float %27, %31
store float %34, float* %11
ret i32 0
}