#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 */
long double _maxim(long double **, int);
scalar_t__ segments_intersect(long double *, long double *, long double *,
                              long double *);
int point_in_polygon(long double *p, long double **poly, int Np) {
  int inter, i;
  long double M[] = {_maxim(poly, Np), p[1]};
  for (i = 0, inter = 0; i < (Np - 1); i++)
    inter += segments_intersect(p, M, poly[i], poly[i + 1]);
  if (inter % 2 == 0)
    return 0;
  else
    return 1;
}


x86 assembly (clang, -O0):
<point_in_polygon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <_maxim@plt>
fstpt  -0x50(%rbp)
mov    -0x10(%rbp),%rax
fldt   0x10(%rax)
fstpt  -0x40(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11b0 <point_in_polygon+0x90>
mov    -0x10(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
call   1030 <segments_intersect@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115a <point_in_polygon+0x3a>
mov    -0x20(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d0 <point_in_polygon+0xb0>
movl   $0x0,-0x4(%rbp)
jmp    11d7 <point_in_polygon+0xb7>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<point_in_polygon>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,%r14d
mov    %rsi,%r13
mov    %rdi,%r15
mov    %rsi,%rdi
mov    %edx,%esi
call   1040 <_maxim@plt>
fstpt  (%rsp)
fldt   0x10(%r15)
fstpt  0x10(%rsp)
xor    %ebp,%ebp
cmp    $0x2,%r14d
jl     1186 <point_in_polygon+0x66>
add    $0xffffffff,%r14d
xor    %eax,%eax
mov    %rsp,%r12
xor    %ebp,%ebp
nop
lea    0x1(%rax),%rbx
mov    0x0(%r13,%rax,8),%rdx
mov    0x8(%r13,%rax,8),%rcx
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <segments_intersect@plt>
add    %eax,%ebp
mov    %rbx,%rax
cmp    %rbx,%r14
jne    1160 <point_in_polygon+0x40>
and    $0x1,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @point_in_polygon(x86_fp80* %0, x86_fp80** %1, i32 %2) {
%4 = alloca i32
%5 = alloca x86_fp80*
%6 = alloca x86_fp80**
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [2 x x86_fp80]
store x86_fp80* %0, x86_fp80** %5
store x86_fp80** %1, x86_fp80*** %6
store i32 %2, i32* %7
%11 = getelementptr inbounds [2 x x86_fp80], [2 x x86_fp80]* %10, i64 0, i64 0
%12 = load x86_fp80**, x86_fp80*** %6
%13 = load i32, i32* %7
%14 = call x86_fp80 @_maxim(x86_fp80** %12, i32 %13)
store x86_fp80 %14, x86_fp80* %11
%15 = getelementptr inbounds x86_fp80, x86_fp80* %11, i64 1
%16 = load x86_fp80*, x86_fp80** %5
%17 = getelementptr inbounds x86_fp80, x86_fp80* %16, i64 1
%18 = load x86_fp80, x86_fp80* %17
store x86_fp80 %18, x86_fp80* %15
store i32 0, i32* %9
store i32 0, i32* %8
br label %19
19: ; preds = %43, %3
%20 = load i32, i32* %9
%21 = load i32, i32* %7
%22 = sub nsw i32 %21, 1
%23 = icmp slt i32 %20, %22
br i1 %23, label %24, label %46
24: ; preds = %19
%25 = load x86_fp80*, x86_fp80** %5
%26 = getelementptr inbounds [2 x x86_fp80], [2 x x86_fp80]* %10, i64 0, i64 0
%27 = load x86_fp80**, x86_fp80*** %6
%28 = load i32, i32* %9
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds x86_fp80*, x86_fp80** %27, i64 %29
%31 = load x86_fp80*, x86_fp80** %30
%32 = load x86_fp80**, x86_fp80*** %6
%33 = load i32, i32* %9
%34 = add nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds x86_fp80*, x86_fp80** %32, i64 %35
%37 = load x86_fp80*, x86_fp80** %36
%38 = call i64 @segments_intersect(x86_fp80* %25, x86_fp80* %26, x86_fp80* %31, x86_fp80* %37)
%39 = load i32, i32* %8
%40 = sext i32 %39 to i64
%41 = add nsw i64 %40, %38
%42 = trunc i64 %41 to i32
store i32 %42, i32* %8
br label %43
43: ; preds = %24
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
br label %19
46: ; preds = %19
%47 = load i32, i32* %8
%48 = srem i32 %47, 2
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %46
store i32 0, i32* %4
br label %52
51: ; preds = %46
store i32 1, i32* %4
br label %52
52: ; preds = %51, %50
%53 = load i32, i32* %4
ret i32 %53
}

LLVM IR (-O2):
define i32 @point_in_polygon(x86_fp80* %0, x86_fp80** %1, i32 %2) {
%4 = alloca [2 x x86_fp80]
%5 = bitcast [2 x x86_fp80]* %4 to i8*
%6 = getelementptr inbounds [2 x x86_fp80], [2 x x86_fp80]* %4, i64 0, i64 0
%7 = tail call x86_fp80 @_maxim(x86_fp80** %1, i32 %2)
store x86_fp80 %7, x86_fp80* %6
%8 = getelementptr inbounds [2 x x86_fp80], [2 x x86_fp80]* %4, i64 0, i64 1
%9 = getelementptr inbounds x86_fp80, x86_fp80* %0, i64 1
%10 = load x86_fp80, x86_fp80* %9
store x86_fp80 %10, x86_fp80* %8
%11 = icmp sgt i32 %2, 1
br i1 %11, label %12, label %29
12: ; preds = %3
%13 = add nsw i32 %2, -1
%14 = zext i32 %13 to i64
br label %15
15: ; preds = %12, %15
%16 = phi i64 [ 0, %12 ], [ %20, %15 ]
%17 = phi i32 [ 0, %12 ], [ %25, %15 ]
%18 = getelementptr inbounds x86_fp80*, x86_fp80** %1, i64 %16
%19 = load x86_fp80*, x86_fp80** %18
%20 = add nuw nsw i64 %16, 1
%21 = getelementptr inbounds x86_fp80*, x86_fp80** %1, i64 %20
%22 = load x86_fp80*, x86_fp80** %21
%23 = call i64 @segments_intersect(x86_fp80* %0, x86_fp80* %6, x86_fp80* %19, x86_fp80* %22)
%24 = trunc i64 %23 to i32
%25 = add i32 %17, %24
%26 = icmp eq i64 %20, %14
br i1 %26, label %27, label %15
27: ; preds = %15
%28 = and i32 %25, 1
br label %29
29: ; preds = %27, %3
%30 = phi i32 [ 0, %3 ], [ %28, %27 ]
ret i32 %30
}