#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__ side(double, double, double, double, double, double);
bool naivePointInTriangle(double x1, double y1, double x2, double y2, double x3,
                          double y3, double x, double y) {
  double checkSide1 = side(x1, y1, x2, y2, x, y) >= 0;
  double checkSide2 = side(x2, y2, x3, y3, x, y) >= 0;
  double checkSide3 = side(x3, y3, x1, y1, x, y) >= 0;
  return checkSide1 && checkSide2 && checkSide3;
}


x86 assembly (clang, -O0):
<naivePointInTriangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
movsd  %xmm6,-0x38(%rbp)
movsd  %xmm7,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm4
movsd  -0x40(%rbp),%xmm5
call   1030 <side@plt>
cmp    $0x0,%rax
setge  %al
and    $0x1,%al
movzbl %al,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm4
movsd  -0x40(%rbp),%xmm5
call   1030 <side@plt>
cmp    $0x0,%rax
setge  %al
and    $0x1,%al
movzbl %al,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm2
movsd  -0x10(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm4
movsd  -0x40(%rbp),%xmm5
call   1030 <side@plt>
cmp    $0x0,%rax
setge  %al
and    $0x1,%al
movzbl %al,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x59(%rbp)
jne    120a <naivePointInTriangle+0xfa>
jp     120a <naivePointInTriangle+0xfa>
jmp    1243 <naivePointInTriangle+0x133>
movsd  -0x50(%rbp),%xmm0
xor    %eax,%eax
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x59(%rbp)
jne    122c <naivePointInTriangle+0x11c>
jp     122c <naivePointInTriangle+0x11c>
jmp    1243 <naivePointInTriangle+0x133>
movsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setne  %al
setp   %cl
or     %cl,%al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<naivePointInTriangle>:
push   %r14
push   %rbx
sub    $0x48,%rsp
movsd  %xmm7,0x10(%rsp)
movsd  %xmm6,0x8(%rsp)
movsd  %xmm5,0x20(%rsp)
movsd  %xmm4,0x18(%rsp)
movsd  %xmm3,0x30(%rsp)
movsd  %xmm2,0x28(%rsp)
movsd  %xmm1,0x40(%rsp)
movsd  %xmm0,0x38(%rsp)
movaps %xmm6,%xmm4
movaps %xmm7,%xmm5
call   1030 <side@plt>
mov    %rax,%r14
movsd  0x28(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
movsd  0x8(%rsp),%xmm4
movsd  0x10(%rsp),%xmm5
call   1030 <side@plt>
mov    %rax,%rbx
movsd  0x18(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movsd  0x38(%rsp),%xmm2
movsd  0x40(%rsp),%xmm3
movsd  0x8(%rsp),%xmm4
movsd  0x10(%rsp),%xmm5
call   1030 <side@plt>
shr    $0x3f,%rax
xor    $0x1,%eax
xor    %ecx,%ecx
or     %r14,%rbx
cmovs  %ecx,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @naivePointInTriangle(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7) {
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
store double %0, double* %9
store double %1, double* %10
store double %2, double* %11
store double %3, double* %12
store double %4, double* %13
store double %5, double* %14
store double %6, double* %15
store double %7, double* %16
%20 = load double, double* %9
%21 = load double, double* %10
%22 = load double, double* %11
%23 = load double, double* %12
%24 = load double, double* %15
%25 = load double, double* %16
%26 = call i64 @side(double %20, double %21, double %22, double %23, double %24, double %25)
%27 = icmp sge i64 %26, 0
%28 = zext i1 %27 to i32
%29 = sitofp i32 %28 to double
store double %29, double* %17
%30 = load double, double* %11
%31 = load double, double* %12
%32 = load double, double* %13
%33 = load double, double* %14
%34 = load double, double* %15
%35 = load double, double* %16
%36 = call i64 @side(double %30, double %31, double %32, double %33, double %34, double %35)
%37 = icmp sge i64 %36, 0
%38 = zext i1 %37 to i32
%39 = sitofp i32 %38 to double
store double %39, double* %18
%40 = load double, double* %13
%41 = load double, double* %14
%42 = load double, double* %9
%43 = load double, double* %10
%44 = load double, double* %15
%45 = load double, double* %16
%46 = call i64 @side(double %40, double %41, double %42, double %43, double %44, double %45)
%47 = icmp sge i64 %46, 0
%48 = zext i1 %47 to i32
%49 = sitofp i32 %48 to double
store double %49, double* %19
%50 = load double, double* %17
%51 = fcmp une double %50, 0.000000e+00
br i1 %51, label %52, label %58
52: ; preds = %8
%53 = load double, double* %18
%54 = fcmp une double %53, 0.000000e+00
br i1 %54, label %55, label %58
55: ; preds = %52
%56 = load double, double* %19
%57 = fcmp une double %56, 0.000000e+00
br label %58
58: ; preds = %55, %52, %8
%59 = phi i1 [ false, %52 ], [ false, %8 ], [ %57, %55 ]
%60 = zext i1 %59 to i32
ret i32 %60
}

LLVM IR (-O2):
define i32 @naivePointInTriangle(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7) {
%9 = tail call i64 @side(double %0, double %1, double %2, double %3, double %6, double %7)
%10 = tail call i64 @side(double %2, double %3, double %4, double %5, double %6, double %7)
%11 = tail call i64 @side(double %4, double %5, double %0, double %1, double %6, double %7)
%12 = icmp sgt i64 %9, -1
%13 = icmp sgt i64 %10, -1
%14 = select i1 %12, i1 %13, i1 false
%15 = lshr i64 %11, 63
%16 = trunc i64 %15 to i32
%17 = xor i32 %16, 1
%18 = select i1 %14, i32 %17, i32 0
ret i32 %18
}