#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__ isbetween(long double *, long double *, long double *);
int is_on_bound(long double *p, long double **bound, int N) {
  int i;
  for (i = 0; i < (N - 1); i++)
    if (isbetween(bound[i], bound[i + 1], p))
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<is_on_bound>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    118a <is_on_bound+0x7a>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <isbetween@plt>
cmp    $0x0,%rax
je     1177 <is_on_bound+0x67>
movl   $0x1,-0x4(%rbp)
jmp    1191 <is_on_bound+0x81>
jmp    117c <is_on_bound+0x6c>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112a <is_on_bound+0x1a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_on_bound>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %edx,%r15d
mov    %rsi,%r13
mov    %rdi,%r12
add    $0xffffffff,%r15d
xor    %r14d,%r14d
test   %r15d,%r15d
cmovle %r14d,%r15d
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %rcx,%r15
je     1169 <is_on_bound+0x59>
lea    0x1(%rcx),%rbx
mov    0x0(%r13,%rcx,8),%rdi
mov    0x8(%r13,%rcx,8),%rsi
mov    %r12,%rdx
call   1030 <isbetween@plt>
mov    %rbx,%rcx
test   %rax,%rax
je     1140 <is_on_bound+0x30>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @is_on_bound(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
store x86_fp80* %0, x86_fp80** %5
store x86_fp80** %1, x86_fp80*** %6
store i32 %2, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %31, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %7
%12 = sub nsw i32 %11, 1
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %34
14: ; preds = %9
%15 = load x86_fp80**, x86_fp80*** %6
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds x86_fp80*, x86_fp80** %15, i64 %17
%19 = load x86_fp80*, x86_fp80** %18
%20 = load x86_fp80**, x86_fp80*** %6
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds x86_fp80*, x86_fp80** %20, i64 %23
%25 = load x86_fp80*, x86_fp80** %24
%26 = load x86_fp80*, x86_fp80** %5
%27 = call i64 @isbetween(x86_fp80* %19, x86_fp80* %25, x86_fp80* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %14
store i32 1, i32* %4
br label %35
30: ; preds = %14
br label %31
31: ; preds = %30
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
br label %9
34: ; preds = %9
store i32 0, i32* %4
br label %35
35: ; preds = %34, %29
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
define i32 @is_on_bound(x86_fp80* %0, x86_fp80** nocapture %1, i32 %2) {
%4 = add i32 %2, -1
%5 = call i32 @llvm.smax.i32(i32 %4, i32 0)
%6 = zext i32 %5 to i64
br label %7
7: ; preds = %10, %3
%8 = phi i64 [ %13, %10 ], [ 0, %3 ]
%9 = icmp eq i64 %8, %6
br i1 %9, label %18, label %10
10: ; preds = %7
%11 = getelementptr inbounds x86_fp80*, x86_fp80** %1, i64 %8
%12 = load x86_fp80*, x86_fp80** %11
%13 = add nuw nsw i64 %8, 1
%14 = getelementptr inbounds x86_fp80*, x86_fp80** %1, i64 %13
%15 = load x86_fp80*, x86_fp80** %14
%16 = tail call i64 @isbetween(x86_fp80* %12, x86_fp80* %15, x86_fp80* %0)
%17 = icmp eq i64 %16, 0
br i1 %17, label %7, label %18
18: ; preds = %7, %10
%19 = phi i32 [ 1, %10 ], [ 0, %7 ]
ret i32 %19
}