#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*/ die(char *);
scalar_t__ inTriangle(double, double, double, double, double, double, double,
                      double);
int /*<<< orphan*/ printf(char *);
scalar_t__ scanf(char *, double *, double *, ...);
int main() {
  double a0, b0, a1, b1, a2, b2, ap, bp;
  printf("6 coords for 3 vertices of triangle: ");
  if (!scanf("%lf %lf %lf %lf %lf %lf", &a0, &b0, &a1, &b1, &a2, &b2))
    die("Input failure.\n");
  printf("Now input coordinate pairs of points to test, non-# to quit.\nx y: ");
  while (scanf("%lf %lf", &ap, &bp)) {
    if (inTriangle(a0, b0, a1, b1, a2, b2, ap, bp))
      printf(" in\n");
    else
      printf(" not in\n");
    printf("x y: ");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
lea    -0x30(%rbp),%r9
lea    -0x38(%rbp),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x0,%rax
jne    119b <main+0x5b>
lea    0xea8(%rip),%rdi
call   1060 <die@plt>
lea    0xeac(%rip),%rdi
call   1040 <printf@plt>
lea    0xe88(%rip),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x48(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x0,%rax
je     122c <main+0xec>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
movsd  -0x28(%rbp),%xmm3
movsd  -0x30(%rbp),%xmm4
movsd  -0x38(%rbp),%xmm5
movsd  -0x40(%rbp),%xmm6
movsd  -0x48(%rbp),%xmm7
call   1030 <inTriangle@plt>
cmp    $0x0,%rax
je     120f <main+0xcf>
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
jmp    121b <main+0xdb>
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
jmp    11a7 <main+0x67>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xe9b(%rip),%rdi
call   1050 <printf@plt>
lea    0x18(%rsp),%rax
mov    %rax,(%rsp)
lea    0xeac(%rip),%rdi
lea    0x40(%rsp),%rsi
lea    0x38(%rsp),%rdx
lea    0x30(%rsp),%rcx
lea    0x28(%rsp),%r8
lea    0x20(%rsp),%r9
xor    %eax,%eax
call   1060 <scanf@plt>
test   %rax,%rax
jne    11ab <main+0x5b>
lea    0xe98(%rip),%rdi
call   1070 <die@plt>
lea    0xe9c(%rip),%rdi
call   1050 <printf@plt>
lea    0xe78(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
test   %rax,%rax
je     1261 <main+0x111>
lea    0xeb2(%rip),%r13
lea    0xeaf(%rip),%rbp
lea    0xe9e(%rip),%r14
lea    0xe42(%rip),%r15
lea    0x10(%rsp),%r12
lea    0x8(%rsp),%rbx
xchg   %ax,%ax
movsd  0x40(%rsp),%xmm0
movsd  0x38(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
movsd  0x28(%rsp),%xmm3
movsd  0x20(%rsp),%xmm4
movsd  0x18(%rsp),%xmm5
movsd  0x10(%rsp),%xmm6
movsd  0x8(%rsp),%xmm7
call   1040 <inTriangle@plt>
test   %rax,%rax
mov    %rbp,%rdi
cmove  %r13,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
test   %rax,%rax
jne    1200 <main+0xb0>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"6 coords for 3 vertices of triangle: \00"
@.str.1 = [24 x i8] c"%lf %lf %lf %lf %lf %lf\00"
@.str.2 = [16 x i8] c"Input failure.\0A\00"
@.str.3 = [67 x i8] c"Now input coordinate pairs of points to test, non-# to quit.\0Ax y: \00"
@.str.4 = [8 x i8] c"%lf %lf\00"
@.str.5 = [5 x i8] c" in\0A\00"
@.str.6 = [9 x i8] c" not in\0A\00"
@.str.7 = [6 x i8] c"x y: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store i32 0, i32* %1
%10 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%11 = call i64 (i8*, double*, double*, ...) @scanf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), double* %2, double* %3, double* %4, double* %5, double* %6, double* %7)
%12 = icmp ne i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %0
%14 = call i32 @die(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %0
%16 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %35, %15
%18 = call i64 (i8*, double*, double*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double* %8, double* %9)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %37
20: ; preds = %17
%21 = load double, double* %2
%22 = load double, double* %3
%23 = load double, double* %4
%24 = load double, double* %5
%25 = load double, double* %6
%26 = load double, double* %7
%27 = load double, double* %8
%28 = load double, double* %9
%29 = call i64 @inTriangle(double %21, double %22, double %23, double %24, double %25, double %26, double %27, double %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %20
%32 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %35
33: ; preds = %20
%34 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %35
35: ; preds = %33, %31
%36 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %17
37: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"6 coords for 3 vertices of triangle: \00"
@.str.1 = [24 x i8] c"%lf %lf %lf %lf %lf %lf\00"
@.str.2 = [16 x i8] c"Input failure.\0A\00"
@.str.3 = [67 x i8] c"Now input coordinate pairs of points to test, non-# to quit.\0Ax y: \00"
@.str.4 = [8 x i8] c"%lf %lf\00"
@.str.7 = [6 x i8] c"x y: \00"
@str = [8 x i8] c" not in\00"
@str.8 = [4 x i8] c" in\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = bitcast double* %1 to i8*
%10 = bitcast double* %2 to i8*
%11 = bitcast double* %3 to i8*
%12 = bitcast double* %4 to i8*
%13 = bitcast double* %5 to i8*
%14 = bitcast double* %6 to i8*
%15 = bitcast double* %7 to i8*
%16 = bitcast double* %8 to i8*
%17 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%18 = call i64 (i8*, double*, double*, ...) @scanf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), double* %1, double* %2, double* %3, double* %4, double* %5, double* %6)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %0
%21 = call i32 @die(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %0
%23 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str.3, i64 0, i64 0))
%24 = call i64 (i8*, double*, double*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double* %7, double* %8)
%25 = icmp eq i64 %24, 0
br i1 %25, label %42, label %26
26: ; preds = %22, %26
%27 = load double, double* %1
%28 = load double, double* %2
%29 = load double, double* %3
%30 = load double, double* %4
%31 = load double, double* %5
%32 = load double, double* %6
%33 = load double, double* %7
%34 = load double, double* %8
%35 = call i64 @inTriangle(double %27, double %28, double %29, double %30, double %31, double %32, double %33, double %34)
%36 = icmp eq i64 %35, 0
%37 = select i1 %36, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str.8, i64 0, i64 0)
%38 = call i32 @puts(i8* dereferenceable(1) %37)
%39 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%40 = call i64 (i8*, double*, double*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double* %7, double* %8)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %26
42: ; preds = %26, %22
ret i32 0
}