#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 */
scalar_t__ LeftTurn(double const *, double const *, double const *);
int TriangleContainsPoint(const double org[2], const double u[2],
                          const double v[2], const double p[2]) {
  if (LeftTurn(org, u, p) >= 0) {
    if (LeftTurn(org, v, p) <= 0) {
      double x[2] = {p[0] - org[0], p[1] - org[1]};
      if (LeftTurn(u, v, x) >= 0) {
        return 1;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<TriangleContainsPoint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <LeftTurn@plt>
cmp    $0x0,%rax
jl     11bb <TriangleContainsPoint+0xab>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <LeftTurn@plt>
cmp    $0x0,%rax
jg     11b6 <TriangleContainsPoint+0xa6>
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x28(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x10(%rbp),%rax
subsd  0x8(%rax),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1030 <LeftTurn@plt>
cmp    $0x0,%rax
jl     11b1 <TriangleContainsPoint+0xa1>
movl   $0x1,-0x4(%rbp)
jmp    11c2 <TriangleContainsPoint+0xb2>
jmp    11b6 <TriangleContainsPoint+0xa6>
jmp    11bb <TriangleContainsPoint+0xab>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TriangleContainsPoint>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rcx,%rdx
call   1030 <LeftTurn@plt>
test   %rax,%rax
js     1175 <TriangleContainsPoint+0x65>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1030 <LeftTurn@plt>
test   %rax,%rax
jg     1175 <TriangleContainsPoint+0x65>
movupd (%r12),%xmm0
movupd (%rbx),%xmm1
subpd  %xmm1,%xmm0
movapd %xmm0,(%rsp)
mov    %rsp,%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <LeftTurn@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jns    1177 <TriangleContainsPoint+0x67>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @TriangleContainsPoint(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 [2 x double]
store double* %0, double** %6
store double* %1, double** %7
store double* %2, double** %8
store double* %3, double** %9
%11 = load double*, double** %6
%12 = load double*, double** %7
%13 = load double*, double** %9
%14 = call i64 @LeftTurn(double* %11, double* %12, double* %13)
%15 = icmp sge i64 %14, 0
br i1 %15, label %16, label %47
16: ; preds = %4
%17 = load double*, double** %6
%18 = load double*, double** %8
%19 = load double*, double** %9
%20 = call i64 @LeftTurn(double* %17, double* %18, double* %19)
%21 = icmp sle i64 %20, 0
br i1 %21, label %22, label %46
22: ; preds = %16
%23 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 0
%24 = load double*, double** %9
%25 = getelementptr inbounds double, double* %24, i64 0
%26 = load double, double* %25
%27 = load double*, double** %6
%28 = getelementptr inbounds double, double* %27, i64 0
%29 = load double, double* %28
%30 = fsub double %26, %29
store double %30, double* %23
%31 = getelementptr inbounds double, double* %23, i64 1
%32 = load double*, double** %9
%33 = getelementptr inbounds double, double* %32, i64 1
%34 = load double, double* %33
%35 = load double*, double** %6
%36 = getelementptr inbounds double, double* %35, i64 1
%37 = load double, double* %36
%38 = fsub double %34, %37
store double %38, double* %31
%39 = load double*, double** %7
%40 = load double*, double** %8
%41 = getelementptr inbounds [2 x double], [2 x double]* %10, i64 0, i64 0
%42 = call i64 @LeftTurn(double* %39, double* %40, double* %41)
%43 = icmp sge i64 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %22
store i32 1, i32* %5
br label %48
45: ; preds = %22
br label %46
46: ; preds = %45, %16
br label %47
47: ; preds = %46, %4
store i32 0, i32* %5
br label %48
48: ; preds = %47, %44
%49 = load i32, i32* %5
ret i32 %49
}

LLVM IR (-O2):
define i32 @TriangleContainsPoint(double* %0, double* %1, double* %2, double* %3) {
%5 = alloca <2 x double>
%6 = tail call i64 @LeftTurn(double* %0, double* %1, double* %3)
%7 = icmp sgt i64 %6, -1
br i1 %7, label %8, label %21
8: ; preds = %4
%9 = tail call i64 @LeftTurn(double* %0, double* %2, double* %3)
%10 = icmp slt i64 %9, 1
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = bitcast <2 x double>* %5 to i8*
%13 = getelementptr inbounds <2 x double>, <2 x double>* %5, i64 0, i64 0
%14 = bitcast double* %3 to <2 x double>*
%15 = load <2 x double>, <2 x double>* %14
%16 = bitcast double* %0 to <2 x double>*
%17 = load <2 x double>, <2 x double>* %16
%18 = fsub <2 x double> %15, %17
store <2 x double> %18, <2 x double>* %5
%19 = call i64 @LeftTurn(double* %1, double* %2, double* %13)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %11, %8, %4
br label %22
22: ; preds = %11, %21
%23 = phi i32 [ 1, %11 ], [ 0, %21 ]
ret i32 %23
}