// File: /workspace/github_c_makefile_star2_O1/PoulinV[P]AxiCLASS/build/../tools/arrays.c
// Function: array_search_bisect
int array_search_bisect(
                        int n_lines,
                        double * __restrict__ array,
                        double c,
                        int * __restrict__ last_index,
                        ErrorMsg errmsg) {

  int inf,sup,mid;

  inf=0;
  sup=n_lines-1;

  if (array[inf] < array[sup]){

    if (c < array[inf]) {
      class_sprintf(errmsg,"%s(L:%d) : c=%e < y_min=%e",__func__,__LINE__,c,array[inf]);
      return _FAILURE_;
    }

    if (c > array[sup]) {
      class_sprintf(errmsg,"%s(L:%d) : c=%e > y_max=%e",__func__,__LINE__,c,array[sup]);
      return _FAILURE_;
    }

    while (sup-inf > 1) {

      mid=(int)(0.5*(inf+sup));
      if (c < array[mid]) {sup=mid;}
      else {inf=mid;}

    }

  }

  else {

    if (c < array[sup]) {
      class_sprintf(errmsg,"%s(L:%d) : x=%e < x_min=%e",__func__,__LINE__,c,array[sup]);
      return _FAILURE_;
    }

    if (c > array[inf]) {
      class_sprintf(errmsg,"%s(L:%d) : x=%e > x_max=%e",__func__,__LINE__,c,array[inf]);
      return _FAILURE_;
    }

    while (sup-inf > 1) {

      mid=(int)(0.5*(inf+sup));
      if (c > array[mid]) {sup=mid;}
      else {inf=mid;}

    }

  }

  *last_index = inf;

  return _SUCCESS_;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rbx
leal -0x1(%rdi), %eax
movsd (%rsi), %xmm2
movslq %edi, %rcx
movsd -0x8(%rsi,%rcx,8), %xmm1
ucomisd %xmm2, %xmm1
jbe 0x18272
ucomisd %xmm0, %xmm2
jbe 0x182c5
leaq 0xdaf68(%rip), %r14     # 0xf3194
leaq 0xdaf7c(%rip), %r15     # 0xf31af
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rdx
movq %r15, %rcx
movl $0x76d, %r8d            # imm = 0x76D
movapd %xmm2, %xmm1
movsd %xmm2, (%rsp)
movb $0x2, %al
movsd %xmm0, 0x8(%rsp)
callq 0x8550
incl %eax
movslq %eax, %rsi
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
movl $0x76d, %r8d            # imm = 0x76D
jmp 0x18367
ucomisd %xmm0, %xmm1
jbe 0x18315
leaq 0xdae8c(%rip), %r14     # 0xf310f
leaq 0xdaf25(%rip), %r15     # 0xf31af
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rdx
movq %r15, %rcx
movl $0x783, %r8d            # imm = 0x783
movb $0x2, %al
movsd %xmm0, 0x8(%rsp)
movsd %xmm1, (%rsp)
callq 0x8550
incl %eax
movslq %eax, %rsi
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
movl $0x783, %r8d            # imm = 0x783
jmp 0x18367
ucomisd %xmm1, %xmm0
jbe 0x18383
leaq 0xdaeed(%rip), %r14     # 0xf31c3
leaq 0xdaed2(%rip), %r15     # 0xf31af
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rdx
movq %r15, %rcx
movl $0x772, %r8d            # imm = 0x772
movb $0x2, %al
movsd %xmm0, 0x8(%rsp)
movsd %xmm1, (%rsp)
callq 0x8550
incl %eax
movslq %eax, %rsi
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
movl $0x772, %r8d            # imm = 0x772
jmp 0x18367
ucomisd %xmm2, %xmm0
jbe 0x183c6
leaq 0xdae16(%rip), %r14     # 0xf313c
leaq 0xdae82(%rip), %r15     # 0xf31af
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rdx
movq %r15, %rcx
movl $0x788, %r8d            # imm = 0x788
movapd %xmm2, %xmm1
movsd %xmm2, (%rsp)
movb $0x2, %al
movsd %xmm0, 0x8(%rsp)
callq 0x8550
incl %eax
movslq %eax, %rsi
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
movl $0x788, %r8d            # imm = 0x788
movsd 0x8(%rsp), %xmm0
movsd (%rsp), %xmm1
movb $0x2, %al
callq 0x8550
movl $0x1, %eax
jmp 0x1840b
cmpl $0x3, %edi
jl 0x18405
xorl %edi, %edi
movsd 0xd993e(%rip), %xmm2    # 0xf1cd0
leal (%rdi,%rax), %ecx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %ecx
movslq %ecx, %rcx
movsd (%rsi,%rcx,8), %xmm1
ucomisd %xmm0, %xmm1
cmoval %ecx, %eax
cmoval %edi, %ecx
movl %eax, %r8d
subl %ecx, %r8d
movl %ecx, %edi
cmpl $0x1, %r8d
jg 0x18392
jmp 0x18407
cmpl $0x3, %edi
jl 0x18405
xorl %edi, %edi
movsd 0xd98fb(%rip), %xmm2    # 0xf1cd0
leal (%rdi,%rax), %ecx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %ecx
movslq %ecx, %rcx
ucomisd (%rsi,%rcx,8), %xmm0
cmoval %ecx, %eax
cmoval %edi, %ecx
movl %eax, %r8d
subl %ecx, %r8d
movl %ecx, %edi
cmpl $0x1, %r8d
jg 0x183d5
jmp 0x18407
xorl %ecx, %ecx
movl %ecx, (%rdx)
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq