#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*/ get_n_triangle(double *, double *, double *, double *);
double sqrt(double);
double area_triangle(double *P1, double *P2, double *P3) {
  double area;
  double normal[3];
  get_n_triangle(P1, P2, P3, normal);
  area = 0.5 * sqrt(normal[0] * normal[0] + normal[1] * normal[1] +
                    normal[2] * normal[2]);
  return (area);
}


x86 assembly (clang, -O0):
<area_triangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x40(%rbp),%rcx
call   1030 <get_n_triangle@plt>
movsd  -0x40(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe79(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<area_triangle>:
sub    $0x18,%rsp
mov    %rsp,%rcx
call   1030 <get_n_triangle@plt>
movsd  (%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1161 <area_triangle+0x41>
sqrtsd %xmm0,%xmm0
jmp    1166 <area_triangle+0x46>
call   1040 <sqrt@plt>
mulsd  0xe92(%rip),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @area_triangle(double* %0, double* %1, double* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca double*
%7 = alloca double
%8 = alloca [3 x double]
store double* %0, double** %4
store double* %1, double** %5
store double* %2, double** %6
%9 = load double*, double** %4
%10 = load double*, double** %5
%11 = load double*, double** %6
%12 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%13 = call i32 @get_n_triangle(double* %9, double* %10, double* %11, double* %12)
%14 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%15 = load double, double* %14
%16 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%17 = load double, double* %16
%18 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 1
%19 = load double, double* %18
%20 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 1
%21 = load double, double* %20
%22 = fmul double %19, %21
%23 = call double @llvm.fmuladd.f64(double %15, double %17, double %22)
%24 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 2
%25 = load double, double* %24
%26 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 2
%27 = load double, double* %26
%28 = call double @llvm.fmuladd.f64(double %25, double %27, double %23)
%29 = call double @sqrt(double %28)
%30 = fmul double 5.000000e-01, %29
store double %30, double* %7
%31 = load double, double* %7
ret double %31
}

LLVM IR (-O2):
define double @area_triangle(double* %0, double* %1, double* %2) {
%4 = alloca [3 x double]
%5 = bitcast [3 x double]* %4 to i8*
%6 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%7 = call i32 @get_n_triangle(double* %0, double* %1, double* %2, double* %6)
%8 = load double, double* %6
%9 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
%10 = load double, double* %9
%11 = fmul double %10, %10
%12 = call double @llvm.fmuladd.f64(double %8, double %8, double %11)
%13 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
%14 = load double, double* %13
%15 = call double @llvm.fmuladd.f64(double %14, double %14, double %12)
%16 = call double @sqrt(double %15)
%17 = fmul double %16, 5.000000e-01
ret double %17
}