#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 haversine_distance(long double *, long double *);
int _nvp_to_close(long double *d, long double *t_c, long double *vel,
                  long double dV, long double **nvp, long double *l_nvp, int *j,
                  int n_nvp, long double *time, long double t) {
  if (*d >= *l_nvp) {
    *t_c = *t_c - *l_nvp / (vel[*j] * (1. + dV));
    (*j) = *j + 1;
    if ((*j + 1) > (n_nvp - 1)) {
      return (0);
    }
    time[*j] = t - *t_c;
    *d = (vel[*j] * (1. + dV)) * (*t_c);
    *l_nvp = haversine_distance(nvp[*j], nvp[*j + 1]);
    return _nvp_to_close(d, t_c, vel, dV, nvp, l_nvp, j, n_nvp, time, t);
  } else
    return 1;
}


x86 assembly (clang, -O0):
<_nvp_to_close>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
fldt   0x30(%rbp)
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%eax
fldt   0x10(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
fstpt  -0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %r8,-0x40(%rbp)
mov    %r9,-0x48(%rbp)
fstpt  -0x60(%rbp)
mov    -0x10(%rbp),%rax
fldt   (%rax)
mov    -0x40(%rbp),%rax
fldt   (%rax)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jb     127a <_nvp_to_close+0x15a>
jmp    1173 <_nvp_to_close+0x53>
mov    -0x18(%rbp),%rax
fldt   (%rax)
mov    -0x40(%rbp),%rcx
fldt   (%rcx)
mov    -0x20(%rbp),%rcx
mov    -0x48(%rbp),%rdx
movslq (%rdx),%rdx
shl    $0x4,%rdx
fldt   (%rcx,%rdx,1)
fldt   -0x30(%rbp)
fld1
faddp  %st,%st(1)
fmulp  %st,%st(1)
fdivrp %st,%st(1)
fsubrp %st,%st(1)
fstpt  (%rax)
mov    -0x48(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    0x20(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jle    11d2 <_nvp_to_close+0xb2>
movl   $0x0,-0x4(%rbp)
jmp    1281 <_nvp_to_close+0x161>
fldt   -0x60(%rbp)
mov    -0x18(%rbp),%rax
fldt   (%rax)
fsubrp %st,%st(1)
mov    0x28(%rbp),%rax
mov    -0x48(%rbp),%rcx
movslq (%rcx),%rcx
shl    $0x4,%rcx
fstpt  (%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    -0x48(%rbp),%rcx
movslq (%rcx),%rcx
shl    $0x4,%rcx
fldt   (%rax,%rcx,1)
fldt   -0x30(%rbp)
fld1
faddp  %st,%st(1)
fmulp  %st,%st(1)
mov    -0x18(%rbp),%rax
fldt   (%rax)
fmulp  %st,%st(1)
mov    -0x10(%rbp),%rax
fstpt  (%rax)
mov    -0x38(%rbp),%rax
mov    -0x48(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x8(%rax,%rcx,8),%rsi
call   1030 <haversine_distance@plt>
mov    -0x40(%rbp),%rax
fstpt  (%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
fldt   -0x30(%rbp)
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
mov    -0x48(%rbp),%r9
mov    0x20(%rbp),%r10d
mov    0x28(%rbp),%r11
fldt   -0x60(%rbp)
mov    %rsp,%rax
fstpt  0x20(%rax)
mov    %r11,0x18(%rax)
mov    %r10d,0x10(%rax)
fstpt  (%rax)
call   1040 <_nvp_to_close@plt>
mov    %eax,-0x4(%rbp)
jmp    1281 <_nvp_to_close+0x161>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_nvp_to_close>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
fldt   0x70(%rsp)
fstpt  0xc(%rsp)
fldt   0x50(%rsp)
fldt   (%rdi)
fldt   (%r8)
mov    $0x1,%eax
fxch   %st(1)
fucomip %st(1),%st
jae    1143 <_nvp_to_close+0x33>
fstp   %st(0)
fstp   %st(0)
jmp    11dc <_nvp_to_close+0xcc>
mov    %r9,%r13
mov    %r8,%r15
mov    %rcx,%r12
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    %rdi,%r14
fld1
faddp  %st,%st(2)
fld    %st(1)
fstpt  (%rsp)
xchg   %ax,%ax
fldt   (%rbx)
movslq 0x0(%r13),%rax
mov    %rax,%rcx
shl    $0x4,%rcx
fldt   0x0(%rbp,%rcx,1)
fmul   %st(3),%st
fdivrp %st,%st(2)
fsubp  %st,%st(1)
fld    %st(0)
fstpt  (%rbx)
lea    0x1(%rax),%rcx
mov    %ecx,0x0(%r13)
lea    0x2(%rax),%edx
cmp    0x60(%rsp),%edx
jge    11d6 <_nvp_to_close+0xc6>
fldt   0xc(%rsp)
fsubp  %st,%st(1)
shl    $0x4,%rcx
mov    0x68(%rsp),%rdx
fstpt  (%rdx,%rcx,1)
fldt   0x0(%rbp,%rcx,1)
fmulp  %st,%st(1)
fldt   (%rbx)
fmulp  %st,%st(1)
fstpt  (%r14)
mov    0x8(%r12,%rax,8),%rdi
mov    0x10(%r12,%rax,8),%rsi
call   1030 <haversine_distance@plt>
fldt   (%rsp)
fld    %st(1)
fstpt  (%r15)
fldt   (%r14)
fucomip %st(2),%st
fxch   %st(1)
jae    1160 <_nvp_to_close+0x50>
fstp   %st(0)
fstp   %st(0)
mov    $0x1,%eax
jmp    11dc <_nvp_to_close+0xcc>
fstp   %st(0)
fstp   %st(0)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @_nvp_to_close(x86_fp80* %0, x86_fp80* %1, x86_fp80* %2, x86_fp80 %3, x86_fp80** %4, x86_fp80* %5, i32* %6, i32 %7, x86_fp80* %8, x86_fp80 %9) {
%11 = alloca i32
%12 = alloca x86_fp80*
%13 = alloca x86_fp80*
%14 = alloca x86_fp80*
%15 = alloca x86_fp80
%16 = alloca x86_fp80**
%17 = alloca x86_fp80*
%18 = alloca i32*
%19 = alloca i32
%20 = alloca x86_fp80*
%21 = alloca x86_fp80
store x86_fp80* %0, x86_fp80** %12
store x86_fp80* %1, x86_fp80** %13
store x86_fp80* %2, x86_fp80** %14
store x86_fp80 %3, x86_fp80* %15
store x86_fp80** %4, x86_fp80*** %16
store x86_fp80* %5, x86_fp80** %17
store i32* %6, i32** %18
store i32 %7, i32* %19
store x86_fp80* %8, x86_fp80** %20
store x86_fp80 %9, x86_fp80* %21
%22 = load x86_fp80*, x86_fp80** %12
%23 = load x86_fp80, x86_fp80* %22
%24 = load x86_fp80*, x86_fp80** %17
%25 = load x86_fp80, x86_fp80* %24
%26 = fcmp oge x86_fp80 %23, %25
br i1 %26, label %27, label %104
27: ; preds = %10
%28 = load x86_fp80*, x86_fp80** %13
%29 = load x86_fp80, x86_fp80* %28
%30 = load x86_fp80*, x86_fp80** %17
%31 = load x86_fp80, x86_fp80* %30
%32 = load x86_fp80*, x86_fp80** %14
%33 = load i32*, i32** %18
%34 = load i32, i32* %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds x86_fp80, x86_fp80* %32, i64 %35
%37 = load x86_fp80, x86_fp80* %36
%38 = load x86_fp80, x86_fp80* %15
%39 = fadd x86_fp80 0xK3FFF8000000000000000, %38
%40 = fmul x86_fp80 %37, %39
%41 = fdiv x86_fp80 %31, %40
%42 = fsub x86_fp80 %29, %41
%43 = load x86_fp80*, x86_fp80** %13
store x86_fp80 %42, x86_fp80* %43
%44 = load i32*, i32** %18
%45 = load i32, i32* %44
%46 = add nsw i32 %45, 1
%47 = load i32*, i32** %18
store i32 %46, i32* %47
%48 = load i32*, i32** %18
%49 = load i32, i32* %48
%50 = add nsw i32 %49, 1
%51 = load i32, i32* %19
%52 = sub nsw i32 %51, 1
%53 = icmp sgt i32 %50, %52
br i1 %53, label %54, label %55
54: ; preds = %27
store i32 0, i32* %11
br label %105
55: ; preds = %27
%56 = load x86_fp80, x86_fp80* %21
%57 = load x86_fp80*, x86_fp80** %13
%58 = load x86_fp80, x86_fp80* %57
%59 = fsub x86_fp80 %56, %58
%60 = load x86_fp80*, x86_fp80** %20
%61 = load i32*, i32** %18
%62 = load i32, i32* %61
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds x86_fp80, x86_fp80* %60, i64 %63
store x86_fp80 %59, x86_fp80* %64
%65 = load x86_fp80*, x86_fp80** %14
%66 = load i32*, i32** %18
%67 = load i32, i32* %66
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds x86_fp80, x86_fp80* %65, i64 %68
%70 = load x86_fp80, x86_fp80* %69
%71 = load x86_fp80, x86_fp80* %15
%72 = fadd x86_fp80 0xK3FFF8000000000000000, %71
%73 = fmul x86_fp80 %70, %72
%74 = load x86_fp80*, x86_fp80** %13
%75 = load x86_fp80, x86_fp80* %74
%76 = fmul x86_fp80 %73, %75
%77 = load x86_fp80*, x86_fp80** %12
store x86_fp80 %76, x86_fp80* %77
%78 = load x86_fp80**, x86_fp80*** %16
%79 = load i32*, i32** %18
%80 = load i32, i32* %79
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds x86_fp80*, x86_fp80** %78, i64 %81
%83 = load x86_fp80*, x86_fp80** %82
%84 = load x86_fp80**, x86_fp80*** %16
%85 = load i32*, i32** %18
%86 = load i32, i32* %85
%87 = add nsw i32 %86, 1
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds x86_fp80*, x86_fp80** %84, i64 %88
%90 = load x86_fp80*, x86_fp80** %89
%91 = call x86_fp80 @haversine_distance(x86_fp80* %83, x86_fp80* %90)
%92 = load x86_fp80*, x86_fp80** %17
store x86_fp80 %91, x86_fp80* %92
%93 = load x86_fp80*, x86_fp80** %12
%94 = load x86_fp80*, x86_fp80** %13
%95 = load x86_fp80*, x86_fp80** %14
%96 = load x86_fp80, x86_fp80* %15
%97 = load x86_fp80**, x86_fp80*** %16
%98 = load x86_fp80*, x86_fp80** %17
%99 = load i32*, i32** %18
%100 = load i32, i32* %19
%101 = load x86_fp80*, x86_fp80** %20
%102 = load x86_fp80, x86_fp80* %21
%103 = call i32 @_nvp_to_close(x86_fp80* %93, x86_fp80* %94, x86_fp80* %95, x86_fp80 %96, x86_fp80** %97, x86_fp80* %98, i32* %99, i32 %100, x86_fp80* %101, x86_fp80 %102)
store i32 %103, i32* %11
br label %105
104: ; preds = %10
store i32 1, i32* %11
br label %105
105: ; preds = %104, %55, %54
%106 = load i32, i32* %11
ret i32 %106
}

LLVM IR (-O2):
define i32 @_nvp_to_close(x86_fp80* nocapture %0, x86_fp80* nocapture %1, x86_fp80* nocapture %2, x86_fp80 %3, x86_fp80** nocapture %4, x86_fp80* nocapture %5, i32* nocapture %6, i32 %7, x86_fp80* nocapture writeonly %8, x86_fp80 %9) {
%11 = load x86_fp80, x86_fp80* %0
%12 = load x86_fp80, x86_fp80* %5
%13 = fcmp ult x86_fp80 %11, %12
br i1 %13, label %46, label %14
14: ; preds = %10
%15 = fadd x86_fp80 %3, 0xK3FFF8000000000000000
br label %16
16: ; preds = %14, %29
%17 = phi x86_fp80 [ %12, %14 ], [ %43, %29 ]
%18 = load x86_fp80, x86_fp80* %1
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds x86_fp80, x86_fp80* %2, i64 %20
%22 = load x86_fp80, x86_fp80* %21
%23 = fmul x86_fp80 %15, %22
%24 = fdiv x86_fp80 %17, %23
%25 = fsub x86_fp80 %18, %24
store x86_fp80 %25, x86_fp80* %1
%26 = add nsw i32 %19, 1
store i32 %26, i32* %6
%27 = add nsw i32 %19, 2
%28 = icmp slt i32 %27, %7
br i1 %28, label %29, label %46
29: ; preds = %16
%30 = fsub x86_fp80 %9, %25
%31 = sext i32 %26 to i64
%32 = getelementptr inbounds x86_fp80, x86_fp80* %8, i64 %31
store x86_fp80 %30, x86_fp80* %32
%33 = getelementptr inbounds x86_fp80, x86_fp80* %2, i64 %31
%34 = load x86_fp80, x86_fp80* %33
%35 = fmul x86_fp80 %15, %34
%36 = load x86_fp80, x86_fp80* %1
%37 = fmul x86_fp80 %35, %36
store x86_fp80 %37, x86_fp80* %0
%38 = getelementptr inbounds x86_fp80*, x86_fp80** %4, i64 %31
%39 = load x86_fp80*, x86_fp80** %38
%40 = sext i32 %27 to i64
%41 = getelementptr inbounds x86_fp80*, x86_fp80** %4, i64 %40
%42 = load x86_fp80*, x86_fp80** %41
%43 = tail call x86_fp80 @haversine_distance(x86_fp80* %39, x86_fp80* %42)
store x86_fp80 %43, x86_fp80* %5
%44 = load x86_fp80, x86_fp80* %0
%45 = fcmp ult x86_fp80 %44, %43
br i1 %45, label %46, label %16
46: ; preds = %16, %29, %10
%47 = phi i32 [ 1, %10 ], [ 1, %29 ], [ 0, %16 ]
ret i32 %47
}