#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 findInterval(double *, int, double, int, int, int, int *);
void find_interv_vec(double *xt, int *n, double *x, int *nx,
                     int *rightmost_closed, int *all_inside, int *indx) {
  int i, ii, mfl;
  ii = 1;
  for (i = 0; i < *nx; i++) {
    mfl = *all_inside;
    ii = findInterval(xt, *n, x[i], *rightmost_closed, *all_inside, ii, &mfl);
    indx[i] = ii;
  }
}


x86 assembly (clang, -O0):
<find_interv_vec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x1,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    11a9 <find_interv_vec+0x99>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
mov    -0x30(%rbp),%rax
mov    (%rax),%ecx
mov    -0x38(%rbp),%r8d
lea    -0x3c(%rbp),%r9
call   1030 <findInterval@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%edx
mov    0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1142 <find_interv_vec+0x32>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_interv_vec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmpl   $0x0,(%rcx)
jle    117e <find_interv_vec+0x6e>
mov    %r9,%r15
mov    %r8,%r12
mov    %rcx,%rbp
mov    %rsi,%rbx
mov    %rdi,%r13
mov    $0x1,%eax
xor    %r14d,%r14d
mov    %rdx,0x10(%rsp)
nop
mov    (%r15),%ecx
mov    %ecx,0xc(%rsp)
mov    (%rbx),%esi
movsd  (%rdx,%r14,8),%xmm0
mov    (%r12),%edx
mov    %r13,%rdi
mov    %eax,%r8d
lea    0xc(%rsp),%r9
call   1030 <findInterval@plt>
mov    0x10(%rsp),%rdx
mov    0x50(%rsp),%rcx
mov    %eax,(%rcx,%r14,4)
add    $0x1,%r14
movslq 0x0(%rbp),%rcx
cmp    %rcx,%r14
jl     1140 <find_interv_vec+0x30>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @find_interv_vec(double* %0, i32* nocapture %1, double* nocapture %2, i32* nocapture %3, i32* nocapture %4, i32* nocapture %5, i32* nocapture writeonly %6) {
%8 = alloca i32
%9 = bitcast i32* %8 to i8*
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %26
12: ; preds = %7, %12
%13 = phi i64 [ %22, %12 ], [ 0, %7 ]
%14 = phi i32 [ %20, %12 ], [ 1, %7 ]
%15 = load i32, i32* %5
store i32 %15, i32* %8
%16 = load i32, i32* %1
%17 = getelementptr inbounds double, double* %2, i64 %13
%18 = load double, double* %17
%19 = load i32, i32* %4
%20 = call i32 @findInterval(double* %0, i32 %16, double %18, i32 %19, i32 %15, i32 %14, i32* %8)
%21 = getelementptr inbounds i32, i32* %6, i64 %13
store i32 %20, i32* %21
%22 = add nuw nsw i64 %13, 1
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %22, %24
br i1 %25, label %12, label %26
26: ; preds = %12, %7
ret void
}