#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*/ find_barycentric_coords(size_t const, double *, double *,
                                           double *);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, double);
int main() {
  size_t const size = 2;
  double simplex[3][2] = {{1, 2}, {17, 3}, {9, 12}};
  double point[2] = {10, 15};
  double *results = (double *)malloc(3 * sizeof(double));
  find_barycentric_coords(size, (double *)point, (double *)simplex, results);
  for (size_t i = 0; i <= size; ++i) {
    printf("%lf\n", results[i]);
  }
  free(results);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x2,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1060 <memset@plt>
movsd  0xea9(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe94(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe7f(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe6a(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe55(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe40(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    0xe64(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe61(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    $0x18,%edi
call   1070 <malloc@plt>
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rsi
lea    -0x40(%rbp),%rdx
mov    -0x58(%rbp),%rcx
mov    $0x2,%edi
call   1050 <find_barycentric_coords@plt>
movq   $0x0,-0x60(%rbp)
cmpq   $0x2,-0x60(%rbp)
ja     123c <main+0xec>
mov    -0x58(%rbp),%rax
mov    -0x60(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe1a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    1207 <main+0xb7>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb6(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xeba(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0x18,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
mov    %rsp,%rsi
lea    0x10(%rsp),%rdx
mov    $0x2,%edi
mov    %rax,%rcx
call   1050 <find_barycentric_coords@plt>
movsd  (%rbx),%xmm0
lea    0xe9d(%rip),%r14
mov    %r14,%rdi
call   1040 <printf@plt>
movsd  0x8(%rbx),%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
movsd  0x10(%rbx),%xmm0
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.point = [2 x double] [double 1.000000e+01, double 1.500000e+01]
@.str = [5 x i8] c"%lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [3 x [2 x double]]
%4 = alloca [2 x double]
%5 = alloca double*
%6 = alloca i64
store i32 0, i32* %1
store i64 2, i64* %2
%7 = bitcast [3 x [2 x double]]* %3 to i8*
%8 = bitcast i8* %7 to [3 x [2 x double]]*
%9 = getelementptr inbounds [3 x [2 x double]], [3 x [2 x double]]* %8, i32 0, i32 0
%10 = getelementptr inbounds [2 x double], [2 x double]* %9, i32 0, i32 0
store double 1.000000e+00, double* %10
%11 = getelementptr inbounds [2 x double], [2 x double]* %9, i32 0, i32 1
store double 2.000000e+00, double* %11
%12 = getelementptr inbounds [3 x [2 x double]], [3 x [2 x double]]* %8, i32 0, i32 1
%13 = getelementptr inbounds [2 x double], [2 x double]* %12, i32 0, i32 0
store double 1.700000e+01, double* %13
%14 = getelementptr inbounds [2 x double], [2 x double]* %12, i32 0, i32 1
store double 3.000000e+00, double* %14
%15 = getelementptr inbounds [3 x [2 x double]], [3 x [2 x double]]* %8, i32 0, i32 2
%16 = getelementptr inbounds [2 x double], [2 x double]* %15, i32 0, i32 0
store double 9.000000e+00, double* %16
%17 = getelementptr inbounds [2 x double], [2 x double]* %15, i32 0, i32 1
store double 1.200000e+01, double* %17
%18 = bitcast [2 x double]* %4 to i8*
%19 = call i64 @malloc(i32 24)
%20 = inttoptr i64 %19 to double*
store double* %20, double** %5
%21 = getelementptr inbounds [2 x double], [2 x double]* %4, i64 0, i64 0
%22 = getelementptr inbounds [3 x [2 x double]], [3 x [2 x double]]* %3, i64 0, i64 0
%23 = bitcast [2 x double]* %22 to double*
%24 = load double*, double** %5
%25 = call i32 @find_barycentric_coords(i64 2, double* %21, double* %23, double* %24)
store i64 0, i64* %6
br label %26
26: ; preds = %35, %0
%27 = load i64, i64* %6
%28 = icmp ule i64 %27, 2
br i1 %28, label %29, label %38
29: ; preds = %26
%30 = load double*, double** %5
%31 = load i64, i64* %6
%32 = getelementptr inbounds double, double* %30, i64 %31
%33 = load double, double* %32
%34 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %33)
br label %35
35: ; preds = %29
%36 = load i64, i64* %6
%37 = add i64 %36, 1
store i64 %37, i64* %6
br label %26
38: ; preds = %26
%39 = load double*, double** %5
%40 = call i32 @free(double* %39)
ret i32 0
}

LLVM IR (-O2):
@__const.main.point = [2 x double] [double 1.000000e+01, double 1.500000e+01]
@.str = [5 x i8] c"%lf\0A\00"
define i32 @main() {
%1 = alloca [3 x [2 x double]]
%2 = alloca [2 x double]
%3 = bitcast [3 x [2 x double]]* %1 to i8*
%4 = getelementptr inbounds [3 x [2 x double]], [3 x [2 x double]]* %1, i64 0, i64 0, i64 0
%5 = bitcast [3 x [2 x double]]* %1 to <2 x double>*
store <2 x double> <double 1.000000e+00, double 2.000000e+00>, <2 x double>* %5
%6 = getelementptr inbounds [3 x [2 x double]], [3 x [2 x double]]* %1, i64 0, i64 1, i64 0
%7 = bitcast double* %6 to <2 x double>*
store <2 x double> <double 1.700000e+01, double 3.000000e+00>, <2 x double>* %7
%8 = getelementptr inbounds [3 x [2 x double]], [3 x [2 x double]]* %1, i64 0, i64 2, i64 0
%9 = bitcast double* %8 to <2 x double>*
store <2 x double> <double 9.000000e+00, double 1.200000e+01>, <2 x double>* %9
%10 = bitcast [2 x double]* %2 to i8*
%11 = tail call i64 @malloc(i32 24)
%12 = inttoptr i64 %11 to double*
%13 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 0
%14 = call i32 @find_barycentric_coords(i64 2, double* %13, double* %4, double* %12)
%15 = load double, double* %12
%16 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %15)
%17 = getelementptr inbounds double, double* %12, i64 1
%18 = load double, double* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %18)
%20 = getelementptr inbounds double, double* %12, i64 2
%21 = load double, double* %20
%22 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %21)
%23 = call i32 @free(double* %12)
ret i32 0
}