#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*/ cross(double *, double *, double *);
double dot(double *, double *);
int ptriside(double *v1, double *v2, double *v3, double *r) {
  double val;
  double a[3], b[3], c[3], d[3];
  int k;
  for (k = 0; k < 3; k++) {
    a[k] = r[k] - v1[k];
    b[k] = v2[k] - v1[k];
    c[k] = v3[k] - v1[k];
  }
  cross(b, c, d);
  val = dot(a, d);
  if (val > 0)
    return 1;
  else if (val < 0)
    return -1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<ptriside>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0xb4(%rbp)
cmpl   $0x3,-0xb4(%rbp)
jge    11f0 <ptriside+0xd0>
mov    -0x28(%rbp),%rax
movslq -0xb4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0xb4(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movslq -0xb4(%rbp),%rax
movsd  %xmm0,-0x50(%rbp,%rax,8)
mov    -0x18(%rbp),%rax
movslq -0xb4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0xb4(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movslq -0xb4(%rbp),%rax
movsd  %xmm0,-0x70(%rbp,%rax,8)
mov    -0x20(%rbp),%rax
movslq -0xb4(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0xb4(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movslq -0xb4(%rbp),%rax
movsd  %xmm0,-0x90(%rbp,%rax,8)
ff ff
mov    -0xb4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb4(%rbp)
jmp    1145 <ptriside+0x25>
lea    -0x70(%rbp),%rdi
lea    -0x90(%rbp),%rsi
lea    -0xb0(%rbp),%rdx
call   1040 <cross@plt>
lea    -0x50(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
call   1030 <dot@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    123a <ptriside+0x11a>
movl   $0x1,-0x4(%rbp)
jmp    125b <ptriside+0x13b>
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1254 <ptriside+0x134>
movl   $0xffffffff,-0x4(%rbp)
jmp    125b <ptriside+0x13b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptriside>:
push   %rbx
sub    $0x80,%rsp
movupd (%rdi),%xmm0
movupd (%rcx),%xmm1
subpd  %xmm0,%xmm1
movapd %xmm1,0x40(%rsp)
movupd (%rsi),%xmm1
subpd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
movupd (%rdx),%xmm1
subpd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
movsd  0x10(%rcx),%xmm0
movsd  0x10(%rdi),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x50(%rsp)
movsd  0x10(%rsi),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0x10(%rdx),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0x20(%rsp),%rdi
mov    %rsp,%rsi
lea    0x60(%rsp),%rbx
mov    %rbx,%rdx
call   1040 <cross@plt>
lea    0x40(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <dot@plt>
xorpd  %xmm1,%xmm1
xor    %ecx,%ecx
ucomisd %xmm0,%xmm1
seta   %cl
neg    %ecx
ucomisd %xmm1,%xmm0
mov    $0x1,%eax
cmovbe %ecx,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @ptriside(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca i32
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca double*
%10 = alloca double
%11 = alloca [3 x double]
%12 = alloca [3 x double]
%13 = alloca [3 x double]
%14 = alloca [3 x double]
%15 = alloca i32
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
store i32 0, i32* %15
br label %16
16: ; preds = %62, %4
%17 = load i32, i32* %15
%18 = icmp slt i32 %17, 3
br i1 %18, label %19, label %65
19: ; preds = %16
%20 = load double*, double** %9
%21 = load i32, i32* %15
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds double, double* %20, i64 %22
%24 = load double, double* %23
%25 = load double*, double** %6
%26 = load i32, i32* %15
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
%29 = load double, double* %28
%30 = fsub double %24, %29
%31 = load i32, i32* %15
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 %32
store double %30, double* %33
%34 = load double*, double** %7
%35 = load i32, i32* %15
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %34, i64 %36
%38 = load double, double* %37
%39 = load double*, double** %6
%40 = load i32, i32* %15
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds double, double* %39, i64 %41
%43 = load double, double* %42
%44 = fsub double %38, %43
%45 = load i32, i32* %15
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 %46
store double %44, double* %47
%48 = load double*, double** %8
%49 = load i32, i32* %15
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds double, double* %48, i64 %50
%52 = load double, double* %51
%53 = load double*, double** %6
%54 = load i32, i32* %15
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds double, double* %53, i64 %55
%57 = load double, double* %56
%58 = fsub double %52, %57
%59 = load i32, i32* %15
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 %60
store double %58, double* %61
br label %62
62: ; preds = %19
%63 = load i32, i32* %15
%64 = add nsw i32 %63, 1
store i32 %64, i32* %15
br label %16
65: ; preds = %16
%66 = getelementptr inbounds [3 x double], [3 x double]* %12, i64 0, i64 0
%67 = getelementptr inbounds [3 x double], [3 x double]* %13, i64 0, i64 0
%68 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 0
%69 = call i32 @cross(double* %66, double* %67, double* %68)
%70 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%71 = getelementptr inbounds [3 x double], [3 x double]* %14, i64 0, i64 0
%72 = call double @dot(double* %70, double* %71)
store double %72, double* %10
%73 = load double, double* %10
%74 = fcmp ogt double %73, 0.000000e+00
br i1 %74, label %75, label %76
75: ; preds = %65
store i32 1, i32* %5
br label %81
76: ; preds = %65
%77 = load double, double* %10
%78 = fcmp olt double %77, 0.000000e+00
br i1 %78, label %79, label %80
79: ; preds = %76
store i32 -1, i32* %5
br label %81
80: ; preds = %76
store i32 0, i32* %5
br label %81
81: ; preds = %80, %79, %75
%82 = load i32, i32* %5
ret i32 %82
}

LLVM IR (-O2):
define i32 @ptriside(double* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3) {
%5 = alloca [3 x double]
%6 = alloca [3 x double]
%7 = alloca [3 x double]
%8 = alloca [3 x double]
%9 = bitcast [3 x double]* %5 to i8*
%10 = bitcast [3 x double]* %6 to i8*
%11 = bitcast [3 x double]* %7 to i8*
%12 = bitcast [3 x double]* %8 to i8*
%13 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%14 = bitcast double* %0 to <2 x double>*
%15 = load <2 x double>, <2 x double>* %14
%16 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%17 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%18 = bitcast double* %3 to <2 x double>*
%19 = load <2 x double>, <2 x double>* %18
%20 = fsub <2 x double> %19, %15
%21 = bitcast [3 x double]* %5 to <2 x double>*
store <2 x double> %20, <2 x double>* %21
%22 = bitcast double* %1 to <2 x double>*
%23 = load <2 x double>, <2 x double>* %22
%24 = fsub <2 x double> %23, %15
%25 = bitcast [3 x double]* %6 to <2 x double>*
store <2 x double> %24, <2 x double>* %25
%26 = bitcast double* %2 to <2 x double>*
%27 = load <2 x double>, <2 x double>* %26
%28 = fsub <2 x double> %27, %15
%29 = bitcast [3 x double]* %7 to <2 x double>*
store <2 x double> %28, <2 x double>* %29
%30 = getelementptr inbounds double, double* %3, i64 2
%31 = load double, double* %30
%32 = getelementptr inbounds double, double* %0, i64 2
%33 = load double, double* %32
%34 = fsub double %31, %33
%35 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
store double %34, double* %35
%36 = getelementptr inbounds double, double* %1, i64 2
%37 = load double, double* %36
%38 = fsub double %37, %33
%39 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 2
store double %38, double* %39
%40 = getelementptr inbounds double, double* %2, i64 2
%41 = load double, double* %40
%42 = fsub double %41, %33
%43 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 2
store double %42, double* %43
%44 = getelementptr inbounds [3 x double], [3 x double]* %8, i64 0, i64 0
%45 = call i32 @cross(double* %16, double* %17, double* %44)
%46 = call double @dot(double* %13, double* %44)
%47 = fcmp ogt double %46, 0.000000e+00
%48 = fcmp olt double %46, 0.000000e+00
%49 = sext i1 %48 to i32
%50 = select i1 %47, i32 1, i32 %49
ret i32 %50
}