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


x86 assembly (clang, -O0):
<glmComputeTriangleArea2d>:
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 <glmComputeDistance2d@plt>
movss  %xmm0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <glmComputeDistance2d@plt>
movss  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <glmComputeDistance2d@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):
<glmComputeTriangleArea2d>:
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 <glmComputeDistance2d@plt>
movss  %xmm0,0xc(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <glmComputeDistance2d@plt>
movss  %xmm0,0x8(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <glmComputeDistance2d@plt>
movss  0xc(%rsp),%xmm3
movaps %xmm3,%xmm1
movss  0x8(%rsp),%xmm4
addss  %xmm4,%xmm1
addss  %xmm0,%xmm1
mulss  0xe82(%rip),%xmm1
movaps %xmm1,%xmm2
subss  %xmm3,%xmm2
mulss  %xmm1,%xmm2
movaps %xmm1,%xmm3
subss  %xmm4,%xmm3
mulss  %xmm2,%xmm3
subss  %xmm0,%xmm1
mulss  %xmm3,%xmm1
movaps %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <sqrt@plt>

LLVM IR (-O0):
define double @glmComputeTriangleArea2d(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%11 = load double*, double** %5
%12 = load double*, double** %6
%13 = call float @glmComputeDistance2d(double* %11, double* %12)
store float %13, float* %7
%14 = load double*, double** %4
%15 = load double*, double** %6
%16 = call float @glmComputeDistance2d(double* %14, double* %15)
store float %16, float* %8
%17 = load double*, double** %4
%18 = load double*, double** %5
%19 = call float @glmComputeDistance2d(double* %17, double* %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 double @sqrt(float %40)
ret double %41
}

LLVM IR (-O2):
define double @glmComputeTriangleArea2d(double* %0, double* %1, double* %2) {
%4 = tail call float @glmComputeDistance2d(double* %1, double* %2)
%5 = tail call float @glmComputeDistance2d(double* %0, double* %2)
%6 = tail call float @glmComputeDistance2d(double* %0, double* %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 double @sqrt(float %15)
ret double %16
}