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


x86 assembly (clang, -O0):
<find_p_indx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    118c <find_p_indx+0x7c>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <isbetween@plt>
cmp    $0x0,%rax
je     1179 <find_p_indx+0x69>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1193 <find_p_indx+0x83>
jmp    117e <find_p_indx+0x6e>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    112a <find_p_indx+0x1a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @find_p_indx(x86_fp80** %0, i32 %1, x86_fp80* %2) {
%4 = alloca i32
%5 = alloca x86_fp80**
%6 = alloca i32
%7 = alloca x86_fp80*
%8 = alloca i32
store x86_fp80** %0, x86_fp80*** %5
store i32 %1, i32* %6
store x86_fp80* %2, x86_fp80** %7
store i32 0, i32* %8
br label %9
9: ; preds = %33, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %6
%12 = sub nsw i32 %11, 1
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %36
14: ; preds = %9
%15 = load x86_fp80**, x86_fp80*** %5
%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*** %5
%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** %7
%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 %32
29: ; preds = %14
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %37
32: ; preds = %14
br label %33
33: ; preds = %32
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %9
36: ; preds = %9
store i32 0, i32* %4
br label %37
37: ; preds = %36, %29
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
define i32 @find_p_indx(x86_fp80** nocapture %0, i32 %1, x86_fp80* %2) {
%4 = add i32 %1, -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 %20, label %10
10: ; preds = %7
%11 = getelementptr inbounds x86_fp80*, x86_fp80** %0, i64 %8
%12 = load x86_fp80*, x86_fp80** %11
%13 = add nuw nsw i64 %8, 1
%14 = getelementptr inbounds x86_fp80*, x86_fp80** %0, i64 %13
%15 = load x86_fp80*, x86_fp80** %14
%16 = tail call i64 @isbetween(x86_fp80* %12, x86_fp80* %15, x86_fp80* %2)
%17 = icmp eq i64 %16, 0
br i1 %17, label %7, label %18
18: ; preds = %10
%19 = trunc i64 %13 to i32
br label %20
20: ; preds = %7, %18
%21 = phi i32 [ %19, %18 ], [ 0, %7 ]
ret i32 %21
}