#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 */
float glmComputeDistance2f(float const *, float const *);
float sqrt(float);
float glmComputeTriangleArea2f(const float v1[2], const float v2[2],
                               const float v3[2]) {
  float a, b, c, p;
  a = glmComputeDistance2f(v2, v3);
  b = glmComputeDistance2f(v1, v3);
  c = glmComputeDistance2f(v1, v2);
  p = (a + b + c) / 2.0;
  return sqrt(p * (p - a) * (p - b) * (p - c));
}


x86 assembly (clang, -O0):
<glmComputeTriangleArea2f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <glmComputeDistance2f@plt>
movss  %xmm0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <glmComputeDistance2f@plt>
movss  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <glmComputeDistance2f@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x1c(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
addss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe7b(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
movss  -0x28(%rbp),%xmm1
subss  -0x1c(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  -0x28(%rbp),%xmm1
subss  -0x20(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  -0x28(%rbp),%xmm1
subss  -0x24(%rbp),%xmm1
mulss  %xmm1,%xmm0
call   1030 <sqrt@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glmComputeTriangleArea2f>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1040 <glmComputeDistance2f@plt>
movss  %xmm0,0xc(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <glmComputeDistance2f@plt>
movss  %xmm0,0x8(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <glmComputeDistance2f@plt>
movaps %xmm0,%xmm1
movss  0xc(%rsp),%xmm3
movaps %xmm3,%xmm0
movss  0x8(%rsp),%xmm4
addss  %xmm4,%xmm0
addss  %xmm1,%xmm0
mulss  0xe7f(%rip),%xmm0
movaps %xmm0,%xmm2
subss  %xmm3,%xmm2
mulss  %xmm0,%xmm2
movaps %xmm0,%xmm3
subss  %xmm4,%xmm3
mulss  %xmm2,%xmm3
subss  %xmm1,%xmm0
mulss  %xmm3,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     11b5 <glmComputeTriangleArea2f+0x95>
sqrtss %xmm0,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <sqrt@plt>

LLVM IR (-O0):
define float @glmComputeTriangleArea2f(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%11 = load float*, float** %5
%12 = load float*, float** %6
%13 = call float @glmComputeDistance2f(float* %11, float* %12)
store float %13, float* %7
%14 = load float*, float** %4
%15 = load float*, float** %6
%16 = call float @glmComputeDistance2f(float* %14, float* %15)
store float %16, float* %8
%17 = load float*, float** %4
%18 = load float*, float** %5
%19 = call float @glmComputeDistance2f(float* %17, float* %18)
store float %19, float* %9
%20 = load float, float* %7
%21 = load float, float* %8
%22 = fadd float %20, %21
%23 = load float, float* %9
%24 = fadd float %22, %23
%25 = fpext float %24 to double
%26 = fdiv double %25, 2.000000e+00
%27 = fptrunc double %26 to float
store float %27, float* %10
%28 = load float, float* %10
%29 = load float, float* %10
%30 = load float, float* %7
%31 = fsub float %29, %30
%32 = fmul float %28, %31
%33 = load float, float* %10
%34 = load float, float* %8
%35 = fsub float %33, %34
%36 = fmul float %32, %35
%37 = load float, float* %10
%38 = load float, float* %9
%39 = fsub float %37, %38
%40 = fmul float %36, %39
%41 = call float @sqrt(float %40)
ret float %41
}

LLVM IR (-O2):
define float @glmComputeTriangleArea2f(float* %0, float* %1, float* %2) {
%4 = tail call float @glmComputeDistance2f(float* %1, float* %2)
%5 = tail call float @glmComputeDistance2f(float* %0, float* %2)
%6 = tail call float @glmComputeDistance2f(float* %0, float* %1)
%7 = fadd float %4, %5
%8 = fadd float %7, %6
%9 = fmul float %8, 5.000000e-01
%10 = fsub float %9, %4
%11 = fmul float %9, %10
%12 = fsub float %9, %5
%13 = fmul float %12, %11
%14 = fsub float %9, %6
%15 = fmul float %14, %13
%16 = tail call float @sqrt(float %15)
ret float %16
}