#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 get_interval_from_guess(double const *const, int const, double const, int);
int get_interval(const double *const arr, const int N, const double t) {
  double t0 = arr[0];
  double tend = arr[N - 1];
  int i = ((t - t0) / (tend - t0) * N);
  return get_interval_from_guess(arr, N, t, i);
}


x86 assembly (clang, -O0):
<get_interval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
mov    -0x2c(%rbp),%edx
call   1030 <get_interval_from_guess@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_interval>:
movsd  (%rdi),%xmm1
movslq %esi,%rsi
movsd  -0x8(%rdi,%rsi,8),%xmm2
movapd %xmm0,%xmm3
subsd  %xmm1,%xmm3
subsd  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtsi2sd %esi,%xmm1
divsd  %xmm2,%xmm3
mulsd  %xmm3,%xmm1
cvttsd2si %xmm1,%edx
jmp    1030 <get_interval_from_guess@plt>

LLVM IR (-O0):
define i32 @get_interval(double* %0, i32 %1, double %2) {
%4 = alloca double*
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store double* %0, double** %4
store i32 %1, i32* %5
store double %2, double* %6
%10 = load double*, double** %4
%11 = getelementptr inbounds double, double* %10, i64 0
%12 = load double, double* %11
store double %12, double* %7
%13 = load double*, double** %4
%14 = load i32, i32* %5
%15 = sub nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %13, i64 %16
%18 = load double, double* %17
store double %18, double* %8
%19 = load double, double* %6
%20 = load double, double* %7
%21 = fsub double %19, %20
%22 = load double, double* %8
%23 = load double, double* %7
%24 = fsub double %22, %23
%25 = fdiv double %21, %24
%26 = load i32, i32* %5
%27 = sitofp i32 %26 to double
%28 = fmul double %25, %27
%29 = fptosi double %28 to i32
store i32 %29, i32* %9
%30 = load double*, double** %4
%31 = load i32, i32* %5
%32 = load double, double* %6
%33 = load i32, i32* %9
%34 = call i32 @get_interval_from_guess(double* %30, i32 %31, double %32, i32 %33)
ret i32 %34
}

LLVM IR (-O2):
define i32 @get_interval(double* %0, i32 %1, double %2) {
%4 = load double, double* %0
%5 = add nsw i32 %1, -1
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds double, double* %0, i64 %6
%8 = load double, double* %7
%9 = fsub double %2, %4
%10 = fsub double %8, %4
%11 = fdiv double %9, %10
%12 = sitofp i32 %1 to double
%13 = fmul double %11, %12
%14 = fptosi double %13 to i32
%15 = tail call i32 @get_interval_from_guess(double* %0, i32 %1, double %2, i32 %14)
ret i32 %15
}