#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 */
double dist(double *, double *, int);
double sqrt(double);
double triangle_area(double x[], double y[], double z[], int n) {
  double a = dist(x, y, n);
  double b = dist(x, z, n);
  double c = dist(y, z, n);
  double s = .5 * (a + b + c);
  return sqrt(s * (s - a) * (s - b) * (s - c));
}


x86 assembly (clang, -O0):
<triangle_area>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <dist@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <dist@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <dist@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm1
addsd  -0x30(%rbp),%xmm1
addsd  -0x38(%rbp),%xmm1
movsd  0xe73(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<triangle_area>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %ecx,%edx
call   1030 <dist@plt>
movsd  %xmm0,0x10(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <dist@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <dist@plt>
movapd %xmm0,%xmm1
movsd  0x10(%rsp),%xmm3
movapd %xmm3,%xmm0
movsd  0x8(%rsp),%xmm4
addsd  %xmm4,%xmm0
addsd  %xmm1,%xmm0
mulsd  0xe7a(%rip),%xmm0
movapd %xmm0,%xmm2
subsd  %xmm3,%xmm2
mulsd  %xmm0,%xmm2
movapd %xmm0,%xmm3
subsd  %xmm4,%xmm3
mulsd  %xmm2,%xmm3
subsd  %xmm1,%xmm0
mulsd  %xmm3,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11bf <triangle_area+0x9f>
sqrtsd %xmm0,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <sqrt@plt>

LLVM IR (-O0):
define double @triangle_area(double* %0, double* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i32 %3, i32* %8
%13 = load double*, double** %5
%14 = load double*, double** %6
%15 = load i32, i32* %8
%16 = call double @dist(double* %13, double* %14, i32 %15)
store double %16, double* %9
%17 = load double*, double** %5
%18 = load double*, double** %7
%19 = load i32, i32* %8
%20 = call double @dist(double* %17, double* %18, i32 %19)
store double %20, double* %10
%21 = load double*, double** %6
%22 = load double*, double** %7
%23 = load i32, i32* %8
%24 = call double @dist(double* %21, double* %22, i32 %23)
store double %24, double* %11
%25 = load double, double* %9
%26 = load double, double* %10
%27 = fadd double %25, %26
%28 = load double, double* %11
%29 = fadd double %27, %28
%30 = fmul double 5.000000e-01, %29
store double %30, double* %12
%31 = load double, double* %12
%32 = load double, double* %12
%33 = load double, double* %9
%34 = fsub double %32, %33
%35 = fmul double %31, %34
%36 = load double, double* %12
%37 = load double, double* %10
%38 = fsub double %36, %37
%39 = fmul double %35, %38
%40 = load double, double* %12
%41 = load double, double* %11
%42 = fsub double %40, %41
%43 = fmul double %39, %42
%44 = call double @sqrt(double %43)
ret double %44
}

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